示例#1
0
 /**
  * constructor
  * @param Setup $app
  */
 public function __construct(Setup $app)
 {
     $this->app = $app;
     $this->request = $app->request;
     $this->response = $app->response;
     $this->requestBodyArr = json_decode($app->request()->getBody(), true);
 }
示例#2
0
 /**
  * Setup routing request
  * @param Setup $app
  */
 public static function setupRouting(Setup $app)
 {
     $app->group('/v1', function () use($app) {
         // CREATE API KEY
         $app->post('/create-api-token', function () use($app) {
             $token = new APITokenAuth($app);
             $token->createNewToken();
         });
         // ControllerBukaPintu
         $ctrlBukaPintu = new ControllerBukaPintu($app);
         ### GET
         $app->get('/bukapintu', function () use($ctrlBukaPintu) {
             $ctrlBukaPintu->bukaPintu();
         });
         $app->get('/stopbukapintu', function () use($ctrlBukaPintu) {
             $ctrlBukaPintu->stopBukaPintu();
         });
         // ControllerAuth
         $ctrlAuth = new ControllerAuth($app);
         ### POST
         $app->post('/login', function () use($ctrlAuth) {
             $ctrlAuth->loginToGetToken();
         });
         $app->post('/register', function () use($ctrlAuth) {
             $ctrlAuth->registerNewUser();
         });
         ### GET
         $app->get('/active/:USER_ID', function ($USER_ID) use($ctrlAuth) {
             $ctrlAuth->userActivation($USER_ID);
         });
         $app->get('/isexist/:EMAIL', function ($EMAIL) use($ctrlAuth) {
             $ctrlAuth->cekEmailIsExist($EMAIL);
         });
         $app->get('/pending-users', function () use($ctrlAuth) {
             $ctrlAuth->getAllPendingUser();
         });
         ### DELETE
         $app->delete('/user/:USER_ID', function ($USER_ID) use($ctrlAuth) {
             $ctrlAuth->removeUser($USER_ID);
         });
     });
 }
示例#3
0
 /**
  * Setup routing request
  * @param Setup $app
  */
 public static function setupRouting(Setup $app)
 {
     $app->group('/v1', function () use($app) {
         // CREATE API KEY
         $app->post('/create-api-token', function () use($app) {
             $token = new APITokenAuth($app);
             $token->createNewToken();
         });
         // SAMPLE REQUEST
         $controller = new ExpControllerDataCustomer($app);
         ### GET REQUEST
         $app->get('/customers', function () use($controller) {
             $controller->getCustomers();
         });
         $app->get('/customer/:ID_CUSTOMER', function ($id_customer) use($controller) {
             $controller->getCustomers($id_customer);
         });
         $app->get('/customer_items/:ID_CUSTOMER', function ($id_customer) use($controller) {
             $controller->getCustomerItems($id_customer);
         });
         $app->get('/customer/filterby', function () use($controller) {
             $controller->filterCustomerBy();
         });
         $app->get('/customer_items/filterby', function () use($controller) {
             $controller->filterCustomerItems();
         });
         ### POST REQUEST
         $app->post('/customer', function () use($controller) {
             $controller->addNewCustomer();
         });
         $app->post('/customer_items', function () use($controller) {
             $controller->addCustomerItems();
         });
         ### PUT REQUEST
         $app->put('/customer_items/:ID_CUSTOMER', function ($id_customer) use($controller) {
             $controller->changeCustomerData($id_customer);
         });
         ### DELETE REQUEST
         $app->delete('/customer_items/:ID_CUSTOMER', function ($id_customer) use($controller) {
             $controller->removeCustomer($id_customer);
         });
     });
 }