get('/plugins/invites/settings', function ($request, $response, $args) { /** * @OA\Get( * tags={"plugins-invites"}, * path="/api/v2/plugins/invites/settings", * summary="Get settings", * @OA\Response( * response="200", * description="Success", * @OA\JsonContent(ref="#/components/schemas/pluginSettingsPage"), * ), * @OA\Response(response="401",description="Unauthorized"), * security={{ "api_key":{} }} * ) */ $Invites = new Invites(); if ($Invites->checkRoute($request)) { if ($Invites->qualifyRequest(1, true)) { $GLOBALS['api']['response']['data'] = $Invites->_invitesPluginGetSettings(); } } $response->getBody()->write(jsonE($GLOBALS['api'])); return $response ->withHeader('Content-Type', 'application/json;charset=UTF-8') ->withStatus($GLOBALS['responseCode']); }); $app->get('/plugins/invites', function ($request, $response, $args) { /** * @OA\Get( * tags={"plugins-invites"}, * path="/api/v2/plugins/invites", * summary="Get All Invites", * @OA\Response( * response="200", * description="Success", * @OA\JsonContent(ref="#/components/schemas/getInvites"), * ), * @OA\Response(response="401",description="Unauthorized"), * security={{ "api_key":{} }} * ) */ $Invites = new Invites(); if ($Invites->checkRoute($request)) { if ($Invites->qualifyRequest($Invites->config['INVITES-Auth-include'], true)) { $GLOBALS['api']['response']['data'] = $Invites->_invitesPluginGetCodes(); } } $response->getBody()->write(jsonE($GLOBALS['api'])); return $response ->withHeader('Content-Type', 'application/json;charset=UTF-8') ->withStatus($GLOBALS['responseCode']); }); $app->post('/plugins/invites', function ($request, $response, $args) { /** * @OA\Post( * tags={"plugins-invites"}, * path="/api/v2/plugins/invites", * summary="Create Invite Code", * @OA\Response( * response="200", * description="Success", * @OA\JsonContent(ref="#/components/schemas/createInviteCode"), * ), * @OA\Response(response="401",description="Unauthorized"), * security={{ "api_key":{} }} * ) */ $Invites = new Invites(); if ($Invites->checkRoute($request)) { if ($Invites->qualifyRequest($Invites->config['INVITES-Auth-include'], true)) { $Invites->_invitesPluginCreateCode($Invites->apiData($request)); } } $response->getBody()->write(jsonE($GLOBALS['api'])); return $response ->withHeader('Content-Type', 'application/json;charset=UTF-8') ->withStatus($GLOBALS['responseCode']); }); $app->get('/plugins/invites/{code}', function ($request, $response, $args) { /** * @OA\Get( * tags={"plugins-invites"}, * path="/api/v2/plugins/invites/{code}", * summary="Verify Invite Code", * @OA\Parameter( * name="code", * description="The Invite Code", * @OA\Schema( * type="integer", * format="int64", * ), * in="path", * required=true * ), * @OA\Response( * response="200", * description="Success", * @OA\JsonContent(ref="#/components/schemas/verifyInviteCode"), * ), * @OA\Response(response="401",description="Unauthorized") * ) */ $Invites = new Invites(); if ($Invites->checkRoute($request)) { if ($Invites->qualifyRequest(999, true)) { $Invites->_invitesPluginVerifyCode($args['code']); } } $response->getBody()->write(jsonE($GLOBALS['api'])); return $response ->withHeader('Content-Type', 'application/json;charset=UTF-8') ->withStatus($GLOBALS['responseCode']); }); $app->post('/plugins/invites/{code}', function ($request, $response, $args) { /** * @OA\Post( * tags={"plugins-invites"}, * path="/api/v2/plugins/invites/{code}", * summary="Use Invite Code", * @OA\Parameter( * name="code", * description="The Invite Code", * @OA\Schema( * type="integer", * format="int64", * ), * in="path", * required=true * ), * @OA\Response( * response="200", * description="Success", * @OA\JsonContent(ref="#/components/schemas/useInviteCode"), * ), * @OA\Response(response="401",description="Unauthorized") * ) */ $Invites = new Invites(); if ($Invites->checkRoute($request)) { if ($Invites->qualifyRequest(999, true)) { $Invites->_invitesPluginUseCode($args['code'], $Invites->apiData($request)); } } $response->getBody()->write(jsonE($GLOBALS['api'])); return $response ->withHeader('Content-Type', 'application/json;charset=UTF-8') ->withStatus($GLOBALS['responseCode']); }); $app->delete('/plugins/invites/{code}', function ($request, $response, $args) { /** * @OA\Delete( * tags={"plugins-invites"}, * path="/api/v2/plugins/invites/{code}", * summary="Delete Invite Code", * @OA\Parameter( * name="code", * description="The Invite Code", * @OA\Schema( * type="integer", * format="int64", * ), * in="path", * required=true * ), * @OA\Response( * response="200", * description="Success", * @OA\JsonContent(ref="#/components/schemas/deleteInviteCode"), * ), * @OA\Response(response="401",description="Unauthorized"), * security={{ "api_key":{} }} * ) */ $Invites = new Invites(); if ($Invites->checkRoute($request)) { if ($Invites->qualifyRequest($Invites->config['INVITES-Auth-include'], true)) { $Invites->_invitesPluginDeleteCode($args['code']); } } $response->getBody()->write(jsonE($GLOBALS['api'])); return $response ->withHeader('Content-Type', 'application/json;charset=UTF-8') ->withStatus($GLOBALS['responseCode']); });