コード例 #1
0
 /**
  * Parses common fields for a json response from CloudFlare.
  *
  * @param string $json_response
  *   Response returned from the API.
  */
 public function __construct($json_response)
 {
     Utils::assertParam($json_response, 'string', '$json_response');
     $response = json_decode($json_response, TRUE);
     $this->result = $response['result'];
     $this->success = (bool) $response['success'];
     $this->errors = $response['errors'];
     $this->messages = $response['messages'];
 }
コード例 #2
0
 /**
  * Parses common fields for a json response from CloudFlare.
  *
  * @param string $json_response
  *   Response returned from the API.
  */
 public function __construct($json_response)
 {
     Utils::assertParam($json_response, 'string', '$json_response');
     $response = json_decode($json_response, TRUE);
     $this->result = $response['result'];
     $this->success = (bool) $response['success'];
     $this->errors = $response['errors'];
     $this->messages = $response['messages'];
     $has_pagination_data = isset($response['result_info']['total_count']);
     if ($has_pagination_data) {
         $this->totalCount = $response['result_info']['total_count'];
         $this->page = $response['result_info']['page'];
         $this->resultsPerPage = $response['result_info']['per_page'];
         $this->numPages = $response['result_info']['total_pages'];
     }
 }