| @@ 10-216 (lines=207) @@ | ||
| 7 | /** |
|
| 8 | * @author Ibrahim Hizeoui <[email protected]> |
|
| 9 | */ |
|
| 10 | class CustomerBillingAddress implements CreatableFromArray |
|
| 11 | { |
|
| 12 | /** |
|
| 13 | * @var string |
|
| 14 | */ |
|
| 15 | private $careOf; |
|
| 16 | ||
| 17 | /** |
|
| 18 | * @var bool |
|
| 19 | */ |
|
| 20 | private $useCareOfAsAttention; |
|
| 21 | ||
| 22 | /** |
|
| 23 | * @var string |
|
| 24 | */ |
|
| 25 | private $streetAddress; |
|
| 26 | ||
| 27 | /** |
|
| 28 | * @var string |
|
| 29 | */ |
|
| 30 | private $zipCode; |
|
| 31 | ||
| 32 | /** |
|
| 33 | * @var string |
|
| 34 | */ |
|
| 35 | private $city; |
|
| 36 | ||
| 37 | /** |
|
| 38 | * @var string |
|
| 39 | */ |
|
| 40 | private $country; |
|
| 41 | ||
| 42 | public function __construct() |
|
| 43 | { |
|
| 44 | } |
|
| 45 | ||
| 46 | /** |
|
| 47 | * @return string |
|
| 48 | */ |
|
| 49 | public function getCareOf() |
|
| 50 | { |
|
| 51 | return $this->careOf; |
|
| 52 | } |
|
| 53 | ||
| 54 | /** |
|
| 55 | * @param string $careOf |
|
| 56 | * |
|
| 57 | * @return CustomerBillingAddress |
|
| 58 | */ |
|
| 59 | public function withCareOf(string $careOf) |
|
| 60 | { |
|
| 61 | $new = clone $this; |
|
| 62 | $new->careOf = $careOf; |
|
| 63 | ||
| 64 | return $new; |
|
| 65 | } |
|
| 66 | ||
| 67 | /** |
|
| 68 | * @return bool |
|
| 69 | */ |
|
| 70 | public function isUseCareOfAsAttention() |
|
| 71 | { |
|
| 72 | return $this->useCareOfAsAttention; |
|
| 73 | } |
|
| 74 | ||
| 75 | /** |
|
| 76 | * @param bool $useCareOfAsAttention |
|
| 77 | * |
|
| 78 | * @return CustomerBillingAddress |
|
| 79 | */ |
|
| 80 | public function withUseCareOfAsAttention(bool $useCareOfAsAttention) |
|
| 81 | { |
|
| 82 | $new = clone $this; |
|
| 83 | $new->useCareOfAsAttention = $useCareOfAsAttention; |
|
| 84 | ||
| 85 | return $new; |
|
| 86 | } |
|
| 87 | ||
| 88 | /** |
|
| 89 | * @return string |
|
| 90 | */ |
|
| 91 | public function getStreetAddress() |
|
| 92 | { |
|
| 93 | return $this->streetAddress; |
|
| 94 | } |
|
| 95 | ||
| 96 | /** |
|
| 97 | * @param string $streetAddress |
|
| 98 | * |
|
| 99 | * @return CustomerBillingAddress |
|
| 100 | */ |
|
| 101 | public function withStreetAddress(string $streetAddress) |
|
| 102 | { |
|
| 103 | $new = clone $this; |
|
| 104 | $new->streetAddress = $streetAddress; |
|
| 105 | ||
| 106 | return $new; |
|
| 107 | } |
|
| 108 | ||
| 109 | /** |
|
| 110 | * @return string |
|
| 111 | */ |
|
| 112 | public function getZipCode() |
|
| 113 | { |
|
| 114 | return $this->zipCode; |
|
| 115 | } |
|
| 116 | ||
| 117 | /** |
|
| 118 | * @param string $zipCode |
|
| 119 | * |
|
| 120 | * @return CustomerBillingAddress |
|
| 121 | */ |
|
| 122 | public function withZipCode(string $zipCode) |
|
| 123 | { |
|
| 124 | $new = clone $this; |
|
| 125 | $new->zipCode = $zipCode; |
|
| 126 | ||
| 127 | return $new; |
|
| 128 | } |
|
| 129 | ||
| 130 | /** |
|
| 131 | * @return string |
|
| 132 | */ |
|
| 133 | public function getCity() |
|
| 134 | { |
|
| 135 | return $this->city; |
|
| 136 | } |
|
| 137 | ||
| 138 | /** |
|
| 139 | * @param string $city |
|
| 140 | * |
|
| 141 | * @return CustomerBillingAddress |
|
| 142 | */ |
|
| 143 | public function withCity(string $city) |
|
| 144 | { |
|
| 145 | $new = clone $this; |
|
| 146 | $new->city = $city; |
|
| 147 | ||
| 148 | return $new; |
|
| 149 | } |
|
| 150 | ||
| 151 | /** |
|
| 152 | * @return string |
|
| 153 | */ |
|
| 154 | public function getCountry() |
|
| 155 | { |
|
| 156 | return $this->country; |
|
| 157 | } |
|
| 158 | ||
| 159 | /** |
|
| 160 | * @param string $country |
|
| 161 | * |
|
| 162 | * @return CustomerBillingAddress |
|
| 163 | */ |
|
| 164 | public function withCountry(string $country) |
|
| 165 | { |
|
| 166 | $new = clone $this; |
|
| 167 | $new->country = $country; |
|
| 168 | ||
| 169 | return $new; |
|
| 170 | } |
|
| 171 | ||
| 172 | public function toArray() |
|
| 173 | { |
|
| 174 | $data = []; |
|
| 175 | if ($this->careOf !== null) { |
|
| 176 | $data['careof'] = $this->careOf; |
|
| 177 | } |
|
| 178 | if ($this->useCareOfAsAttention !== null) { |
|
| 179 | $data['use_careof_as_attention'] = $this->useCareOfAsAttention; |
|
| 180 | } |
|
| 181 | if ($this->streetAddress !== null) { |
|
| 182 | $data['street_address'] = $this->streetAddress; |
|
| 183 | } |
|
| 184 | if ($this->zipCode !== null) { |
|
| 185 | $data['zipcode'] = $this->zipCode; |
|
| 186 | } |
|
| 187 | if ($this->city !== null) { |
|
| 188 | $data['city'] = $this->city; |
|
| 189 | } |
|
| 190 | if ($this->country !== null) { |
|
| 191 | $data['country'] = $this->country; |
|
| 192 | } |
|
| 193 | ||
| 194 | return $data; |
|
| 195 | } |
|
| 196 | ||
| 197 | /** |
|
| 198 | * Create an API response object from the HTTP response from the API server. |
|
| 199 | * |
|
| 200 | * @param array $data |
|
| 201 | * |
|
| 202 | * @return self |
|
| 203 | */ |
|
| 204 | public static function createFromArray(array $data) |
|
| 205 | { |
|
| 206 | $customerBillingAddress = new self(); |
|
| 207 | $customerBillingAddress->careOf = $data['careof']; |
|
| 208 | $customerBillingAddress->useCareOfAsAttention = $data['use_careof_as_attention']; |
|
| 209 | $customerBillingAddress->streetAddress = $data['street_address']; |
|
| 210 | $customerBillingAddress->zipCode = $data['zipcode']; |
|
| 211 | $customerBillingAddress->city = $data['city']; |
|
| 212 | $customerBillingAddress->country = $data['country']; |
|
| 213 | ||
| 214 | return $customerBillingAddress; |
|
| 215 | } |
|
| 216 | } |
|
| 217 | ||
| @@ 10-216 (lines=207) @@ | ||
| 7 | /** |
|
| 8 | * @author Ibrahim Hizeoui <[email protected]> |
|
| 9 | */ |
|
| 10 | class CustomerDeliveryAddress implements CreatableFromArray |
|
| 11 | { |
|
| 12 | /** |
|
| 13 | * @var string |
|
| 14 | */ |
|
| 15 | private $name; |
|
| 16 | ||
| 17 | /** |
|
| 18 | * @var string |
|
| 19 | */ |
|
| 20 | private $streetAddress; |
|
| 21 | ||
| 22 | /** |
|
| 23 | * @var string |
|
| 24 | */ |
|
| 25 | private $careOf; |
|
| 26 | ||
| 27 | /** |
|
| 28 | * @var string |
|
| 29 | */ |
|
| 30 | private $zipCode; |
|
| 31 | ||
| 32 | /** |
|
| 33 | * @var string |
|
| 34 | */ |
|
| 35 | private $city; |
|
| 36 | ||
| 37 | /** |
|
| 38 | * @var string |
|
| 39 | */ |
|
| 40 | private $country; |
|
| 41 | ||
| 42 | public function __construct() |
|
| 43 | { |
|
| 44 | } |
|
| 45 | ||
| 46 | /** |
|
| 47 | * @return string |
|
| 48 | */ |
|
| 49 | public function getName() |
|
| 50 | { |
|
| 51 | return $this->name; |
|
| 52 | } |
|
| 53 | ||
| 54 | /** |
|
| 55 | * @param string $name |
|
| 56 | * |
|
| 57 | * @return CustomerDeliveryAddress |
|
| 58 | */ |
|
| 59 | public function withName(string $name) |
|
| 60 | { |
|
| 61 | $new = clone $this; |
|
| 62 | $new->name = $name; |
|
| 63 | ||
| 64 | return $new; |
|
| 65 | } |
|
| 66 | ||
| 67 | /** |
|
| 68 | * @return string |
|
| 69 | */ |
|
| 70 | public function getStreetAddress() |
|
| 71 | { |
|
| 72 | return $this->streetAddress; |
|
| 73 | } |
|
| 74 | ||
| 75 | /** |
|
| 76 | * @param string $streetAddress |
|
| 77 | * |
|
| 78 | * @return CustomerDeliveryAddress |
|
| 79 | */ |
|
| 80 | public function withStreetAddress(string $streetAddress) |
|
| 81 | { |
|
| 82 | $new = clone $this; |
|
| 83 | $new->streetAddress = $streetAddress; |
|
| 84 | ||
| 85 | return $new; |
|
| 86 | } |
|
| 87 | ||
| 88 | /** |
|
| 89 | * @return string |
|
| 90 | */ |
|
| 91 | public function getCareOf() |
|
| 92 | { |
|
| 93 | return $this->careOf; |
|
| 94 | } |
|
| 95 | ||
| 96 | /** |
|
| 97 | * @param string $careOf |
|
| 98 | * |
|
| 99 | * @return CustomerDeliveryAddress |
|
| 100 | */ |
|
| 101 | public function withCareOf(string $careOf) |
|
| 102 | { |
|
| 103 | $new = clone $this; |
|
| 104 | $new->zipCode = $careOf; |
|
| 105 | ||
| 106 | return $new; |
|
| 107 | } |
|
| 108 | ||
| 109 | /** |
|
| 110 | * @return string |
|
| 111 | */ |
|
| 112 | public function getZipCode() |
|
| 113 | { |
|
| 114 | return $this->zipCode; |
|
| 115 | } |
|
| 116 | ||
| 117 | /** |
|
| 118 | * @param string $zipCode |
|
| 119 | * |
|
| 120 | * @return CustomerDeliveryAddress |
|
| 121 | */ |
|
| 122 | public function withZipCode(string $zipCode) |
|
| 123 | { |
|
| 124 | $new = clone $this; |
|
| 125 | $new->zipCode = $zipCode; |
|
| 126 | ||
| 127 | return $new; |
|
| 128 | } |
|
| 129 | ||
| 130 | /** |
|
| 131 | * @return string |
|
| 132 | */ |
|
| 133 | public function getCity() |
|
| 134 | { |
|
| 135 | return $this->city; |
|
| 136 | } |
|
| 137 | ||
| 138 | /** |
|
| 139 | * @param string $city |
|
| 140 | * |
|
| 141 | * @return CustomerDeliveryAddress |
|
| 142 | */ |
|
| 143 | public function withCity(string $city) |
|
| 144 | { |
|
| 145 | $new = clone $this; |
|
| 146 | $new->city = $city; |
|
| 147 | ||
| 148 | return $new; |
|
| 149 | } |
|
| 150 | ||
| 151 | /** |
|
| 152 | * @return string |
|
| 153 | */ |
|
| 154 | public function getCountry() |
|
| 155 | { |
|
| 156 | return $this->country; |
|
| 157 | } |
|
| 158 | ||
| 159 | /** |
|
| 160 | * @param string $country |
|
| 161 | * |
|
| 162 | * @return CustomerDeliveryAddress |
|
| 163 | */ |
|
| 164 | public function withCountry(string $country) |
|
| 165 | { |
|
| 166 | $new = clone $this; |
|
| 167 | $new->country = $country; |
|
| 168 | ||
| 169 | return $new; |
|
| 170 | } |
|
| 171 | ||
| 172 | public function toArray() |
|
| 173 | { |
|
| 174 | $data = []; |
|
| 175 | if ($this->name !== null) { |
|
| 176 | $data['name'] = $this->name; |
|
| 177 | } |
|
| 178 | if ($this->streetAddress !== null) { |
|
| 179 | $data['street_address'] = $this->streetAddress; |
|
| 180 | } |
|
| 181 | if ($this->careOf !== null) { |
|
| 182 | $data['careof'] = $this->careOf; |
|
| 183 | } |
|
| 184 | if ($this->zipCode !== null) { |
|
| 185 | $data['zipcode'] = $this->zipCode; |
|
| 186 | } |
|
| 187 | if ($this->city !== null) { |
|
| 188 | $data['city'] = $this->city; |
|
| 189 | } |
|
| 190 | if ($this->country !== null) { |
|
| 191 | $data['country'] = $this->country; |
|
| 192 | } |
|
| 193 | ||
| 194 | return $data; |
|
| 195 | } |
|
| 196 | ||
| 197 | /** |
|
| 198 | * Create an API response object from the HTTP response from the API server. |
|
| 199 | * |
|
| 200 | * @param array $data |
|
| 201 | * |
|
| 202 | * @return self |
|
| 203 | */ |
|
| 204 | public static function createFromArray(array $data) |
|
| 205 | { |
|
| 206 | $customerDeliveryAddress = new self(); |
|
| 207 | $customerDeliveryAddress->name = $data['name']; |
|
| 208 | $customerDeliveryAddress->streetAddress = $data['street_address']; |
|
| 209 | $customerDeliveryAddress->careOf = $data['careof']; |
|
| 210 | $customerDeliveryAddress->zipCode = $data['zipcode']; |
|
| 211 | $customerDeliveryAddress->city = $data['city']; |
|
| 212 | $customerDeliveryAddress->country = $data['country']; |
|
| 213 | ||
| 214 | return $customerDeliveryAddress; |
|
| 215 | } |
|
| 216 | } |
|
| 217 | ||