*/ class Shipping implements ModelInterface, ArrayAccess, \JsonSerializable { public const DISCRIMINATOR = null; /** * The original name of the model. * * @var string */ protected static $openAPIModelName = 'shipping'; /** * Array of property to type mappings. Used for (de)serialization * * @var string[] */ protected static $openAPITypes = [ 'last_name' => 'string', 'first_name' => 'string', 'address' => 'string', 'city' => 'string', 'postcode' => 'string', 'state' => 'string', 'country' => 'string', 'country_code' => 'string', 'phone' => 'string', 'cellphone' => 'string', 'email' => 'string' ]; /** * Array of property to format mappings. Used for (de)serialization * * @var string[] * @phpstan-var array * @psalm-var array */ protected static $openAPIFormats = [ 'last_name' => null, 'first_name' => null, 'address' => null, 'city' => null, 'postcode' => null, 'state' => null, 'country' => null, 'country_code' => null, 'phone' => null, 'cellphone' => null, 'email' => null ]; /** * Array of nullable properties. Used for (de)serialization * * @var boolean[] */ protected static array $openAPINullables = [ 'last_name' => true, 'first_name' => true, 'address' => true, 'city' => true, 'postcode' => true, 'state' => true, 'country' => true, 'country_code' => true, 'phone' => true, 'cellphone' => true, 'email' => true ]; /** * If a nullable field gets set to null, insert it here * * @var boolean[] */ protected array $openAPINullablesSetToNull = []; /** * Array of property to type mappings. Used for (de)serialization * * @return array */ public static function openAPITypes() { return self::$openAPITypes; } /** * Array of property to format mappings. Used for (de)serialization * * @return array */ public static function openAPIFormats() { return self::$openAPIFormats; } /** * Array of nullable properties * * @return array */ protected static function openAPINullables(): array { return self::$openAPINullables; } /** * Array of nullable field names deliberately set to null * * @return boolean[] */ private function getOpenAPINullablesSetToNull(): array { return $this->openAPINullablesSetToNull; } /** * Setter - Array of nullable field names deliberately set to null * * @param boolean[] $openAPINullablesSetToNull */ private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void { $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; } /** * Checks if a property is nullable * * @param string $property * @return bool */ public static function isNullable(string $property): bool { return self::openAPINullables()[$property] ?? false; } /** * Checks if a nullable property is set to null. * * @param string $property * @return bool */ public function isNullableSetToNull(string $property): bool { return in_array($property, $this->getOpenAPINullablesSetToNull(), true); } /** * Array of attributes where the key is the local name, * and the value is the original name * * @var string[] */ protected static $attributeMap = [ 'last_name' => 'lastName', 'first_name' => 'firstName', 'address' => 'address', 'city' => 'city', 'postcode' => 'postcode', 'state' => 'state', 'country' => 'country', 'country_code' => 'countryCode', 'phone' => 'phone', 'cellphone' => 'cellphone', 'email' => 'email' ]; /** * Array of attributes to setter functions (for deserialization of responses) * * @var string[] */ protected static $setters = [ 'last_name' => 'setLastName', 'first_name' => 'setFirstName', 'address' => 'setAddress', 'city' => 'setCity', 'postcode' => 'setPostcode', 'state' => 'setState', 'country' => 'setCountry', 'country_code' => 'setCountryCode', 'phone' => 'setPhone', 'cellphone' => 'setCellphone', 'email' => 'setEmail' ]; /** * Array of attributes to getter functions (for serialization of requests) * * @var string[] */ protected static $getters = [ 'last_name' => 'getLastName', 'first_name' => 'getFirstName', 'address' => 'getAddress', 'city' => 'getCity', 'postcode' => 'getPostcode', 'state' => 'getState', 'country' => 'getCountry', 'country_code' => 'getCountryCode', 'phone' => 'getPhone', 'cellphone' => 'getCellphone', 'email' => 'getEmail' ]; /** * Array of attributes where the key is the local name, * and the value is the original name * * @return array */ public static function attributeMap() { return self::$attributeMap; } /** * Array of attributes to setter functions (for deserialization of responses) * * @return array */ public static function setters() { return self::$setters; } /** * Array of attributes to getter functions (for serialization of requests) * * @return array */ public static function getters() { return self::$getters; } /** * The original name of the model. * * @return string */ public function getModelName() { return self::$openAPIModelName; } /** * Associative array for storing property values * * @var mixed[] */ protected $container = []; /** * Constructor * * @param mixed[]|null $data Associated array of property values * initializing the model */ public function __construct(?array $data = null) { $this->setIfExists('last_name', $data ?? [], null); $this->setIfExists('first_name', $data ?? [], null); $this->setIfExists('address', $data ?? [], null); $this->setIfExists('city', $data ?? [], null); $this->setIfExists('postcode', $data ?? [], null); $this->setIfExists('state', $data ?? [], null); $this->setIfExists('country', $data ?? [], null); $this->setIfExists('country_code', $data ?? [], null); $this->setIfExists('phone', $data ?? [], null); $this->setIfExists('cellphone', $data ?? [], null); $this->setIfExists('email', $data ?? [], null); } /** * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the * $this->openAPINullablesSetToNull array * * @param string $variableName * @param array $fields * @param mixed $defaultValue */ private function setIfExists(string $variableName, array $fields, $defaultValue): void { if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { $this->openAPINullablesSetToNull[] = $variableName; } $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; } /** * Show all the invalid properties with reasons. * * @return array invalid properties with reasons */ public function listInvalidProperties() { $invalidProperties = []; if (!is_null($this->container['last_name']) && (mb_strlen($this->container['last_name']) > 60)) { $invalidProperties[] = "invalid value for 'last_name', the character length must be smaller than or equal to 60."; } if (!is_null($this->container['last_name']) && (mb_strlen($this->container['last_name']) < 1)) { $invalidProperties[] = "invalid value for 'last_name', the character length must be bigger than or equal to 1."; } if (!is_null($this->container['first_name']) && (mb_strlen($this->container['first_name']) > 60)) { $invalidProperties[] = "invalid value for 'first_name', the character length must be smaller than or equal to 60."; } if (!is_null($this->container['first_name']) && (mb_strlen($this->container['first_name']) < 1)) { $invalidProperties[] = "invalid value for 'first_name', the character length must be bigger than or equal to 1."; } if (!is_null($this->container['address']) && (mb_strlen($this->container['address']) > 120)) { $invalidProperties[] = "invalid value for 'address', the character length must be smaller than or equal to 120."; } if (!is_null($this->container['city']) && (mb_strlen($this->container['city']) > 60)) { $invalidProperties[] = "invalid value for 'city', the character length must be smaller than or equal to 60."; } if (!is_null($this->container['postcode']) && (mb_strlen($this->container['postcode']) > 10)) { $invalidProperties[] = "invalid value for 'postcode', the character length must be smaller than or equal to 10."; } if (!is_null($this->container['state']) && (mb_strlen($this->container['state']) > 60)) { $invalidProperties[] = "invalid value for 'state', the character length must be smaller than or equal to 60."; } if (!is_null($this->container['country']) && (mb_strlen($this->container['country']) > 20)) { $invalidProperties[] = "invalid value for 'country', the character length must be smaller than or equal to 20."; } if (!is_null($this->container['country_code']) && (mb_strlen($this->container['country_code']) > 2)) { $invalidProperties[] = "invalid value for 'country_code', the character length must be smaller than or equal to 2."; } if (!is_null($this->container['phone']) && (mb_strlen($this->container['phone']) > 15)) { $invalidProperties[] = "invalid value for 'phone', the character length must be smaller than or equal to 15."; } if (!is_null($this->container['cellphone']) && (mb_strlen($this->container['cellphone']) > 15)) { $invalidProperties[] = "invalid value for 'cellphone', the character length must be smaller than or equal to 15."; } if (!is_null($this->container['email']) && (mb_strlen($this->container['email']) > 60)) { $invalidProperties[] = "invalid value for 'email', the character length must be smaller than or equal to 60."; } return $invalidProperties; } /** * Validate all the properties in the model * return true if all passed * * @return bool True if all properties are valid */ public function valid() { return count($this->listInvalidProperties()) === 0; } /** * Gets last_name * * @return string|null */ public function getLastName() { return $this->container['last_name']; } /** * Sets last_name * * @param string|null $last_name last_name * * @return self */ public function setLastName($last_name) { if (is_null($last_name)) { array_push($this->openAPINullablesSetToNull, 'last_name'); } else { $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); $index = array_search('last_name', $nullablesSetToNull); if ($index !== FALSE) { unset($nullablesSetToNull[$index]); $this->setOpenAPINullablesSetToNull($nullablesSetToNull); } } if (!is_null($last_name) && (mb_strlen($last_name) > 60)) { throw new \InvalidArgumentException('invalid length for $last_name when calling Shipping., must be smaller than or equal to 60.'); } if (!is_null($last_name) && (mb_strlen($last_name) < 1)) { throw new \InvalidArgumentException('invalid length for $last_name when calling Shipping., must be bigger than or equal to 1.'); } $this->container['last_name'] = $last_name; return $this; } /** * Gets first_name * * @return string|null */ public function getFirstName() { return $this->container['first_name']; } /** * Sets first_name * * @param string|null $first_name first_name * * @return self */ public function setFirstName($first_name) { if (is_null($first_name)) { array_push($this->openAPINullablesSetToNull, 'first_name'); } else { $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); $index = array_search('first_name', $nullablesSetToNull); if ($index !== FALSE) { unset($nullablesSetToNull[$index]); $this->setOpenAPINullablesSetToNull($nullablesSetToNull); } } if (!is_null($first_name) && (mb_strlen($first_name) > 60)) { throw new \InvalidArgumentException('invalid length for $first_name when calling Shipping., must be smaller than or equal to 60.'); } if (!is_null($first_name) && (mb_strlen($first_name) < 1)) { throw new \InvalidArgumentException('invalid length for $first_name when calling Shipping., must be bigger than or equal to 1.'); } $this->container['first_name'] = $first_name; return $this; } /** * Gets address * * @return string|null */ public function getAddress() { return $this->container['address']; } /** * Sets address * * @param string|null $address address * * @return self */ public function setAddress($address) { if (is_null($address)) { array_push($this->openAPINullablesSetToNull, 'address'); } else { $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); $index = array_search('address', $nullablesSetToNull); if ($index !== FALSE) { unset($nullablesSetToNull[$index]); $this->setOpenAPINullablesSetToNull($nullablesSetToNull); } } if (!is_null($address) && (mb_strlen($address) > 120)) { throw new \InvalidArgumentException('invalid length for $address when calling Shipping., must be smaller than or equal to 120.'); } $this->container['address'] = $address; return $this; } /** * Gets city * * @return string|null */ public function getCity() { return $this->container['city']; } /** * Sets city * * @param string|null $city city * * @return self */ public function setCity($city) { if (is_null($city)) { array_push($this->openAPINullablesSetToNull, 'city'); } else { $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); $index = array_search('city', $nullablesSetToNull); if ($index !== FALSE) { unset($nullablesSetToNull[$index]); $this->setOpenAPINullablesSetToNull($nullablesSetToNull); } } if (!is_null($city) && (mb_strlen($city) > 60)) { throw new \InvalidArgumentException('invalid length for $city when calling Shipping., must be smaller than or equal to 60.'); } $this->container['city'] = $city; return $this; } /** * Gets postcode * * @return string|null */ public function getPostcode() { return $this->container['postcode']; } /** * Sets postcode * * @param string|null $postcode postcode * * @return self */ public function setPostcode($postcode) { if (is_null($postcode)) { array_push($this->openAPINullablesSetToNull, 'postcode'); } else { $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); $index = array_search('postcode', $nullablesSetToNull); if ($index !== FALSE) { unset($nullablesSetToNull[$index]); $this->setOpenAPINullablesSetToNull($nullablesSetToNull); } } if (!is_null($postcode) && (mb_strlen($postcode) > 10)) { throw new \InvalidArgumentException('invalid length for $postcode when calling Shipping., must be smaller than or equal to 10.'); } $this->container['postcode'] = $postcode; return $this; } /** * Gets state * * @return string|null */ public function getState() { return $this->container['state']; } /** * Sets state * * @param string|null $state state * * @return self */ public function setState($state) { if (is_null($state)) { array_push($this->openAPINullablesSetToNull, 'state'); } else { $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); $index = array_search('state', $nullablesSetToNull); if ($index !== FALSE) { unset($nullablesSetToNull[$index]); $this->setOpenAPINullablesSetToNull($nullablesSetToNull); } } if (!is_null($state) && (mb_strlen($state) > 60)) { throw new \InvalidArgumentException('invalid length for $state when calling Shipping., must be smaller than or equal to 60.'); } $this->container['state'] = $state; return $this; } /** * Gets country * * @return string|null */ public function getCountry() { return $this->container['country']; } /** * Sets country * * @param string|null $country country * * @return self */ public function setCountry($country) { if (is_null($country)) { array_push($this->openAPINullablesSetToNull, 'country'); } else { $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); $index = array_search('country', $nullablesSetToNull); if ($index !== FALSE) { unset($nullablesSetToNull[$index]); $this->setOpenAPINullablesSetToNull($nullablesSetToNull); } } if (!is_null($country) && (mb_strlen($country) > 20)) { throw new \InvalidArgumentException('invalid length for $country when calling Shipping., must be smaller than or equal to 20.'); } $this->container['country'] = $country; return $this; } /** * Gets country_code * * @return string|null */ public function getCountryCode() { return $this->container['country_code']; } /** * Sets country_code * * @param string|null $country_code country_code * * @return self */ public function setCountryCode($country_code) { if (is_null($country_code)) { array_push($this->openAPINullablesSetToNull, 'country_code'); } else { $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); $index = array_search('country_code', $nullablesSetToNull); if ($index !== FALSE) { unset($nullablesSetToNull[$index]); $this->setOpenAPINullablesSetToNull($nullablesSetToNull); } } if (!is_null($country_code) && (mb_strlen($country_code) > 2)) { throw new \InvalidArgumentException('invalid length for $country_code when calling Shipping., must be smaller than or equal to 2.'); } $this->container['country_code'] = $country_code; return $this; } /** * Gets phone * * @return string|null */ public function getPhone() { return $this->container['phone']; } /** * Sets phone * * @param string|null $phone phone * * @return self */ public function setPhone($phone) { if (is_null($phone)) { array_push($this->openAPINullablesSetToNull, 'phone'); } else { $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); $index = array_search('phone', $nullablesSetToNull); if ($index !== FALSE) { unset($nullablesSetToNull[$index]); $this->setOpenAPINullablesSetToNull($nullablesSetToNull); } } if (!is_null($phone) && (mb_strlen($phone) > 15)) { throw new \InvalidArgumentException('invalid length for $phone when calling Shipping., must be smaller than or equal to 15.'); } $this->container['phone'] = $phone; return $this; } /** * Gets cellphone * * @return string|null */ public function getCellphone() { return $this->container['cellphone']; } /** * Sets cellphone * * @param string|null $cellphone cellphone * * @return self */ public function setCellphone($cellphone) { if (is_null($cellphone)) { array_push($this->openAPINullablesSetToNull, 'cellphone'); } else { $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); $index = array_search('cellphone', $nullablesSetToNull); if ($index !== FALSE) { unset($nullablesSetToNull[$index]); $this->setOpenAPINullablesSetToNull($nullablesSetToNull); } } if (!is_null($cellphone) && (mb_strlen($cellphone) > 15)) { throw new \InvalidArgumentException('invalid length for $cellphone when calling Shipping., must be smaller than or equal to 15.'); } $this->container['cellphone'] = $cellphone; return $this; } /** * Gets email * * @return string|null */ public function getEmail() { return $this->container['email']; } /** * Sets email * * @param string|null $email email * * @return self */ public function setEmail($email) { if (is_null($email)) { array_push($this->openAPINullablesSetToNull, 'email'); } else { $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); $index = array_search('email', $nullablesSetToNull); if ($index !== FALSE) { unset($nullablesSetToNull[$index]); $this->setOpenAPINullablesSetToNull($nullablesSetToNull); } } if (!is_null($email) && (mb_strlen($email) > 60)) { throw new \InvalidArgumentException('invalid length for $email when calling Shipping., must be smaller than or equal to 60.'); } $this->container['email'] = $email; return $this; } /** * Returns true if offset exists. False otherwise. * * @param integer|string $offset Offset * * @return boolean */ public function offsetExists(mixed $offset): bool { return isset($this->container[$offset]); } /** * Gets offset. * * @param integer|string $offset Offset * * @return mixed|null */ #[\ReturnTypeWillChange] public function offsetGet(mixed $offset) { return $this->container[$offset] ?? null; } /** * Sets value based on offset. * * @param int|null $offset Offset * @param mixed $value Value to be set * * @return void */ public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; } else { $this->container[$offset] = $value; } } /** * Unsets offset. * * @param integer|string $offset Offset * * @return void */ public function offsetUnset(mixed $offset): void { unset($this->container[$offset]); } /** * Serializes the object to a value that can be serialized natively by json_encode(). * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php * * @return mixed Returns data which can be serialized by json_encode(), which is a value * of any type other than a resource. */ #[\ReturnTypeWillChange] public function jsonSerialize() { return ObjectSerializer::sanitizeForSerialization($this); } /** * Gets the string presentation of the object * * @return string */ public function __toString() { return json_encode( ObjectSerializer::sanitizeForSerialization($this), JSON_PRETTY_PRINT ); } /** * Gets a header-safe presentation of the object * * @return string */ public function toHeaderValue() { return json_encode(ObjectSerializer::sanitizeForSerialization($this)); } }