<?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!
|
*/
$api = app('Dingo\Api\Routing\Router');
$api->version('v1', [
    'namespace' => 'App\Http\Controllers\Api',
    'prefix'    => 'api',
    //'middleware' => ['serializer:array', 'bindings']
], function($api) {
     $api->post('payment/notice', 'PaymentController@notice');

    // 限制登录和验证码接口请求频率
    $api->group([
        'middleware' => 'api.throttle',
        'limit'   => config('api.rate_limits.sign.limit'),
        'expires' => config('api.rate_limits.sign.expires'),
    ], function($api) {
        $api->any('passport/login', 'PassportController@login');
    });

    // 需要登录
    $api->group([
        'middleware' => [
            'api.auth'
        ],
    ], function($api) {
        $api->get('setting/get', 'SettingController@get');
        $api->get('user/get', 'UserController@get');
        $api->get('user/query', 'UserController@query');
        $api->get('user/shares', 'UserController@shares');
        $api->get('user/memberRecord', 'UserController@memberRecord');
        $api->get('user/overage', 'UserController@overage');
        $api->get('user/income', 'UserController@income');
        $api->post('user/bind', 'UserController@bind');
        $api->post('user/bindPhone', 'UserController@bindPhone');
        $api->post('user/buy', 'UserController@buy');
        $api->post('user/update', 'UserController@update');
        $api->post('withdraw/apply', 'WithdrawController@apply');
        $api->get('withdraw/lists', 'WithdrawController@lists');
    });

});
