analytics-admin
3 years ago
class-ga-lib-api-client-exception.php
4 years ago
class-ga-lib-api-client.php
4 years ago
class-ga-lib-api-request-exception.php
4 years ago
class-ga-lib-api-request.php
4 years ago
class-ga-lib-api-response.php
4 years ago
class-ga-lib-google-api-client-accountsummaries-exception.php
4 years ago
class-ga-lib-google-api-client-authcode-exception.php
4 years ago
class-ga-lib-google-api-client-data-exception.php
4 years ago
class-ga-lib-google-api-client-exception.php
4 years ago
class-ga-lib-google-api-client-refreshtoken-exception.php
4 years ago
class-ga-lib-google-api-client.php
4 years ago
class-ga-lib-sharethis-api-client-alerts-exception.php
4 years ago
class-ga-lib-sharethis-api-client-exception.php
4 years ago
class-ga-lib-sharethis-api-client-invaliddomain-exception.php
4 years ago
class-ga-lib-sharethis-api-client-invite-exception.php
4 years ago
class-ga-lib-sharethis-api-client-verify-exception.php
4 years ago
class-ga-lib-sharethis-api-client.php
4 years ago
class-ga-lib-api-response.php
114 lines
| 1 | <?php |
| 2 | /** |
| 3 | * API Response library. |
| 4 | * |
| 5 | * @package GoogleAnalytics |
| 6 | */ |
| 7 | |
| 8 | /** |
| 9 | * API Response Library response. |
| 10 | */ |
| 11 | class Ga_Lib_Api_Response { |
| 12 | |
| 13 | /** |
| 14 | * Emtpy response. |
| 15 | * |
| 16 | * @var string[] |
| 17 | */ |
| 18 | public static $empty_response = array( '', '' ); |
| 19 | |
| 20 | /** |
| 21 | * Header. |
| 22 | * |
| 23 | * @var mixed |
| 24 | */ |
| 25 | private $header; |
| 26 | |
| 27 | /** |
| 28 | * Body. |
| 29 | * |
| 30 | * @var mixed |
| 31 | */ |
| 32 | private $body; |
| 33 | |
| 34 | /** |
| 35 | * Data. |
| 36 | * |
| 37 | * @var mixed |
| 38 | */ |
| 39 | private $data; |
| 40 | |
| 41 | /** |
| 42 | * Constructor. |
| 43 | * |
| 44 | * @param array|null $raw_response Raw response array. |
| 45 | */ |
| 46 | public function __construct( $raw_response = null ) { |
| 47 | if ( false === empty( $raw_response ) ) { |
| 48 | $this->set_header( $raw_response[0] ); |
| 49 | $this->set_body( $raw_response[1] ); |
| 50 | $this->set_data( json_decode( $raw_response[1], true ) ); |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * Set header. |
| 56 | * |
| 57 | * @param mixed $header Header. |
| 58 | * |
| 59 | * @return void |
| 60 | */ |
| 61 | public function set_header( $header ) { |
| 62 | $this->header = $header; |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * Get header. |
| 67 | * |
| 68 | * @return mixed |
| 69 | */ |
| 70 | public function get_header() { |
| 71 | return $this->header; |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * Set body. |
| 76 | * |
| 77 | * @param mixed $body Body. |
| 78 | * |
| 79 | * @return void |
| 80 | */ |
| 81 | public function set_body( $body ) { |
| 82 | $this->body = $body; |
| 83 | } |
| 84 | |
| 85 | /** |
| 86 | * Get body. |
| 87 | * |
| 88 | * @return mixed |
| 89 | */ |
| 90 | public function get_body() { |
| 91 | return $this->body; |
| 92 | } |
| 93 | |
| 94 | /** |
| 95 | * Set data. |
| 96 | * |
| 97 | * @param mixed $data Data. |
| 98 | * |
| 99 | * @return void |
| 100 | */ |
| 101 | public function set_data( $data ) { |
| 102 | $this->data = $data; |
| 103 | } |
| 104 | |
| 105 | /** |
| 106 | * Get data. |
| 107 | * |
| 108 | * @return mixed |
| 109 | */ |
| 110 | public function get_data() { |
| 111 | return $this->data; |
| 112 | } |
| 113 | } |
| 114 |