/**
  * 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'];
 }
 /**
  * Constructor for ZoneSettings.
  *
  * @param string $zone_id
  *   The zone's zoneId.
  * @param \CloudFlarePhpSdk\ApiTypes\CloudFlareApiResponse $query_results
  *   The results from an API Zone Settings Query.
  */
 public function __construct($zone_id, CloudFlareApiResponse $query_results)
 {
     $this->id = $zone_id;
     foreach ($query_results->getResult() as $raw_setting) {
         // @todo would like to add some stronger parsing/validation here and
         // Potentially break it out into a separate class with a single
         // responsibility for parsing.
         $setting_name = $raw_setting[self::SETTING_WRAPPER_ID];
         $modified_time = Utils::parseCloudFlareDate($raw_setting[self::SETTING_WRAPPER_MODIFIED_ON]);
         $editable = $raw_setting[self::SETTING_WRAPPER_EDITABLE];
         $value = $raw_setting[self::SETTING_WRAPPER_VALUE];
         // Parse the boolean values into ZoneSettingBools.
         if (in_array($setting_name, $this->getBooleanSettings())) {
             $this->settings[$setting_name] = new ZoneSettingBool($value, $setting_name, $editable, $modified_time);
         } else {
             switch ($setting_name) {
                 case self::SETTING_BROWSER_CACHE_TTL:
                     $this->settings[$setting_name] = new ZoneSettingBrowserCacheTtl($value, $setting_name, $editable, $modified_time);
                     break;
                 case self::SETTING_CHALLENGE_TTL:
                     $this->settings[$setting_name] = new ZoneSettingChallengeTtl($value, $setting_name, $editable, $modified_time);
                     break;
                 case self::SETTING_MINIFY:
                     $css = $value[self::SETTING_MINIFY_CSS];
                     $html = $value[self::SETTING_MINIFY_HTML];
                     $js = $value[self::SETTING_MINIFY_JS];
                     $this->settings[$setting_name] = new ZoneSettingMinify($css, $html, $js, $setting_name, $editable, $modified_time);
                     break;
                 case self::SETTING_MOBILE_REDIRECT:
                     $is_mobile_redirect_enabled = (bool) $value[self::SETTING_MOBILE_REDIRECT_ENABLED];
                     $mobile_subdomain = $value[self::SETTING_MOBILE_REDIRECT_MOBILE_SUBDOMAIN];
                     $is_strip_uri_enabled = (bool) $value[self::SETTING_MOBILE_REDIRECT_STRIP_URI];
                     $this->settings[$setting_name] = new ZoneSettingMobileRedirect($is_mobile_redirect_enabled, $mobile_subdomain, $is_strip_uri_enabled, $setting_name, $editable, $modified_time);
                     break;
                 case self::SETTING_SECURITY_HEADER:
                     $this->settings[$setting_name] = new ZoneSettingSecurityHeader($value, $setting_name, $editable, $modified_time);
                     break;
                 case self::SETTING_SECURITY_LEVEL:
                     $this->settings[$setting_name] = new ZoneSettingSecurityLevel($value, $setting_name, $editable, $modified_time);
                     break;
                 case self::SETTING_SSL:
                     $this->settings[$setting_name] = new ZoneSettingSsl($value, $setting_name, $editable, $modified_time);
                     break;
             }
         }
     }
 }
 /**
  * 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'];
     }
 }