<?php

/*
|--------------------------------------------------------------------------
| Module Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for this module.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/

Route::group(['prefix' => Config::get('app.api_path'), 'middleware' => ['web', 'auth']], function () {
	Route::get('clients/subscriptions', [\App\Modules\Clients\controllers\api\v1\ClientsControllerREST::class, 'getSubscriptions']);
    Route::resource('clients', \App\Modules\Clients\controllers\api\v1\ClientsControllerREST::class);
    Route::resource('customers', \App\Modules\Clients\controllers\api\v1\CustomersControllerREST::class);
    Route::resource('sites', \App\Modules\Clients\controllers\api\v1\SitesControllerREST::class);
    Route::resource('sites.users', \App\Modules\Clients\controllers\api\v1\SiteUsersControllerREST::class);
    Route::resource('licenses', \App\Modules\Clients\controllers\api\v1\LicensesControllerREST::class, ['only' => ['index', 'store', 'update']]);
    Route::get('clients/helpers/overview', [\App\Modules\Clients\controllers\api\v1\HelpersControllerREST::class, 'getOverview']);
    Route::get('clients/helpers/client-summary/{id}', [\App\Modules\Clients\controllers\api\v1\HelpersControllerREST::class, 'getClientSummary']);
    Route::get('clients/helpers/customer-summary/{id}', [\App\Modules\Clients\controllers\api\v1\HelpersControllerREST::class, 'getCustomerSummary']);
    Route::get('clients/helpers/activity', [\App\Modules\Clients\controllers\api\v1\HelpersControllerREST::class, 'getActivity']);
    Route::get('clients/marketing/activity', [\App\Modules\Clients\controllers\api\v1\MarketingControllerREST::class, 'getActivity']);
    Route::get('clients/marketing/reach', [\App\Modules\Clients\controllers\api\v1\MarketingControllerREST::class, 'getReach']);
    Route::post('clients/marketing/send', [\App\Modules\Clients\controllers\api\v1\MarketingControllerREST::class, 'postSend']);
    Route::post('clients/marketing/preview', [\App\Modules\Clients\controllers\api\v1\MarketingControllerREST::class, 'postPreview']);
    Route::post('clients/marketing/export', [\App\Modules\Clients\controllers\api\v1\MarketingControllerREST::class, 'postExport']);
    Route::get('clients/marketing/export/{filename}', [\App\Modules\Clients\controllers\api\v1\MarketingControllerREST::class, 'getExport']);
    Route::post('clients/subscribe/{id}', [\App\Modules\Clients\controllers\api\v1\ClientsControllerREST::class, 'subscribe']);
    Route::post('clients/unsubscribe/{id}', [\App\Modules\Clients\controllers\api\v1\ClientsControllerREST::class, 'unsubscribe']);
    // Route::resource('invoices.item', 'App\Modules\Invoices\InvoiceItemControllerREST');
});

/*
|--------------------------------------------------------------------------
| Pages rendered on the server
|--------------------------------------------------------------------------
|
| This group routes are pages rendered on the server.
| All the pages require the user to be authentificated.
|
*/

// Phone system name lookup
Route::get('clients/name-lookup', ['as' => 'clients.name-lookup', 'uses' => \App\Modules\Clients\controllers\ClientsController::class . '@getNameLookup']);

Route::group(['middleware' => ['web', 'auth']], function () {
    Route::get('clients', [\App\Modules\Clients\controllers\ClientsController::class, 'getIndex']);
    Route::get('subscriptions', [\App\Modules\Clients\controllers\ClientsController::class, 'subscriptions']);
});
