826 lines
19 KiB
PHP
826 lines
19 KiB
PHP
<?php
|
|
/**
|
|
* PaymentRequestBasketItem
|
|
*
|
|
* PHP version 7.4
|
|
*
|
|
* @category Class
|
|
* @package Xendit
|
|
*/
|
|
|
|
/**
|
|
* Payment Requests
|
|
*
|
|
* The version of the OpenAPI document: 1.59.0
|
|
*/
|
|
|
|
/**
|
|
* NOTE: This class is auto generated.
|
|
* Do not edit the class manually.
|
|
*/
|
|
|
|
namespace Xendit\PaymentRequest;
|
|
|
|
|
|
use \ArrayAccess;
|
|
use \Xendit\ObjectSerializer;
|
|
use \Xendit\Model\ModelInterface;
|
|
|
|
/**
|
|
* PaymentRequestBasketItem Class Doc Comment
|
|
*
|
|
* @category Class
|
|
* @package Xendit
|
|
* @implements \ArrayAccess<string, mixed>
|
|
*/
|
|
class PaymentRequestBasketItem implements ModelInterface, ArrayAccess, \JsonSerializable
|
|
{
|
|
public const DISCRIMINATOR = null;
|
|
|
|
/**
|
|
* The original name of the model.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected static $openAPIModelName = 'PaymentRequestBasketItem';
|
|
|
|
/**
|
|
* Array of property to type mappings. Used for (de)serialization
|
|
*
|
|
* @var string[]
|
|
*/
|
|
protected static $openAPITypes = [
|
|
'reference_id' => 'string',
|
|
'name' => 'string',
|
|
'description' => 'string',
|
|
'type' => 'string',
|
|
'category' => 'string',
|
|
'sub_category' => 'string',
|
|
'currency' => 'string',
|
|
'quantity' => 'float',
|
|
'price' => 'float',
|
|
'payer_charged_currency' => 'string',
|
|
'payer_charged_price' => 'float',
|
|
'url' => 'string',
|
|
'metadata' => 'object'
|
|
];
|
|
|
|
/**
|
|
* Array of property to format mappings. Used for (de)serialization
|
|
*
|
|
* @var string[]
|
|
* @phpstan-var array<string, string|null>
|
|
* @psalm-var array<string, string|null>
|
|
*/
|
|
protected static $openAPIFormats = [
|
|
'reference_id' => null,
|
|
'name' => null,
|
|
'description' => null,
|
|
'type' => null,
|
|
'category' => null,
|
|
'sub_category' => null,
|
|
'currency' => null,
|
|
'quantity' => 'double',
|
|
'price' => 'double',
|
|
'payer_charged_currency' => null,
|
|
'payer_charged_price' => 'double',
|
|
'url' => null,
|
|
'metadata' => null
|
|
];
|
|
|
|
/**
|
|
* Array of nullable properties. Used for (de)serialization
|
|
*
|
|
* @var boolean[]
|
|
*/
|
|
protected static array $openAPINullables = [
|
|
'reference_id' => false,
|
|
'name' => false,
|
|
'description' => false,
|
|
'type' => false,
|
|
'category' => false,
|
|
'sub_category' => false,
|
|
'currency' => false,
|
|
'quantity' => false,
|
|
'price' => false,
|
|
'payer_charged_currency' => false,
|
|
'payer_charged_price' => false,
|
|
'url' => false,
|
|
'metadata' => false
|
|
];
|
|
|
|
/**
|
|
* 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 = [
|
|
'reference_id' => 'reference_id',
|
|
'name' => 'name',
|
|
'description' => 'description',
|
|
'type' => 'type',
|
|
'category' => 'category',
|
|
'sub_category' => 'sub_category',
|
|
'currency' => 'currency',
|
|
'quantity' => 'quantity',
|
|
'price' => 'price',
|
|
'payer_charged_currency' => 'payer_charged_currency',
|
|
'payer_charged_price' => 'payer_charged_price',
|
|
'url' => 'url',
|
|
'metadata' => 'metadata'
|
|
];
|
|
|
|
/**
|
|
* Array of attributes to setter functions (for deserialization of responses)
|
|
*
|
|
* @var string[]
|
|
*/
|
|
protected static $setters = [
|
|
'reference_id' => 'setReferenceId',
|
|
'name' => 'setName',
|
|
'description' => 'setDescription',
|
|
'type' => 'setType',
|
|
'category' => 'setCategory',
|
|
'sub_category' => 'setSubCategory',
|
|
'currency' => 'setCurrency',
|
|
'quantity' => 'setQuantity',
|
|
'price' => 'setPrice',
|
|
'payer_charged_currency' => 'setPayerChargedCurrency',
|
|
'payer_charged_price' => 'setPayerChargedPrice',
|
|
'url' => 'setUrl',
|
|
'metadata' => 'setMetadata'
|
|
];
|
|
|
|
/**
|
|
* Array of attributes to getter functions (for serialization of requests)
|
|
*
|
|
* @var string[]
|
|
*/
|
|
protected static $getters = [
|
|
'reference_id' => 'getReferenceId',
|
|
'name' => 'getName',
|
|
'description' => 'getDescription',
|
|
'type' => 'getType',
|
|
'category' => 'getCategory',
|
|
'sub_category' => 'getSubCategory',
|
|
'currency' => 'getCurrency',
|
|
'quantity' => 'getQuantity',
|
|
'price' => 'getPrice',
|
|
'payer_charged_currency' => 'getPayerChargedCurrency',
|
|
'payer_charged_price' => 'getPayerChargedPrice',
|
|
'url' => 'getUrl',
|
|
'metadata' => 'getMetadata'
|
|
];
|
|
|
|
/**
|
|
* 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[] $data Associated array of property values
|
|
* initializing the model
|
|
*/
|
|
public function __construct(array $data = null)
|
|
{
|
|
$this->setIfExists('reference_id', $data ?? [], null);
|
|
$this->setIfExists('name', $data ?? [], null);
|
|
$this->setIfExists('description', $data ?? [], null);
|
|
$this->setIfExists('type', $data ?? [], null);
|
|
$this->setIfExists('category', $data ?? [], null);
|
|
$this->setIfExists('sub_category', $data ?? [], null);
|
|
$this->setIfExists('currency', $data ?? [], null);
|
|
$this->setIfExists('quantity', $data ?? [], null);
|
|
$this->setIfExists('price', $data ?? [], null);
|
|
$this->setIfExists('payer_charged_currency', $data ?? [], null);
|
|
$this->setIfExists('payer_charged_price', $data ?? [], null);
|
|
$this->setIfExists('url', $data ?? [], null);
|
|
$this->setIfExists('metadata', $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 ($this->container['name'] === null) {
|
|
$invalidProperties[] = "'name' can't be null";
|
|
}
|
|
if ($this->container['category'] === null) {
|
|
$invalidProperties[] = "'category' can't be null";
|
|
}
|
|
if ($this->container['currency'] === null) {
|
|
$invalidProperties[] = "'currency' can't be null";
|
|
}
|
|
if ($this->container['quantity'] === null) {
|
|
$invalidProperties[] = "'quantity' can't be null";
|
|
}
|
|
if ($this->container['price'] === null) {
|
|
$invalidProperties[] = "'price' can't be null";
|
|
}
|
|
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 reference_id
|
|
*
|
|
* @return string|null
|
|
*/
|
|
public function getReferenceId()
|
|
{
|
|
return $this->container['reference_id'];
|
|
}
|
|
|
|
/**
|
|
* Sets reference_id
|
|
*
|
|
* @param string|null $reference_id reference_id
|
|
*
|
|
* @return self
|
|
*/
|
|
public function setReferenceId($reference_id)
|
|
{
|
|
if (is_null($reference_id)) {
|
|
throw new \InvalidArgumentException('non-nullable reference_id cannot be null');
|
|
}
|
|
$this->container['reference_id'] = $reference_id;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Gets name
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getName()
|
|
{
|
|
return $this->container['name'];
|
|
}
|
|
|
|
/**
|
|
* Sets name
|
|
*
|
|
* @param string $name name
|
|
*
|
|
* @return self
|
|
*/
|
|
public function setName($name)
|
|
{
|
|
if (is_null($name)) {
|
|
throw new \InvalidArgumentException('non-nullable name cannot be null');
|
|
}
|
|
$this->container['name'] = $name;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Gets description
|
|
*
|
|
* @return string|null
|
|
*/
|
|
public function getDescription()
|
|
{
|
|
return $this->container['description'];
|
|
}
|
|
|
|
/**
|
|
* Sets description
|
|
*
|
|
* @param string|null $description description
|
|
*
|
|
* @return self
|
|
*/
|
|
public function setDescription($description)
|
|
{
|
|
if (is_null($description)) {
|
|
throw new \InvalidArgumentException('non-nullable description cannot be null');
|
|
}
|
|
$this->container['description'] = $description;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Gets type
|
|
*
|
|
* @return string|null
|
|
*/
|
|
public function getType()
|
|
{
|
|
return $this->container['type'];
|
|
}
|
|
|
|
/**
|
|
* Sets type
|
|
*
|
|
* @param string|null $type type
|
|
*
|
|
* @return self
|
|
*/
|
|
public function setType($type)
|
|
{
|
|
if (is_null($type)) {
|
|
throw new \InvalidArgumentException('non-nullable type cannot be null');
|
|
}
|
|
$this->container['type'] = $type;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Gets category
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getCategory()
|
|
{
|
|
return $this->container['category'];
|
|
}
|
|
|
|
/**
|
|
* Sets category
|
|
*
|
|
* @param string $category category
|
|
*
|
|
* @return self
|
|
*/
|
|
public function setCategory($category)
|
|
{
|
|
if (is_null($category)) {
|
|
throw new \InvalidArgumentException('non-nullable category cannot be null');
|
|
}
|
|
$this->container['category'] = $category;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Gets sub_category
|
|
*
|
|
* @return string|null
|
|
*/
|
|
public function getSubCategory()
|
|
{
|
|
return $this->container['sub_category'];
|
|
}
|
|
|
|
/**
|
|
* Sets sub_category
|
|
*
|
|
* @param string|null $sub_category sub_category
|
|
*
|
|
* @return self
|
|
*/
|
|
public function setSubCategory($sub_category)
|
|
{
|
|
if (is_null($sub_category)) {
|
|
throw new \InvalidArgumentException('non-nullable sub_category cannot be null');
|
|
}
|
|
$this->container['sub_category'] = $sub_category;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Gets currency
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getCurrency()
|
|
{
|
|
return $this->container['currency'];
|
|
}
|
|
|
|
/**
|
|
* Sets currency
|
|
*
|
|
* @param string $currency currency
|
|
*
|
|
* @return self
|
|
*/
|
|
public function setCurrency($currency)
|
|
{
|
|
if (is_null($currency)) {
|
|
throw new \InvalidArgumentException('non-nullable currency cannot be null');
|
|
}
|
|
$this->container['currency'] = $currency;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Gets quantity
|
|
*
|
|
* @return float
|
|
*/
|
|
public function getQuantity()
|
|
{
|
|
return $this->container['quantity'];
|
|
}
|
|
|
|
/**
|
|
* Sets quantity
|
|
*
|
|
* @param float $quantity quantity
|
|
*
|
|
* @return self
|
|
*/
|
|
public function setQuantity($quantity)
|
|
{
|
|
if (is_null($quantity)) {
|
|
throw new \InvalidArgumentException('non-nullable quantity cannot be null');
|
|
}
|
|
$this->container['quantity'] = $quantity;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Gets price
|
|
*
|
|
* @return float
|
|
*/
|
|
public function getPrice()
|
|
{
|
|
return $this->container['price'];
|
|
}
|
|
|
|
/**
|
|
* Sets price
|
|
*
|
|
* @param float $price price
|
|
*
|
|
* @return self
|
|
*/
|
|
public function setPrice($price)
|
|
{
|
|
if (is_null($price)) {
|
|
throw new \InvalidArgumentException('non-nullable price cannot be null');
|
|
}
|
|
$this->container['price'] = $price;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Gets payer_charged_currency
|
|
*
|
|
* @return string|null
|
|
*/
|
|
public function getPayerChargedCurrency()
|
|
{
|
|
return $this->container['payer_charged_currency'];
|
|
}
|
|
|
|
/**
|
|
* Sets payer_charged_currency
|
|
*
|
|
* @param string|null $payer_charged_currency payer_charged_currency
|
|
*
|
|
* @return self
|
|
*/
|
|
public function setPayerChargedCurrency($payer_charged_currency)
|
|
{
|
|
if (is_null($payer_charged_currency)) {
|
|
throw new \InvalidArgumentException('non-nullable payer_charged_currency cannot be null');
|
|
}
|
|
$this->container['payer_charged_currency'] = $payer_charged_currency;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Gets payer_charged_price
|
|
*
|
|
* @return float|null
|
|
*/
|
|
public function getPayerChargedPrice()
|
|
{
|
|
return $this->container['payer_charged_price'];
|
|
}
|
|
|
|
/**
|
|
* Sets payer_charged_price
|
|
*
|
|
* @param float|null $payer_charged_price payer_charged_price
|
|
*
|
|
* @return self
|
|
*/
|
|
public function setPayerChargedPrice($payer_charged_price)
|
|
{
|
|
if (is_null($payer_charged_price)) {
|
|
throw new \InvalidArgumentException('non-nullable payer_charged_price cannot be null');
|
|
}
|
|
$this->container['payer_charged_price'] = $payer_charged_price;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Gets url
|
|
*
|
|
* @return string|null
|
|
*/
|
|
public function getUrl()
|
|
{
|
|
return $this->container['url'];
|
|
}
|
|
|
|
/**
|
|
* Sets url
|
|
*
|
|
* @param string|null $url url
|
|
*
|
|
* @return self
|
|
*/
|
|
public function setUrl($url)
|
|
{
|
|
if (is_null($url)) {
|
|
throw new \InvalidArgumentException('non-nullable url cannot be null');
|
|
}
|
|
$this->container['url'] = $url;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Gets metadata
|
|
*
|
|
* @return object|null
|
|
*/
|
|
public function getMetadata()
|
|
{
|
|
return $this->container['metadata'];
|
|
}
|
|
|
|
/**
|
|
* Sets metadata
|
|
*
|
|
* @param object|null $metadata metadata
|
|
*
|
|
* @return self
|
|
*/
|
|
public function setMetadata($metadata)
|
|
{
|
|
if (is_null($metadata)) {
|
|
throw new \InvalidArgumentException('non-nullable metadata cannot be null');
|
|
}
|
|
$this->container['metadata'] = $metadata;
|
|
|
|
return $this;
|
|
}
|
|
/**
|
|
* Returns true if offset exists. False otherwise.
|
|
*
|
|
* @param integer $offset Offset
|
|
*
|
|
* @return boolean
|
|
*/
|
|
public function offsetExists($offset): bool
|
|
{
|
|
return isset($this->container[$offset]);
|
|
}
|
|
|
|
/**
|
|
* Gets offset.
|
|
*
|
|
* @param integer $offset Offset
|
|
*
|
|
* @return mixed|null
|
|
*/
|
|
#[\ReturnTypeWillChange]
|
|
public function offsetGet($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 $offset Offset
|
|
*
|
|
* @return void
|
|
*/
|
|
public function offsetUnset($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));
|
|
}
|
|
}
|
|
|
|
|