public function run()
 {
     $appPrm = $this->request->getData()['AppPermission'];
     $apiKey = $appPrm['apiKey'];
     $res = $this->forward('/apps/validate/' . $apiKey);
     $appId = $res->getData()['App']['id'];
     $permission = new AppPermission();
     $permission->setAppId($appId);
     $permission->setAction($appPrm['action']);
     if ($permission->read() === null) {
         $this->sendModel($permission->create());
     } else {
         throw new GraphException('permission already assigned');
     }
 }
 public function run()
 {
     $appPrm = json_decode($this->request->getBody(), true)['AppPermission'];
     $apiKey = $appPrm['apiKey'];
     $res = $this->forward('/apps/validate/' . $apiKey);
     if ($res->getStatusCode() !== 200) {
         throw new GraphException('Application not found', 400);
     }
     $appId = json_decode($res->getBody(), true)['App']['id'];
     $permission = new AppPermission();
     $permission->setAppId($appId);
     $permission->setAction($appPrm['action']);
     $rPermission = $permission->read();
     if ($rPermission !== null) {
         $rPermission->delete();
         $this->sendMessage('permission deleted successfully');
     } else {
         throw new GraphException('permission not found');
     }
 }