MIF_E31211285/vendor/xendit/xendit-php/lib/Refund/CreateRefund.php

654 lines
15 KiB
PHP

<?php
/**
* CreateRefund
*
* PHP version 7.4
*
* @category Class
* @package Xendit
*/
/**
* Refund Service
*
* The version of the OpenAPI document: 1.3.4
*/
/**
* NOTE: This class is auto generated.
* Do not edit the class manually.
*/
namespace Xendit\Refund;
use \ArrayAccess;
use \Xendit\ObjectSerializer;
use \Xendit\Model\ModelInterface;
/**
* CreateRefund Class Doc Comment
*
* @category Class
* @package Xendit
* @implements \ArrayAccess<string, mixed>
*/
class CreateRefund implements ModelInterface, ArrayAccess, \JsonSerializable
{
public const DISCRIMINATOR = null;
/**
* The original name of the model.
*
* @var string
*/
protected static $openAPIModelName = 'CreateRefund';
/**
* Array of property to type mappings. Used for (de)serialization
*
* @var string[]
*/
protected static $openAPITypes = [
'payment_request_id' => 'string',
'invoice_id' => 'string',
'reference_id' => 'string',
'amount' => 'float',
'currency' => 'string',
'reason' => '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 = [
'payment_request_id' => null,
'invoice_id' => null,
'reference_id' => null,
'amount' => 'double',
'currency' => null,
'reason' => null,
'metadata' => null
];
/**
* Array of nullable properties. Used for (de)serialization
*
* @var boolean[]
*/
protected static array $openAPINullables = [
'payment_request_id' => false,
'invoice_id' => false,
'reference_id' => false,
'amount' => false,
'currency' => false,
'reason' => false,
'metadata' => 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 = [
'payment_request_id' => 'payment_request_id',
'invoice_id' => 'invoice_id',
'reference_id' => 'reference_id',
'amount' => 'amount',
'currency' => 'currency',
'reason' => 'reason',
'metadata' => 'metadata'
];
/**
* Array of attributes to setter functions (for deserialization of responses)
*
* @var string[]
*/
protected static $setters = [
'payment_request_id' => 'setPaymentRequestId',
'invoice_id' => 'setInvoiceId',
'reference_id' => 'setReferenceId',
'amount' => 'setAmount',
'currency' => 'setCurrency',
'reason' => 'setReason',
'metadata' => 'setMetadata'
];
/**
* Array of attributes to getter functions (for serialization of requests)
*
* @var string[]
*/
protected static $getters = [
'payment_request_id' => 'getPaymentRequestId',
'invoice_id' => 'getInvoiceId',
'reference_id' => 'getReferenceId',
'amount' => 'getAmount',
'currency' => 'getCurrency',
'reason' => 'getReason',
'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;
}
public const REASON_FRAUDULENT = 'FRAUDULENT';
public const REASON_DUPLICATE = 'DUPLICATE';
public const REASON_REQUESTED_BY_CUSTOMER = 'REQUESTED_BY_CUSTOMER';
public const REASON_CANCELLATION = 'CANCELLATION';
public const REASON_OTHERS = 'OTHERS';
/**
* Gets allowable values of the enum
*
* @return string[]
*/
public function getReasonAllowableValues()
{
return [
self::REASON_FRAUDULENT,
self::REASON_DUPLICATE,
self::REASON_REQUESTED_BY_CUSTOMER,
self::REASON_CANCELLATION,
self::REASON_OTHERS,
];
}
/**
* 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('payment_request_id', $data ?? [], null);
$this->setIfExists('invoice_id', $data ?? [], null);
$this->setIfExists('reference_id', $data ?? [], null);
$this->setIfExists('amount', $data ?? [], null);
$this->setIfExists('currency', $data ?? [], null);
$this->setIfExists('reason', $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 = [];
$allowedValues = $this->getReasonAllowableValues();
if (!is_null($this->container['reason']) && !in_array($this->container['reason'], $allowedValues, true)) {
$invalidProperties[] = sprintf(
"invalid value '%s' for 'reason', must be one of '%s'",
$this->container['reason'],
implode("', '", $allowedValues)
);
}
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 payment_request_id
*
* @return string|null
*/
public function getPaymentRequestId()
{
return $this->container['payment_request_id'];
}
/**
* Sets payment_request_id
*
* @param string|null $payment_request_id payment_request_id
*
* @return self
*/
public function setPaymentRequestId($payment_request_id)
{
if (is_null($payment_request_id)) {
throw new \InvalidArgumentException('non-nullable payment_request_id cannot be null');
}
$this->container['payment_request_id'] = $payment_request_id;
return $this;
}
/**
* Gets invoice_id
*
* @return string|null
*/
public function getInvoiceId()
{
return $this->container['invoice_id'];
}
/**
* Sets invoice_id
*
* @param string|null $invoice_id invoice_id
*
* @return self
*/
public function setInvoiceId($invoice_id)
{
if (is_null($invoice_id)) {
throw new \InvalidArgumentException('non-nullable invoice_id cannot be null');
}
$this->container['invoice_id'] = $invoice_id;
return $this;
}
/**
* 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 amount
*
* @return float|null
*/
public function getAmount()
{
return $this->container['amount'];
}
/**
* Sets amount
*
* @param float|null $amount amount
*
* @return self
*/
public function setAmount($amount)
{
if (is_null($amount)) {
throw new \InvalidArgumentException('non-nullable amount cannot be null');
}
$this->container['amount'] = $amount;
return $this;
}
/**
* Gets currency
*
* @return string|null
*/
public function getCurrency()
{
return $this->container['currency'];
}
/**
* Sets currency
*
* @param string|null $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 reason
*
* @return string|null
*/
public function getReason()
{
return $this->container['reason'];
}
/**
* Sets reason
*
* @param string|null $reason reason
*
* @return self
*/
public function setReason($reason)
{
if (is_null($reason)) {
throw new \InvalidArgumentException('non-nullable reason cannot be null');
}
$allowedValues = $this->getReasonAllowableValues();
if (!in_array($reason, $allowedValues, true)) {
throw new \InvalidArgumentException(
sprintf(
"Invalid value '%s' for 'reason', must be one of '%s'",
$reason,
implode("', '", $allowedValues)
)
);
}
$this->container['reason'] = $reason;
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)) {
array_push($this->openAPINullablesSetToNull, 'metadata');
} else {
$nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
$index = array_search('metadata', $nullablesSetToNull);
if ($index !== FALSE) {
unset($nullablesSetToNull[$index]);
$this->setOpenAPINullablesSetToNull($nullablesSetToNull);
}
}
$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));
}
}