<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
 */

use Illuminate\Support\Facades\Route;

Route::group(['prefix' => 'print-suppliers'], function () {

    Route::get('/', [ 'as' => 'print-suppliers::home', 'uses' => 'HomeController@index', ]);
    Route::group(['prefix' => 'cron'], function () {
        Route::any('/webhook', ['uses' => 'CronController@webhook', 'as' => 'print-suppliers::cron::webhook']);
    });
    Route::group(['prefix' => 'report'], function () {
        Route::get('/stuck-autoff', [ 'as' => 'print-suppliers::home', 'uses' => 'HomeController@stuckAutoFF', ]);
        Route::any('/print-profiles', ['uses' => 'ReportController@reportPrintProfiles']);
    });

    Route::get('/supplier/{supplier_slug}', [ 'uses' => 'SupplierController@supplierIndexFactory', ]);
    Route::any('/supplier/{supplier_slug}/{action}', [ 'uses' => 'SupplierController@supplierIndexFactory', ]);

    Route::post('/webhook/printify', [ 'as' => 'print-suppliers::webhook::printify', 'uses' => 'PrintifyController@printifyWebhook']);

    /** REPORT */
    Route::get('/report/printify', [ 'as' => 'print-suppliers::report::printify', 'uses' => 'ReportController@printifyReport' ]);
    Route::get('/transaction/printify', [ 'as' => 'print-suppliers::transaction::printify', 'uses' => 'ReportController@printifyPaymentTransaction' ]);
    Route::get('/report/gelato', [ 'as' => 'print-suppliers::report::gelato', 'uses' => 'ReportController@gelatoReport' ]);
    Route::get('/transaction/gelato', [ 'as' => 'print-suppliers::transaction::gelato', 'uses' => 'ReportController@gelatoPaymentTransaction' ]);

    Route::post('/get-profile', [ 'as' => 'print-suppliers::pofile::find', 'uses' => 'ProfileController@find', ]);
    Route::post('/profile', [ 'as' => 'print-suppliers::pofile::save', 'uses' => 'ProfileController@save', ]);

    Route::post('/fulfill/log', [ 'as' => 'print-suppliers::fulfill::log', 'uses' => 'ProfileController@logFulfill']);
    Route::post('/fulfill/attach-order-meta', [ 'as' => 'print-suppliers::fulfill::log', 'uses' => 'ProfileController@attachOrderMeta']);
    Route::get('/fulfill/order', [ 'as' => 'print-suppliers::fulfill::order', 'uses' => 'SupplierController@postFulfill']);

    Route::get('/zipcode', [ 'as' => 'print-suppliers::zipcode::find', 'uses' => 'ProfileController@loadZipcode', ]);
    Route::post('/zipcode', [ 'as' => 'print-suppliers::zipcode::store', 'uses' => 'ProfileController@saveZipcode', ]);

    Route::get('/framed-image', [ 'as' => 'print-suppliers::framed::image', 'uses' => 'HomeController@locateImageToFrame', ]);
    Route::get('/cron-update-cost', [ 'as' => 'print-suppliers::cron-update-cost', 'uses' => 'HomeController@cronUpdateOrderMatching', ]);

    Route::get('/test', 'PrintifyController@test');
    Route::get('/{productSkuId}/template', 'PrintifyController@getTemplate');
    Route::get('/{productSkuId}/template/gelato', 'PrintifyController@getTemplateGelato');
    Route::get('/{productSkuId}/resolution', 'PrintifyController@getResolution');
    Route::get('/blueprints.json', 'PrintifyTemplate@blueprints');
    Route::get('/blueprint/{blueprintId}.json', 'PrintifyTemplate@blueprint');
    Route::get('/blueprints/{blueprintId}/print_providers/{printProviderId}/shipping.json', 'PrintifyTemplate@shipping');
    Route::get('/print_providers.json', 'PrintifyTemplate@print_providers');
    Route::get('/print_providers/{id}.json', 'PrintifyTemplate@index');
    Route::get('/print_providers_with_variants/{id}.json', 'PrintifyTemplate@printProvidersWithVariants');
    Route::get('/template', 'HomeController@indexTemplate');
    Route::get('/template/auto', 'HomeController@autoAllTemplates');
    Route::get('/template/enable', 'HomeController@enableAllTemplates');
    Route::get('/template/auto-resolution', 'HomeController@autoResolution');

    Route::get('/template/printify', 'PrintifyTemplate@template');
    Route::get('/template/gelato', 'GelatoTemplate@template');
    Route::get('/template/merchize', 'MerchizeTemplate@template');
    Route::get('/v2/templates/{orderId}', 'PrintifyController@getTemplates');
    Route::get('/v2/autofulfill/{orderId}', 'PrintifyController@autoFulfillOrder');
    Route::get('/templates/print-logistic/{orderId}', 'PrintLogisticController@getTemplates');

    Route::get('/autofulfill/printify', 'PrintifyController@autoFulfill');

    Route::get('/template/{id}', 'HomeController@editTemplate');
    Route::put('/template/{template}', 'HomeController@updateTemplate');
    Route::get('/template/{template}/auto', 'HomeController@autoTemplate');
    Route::get('/template/{template}/toggle', 'HomeController@toggleTemplate');

    Route::any('/get-product-attrs', ['uses' => 'Controller@getProductAttrs']);
    Route::any('/get-fulfill-sku-attrs', ['uses' => 'Controller@getFulfillSkuAttrs']);

    Route::any('/portal/get-stuck-order', ['uses' => 'ReportController@reportStuckOrders']);

    Route::get('/resize-design', 'Controller@showResizeTool')->middleware('auth');
    Route::post('/resize-design', 'Controller@resizeDesign');
    Route::get('/auto-mockup', 'Controller@showAutoMockupTool')->middleware('auth');

    Route::get('/update-profile-product-id', 'ProfileController@updateProductId');
    Route::any('/simulate-get-fulfill-design', 'Controller@simulateGetFulfillDesign');

    Route::get('/tool-update-order-info', 'Controller@updateTool');
    Route::get('/proxy-api', 'PrintifyController@proxyAPI');
    Route::post('/proxy-post-api', 'PrintifyController@proxyPOSTAPI');

    Route::get('/transaction/printify/store', [
        'as' => 'print-suppliers::transaction::printify:history',
        'uses' => 'TransactionController@transactionPrintify'
    ]);

    Route::get('/transaction/merchize/store', [
        'as' => 'print-suppliers::transaction::merchize:history',
        'uses' => 'TransactionController@merchizeTransaction'
    ]);

    Route::get('/transaction/gelato/store', [
        'as' => 'print-suppliers::transaction::transactionGelato:history',
        'uses' => 'TransactionController@transactionGelato'
    ]);

    Route::get('/transaction/yiwang/store', [
        'as' => 'print-suppliers::transaction::transactionYiwang:history',
        'uses' => 'TransactionController@transactionYiwang'
    ]);

    Route::get('/transaction/luxury-pro/store', [
        'as' => 'print-suppliers::transaction::transactionLuxuryPro:history',
        'uses' => 'TransactionController@transactionLuxuryPro'
    ]);

    Route::get('/transaction/chrisx/store', [
        'as' => 'print-suppliers::transaction::transactionChrisX:history',
        'uses' => 'TransactionController@transactionChrisX'
    ]);
    Route::get('/transaction/printlogictics/store', [
        'as' => 'print-suppliers::transaction::transactionPrintLogictics:history',
        'uses' => 'TransactionController@transactionPrintLogictics'
    ]);

    Route::get('/transaction/tezzily/store', [
        'as' => 'print-suppliers::transaction::transactionTezzily:history',
        'uses' => 'TransactionController@transactionTezzily'
    ]);

    Route::get('/transaction/yoycol/store', [
        'as' => 'print-suppliers::transaction::transactionYoycol:history',
        'uses' => 'TransactionController@transactionYoycol'
    ]);

    Route::get('/transaction/toaddit/store', [
        'as' => 'print-suppliers::transaction::transactionToaddit:history',
        'uses' => 'TransactionController@transactionToaddit'
    ]);
    Route::get('/transaction/customcat/store', [
        'as' => 'print-suppliers::transaction::transactionCustomCat:history',
        'uses' => 'TransactionController@transactionCustomCat'
    ]);



    //@todo auth
    Route::get('/report/cost', [
        'as' => 'print-suppliers::report-cost::report',
        'uses' => 'ReportCostController@report'
    ]);

});
