This is a refactoring of the Factual Driver by Aaron: https://github.com/Factual/factual-java-driver
Author: Tyler
Ejemplo n.º 1
0
 /**
  * Parses response from CURL
  * @param array apiResponse response from curl
  * @return void
  */
 protected function parseResponse($apiResponse)
 {
     parent::parseResponse($apiResponse);
     //assign metadata specific to this call
     $this->diffStart = $apiResponse['diffsmeta']['start'];
     $this->diffEnd = $apiResponse['diffsmeta']['end'];
     $this->duration = $apiResponse['diffsmeta']['end'] - $apiResponse['diffsmeta']['start'];
 }
Ejemplo n.º 2
0
 protected function parseJSON($json)
 {
     $rootJSON = parent::parseJSON($json);
     //set factual ID
     if ($rootJSON['response']['included_rows'] == 1) {
         $this->factualID = $rootJSON['response']['data'][0]['factual_id'];
     }
     return $rootJSON;
 }
Ejemplo n.º 3
0
 /**
  * Parses JSON as array and assigns object values
  * @param string json JSON returned from API
  * @return array structured JSON
  */
 protected function parseJSON($json)
 {
     $rootJSON = parent::parseJSON($json);
     $this->title = $rootJSON['response']['view']['title'];
     $this->description = $rootJSON['response']['view']['description'];
     $this->makeColumnSchemas($rootJSON['response']['view']['fields']);
     $this->searchEnabled = (bool) $rootJSON['response']['view']['search_enabled'];
     $this->geoEnabled = (bool) $rootJSON['response']['view']['geo_enabled'];
     return $rootJSON;
 }
Ejemplo n.º 4
0
 /**
  * Parses JSON as array and assigns object values
  * @param string json JSON returned from API
  * @return array structured JSON
  */
 protected function parseJSON($json)
 {
     $rootJSON = parent::parseJSON($json);
     $this->commitID = $rootJSON['response']['commit_id'];
     if (isset($this->newEntity)) {
         $this->newEntity = (bool) $rootJSON['response']['new_entity'];
     }
     if (isset($rootJSON['response']['factual_id'])) {
         $this->factualID = $rootJSON['response']['factual_id'];
     }
     return $rootJSON;
 }
Ejemplo n.º 5
0
 /**
  * Parses JSON as array and assigns object values
  * @param string json JSON returned from API
  * @return array structured JSON
  */
 protected function parseJSON($json)
 {
     $rootJSON = parent::parseJSON($json);
     //assign total row count
     if (isset($rootJSON['response']['total_row_count'])) {
         $this->totalRowCount = $rootJSON['response']['total_row_count'];
     }
     if (isset($rootJSON['response']['included_rows'])) {
         $this->includedRows = $rootJSON['response']['included_rows'];
     }
     //assign data
     $this->assignData($rootJSON['response']['data']);
     return $rootJSON;
 }
Ejemplo n.º 6
0
 protected function parseJSON($json)
 {
     $rootJSON = parent::parseJSON($json);
     //Check against rowcount and resolve flag
     if ($rootJSON['response']['included_rows'] == 1 || $rootJSON['response']['included_rows'] > 1) {
         if ($rootJSON['response']['data'][0]['resolved']) {
             $this->resolved = $rootJSON['response']['data'][0];
             unset($this->resolved['resolved']);
             //remove old flag
         }
     }
     $this->data = $rootJSON['response']['data'];
     return $rootJSON;
 }
Ejemplo n.º 7
0
 /**
  * Parses JSON as array and assigns object values
  * @param string json JSON returned from API
  * @return array structured JSON
  */
 protected function parseJSON($json)
 {
     $rootJSON = parent::parseJSON($json);
     //in some instances writes to the system will be delayed, and we cannot provide a committ ID
     if (array_key_exists('error_type', $rootJSON) && $rootJSON['error_type'] == "DelayedResponse") {
         //throw new Exception($rootJSON['message']);
         $this->isDelayed = true;
     } else {
         $this->commitID = $rootJSON['response']['commit_id'];
         if (isset($this->newEntity)) {
             $this->newEntity = (bool) $rootJSON['response']['new_entity'];
         }
         if (isset($rootJSON['response']['factual_id'])) {
             $this->factualID = $rootJSON['response']['factual_id'];
         }
     }
     return $rootJSON;
 }
Ejemplo n.º 8
0
 /**
  * Constructor, parses return values from CURL in factual::request() 
  * @param array response The JSON response String returned by Factual.
  */
 public function __construct($apiResponse, $responseTypes)
 {
     $this->responseTypes = $responseTypes;
     //pass response types from query. Do this before parent
     parent::__construct($apiResponse);
 }