diff --git a/README.md b/README.md index fbdccf8..8216da2 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ A PHP client library for the PAY.JP v2 API. This SDK provides a convenient way t This PHP package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: - API version: `2.0.0` -- Package version: `1.0.10` +- Package version: `1.1.0` - Generator version: `7.14.0` - Build package: `org.openapitools.codegen.languages.PhpClientCodegen` @@ -234,11 +234,13 @@ Class | Method | HTTP request | Description - [PaymentTransactionResponse](docs/Model/PaymentTransactionResponse.md) - [PaymentTransactionType](docs/Model/PaymentTransactionType.md) - [PriceCreateRequest](docs/Model/PriceCreateRequest.md) +- [PriceDataRequest](docs/Model/PriceDataRequest.md) - [PriceDetailsResponse](docs/Model/PriceDetailsResponse.md) - [PriceListResponse](docs/Model/PriceListResponse.md) - [PriceType](docs/Model/PriceType.md) - [PriceUpdateRequest](docs/Model/PriceUpdateRequest.md) - [ProductCreateRequest](docs/Model/ProductCreateRequest.md) +- [ProductDataRequest](docs/Model/ProductDataRequest.md) - [ProductDeletedResponse](docs/Model/ProductDeletedResponse.md) - [ProductDetailsResponse](docs/Model/ProductDetailsResponse.md) - [ProductListResponse](docs/Model/ProductListResponse.md) @@ -306,6 +308,6 @@ vendor/bin/phpunit This PHP package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: - API version: `2.0.0` -- Package version: `1.0.10` +- Package version: `1.1.0` - Generator version: `7.14.0` - Build package: `org.openapitools.codegen.languages.PhpClientCodegen` diff --git a/docs/Model/CustomerUpdateRequest.md b/docs/Model/CustomerUpdateRequest.md index 10510b3..7a08d57 100644 --- a/docs/Model/CustomerUpdateRequest.md +++ b/docs/Model/CustomerUpdateRequest.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**defaultPaymentMethodId** | **string** | | [optional] +**defaultPaymentMethodId** | **string** | 支払いにデフォルトで使用される支払い方法 ID | [optional] **email** | **string** | 顧客のメールアドレス。メールアドレスの形式が正しいかどうかは検証されます。 | [optional] **description** | **string** | 顧客オブジェクトに付加できる任意の文字列です。管理画面で顧客と一緒に表示されます。 | [optional] **metadata** | **array** | キーバリューの任意のデータを格納できます。20件まで登録可能で、空文字列を指定するとそのキーを削除できます。<a href=\"https://docs.pay.jp/v2/guide/developers/metadata\">詳細はメタデータのドキュメントを参照してください。</a> | [optional] diff --git a/docs/Model/LineItemRequest.md b/docs/Model/LineItemRequest.md index 8c6c7a6..f731905 100644 --- a/docs/Model/LineItemRequest.md +++ b/docs/Model/LineItemRequest.md @@ -4,7 +4,8 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**priceId** | **string** | 料金 ID | +**priceId** | **string** | | [optional] +**priceData** | [**\PAYJPV2\Model\PriceDataRequest**](PriceDataRequest.md) | | [optional] **quantity** | **int** | 購入する商品の数量 | **taxRates** | **string[]** | 税率 ID | [optional] diff --git a/docs/Model/PriceDataRequest.md b/docs/Model/PriceDataRequest.md new file mode 100644 index 0000000..a9cdb92 --- /dev/null +++ b/docs/Model/PriceDataRequest.md @@ -0,0 +1,12 @@ +# # PriceDataRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**currency** | [**\PAYJPV2\Model\Currency**](Currency.md) | 通貨。現在は `jpy` のみサポートしています。 | +**unitAmount** | **int** | 単価(0以上の整数) | +**productId** | **string** | | [optional] +**productData** | [**\PAYJPV2\Model\ProductDataRequest**](ProductDataRequest.md) | | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/ProductDataRequest.md b/docs/Model/ProductDataRequest.md new file mode 100644 index 0000000..ef1d7fd --- /dev/null +++ b/docs/Model/ProductDataRequest.md @@ -0,0 +1,10 @@ +# # ProductDataRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **string** | Checkout などで顧客に表示される商品名 | +**description** | **string** | | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/lib/Api/PaymentRefundsApi.php b/lib/Api/PaymentRefundsApi.php index 9339284..f68eb21 100644 --- a/lib/Api/PaymentRefundsApi.php +++ b/lib/Api/PaymentRefundsApi.php @@ -144,7 +144,7 @@ public function getConfig() * * @throws \PAYJPV2\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException - * @return \PAYJPV2\Model\PaymentRefundResponse|\PAYJPV2\Model\ErrorResponse|\PAYJPV2\Model\ErrorResponse|\PAYJPV2\Model\ErrorResponse + * @return \PAYJPV2\Model\PaymentRefundResponse|\PAYJPV2\Model\ErrorResponse|\PAYJPV2\Model\ErrorResponse|\PAYJPV2\Model\ErrorResponse|\PAYJPV2\Model\ErrorResponse */ public function createPaymentRefund($paymentRefundCreateRequest, ?string $idempotencyKey = null) { @@ -163,7 +163,7 @@ public function createPaymentRefund($paymentRefundCreateRequest, ?string $idempo * * @throws \PAYJPV2\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException - * @return array of \PAYJPV2\Model\PaymentRefundResponse|\PAYJPV2\Model\ErrorResponse|\PAYJPV2\Model\ErrorResponse|\PAYJPV2\Model\ErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @return array of \PAYJPV2\Model\PaymentRefundResponse|\PAYJPV2\Model\ErrorResponse|\PAYJPV2\Model\ErrorResponse|\PAYJPV2\Model\ErrorResponse|\PAYJPV2\Model\ErrorResponse, HTTP status code, HTTP response headers (array of strings) */ public function createPaymentRefundWithHttpInfo($paymentRefundCreateRequest, ?string $idempotencyKey = null) { @@ -218,6 +218,12 @@ public function createPaymentRefundWithHttpInfo($paymentRefundCreateRequest, ?st $request, $response, ); + case 402: + return $this->handleResponseWithDataType( + '\PAYJPV2\Model\ErrorResponse', + $request, + $response, + ); } @@ -277,6 +283,15 @@ public function createPaymentRefundWithHttpInfo($paymentRefundCreateRequest, ?st ); $e->setResponseObject($data); + throw $e; + case 402: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\PAYJPV2\Model\ErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; } diff --git a/lib/Configuration.php b/lib/Configuration.php index c7f1f4d..73030f9 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -101,7 +101,7 @@ class Configuration * * @var string */ - protected $userAgent = 'payjp/payjpv2 PHPBindings/1.0.10'; + protected $userAgent = 'payjp/payjpv2 PHPBindings/1.1.0'; /** * Debug switch (default set to false) @@ -339,7 +339,7 @@ public function getUserAgent(): string public static function buildClientUserAgent(): string { $uaInfo = [ - 'bindings_version' => '1.0.10', + 'bindings_version' => '1.1.0', 'lang' => 'php', 'lang_version' => PHP_VERSION, 'publisher' => 'payjp', @@ -458,7 +458,7 @@ public static function toDebugReport() $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' The version of the OpenAPI document: 2.0.0' . PHP_EOL; - $report .= ' SDK Package Version: 1.0.10' . PHP_EOL; + $report .= ' SDK Package Version: 1.1.0' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; diff --git a/lib/Model/CustomerUpdateRequest.php b/lib/Model/CustomerUpdateRequest.php index c10c950..887d935 100644 --- a/lib/Model/CustomerUpdateRequest.php +++ b/lib/Model/CustomerUpdateRequest.php @@ -84,7 +84,7 @@ class CustomerUpdateRequest implements ModelInterface, ArrayAccess, \JsonSeriali * @var bool[] */ protected static array $openAPINullables = [ - 'defaultPaymentMethodId' => true, + 'defaultPaymentMethodId' => false, 'email' => false, 'description' => false, 'metadata' => false, @@ -332,21 +332,14 @@ public function getDefaultPaymentMethodId(): ?string /** * Sets defaultPaymentMethodId * - * @param string|null $defaultPaymentMethodId defaultPaymentMethodId + * @param string|null $defaultPaymentMethodId 支払いにデフォルトで使用される支払い方法 ID * * @return self */ public function setDefaultPaymentMethodId(?string $defaultPaymentMethodId): self { if (is_null($defaultPaymentMethodId)) { - array_push($this->openAPINullablesSetToNull, 'defaultPaymentMethodId'); - } else { - $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); - $index = array_search('defaultPaymentMethodId', $nullablesSetToNull); - if ($index !== false) { - unset($nullablesSetToNull[$index]); - $this->setOpenAPINullablesSetToNull($nullablesSetToNull); - } + throw new \InvalidArgumentException('non-nullable defaultPaymentMethodId cannot be null'); } $this->container['defaultPaymentMethodId'] = $defaultPaymentMethodId; diff --git a/lib/Model/LineItemRequest.php b/lib/Model/LineItemRequest.php index 4e410a4..88ceaf5 100644 --- a/lib/Model/LineItemRequest.php +++ b/lib/Model/LineItemRequest.php @@ -59,6 +59,7 @@ class LineItemRequest implements ModelInterface, ArrayAccess, \JsonSerializable */ protected static $openAPITypes = [ 'priceId' => 'string', + 'priceData' => '\PAYJPV2\Model\PriceDataRequest', 'quantity' => 'int', 'taxRates' => 'string[]', ]; @@ -72,6 +73,7 @@ class LineItemRequest implements ModelInterface, ArrayAccess, \JsonSerializable */ protected static $openAPIFormats = [ 'priceId' => null, + 'priceData' => null, 'quantity' => null, 'taxRates' => null, ]; @@ -82,7 +84,8 @@ class LineItemRequest implements ModelInterface, ArrayAccess, \JsonSerializable * @var bool[] */ protected static array $openAPINullables = [ - 'priceId' => false, + 'priceId' => true, + 'priceData' => true, 'quantity' => false, 'taxRates' => false, ]; @@ -174,6 +177,7 @@ public function isNullableSetToNull(string $property): bool */ protected static $attributeMap = [ 'priceId' => 'price_id', + 'priceData' => 'price_data', 'quantity' => 'quantity', 'taxRates' => 'tax_rates', ]; @@ -185,6 +189,7 @@ public function isNullableSetToNull(string $property): bool */ protected static $setters = [ 'priceId' => 'setPriceId', + 'priceData' => 'setPriceData', 'quantity' => 'setQuantity', 'taxRates' => 'setTaxRates', ]; @@ -196,6 +201,7 @@ public function isNullableSetToNull(string $property): bool */ protected static $getters = [ 'priceId' => 'getPriceId', + 'priceData' => 'getPriceData', 'quantity' => 'getQuantity', 'taxRates' => 'getTaxRates', ]; @@ -258,6 +264,7 @@ public function getModelName() public function __construct(?array $data = null) { $this->setIfExists('priceId', $data ?? [], null); + $this->setIfExists('priceData', $data ?? [], null); $this->setIfExists('quantity', $data ?? [], null); $this->setIfExists('taxRates', $data ?? [], null); } @@ -289,9 +296,6 @@ public function listInvalidProperties() { $invalidProperties = []; - if ($this->container['priceId'] === null) { - $invalidProperties[] = "'priceId' can't be null"; - } if ($this->container['quantity'] === null) { $invalidProperties[] = "'quantity' can't be null"; } @@ -314,34 +318,71 @@ public function valid() /** * Gets priceId * - * @return string + * @return string|null */ - public function getPriceId(): string + public function getPriceId(): ?string { - if ($this->container['priceId'] === null) { - throw new \LogicException('Property "priceId" is required but has not been set.'); - } - return $this->container['priceId']; } /** * Sets priceId * - * @param string $priceId 料金 ID + * @param string|null $priceId priceId * * @return self */ - public function setPriceId(string $priceId): self + public function setPriceId(?string $priceId): self { if (is_null($priceId)) { - throw new \InvalidArgumentException('non-nullable priceId cannot be null'); + array_push($this->openAPINullablesSetToNull, 'priceId'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('priceId', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } } $this->container['priceId'] = $priceId; return $this; } + /** + * Gets priceData + * + * @return \PAYJPV2\Model\PriceDataRequest|null + */ + public function getPriceData(): ?\PAYJPV2\Model\PriceDataRequest + { + return $this->container['priceData']; + } + + /** + * Sets priceData + * + * @param \PAYJPV2\Model\PriceDataRequest|null $priceData priceData + * + * @return self + */ + public function setPriceData(?\PAYJPV2\Model\PriceDataRequest $priceData): self + { + if (is_null($priceData)) { + array_push($this->openAPINullablesSetToNull, 'priceData'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('priceData', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['priceData'] = $priceData; + + return $this; + } + /** * Gets quantity * diff --git a/lib/Model/PriceDataRequest.php b/lib/Model/PriceDataRequest.php new file mode 100644 index 0000000..8f53902 --- /dev/null +++ b/lib/Model/PriceDataRequest.php @@ -0,0 +1,547 @@ + + */ +class PriceDataRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'PriceDataRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'currency' => '\PAYJPV2\Model\Currency', + 'unitAmount' => 'int', + 'productId' => 'string', + 'productData' => '\PAYJPV2\Model\ProductDataRequest', + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'currency' => null, + 'unitAmount' => null, + 'productId' => null, + 'productData' => null, + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'currency' => false, + 'unitAmount' => false, + 'productId' => true, + 'productData' => true, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + 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 bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $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 = [ + 'currency' => 'currency', + 'unitAmount' => 'unit_amount', + 'productId' => 'product_id', + 'productData' => 'product_data', + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'currency' => 'setCurrency', + 'unitAmount' => 'setUnitAmount', + 'productId' => 'setProductId', + 'productData' => 'setProductData', + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'currency' => 'getCurrency', + 'unitAmount' => 'getUnitAmount', + 'productId' => 'getProductId', + 'productData' => 'getProductData', + ]; + + /** + * 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('currency', $data ?? [], null); + $this->setIfExists('unitAmount', $data ?? [], null); + $this->setIfExists('productId', $data ?? [], null); + $this->setIfExists('productData', $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['currency'] === null) { + $invalidProperties[] = "'currency' can't be null"; + } + if ($this->container['unitAmount'] === null) { + $invalidProperties[] = "'unitAmount' can't be null"; + } + if (($this->container['unitAmount'] < 0)) { + $invalidProperties[] = "invalid value for 'unitAmount', must be bigger than or equal to 0."; + } + + 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 currency + * + * @return \PAYJPV2\Model\Currency + */ + public function getCurrency(): \PAYJPV2\Model\Currency + { + if ($this->container['currency'] === null) { + throw new \LogicException('Property "currency" is required but has not been set.'); + } + + return $this->container['currency']; + } + + /** + * Sets currency + * + * @param \PAYJPV2\Model\Currency $currency 通貨。現在は `jpy` のみサポートしています。 + * + * @return self + */ + public function setCurrency(\PAYJPV2\Model\Currency $currency): self + { + if (is_null($currency)) { + throw new \InvalidArgumentException('non-nullable currency cannot be null'); + } + $this->container['currency'] = $currency; + + return $this; + } + + /** + * Gets unitAmount + * + * @return int + */ + public function getUnitAmount(): int + { + if ($this->container['unitAmount'] === null) { + throw new \LogicException('Property "unitAmount" is required but has not been set.'); + } + + return $this->container['unitAmount']; + } + + /** + * Sets unitAmount + * + * @param int $unitAmount 単価(0以上の整数) + * + * @return self + */ + public function setUnitAmount(int $unitAmount): self + { + if (is_null($unitAmount)) { + throw new \InvalidArgumentException('non-nullable unitAmount cannot be null'); + } + + if (($unitAmount < 0)) { + throw new \InvalidArgumentException('invalid value for $unitAmount when calling PriceDataRequest., must be bigger than or equal to 0.'); + } + + $this->container['unitAmount'] = $unitAmount; + + return $this; + } + + /** + * Gets productId + * + * @return string|null + */ + public function getProductId(): ?string + { + return $this->container['productId']; + } + + /** + * Sets productId + * + * @param string|null $productId productId + * + * @return self + */ + public function setProductId(?string $productId): self + { + if (is_null($productId)) { + array_push($this->openAPINullablesSetToNull, 'productId'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('productId', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['productId'] = $productId; + + return $this; + } + + /** + * Gets productData + * + * @return \PAYJPV2\Model\ProductDataRequest|null + */ + public function getProductData(): ?\PAYJPV2\Model\ProductDataRequest + { + return $this->container['productData']; + } + + /** + * Sets productData + * + * @param \PAYJPV2\Model\ProductDataRequest|null $productData productData + * + * @return self + */ + public function setProductData(?\PAYJPV2\Model\ProductDataRequest $productData): self + { + if (is_null($productData)) { + array_push($this->openAPINullablesSetToNull, 'productData'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('productData', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['productData'] = $productData; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param int $offset Offset + * + * @return bool + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param int $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 int $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)); + } +} diff --git a/lib/Model/ProductDataRequest.php b/lib/Model/ProductDataRequest.php new file mode 100644 index 0000000..f56e535 --- /dev/null +++ b/lib/Model/ProductDataRequest.php @@ -0,0 +1,457 @@ + + */ +class ProductDataRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ProductDataRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'name' => 'string', + 'description' => 'string', + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'name' => null, + 'description' => null, + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var bool[] + */ + protected static array $openAPINullables = [ + 'name' => false, + 'description' => true, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var bool[] + */ + 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 bool[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param bool[] $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 = [ + 'name' => 'name', + 'description' => 'description', + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'name' => 'setName', + 'description' => 'setDescription', + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'name' => 'getName', + 'description' => 'getDescription', + ]; + + /** + * 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('name', $data ?? [], null); + $this->setIfExists('description', $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"; + } + + 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 name + * + * @return string + */ + public function getName(): string + { + if ($this->container['name'] === null) { + throw new \LogicException('Property "name" is required but has not been set.'); + } + + return $this->container['name']; + } + + /** + * Sets name + * + * @param string $name Checkout などで顧客に表示される商品名 + * + * @return self + */ + public function setName(string $name): self + { + 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(): ?string + { + return $this->container['description']; + } + + /** + * Sets description + * + * @param string|null $description description + * + * @return self + */ + public function setDescription(?string $description): self + { + if (is_null($description)) { + array_push($this->openAPINullablesSetToNull, 'description'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('description', $nullablesSetToNull); + if ($index !== false) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['description'] = $description; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param int $offset Offset + * + * @return bool + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param int $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 int $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)); + } +} diff --git a/test/Model/LineItemRequestTest.php b/test/Model/LineItemRequestTest.php index 5179597..b2ac689 100644 --- a/test/Model/LineItemRequestTest.php +++ b/test/Model/LineItemRequestTest.php @@ -88,6 +88,15 @@ public function testPropertyPriceId() self::markTestIncomplete('Not implemented'); } + /** + * Test attribute "priceData" + */ + public function testPropertyPriceData() + { + // TODO: implement + self::markTestIncomplete('Not implemented'); + } + /** * Test attribute "quantity" */ diff --git a/test/Model/PriceDataRequestTest.php b/test/Model/PriceDataRequestTest.php new file mode 100644 index 0000000..065f191 --- /dev/null +++ b/test/Model/PriceDataRequestTest.php @@ -0,0 +1,117 @@ +