Beispiel #1
0
 public function postQuery()
 {
     // We will validate the key pairs as we dont want to cause unneeded errors
     $validation = new APIKeyValidator();
     if ($validation->passes()) {
         // Bootstrap the Pheal Instance
         BaseApi::bootstrap();
         $pheal = new Pheal(Input::get('keyID'), Input::get('vCode'));
         $pheal->scope = strtolower(Input::get('api'));
         // Prepare an array with the arguements that we have received.
         // first the character
         $arguements = array();
         if (strlen(Input::get('characterid')) > 0) {
             $arguements = array('characterid' => Input::get('characterid'));
         }
         // Next, process the option arrays
         if (strlen(Input::get('optional1')) > 0) {
             $arguements[Input::get('optional1')] = Input::get('optional1value');
         }
         if (strlen(Input::get('optional2')) > 0) {
             $arguements[Input::get('optional2')] = Input::get('optional2value');
         }
         // Compute the array for the view to sample the pheal call that will be made
         $call_sample = array('keyID' => Input::get('keyID'), 'vCode' => Input::get('vCode'), 'scope' => Input::get('api'), 'call' => Input::get('call'), 'args' => $arguements);
         try {
             $method = Input::get('call');
             $response = $pheal->{$method}($arguements);
         } catch (Exception $e) {
             return View::make('debug.ajax.result')->with('call_sample', $call_sample)->with('exception', $e);
         }
         return View::make('debug.ajax.result')->with('call_sample', $call_sample)->with('response', $response->toArray());
     } else {
         return View::make('debug.ajax.result')->withErrors($validation->errors);
     }
 }
Beispiel #2
0
 public function getAdd($keyID, $vCode)
 {
     $validation = new APIKeyValidator(array('keyID' => $keyID, 'vCode' => $vCode));
     if ($validation->passes()) {
         // Check if we have this key in the db, even those that are soft deleted
         $key_data = SeatKey::withTrashed()->where('keyID', $keyID)->first();
         if (!$key_data) {
             $key_data = new SeatKey();
         }
         $key_data->keyID = $keyID;
         $key_data->vCode = $vCode;
         $key_data->isOk = 1;
         $key_data->lastError = null;
         $key_data->deleted_at = null;
         $key_data->user_id = \Auth::User()->id;
         $key_data->save();
         // Queue a job to update this API **now**
         $access = EveApi\BaseApi::determineAccess($keyID);
         if (!isset($access['type'])) {
             return Redirect::action('ApiKeyController@getAll')->with('warning', 'Key was successfully added, but a update job was not submitted.');
         }
         // Based in the key type, push a update job
         switch ($access['type']) {
             case 'Character':
                 // Do a fresh AccountStatus lookup
                 Account\AccountStatus::update($keyID, $vCode);
                 $jobID = \App\Services\Queue\QueueHelper::addToQueue('\\Seat\\EveQueues\\Full\\Character', $key_data->keyID, $key_data->vCode, 'Character', 'Eve');
                 break;
             case 'Corporation':
                 $jobID = \App\Services\Queue\QueueHelper::addToQueue('\\Seat\\EveQueues\\Full\\Corporation', $key_data->keyID, $key_data->vCode, 'Corporation', 'Eve');
                 break;
             default:
                 $jobID = 'Unknown';
                 break;
         }
         return Redirect::action('ApiKeyController@getAll')->with('success', 'Key was successfully added and job ' . $jobID . ' was queued to update it.');
     } else {
         return Redirect::action('ApiKeyController@getNewKey')->withErrors($validation->errors);
     }
 }