<?php

/*
|--------------------------------------------------------------------------
| 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::group([ 'namespace' => 'API' ], function () {
    Route::group([ 'prefix' => '/user', 'namespace' => 'User' ], function () {
        Route::post('/login', [ 'uses' => 'Login@index' ]);
        Route::get('/profile/view-image/{customerid}/{width}/{height}/{filename}', [
            'as'   => 'apiShowProfilePicture',
            'uses' => 'Profile@showPicture'
        ]);
        Route::group([ 'middleware' => 'auth.token' ], function () {
            Route::get('/profile', [ 'uses' => 'Profile@view' ]);
            Route::post('/profile', [ 'uses' => 'Profile@update' ]);
            Route::post('/profile/image', [ 'uses' => 'Profile@uploadProfilePhoto' ]);
            Route::post('/register-device', [ 'uses' => 'RegisterDevice@store' ]);
            Route::get('/logout', [ 'uses' => 'Logout@index' ]);
        });
    });

    Route::group([ 'prefix' => '/chat', 'namespace' => 'Chat' ], function () {
        Route::get('/message/view-image/{customerid}/{group}/{height}/{filename}', [
            'as'   => 'apiMessageSmallerImage',
            'uses' => 'Messages@getSmallerImage'
        ]);
        Route::group([ 'middleware' => 'auth.token' ], function () {
            Route::get('/groups', [ 'uses' => 'Groups@index' ]);
            Route::get('/messages', [ 'uses' => 'Messages@index' ]);
            Route::post('/messages/send', [ 'uses' => 'Messages@sendMessage' ]);
        });
    });
});