<?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.
|
*/

/*$router->group(['prefix' => 'api/admin/'], function () use ($router) {
    $router->get('business','BusinessController@index');
    $router->get('business/{ruc}','BusinessController@show');
    $router->post('create_business','BusinessController@store');
    $router->put('edit_business/{ruc}','BusinessController@update');
    $router->patch('edit_business/{ruc}','BusinessController@update');
    $router->delete('delete_business/{ruc}','BusinessController@destroy');

    })*/
	$router->group(['prefix' => 'api/admin/'], function () use ($router) {
		
		$router->post('inicio_session','UserController@login');
	});
	
$router->group(['middleware' => 'auth'], function () use ($router) {
    $router->group(['prefix' => 'api/admin/'], function () use ($router) {
        $router->get('empresas','EmpresaController@listarEmpresas');
        $router->get('empresas/{id}','EmpresaController@listaraxId');
        $router->get('empresa_ruc/{ruc}','EmpresaController@listarPorRuc');     
        $router->get('empresas/{id_empresa}/{status}','EmpresaController@cambiarestado');
        $router->post('crear_empresas','EmpresaController@registrarEmpresa');
        $router->put('editar_empresas/{id}','EmpresaController@actualizarEmpresa');
        $router->patch('editar_empresas/{id}','EmpresaController@actualizarEmpresa');
        $router->delete('eliminar_empresas/{id}','EmpresaController@eliminarEmpresa');
        $router->get('/documents/list','TipoDocumentoController@index');
		$router->post('crear_usuario','UserController@User_create');
		
		$router->post('cerrar_session','UserController@logout');
		
		$router->get('user', function () use ($router){
			return auth::user();
		});
    });
});
$router->group(['prefix' => 'api/v1'], function () use ($router) {
    $router->group(['prefix' => '/client'], function () use ($router) {        
        $router->get('/obtener_deuda/{ruc}',
            'ClientsController@obtenerDeuda'
        );
        $router->get('/subdominio', [
            'as' => 'client.subdominio',
            'uses' => 'ClientsController@listarEmpresaPorSubdominio'
        ]);
        $router->get('/{ruc}', [
            'as' => 'client.show',
            'uses' => 'ClientsController@show'
        ]);
        $router->get('/ticket/{ruc}', [
            'as' => 'client.ticket',
            'uses' => 'TicketController@obtener_ticket'
        ]);
        $router->get('/ticket_detalle/{id_ticket}', [
            'as' => 'client.ticket_detalle',
            'uses' => 'TicketController@obtener_ticket_detalle'
        ]);
        
    });

});
//crear la ruta->crear la funcion para obtener el estado pasando como parametro el ruc->pasar el ruc por el postman como con subdominio-> retornar el id_ticket_pen->crear una funcion que consuma el servicio->mandar al header a traves de otra funcion.


/*$router->get('/Business/{ruc}','BusinessController@show');
$router->post('/Business','BusinessController@store');
$router->put('/Business/{ruc}','BusinessController@update');
$router->patch('/Business/{ruc}','BusinessController@update');
$router->delete('/Business/{ruc}','BusinessController@destroy');*/

