<?php

use Illuminate\Http\Request;
use App\Jobs\UpdateProductSizeTags;
//use App\Http\Controllers\BrandPaymentMethodController;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::middleware('auth:api')->get('/user', function (Request $request) {
    return $request->user();
});

Route::get('order/{domain}/import_shopify_orders', 'SalesOrderController@import_orders');

Route::post('shopify-webhook/create-order', 'ShopifyWebhook@create_order');
Route::post('shopify-webhook/delete-order', 'ShopifyWebhook@delete_order');
Route::post('shopify-webhook/cancel-order', 'ShopifyWebhook@cancel_order');
Route::post('shopify-webhook/fulfil-order', 'ShopifyWebhook@fulfil_order');
Route::post('shopify-webhook/otp-order', 'ShopifyWebhook@otp_order');
Route::post('shopify-webhook/update-order/tags', 'ShopifyWebhook@update_order_tags');

Route::get('order/sms_verification/validate/{order_id}/{email}', 'SmsVerificationController@order_sms_verification_validate');
Route::get('order/sms_verification/resend_otp/{order_id}/{email}', 'SmsVerificationController@order_sms_verification_resend_otp');
Route::get('order/sms_verification/verify_otp/{order_id}/{email}/{otp}', 'SmsVerificationController@order_sms_verification_verify_otp');

Route::get('order/track_order/{order_name}/{domain}', 'ApiController@track_order');

Route::get('products/fetch_all', 'ProductController@fetch_all');
Route::get('products/update/size_filter', 'ProductController@index_size_filter');
Route::get('products/update/size_tags', 'ProductController@update_size_tags');

// Helper Routes
Route::get('fetch-and-store-order-product-images/{order_id}/{product_id}', 'HelperController@fetch_and_store_order_product_images');
Route::get('update-missing-order-product-images', 'HelperController@update_missing_order_product_images');

Route::group(['prefix' => 'factoryoutlet'], function () {
    Route::post('fol_ivr', 'FactoryOutletController@fol_ivr');
    Route::get('fol_ivr_call_back', 'FactoryOutletController@fol_ivr_call_back');
});

Route::post('ivr/yves_ivr', 'IvrController@yves_ivr');
Route::post('ivr/sf_ivr', 'IvrController@sf_ivr');
Route::post('ivr/gcc_ivr', 'IvrController@gcc_ivr');
Route::get('ivr/ivr_tav_return', 'IvrController@ivr_tav_return');

Route::post('ivr/kayseria', 'IvrController@kayseria_ivr');
Route::get('ivr/ivr_kayseria_return', 'IvrController@ivr_kayseria_return');

// rest of brands bin
Route::get('payment_method', 'BrandPaymentMethodController@index');
Route::get('payment_redirect', 'BrandPaymentMethodController@redirect');

// qurbani express bin
Route::get('payment_method_express', 'BrandPaymentMethodController@payment_method_express');
Route::get('alfala_payment_method_express','NewBrandPaymentMethodController@alfala_payment_method_express');

Route::get('credit_card', 'BrandPaymentMethodController@cc');

Route::post('credit_card_post', 'BrandPaymentMethodController@cc_post');

Route::get('bin_numbers', 'BrandPaymentMethodController@get_bin_number');
Route::post('bin_order_post', 'BrandPaymentMethodController@bin_order_post');

//qurbani express bin post
Route::post('qurbani_bin_order_post', 'BrandPaymentMethodController@qurbani_bin_order_post');
Route::post('qurbani_bin_order_post_new', 'NewBrandPaymentMethodController@test_qurbani_bin_order_post');


Route::get('test_transaction', 'BrandPaymentMethodController@test_transaction');
Route::get('test_transaction_old', 'BrandPaymentMethodController@test_transaction_old');
Route::get('test_transaction_only', 'BrandPaymentMethodController@test_transaction_only');

Route::get('testinghttp', function(){
    // shopify_update_order('https://5b8d38dc0b216f929b7394784e486ba9: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@yves-rocher-pakistan.myshopify.com', '3087295643806', '{ "order": { "id": "3087295643806", "tags": "Canceled" } }');
    // shopify_update_order('https://5b8d38dc0b216f929b7394784e486ba9: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@yves-rocher-pakistan.myshopify.com', '3087295643806', '{ "order": { "id": "3087295643806", "note": "Order marked Canceled" } }');
    // shopify_cancel_order('https://5b8d38dc0b216f929b7394784e486ba9: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@yves-rocher-pakistan.myshopify.com', '3087295643806', '{ "restock": "true" }');    
    // shopify_create_transactions('https://5b8d38dc0b216f929b7394784e486ba9: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@yves-rocher-pakistan.myshopify.com', '3087295643806', '{ "transaction": { "kind": "void" } }');
    // shopify_get_orders('https://5b8d38dc0b216f929b7394784e486ba9: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@yves-rocher-pakistan.myshopify.com');
    // shopify_get_order('https://5b8d38dc0b216f929b7394784e486ba9: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@yves-rocher-pakistan.myshopify.com', '3087295643806');
    // shopify_get_variant('https://320425eaf44a5010f0fde6210bfad306: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@super-feet-pakistan.myshopify.com', '37970541740215');
    // shopify_get_product_images('https://320425eaf44a5010f0fde6210bfad306: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@super-feet-pakistan.myshopify.com', '6087057506487');
    // shopify_get_product('https://c13028116191e460a288edec2773decf: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@get-cotton-candy.myshopify.com', '6114310324389');
});

Route::get('stock_sync_update_queue', 'StockSyncController@stock_sync_update_queue');
Route::get('stock_sync_update_queue_new', 'StockSyncController@stock_sync_update_queue');
Route::get('stock_sync_via_brand_update_queue/{id}', 'StockSyncController@stock_sync_via_brand_update_queue');

Route::get('stock_sync_update_queue_retry', 'StockSyncController@stock_sync_update_queue_retry');
Route::get('process_collection_add_queue', 'ProductController@process_collection_add_queue');
Route::get('process_collection_product_tag_queue', 'ProductController@process_collection_product_tag_queue');
Route::get('process_attribute_product_tag_update_queue', 'ProductController@update_product_tag_update_queue');
Route::get('variant_addition_queue', 'ProductController@variant_addition_queue');
Route::get('retail_pro_update_queue', 'RetailProController@retail_pro_update_queue');
Route::get('product_update_tool_update_queue', 'ProductController@product_update_tool_update_queue');
Route::get('product_template_update_queue', 'ProductController@product_template_update_queue');
Route::get('product_meta_update_queue', 'ProductController@product_meta_update_queue');
Route::get('retail_pro_sync/{brand_id}/{location_id}', 'RetailProController@run_sync');
Route::get('ivr_queue', 'IvrController@ivr_queue');
Route::get('product_size_filter_reindex_queue', 'IndexManagementController@product_size_filter_reindex_queue');
Route::get('product_price_filter_reindex_queue', 'IndexManagementController@product_price_filter_reindex_queue');

Route::get('get_orders_tags/{id}/{name}', 'SalesOrderController@get_orders_tags');

Route::get('paid_orders_email_link_validate/{id}', 'SalesOrderController@paid_orders_email_link_validate');
Route::get('paid_orders_email_link_validate_by_name/{id}', 'SalesOrderController@paid_orders_email_link_validate_by_name');

Route::get('order_sms_on_ivr_verified_yv', 'IvrController@order_sms_on_ivr_verified_yv');
Route::get('order_sms_on_ivr_verified_sf', 'IvrController@order_sms_on_ivr_verified_sf');

Route::get('get_orders_api/{brand_id}/{order_id}','OrderAPIController@getOrders');

Route::get('testing_sms', function(Request $request){
    $phone_number = '03129699337';

    $customer = 'Test 1';

    $message = 'Dear '.$customer.'! Thank you for the online order '.$request->name.'. Your order should be delivered in 2 to 3 working days. For any assistance, please contact us at 021-111-221-331';

    $ch = curl_init('https://bsms.its.com.pk/api.php?key=4c9848c340e68d6cbbda0c0dad771fd8&receiver='.$phone_number.'&sender=SUPERFEET&msgdata='.urlencode($message));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $result = curl_exec($ch);
    curl_close($ch);

    dd($result);
});



https://connector.ecompk.com/

Route::get('fetch_custom_order', 'ApiController@fetch_custom_order');

Route::get('fetch_custom_order_shipped', 'ApiController@fetch_custom_order_shipped');
Route::post('fetch_custom_order_shipped_post', 'ApiController@fetch_custom_order_shipped_post');

Route::get('connector_update_order', 'ApiController@connector_update_order');

Route::get('ivr_logs', function(){
    $var = DB::table('ivr_logs')->orderBy('id', 'DESC')->first();
    dd($var);
});

Route::get('kayseria/check-for-emp-coupon/{id}', 'ApiController@kayseria_check_for_emp_coupon');
Route::get('missing-order-cron/{id}', 'ApiController@missing_orders_cron');
Route::get('missing-order-cron-import', 'ApiController@missing_order_cron_import');

Route::get('check-ent-sms', function(){
    $sms_content = "this is test sms";

    $ch = curl_init('https://telenorcsms.com.pk:27677/corporate_sms2/api/sendsms.jsp?session_id=d3c51d97dd524cd6be1ad7d0b515dfbc&to=923122132444&text='.urlencode($sms_content).'&mask=Alkaram');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $result = curl_exec($ch);
    curl_close($ch);

    dd($result);
});

Route::get('fetch_missing_items', 'ApiController@fetch_missing_items');
