diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index ce6243a..ecd396f 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -4,15 +4,20 @@ src/ApiException.php src/Configuration.php src/FormDataProcessor.php src/HeaderSelector.php +src/Model/AuthMethod.php src/Model/AuthorizedTransaction.php src/Model/Currency.php src/Model/Delivery.php +src/Model/Do200Response.php +src/Model/Dorecurring200Response.php src/Model/Finish200Response.php src/Model/Invoice.php src/Model/Item.php src/Model/Language.php src/Model/Method.php src/Model/ModelInterface.php +src/Model/OneClickTransaction.php +src/Model/OneClickTransactionAllOfBrowser.php src/Model/Query.php src/Model/Query200Response.php src/Model/Query200ResponseTransactionsInner.php @@ -23,18 +28,27 @@ src/Model/Refund200Response.php src/Model/RefundStatus.php src/Model/Start200Response.php src/Model/Status.php +src/Model/TokenTransaction.php src/Model/Transaction.php +src/Model/TransactionCancel.php +src/Model/TransactionType.php src/Model/TransactionUrls.php +src/Model/Transactioncancel200Response.php src/ObjectSerializer.php tests/Api/TransactionApiTest.php +tests/Model/AuthMethodTest.php tests/Model/AuthorizedTransactionTest.php tests/Model/CurrencyTest.php tests/Model/DeliveryTest.php +tests/Model/Do200ResponseTest.php +tests/Model/Dorecurring200ResponseTest.php tests/Model/Finish200ResponseTest.php tests/Model/InvoiceTest.php tests/Model/ItemTest.php tests/Model/LanguageTest.php tests/Model/MethodTest.php +tests/Model/OneClickTransactionAllOfBrowserTest.php +tests/Model/OneClickTransactionTest.php tests/Model/Query200ResponseTest.php tests/Model/Query200ResponseTransactionsInnerItemsInnerTest.php tests/Model/Query200ResponseTransactionsInnerRefundsInnerTest.php @@ -45,5 +59,9 @@ tests/Model/RefundStatusTest.php tests/Model/RefundTest.php tests/Model/Start200ResponseTest.php tests/Model/StatusTest.php +tests/Model/TokenTransactionTest.php +tests/Model/TransactionCancelTest.php tests/Model/TransactionTest.php +tests/Model/TransactionTypeTest.php tests/Model/TransactionUrlsTest.php +tests/Model/Transactioncancel200ResponseTest.php diff --git a/src/Api/TransactionApi.php b/src/Api/TransactionApi.php index 2ccc6d1..5fc496e 100644 --- a/src/Api/TransactionApi.php +++ b/src/Api/TransactionApi.php @@ -74,6 +74,12 @@ class TransactionApi /** @var string[] $contentTypes **/ public const contentTypes = [ + 'callDo' => [ + 'application/json', + ], + 'dorecurring' => [ + 'application/json', + ], 'finish' => [ 'application/json', ], @@ -86,6 +92,9 @@ class TransactionApi 'start' => [ 'application/json', ], + 'transactioncancel' => [ + 'application/json', + ], ]; /** @@ -126,12 +135,602 @@ public function getHostIndex(): int return $this->hostIndex; } - /** - * @return Configuration - */ - public function getConfig(): Configuration - { - return $this->config; + /** + * @return Configuration + */ + public function getConfig(): Configuration + { + return $this->config; + } + + /** + * Operation callDo + * + * Do a one-click transaction + * + * @param string $signature The signature. (required) + * @param \Cone\SimplePay\Model\OneClickTransaction $oneClickTransaction The transaction object you would init. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['callDo'] to see the possible values for this operation + * + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @return \Cone\SimplePay\Model\Do200Response + */ + public function callDo( + string $signature, + \Cone\SimplePay\Model\OneClickTransaction $oneClickTransaction, + string $contentType = self::contentTypes['callDo'][0] + ): \Cone\SimplePay\Model\Do200Response { + list($response) = $this->callDoWithHttpInfo($signature, $oneClickTransaction, $contentType); + return $response; + } + + /** + * Operation callDoWithHttpInfo + * + * Do a one-click transaction + * + * @param string $signature The signature. (required) + * @param \Cone\SimplePay\Model\OneClickTransaction $oneClickTransaction The transaction object you would init. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['callDo'] to see the possible values for this operation + * + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @return array of \Cone\SimplePay\Model\Do200Response, HTTP status code, HTTP response headers (array of strings) + */ + public function callDoWithHttpInfo( + string $signature, + \Cone\SimplePay\Model\OneClickTransaction $oneClickTransaction, + string $contentType = self::contentTypes['callDo'][0] + ): array { + $request = $this->callDoRequest($signature, $oneClickTransaction, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + switch ($statusCode) { + case 200: + return $this->handleResponseWithDataType( + '\Cone\SimplePay\Model\Do200Response', + $request, + $response, + ); + } + + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + return $this->handleResponseWithDataType( + '\Cone\SimplePay\Model\Do200Response', + $request, + $response, + ); + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Cone\SimplePay\Model\Do200Response', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; + } + + throw $e; + } + } + + /** + * Operation callDoAsync + * + * Do a one-click transaction + * + * @param string $signature The signature. (required) + * @param \Cone\SimplePay\Model\OneClickTransaction $oneClickTransaction The transaction object you would init. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['callDo'] to see the possible values for this operation + * + * @throws InvalidArgumentException + * @return PromiseInterface + */ + public function callDoAsync( + string $signature, + \Cone\SimplePay\Model\OneClickTransaction $oneClickTransaction, + string $contentType = self::contentTypes['callDo'][0] + ): PromiseInterface { + return $this->callDoAsyncWithHttpInfo($signature, $oneClickTransaction, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation callDoAsyncWithHttpInfo + * + * Do a one-click transaction + * + * @param string $signature The signature. (required) + * @param \Cone\SimplePay\Model\OneClickTransaction $oneClickTransaction The transaction object you would init. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['callDo'] to see the possible values for this operation + * + * @throws InvalidArgumentException + * @return PromiseInterface + */ + public function callDoAsyncWithHttpInfo( + string $signature, + \Cone\SimplePay\Model\OneClickTransaction $oneClickTransaction, + string $contentType = self::contentTypes['callDo'][0] + ): PromiseInterface { + $returnType = '\Cone\SimplePay\Model\Do200Response'; + $request = $this->callDoRequest($signature, $oneClickTransaction, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if (in_array($returnType, ['\SplFileObject', '\Psr\Http\Message\StreamInterface'], true)) { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders(), + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'callDo' + * + * @param string $signature The signature. (required) + * @param \Cone\SimplePay\Model\OneClickTransaction $oneClickTransaction The transaction object you would init. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['callDo'] to see the possible values for this operation + * + * @throws InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function callDoRequest( + string $signature, + \Cone\SimplePay\Model\OneClickTransaction $oneClickTransaction, + string $contentType = self::contentTypes['callDo'][0] + ): Request { + + // verify the required parameter 'signature' is set + if ($signature === null || (is_array($signature) && count($signature) === 0)) { + throw new InvalidArgumentException( + 'Missing the required parameter $signature when calling callDo' + ); + } + + // verify the required parameter 'oneClickTransaction' is set + if ($oneClickTransaction === null || (is_array($oneClickTransaction) && count($oneClickTransaction) === 0)) { + throw new InvalidArgumentException( + 'Missing the required parameter $oneClickTransaction when calling callDo' + ); + } + + + $resourcePath = '/do'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + // header params + if ($signature !== null) { + $headerParams['Signature'] = ObjectSerializer::toHeaderValue($signature); + } + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($oneClickTransaction)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($oneClickTransaction)); + } else { + $httpBody = $oneClickTransaction; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem, + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation dorecurring + * + * Do a recurring transaction + * + * @param string $signature The signature. (required) + * @param \Cone\SimplePay\Model\TokenTransaction $tokenTransaction The transaction object you would init. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['dorecurring'] to see the possible values for this operation + * + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @return \Cone\SimplePay\Model\Dorecurring200Response + */ + public function dorecurring( + string $signature, + \Cone\SimplePay\Model\TokenTransaction $tokenTransaction, + string $contentType = self::contentTypes['dorecurring'][0] + ): \Cone\SimplePay\Model\Dorecurring200Response { + list($response) = $this->dorecurringWithHttpInfo($signature, $tokenTransaction, $contentType); + return $response; + } + + /** + * Operation dorecurringWithHttpInfo + * + * Do a recurring transaction + * + * @param string $signature The signature. (required) + * @param \Cone\SimplePay\Model\TokenTransaction $tokenTransaction The transaction object you would init. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['dorecurring'] to see the possible values for this operation + * + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @return array of \Cone\SimplePay\Model\Dorecurring200Response, HTTP status code, HTTP response headers (array of strings) + */ + public function dorecurringWithHttpInfo( + string $signature, + \Cone\SimplePay\Model\TokenTransaction $tokenTransaction, + string $contentType = self::contentTypes['dorecurring'][0] + ): array { + $request = $this->dorecurringRequest($signature, $tokenTransaction, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + switch ($statusCode) { + case 200: + return $this->handleResponseWithDataType( + '\Cone\SimplePay\Model\Dorecurring200Response', + $request, + $response, + ); + } + + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + return $this->handleResponseWithDataType( + '\Cone\SimplePay\Model\Dorecurring200Response', + $request, + $response, + ); + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Cone\SimplePay\Model\Dorecurring200Response', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; + } + + throw $e; + } + } + + /** + * Operation dorecurringAsync + * + * Do a recurring transaction + * + * @param string $signature The signature. (required) + * @param \Cone\SimplePay\Model\TokenTransaction $tokenTransaction The transaction object you would init. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['dorecurring'] to see the possible values for this operation + * + * @throws InvalidArgumentException + * @return PromiseInterface + */ + public function dorecurringAsync( + string $signature, + \Cone\SimplePay\Model\TokenTransaction $tokenTransaction, + string $contentType = self::contentTypes['dorecurring'][0] + ): PromiseInterface { + return $this->dorecurringAsyncWithHttpInfo($signature, $tokenTransaction, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation dorecurringAsyncWithHttpInfo + * + * Do a recurring transaction + * + * @param string $signature The signature. (required) + * @param \Cone\SimplePay\Model\TokenTransaction $tokenTransaction The transaction object you would init. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['dorecurring'] to see the possible values for this operation + * + * @throws InvalidArgumentException + * @return PromiseInterface + */ + public function dorecurringAsyncWithHttpInfo( + string $signature, + \Cone\SimplePay\Model\TokenTransaction $tokenTransaction, + string $contentType = self::contentTypes['dorecurring'][0] + ): PromiseInterface { + $returnType = '\Cone\SimplePay\Model\Dorecurring200Response'; + $request = $this->dorecurringRequest($signature, $tokenTransaction, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if (in_array($returnType, ['\SplFileObject', '\Psr\Http\Message\StreamInterface'], true)) { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders(), + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'dorecurring' + * + * @param string $signature The signature. (required) + * @param \Cone\SimplePay\Model\TokenTransaction $tokenTransaction The transaction object you would init. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['dorecurring'] to see the possible values for this operation + * + * @throws InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function dorecurringRequest( + string $signature, + \Cone\SimplePay\Model\TokenTransaction $tokenTransaction, + string $contentType = self::contentTypes['dorecurring'][0] + ): Request { + + // verify the required parameter 'signature' is set + if ($signature === null || (is_array($signature) && count($signature) === 0)) { + throw new InvalidArgumentException( + 'Missing the required parameter $signature when calling dorecurring' + ); + } + + // verify the required parameter 'tokenTransaction' is set + if ($tokenTransaction === null || (is_array($tokenTransaction) && count($tokenTransaction) === 0)) { + throw new InvalidArgumentException( + 'Missing the required parameter $tokenTransaction when calling dorecurring' + ); + } + + + $resourcePath = '/dorecurring'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + // header params + if ($signature !== null) { + $headerParams['Signature'] = ObjectSerializer::toHeaderValue($signature); + } + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($tokenTransaction)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($tokenTransaction)); + } else { + $httpBody = $tokenTransaction; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem, + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); } /** @@ -1314,6 +1913,301 @@ public function startRequest( ); } + /** + * Operation transactioncancel + * + * Cancel a transaction + * + * @param string $signature The signature. (required) + * @param \Cone\SimplePay\Model\TransactionCancel $transactionCancel The cancel object. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['transactioncancel'] to see the possible values for this operation + * + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @return \Cone\SimplePay\Model\Transactioncancel200Response + */ + public function transactioncancel( + string $signature, + \Cone\SimplePay\Model\TransactionCancel $transactionCancel, + string $contentType = self::contentTypes['transactioncancel'][0] + ): \Cone\SimplePay\Model\Transactioncancel200Response { + list($response) = $this->transactioncancelWithHttpInfo($signature, $transactionCancel, $contentType); + return $response; + } + + /** + * Operation transactioncancelWithHttpInfo + * + * Cancel a transaction + * + * @param string $signature The signature. (required) + * @param \Cone\SimplePay\Model\TransactionCancel $transactionCancel The cancel object. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['transactioncancel'] to see the possible values for this operation + * + * @throws ApiException on non-2xx response or if the response body is not in the expected format + * @throws InvalidArgumentException + * @return array of \Cone\SimplePay\Model\Transactioncancel200Response, HTTP status code, HTTP response headers (array of strings) + */ + public function transactioncancelWithHttpInfo( + string $signature, + \Cone\SimplePay\Model\TransactionCancel $transactionCancel, + string $contentType = self::contentTypes['transactioncancel'][0] + ): array { + $request = $this->transactioncancelRequest($signature, $transactionCancel, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + switch ($statusCode) { + case 200: + return $this->handleResponseWithDataType( + '\Cone\SimplePay\Model\Transactioncancel200Response', + $request, + $response, + ); + } + + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + return $this->handleResponseWithDataType( + '\Cone\SimplePay\Model\Transactioncancel200Response', + $request, + $response, + ); + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Cone\SimplePay\Model\Transactioncancel200Response', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; + } + + throw $e; + } + } + + /** + * Operation transactioncancelAsync + * + * Cancel a transaction + * + * @param string $signature The signature. (required) + * @param \Cone\SimplePay\Model\TransactionCancel $transactionCancel The cancel object. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['transactioncancel'] to see the possible values for this operation + * + * @throws InvalidArgumentException + * @return PromiseInterface + */ + public function transactioncancelAsync( + string $signature, + \Cone\SimplePay\Model\TransactionCancel $transactionCancel, + string $contentType = self::contentTypes['transactioncancel'][0] + ): PromiseInterface { + return $this->transactioncancelAsyncWithHttpInfo($signature, $transactionCancel, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation transactioncancelAsyncWithHttpInfo + * + * Cancel a transaction + * + * @param string $signature The signature. (required) + * @param \Cone\SimplePay\Model\TransactionCancel $transactionCancel The cancel object. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['transactioncancel'] to see the possible values for this operation + * + * @throws InvalidArgumentException + * @return PromiseInterface + */ + public function transactioncancelAsyncWithHttpInfo( + string $signature, + \Cone\SimplePay\Model\TransactionCancel $transactionCancel, + string $contentType = self::contentTypes['transactioncancel'][0] + ): PromiseInterface { + $returnType = '\Cone\SimplePay\Model\Transactioncancel200Response'; + $request = $this->transactioncancelRequest($signature, $transactionCancel, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if (in_array($returnType, ['\SplFileObject', '\Psr\Http\Message\StreamInterface'], true)) { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders(), + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'transactioncancel' + * + * @param string $signature The signature. (required) + * @param \Cone\SimplePay\Model\TransactionCancel $transactionCancel The cancel object. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['transactioncancel'] to see the possible values for this operation + * + * @throws InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function transactioncancelRequest( + string $signature, + \Cone\SimplePay\Model\TransactionCancel $transactionCancel, + string $contentType = self::contentTypes['transactioncancel'][0] + ): Request { + + // verify the required parameter 'signature' is set + if ($signature === null || (is_array($signature) && count($signature) === 0)) { + throw new InvalidArgumentException( + 'Missing the required parameter $signature when calling transactioncancel' + ); + } + + // verify the required parameter 'transactionCancel' is set + if ($transactionCancel === null || (is_array($transactionCancel) && count($transactionCancel) === 0)) { + throw new InvalidArgumentException( + 'Missing the required parameter $transactionCancel when calling transactioncancel' + ); + } + + + $resourcePath = '/transactioncancel'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + // header params + if ($signature !== null) { + $headerParams['Signature'] = ObjectSerializer::toHeaderValue($signature); + } + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($transactionCancel)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($transactionCancel)); + } else { + $httpBody = $transactionCancel; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem, + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + // if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + /** * Create http client option * diff --git a/src/Model/AuthMethod.php b/src/Model/AuthMethod.php new file mode 100644 index 0000000..6d974cc --- /dev/null +++ b/src/Model/AuthMethod.php @@ -0,0 +1,44 @@ + + */ +class Do200Response implements ModelInterface, ArrayAccess, JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static string $openAPIModelName = 'do_200_response'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var array + */ + protected static array $openAPITypes = [ + 'salt' => 'string', + 'merchant' => 'string', + 'transactionId' => 'float', + 'orderRef' => 'string', + 'currency' => '\Cone\SimplePay\Model\Currency', + 'total' => 'float', + 'redirectUrl' => 'string', + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var array + */ + protected static array $openAPIFormats = [ + 'salt' => null, + 'merchant' => null, + 'transactionId' => null, + 'orderRef' => null, + 'currency' => null, + 'total' => null, + 'redirectUrl' => null, + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var array + */ + protected static array $openAPINullables = [ + 'salt' => false, + 'merchant' => false, + 'transactionId' => false, + 'orderRef' => false, + 'currency' => false, + 'total' => false, + 'redirectUrl' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var array + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes(): array + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats(): array + { + 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 array + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param array $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 array + */ + protected static array $attributeMap = [ + 'salt' => 'salt', + 'merchant' => 'merchant', + 'transactionId' => 'transactionId', + 'orderRef' => 'orderRef', + 'currency' => 'currency', + 'total' => 'total', + 'redirectUrl' => 'redirectUrl', + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var array + */ + protected static array $setters = [ + 'salt' => 'setSalt', + 'merchant' => 'setMerchant', + 'transactionId' => 'setTransactionId', + 'orderRef' => 'setOrderRef', + 'currency' => 'setCurrency', + 'total' => 'setTotal', + 'redirectUrl' => 'setRedirectUrl', + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var array + */ + protected static array $getters = [ + 'salt' => 'getSalt', + 'merchant' => 'getMerchant', + 'transactionId' => 'getTransactionId', + 'orderRef' => 'getOrderRef', + 'currency' => 'getCurrency', + 'total' => 'getTotal', + 'redirectUrl' => 'getRedirectUrl', + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap(): array + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters(): array + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters(): array + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName(): string + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var array + */ + protected array $container = []; + + /** + * Constructor + * + * @param array $data Associated array of property values initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('salt', $data ?? [], null); + $this->setIfExists('merchant', $data ?? [], null); + $this->setIfExists('transactionId', $data ?? [], null); + $this->setIfExists('orderRef', $data ?? [], null); + $this->setIfExists('currency', $data ?? [], null); + $this->setIfExists('total', $data ?? [], null); + $this->setIfExists('redirectUrl', $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, mixed $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 string[] invalid properties with reasons + */ + public function listInvalidProperties(): array + { + $invalidProperties = []; + + 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(): bool + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets salt + * + * @return string|null + */ + public function getSalt(): ?string + { + return $this->container['salt']; + } + + /** + * Sets salt + * + * @param string|null $salt salt + * + * @return $this + */ + public function setSalt(?string $salt): static + { + if (is_null($salt)) { + throw new InvalidArgumentException('non-nullable salt cannot be null'); + } + $this->container['salt'] = $salt; + + return $this; + } + + /** + * Gets merchant + * + * @return string|null + */ + public function getMerchant(): ?string + { + return $this->container['merchant']; + } + + /** + * Sets merchant + * + * @param string|null $merchant merchant + * + * @return $this + */ + public function setMerchant(?string $merchant): static + { + if (is_null($merchant)) { + throw new InvalidArgumentException('non-nullable merchant cannot be null'); + } + $this->container['merchant'] = $merchant; + + return $this; + } + + /** + * Gets transactionId + * + * @return float|null + */ + public function getTransactionId(): ?float + { + return $this->container['transactionId']; + } + + /** + * Sets transactionId + * + * @param float|null $transactionId transactionId + * + * @return $this + */ + public function setTransactionId(?float $transactionId): static + { + if (is_null($transactionId)) { + throw new InvalidArgumentException('non-nullable transactionId cannot be null'); + } + $this->container['transactionId'] = $transactionId; + + return $this; + } + + /** + * Gets orderRef + * + * @return string|null + */ + public function getOrderRef(): ?string + { + return $this->container['orderRef']; + } + + /** + * Sets orderRef + * + * @param string|null $orderRef orderRef + * + * @return $this + */ + public function setOrderRef(?string $orderRef): static + { + if (is_null($orderRef)) { + throw new InvalidArgumentException('non-nullable orderRef cannot be null'); + } + $this->container['orderRef'] = $orderRef; + + return $this; + } + + /** + * Gets currency + * + * @return \Cone\SimplePay\Model\Currency|null + */ + public function getCurrency(): ?\Cone\SimplePay\Model\Currency + { + return $this->container['currency']; + } + + /** + * Sets currency + * + * @param \Cone\SimplePay\Model\Currency|null $currency currency + * + * @return $this + */ + public function setCurrency(?\Cone\SimplePay\Model\Currency $currency): static + { + if (is_null($currency)) { + throw new InvalidArgumentException('non-nullable currency cannot be null'); + } + $this->container['currency'] = $currency; + + return $this; + } + + /** + * Gets total + * + * @return float|null + */ + public function getTotal(): ?float + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param float|null $total total + * + * @return $this + */ + public function setTotal(?float $total): static + { + if (is_null($total)) { + throw new InvalidArgumentException('non-nullable total cannot be null'); + } + $this->container['total'] = $total; + + return $this; + } + + /** + * Gets redirectUrl + * + * @return string|null + */ + public function getRedirectUrl(): ?string + { + return $this->container['redirectUrl']; + } + + /** + * Sets redirectUrl + * + * @param string|null $redirectUrl The 3DS challange interface URL. + * + * @return $this + */ + public function setRedirectUrl(?string $redirectUrl): static + { + if (is_null($redirectUrl)) { + throw new InvalidArgumentException('non-nullable redirectUrl cannot be null'); + } + $this->container['redirectUrl'] = $redirectUrl; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param int $offset Offset + * + * @return bool + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param int $offset Offset + * + * @return mixed|null + */ + #[ReturnTypeWillChange] + public function offsetGet(mixed $offset): mixed + { + 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(mixed $offset, mixed $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(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(): mixed + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString(): string + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue(): string + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} diff --git a/src/Model/Dorecurring200Response.php b/src/Model/Dorecurring200Response.php new file mode 100644 index 0000000..30be9f5 --- /dev/null +++ b/src/Model/Dorecurring200Response.php @@ -0,0 +1,575 @@ + + */ +class Dorecurring200Response implements ModelInterface, ArrayAccess, JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static string $openAPIModelName = 'dorecurring_200_response'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var array + */ + protected static array $openAPITypes = [ + 'salt' => 'string', + 'merchant' => 'string', + 'transactionId' => 'float', + 'orderRef' => 'string', + 'currency' => '\Cone\SimplePay\Model\Currency', + 'total' => 'float', + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var array + */ + protected static array $openAPIFormats = [ + 'salt' => null, + 'merchant' => null, + 'transactionId' => null, + 'orderRef' => null, + 'currency' => null, + 'total' => null, + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var array + */ + protected static array $openAPINullables = [ + 'salt' => false, + 'merchant' => false, + 'transactionId' => false, + 'orderRef' => false, + 'currency' => false, + 'total' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var array + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes(): array + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats(): array + { + 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 array + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param array $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 array + */ + protected static array $attributeMap = [ + 'salt' => 'salt', + 'merchant' => 'merchant', + 'transactionId' => 'transactionId', + 'orderRef' => 'orderRef', + 'currency' => 'currency', + 'total' => 'total', + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var array + */ + protected static array $setters = [ + 'salt' => 'setSalt', + 'merchant' => 'setMerchant', + 'transactionId' => 'setTransactionId', + 'orderRef' => 'setOrderRef', + 'currency' => 'setCurrency', + 'total' => 'setTotal', + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var array + */ + protected static array $getters = [ + 'salt' => 'getSalt', + 'merchant' => 'getMerchant', + 'transactionId' => 'getTransactionId', + 'orderRef' => 'getOrderRef', + 'currency' => 'getCurrency', + 'total' => 'getTotal', + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap(): array + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters(): array + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters(): array + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName(): string + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var array + */ + protected array $container = []; + + /** + * Constructor + * + * @param array $data Associated array of property values initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('salt', $data ?? [], null); + $this->setIfExists('merchant', $data ?? [], null); + $this->setIfExists('transactionId', $data ?? [], null); + $this->setIfExists('orderRef', $data ?? [], null); + $this->setIfExists('currency', $data ?? [], null); + $this->setIfExists('total', $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, mixed $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 string[] invalid properties with reasons + */ + public function listInvalidProperties(): array + { + $invalidProperties = []; + + 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(): bool + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets salt + * + * @return string|null + */ + public function getSalt(): ?string + { + return $this->container['salt']; + } + + /** + * Sets salt + * + * @param string|null $salt salt + * + * @return $this + */ + public function setSalt(?string $salt): static + { + if (is_null($salt)) { + throw new InvalidArgumentException('non-nullable salt cannot be null'); + } + $this->container['salt'] = $salt; + + return $this; + } + + /** + * Gets merchant + * + * @return string|null + */ + public function getMerchant(): ?string + { + return $this->container['merchant']; + } + + /** + * Sets merchant + * + * @param string|null $merchant merchant + * + * @return $this + */ + public function setMerchant(?string $merchant): static + { + if (is_null($merchant)) { + throw new InvalidArgumentException('non-nullable merchant cannot be null'); + } + $this->container['merchant'] = $merchant; + + return $this; + } + + /** + * Gets transactionId + * + * @return float|null + */ + public function getTransactionId(): ?float + { + return $this->container['transactionId']; + } + + /** + * Sets transactionId + * + * @param float|null $transactionId transactionId + * + * @return $this + */ + public function setTransactionId(?float $transactionId): static + { + if (is_null($transactionId)) { + throw new InvalidArgumentException('non-nullable transactionId cannot be null'); + } + $this->container['transactionId'] = $transactionId; + + return $this; + } + + /** + * Gets orderRef + * + * @return string|null + */ + public function getOrderRef(): ?string + { + return $this->container['orderRef']; + } + + /** + * Sets orderRef + * + * @param string|null $orderRef orderRef + * + * @return $this + */ + public function setOrderRef(?string $orderRef): static + { + if (is_null($orderRef)) { + throw new InvalidArgumentException('non-nullable orderRef cannot be null'); + } + $this->container['orderRef'] = $orderRef; + + return $this; + } + + /** + * Gets currency + * + * @return \Cone\SimplePay\Model\Currency|null + */ + public function getCurrency(): ?\Cone\SimplePay\Model\Currency + { + return $this->container['currency']; + } + + /** + * Sets currency + * + * @param \Cone\SimplePay\Model\Currency|null $currency currency + * + * @return $this + */ + public function setCurrency(?\Cone\SimplePay\Model\Currency $currency): static + { + if (is_null($currency)) { + throw new InvalidArgumentException('non-nullable currency cannot be null'); + } + $this->container['currency'] = $currency; + + return $this; + } + + /** + * Gets total + * + * @return float|null + */ + public function getTotal(): ?float + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param float|null $total total + * + * @return $this + */ + public function setTotal(?float $total): static + { + if (is_null($total)) { + throw new InvalidArgumentException('non-nullable total cannot be null'); + } + $this->container['total'] = $total; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param int $offset Offset + * + * @return bool + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param int $offset Offset + * + * @return mixed|null + */ + #[ReturnTypeWillChange] + public function offsetGet(mixed $offset): mixed + { + 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(mixed $offset, mixed $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(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(): mixed + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString(): string + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue(): string + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} diff --git a/src/Model/OneClickTransaction.php b/src/Model/OneClickTransaction.php new file mode 100644 index 0000000..b9510b2 --- /dev/null +++ b/src/Model/OneClickTransaction.php @@ -0,0 +1,1229 @@ + + */ +class OneClickTransaction implements ModelInterface, ArrayAccess, JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static string $openAPIModelName = 'OneClickTransaction'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var array + */ + protected static array $openAPITypes = [ + 'customer' => 'string', + 'customerEmail' => 'string', + 'currency' => '\Cone\SimplePay\Model\Currency', + 'maySelectInvoice' => 'bool', + 'maySelectEmail' => 'bool', + 'maySelectDelivery' => 'string[]', + 'twoStep' => 'bool', + 'onlyCardReg' => 'bool', + 'url' => 'string', + 'urls' => '\Cone\SimplePay\Model\TransactionUrls', + 'language' => '\Cone\SimplePay\Model\Language', + 'discount' => 'float', + 'shippingCost' => 'float', + 'total' => 'float', + 'delivery' => '\Cone\SimplePay\Model\Delivery', + 'invoice' => '\Cone\SimplePay\Model\Invoice', + 'items' => '\Cone\SimplePay\Model\Item[]', + 'methods' => '\Cone\SimplePay\Model\Method[]', + 'timeout' => 'string', + 'threeDSReqAuthMethod' => '\Cone\SimplePay\Model\AuthMethod', + 'type' => '\Cone\SimplePay\Model\TransactionType', + 'cardId' => 'float', + 'cardSecret' => 'string', + 'browser' => '\Cone\SimplePay\Model\OneClickTransactionAllOfBrowser', + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var array + */ + protected static array $openAPIFormats = [ + 'customer' => null, + 'customerEmail' => 'email', + 'currency' => null, + 'maySelectInvoice' => null, + 'maySelectEmail' => null, + 'maySelectDelivery' => null, + 'twoStep' => null, + 'onlyCardReg' => null, + 'url' => null, + 'urls' => null, + 'language' => null, + 'discount' => null, + 'shippingCost' => null, + 'total' => null, + 'delivery' => null, + 'invoice' => null, + 'items' => null, + 'methods' => null, + 'timeout' => null, + 'threeDSReqAuthMethod' => null, + 'type' => null, + 'cardId' => null, + 'cardSecret' => null, + 'browser' => null, + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var array + */ + protected static array $openAPINullables = [ + 'customer' => false, + 'customerEmail' => false, + 'currency' => false, + 'maySelectInvoice' => false, + 'maySelectEmail' => false, + 'maySelectDelivery' => false, + 'twoStep' => false, + 'onlyCardReg' => false, + 'url' => false, + 'urls' => false, + 'language' => false, + 'discount' => false, + 'shippingCost' => false, + 'total' => false, + 'delivery' => false, + 'invoice' => false, + 'items' => false, + 'methods' => false, + 'timeout' => false, + 'threeDSReqAuthMethod' => false, + 'type' => false, + 'cardId' => false, + 'cardSecret' => false, + 'browser' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var array + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes(): array + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats(): array + { + 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 array + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param array $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 array + */ + protected static array $attributeMap = [ + 'customer' => 'customer', + 'customerEmail' => 'customerEmail', + 'currency' => 'currency', + 'maySelectInvoice' => 'maySelectInvoice', + 'maySelectEmail' => 'maySelectEmail', + 'maySelectDelivery' => 'maySelectDelivery', + 'twoStep' => 'twoStep', + 'onlyCardReg' => 'onlyCardReg', + 'url' => 'url', + 'urls' => 'urls', + 'language' => 'language', + 'discount' => 'discount', + 'shippingCost' => 'shippingCost', + 'total' => 'total', + 'delivery' => 'delivery', + 'invoice' => 'invoice', + 'items' => 'items', + 'methods' => 'methods', + 'timeout' => 'timeout', + 'threeDSReqAuthMethod' => 'threeDSReqAuthMethod', + 'type' => 'type', + 'cardId' => 'cardId', + 'cardSecret' => 'cardSecret', + 'browser' => 'browser', + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var array + */ + protected static array $setters = [ + 'customer' => 'setCustomer', + 'customerEmail' => 'setCustomerEmail', + 'currency' => 'setCurrency', + 'maySelectInvoice' => 'setMaySelectInvoice', + 'maySelectEmail' => 'setMaySelectEmail', + 'maySelectDelivery' => 'setMaySelectDelivery', + 'twoStep' => 'setTwoStep', + 'onlyCardReg' => 'setOnlyCardReg', + 'url' => 'setUrl', + 'urls' => 'setUrls', + 'language' => 'setLanguage', + 'discount' => 'setDiscount', + 'shippingCost' => 'setShippingCost', + 'total' => 'setTotal', + 'delivery' => 'setDelivery', + 'invoice' => 'setInvoice', + 'items' => 'setItems', + 'methods' => 'setMethods', + 'timeout' => 'setTimeout', + 'threeDSReqAuthMethod' => 'setThreeDSReqAuthMethod', + 'type' => 'setType', + 'cardId' => 'setCardId', + 'cardSecret' => 'setCardSecret', + 'browser' => 'setBrowser', + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var array + */ + protected static array $getters = [ + 'customer' => 'getCustomer', + 'customerEmail' => 'getCustomerEmail', + 'currency' => 'getCurrency', + 'maySelectInvoice' => 'getMaySelectInvoice', + 'maySelectEmail' => 'getMaySelectEmail', + 'maySelectDelivery' => 'getMaySelectDelivery', + 'twoStep' => 'getTwoStep', + 'onlyCardReg' => 'getOnlyCardReg', + 'url' => 'getUrl', + 'urls' => 'getUrls', + 'language' => 'getLanguage', + 'discount' => 'getDiscount', + 'shippingCost' => 'getShippingCost', + 'total' => 'getTotal', + 'delivery' => 'getDelivery', + 'invoice' => 'getInvoice', + 'items' => 'getItems', + 'methods' => 'getMethods', + 'timeout' => 'getTimeout', + 'threeDSReqAuthMethod' => 'getThreeDSReqAuthMethod', + 'type' => 'getType', + 'cardId' => 'getCardId', + 'cardSecret' => 'getCardSecret', + 'browser' => 'getBrowser', + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap(): array + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters(): array + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters(): array + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName(): string + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var array + */ + protected array $container = []; + + /** + * Constructor + * + * @param array $data Associated array of property values initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('customer', $data ?? [], null); + $this->setIfExists('customerEmail', $data ?? [], null); + $this->setIfExists('currency', $data ?? [], null); + $this->setIfExists('maySelectInvoice', $data ?? [], false); + $this->setIfExists('maySelectEmail', $data ?? [], false); + $this->setIfExists('maySelectDelivery', $data ?? [], null); + $this->setIfExists('twoStep', $data ?? [], false); + $this->setIfExists('onlyCardReg', $data ?? [], false); + $this->setIfExists('url', $data ?? [], null); + $this->setIfExists('urls', $data ?? [], null); + $this->setIfExists('language', $data ?? [], null); + $this->setIfExists('discount', $data ?? [], 0); + $this->setIfExists('shippingCost', $data ?? [], 0); + $this->setIfExists('total', $data ?? [], 0); + $this->setIfExists('delivery', $data ?? [], null); + $this->setIfExists('invoice', $data ?? [], null); + $this->setIfExists('items', $data ?? [], null); + $this->setIfExists('methods', $data ?? [], null); + $this->setIfExists('timeout', $data ?? [], null); + $this->setIfExists('threeDSReqAuthMethod', $data ?? [], null); + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('cardId', $data ?? [], null); + $this->setIfExists('cardSecret', $data ?? [], null); + $this->setIfExists('browser', $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, mixed $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 string[] invalid properties with reasons + */ + public function listInvalidProperties(): array + { + $invalidProperties = []; + + if ($this->container['customerEmail'] === null) { + $invalidProperties[] = "'customerEmail' can't be null"; + } + if ($this->container['currency'] === null) { + $invalidProperties[] = "'currency' can't be null"; + } + if ($this->container['language'] === null) { + $invalidProperties[] = "'language' can't be null"; + } + if (!is_null($this->container['discount']) && ($this->container['discount'] < 0)) { + $invalidProperties[] = "invalid value for 'discount', must be bigger than or equal to 0."; + } + + if (!is_null($this->container['shippingCost']) && ($this->container['shippingCost'] < 0)) { + $invalidProperties[] = "invalid value for 'shippingCost', must be bigger than or equal to 0."; + } + + if (!is_null($this->container['total']) && ($this->container['total'] <= 0)) { + $invalidProperties[] = "invalid value for 'total', must be bigger than 0."; + } + + if ($this->container['methods'] === null) { + $invalidProperties[] = "'methods' can't be null"; + } + if ($this->container['timeout'] === null) { + $invalidProperties[] = "'timeout' 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(): bool + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets customer + * + * @return string|null + */ + public function getCustomer(): ?string + { + return $this->container['customer']; + } + + /** + * Sets customer + * + * @param string|null $customer customer + * + * @return $this + */ + public function setCustomer(?string $customer): static + { + if (is_null($customer)) { + throw new InvalidArgumentException('non-nullable customer cannot be null'); + } + $this->container['customer'] = $customer; + + return $this; + } + + /** + * Gets customerEmail + * + * @return string + */ + public function getCustomerEmail(): string + { + return $this->container['customerEmail']; + } + + /** + * Sets customerEmail + * + * @param string $customerEmail customerEmail + * + * @return $this + */ + public function setCustomerEmail(string $customerEmail): static + { + if (is_null($customerEmail)) { + throw new InvalidArgumentException('non-nullable customerEmail cannot be null'); + } + $this->container['customerEmail'] = $customerEmail; + + return $this; + } + + /** + * Gets currency + * + * @return \Cone\SimplePay\Model\Currency + */ + public function getCurrency(): \Cone\SimplePay\Model\Currency + { + return $this->container['currency']; + } + + /** + * Sets currency + * + * @param \Cone\SimplePay\Model\Currency $currency currency + * + * @return $this + */ + public function setCurrency(\Cone\SimplePay\Model\Currency $currency): static + { + if (is_null($currency)) { + throw new InvalidArgumentException('non-nullable currency cannot be null'); + } + $this->container['currency'] = $currency; + + return $this; + } + + /** + * Gets maySelectInvoice + * + * @return bool|null + */ + public function getMaySelectInvoice(): ?bool + { + return $this->container['maySelectInvoice']; + } + + /** + * Sets maySelectInvoice + * + * @param bool|null $maySelectInvoice maySelectInvoice + * + * @return $this + */ + public function setMaySelectInvoice(?bool $maySelectInvoice): static + { + if (is_null($maySelectInvoice)) { + throw new InvalidArgumentException('non-nullable maySelectInvoice cannot be null'); + } + $this->container['maySelectInvoice'] = $maySelectInvoice; + + return $this; + } + + /** + * Gets maySelectEmail + * + * @return bool|null + */ + public function getMaySelectEmail(): ?bool + { + return $this->container['maySelectEmail']; + } + + /** + * Sets maySelectEmail + * + * @param bool|null $maySelectEmail maySelectEmail + * + * @return $this + */ + public function setMaySelectEmail(?bool $maySelectEmail): static + { + if (is_null($maySelectEmail)) { + throw new InvalidArgumentException('non-nullable maySelectEmail cannot be null'); + } + $this->container['maySelectEmail'] = $maySelectEmail; + + return $this; + } + + /** + * Gets maySelectDelivery + * + * @return string[]|null + */ + public function getMaySelectDelivery(): ?array + { + return $this->container['maySelectDelivery']; + } + + /** + * Sets maySelectDelivery + * + * @param string[]|null $maySelectDelivery maySelectDelivery + * + * @return $this + */ + public function setMaySelectDelivery(?array $maySelectDelivery): static + { + if (is_null($maySelectDelivery)) { + throw new InvalidArgumentException('non-nullable maySelectDelivery cannot be null'); + } + $this->container['maySelectDelivery'] = $maySelectDelivery; + + return $this; + } + + /** + * Gets twoStep + * + * @return bool|null + */ + public function getTwoStep(): ?bool + { + return $this->container['twoStep']; + } + + /** + * Sets twoStep + * + * @param bool|null $twoStep twoStep + * + * @return $this + */ + public function setTwoStep(?bool $twoStep): static + { + if (is_null($twoStep)) { + throw new InvalidArgumentException('non-nullable twoStep cannot be null'); + } + $this->container['twoStep'] = $twoStep; + + return $this; + } + + /** + * Gets onlyCardReg + * + * @return bool|null + */ + public function getOnlyCardReg(): ?bool + { + return $this->container['onlyCardReg']; + } + + /** + * Sets onlyCardReg + * + * @param bool|null $onlyCardReg onlyCardReg + * + * @return $this + */ + public function setOnlyCardReg(?bool $onlyCardReg): static + { + if (is_null($onlyCardReg)) { + throw new InvalidArgumentException('non-nullable onlyCardReg cannot be null'); + } + $this->container['onlyCardReg'] = $onlyCardReg; + + return $this; + } + + /** + * Gets url + * + * @return string|null + */ + public function getUrl(): ?string + { + return $this->container['url']; + } + + /** + * Sets url + * + * @param string|null $url url + * + * @return $this + */ + public function setUrl(?string $url): static + { + if (is_null($url)) { + throw new InvalidArgumentException('non-nullable url cannot be null'); + } + $this->container['url'] = $url; + + return $this; + } + + /** + * Gets urls + * + * @return \Cone\SimplePay\Model\TransactionUrls|null + */ + public function getUrls(): ?\Cone\SimplePay\Model\TransactionUrls + { + return $this->container['urls']; + } + + /** + * Sets urls + * + * @param \Cone\SimplePay\Model\TransactionUrls|null $urls urls + * + * @return $this + */ + public function setUrls(?\Cone\SimplePay\Model\TransactionUrls $urls): static + { + if (is_null($urls)) { + throw new InvalidArgumentException('non-nullable urls cannot be null'); + } + $this->container['urls'] = $urls; + + return $this; + } + + /** + * Gets language + * + * @return \Cone\SimplePay\Model\Language + */ + public function getLanguage(): \Cone\SimplePay\Model\Language + { + return $this->container['language']; + } + + /** + * Sets language + * + * @param \Cone\SimplePay\Model\Language $language language + * + * @return $this + */ + public function setLanguage(\Cone\SimplePay\Model\Language $language): static + { + if (is_null($language)) { + throw new InvalidArgumentException('non-nullable language cannot be null'); + } + $this->container['language'] = $language; + + return $this; + } + + /** + * Gets discount + * + * @return float|null + */ + public function getDiscount(): ?float + { + return $this->container['discount']; + } + + /** + * Sets discount + * + * @param float|null $discount discount + * + * @return $this + */ + public function setDiscount(?float $discount): static + { + if (is_null($discount)) { + throw new InvalidArgumentException('non-nullable discount cannot be null'); + } + + if (($discount < 0)) { + throw new InvalidArgumentException('invalid value for $discount when calling OneClickTransaction., must be bigger than or equal to 0.'); + } + + $this->container['discount'] = $discount; + + return $this; + } + + /** + * Gets shippingCost + * + * @return float|null + */ + public function getShippingCost(): ?float + { + return $this->container['shippingCost']; + } + + /** + * Sets shippingCost + * + * @param float|null $shippingCost shippingCost + * + * @return $this + */ + public function setShippingCost(?float $shippingCost): static + { + if (is_null($shippingCost)) { + throw new InvalidArgumentException('non-nullable shippingCost cannot be null'); + } + + if (($shippingCost < 0)) { + throw new InvalidArgumentException('invalid value for $shippingCost when calling OneClickTransaction., must be bigger than or equal to 0.'); + } + + $this->container['shippingCost'] = $shippingCost; + + return $this; + } + + /** + * Gets total + * + * @return float|null + */ + public function getTotal(): ?float + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param float|null $total total + * + * @return $this + */ + public function setTotal(?float $total): static + { + if (is_null($total)) { + throw new InvalidArgumentException('non-nullable total cannot be null'); + } + + if (($total <= 0)) { + throw new InvalidArgumentException('invalid value for $total when calling OneClickTransaction., must be bigger than 0.'); + } + + $this->container['total'] = $total; + + return $this; + } + + /** + * Gets delivery + * + * @return \Cone\SimplePay\Model\Delivery|null + */ + public function getDelivery(): ?\Cone\SimplePay\Model\Delivery + { + return $this->container['delivery']; + } + + /** + * Sets delivery + * + * @param \Cone\SimplePay\Model\Delivery|null $delivery delivery + * + * @return $this + */ + public function setDelivery(?\Cone\SimplePay\Model\Delivery $delivery): static + { + if (is_null($delivery)) { + throw new InvalidArgumentException('non-nullable delivery cannot be null'); + } + $this->container['delivery'] = $delivery; + + return $this; + } + + /** + * Gets invoice + * + * @return \Cone\SimplePay\Model\Invoice|null + */ + public function getInvoice(): ?\Cone\SimplePay\Model\Invoice + { + return $this->container['invoice']; + } + + /** + * Sets invoice + * + * @param \Cone\SimplePay\Model\Invoice|null $invoice invoice + * + * @return $this + */ + public function setInvoice(?\Cone\SimplePay\Model\Invoice $invoice): static + { + if (is_null($invoice)) { + throw new InvalidArgumentException('non-nullable invoice cannot be null'); + } + $this->container['invoice'] = $invoice; + + return $this; + } + + /** + * Gets items + * + * @return \Cone\SimplePay\Model\Item[]|null + */ + public function getItems(): ?array + { + return $this->container['items']; + } + + /** + * Sets items + * + * @param \Cone\SimplePay\Model\Item[]|null $items items + * + * @return $this + */ + public function setItems(?array $items): static + { + if (is_null($items)) { + throw new InvalidArgumentException('non-nullable items cannot be null'); + } + $this->container['items'] = $items; + + return $this; + } + + /** + * Gets methods + * + * @return \Cone\SimplePay\Model\Method[] + */ + public function getMethods(): array + { + return $this->container['methods']; + } + + /** + * Sets methods + * + * @param \Cone\SimplePay\Model\Method[] $methods Possible values: CARD, WIRE or EAM. + * + * @return $this + */ + public function setMethods(array $methods): static + { + if (is_null($methods)) { + throw new InvalidArgumentException('non-nullable methods cannot be null'); + } + $this->container['methods'] = $methods; + + return $this; + } + + /** + * Gets timeout + * + * @return string + */ + public function getTimeout(): string + { + return $this->container['timeout']; + } + + /** + * Sets timeout + * + * @param string $timeout The ISO 8601 format of the timeout date. + * + * @return $this + */ + public function setTimeout(string $timeout): static + { + if (is_null($timeout)) { + throw new InvalidArgumentException('non-nullable timeout cannot be null'); + } + $this->container['timeout'] = $timeout; + + return $this; + } + + /** + * Gets threeDSReqAuthMethod + * + * @return \Cone\SimplePay\Model\AuthMethod|null + */ + public function getThreeDSReqAuthMethod(): ?\Cone\SimplePay\Model\AuthMethod + { + return $this->container['threeDSReqAuthMethod']; + } + + /** + * Sets threeDSReqAuthMethod + * + * @param \Cone\SimplePay\Model\AuthMethod|null $threeDSReqAuthMethod threeDSReqAuthMethod + * + * @return $this + */ + public function setThreeDSReqAuthMethod(?\Cone\SimplePay\Model\AuthMethod $threeDSReqAuthMethod): static + { + if (is_null($threeDSReqAuthMethod)) { + throw new InvalidArgumentException('non-nullable threeDSReqAuthMethod cannot be null'); + } + $this->container['threeDSReqAuthMethod'] = $threeDSReqAuthMethod; + + return $this; + } + + /** + * Gets type + * + * @return \Cone\SimplePay\Model\TransactionType|null + */ + public function getType(): ?\Cone\SimplePay\Model\TransactionType + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param \Cone\SimplePay\Model\TransactionType|null $type For one-click payments this should be always 'CIT'. + * + * @return $this + */ + public function setType(?\Cone\SimplePay\Model\TransactionType $type): static + { + if (is_null($type)) { + throw new InvalidArgumentException('non-nullable type cannot be null'); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets cardId + * + * @return float|null + */ + public function getCardId(): ?float + { + return $this->container['cardId']; + } + + /** + * Sets cardId + * + * @param float|null $cardId cardId + * + * @return $this + */ + public function setCardId(?float $cardId): static + { + if (is_null($cardId)) { + throw new InvalidArgumentException('non-nullable cardId cannot be null'); + } + $this->container['cardId'] = $cardId; + + return $this; + } + + /** + * Gets cardSecret + * + * @return string|null + */ + public function getCardSecret(): ?string + { + return $this->container['cardSecret']; + } + + /** + * Sets cardSecret + * + * @param string|null $cardSecret cardSecret + * + * @return $this + */ + public function setCardSecret(?string $cardSecret): static + { + if (is_null($cardSecret)) { + throw new InvalidArgumentException('non-nullable cardSecret cannot be null'); + } + $this->container['cardSecret'] = $cardSecret; + + return $this; + } + + /** + * Gets browser + * + * @return \Cone\SimplePay\Model\OneClickTransactionAllOfBrowser|null + */ + public function getBrowser(): ?\Cone\SimplePay\Model\OneClickTransactionAllOfBrowser + { + return $this->container['browser']; + } + + /** + * Sets browser + * + * @param \Cone\SimplePay\Model\OneClickTransactionAllOfBrowser|null $browser browser + * + * @return $this + */ + public function setBrowser(?\Cone\SimplePay\Model\OneClickTransactionAllOfBrowser $browser): static + { + if (is_null($browser)) { + throw new InvalidArgumentException('non-nullable browser cannot be null'); + } + $this->container['browser'] = $browser; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param int $offset Offset + * + * @return bool + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param int $offset Offset + * + * @return mixed|null + */ + #[ReturnTypeWillChange] + public function offsetGet(mixed $offset): mixed + { + 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(mixed $offset, mixed $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(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(): mixed + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString(): string + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue(): string + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} diff --git a/src/Model/OneClickTransactionAllOfBrowser.php b/src/Model/OneClickTransactionAllOfBrowser.php new file mode 100644 index 0000000..976c31d --- /dev/null +++ b/src/Model/OneClickTransactionAllOfBrowser.php @@ -0,0 +1,677 @@ + + */ +class OneClickTransactionAllOfBrowser implements ModelInterface, ArrayAccess, JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static string $openAPIModelName = 'OneClickTransaction_allOf_browser'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var array + */ + protected static array $openAPITypes = [ + 'ip' => 'string', + 'accept' => 'string', + 'agent' => 'string', + 'color' => 'int', + 'height' => 'int', + 'width' => 'int', + 'java' => 'bool', + 'lang' => 'string', + 'tz' => 'int', + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var array + */ + protected static array $openAPIFormats = [ + 'ip' => null, + 'accept' => null, + 'agent' => null, + 'color' => null, + 'height' => null, + 'width' => null, + 'java' => null, + 'lang' => null, + 'tz' => null, + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var array + */ + protected static array $openAPINullables = [ + 'ip' => false, + 'accept' => false, + 'agent' => false, + 'color' => false, + 'height' => false, + 'width' => false, + 'java' => false, + 'lang' => false, + 'tz' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var array + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes(): array + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats(): array + { + 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 array + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param array $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 array + */ + protected static array $attributeMap = [ + 'ip' => 'ip', + 'accept' => 'accept', + 'agent' => 'agent', + 'color' => 'color', + 'height' => 'height', + 'width' => 'width', + 'java' => 'java', + 'lang' => 'lang', + 'tz' => 'tz', + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var array + */ + protected static array $setters = [ + 'ip' => 'setIp', + 'accept' => 'setAccept', + 'agent' => 'setAgent', + 'color' => 'setColor', + 'height' => 'setHeight', + 'width' => 'setWidth', + 'java' => 'setJava', + 'lang' => 'setLang', + 'tz' => 'setTz', + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var array + */ + protected static array $getters = [ + 'ip' => 'getIp', + 'accept' => 'getAccept', + 'agent' => 'getAgent', + 'color' => 'getColor', + 'height' => 'getHeight', + 'width' => 'getWidth', + 'java' => 'getJava', + 'lang' => 'getLang', + 'tz' => 'getTz', + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap(): array + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters(): array + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters(): array + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName(): string + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var array + */ + protected array $container = []; + + /** + * Constructor + * + * @param array $data Associated array of property values initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('ip', $data ?? [], null); + $this->setIfExists('accept', $data ?? [], null); + $this->setIfExists('agent', $data ?? [], null); + $this->setIfExists('color', $data ?? [], null); + $this->setIfExists('height', $data ?? [], null); + $this->setIfExists('width', $data ?? [], null); + $this->setIfExists('java', $data ?? [], null); + $this->setIfExists('lang', $data ?? [], null); + $this->setIfExists('tz', $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, mixed $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 string[] invalid properties with reasons + */ + public function listInvalidProperties(): array + { + $invalidProperties = []; + + 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(): bool + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets ip + * + * @return string|null + */ + public function getIp(): ?string + { + return $this->container['ip']; + } + + /** + * Sets ip + * + * @param string|null $ip ip + * + * @return $this + */ + public function setIp(?string $ip): static + { + if (is_null($ip)) { + throw new InvalidArgumentException('non-nullable ip cannot be null'); + } + $this->container['ip'] = $ip; + + return $this; + } + + /** + * Gets accept + * + * @return string|null + */ + public function getAccept(): ?string + { + return $this->container['accept']; + } + + /** + * Sets accept + * + * @param string|null $accept accept + * + * @return $this + */ + public function setAccept(?string $accept): static + { + if (is_null($accept)) { + throw new InvalidArgumentException('non-nullable accept cannot be null'); + } + $this->container['accept'] = $accept; + + return $this; + } + + /** + * Gets agent + * + * @return string|null + */ + public function getAgent(): ?string + { + return $this->container['agent']; + } + + /** + * Sets agent + * + * @param string|null $agent You may use 'navigator.userAgent' in JS. + * + * @return $this + */ + public function setAgent(?string $agent): static + { + if (is_null($agent)) { + throw new InvalidArgumentException('non-nullable agent cannot be null'); + } + $this->container['agent'] = $agent; + + return $this; + } + + /** + * Gets color + * + * @return int|null + */ + public function getColor(): ?int + { + return $this->container['color']; + } + + /** + * Sets color + * + * @param int|null $color You may use 'screen.colorDepth' in JS. + * + * @return $this + */ + public function setColor(?int $color): static + { + if (is_null($color)) { + throw new InvalidArgumentException('non-nullable color cannot be null'); + } + $this->container['color'] = $color; + + return $this; + } + + /** + * Gets height + * + * @return int|null + */ + public function getHeight(): ?int + { + return $this->container['height']; + } + + /** + * Sets height + * + * @param int|null $height You may use 'screen.height' in JS. + * + * @return $this + */ + public function setHeight(?int $height): static + { + if (is_null($height)) { + throw new InvalidArgumentException('non-nullable height cannot be null'); + } + $this->container['height'] = $height; + + return $this; + } + + /** + * Gets width + * + * @return int|null + */ + public function getWidth(): ?int + { + return $this->container['width']; + } + + /** + * Sets width + * + * @param int|null $width You may use 'screen.width' in JS. + * + * @return $this + */ + public function setWidth(?int $width): static + { + if (is_null($width)) { + throw new InvalidArgumentException('non-nullable width cannot be null'); + } + $this->container['width'] = $width; + + return $this; + } + + /** + * Gets java + * + * @return bool|null + */ + public function getJava(): ?bool + { + return $this->container['java']; + } + + /** + * Sets java + * + * @param bool|null $java You may use 'navigator.javaEnabled()' in JS. + * + * @return $this + */ + public function setJava(?bool $java): static + { + if (is_null($java)) { + throw new InvalidArgumentException('non-nullable java cannot be null'); + } + $this->container['java'] = $java; + + return $this; + } + + /** + * Gets lang + * + * @return string|null + */ + public function getLang(): ?string + { + return $this->container['lang']; + } + + /** + * Sets lang + * + * @param string|null $lang You may use 'navigator.language' in JS. + * + * @return $this + */ + public function setLang(?string $lang): static + { + if (is_null($lang)) { + throw new InvalidArgumentException('non-nullable lang cannot be null'); + } + $this->container['lang'] = $lang; + + return $this; + } + + /** + * Gets tz + * + * @return int|null + */ + public function getTz(): ?int + { + return $this->container['tz']; + } + + /** + * Sets tz + * + * @param int|null $tz You may use 'new Date().getTimezoneOffset()' in JS. + * + * @return $this + */ + public function setTz(?int $tz): static + { + if (is_null($tz)) { + throw new InvalidArgumentException('non-nullable tz cannot be null'); + } + $this->container['tz'] = $tz; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param int $offset Offset + * + * @return bool + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param int $offset Offset + * + * @return mixed|null + */ + #[ReturnTypeWillChange] + public function offsetGet(mixed $offset): mixed + { + 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(mixed $offset, mixed $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(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(): mixed + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString(): string + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue(): string + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} diff --git a/src/Model/TokenTransaction.php b/src/Model/TokenTransaction.php new file mode 100644 index 0000000..8f14b35 --- /dev/null +++ b/src/Model/TokenTransaction.php @@ -0,0 +1,1161 @@ + + */ +class TokenTransaction implements ModelInterface, ArrayAccess, JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static string $openAPIModelName = 'TokenTransaction'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var array + */ + protected static array $openAPITypes = [ + 'customer' => 'string', + 'customerEmail' => 'string', + 'currency' => '\Cone\SimplePay\Model\Currency', + 'maySelectInvoice' => 'bool', + 'maySelectEmail' => 'bool', + 'maySelectDelivery' => 'string[]', + 'twoStep' => 'bool', + 'onlyCardReg' => 'bool', + 'url' => 'string', + 'urls' => '\Cone\SimplePay\Model\TransactionUrls', + 'language' => '\Cone\SimplePay\Model\Language', + 'discount' => 'float', + 'shippingCost' => 'float', + 'total' => 'float', + 'delivery' => '\Cone\SimplePay\Model\Delivery', + 'invoice' => '\Cone\SimplePay\Model\Invoice', + 'items' => '\Cone\SimplePay\Model\Item[]', + 'methods' => '\Cone\SimplePay\Model\Method[]', + 'timeout' => 'string', + 'threeDSReqAuthMethod' => '\Cone\SimplePay\Model\AuthMethod', + 'type' => '\Cone\SimplePay\Model\TransactionType', + 'token' => 'string', + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var array + */ + protected static array $openAPIFormats = [ + 'customer' => null, + 'customerEmail' => 'email', + 'currency' => null, + 'maySelectInvoice' => null, + 'maySelectEmail' => null, + 'maySelectDelivery' => null, + 'twoStep' => null, + 'onlyCardReg' => null, + 'url' => null, + 'urls' => null, + 'language' => null, + 'discount' => null, + 'shippingCost' => null, + 'total' => null, + 'delivery' => null, + 'invoice' => null, + 'items' => null, + 'methods' => null, + 'timeout' => null, + 'threeDSReqAuthMethod' => null, + 'type' => null, + 'token' => null, + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var array + */ + protected static array $openAPINullables = [ + 'customer' => false, + 'customerEmail' => false, + 'currency' => false, + 'maySelectInvoice' => false, + 'maySelectEmail' => false, + 'maySelectDelivery' => false, + 'twoStep' => false, + 'onlyCardReg' => false, + 'url' => false, + 'urls' => false, + 'language' => false, + 'discount' => false, + 'shippingCost' => false, + 'total' => false, + 'delivery' => false, + 'invoice' => false, + 'items' => false, + 'methods' => false, + 'timeout' => false, + 'threeDSReqAuthMethod' => false, + 'type' => false, + 'token' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var array + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes(): array + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats(): array + { + 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 array + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param array $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 array + */ + protected static array $attributeMap = [ + 'customer' => 'customer', + 'customerEmail' => 'customerEmail', + 'currency' => 'currency', + 'maySelectInvoice' => 'maySelectInvoice', + 'maySelectEmail' => 'maySelectEmail', + 'maySelectDelivery' => 'maySelectDelivery', + 'twoStep' => 'twoStep', + 'onlyCardReg' => 'onlyCardReg', + 'url' => 'url', + 'urls' => 'urls', + 'language' => 'language', + 'discount' => 'discount', + 'shippingCost' => 'shippingCost', + 'total' => 'total', + 'delivery' => 'delivery', + 'invoice' => 'invoice', + 'items' => 'items', + 'methods' => 'methods', + 'timeout' => 'timeout', + 'threeDSReqAuthMethod' => 'threeDSReqAuthMethod', + 'type' => 'type', + 'token' => 'token', + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var array + */ + protected static array $setters = [ + 'customer' => 'setCustomer', + 'customerEmail' => 'setCustomerEmail', + 'currency' => 'setCurrency', + 'maySelectInvoice' => 'setMaySelectInvoice', + 'maySelectEmail' => 'setMaySelectEmail', + 'maySelectDelivery' => 'setMaySelectDelivery', + 'twoStep' => 'setTwoStep', + 'onlyCardReg' => 'setOnlyCardReg', + 'url' => 'setUrl', + 'urls' => 'setUrls', + 'language' => 'setLanguage', + 'discount' => 'setDiscount', + 'shippingCost' => 'setShippingCost', + 'total' => 'setTotal', + 'delivery' => 'setDelivery', + 'invoice' => 'setInvoice', + 'items' => 'setItems', + 'methods' => 'setMethods', + 'timeout' => 'setTimeout', + 'threeDSReqAuthMethod' => 'setThreeDSReqAuthMethod', + 'type' => 'setType', + 'token' => 'setToken', + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var array + */ + protected static array $getters = [ + 'customer' => 'getCustomer', + 'customerEmail' => 'getCustomerEmail', + 'currency' => 'getCurrency', + 'maySelectInvoice' => 'getMaySelectInvoice', + 'maySelectEmail' => 'getMaySelectEmail', + 'maySelectDelivery' => 'getMaySelectDelivery', + 'twoStep' => 'getTwoStep', + 'onlyCardReg' => 'getOnlyCardReg', + 'url' => 'getUrl', + 'urls' => 'getUrls', + 'language' => 'getLanguage', + 'discount' => 'getDiscount', + 'shippingCost' => 'getShippingCost', + 'total' => 'getTotal', + 'delivery' => 'getDelivery', + 'invoice' => 'getInvoice', + 'items' => 'getItems', + 'methods' => 'getMethods', + 'timeout' => 'getTimeout', + 'threeDSReqAuthMethod' => 'getThreeDSReqAuthMethod', + 'type' => 'getType', + 'token' => 'getToken', + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap(): array + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters(): array + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters(): array + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName(): string + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var array + */ + protected array $container = []; + + /** + * Constructor + * + * @param array $data Associated array of property values initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('customer', $data ?? [], null); + $this->setIfExists('customerEmail', $data ?? [], null); + $this->setIfExists('currency', $data ?? [], null); + $this->setIfExists('maySelectInvoice', $data ?? [], false); + $this->setIfExists('maySelectEmail', $data ?? [], false); + $this->setIfExists('maySelectDelivery', $data ?? [], null); + $this->setIfExists('twoStep', $data ?? [], false); + $this->setIfExists('onlyCardReg', $data ?? [], false); + $this->setIfExists('url', $data ?? [], null); + $this->setIfExists('urls', $data ?? [], null); + $this->setIfExists('language', $data ?? [], null); + $this->setIfExists('discount', $data ?? [], 0); + $this->setIfExists('shippingCost', $data ?? [], 0); + $this->setIfExists('total', $data ?? [], 0); + $this->setIfExists('delivery', $data ?? [], null); + $this->setIfExists('invoice', $data ?? [], null); + $this->setIfExists('items', $data ?? [], null); + $this->setIfExists('methods', $data ?? [], null); + $this->setIfExists('timeout', $data ?? [], null); + $this->setIfExists('threeDSReqAuthMethod', $data ?? [], null); + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('token', $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, mixed $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 string[] invalid properties with reasons + */ + public function listInvalidProperties(): array + { + $invalidProperties = []; + + if ($this->container['customerEmail'] === null) { + $invalidProperties[] = "'customerEmail' can't be null"; + } + if ($this->container['currency'] === null) { + $invalidProperties[] = "'currency' can't be null"; + } + if ($this->container['language'] === null) { + $invalidProperties[] = "'language' can't be null"; + } + if (!is_null($this->container['discount']) && ($this->container['discount'] < 0)) { + $invalidProperties[] = "invalid value for 'discount', must be bigger than or equal to 0."; + } + + if (!is_null($this->container['shippingCost']) && ($this->container['shippingCost'] < 0)) { + $invalidProperties[] = "invalid value for 'shippingCost', must be bigger than or equal to 0."; + } + + if (!is_null($this->container['total']) && ($this->container['total'] <= 0)) { + $invalidProperties[] = "invalid value for 'total', must be bigger than 0."; + } + + if ($this->container['methods'] === null) { + $invalidProperties[] = "'methods' can't be null"; + } + if ($this->container['timeout'] === null) { + $invalidProperties[] = "'timeout' 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(): bool + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets customer + * + * @return string|null + */ + public function getCustomer(): ?string + { + return $this->container['customer']; + } + + /** + * Sets customer + * + * @param string|null $customer customer + * + * @return $this + */ + public function setCustomer(?string $customer): static + { + if (is_null($customer)) { + throw new InvalidArgumentException('non-nullable customer cannot be null'); + } + $this->container['customer'] = $customer; + + return $this; + } + + /** + * Gets customerEmail + * + * @return string + */ + public function getCustomerEmail(): string + { + return $this->container['customerEmail']; + } + + /** + * Sets customerEmail + * + * @param string $customerEmail customerEmail + * + * @return $this + */ + public function setCustomerEmail(string $customerEmail): static + { + if (is_null($customerEmail)) { + throw new InvalidArgumentException('non-nullable customerEmail cannot be null'); + } + $this->container['customerEmail'] = $customerEmail; + + return $this; + } + + /** + * Gets currency + * + * @return \Cone\SimplePay\Model\Currency + */ + public function getCurrency(): \Cone\SimplePay\Model\Currency + { + return $this->container['currency']; + } + + /** + * Sets currency + * + * @param \Cone\SimplePay\Model\Currency $currency currency + * + * @return $this + */ + public function setCurrency(\Cone\SimplePay\Model\Currency $currency): static + { + if (is_null($currency)) { + throw new InvalidArgumentException('non-nullable currency cannot be null'); + } + $this->container['currency'] = $currency; + + return $this; + } + + /** + * Gets maySelectInvoice + * + * @return bool|null + */ + public function getMaySelectInvoice(): ?bool + { + return $this->container['maySelectInvoice']; + } + + /** + * Sets maySelectInvoice + * + * @param bool|null $maySelectInvoice maySelectInvoice + * + * @return $this + */ + public function setMaySelectInvoice(?bool $maySelectInvoice): static + { + if (is_null($maySelectInvoice)) { + throw new InvalidArgumentException('non-nullable maySelectInvoice cannot be null'); + } + $this->container['maySelectInvoice'] = $maySelectInvoice; + + return $this; + } + + /** + * Gets maySelectEmail + * + * @return bool|null + */ + public function getMaySelectEmail(): ?bool + { + return $this->container['maySelectEmail']; + } + + /** + * Sets maySelectEmail + * + * @param bool|null $maySelectEmail maySelectEmail + * + * @return $this + */ + public function setMaySelectEmail(?bool $maySelectEmail): static + { + if (is_null($maySelectEmail)) { + throw new InvalidArgumentException('non-nullable maySelectEmail cannot be null'); + } + $this->container['maySelectEmail'] = $maySelectEmail; + + return $this; + } + + /** + * Gets maySelectDelivery + * + * @return string[]|null + */ + public function getMaySelectDelivery(): ?array + { + return $this->container['maySelectDelivery']; + } + + /** + * Sets maySelectDelivery + * + * @param string[]|null $maySelectDelivery maySelectDelivery + * + * @return $this + */ + public function setMaySelectDelivery(?array $maySelectDelivery): static + { + if (is_null($maySelectDelivery)) { + throw new InvalidArgumentException('non-nullable maySelectDelivery cannot be null'); + } + $this->container['maySelectDelivery'] = $maySelectDelivery; + + return $this; + } + + /** + * Gets twoStep + * + * @return bool|null + */ + public function getTwoStep(): ?bool + { + return $this->container['twoStep']; + } + + /** + * Sets twoStep + * + * @param bool|null $twoStep twoStep + * + * @return $this + */ + public function setTwoStep(?bool $twoStep): static + { + if (is_null($twoStep)) { + throw new InvalidArgumentException('non-nullable twoStep cannot be null'); + } + $this->container['twoStep'] = $twoStep; + + return $this; + } + + /** + * Gets onlyCardReg + * + * @return bool|null + */ + public function getOnlyCardReg(): ?bool + { + return $this->container['onlyCardReg']; + } + + /** + * Sets onlyCardReg + * + * @param bool|null $onlyCardReg onlyCardReg + * + * @return $this + */ + public function setOnlyCardReg(?bool $onlyCardReg): static + { + if (is_null($onlyCardReg)) { + throw new InvalidArgumentException('non-nullable onlyCardReg cannot be null'); + } + $this->container['onlyCardReg'] = $onlyCardReg; + + return $this; + } + + /** + * Gets url + * + * @return string|null + */ + public function getUrl(): ?string + { + return $this->container['url']; + } + + /** + * Sets url + * + * @param string|null $url url + * + * @return $this + */ + public function setUrl(?string $url): static + { + if (is_null($url)) { + throw new InvalidArgumentException('non-nullable url cannot be null'); + } + $this->container['url'] = $url; + + return $this; + } + + /** + * Gets urls + * + * @return \Cone\SimplePay\Model\TransactionUrls|null + */ + public function getUrls(): ?\Cone\SimplePay\Model\TransactionUrls + { + return $this->container['urls']; + } + + /** + * Sets urls + * + * @param \Cone\SimplePay\Model\TransactionUrls|null $urls urls + * + * @return $this + */ + public function setUrls(?\Cone\SimplePay\Model\TransactionUrls $urls): static + { + if (is_null($urls)) { + throw new InvalidArgumentException('non-nullable urls cannot be null'); + } + $this->container['urls'] = $urls; + + return $this; + } + + /** + * Gets language + * + * @return \Cone\SimplePay\Model\Language + */ + public function getLanguage(): \Cone\SimplePay\Model\Language + { + return $this->container['language']; + } + + /** + * Sets language + * + * @param \Cone\SimplePay\Model\Language $language language + * + * @return $this + */ + public function setLanguage(\Cone\SimplePay\Model\Language $language): static + { + if (is_null($language)) { + throw new InvalidArgumentException('non-nullable language cannot be null'); + } + $this->container['language'] = $language; + + return $this; + } + + /** + * Gets discount + * + * @return float|null + */ + public function getDiscount(): ?float + { + return $this->container['discount']; + } + + /** + * Sets discount + * + * @param float|null $discount discount + * + * @return $this + */ + public function setDiscount(?float $discount): static + { + if (is_null($discount)) { + throw new InvalidArgumentException('non-nullable discount cannot be null'); + } + + if (($discount < 0)) { + throw new InvalidArgumentException('invalid value for $discount when calling TokenTransaction., must be bigger than or equal to 0.'); + } + + $this->container['discount'] = $discount; + + return $this; + } + + /** + * Gets shippingCost + * + * @return float|null + */ + public function getShippingCost(): ?float + { + return $this->container['shippingCost']; + } + + /** + * Sets shippingCost + * + * @param float|null $shippingCost shippingCost + * + * @return $this + */ + public function setShippingCost(?float $shippingCost): static + { + if (is_null($shippingCost)) { + throw new InvalidArgumentException('non-nullable shippingCost cannot be null'); + } + + if (($shippingCost < 0)) { + throw new InvalidArgumentException('invalid value for $shippingCost when calling TokenTransaction., must be bigger than or equal to 0.'); + } + + $this->container['shippingCost'] = $shippingCost; + + return $this; + } + + /** + * Gets total + * + * @return float|null + */ + public function getTotal(): ?float + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param float|null $total total + * + * @return $this + */ + public function setTotal(?float $total): static + { + if (is_null($total)) { + throw new InvalidArgumentException('non-nullable total cannot be null'); + } + + if (($total <= 0)) { + throw new InvalidArgumentException('invalid value for $total when calling TokenTransaction., must be bigger than 0.'); + } + + $this->container['total'] = $total; + + return $this; + } + + /** + * Gets delivery + * + * @return \Cone\SimplePay\Model\Delivery|null + */ + public function getDelivery(): ?\Cone\SimplePay\Model\Delivery + { + return $this->container['delivery']; + } + + /** + * Sets delivery + * + * @param \Cone\SimplePay\Model\Delivery|null $delivery delivery + * + * @return $this + */ + public function setDelivery(?\Cone\SimplePay\Model\Delivery $delivery): static + { + if (is_null($delivery)) { + throw new InvalidArgumentException('non-nullable delivery cannot be null'); + } + $this->container['delivery'] = $delivery; + + return $this; + } + + /** + * Gets invoice + * + * @return \Cone\SimplePay\Model\Invoice|null + */ + public function getInvoice(): ?\Cone\SimplePay\Model\Invoice + { + return $this->container['invoice']; + } + + /** + * Sets invoice + * + * @param \Cone\SimplePay\Model\Invoice|null $invoice invoice + * + * @return $this + */ + public function setInvoice(?\Cone\SimplePay\Model\Invoice $invoice): static + { + if (is_null($invoice)) { + throw new InvalidArgumentException('non-nullable invoice cannot be null'); + } + $this->container['invoice'] = $invoice; + + return $this; + } + + /** + * Gets items + * + * @return \Cone\SimplePay\Model\Item[]|null + */ + public function getItems(): ?array + { + return $this->container['items']; + } + + /** + * Sets items + * + * @param \Cone\SimplePay\Model\Item[]|null $items items + * + * @return $this + */ + public function setItems(?array $items): static + { + if (is_null($items)) { + throw new InvalidArgumentException('non-nullable items cannot be null'); + } + $this->container['items'] = $items; + + return $this; + } + + /** + * Gets methods + * + * @return \Cone\SimplePay\Model\Method[] + */ + public function getMethods(): array + { + return $this->container['methods']; + } + + /** + * Sets methods + * + * @param \Cone\SimplePay\Model\Method[] $methods Possible values: CARD, WIRE or EAM. + * + * @return $this + */ + public function setMethods(array $methods): static + { + if (is_null($methods)) { + throw new InvalidArgumentException('non-nullable methods cannot be null'); + } + $this->container['methods'] = $methods; + + return $this; + } + + /** + * Gets timeout + * + * @return string + */ + public function getTimeout(): string + { + return $this->container['timeout']; + } + + /** + * Sets timeout + * + * @param string $timeout The ISO 8601 format of the timeout date. + * + * @return $this + */ + public function setTimeout(string $timeout): static + { + if (is_null($timeout)) { + throw new InvalidArgumentException('non-nullable timeout cannot be null'); + } + $this->container['timeout'] = $timeout; + + return $this; + } + + /** + * Gets threeDSReqAuthMethod + * + * @return \Cone\SimplePay\Model\AuthMethod|null + */ + public function getThreeDSReqAuthMethod(): ?\Cone\SimplePay\Model\AuthMethod + { + return $this->container['threeDSReqAuthMethod']; + } + + /** + * Sets threeDSReqAuthMethod + * + * @param \Cone\SimplePay\Model\AuthMethod|null $threeDSReqAuthMethod threeDSReqAuthMethod + * + * @return $this + */ + public function setThreeDSReqAuthMethod(?\Cone\SimplePay\Model\AuthMethod $threeDSReqAuthMethod): static + { + if (is_null($threeDSReqAuthMethod)) { + throw new InvalidArgumentException('non-nullable threeDSReqAuthMethod cannot be null'); + } + $this->container['threeDSReqAuthMethod'] = $threeDSReqAuthMethod; + + return $this; + } + + /** + * Gets type + * + * @return \Cone\SimplePay\Model\TransactionType|null + */ + public function getType(): ?\Cone\SimplePay\Model\TransactionType + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param \Cone\SimplePay\Model\TransactionType|null $type For token payments this should be always 'MIT'. + * + * @return $this + */ + public function setType(?\Cone\SimplePay\Model\TransactionType $type): static + { + if (is_null($type)) { + throw new InvalidArgumentException('non-nullable type cannot be null'); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets token + * + * @return string|null + */ + public function getToken(): ?string + { + return $this->container['token']; + } + + /** + * Sets token + * + * @param string|null $token token + * + * @return $this + */ + public function setToken(?string $token): static + { + if (is_null($token)) { + throw new InvalidArgumentException('non-nullable token cannot be null'); + } + $this->container['token'] = $token; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param int $offset Offset + * + * @return bool + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param int $offset Offset + * + * @return mixed|null + */ + #[ReturnTypeWillChange] + public function offsetGet(mixed $offset): mixed + { + 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(mixed $offset, mixed $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(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(): mixed + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString(): string + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue(): string + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} diff --git a/src/Model/Transaction.php b/src/Model/Transaction.php index e03a845..6fb6d6b 100644 --- a/src/Model/Transaction.php +++ b/src/Model/Transaction.php @@ -398,9 +398,15 @@ public function listInvalidProperties(): array { $invalidProperties = []; + if ($this->container['customerEmail'] === null) { + $invalidProperties[] = "'customerEmail' can't be null"; + } if ($this->container['currency'] === null) { $invalidProperties[] = "'currency' can't be null"; } + if ($this->container['language'] === null) { + $invalidProperties[] = "'language' can't be null"; + } if (!is_null($this->container['discount']) && ($this->container['discount'] < 0)) { $invalidProperties[] = "invalid value for 'discount', must be bigger than or equal to 0."; } @@ -413,6 +419,12 @@ public function listInvalidProperties(): array $invalidProperties[] = "invalid value for 'total', must be bigger than 0."; } + if ($this->container['methods'] === null) { + $invalidProperties[] = "'methods' can't be null"; + } + if ($this->container['timeout'] === null) { + $invalidProperties[] = "'timeout' can't be null"; + } return $invalidProperties; } @@ -458,9 +470,9 @@ public function setCustomer(?string $customer): static /** * Gets customerEmail * - * @return string|null + * @return string */ - public function getCustomerEmail(): ?string + public function getCustomerEmail(): string { return $this->container['customerEmail']; } @@ -468,11 +480,11 @@ public function getCustomerEmail(): ?string /** * Sets customerEmail * - * @param string|null $customerEmail customerEmail + * @param string $customerEmail customerEmail * * @return $this */ - public function setCustomerEmail(?string $customerEmail): static + public function setCustomerEmail(string $customerEmail): static { if (is_null($customerEmail)) { throw new InvalidArgumentException('non-nullable customerEmail cannot be null'); @@ -701,9 +713,9 @@ public function setUrls(?\Cone\SimplePay\Model\TransactionUrls $urls): static /** * Gets language * - * @return \Cone\SimplePay\Model\Language|null + * @return \Cone\SimplePay\Model\Language */ - public function getLanguage(): ?\Cone\SimplePay\Model\Language + public function getLanguage(): \Cone\SimplePay\Model\Language { return $this->container['language']; } @@ -711,11 +723,11 @@ public function getLanguage(): ?\Cone\SimplePay\Model\Language /** * Sets language * - * @param \Cone\SimplePay\Model\Language|null $language language + * @param \Cone\SimplePay\Model\Language $language language * * @return $this */ - public function setLanguage(?\Cone\SimplePay\Model\Language $language): static + public function setLanguage(\Cone\SimplePay\Model\Language $language): static { if (is_null($language)) { throw new InvalidArgumentException('non-nullable language cannot be null'); @@ -905,9 +917,9 @@ public function setItems(?array $items): static /** * Gets methods * - * @return \Cone\SimplePay\Model\Method[]|null + * @return \Cone\SimplePay\Model\Method[] */ - public function getMethods(): ?array + public function getMethods(): array { return $this->container['methods']; } @@ -915,11 +927,11 @@ public function getMethods(): ?array /** * Sets methods * - * @param \Cone\SimplePay\Model\Method[]|null $methods Possible values: CARD, WIRE or EAM. + * @param \Cone\SimplePay\Model\Method[] $methods Possible values: CARD, WIRE or EAM. * * @return $this */ - public function setMethods(?array $methods): static + public function setMethods(array $methods): static { if (is_null($methods)) { throw new InvalidArgumentException('non-nullable methods cannot be null'); @@ -932,9 +944,9 @@ public function setMethods(?array $methods): static /** * Gets timeout * - * @return string|null + * @return string */ - public function getTimeout(): ?string + public function getTimeout(): string { return $this->container['timeout']; } @@ -942,11 +954,11 @@ public function getTimeout(): ?string /** * Sets timeout * - * @param string|null $timeout The ISO 8601 format of the timeout date. + * @param string $timeout The ISO 8601 format of the timeout date. * * @return $this */ - public function setTimeout(?string $timeout): static + public function setTimeout(string $timeout): static { if (is_null($timeout)) { throw new InvalidArgumentException('non-nullable timeout cannot be null'); diff --git a/src/Model/TransactionCancel.php b/src/Model/TransactionCancel.php new file mode 100644 index 0000000..dc9ecac --- /dev/null +++ b/src/Model/TransactionCancel.php @@ -0,0 +1,445 @@ + + */ +class TransactionCancel implements ModelInterface, ArrayAccess, JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static string $openAPIModelName = 'TransactionCancel'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var array + */ + protected static array $openAPITypes = [ + 'transactionId' => 'float', + 'currency' => '\Cone\SimplePay\Model\Currency', + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var array + */ + protected static array $openAPIFormats = [ + 'transactionId' => null, + 'currency' => null, + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var array + */ + protected static array $openAPINullables = [ + 'transactionId' => false, + 'currency' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var array + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes(): array + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats(): array + { + 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 array + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param array $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 array + */ + protected static array $attributeMap = [ + 'transactionId' => 'transactionId', + 'currency' => 'currency', + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var array + */ + protected static array $setters = [ + 'transactionId' => 'setTransactionId', + 'currency' => 'setCurrency', + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var array + */ + protected static array $getters = [ + 'transactionId' => 'getTransactionId', + 'currency' => 'getCurrency', + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap(): array + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters(): array + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters(): array + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName(): string + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var array + */ + protected array $container = []; + + /** + * Constructor + * + * @param array $data Associated array of property values initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('transactionId', $data ?? [], null); + $this->setIfExists('currency', $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, mixed $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 string[] invalid properties with reasons + */ + public function listInvalidProperties(): array + { + $invalidProperties = []; + + if ($this->container['transactionId'] === null) { + $invalidProperties[] = "'transactionId' can't be null"; + } + if ($this->container['currency'] === null) { + $invalidProperties[] = "'currency' 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(): bool + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets transactionId + * + * @return float + */ + public function getTransactionId(): float + { + return $this->container['transactionId']; + } + + /** + * Sets transactionId + * + * @param float $transactionId transactionId + * + * @return $this + */ + public function setTransactionId(float $transactionId): static + { + if (is_null($transactionId)) { + throw new InvalidArgumentException('non-nullable transactionId cannot be null'); + } + $this->container['transactionId'] = $transactionId; + + return $this; + } + + /** + * Gets currency + * + * @return \Cone\SimplePay\Model\Currency + */ + public function getCurrency(): \Cone\SimplePay\Model\Currency + { + return $this->container['currency']; + } + + /** + * Sets currency + * + * @param \Cone\SimplePay\Model\Currency $currency currency + * + * @return $this + */ + public function setCurrency(\Cone\SimplePay\Model\Currency $currency): static + { + if (is_null($currency)) { + throw new InvalidArgumentException('non-nullable currency cannot be null'); + } + $this->container['currency'] = $currency; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param int $offset Offset + * + * @return bool + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param int $offset Offset + * + * @return mixed|null + */ + #[ReturnTypeWillChange] + public function offsetGet(mixed $offset): mixed + { + 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(mixed $offset, mixed $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(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(): mixed + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString(): string + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue(): string + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} diff --git a/src/Model/TransactionType.php b/src/Model/TransactionType.php new file mode 100644 index 0000000..3d8c401 --- /dev/null +++ b/src/Model/TransactionType.php @@ -0,0 +1,42 @@ + + */ +class Transactioncancel200Response implements ModelInterface, ArrayAccess, JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static string $openAPIModelName = 'transactioncancel_200_response'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var array + */ + protected static array $openAPITypes = [ + 'salt' => 'string', + 'merchant' => 'string', + 'orderRef' => 'string', + 'status' => '\Cone\SimplePay\Model\Status', + 'transactionId' => 'float', + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var array + */ + protected static array $openAPIFormats = [ + 'salt' => null, + 'merchant' => null, + 'orderRef' => null, + 'status' => null, + 'transactionId' => null, + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var array + */ + protected static array $openAPINullables = [ + 'salt' => false, + 'merchant' => false, + 'orderRef' => false, + 'status' => false, + 'transactionId' => false, + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var array + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes(): array + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats(): array + { + 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 array + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param array $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 array + */ + protected static array $attributeMap = [ + 'salt' => 'salt', + 'merchant' => 'merchant', + 'orderRef' => 'orderRef', + 'status' => 'status', + 'transactionId' => 'transactionId', + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var array + */ + protected static array $setters = [ + 'salt' => 'setSalt', + 'merchant' => 'setMerchant', + 'orderRef' => 'setOrderRef', + 'status' => 'setStatus', + 'transactionId' => 'setTransactionId', + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var array + */ + protected static array $getters = [ + 'salt' => 'getSalt', + 'merchant' => 'getMerchant', + 'orderRef' => 'getOrderRef', + 'status' => 'getStatus', + 'transactionId' => 'getTransactionId', + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap(): array + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters(): array + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters(): array + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName(): string + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var array + */ + protected array $container = []; + + /** + * Constructor + * + * @param array $data Associated array of property values initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('salt', $data ?? [], null); + $this->setIfExists('merchant', $data ?? [], null); + $this->setIfExists('orderRef', $data ?? [], null); + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('transactionId', $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, mixed $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 string[] invalid properties with reasons + */ + public function listInvalidProperties(): array + { + $invalidProperties = []; + + 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(): bool + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets salt + * + * @return string|null + */ + public function getSalt(): ?string + { + return $this->container['salt']; + } + + /** + * Sets salt + * + * @param string|null $salt salt + * + * @return $this + */ + public function setSalt(?string $salt): static + { + if (is_null($salt)) { + throw new InvalidArgumentException('non-nullable salt cannot be null'); + } + $this->container['salt'] = $salt; + + return $this; + } + + /** + * Gets merchant + * + * @return string|null + */ + public function getMerchant(): ?string + { + return $this->container['merchant']; + } + + /** + * Sets merchant + * + * @param string|null $merchant merchant + * + * @return $this + */ + public function setMerchant(?string $merchant): static + { + if (is_null($merchant)) { + throw new InvalidArgumentException('non-nullable merchant cannot be null'); + } + $this->container['merchant'] = $merchant; + + return $this; + } + + /** + * Gets orderRef + * + * @return string|null + */ + public function getOrderRef(): ?string + { + return $this->container['orderRef']; + } + + /** + * Sets orderRef + * + * @param string|null $orderRef orderRef + * + * @return $this + */ + public function setOrderRef(?string $orderRef): static + { + if (is_null($orderRef)) { + throw new InvalidArgumentException('non-nullable orderRef cannot be null'); + } + $this->container['orderRef'] = $orderRef; + + return $this; + } + + /** + * Gets status + * + * @return \Cone\SimplePay\Model\Status|null + */ + public function getStatus(): ?\Cone\SimplePay\Model\Status + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \Cone\SimplePay\Model\Status|null $status status + * + * @return $this + */ + public function setStatus(?\Cone\SimplePay\Model\Status $status): static + { + if (is_null($status)) { + throw new InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets transactionId + * + * @return float|null + */ + public function getTransactionId(): ?float + { + return $this->container['transactionId']; + } + + /** + * Sets transactionId + * + * @param float|null $transactionId transactionId + * + * @return $this + */ + public function setTransactionId(?float $transactionId): static + { + if (is_null($transactionId)) { + throw new InvalidArgumentException('non-nullable transactionId cannot be null'); + } + $this->container['transactionId'] = $transactionId; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param int $offset Offset + * + * @return bool + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param int $offset Offset + * + * @return mixed|null + */ + #[ReturnTypeWillChange] + public function offsetGet(mixed $offset): mixed + { + 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(mixed $offset, mixed $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(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(): mixed + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString(): string + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue(): string + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} diff --git a/tests/Api/TransactionApiTest.php b/tests/Api/TransactionApiTest.php index 2291fbf..f4969df 100644 --- a/tests/Api/TransactionApiTest.php +++ b/tests/Api/TransactionApiTest.php @@ -68,6 +68,30 @@ public static function tearDownAfterClass(): void { } + /** + * Test case for callDo + * + * Do a one-click transaction. + * + */ + public function testCallDo() + { + // TODO: implement + self::markTestIncomplete('Not implemented'); + } + + /** + * Test case for dorecurring + * + * Do a recurring transaction. + * + */ + public function testDorecurring() + { + // TODO: implement + self::markTestIncomplete('Not implemented'); + } + /** * Test case for finish * @@ -115,4 +139,16 @@ public function testStart() // TODO: implement self::markTestIncomplete('Not implemented'); } + + /** + * Test case for transactioncancel + * + * Cancel a transaction. + * + */ + public function testTransactioncancel() + { + // TODO: implement + self::markTestIncomplete('Not implemented'); + } } diff --git a/tests/Model/AuthMethodTest.php b/tests/Model/AuthMethodTest.php new file mode 100644 index 0000000..adf44bf --- /dev/null +++ b/tests/Model/AuthMethodTest.php @@ -0,0 +1,78 @@ +