<?php

/*
  |--------------------------------------------------------------------------
  | Application Routes
  |--------------------------------------------------------------------------
  |
  | Here is where you can register all of the routes for an application.
  | It is a breeze. Simply tell Lumen the URIs it should respond to
  | and give it the Closure to call when that URI is requested.
  |
 */
$app->get('/', function () use ($app) {
    //return $app->version();
    return 'Welcome!';
});


$app->group(['prefix' => 'api/v1/user/'], function ($app) {
    $app->get('/', 'Api\v1\UserController@index');
    $app->post('/show', 'Api\v1\SubscriptionPlanController@show');
    //$app->get('/{id}/', 'Api\v1\UserController@show');
    $app->post('/login', 'Api\v1\UserController@login');
    $app->post('/saveprofile', 'Api\v1\SettingController@changeProfile');
    $app->post('/changepassword', 'Api\v1\SettingController@changePassword');
    $app->post('/reset', 'Api\v1\UserController@resetPassword');
    $app->post('/forgotpass', 'Api\v1\UserController@forgotPassword');
    $app->delete('/{id}/', 'Api\v1\UserController@destroy');
    $app->post('/getimage', 'Api\v1\SettingController@getImage');
});
$app->post('/api/v1/get-latest-version-app', ['as' => 'api.latest.version', 'uses' => 'Api\v1\AuthController@isForceUpdate']);
$app->post('/api/v1/user/coupon/checkStatus', 'Api\v1\UserCouponController@checkStatus');
$app->post('/api/v1/user/coupon/couponReport/excel', 'Api\v1\UserCouponController@exportExcel');
$app->get('/api/v1/user/coupon/couponReport/excel/download/{type}/{file}', 'Api\v1\UserCouponController@download');


//Routes for total coupon usage by jatinparmar
$app->get('/api/v1/user/coupon/get_coupon_usage/{id}/{perpage}', 'Api\v1\UserCouponController@get_coupon_usage');
$app->get('/api/v1/user/coupon/export_coupon_usage/{id}', 'Api\v1\UserCouponController@export_coupon_usage');
$app->get('/api/v1/user/getAllPlan', 'Api\v1\UserCouponController@getAllPlan');

// all routes for Coupon Module
$app->group(['middleware' => 'auth:api', 'prefix' => 'api/v1/user/coupon/'], function ($app) {
    $app->post('couponReport/', 'Api\v1\UserCouponController@couponReport');
    $app->get('couponReport/{id}', 'Api\v1\UserCouponController@couponReportDetail');
    $app->post('store', 'Api\v1\UserCouponController@store');
    $app->post('/', 'Api\v1\UserCouponController@index');

    $app->post('/changeStatus/', 'Api\v1\UserCouponController@changeStatus');
    $app->get('/{id}', 'Api\v1\UserCouponController@show');
    $app->post('/{id}', 'Api\v1\UserCouponController@update');
    $app->delete('/{id}/', 'Api\v1\UserCouponController@destroy');
});

$app->group(['prefix' => 'api/v1/activity/'], function ($app) {
    $app->get('/', 'Api\v1\ActivityController@index');
    $app->get('/{id}', 'Api\v1\ActivityController@show');
    $app->post('/filter', 'Api\v1\ActivityController@filterByDate');
});

// all routes for Cms module
$app->group(['middleware' => 'auth:api', 'prefix' => 'api/v1/cms/'], function ($app) {
    $app->get('/', 'Api\v1\CmsController@index');
    $app->post('/', 'Api\v1\CmsController@store');
    $app->get('/{id}/', 'Api\v1\CmsController@show');
    $app->put('/{id}/', 'Api\v1\CmsController@update');
    $app->delete('/{id}/', 'Api\v1\CmsController@destroy');
});

// all routes for Branch module
$app->group(['prefix' => 'api/v1/branch/'], function ($app) {
    $app->get('/', 'Api\v1\BranchController@index');
    $app->post('/all', 'Api\v1\BranchController@managerbranches');
    $app->post('/', 'Api\v1\BranchController@store');
    $app->get('/{id}/', 'Api\v1\BranchController@show');
    $app->put('/{id}/', 'Api\v1\BranchController@update');
    $app->post('/saveplace', 'Api\v1\BranchController@savePlace');
    $app->delete('/{id}/', 'Api\v1\BranchController@destroy');
});

// all routes for SubscriptionPlan module
$app->group(['prefix' => 'api/v1/plan/'], function ($app) {
    $app->get('/', 'Api\v1\SubscriptionPlanController@index');
    $app->post('/', 'Api\v1\SubscriptionPlanController@store');
    $app->post('/show', 'Api\v1\SubscriptionPlanController@show');
    $app->put('/{id}/', 'Api\v1\SubscriptionPlanController@update');
    $app->put('changestatus/{id}/', 'Api\v1\SubscriptionPlanController@changeStatus');
    $app->delete('/{id}/', 'Api\v1\SubscriptionPlanController@destroy');
    $app->post('/paybycard', 'Api\v1\SubscriptionPlanController@subscribeCustomer');
    $app->post('/cancelsubscription', 'Api\v1\SubscriptionPlanController@cancelSubscription');
    $app->post('/createbankaccount', 'Api\v1\SubscriptionPlanController@createACHToken');
    $app->post('/verifybankaccount', 'Api\v1\SubscriptionPlanController@verifyACHCustomer');
    $app->post('/paybybank', 'Api\v1\SubscriptionPlanController@achCharge');
    $app->post('/verification', 'Api\v1\SubscriptionPlanController@plaidVerification');
    $app->post('/bankToken', 'Api\v1\SubscriptionPlanController@createBankToken');
    $app->get('/sycleFreePlan', 'Api\v1\SubscriptionPlanController@getSycleUserDefaultPlanDetails');
    $app->get('/sycleUserPlan', 'Api\v1\SubscriptionPlanController@getSycleUserPlanProfileDetails');
});
$app->group(['prefix' => 'api/v1/stripewebhook/'], function ($app) {
    $app->post('/chargeEvent', 'Api\v1\StripeWebhookController@chargeEvent');   
});
$app->group(['prefix' => 'api/v1/cron/'], function ($app) {
    $app->get('/sendlinkemail', 'Api\v1\CronController@sendlinkemail');   
});
// all routes for Manager module
$app->group(['prefix' => 'api/v1/manager/'], function ($app) {
    $app->get('/', 'Api\v1\ManagerController@index');
    $app->get('/plan', 'Api\v1\ManagerController@getPlan');
    $app->get('/get', 'Api\v1\ManagerController@getManager');
    $app->post('/', 'Api\v1\ManagerController@store');
    $app->post('/add', 'Api\v1\ManagerController@addBusiness');
    $app->get('/widget', 'Api\v1\WidgetController@show');
    $app->get('/{id}/', 'Api\v1\ManagerController@show');
    $app->put('/{id}/', 'Api\v1\ManagerController@update');
    $app->delete('/{id}/', 'Api\v1\ManagerController@destroy');
    $app->post('/sendSmsAndMail', 'Api\v1\ManagerController@sendSmsAndMail');
    $app->post('/getstripeid', 'Api\v1\ManagerController@getStripeId');
    $app->post('/getfbverified', 'Api\v1\ManagerController@getFbVerified');
    $app->post('/gettwitterverified', 'Api\v1\ManagerController@getTwitterVerified');
    $app->post('/getinstaverified', 'Api\v1\ManagerController@getInstaVerified');
    $app->post('/instadata', 'Api\v1\ManagerController@getInstaData');
});

// all routes for Manager module
$app->group(['middleware' => 'auth:api', 'prefix' => 'api/v1/device/'], function ($app) {
    $app->get('/', 'Api\v1\DeviceController@index');
    $app->post('/', 'Api\v1\DeviceController@store');
    $app->put('/', 'Api\v1\DeviceController@changeStatus');
});

// all routes for EmailTemplate module
$app->group(['middleware' => 'auth:api', 'prefix' => 'api/v1/template/'], function ($app) {
    $app->get('/', 'Api\v1\EmailTemplateController@index');
    $app->post('/', 'Api\v1\EmailTemplateController@store');
    $app->get('/{id}/', 'Api\v1\EmailTemplateController@show');
    $app->put('/{id}/', 'Api\v1\EmailTemplateController@update');
    $app->put('/', 'Api\v1\EmailTemplateController@changeStatus');
});

// dashboards paths
$app->post('api/v1/manager/dashboard', 'Api\v1\FeedbackController@index');
$app->get('api/v1/admin/dashboard', 'Api\v1\FeedbackController@adminDashboard');
$app->post('api/v1/admin/getRevenue', 'Api\v1\FeedbackController@getRevenue');
$app->get('api/v1/admin/subscriptions', 'Api\v1\ManagerPlanController@index');

// all routes for EmailTemplate module
$app->group(['middleware' => 'auth:api', 'prefix' => 'api/v1/sub-admin/'], function ($app) {
    $app->get('/', 'Api\v1\SubAdminController@index');
    $app->post('/', 'Api\v1\SubAdminController@store');
    $app->get('/{id}/', 'Api\v1\SubAdminController@show');
    $app->put('/{id}/', 'Api\v1\SubAdminController@update');
    $app->put('/', 'Api\v1\SubAdminController@changeStatus');
    $app->delete('/{id}/', 'Api\v1\SubAdminController@destroy');
});

// all routes for EmailTemplate module
$app->group(['prefix' => 'api/v1/feedback/'], function ($app) {
    $app->get('/getSendFeedbackLinkLog[/{token}]/', 'Api\v1\FeedbackController@getSendFeedbackLinkLog');
    $app->post('/customers', 'Api\v1\FeedbackController@customers');
    $app->post('/', 'Api\v1\FeedbackController@store');
    $app->post('/sendlink', 'Api\v1\FeedbackController@sendlinknew');
    $app->post('/save', 'Api\v1\FeedbackController@save');
    $app->post('/storefeedbackold', 'Api\v1\FeedbackController@storeFeedbackOld');
    $app->post('/storefeedback', 'Api\v1\FeedbackController@storeFeedback');
    $app->get('/{id}/', 'Api\v1\FeedbackController@show');
    $app->get('/totalLink/{user_id}', 'Api\v1\FeedbackController@totalLink');
    $app->get('/totalsendLinkByOrg/{org_id}', 'Api\v1\FeedbackController@totalsendLinkByOrg');
    $app->put('/{id}/', 'Api\v1\FeedbackController@update');
    $app->put('/', 'Api\v1\FeedbackController@changeStatus');
    $app->post('/getimage', 'Api\v1\FeedbackController@getImage');
    $app->post('/getoptions', 'Api\v1\FeedbackController@getOptions');
    $app->post('/listing', 'Api\v1\FeedbackController@employeeFeedback');
    $app->delete('/{id}/', 'Api\v1\FeedbackController@destroy');
});

//
$app->group(['middleware' => 'auth:api','prefix' => 'api/v1/feedback/'], function ($app) {
   $app->post('/sendlinkFromQueueListing', 'Api\v1\FeedbackController@sendlinkFromQueueListing'); 
});
// all routes for Employee module
$app->group(['prefix' => 'api/v1/employee/'], function ($app) {
    $app->post('/all', 'Api\v1\EmployeeController@index');
    $app->post('/selected', 'Api\v1\EmployeeController@selected');
    $app->post('/', 'Api\v1\EmployeeController@store');
    $app->get('/{id}/', 'Api\v1\EmployeeController@show');
    $app->put('/{id}/', 'Api\v1\EmployeeController@update');
    $app->put('/', 'Api\v1\EmployeeController@changeStatus');
    $app->delete('/{id}/', 'Api\v1\EmployeeController@destroy');
});

// all routes for WelcomePages module
$app->group(['prefix' => 'api/v1/welcomepage/'], function ($app) {
    $app->get('/', 'Api\v1\WelcomePageController@all');
    $app->post('/', 'Api\v1\WelcomePageController@store');
    $app->get('/{id}/', 'Api\v1\WelcomePageController@show');
    $app->post('/update/', 'Api\v1\WelcomePageController@update');
    $app->delete('/{id}/', 'Api\v1\WelcomePageController@destroy');
});

// all routes for Coupon module
$app->group(['prefix' => 'api/v1/coupon/'], function ($app) {
    $app->post('/', 'Api\v1\CouponController@store');
});

// all routes for social post
$app->group(['prefix' => 'api/v1/social/'], function ($app) {
    $app->post('/post', 'Api\v1\SocialController@postOnSocialMedia');
    $app->post('/storefbdata', 'Api\v1\SocialController@storeFbData');
    $app->put('/getfbpagedata/{id}', 'Api\v1\SocialController@getFbPageData');
    $app->post('/storefbpagedata', 'Api\v1\SocialController@storeFbPageData');
    $app->post('/storetwitterdata', 'Api\v1\SocialController@storeTwitterData');
    $app->post('/storeinstagramdata', 'Api\v1\SocialController@storeInstagramData');
    $app->post('/postOnInsta', 'Api\v1\SocialController@postOnInsta');
});


$app->get('static/{cid}/{type}/{filename}/', 'Api\v1\FeedbackController@showAsset');

//expiry cron
$app->get('api/v1/paln/expiredPlan', 'Api\v1\SubscriptionPlanController@expiredPlan');
//email sending cron
$app->get('api/v1/sendemails', 'Api\v1\EmailQueueController@sendEmailQueue');

// all routes for role module
$app->group(['middleware' => 'auth:api', 'prefix' => 'api/v1/role/'], function ($app) {
    $app->get('/', 'Api\v1\RoleController@index');
    $app->get('/get', 'Api\v1\RoleController@getRole');
    $app->post('/permissions', 'Api\v1\RoleController@permissionList');
    $app->post('/addRole', 'Api\v1\RoleController@addRole');
    $app->put('/{id}/', 'Api\v1\RoleController@update');
    $app->get('/{id}/', 'Api\v1\RoleController@show');
    $app->post('/update', 'Api\v1\RoleController@updatePermission');
});
//review
$app->post('api/v1/review', 'Api\v1\FeedbackController@review');

// all routes for Sycle module
$app->group(['prefix' => 'api/v1/sycle/'], function ($app) {
    $app->get('/', 'Api\v1\SycleController@index');
    $app->post('/addFtp', 'Api\v1\SycleController@addFtp');
    $app->put('/{id}/', 'Api\v1\SycleController@updateFtpDetails');
    $app->delete('/{id}/', 'Api\v1\SycleController@deleteFtpDetails');
    $app->get('/getFtpDetailsByBusinessId', 'Api\v1\SycleController@getFtpDetailsByBusinessId');
    $app->get('/{id}/', 'Api\v1\SycleController@getDetailsByBusinessId');
    $app->post('/getInfo', 'Api\v1\SycleController@getDetailsByFileStatus');
    $app->post('/getCsvDetails/', 'Api\v1\SycleController@getCsvDetails');
    

});


//feedback route with oauth//
$app->group(['middleware' => 'auth:api', 'prefix' => 'api/v1/sycle/'], function ($app) {
    $app->post('/deletefeedback', 'Api\v1\SycleController@deletefeedback');
    $app->post('/removefrompatientListing', 'Api\v1\SycleController@removefrompatientListing');
    $app->post('/patientListing', 'Api\v1\SycleController@getQueuePatientListing');
});


/* =========== MOBILE APPLICATION ROUTES ============== */
$app->get('api/v1/tour', 'Api\v1\WelcomePageController@index');
$app->post('api/v1/employee/login', 'Api\v1\EmployeeController@login');
$app->post('api/v1/employee/forgotpassword', 'Api\v1\EmployeeController@forgotPassword');
$app->post('api/v1/employee/changepassword', 'Api\v1\EmployeeController@changePassword');
$app->post('api/v1/employee/saveownfeedback', 'Api\v1\EmployeeController@ownFeedback');
$app->post('api/v1/employee/dashboard', 'Api\v1\EmployeeController@dashboardData');
$app->post('api/v1/employee/savemedia', 'Api\v1\FeedbackController@saveMedia');
$app->post('api/v1/employee/sendinvitation', 'Api\v1\FeedbackController@sendInvitationLink');