|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace RahulGodiyal\PhpUpsApiWrapper\Entity; |
| 4 | + |
| 5 | +class Address |
| 6 | +{ |
| 7 | + private ?string $addressLine1; |
| 8 | + private ?string $addressLine2; |
| 9 | + private ?string $city; |
| 10 | + private ?string $stateProvinceCode; |
| 11 | + private ?string $postalCode; |
| 12 | + private ?string $countryCode; |
| 13 | + |
| 14 | + public function setAddressLine1(string $addressLine1): self |
| 15 | + { |
| 16 | + $this->addressLine1 = $addressLine1; |
| 17 | + return $this; |
| 18 | + } |
| 19 | + |
| 20 | + public function getAddressLine1(): string | null |
| 21 | + { |
| 22 | + return $this->addressLine1; |
| 23 | + } |
| 24 | + |
| 25 | + public function setAddressLine2(string $addressLine2): self |
| 26 | + { |
| 27 | + $this->addressLine2 = $addressLine2; |
| 28 | + return $this; |
| 29 | + } |
| 30 | + |
| 31 | + public function getAddressLine2(): string | null |
| 32 | + { |
| 33 | + return $this->addressLine2; |
| 34 | + } |
| 35 | + |
| 36 | + public function setCity(string $city): self |
| 37 | + { |
| 38 | + $this->city = $city; |
| 39 | + return $this; |
| 40 | + } |
| 41 | + |
| 42 | + public function getCity(): string | null |
| 43 | + { |
| 44 | + return $this->city; |
| 45 | + } |
| 46 | + |
| 47 | + public function setStateProvinceCode(string $state): self |
| 48 | + { |
| 49 | + $this->stateProvinceCode = $state; |
| 50 | + return $this; |
| 51 | + } |
| 52 | + |
| 53 | + public function getStateProvinceCode(): string | null |
| 54 | + { |
| 55 | + return $this->stateProvinceCode; |
| 56 | + } |
| 57 | + |
| 58 | + public function setPostalCode(string $postal_code): self |
| 59 | + { |
| 60 | + $this->postalCode = $postal_code; |
| 61 | + return $this; |
| 62 | + } |
| 63 | + |
| 64 | + public function getPostalCode(): string | null |
| 65 | + { |
| 66 | + return $this->postalCode; |
| 67 | + } |
| 68 | + |
| 69 | + public function setCountryCode(string $country_code): self |
| 70 | + { |
| 71 | + $this->countryCode = $country_code; |
| 72 | + return $this; |
| 73 | + } |
| 74 | + |
| 75 | + public function getCountryCode(): string | null |
| 76 | + { |
| 77 | + return $this->countryCode; |
| 78 | + } |
| 79 | + |
| 80 | + public function toArray(): array |
| 81 | + { |
| 82 | + $address_lines = [$this->addressLine1]; |
| 83 | + |
| 84 | + if ($this->addressLine2) { |
| 85 | + array_push($address_lines, $this->addressLine2); |
| 86 | + } |
| 87 | + |
| 88 | + return [ |
| 89 | + "AddressLine" => $address_lines, |
| 90 | + "City" => $this->city, |
| 91 | + "StateProvinceCode" => $this->stateProvinceCode, |
| 92 | + "PostalCode" => $this->postalCode, |
| 93 | + "CountryCode" => $this->countryCode |
| 94 | + ]; |
| 95 | + } |
| 96 | +} |
0 commit comments