<?php

use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\Route;
use TPS\Birzha\Classes\SMPP;
use TPS\Birzha\Classes\SmsBuilder;

// use October\Rain\Network\Http;
// use October\Rain\Support\Facades\Http as FacadesHttp;
// use Http;
use System\Classes\MailManager;
use System\Models\MailLayout;
use System\Models\MailTemplate;

Route::namespace('TPS\Birzha\Controllers')->group(function () {

    Route::prefix('api')->group(function (){
        // api version
        Route::get('version', 'Settings@version')->name('version');
//        Route::resource('categories', 'CategoriesAPIController', ['except' => ['destroy', 'create', 'edit']]);
//        Route::get('products', ['as' => 'products.index', 'uses' => 'ProductsApiController@index']);
//        Route::get('products/{id}', ['as' => 'products.show', 'uses' => 'ProductsApiController@show']);
//        Route::get('test',['as' => 'test', 'uses' => 'SmsController@index']);
//        Route::resource('countries', 'CountriesapiController', ['except' => ['destroy', 'create', 'edit']]);
//        Route::resource('currencies', 'CurrenciesapiController', ['except' => ['destroy', 'create', 'edit']]);
//        Route::resource('measures', 'MeasuresapiController', ['except' => ['destroy', 'create', 'edit']]);
//        Route::resource('terms', 'TermsapiController', ['except' => ['destroy', 'create', 'edit']]);
//        Route::post('send-contact-form', 'ContactFormApiController@sendContactForm');
//        Route::middleware(['\Tymon\JWTAuth\Middleware\GetUserFromToken'])->group(function () {
//            Route::post('products', 'ProductsApiController@store');
//            Route::post('products/{id}', 'ProductsApiController@update')
//                ->where('id', '[0-9]+');
//            Route::delete('products/{id}/image-delete/{image_id}', 'ProductsApiController@imageDelete')
//                ->where(['id' => '[0-9]+', 'image_id' => '[0-9]+']);
//            Route::post('products/{id}/publish', 'ProductsApiController@publish')
//                ->where('id', '[0-9]+');
//            Route::get('my-products/','ProductsApiController@myProducts');
//            Route::delete('my-products/{id}', 'ProductsApiController@delete')
//                ->where('id', '[0-9]+');
//            Route::resource('messages', 'MessagesapiController', ['except' => ['destroy', 'create', 'edit']]);
//            Route::get('messages/chatroom/{id}', 'MessagesapiController@enterChatroom')
//                ->where('id', '[0-9]+');
//            Route::get('messages/chatroom/{id}/load-more', 'MessagesapiController@loadMore')
//                ->where('id', '[0-9]+');
//            Route::post('messages/{chatroom_id}', 'MessagesapiController@sendMessage')
//                ->where('chatroom_id', '[0-9]+');
//            Route::post('messages/initialize-chatting/{seller_id}', 'MessagesapiController@initializeChatting')
//                ->where('seller_id', '[0-9]+');
//
//            //Balance
//            Route::post('balance_update','TransactionsApiController@updateBalance');
//            Route::get('notifications', 'NotificationsApiController@index');
//            Route::post('notifications/{id}/read', 'NotificationsApiController@markAsRead')
//                ->where('id', '^(?=.*[a-z])(?=.*[\-])(?=.*\d)[a-z\d\-]{36,}$');
//            Route::get('transactions', 'TransactionsApiController@index');
//            Route::get('my-balance', 'TransactionsApiController@myBalance');
//            Route::post('withdraw-from-balance', 'ExchangeRequestsController@withdrawFromBalance');
//            Route::post('send-sms-code', 'SmsController@sendSmsCode');
//            Route::post('check-sms-code', 'SmsController@checkSmsCode');
//            Route::post('send-email-verification-link', 'EmailVerificationController@sendEmailVerificationLink');
//        });
    });
});

Route::get('/mail', function () {
    $data = [
        'user' => ['name' => 'merdan'],
        'message' => ['text' => 'Some text']
    ];

    $layout = new MailLayout;
    $layout->fillFromCode('default'); // Change this to use another layout.

    $template = new MailTemplate;
    $template->layout = $layout;
    $template->fillFromContent(File::get(base_path('plugins/tps/birzha/views/mail/en/email_verify.htm')));

    return MailManager::instance()->renderTemplate($template, $data);
});
