| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace Square\Legacy\Models; |
| 6 |
|
| 7 |
use stdClass; |
| 8 |
|
| 9 |
/** |
| 10 |
* Defines the fields that are included in the response body of |
| 11 |
* a request to the `RetrieveTokenStatus` endpoint. |
| 12 |
*/ |
| 13 |
class RetrieveTokenStatusResponse implements \JsonSerializable |
| 14 |
{ |
| 15 |
/** |
| 16 |
* @var string[]|null |
| 17 |
*/ |
| 18 |
private $scopes; |
| 19 |
|
| 20 |
/** |
| 21 |
* @var string|null |
| 22 |
*/ |
| 23 |
private $expiresAt; |
| 24 |
|
| 25 |
/** |
| 26 |
* @var string|null |
| 27 |
*/ |
| 28 |
private $clientId; |
| 29 |
|
| 30 |
/** |
| 31 |
* @var string|null |
| 32 |
*/ |
| 33 |
private $merchantId; |
| 34 |
|
| 35 |
/** |
| 36 |
* @var Error[]|null |
| 37 |
*/ |
| 38 |
private $errors; |
| 39 |
|
| 40 |
/** |
| 41 |
* Returns Scopes. |
| 42 |
* The list of scopes associated with an access token. |
| 43 |
* |
| 44 |
* @return string[]|null |
| 45 |
*/ |
| 46 |
public function getScopes(): ?array |
| 47 |
{ |
| 48 |
return $this->scopes; |
| 49 |
} |
| 50 |
|
| 51 |
/** |
| 52 |
* Sets Scopes. |
| 53 |
* The list of scopes associated with an access token. |
| 54 |
* |
| 55 |
* @maps scopes |
| 56 |
* |
| 57 |
* @param string[]|null $scopes |
| 58 |
*/ |
| 59 |
public function setScopes(?array $scopes): void |
| 60 |
{ |
| 61 |
$this->scopes = $scopes; |
| 62 |
} |
| 63 |
|
| 64 |
/** |
| 65 |
* Returns Expires At. |
| 66 |
* The date and time when the `access_token` expires, in RFC 3339 format. Empty if the token never |
| 67 |
* expires. |
| 68 |
*/ |
| 69 |
public function getExpiresAt(): ?string |
| 70 |
{ |
| 71 |
return $this->expiresAt; |
| 72 |
} |
| 73 |
|
| 74 |
/** |
| 75 |
* Sets Expires At. |
| 76 |
* The date and time when the `access_token` expires, in RFC 3339 format. Empty if the token never |
| 77 |
* expires. |
| 78 |
* |
| 79 |
* @maps expires_at |
| 80 |
*/ |
| 81 |
public function setExpiresAt(?string $expiresAt): void |
| 82 |
{ |
| 83 |
$this->expiresAt = $expiresAt; |
| 84 |
} |
| 85 |
|
| 86 |
/** |
| 87 |
* Returns Client Id. |
| 88 |
* The Square-issued application ID associated with the access token. This is the same application ID |
| 89 |
* used to obtain the token. |
| 90 |
*/ |
| 91 |
public function getClientId(): ?string |
| 92 |
{ |
| 93 |
return $this->clientId; |
| 94 |
} |
| 95 |
|
| 96 |
/** |
| 97 |
* Sets Client Id. |
| 98 |
* The Square-issued application ID associated with the access token. This is the same application ID |
| 99 |
* used to obtain the token. |
| 100 |
* |
| 101 |
* @maps client_id |
| 102 |
*/ |
| 103 |
public function setClientId(?string $clientId): void |
| 104 |
{ |
| 105 |
$this->clientId = $clientId; |
| 106 |
} |
| 107 |
|
| 108 |
/** |
| 109 |
* Returns Merchant Id. |
| 110 |
* The ID of the authorizing merchant's business. |
| 111 |
*/ |
| 112 |
public function getMerchantId(): ?string |
| 113 |
{ |
| 114 |
return $this->merchantId; |
| 115 |
} |
| 116 |
|
| 117 |
/** |
| 118 |
* Sets Merchant Id. |
| 119 |
* The ID of the authorizing merchant's business. |
| 120 |
* |
| 121 |
* @maps merchant_id |
| 122 |
*/ |
| 123 |
public function setMerchantId(?string $merchantId): void |
| 124 |
{ |
| 125 |
$this->merchantId = $merchantId; |
| 126 |
} |
| 127 |
|
| 128 |
/** |
| 129 |
* Returns Errors. |
| 130 |
* Any errors that occurred during the request. |
| 131 |
* |
| 132 |
* @return Error[]|null |
| 133 |
*/ |
| 134 |
public function getErrors(): ?array |
| 135 |
{ |
| 136 |
return $this->errors; |
| 137 |
} |
| 138 |
|
| 139 |
/** |
| 140 |
* Sets Errors. |
| 141 |
* Any errors that occurred during the request. |
| 142 |
* |
| 143 |
* @maps errors |
| 144 |
* |
| 145 |
* @param Error[]|null $errors |
| 146 |
*/ |
| 147 |
public function setErrors(?array $errors): void |
| 148 |
{ |
| 149 |
$this->errors = $errors; |
| 150 |
} |
| 151 |
|
| 152 |
/** |
| 153 |
* Encode this object to JSON |
| 154 |
* |
| 155 |
* @param bool $asArrayWhenEmpty Whether to serialize this model as an array whenever no fields |
| 156 |
* are set. (default: false) |
| 157 |
* |
| 158 |
* @return array|stdClass |
| 159 |
*/ |
| 160 |
#[\ReturnTypeWillChange] // @phan-suppress-current-line PhanUndeclaredClassAttribute for (php < 8.1) |
| 161 |
public function jsonSerialize(bool $asArrayWhenEmpty = false) |
| 162 |
{ |
| 163 |
$json = []; |
| 164 |
if (isset($this->scopes)) { |
| 165 |
$json['scopes'] = $this->scopes; |
| 166 |
} |
| 167 |
if (isset($this->expiresAt)) { |
| 168 |
$json['expires_at'] = $this->expiresAt; |
| 169 |
} |
| 170 |
if (isset($this->clientId)) { |
| 171 |
$json['client_id'] = $this->clientId; |
| 172 |
} |
| 173 |
if (isset($this->merchantId)) { |
| 174 |
$json['merchant_id'] = $this->merchantId; |
| 175 |
} |
| 176 |
if (isset($this->errors)) { |
| 177 |
$json['errors'] = $this->errors; |
| 178 |
} |
| 179 |
$json = array_filter($json, function ($val) { |
| 180 |
return $val !== null; |
| 181 |
}); |
| 182 |
|
| 183 |
return (!$asArrayWhenEmpty && empty($json)) ? new stdClass() : $json; |
| 184 |
} |
| 185 |
} |
| 186 |
|