<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| 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::post('/request-upload', 'Api\Gallery\GalleryController@requestUpload');
Route::get('/request-download', 'Api\Test@requestDownload');
Route::get('/request-download-url', 'Api\Test@requestDownloadUrl');
Route::get('/sign-url', 'Api\Test@getSignedUrl');
*/
Route::post('/request-upload', 'Api\Gallery\GalleryController@requestUpload');

Route::group([
    'prefix' => 'signup'
], function ($router) {
    Route::post('email', 'Api\AuthController@signupEmail');
});

Route::group([
    'prefix' => 'auth'
], function ($router) {
    Route::post('login', 'Api\AuthController@login');
    Route::post('logout', 'Api\AuthController@logout');
    Route::post('refresh', 'Api\AuthController@refresh');
    Route::post('me', 'Api\AuthController@me');
});

Route::group([
    'prefix' => 'users/{userUid}',
    'middleware' => ['jwt.refresh', 'auth:api']
], function ($router) {
    Route::put('user-onboard-role', 'Api\User\UserController@updateUserOnboardRole');
    Route::put('user-onboard-usages', 'Api\User\UserController@updateUserOnboardUsages');
    Route::post('avatar', 'Api\User\UserController@updateUserAvatar');
    Route::delete('avatar', 'Api\User\UserController@deleteUserAvatar');
    Route::put('', 'Api\User\UserController@updateUser');
    Route::put('notification-options', 'Api\User\UserController@updateUserNotifications');
    Route::put('email', 'Api\User\UserController@updateEmail');
    Route::put('password', 'Api\User\UserController@updatePassword');
});

Route::group([
    'prefix' => 'accounts/{accountUid}',
    'middleware' => ['jwt.refresh', 'auth:api']
], function ($router) {
    Route::get('', 'Api\Account\AccountController@getAccount');
    Route::put('contacts', 'Api\Account\AccountController@updateContacts');
    Route::post('subscriptions', 'Api\Account\AccountController@createSubscription');
    Route::put('name', 'Api\Account\AccountController@updateName');

    // Stripe / Subscriptions
    Route::put('payment-method', 'Api\Account\AccountController@updatePaymentMethod');

    // Galleries
    Route::get('galleries', 'Api\Gallery\GalleryController@getGalleries');
    Route::post('galleries', 'Api\Gallery\GalleryController@createGallery');
    Route::get('galleries/{galleryUid}', 'Api\Gallery\GalleryController@getGallery');
    Route::put('galleries/{galleryUid}', 'Api\Gallery\GalleryController@updateGallery');
    Route::delete('galleries/{galleryUid}', 'Api\Gallery\GalleryController@deleteGallery');

    // Gallery Sections
    Route::put('galleries/{galleryUid}/sections/{sectionUid}', 'Api\Gallery\GallerySectionController@update');
    Route::put('galleries/{galleryUid}/sections/{sectionUid}/order', 'Api\Gallery\GallerySectionController@updateOrder');

    // Gallery Items
    Route::put('galleries/{galleryUid}/items/{galleryItemUid}', 'Api\Gallery\GalleryItemController@update');
    Route::delete('galleries/{galleryUid}/items/{galleryItemUid}', 'Api\Gallery\GalleryItemController@delete');
});

Route::group([
    'prefix' => 'service',
    'middleware' => ['service-endpoints'],
], function ($router) {
    Route::post('image-meta', 'Api\Gallery\GalleryItemController@setImageMeta');
});
