diff --git a/CHANGELOG.md b/CHANGELOG.md index 093e3ce..fdd406a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,24 @@ All notable changes to the library will be documented in this file. The format of the file is based on [Keep a Changelog](http://keepachangelog.com/) and this library adheres to [Semantic Versioning](http://semver.org/) as mentioned in the [README.md][readme] file. +## [ [5.0.0](https://github.com/infobip/infobip-api-php-client/releases/tag/5.0.0) ] - 2023-03-01 + +⚠️ **IMPORTANT NOTE:** This release contains breaking changes! + +🎉 **NEW Major Version of `infobip-api-php-client`.** + +### Added +* Support for [Infobip MMS API](https://www.infobip.com/docs/api/channels/mms). +* Support for [Infobip Voice API](https://www.infobip.com/docs/api/channels/voice). +* Support for [Infobip WebRTC API](https://www.infobip.com/docs/api/channels/webrtc). +* Support for [Infobip Viber API](https://www.infobip.com/docs/api/channels/viber). +* Most recent [Infobip SMS API](https://www.infobip.com/docs/api/channels/sms) feature set. +* Most recent [Email](https://www.infobip.com/docs/api/channels/email) feature set. +* Most recent [WhatsApp](https://www.infobip.com/docs/api/channels/whatsapp) feature set. + +### Changed +- Fully refactored codebase using Symfony components + ## [ [4.0.0](https://github.com/infobip/infobip-api-php-client/releases/tag/4.0.0) ] - 2022-10-21 ⚠️ **IMPORTANT NOTE:** This release contains breaking changes! diff --git a/Infobip/Api/ApiTrait.php b/Infobip/Api/ApiTrait.php new file mode 100644 index 0000000..f8ca78f --- /dev/null +++ b/Infobip/Api/ApiTrait.php @@ -0,0 +1,93 @@ +objectSerializer + ->denormalize( + $response, + SplFileObject::class, + [SplFileObjectNormalizer::HEADERS_KEY => $responseHeaders] + ); + } + + return $this->objectSerializer->deserialize((string)$response, $type, $responseHeaders); + } + + private function addParamConstraints(array $paramConstraints, array &$validationConstraints): void + { + foreach ($paramConstraints as $key => $constraints) { + if (!empty($constraints)) { + $validationConstraints[$key] = new Assert\All($constraints); + } + } + } + + /** + * @internal + */ + private function validateParams(array $allData, array $validationConstraints): void + { + if (!empty($validationConstraints)) { + $dataToValidate = []; + + foreach (\array_keys($validationConstraints) as $constraintKey) { + $dataToValidate[$constraintKey] = $allData[$constraintKey]; + } + + $this->objectSerializer->validate($dataToValidate, $validationConstraints); + } + } +} diff --git a/Infobip/Api/CallsApi.php b/Infobip/Api/CallsApi.php new file mode 100644 index 0000000..b880687 --- /dev/null +++ b/Infobip/Api/CallsApi.php @@ -0,0 +1,22457 @@ +config = $config; + $this->client = $client ?: new Client(); + $this->objectSerializer = $objectSerializer ?: new ObjectSerializer(); + $this->logger = $logger ?: new NullLogger(); + $this->deprecationChecker = $deprecationChecker ?: new DeprecationChecker($this->logger); + } + + /** + * Operation addExistingConferenceCall + * + * Add existing call + * + * @param string $conferenceId Conference ID. (required) + * @param string $callId Call ID. (required) + * @param \Infobip\Model\CallsAddExistingCallRequest $callsAddExistingCallRequest callsAddExistingCallRequest (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsConference|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function addExistingConferenceCall(string $conferenceId, string $callId, \Infobip\Model\CallsAddExistingCallRequest $callsAddExistingCallRequest) + { + $request = $this->addExistingConferenceCallRequest($conferenceId, $callId, $callsAddExistingCallRequest); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->addExistingConferenceCallResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->addExistingConferenceCallApiException($exception); + } + } + + /** + * Operation addExistingConferenceCallAsync + * + * Add existing call + * + * @param string $conferenceId Conference ID. (required) + * @param string $callId Call ID. (required) + * @param \Infobip\Model\CallsAddExistingCallRequest $callsAddExistingCallRequest (required) + * + * @throws InvalidArgumentException + */ + public function addExistingConferenceCallAsync(string $conferenceId, string $callId, \Infobip\Model\CallsAddExistingCallRequest $callsAddExistingCallRequest): PromiseInterface + { + $request = $this->addExistingConferenceCallRequest($conferenceId, $callId, $callsAddExistingCallRequest); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->addExistingConferenceCallResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->addExistingConferenceCallApiException($exception); + } + ); + } + + /** + * Create request for operation 'addExistingConferenceCall' + * + * @param string $conferenceId Conference ID. (required) + * @param string $callId Call ID. (required) + * @param \Infobip\Model\CallsAddExistingCallRequest $callsAddExistingCallRequest (required) + * + * @throws InvalidArgumentException + */ + private function addExistingConferenceCallRequest(string $conferenceId, string $callId, \Infobip\Model\CallsAddExistingCallRequest $callsAddExistingCallRequest): Request + { + $allData = [ + 'conferenceId' => $conferenceId, + 'callId' => $callId, + 'callsAddExistingCallRequest' => $callsAddExistingCallRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'conferenceId' => [ + new Assert\NotBlank(), + ], + 'callId' => [ + new Assert\NotBlank(), + ], + 'callsAddExistingCallRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/conferences/{conferenceId}/call/{callId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($conferenceId !== null) { + $resourcePath = str_replace( + '{' . 'conferenceId' . '}', + $this->objectSerializer->toPathValue($conferenceId), + $resourcePath + ); + } + + // path params + if ($callId !== null) { + $resourcePath = str_replace( + '{' . 'callId' . '}', + $this->objectSerializer->toPathValue($callId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($callsAddExistingCallRequest)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($callsAddExistingCallRequest) + : $callsAddExistingCallRequest; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'PUT', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'addExistingConferenceCall' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsConference|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function addExistingConferenceCallResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsConference', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'addExistingConferenceCall' + */ + private function addExistingConferenceCallApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation addNewConferenceCall + * + * Add new call + * + * @param string $conferenceId Conference ID. (required) + * @param \Infobip\Model\CallsAddNewCallRequest $callsAddNewCallRequest callsAddNewCallRequest (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsConferenceAndCall|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function addNewConferenceCall(string $conferenceId, \Infobip\Model\CallsAddNewCallRequest $callsAddNewCallRequest) + { + $request = $this->addNewConferenceCallRequest($conferenceId, $callsAddNewCallRequest); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->addNewConferenceCallResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->addNewConferenceCallApiException($exception); + } + } + + /** + * Operation addNewConferenceCallAsync + * + * Add new call + * + * @param string $conferenceId Conference ID. (required) + * @param \Infobip\Model\CallsAddNewCallRequest $callsAddNewCallRequest (required) + * + * @throws InvalidArgumentException + */ + public function addNewConferenceCallAsync(string $conferenceId, \Infobip\Model\CallsAddNewCallRequest $callsAddNewCallRequest): PromiseInterface + { + $request = $this->addNewConferenceCallRequest($conferenceId, $callsAddNewCallRequest); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->addNewConferenceCallResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->addNewConferenceCallApiException($exception); + } + ); + } + + /** + * Create request for operation 'addNewConferenceCall' + * + * @param string $conferenceId Conference ID. (required) + * @param \Infobip\Model\CallsAddNewCallRequest $callsAddNewCallRequest (required) + * + * @throws InvalidArgumentException + */ + private function addNewConferenceCallRequest(string $conferenceId, \Infobip\Model\CallsAddNewCallRequest $callsAddNewCallRequest): Request + { + $allData = [ + 'conferenceId' => $conferenceId, + 'callsAddNewCallRequest' => $callsAddNewCallRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'conferenceId' => [ + new Assert\NotBlank(), + ], + 'callsAddNewCallRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/conferences/{conferenceId}/call'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($conferenceId !== null) { + $resourcePath = str_replace( + '{' . 'conferenceId' . '}', + $this->objectSerializer->toPathValue($conferenceId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($callsAddNewCallRequest)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($callsAddNewCallRequest) + : $callsAddNewCallRequest; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'addNewConferenceCall' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsConferenceAndCall|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function addNewConferenceCallResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsConferenceAndCall', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'addNewConferenceCall' + */ + private function addNewConferenceCallApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation answerCall + * + * Answer + * + * @param string $callId Call ID. (required) + * @param \Infobip\Model\CallsAnswerRequest $callsAnswerRequest callsAnswerRequest (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function answerCall(string $callId, \Infobip\Model\CallsAnswerRequest $callsAnswerRequest) + { + $request = $this->answerCallRequest($callId, $callsAnswerRequest); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->answerCallResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->answerCallApiException($exception); + } + } + + /** + * Operation answerCallAsync + * + * Answer + * + * @param string $callId Call ID. (required) + * @param \Infobip\Model\CallsAnswerRequest $callsAnswerRequest (required) + * + * @throws InvalidArgumentException + */ + public function answerCallAsync(string $callId, \Infobip\Model\CallsAnswerRequest $callsAnswerRequest): PromiseInterface + { + $request = $this->answerCallRequest($callId, $callsAnswerRequest); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->answerCallResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->answerCallApiException($exception); + } + ); + } + + /** + * Create request for operation 'answerCall' + * + * @param string $callId Call ID. (required) + * @param \Infobip\Model\CallsAnswerRequest $callsAnswerRequest (required) + * + * @throws InvalidArgumentException + */ + private function answerCallRequest(string $callId, \Infobip\Model\CallsAnswerRequest $callsAnswerRequest): Request + { + $allData = [ + 'callId' => $callId, + 'callsAnswerRequest' => $callsAnswerRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'callId' => [ + new Assert\NotBlank(), + ], + 'callsAnswerRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/calls/{callId}/answer'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($callId !== null) { + $resourcePath = str_replace( + '{' . 'callId' . '}', + $this->objectSerializer->toPathValue($callId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($callsAnswerRequest)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($callsAnswerRequest) + : $callsAnswerRequest; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'answerCall' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function answerCallResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsActionResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'answerCall' + */ + private function answerCallApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation applicationTransfer + * + * Request application transfer + * + * @param string $callId Call ID. (required) + * @param \Infobip\Model\CallsApplicationTransferRequest $callsApplicationTransferRequest callsApplicationTransferRequest (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function applicationTransfer(string $callId, \Infobip\Model\CallsApplicationTransferRequest $callsApplicationTransferRequest) + { + $request = $this->applicationTransferRequest($callId, $callsApplicationTransferRequest); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->applicationTransferResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->applicationTransferApiException($exception); + } + } + + /** + * Operation applicationTransferAsync + * + * Request application transfer + * + * @param string $callId Call ID. (required) + * @param \Infobip\Model\CallsApplicationTransferRequest $callsApplicationTransferRequest (required) + * + * @throws InvalidArgumentException + */ + public function applicationTransferAsync(string $callId, \Infobip\Model\CallsApplicationTransferRequest $callsApplicationTransferRequest): PromiseInterface + { + $request = $this->applicationTransferRequest($callId, $callsApplicationTransferRequest); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->applicationTransferResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->applicationTransferApiException($exception); + } + ); + } + + /** + * Create request for operation 'applicationTransfer' + * + * @param string $callId Call ID. (required) + * @param \Infobip\Model\CallsApplicationTransferRequest $callsApplicationTransferRequest (required) + * + * @throws InvalidArgumentException + */ + private function applicationTransferRequest(string $callId, \Infobip\Model\CallsApplicationTransferRequest $callsApplicationTransferRequest): Request + { + $allData = [ + 'callId' => $callId, + 'callsApplicationTransferRequest' => $callsApplicationTransferRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'callId' => [ + new Assert\NotBlank(), + ], + 'callsApplicationTransferRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/calls/{callId}/application-transfer'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($callId !== null) { + $resourcePath = str_replace( + '{' . 'callId' . '}', + $this->objectSerializer->toPathValue($callId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($callsApplicationTransferRequest)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($callsApplicationTransferRequest) + : $callsApplicationTransferRequest; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'applicationTransfer' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function applicationTransferResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsActionResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'applicationTransfer' + */ + private function applicationTransferApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation applicationTransferAccept + * + * Accept application transfer + * + * @param string $callId Call ID. (required) + * @param string $transferId The unique identifier of a transfer, sent to the receiving application in an `ApplicationTransferRequestedEvent`. (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function applicationTransferAccept(string $callId, string $transferId) + { + $request = $this->applicationTransferAcceptRequest($callId, $transferId); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->applicationTransferAcceptResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->applicationTransferAcceptApiException($exception); + } + } + + /** + * Operation applicationTransferAcceptAsync + * + * Accept application transfer + * + * @param string $callId Call ID. (required) + * @param string $transferId The unique identifier of a transfer, sent to the receiving application in an `ApplicationTransferRequestedEvent`. (required) + * + * @throws InvalidArgumentException + */ + public function applicationTransferAcceptAsync(string $callId, string $transferId): PromiseInterface + { + $request = $this->applicationTransferAcceptRequest($callId, $transferId); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->applicationTransferAcceptResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->applicationTransferAcceptApiException($exception); + } + ); + } + + /** + * Create request for operation 'applicationTransferAccept' + * + * @param string $callId Call ID. (required) + * @param string $transferId The unique identifier of a transfer, sent to the receiving application in an `ApplicationTransferRequestedEvent`. (required) + * + * @throws InvalidArgumentException + */ + private function applicationTransferAcceptRequest(string $callId, string $transferId): Request + { + $allData = [ + 'callId' => $callId, + 'transferId' => $transferId, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'callId' => [ + new Assert\NotBlank(), + ], + 'transferId' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/calls/{callId}/application-transfer/{transferId}/accept'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($callId !== null) { + $resourcePath = str_replace( + '{' . 'callId' . '}', + $this->objectSerializer->toPathValue($callId), + $resourcePath + ); + } + + // path params + if ($transferId !== null) { + $resourcePath = str_replace( + '{' . 'transferId' . '}', + $this->objectSerializer->toPathValue($transferId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'applicationTransferAccept' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function applicationTransferAcceptResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsActionResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'applicationTransferAccept' + */ + private function applicationTransferAcceptApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation applicationTransferReject + * + * Reject application transfer + * + * @param string $callId Call ID. (required) + * @param string $transferId The unique identifier of a transfer, sent to the receiving application in an `ApplicationTransferRequestedEvent`. (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function applicationTransferReject(string $callId, string $transferId) + { + $request = $this->applicationTransferRejectRequest($callId, $transferId); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->applicationTransferRejectResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->applicationTransferRejectApiException($exception); + } + } + + /** + * Operation applicationTransferRejectAsync + * + * Reject application transfer + * + * @param string $callId Call ID. (required) + * @param string $transferId The unique identifier of a transfer, sent to the receiving application in an `ApplicationTransferRequestedEvent`. (required) + * + * @throws InvalidArgumentException + */ + public function applicationTransferRejectAsync(string $callId, string $transferId): PromiseInterface + { + $request = $this->applicationTransferRejectRequest($callId, $transferId); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->applicationTransferRejectResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->applicationTransferRejectApiException($exception); + } + ); + } + + /** + * Create request for operation 'applicationTransferReject' + * + * @param string $callId Call ID. (required) + * @param string $transferId The unique identifier of a transfer, sent to the receiving application in an `ApplicationTransferRequestedEvent`. (required) + * + * @throws InvalidArgumentException + */ + private function applicationTransferRejectRequest(string $callId, string $transferId): Request + { + $allData = [ + 'callId' => $callId, + 'transferId' => $transferId, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'callId' => [ + new Assert\NotBlank(), + ], + 'transferId' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/calls/{callId}/application-transfer/{transferId}/reject'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($callId !== null) { + $resourcePath = str_replace( + '{' . 'callId' . '}', + $this->objectSerializer->toPathValue($callId), + $resourcePath + ); + } + + // path params + if ($transferId !== null) { + $resourcePath = str_replace( + '{' . 'transferId' . '}', + $this->objectSerializer->toPathValue($transferId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'applicationTransferReject' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function applicationTransferRejectResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsActionResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'applicationTransferReject' + */ + private function applicationTransferRejectApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation callCaptureDtmf + * + * Capture DTMF + * + * @param string $callId Call ID. (required) + * @param \Infobip\Model\CallsDtmfCaptureRequest $callsDtmfCaptureRequest callsDtmfCaptureRequest (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function callCaptureDtmf(string $callId, \Infobip\Model\CallsDtmfCaptureRequest $callsDtmfCaptureRequest) + { + $request = $this->callCaptureDtmfRequest($callId, $callsDtmfCaptureRequest); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->callCaptureDtmfResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->callCaptureDtmfApiException($exception); + } + } + + /** + * Operation callCaptureDtmfAsync + * + * Capture DTMF + * + * @param string $callId Call ID. (required) + * @param \Infobip\Model\CallsDtmfCaptureRequest $callsDtmfCaptureRequest (required) + * + * @throws InvalidArgumentException + */ + public function callCaptureDtmfAsync(string $callId, \Infobip\Model\CallsDtmfCaptureRequest $callsDtmfCaptureRequest): PromiseInterface + { + $request = $this->callCaptureDtmfRequest($callId, $callsDtmfCaptureRequest); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->callCaptureDtmfResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->callCaptureDtmfApiException($exception); + } + ); + } + + /** + * Create request for operation 'callCaptureDtmf' + * + * @param string $callId Call ID. (required) + * @param \Infobip\Model\CallsDtmfCaptureRequest $callsDtmfCaptureRequest (required) + * + * @throws InvalidArgumentException + */ + private function callCaptureDtmfRequest(string $callId, \Infobip\Model\CallsDtmfCaptureRequest $callsDtmfCaptureRequest): Request + { + $allData = [ + 'callId' => $callId, + 'callsDtmfCaptureRequest' => $callsDtmfCaptureRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'callId' => [ + new Assert\NotBlank(), + ], + 'callsDtmfCaptureRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/calls/{callId}/capture/dtmf'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($callId !== null) { + $resourcePath = str_replace( + '{' . 'callId' . '}', + $this->objectSerializer->toPathValue($callId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($callsDtmfCaptureRequest)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($callsDtmfCaptureRequest) + : $callsDtmfCaptureRequest; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'callCaptureDtmf' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function callCaptureDtmfResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsActionResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'callCaptureDtmf' + */ + private function callCaptureDtmfApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation callPlayFile + * + * Play file + * + * @param string $callId Call ID. (required) + * @param \Infobip\Model\CallsPlayRequest $callsPlayRequest callsPlayRequest (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function callPlayFile(string $callId, \Infobip\Model\CallsPlayRequest $callsPlayRequest) + { + $request = $this->callPlayFileRequest($callId, $callsPlayRequest); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->callPlayFileResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->callPlayFileApiException($exception); + } + } + + /** + * Operation callPlayFileAsync + * + * Play file + * + * @param string $callId Call ID. (required) + * @param \Infobip\Model\CallsPlayRequest $callsPlayRequest (required) + * + * @throws InvalidArgumentException + */ + public function callPlayFileAsync(string $callId, \Infobip\Model\CallsPlayRequest $callsPlayRequest): PromiseInterface + { + $request = $this->callPlayFileRequest($callId, $callsPlayRequest); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->callPlayFileResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->callPlayFileApiException($exception); + } + ); + } + + /** + * Create request for operation 'callPlayFile' + * + * @param string $callId Call ID. (required) + * @param \Infobip\Model\CallsPlayRequest $callsPlayRequest (required) + * + * @throws InvalidArgumentException + */ + private function callPlayFileRequest(string $callId, \Infobip\Model\CallsPlayRequest $callsPlayRequest): Request + { + $allData = [ + 'callId' => $callId, + 'callsPlayRequest' => $callsPlayRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'callId' => [ + new Assert\NotBlank(), + ], + 'callsPlayRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/calls/{callId}/play'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($callId !== null) { + $resourcePath = str_replace( + '{' . 'callId' . '}', + $this->objectSerializer->toPathValue($callId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($callsPlayRequest)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($callsPlayRequest) + : $callsPlayRequest; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'callPlayFile' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function callPlayFileResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsActionResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'callPlayFile' + */ + private function callPlayFileApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation callSayText + * + * Say text + * + * @param string $callId Call ID. (required) + * @param \Infobip\Model\CallsSayRequest $callsSayRequest callsSayRequest (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function callSayText(string $callId, \Infobip\Model\CallsSayRequest $callsSayRequest) + { + $request = $this->callSayTextRequest($callId, $callsSayRequest); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->callSayTextResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->callSayTextApiException($exception); + } + } + + /** + * Operation callSayTextAsync + * + * Say text + * + * @param string $callId Call ID. (required) + * @param \Infobip\Model\CallsSayRequest $callsSayRequest (required) + * + * @throws InvalidArgumentException + */ + public function callSayTextAsync(string $callId, \Infobip\Model\CallsSayRequest $callsSayRequest): PromiseInterface + { + $request = $this->callSayTextRequest($callId, $callsSayRequest); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->callSayTextResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->callSayTextApiException($exception); + } + ); + } + + /** + * Create request for operation 'callSayText' + * + * @param string $callId Call ID. (required) + * @param \Infobip\Model\CallsSayRequest $callsSayRequest (required) + * + * @throws InvalidArgumentException + */ + private function callSayTextRequest(string $callId, \Infobip\Model\CallsSayRequest $callsSayRequest): Request + { + $allData = [ + 'callId' => $callId, + 'callsSayRequest' => $callsSayRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'callId' => [ + new Assert\NotBlank(), + ], + 'callsSayRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/calls/{callId}/say'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($callId !== null) { + $resourcePath = str_replace( + '{' . 'callId' . '}', + $this->objectSerializer->toPathValue($callId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($callsSayRequest)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($callsSayRequest) + : $callsSayRequest; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'callSayText' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function callSayTextResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsActionResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'callSayText' + */ + private function callSayTextApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation callSendDtmf + * + * Send DTMF + * + * @param string $callId Call ID. (required) + * @param \Infobip\Model\CallsDtmfSendRequest $callsDtmfSendRequest callsDtmfSendRequest (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function callSendDtmf(string $callId, \Infobip\Model\CallsDtmfSendRequest $callsDtmfSendRequest) + { + $request = $this->callSendDtmfRequest($callId, $callsDtmfSendRequest); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->callSendDtmfResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->callSendDtmfApiException($exception); + } + } + + /** + * Operation callSendDtmfAsync + * + * Send DTMF + * + * @param string $callId Call ID. (required) + * @param \Infobip\Model\CallsDtmfSendRequest $callsDtmfSendRequest (required) + * + * @throws InvalidArgumentException + */ + public function callSendDtmfAsync(string $callId, \Infobip\Model\CallsDtmfSendRequest $callsDtmfSendRequest): PromiseInterface + { + $request = $this->callSendDtmfRequest($callId, $callsDtmfSendRequest); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->callSendDtmfResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->callSendDtmfApiException($exception); + } + ); + } + + /** + * Create request for operation 'callSendDtmf' + * + * @param string $callId Call ID. (required) + * @param \Infobip\Model\CallsDtmfSendRequest $callsDtmfSendRequest (required) + * + * @throws InvalidArgumentException + */ + private function callSendDtmfRequest(string $callId, \Infobip\Model\CallsDtmfSendRequest $callsDtmfSendRequest): Request + { + $allData = [ + 'callId' => $callId, + 'callsDtmfSendRequest' => $callsDtmfSendRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'callId' => [ + new Assert\NotBlank(), + ], + 'callsDtmfSendRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/calls/{callId}/send-dtmf'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($callId !== null) { + $resourcePath = str_replace( + '{' . 'callId' . '}', + $this->objectSerializer->toPathValue($callId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($callsDtmfSendRequest)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($callsDtmfSendRequest) + : $callsDtmfSendRequest; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'callSendDtmf' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function callSendDtmfResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsActionResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'callSendDtmf' + */ + private function callSendDtmfApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation callStartRecording + * + * Start recording + * + * @param string $callId Call ID. (required) + * @param \Infobip\Model\CallsRecordingStartRequest $callsRecordingStartRequest callsRecordingStartRequest (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function callStartRecording(string $callId, \Infobip\Model\CallsRecordingStartRequest $callsRecordingStartRequest) + { + $request = $this->callStartRecordingRequest($callId, $callsRecordingStartRequest); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->callStartRecordingResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->callStartRecordingApiException($exception); + } + } + + /** + * Operation callStartRecordingAsync + * + * Start recording + * + * @param string $callId Call ID. (required) + * @param \Infobip\Model\CallsRecordingStartRequest $callsRecordingStartRequest (required) + * + * @throws InvalidArgumentException + */ + public function callStartRecordingAsync(string $callId, \Infobip\Model\CallsRecordingStartRequest $callsRecordingStartRequest): PromiseInterface + { + $request = $this->callStartRecordingRequest($callId, $callsRecordingStartRequest); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->callStartRecordingResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->callStartRecordingApiException($exception); + } + ); + } + + /** + * Create request for operation 'callStartRecording' + * + * @param string $callId Call ID. (required) + * @param \Infobip\Model\CallsRecordingStartRequest $callsRecordingStartRequest (required) + * + * @throws InvalidArgumentException + */ + private function callStartRecordingRequest(string $callId, \Infobip\Model\CallsRecordingStartRequest $callsRecordingStartRequest): Request + { + $allData = [ + 'callId' => $callId, + 'callsRecordingStartRequest' => $callsRecordingStartRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'callId' => [ + new Assert\NotBlank(), + ], + 'callsRecordingStartRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/calls/{callId}/start-recording'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($callId !== null) { + $resourcePath = str_replace( + '{' . 'callId' . '}', + $this->objectSerializer->toPathValue($callId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($callsRecordingStartRequest)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($callsRecordingStartRequest) + : $callsRecordingStartRequest; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'callStartRecording' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function callStartRecordingResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsActionResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'callStartRecording' + */ + private function callStartRecordingApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation callStopPlayingFile + * + * Stop playing file + * + * @param string $callId Call ID. (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function callStopPlayingFile(string $callId) + { + $request = $this->callStopPlayingFileRequest($callId); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->callStopPlayingFileResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->callStopPlayingFileApiException($exception); + } + } + + /** + * Operation callStopPlayingFileAsync + * + * Stop playing file + * + * @param string $callId Call ID. (required) + * + * @throws InvalidArgumentException + */ + public function callStopPlayingFileAsync(string $callId): PromiseInterface + { + $request = $this->callStopPlayingFileRequest($callId); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->callStopPlayingFileResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->callStopPlayingFileApiException($exception); + } + ); + } + + /** + * Create request for operation 'callStopPlayingFile' + * + * @param string $callId Call ID. (required) + * + * @throws InvalidArgumentException + */ + private function callStopPlayingFileRequest(string $callId): Request + { + $allData = [ + 'callId' => $callId, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'callId' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/calls/{callId}/stop-play'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($callId !== null) { + $resourcePath = str_replace( + '{' . 'callId' . '}', + $this->objectSerializer->toPathValue($callId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'callStopPlayingFile' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function callStopPlayingFileResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsActionResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'callStopPlayingFile' + */ + private function callStopPlayingFileApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation callStopRecording + * + * Stop recording + * + * @param string $callId Call ID. (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function callStopRecording(string $callId) + { + $request = $this->callStopRecordingRequest($callId); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->callStopRecordingResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->callStopRecordingApiException($exception); + } + } + + /** + * Operation callStopRecordingAsync + * + * Stop recording + * + * @param string $callId Call ID. (required) + * + * @throws InvalidArgumentException + */ + public function callStopRecordingAsync(string $callId): PromiseInterface + { + $request = $this->callStopRecordingRequest($callId); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->callStopRecordingResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->callStopRecordingApiException($exception); + } + ); + } + + /** + * Create request for operation 'callStopRecording' + * + * @param string $callId Call ID. (required) + * + * @throws InvalidArgumentException + */ + private function callStopRecordingRequest(string $callId): Request + { + $allData = [ + 'callId' => $callId, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'callId' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/calls/{callId}/stop-recording'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($callId !== null) { + $resourcePath = str_replace( + '{' . 'callId' . '}', + $this->objectSerializer->toPathValue($callId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'callStopRecording' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function callStopRecordingResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsActionResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'callStopRecording' + */ + private function callStopRecordingApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation cancelBulk + * + * Cancel + * + * @param string $bulkId Bulk ID. (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallBulkStatus|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function cancelBulk(string $bulkId) + { + $request = $this->cancelBulkRequest($bulkId); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->cancelBulkResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->cancelBulkApiException($exception); + } + } + + /** + * Operation cancelBulkAsync + * + * Cancel + * + * @param string $bulkId Bulk ID. (required) + * + * @throws InvalidArgumentException + */ + public function cancelBulkAsync(string $bulkId): PromiseInterface + { + $request = $this->cancelBulkRequest($bulkId); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->cancelBulkResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->cancelBulkApiException($exception); + } + ); + } + + /** + * Create request for operation 'cancelBulk' + * + * @param string $bulkId Bulk ID. (required) + * + * @throws InvalidArgumentException + */ + private function cancelBulkRequest(string $bulkId): Request + { + $allData = [ + 'bulkId' => $bulkId, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'bulkId' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/bulks/{bulkId}/cancel'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($bulkId !== null) { + $resourcePath = str_replace( + '{' . 'bulkId' . '}', + $this->objectSerializer->toPathValue($bulkId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'cancelBulk' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallBulkStatus|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function cancelBulkResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallBulkStatus', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'cancelBulk' + */ + private function cancelBulkApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation composeConferenceRecording + * + * Compose conference recording on calls + * + * @param string $conferenceId Conference ID. (required) + * @param \Infobip\Model\CallsOnDemandComposition $callsOnDemandComposition callsOnDemandComposition (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function composeConferenceRecording(string $conferenceId, \Infobip\Model\CallsOnDemandComposition $callsOnDemandComposition) + { + $request = $this->composeConferenceRecordingRequest($conferenceId, $callsOnDemandComposition); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->composeConferenceRecordingResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->composeConferenceRecordingApiException($exception); + } + } + + /** + * Operation composeConferenceRecordingAsync + * + * Compose conference recording on calls + * + * @param string $conferenceId Conference ID. (required) + * @param \Infobip\Model\CallsOnDemandComposition $callsOnDemandComposition (required) + * + * @throws InvalidArgumentException + */ + public function composeConferenceRecordingAsync(string $conferenceId, \Infobip\Model\CallsOnDemandComposition $callsOnDemandComposition): PromiseInterface + { + $request = $this->composeConferenceRecordingRequest($conferenceId, $callsOnDemandComposition); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->composeConferenceRecordingResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->composeConferenceRecordingApiException($exception); + } + ); + } + + /** + * Create request for operation 'composeConferenceRecording' + * + * @param string $conferenceId Conference ID. (required) + * @param \Infobip\Model\CallsOnDemandComposition $callsOnDemandComposition (required) + * + * @throws InvalidArgumentException + */ + private function composeConferenceRecordingRequest(string $conferenceId, \Infobip\Model\CallsOnDemandComposition $callsOnDemandComposition): Request + { + $allData = [ + 'conferenceId' => $conferenceId, + 'callsOnDemandComposition' => $callsOnDemandComposition, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'conferenceId' => [ + new Assert\NotBlank(), + ], + 'callsOnDemandComposition' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/recordings/conferences/{conferenceId}/compose'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($conferenceId !== null) { + $resourcePath = str_replace( + '{' . 'conferenceId' . '}', + $this->objectSerializer->toPathValue($conferenceId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($callsOnDemandComposition)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($callsOnDemandComposition) + : $callsOnDemandComposition; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'composeConferenceRecording' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function composeConferenceRecordingResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsActionResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'composeConferenceRecording' + */ + private function composeConferenceRecordingApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation composeDialogRecording + * + * Compose dialog recording on calls + * + * @param string $dialogId Dialog ID. (required) + * @param \Infobip\Model\CallsOnDemandComposition $callsOnDemandComposition callsOnDemandComposition (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function composeDialogRecording(string $dialogId, \Infobip\Model\CallsOnDemandComposition $callsOnDemandComposition) + { + $request = $this->composeDialogRecordingRequest($dialogId, $callsOnDemandComposition); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->composeDialogRecordingResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->composeDialogRecordingApiException($exception); + } + } + + /** + * Operation composeDialogRecordingAsync + * + * Compose dialog recording on calls + * + * @param string $dialogId Dialog ID. (required) + * @param \Infobip\Model\CallsOnDemandComposition $callsOnDemandComposition (required) + * + * @throws InvalidArgumentException + */ + public function composeDialogRecordingAsync(string $dialogId, \Infobip\Model\CallsOnDemandComposition $callsOnDemandComposition): PromiseInterface + { + $request = $this->composeDialogRecordingRequest($dialogId, $callsOnDemandComposition); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->composeDialogRecordingResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->composeDialogRecordingApiException($exception); + } + ); + } + + /** + * Create request for operation 'composeDialogRecording' + * + * @param string $dialogId Dialog ID. (required) + * @param \Infobip\Model\CallsOnDemandComposition $callsOnDemandComposition (required) + * + * @throws InvalidArgumentException + */ + private function composeDialogRecordingRequest(string $dialogId, \Infobip\Model\CallsOnDemandComposition $callsOnDemandComposition): Request + { + $allData = [ + 'dialogId' => $dialogId, + 'callsOnDemandComposition' => $callsOnDemandComposition, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'dialogId' => [ + new Assert\NotBlank(), + ], + 'callsOnDemandComposition' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/recordings/dialogs/{dialogId}/compose'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($dialogId !== null) { + $resourcePath = str_replace( + '{' . 'dialogId' . '}', + $this->objectSerializer->toPathValue($dialogId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($callsOnDemandComposition)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($callsOnDemandComposition) + : $callsOnDemandComposition; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'composeDialogRecording' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function composeDialogRecordingResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsActionResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'composeDialogRecording' + */ + private function composeDialogRecordingApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation conferencePlayFile + * + * Play file + * + * @param string $conferenceId Conference ID. (required) + * @param \Infobip\Model\CallsPlayRequest $callsPlayRequest callsPlayRequest (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function conferencePlayFile(string $conferenceId, \Infobip\Model\CallsPlayRequest $callsPlayRequest) + { + $request = $this->conferencePlayFileRequest($conferenceId, $callsPlayRequest); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->conferencePlayFileResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->conferencePlayFileApiException($exception); + } + } + + /** + * Operation conferencePlayFileAsync + * + * Play file + * + * @param string $conferenceId Conference ID. (required) + * @param \Infobip\Model\CallsPlayRequest $callsPlayRequest (required) + * + * @throws InvalidArgumentException + */ + public function conferencePlayFileAsync(string $conferenceId, \Infobip\Model\CallsPlayRequest $callsPlayRequest): PromiseInterface + { + $request = $this->conferencePlayFileRequest($conferenceId, $callsPlayRequest); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->conferencePlayFileResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->conferencePlayFileApiException($exception); + } + ); + } + + /** + * Create request for operation 'conferencePlayFile' + * + * @param string $conferenceId Conference ID. (required) + * @param \Infobip\Model\CallsPlayRequest $callsPlayRequest (required) + * + * @throws InvalidArgumentException + */ + private function conferencePlayFileRequest(string $conferenceId, \Infobip\Model\CallsPlayRequest $callsPlayRequest): Request + { + $allData = [ + 'conferenceId' => $conferenceId, + 'callsPlayRequest' => $callsPlayRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'conferenceId' => [ + new Assert\NotBlank(), + ], + 'callsPlayRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/conferences/{conferenceId}/play'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($conferenceId !== null) { + $resourcePath = str_replace( + '{' . 'conferenceId' . '}', + $this->objectSerializer->toPathValue($conferenceId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($callsPlayRequest)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($callsPlayRequest) + : $callsPlayRequest; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'conferencePlayFile' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function conferencePlayFileResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsActionResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'conferencePlayFile' + */ + private function conferencePlayFileApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation conferenceSayText + * + * Say text + * + * @param string $conferenceId Conference ID. (required) + * @param \Infobip\Model\CallsSayRequest $callsSayRequest callsSayRequest (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function conferenceSayText(string $conferenceId, \Infobip\Model\CallsSayRequest $callsSayRequest) + { + $request = $this->conferenceSayTextRequest($conferenceId, $callsSayRequest); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->conferenceSayTextResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->conferenceSayTextApiException($exception); + } + } + + /** + * Operation conferenceSayTextAsync + * + * Say text + * + * @param string $conferenceId Conference ID. (required) + * @param \Infobip\Model\CallsSayRequest $callsSayRequest (required) + * + * @throws InvalidArgumentException + */ + public function conferenceSayTextAsync(string $conferenceId, \Infobip\Model\CallsSayRequest $callsSayRequest): PromiseInterface + { + $request = $this->conferenceSayTextRequest($conferenceId, $callsSayRequest); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->conferenceSayTextResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->conferenceSayTextApiException($exception); + } + ); + } + + /** + * Create request for operation 'conferenceSayText' + * + * @param string $conferenceId Conference ID. (required) + * @param \Infobip\Model\CallsSayRequest $callsSayRequest (required) + * + * @throws InvalidArgumentException + */ + private function conferenceSayTextRequest(string $conferenceId, \Infobip\Model\CallsSayRequest $callsSayRequest): Request + { + $allData = [ + 'conferenceId' => $conferenceId, + 'callsSayRequest' => $callsSayRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'conferenceId' => [ + new Assert\NotBlank(), + ], + 'callsSayRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/conferences/{conferenceId}/say'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($conferenceId !== null) { + $resourcePath = str_replace( + '{' . 'conferenceId' . '}', + $this->objectSerializer->toPathValue($conferenceId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($callsSayRequest)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($callsSayRequest) + : $callsSayRequest; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'conferenceSayText' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function conferenceSayTextResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsActionResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'conferenceSayText' + */ + private function conferenceSayTextApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation conferenceStartRecording + * + * Start recording + * + * @param string $conferenceId Conference ID. (required) + * @param \Infobip\Model\CallsStartRecordingRequest $callsStartRecordingRequest callsStartRecordingRequest (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function conferenceStartRecording(string $conferenceId, \Infobip\Model\CallsStartRecordingRequest $callsStartRecordingRequest) + { + $request = $this->conferenceStartRecordingRequest($conferenceId, $callsStartRecordingRequest); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->conferenceStartRecordingResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->conferenceStartRecordingApiException($exception); + } + } + + /** + * Operation conferenceStartRecordingAsync + * + * Start recording + * + * @param string $conferenceId Conference ID. (required) + * @param \Infobip\Model\CallsStartRecordingRequest $callsStartRecordingRequest (required) + * + * @throws InvalidArgumentException + */ + public function conferenceStartRecordingAsync(string $conferenceId, \Infobip\Model\CallsStartRecordingRequest $callsStartRecordingRequest): PromiseInterface + { + $request = $this->conferenceStartRecordingRequest($conferenceId, $callsStartRecordingRequest); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->conferenceStartRecordingResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->conferenceStartRecordingApiException($exception); + } + ); + } + + /** + * Create request for operation 'conferenceStartRecording' + * + * @param string $conferenceId Conference ID. (required) + * @param \Infobip\Model\CallsStartRecordingRequest $callsStartRecordingRequest (required) + * + * @throws InvalidArgumentException + */ + private function conferenceStartRecordingRequest(string $conferenceId, \Infobip\Model\CallsStartRecordingRequest $callsStartRecordingRequest): Request + { + $allData = [ + 'conferenceId' => $conferenceId, + 'callsStartRecordingRequest' => $callsStartRecordingRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'conferenceId' => [ + new Assert\NotBlank(), + ], + 'callsStartRecordingRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/conferences/{conferenceId}/start-recording'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($conferenceId !== null) { + $resourcePath = str_replace( + '{' . 'conferenceId' . '}', + $this->objectSerializer->toPathValue($conferenceId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($callsStartRecordingRequest)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($callsStartRecordingRequest) + : $callsStartRecordingRequest; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'conferenceStartRecording' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function conferenceStartRecordingResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsActionResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'conferenceStartRecording' + */ + private function conferenceStartRecordingApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation conferenceStopPlayingFile + * + * Stop playing file + * + * @param string $conferenceId Conference ID. (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function conferenceStopPlayingFile(string $conferenceId) + { + $request = $this->conferenceStopPlayingFileRequest($conferenceId); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->conferenceStopPlayingFileResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->conferenceStopPlayingFileApiException($exception); + } + } + + /** + * Operation conferenceStopPlayingFileAsync + * + * Stop playing file + * + * @param string $conferenceId Conference ID. (required) + * + * @throws InvalidArgumentException + */ + public function conferenceStopPlayingFileAsync(string $conferenceId): PromiseInterface + { + $request = $this->conferenceStopPlayingFileRequest($conferenceId); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->conferenceStopPlayingFileResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->conferenceStopPlayingFileApiException($exception); + } + ); + } + + /** + * Create request for operation 'conferenceStopPlayingFile' + * + * @param string $conferenceId Conference ID. (required) + * + * @throws InvalidArgumentException + */ + private function conferenceStopPlayingFileRequest(string $conferenceId): Request + { + $allData = [ + 'conferenceId' => $conferenceId, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'conferenceId' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/conferences/{conferenceId}/stop-play'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($conferenceId !== null) { + $resourcePath = str_replace( + '{' . 'conferenceId' . '}', + $this->objectSerializer->toPathValue($conferenceId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'conferenceStopPlayingFile' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function conferenceStopPlayingFileResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsActionResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'conferenceStopPlayingFile' + */ + private function conferenceStopPlayingFileApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation conferenceStopRecording + * + * Stop recording + * + * @param string $conferenceId Conference ID. (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function conferenceStopRecording(string $conferenceId) + { + $request = $this->conferenceStopRecordingRequest($conferenceId); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->conferenceStopRecordingResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->conferenceStopRecordingApiException($exception); + } + } + + /** + * Operation conferenceStopRecordingAsync + * + * Stop recording + * + * @param string $conferenceId Conference ID. (required) + * + * @throws InvalidArgumentException + */ + public function conferenceStopRecordingAsync(string $conferenceId): PromiseInterface + { + $request = $this->conferenceStopRecordingRequest($conferenceId); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->conferenceStopRecordingResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->conferenceStopRecordingApiException($exception); + } + ); + } + + /** + * Create request for operation 'conferenceStopRecording' + * + * @param string $conferenceId Conference ID. (required) + * + * @throws InvalidArgumentException + */ + private function conferenceStopRecordingRequest(string $conferenceId): Request + { + $allData = [ + 'conferenceId' => $conferenceId, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'conferenceId' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/conferences/{conferenceId}/stop-recording'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($conferenceId !== null) { + $resourcePath = str_replace( + '{' . 'conferenceId' . '}', + $this->objectSerializer->toPathValue($conferenceId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'conferenceStopRecording' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function conferenceStopRecordingResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsActionResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'conferenceStopRecording' + */ + private function conferenceStopRecordingApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation connectCalls + * + * Connect calls + * + * @param \Infobip\Model\CallsConnectRequest $callsConnectRequest callsConnectRequest (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsConference|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function connectCalls(\Infobip\Model\CallsConnectRequest $callsConnectRequest) + { + $request = $this->connectCallsRequest($callsConnectRequest); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->connectCallsResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->connectCallsApiException($exception); + } + } + + /** + * Operation connectCallsAsync + * + * Connect calls + * + * @param \Infobip\Model\CallsConnectRequest $callsConnectRequest (required) + * + * @throws InvalidArgumentException + */ + public function connectCallsAsync(\Infobip\Model\CallsConnectRequest $callsConnectRequest): PromiseInterface + { + $request = $this->connectCallsRequest($callsConnectRequest); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->connectCallsResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->connectCallsApiException($exception); + } + ); + } + + /** + * Create request for operation 'connectCalls' + * + * @param \Infobip\Model\CallsConnectRequest $callsConnectRequest (required) + * + * @throws InvalidArgumentException + */ + private function connectCallsRequest(\Infobip\Model\CallsConnectRequest $callsConnectRequest): Request + { + $allData = [ + 'callsConnectRequest' => $callsConnectRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'callsConnectRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/connect'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($callsConnectRequest)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($callsConnectRequest) + : $callsConnectRequest; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'connectCalls' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsConference|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function connectCallsResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsConference', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'connectCalls' + */ + private function connectCallsApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation connectWithNewCall + * + * Connect with new call + * + * @param string $callId Call ID. (required) + * @param \Infobip\Model\CallsConnectWithNewCallRequest $callsConnectWithNewCallRequest callsConnectWithNewCallRequest (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsConferenceAndCall|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function connectWithNewCall(string $callId, \Infobip\Model\CallsConnectWithNewCallRequest $callsConnectWithNewCallRequest) + { + $request = $this->connectWithNewCallRequest($callId, $callsConnectWithNewCallRequest); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->connectWithNewCallResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->connectWithNewCallApiException($exception); + } + } + + /** + * Operation connectWithNewCallAsync + * + * Connect with new call + * + * @param string $callId Call ID. (required) + * @param \Infobip\Model\CallsConnectWithNewCallRequest $callsConnectWithNewCallRequest (required) + * + * @throws InvalidArgumentException + */ + public function connectWithNewCallAsync(string $callId, \Infobip\Model\CallsConnectWithNewCallRequest $callsConnectWithNewCallRequest): PromiseInterface + { + $request = $this->connectWithNewCallRequest($callId, $callsConnectWithNewCallRequest); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->connectWithNewCallResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->connectWithNewCallApiException($exception); + } + ); + } + + /** + * Create request for operation 'connectWithNewCall' + * + * @param string $callId Call ID. (required) + * @param \Infobip\Model\CallsConnectWithNewCallRequest $callsConnectWithNewCallRequest (required) + * + * @throws InvalidArgumentException + */ + private function connectWithNewCallRequest(string $callId, \Infobip\Model\CallsConnectWithNewCallRequest $callsConnectWithNewCallRequest): Request + { + $allData = [ + 'callId' => $callId, + 'callsConnectWithNewCallRequest' => $callsConnectWithNewCallRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'callId' => [ + new Assert\NotBlank(), + ], + 'callsConnectWithNewCallRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/calls/{callId}/connect'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($callId !== null) { + $resourcePath = str_replace( + '{' . 'callId' . '}', + $this->objectSerializer->toPathValue($callId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($callsConnectWithNewCallRequest)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($callsConnectWithNewCallRequest) + : $callsConnectWithNewCallRequest; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'connectWithNewCall' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsConferenceAndCall|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function connectWithNewCallResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsConferenceAndCall', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'connectWithNewCall' + */ + private function connectWithNewCallApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation createBulk + * + * Create bulk of calls + * + * @param \Infobip\Model\CallBulkRequest $callBulkRequest callBulkRequest (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallBulkResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function createBulk(\Infobip\Model\CallBulkRequest $callBulkRequest) + { + $request = $this->createBulkRequest($callBulkRequest); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->createBulkResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->createBulkApiException($exception); + } + } + + /** + * Operation createBulkAsync + * + * Create bulk of calls + * + * @param \Infobip\Model\CallBulkRequest $callBulkRequest (required) + * + * @throws InvalidArgumentException + */ + public function createBulkAsync(\Infobip\Model\CallBulkRequest $callBulkRequest): PromiseInterface + { + $request = $this->createBulkRequest($callBulkRequest); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->createBulkResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->createBulkApiException($exception); + } + ); + } + + /** + * Create request for operation 'createBulk' + * + * @param \Infobip\Model\CallBulkRequest $callBulkRequest (required) + * + * @throws InvalidArgumentException + */ + private function createBulkRequest(\Infobip\Model\CallBulkRequest $callBulkRequest): Request + { + $allData = [ + 'callBulkRequest' => $callBulkRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'callBulkRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/bulks'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($callBulkRequest)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($callBulkRequest) + : $callBulkRequest; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'createBulk' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallBulkResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function createBulkResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 201) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallBulkResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'createBulk' + */ + private function createBulkApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation createCall + * + * Create call + * + * @param \Infobip\Model\CallRequest $callRequest callRequest (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\Call|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function createCall(\Infobip\Model\CallRequest $callRequest) + { + $request = $this->createCallRequest($callRequest); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->createCallResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->createCallApiException($exception); + } + } + + /** + * Operation createCallAsync + * + * Create call + * + * @param \Infobip\Model\CallRequest $callRequest (required) + * + * @throws InvalidArgumentException + */ + public function createCallAsync(\Infobip\Model\CallRequest $callRequest): PromiseInterface + { + $request = $this->createCallRequest($callRequest); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->createCallResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->createCallApiException($exception); + } + ); + } + + /** + * Create request for operation 'createCall' + * + * @param \Infobip\Model\CallRequest $callRequest (required) + * + * @throws InvalidArgumentException + */ + private function createCallRequest(\Infobip\Model\CallRequest $callRequest): Request + { + $allData = [ + 'callRequest' => $callRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'callRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/calls'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($callRequest)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($callRequest) + : $callRequest; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'createCall' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\Call|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function createCallResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 201) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\Call', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'createCall' + */ + private function createCallApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation createConference + * + * Create conference + * + * @param \Infobip\Model\CallsConferenceRequest $callsConferenceRequest callsConferenceRequest (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsConference|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function createConference(\Infobip\Model\CallsConferenceRequest $callsConferenceRequest) + { + $request = $this->createConferenceRequest($callsConferenceRequest); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->createConferenceResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->createConferenceApiException($exception); + } + } + + /** + * Operation createConferenceAsync + * + * Create conference + * + * @param \Infobip\Model\CallsConferenceRequest $callsConferenceRequest (required) + * + * @throws InvalidArgumentException + */ + public function createConferenceAsync(\Infobip\Model\CallsConferenceRequest $callsConferenceRequest): PromiseInterface + { + $request = $this->createConferenceRequest($callsConferenceRequest); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->createConferenceResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->createConferenceApiException($exception); + } + ); + } + + /** + * Create request for operation 'createConference' + * + * @param \Infobip\Model\CallsConferenceRequest $callsConferenceRequest (required) + * + * @throws InvalidArgumentException + */ + private function createConferenceRequest(\Infobip\Model\CallsConferenceRequest $callsConferenceRequest): Request + { + $allData = [ + 'callsConferenceRequest' => $callsConferenceRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'callsConferenceRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/conferences'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($callsConferenceRequest)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($callsConferenceRequest) + : $callsConferenceRequest; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'createConference' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsConference|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function createConferenceResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 201) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsConference', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'createConference' + */ + private function createConferenceApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation createDialog + * + * Create dialog + * + * @param \Infobip\Model\CallsDialogRequest $callsDialogRequest callsDialogRequest (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsDialogResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function createDialog(\Infobip\Model\CallsDialogRequest $callsDialogRequest) + { + $request = $this->createDialogRequest($callsDialogRequest); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->createDialogResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->createDialogApiException($exception); + } + } + + /** + * Operation createDialogAsync + * + * Create dialog + * + * @param \Infobip\Model\CallsDialogRequest $callsDialogRequest (required) + * + * @throws InvalidArgumentException + */ + public function createDialogAsync(\Infobip\Model\CallsDialogRequest $callsDialogRequest): PromiseInterface + { + $request = $this->createDialogRequest($callsDialogRequest); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->createDialogResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->createDialogApiException($exception); + } + ); + } + + /** + * Create request for operation 'createDialog' + * + * @param \Infobip\Model\CallsDialogRequest $callsDialogRequest (required) + * + * @throws InvalidArgumentException + */ + private function createDialogRequest(\Infobip\Model\CallsDialogRequest $callsDialogRequest): Request + { + $allData = [ + 'callsDialogRequest' => $callsDialogRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'callsDialogRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/dialogs'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($callsDialogRequest)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($callsDialogRequest) + : $callsDialogRequest; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'createDialog' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsDialogResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function createDialogResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 201) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsDialogResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'createDialog' + */ + private function createDialogApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation createMediaStreamConfig + * + * Create a media-stream configuration + * + * @param \Infobip\Model\CallsMediaStreamConfigRequest $callsMediaStreamConfigRequest callsMediaStreamConfigRequest (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsMediaStreamConfigResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function createMediaStreamConfig(\Infobip\Model\CallsMediaStreamConfigRequest $callsMediaStreamConfigRequest) + { + $request = $this->createMediaStreamConfigRequest($callsMediaStreamConfigRequest); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->createMediaStreamConfigResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->createMediaStreamConfigApiException($exception); + } + } + + /** + * Operation createMediaStreamConfigAsync + * + * Create a media-stream configuration + * + * @param \Infobip\Model\CallsMediaStreamConfigRequest $callsMediaStreamConfigRequest (required) + * + * @throws InvalidArgumentException + */ + public function createMediaStreamConfigAsync(\Infobip\Model\CallsMediaStreamConfigRequest $callsMediaStreamConfigRequest): PromiseInterface + { + $request = $this->createMediaStreamConfigRequest($callsMediaStreamConfigRequest); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->createMediaStreamConfigResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->createMediaStreamConfigApiException($exception); + } + ); + } + + /** + * Create request for operation 'createMediaStreamConfig' + * + * @param \Infobip\Model\CallsMediaStreamConfigRequest $callsMediaStreamConfigRequest (required) + * + * @throws InvalidArgumentException + */ + private function createMediaStreamConfigRequest(\Infobip\Model\CallsMediaStreamConfigRequest $callsMediaStreamConfigRequest): Request + { + $allData = [ + 'callsMediaStreamConfigRequest' => $callsMediaStreamConfigRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'callsMediaStreamConfigRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/media-stream-configs'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($callsMediaStreamConfigRequest)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($callsMediaStreamConfigRequest) + : $callsMediaStreamConfigRequest; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'createMediaStreamConfig' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsMediaStreamConfigResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function createMediaStreamConfigResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 201) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsMediaStreamConfigResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'createMediaStreamConfig' + */ + private function createMediaStreamConfigApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation deleteCallRecordings + * + * Delete call recordings + * + * @param string $callId Call ID. (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallRecording|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function deleteCallRecordings(string $callId) + { + $request = $this->deleteCallRecordingsRequest($callId); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->deleteCallRecordingsResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->deleteCallRecordingsApiException($exception); + } + } + + /** + * Operation deleteCallRecordingsAsync + * + * Delete call recordings + * + * @param string $callId Call ID. (required) + * + * @throws InvalidArgumentException + */ + public function deleteCallRecordingsAsync(string $callId): PromiseInterface + { + $request = $this->deleteCallRecordingsRequest($callId); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->deleteCallRecordingsResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->deleteCallRecordingsApiException($exception); + } + ); + } + + /** + * Create request for operation 'deleteCallRecordings' + * + * @param string $callId Call ID. (required) + * + * @throws InvalidArgumentException + */ + private function deleteCallRecordingsRequest(string $callId): Request + { + $allData = [ + 'callId' => $callId, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'callId' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/recordings/calls/{callId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($callId !== null) { + $resourcePath = str_replace( + '{' . 'callId' . '}', + $this->objectSerializer->toPathValue($callId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'DELETE', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'deleteCallRecordings' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallRecording|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function deleteCallRecordingsResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallRecording', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'deleteCallRecordings' + */ + private function deleteCallRecordingsApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation deleteCallsFile + * + * Delete file + * + * @param string $fileId File ID. (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsFile|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function deleteCallsFile(string $fileId) + { + $request = $this->deleteCallsFileRequest($fileId); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->deleteCallsFileResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->deleteCallsFileApiException($exception); + } + } + + /** + * Operation deleteCallsFileAsync + * + * Delete file + * + * @param string $fileId File ID. (required) + * + * @throws InvalidArgumentException + */ + public function deleteCallsFileAsync(string $fileId): PromiseInterface + { + $request = $this->deleteCallsFileRequest($fileId); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->deleteCallsFileResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->deleteCallsFileApiException($exception); + } + ); + } + + /** + * Create request for operation 'deleteCallsFile' + * + * @param string $fileId File ID. (required) + * + * @throws InvalidArgumentException + */ + private function deleteCallsFileRequest(string $fileId): Request + { + $allData = [ + 'fileId' => $fileId, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'fileId' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/files/{fileId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($fileId !== null) { + $resourcePath = str_replace( + '{' . 'fileId' . '}', + $this->objectSerializer->toPathValue($fileId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'DELETE', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'deleteCallsFile' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsFile|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function deleteCallsFileResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsFile', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'deleteCallsFile' + */ + private function deleteCallsFileApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation deleteConferenceRecordings + * + * Delete conference recordings + * + * @param string $conferenceId Conference ID. (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsConferenceRecording|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function deleteConferenceRecordings(string $conferenceId) + { + $request = $this->deleteConferenceRecordingsRequest($conferenceId); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->deleteConferenceRecordingsResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->deleteConferenceRecordingsApiException($exception); + } + } + + /** + * Operation deleteConferenceRecordingsAsync + * + * Delete conference recordings + * + * @param string $conferenceId Conference ID. (required) + * + * @throws InvalidArgumentException + */ + public function deleteConferenceRecordingsAsync(string $conferenceId): PromiseInterface + { + $request = $this->deleteConferenceRecordingsRequest($conferenceId); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->deleteConferenceRecordingsResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->deleteConferenceRecordingsApiException($exception); + } + ); + } + + /** + * Create request for operation 'deleteConferenceRecordings' + * + * @param string $conferenceId Conference ID. (required) + * + * @throws InvalidArgumentException + */ + private function deleteConferenceRecordingsRequest(string $conferenceId): Request + { + $allData = [ + 'conferenceId' => $conferenceId, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'conferenceId' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/recordings/conferences/{conferenceId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($conferenceId !== null) { + $resourcePath = str_replace( + '{' . 'conferenceId' . '}', + $this->objectSerializer->toPathValue($conferenceId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'DELETE', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'deleteConferenceRecordings' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsConferenceRecording|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function deleteConferenceRecordingsResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsConferenceRecording', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'deleteConferenceRecordings' + */ + private function deleteConferenceRecordingsApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation deleteDialogRecordings + * + * Delete dialog recordings + * + * @param string $dialogId Dialog ID. (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsDialogRecordingResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function deleteDialogRecordings(string $dialogId) + { + $request = $this->deleteDialogRecordingsRequest($dialogId); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->deleteDialogRecordingsResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->deleteDialogRecordingsApiException($exception); + } + } + + /** + * Operation deleteDialogRecordingsAsync + * + * Delete dialog recordings + * + * @param string $dialogId Dialog ID. (required) + * + * @throws InvalidArgumentException + */ + public function deleteDialogRecordingsAsync(string $dialogId): PromiseInterface + { + $request = $this->deleteDialogRecordingsRequest($dialogId); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->deleteDialogRecordingsResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->deleteDialogRecordingsApiException($exception); + } + ); + } + + /** + * Create request for operation 'deleteDialogRecordings' + * + * @param string $dialogId Dialog ID. (required) + * + * @throws InvalidArgumentException + */ + private function deleteDialogRecordingsRequest(string $dialogId): Request + { + $allData = [ + 'dialogId' => $dialogId, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'dialogId' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/recordings/dialogs/{dialogId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($dialogId !== null) { + $resourcePath = str_replace( + '{' . 'dialogId' . '}', + $this->objectSerializer->toPathValue($dialogId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'DELETE', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'deleteDialogRecordings' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsDialogRecordingResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function deleteDialogRecordingsResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsDialogRecordingResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'deleteDialogRecordings' + */ + private function deleteDialogRecordingsApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation deleteMediaStreamConfig + * + * Delete a media-stream configuration + * + * @param string $mediaStreamConfigId Media-stream configuration ID. (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsMediaStreamConfigResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function deleteMediaStreamConfig(string $mediaStreamConfigId) + { + $request = $this->deleteMediaStreamConfigRequest($mediaStreamConfigId); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->deleteMediaStreamConfigResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->deleteMediaStreamConfigApiException($exception); + } + } + + /** + * Operation deleteMediaStreamConfigAsync + * + * Delete a media-stream configuration + * + * @param string $mediaStreamConfigId Media-stream configuration ID. (required) + * + * @throws InvalidArgumentException + */ + public function deleteMediaStreamConfigAsync(string $mediaStreamConfigId): PromiseInterface + { + $request = $this->deleteMediaStreamConfigRequest($mediaStreamConfigId); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->deleteMediaStreamConfigResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->deleteMediaStreamConfigApiException($exception); + } + ); + } + + /** + * Create request for operation 'deleteMediaStreamConfig' + * + * @param string $mediaStreamConfigId Media-stream configuration ID. (required) + * + * @throws InvalidArgumentException + */ + private function deleteMediaStreamConfigRequest(string $mediaStreamConfigId): Request + { + $allData = [ + 'mediaStreamConfigId' => $mediaStreamConfigId, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'mediaStreamConfigId' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/media-stream-configs/{mediaStreamConfigId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($mediaStreamConfigId !== null) { + $resourcePath = str_replace( + '{' . 'mediaStreamConfigId' . '}', + $this->objectSerializer->toPathValue($mediaStreamConfigId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'DELETE', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'deleteMediaStreamConfig' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsMediaStreamConfigResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function deleteMediaStreamConfigResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsMediaStreamConfigResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'deleteMediaStreamConfig' + */ + private function deleteMediaStreamConfigApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation deleteRecordingFile + * + * Delete recording file + * + * @param string $fileId File ID. (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsRecordingFile|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function deleteRecordingFile(string $fileId) + { + $request = $this->deleteRecordingFileRequest($fileId); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->deleteRecordingFileResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->deleteRecordingFileApiException($exception); + } + } + + /** + * Operation deleteRecordingFileAsync + * + * Delete recording file + * + * @param string $fileId File ID. (required) + * + * @throws InvalidArgumentException + */ + public function deleteRecordingFileAsync(string $fileId): PromiseInterface + { + $request = $this->deleteRecordingFileRequest($fileId); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->deleteRecordingFileResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->deleteRecordingFileApiException($exception); + } + ); + } + + /** + * Create request for operation 'deleteRecordingFile' + * + * @param string $fileId File ID. (required) + * + * @throws InvalidArgumentException + */ + private function deleteRecordingFileRequest(string $fileId): Request + { + $allData = [ + 'fileId' => $fileId, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'fileId' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/recordings/files/{fileId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($fileId !== null) { + $resourcePath = str_replace( + '{' . 'fileId' . '}', + $this->objectSerializer->toPathValue($fileId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'DELETE', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'deleteRecordingFile' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsRecordingFile|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function deleteRecordingFileResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsRecordingFile', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'deleteRecordingFile' + */ + private function deleteRecordingFileApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation dialogPlayFile + * + * Play file + * + * @param string $dialogId Dialog ID. (required) + * @param \Infobip\Model\CallsDialogPlayRequest $callsDialogPlayRequest callsDialogPlayRequest (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function dialogPlayFile(string $dialogId, \Infobip\Model\CallsDialogPlayRequest $callsDialogPlayRequest) + { + $request = $this->dialogPlayFileRequest($dialogId, $callsDialogPlayRequest); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->dialogPlayFileResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->dialogPlayFileApiException($exception); + } + } + + /** + * Operation dialogPlayFileAsync + * + * Play file + * + * @param string $dialogId Dialog ID. (required) + * @param \Infobip\Model\CallsDialogPlayRequest $callsDialogPlayRequest (required) + * + * @throws InvalidArgumentException + */ + public function dialogPlayFileAsync(string $dialogId, \Infobip\Model\CallsDialogPlayRequest $callsDialogPlayRequest): PromiseInterface + { + $request = $this->dialogPlayFileRequest($dialogId, $callsDialogPlayRequest); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->dialogPlayFileResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->dialogPlayFileApiException($exception); + } + ); + } + + /** + * Create request for operation 'dialogPlayFile' + * + * @param string $dialogId Dialog ID. (required) + * @param \Infobip\Model\CallsDialogPlayRequest $callsDialogPlayRequest (required) + * + * @throws InvalidArgumentException + */ + private function dialogPlayFileRequest(string $dialogId, \Infobip\Model\CallsDialogPlayRequest $callsDialogPlayRequest): Request + { + $allData = [ + 'dialogId' => $dialogId, + 'callsDialogPlayRequest' => $callsDialogPlayRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'dialogId' => [ + new Assert\NotBlank(), + ], + 'callsDialogPlayRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/dialogs/{dialogId}/play'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($dialogId !== null) { + $resourcePath = str_replace( + '{' . 'dialogId' . '}', + $this->objectSerializer->toPathValue($dialogId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($callsDialogPlayRequest)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($callsDialogPlayRequest) + : $callsDialogPlayRequest; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'dialogPlayFile' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function dialogPlayFileResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsActionResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'dialogPlayFile' + */ + private function dialogPlayFileApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation dialogSayText + * + * Say text + * + * @param string $dialogId Dialog ID. (required) + * @param \Infobip\Model\CallsDialogSayRequest $callsDialogSayRequest callsDialogSayRequest (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function dialogSayText(string $dialogId, \Infobip\Model\CallsDialogSayRequest $callsDialogSayRequest) + { + $request = $this->dialogSayTextRequest($dialogId, $callsDialogSayRequest); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->dialogSayTextResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->dialogSayTextApiException($exception); + } + } + + /** + * Operation dialogSayTextAsync + * + * Say text + * + * @param string $dialogId Dialog ID. (required) + * @param \Infobip\Model\CallsDialogSayRequest $callsDialogSayRequest (required) + * + * @throws InvalidArgumentException + */ + public function dialogSayTextAsync(string $dialogId, \Infobip\Model\CallsDialogSayRequest $callsDialogSayRequest): PromiseInterface + { + $request = $this->dialogSayTextRequest($dialogId, $callsDialogSayRequest); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->dialogSayTextResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->dialogSayTextApiException($exception); + } + ); + } + + /** + * Create request for operation 'dialogSayText' + * + * @param string $dialogId Dialog ID. (required) + * @param \Infobip\Model\CallsDialogSayRequest $callsDialogSayRequest (required) + * + * @throws InvalidArgumentException + */ + private function dialogSayTextRequest(string $dialogId, \Infobip\Model\CallsDialogSayRequest $callsDialogSayRequest): Request + { + $allData = [ + 'dialogId' => $dialogId, + 'callsDialogSayRequest' => $callsDialogSayRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'dialogId' => [ + new Assert\NotBlank(), + ], + 'callsDialogSayRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/dialogs/{dialogId}/say'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($dialogId !== null) { + $resourcePath = str_replace( + '{' . 'dialogId' . '}', + $this->objectSerializer->toPathValue($dialogId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($callsDialogSayRequest)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($callsDialogSayRequest) + : $callsDialogSayRequest; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'dialogSayText' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function dialogSayTextResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsActionResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'dialogSayText' + */ + private function dialogSayTextApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation dialogStartRecording + * + * Start recording + * + * @param string $dialogId Dialog ID. (required) + * @param \Infobip\Model\CallsDialogRecordingRequest $callsDialogRecordingRequest callsDialogRecordingRequest (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function dialogStartRecording(string $dialogId, \Infobip\Model\CallsDialogRecordingRequest $callsDialogRecordingRequest) + { + $request = $this->dialogStartRecordingRequest($dialogId, $callsDialogRecordingRequest); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->dialogStartRecordingResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->dialogStartRecordingApiException($exception); + } + } + + /** + * Operation dialogStartRecordingAsync + * + * Start recording + * + * @param string $dialogId Dialog ID. (required) + * @param \Infobip\Model\CallsDialogRecordingRequest $callsDialogRecordingRequest (required) + * + * @throws InvalidArgumentException + */ + public function dialogStartRecordingAsync(string $dialogId, \Infobip\Model\CallsDialogRecordingRequest $callsDialogRecordingRequest): PromiseInterface + { + $request = $this->dialogStartRecordingRequest($dialogId, $callsDialogRecordingRequest); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->dialogStartRecordingResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->dialogStartRecordingApiException($exception); + } + ); + } + + /** + * Create request for operation 'dialogStartRecording' + * + * @param string $dialogId Dialog ID. (required) + * @param \Infobip\Model\CallsDialogRecordingRequest $callsDialogRecordingRequest (required) + * + * @throws InvalidArgumentException + */ + private function dialogStartRecordingRequest(string $dialogId, \Infobip\Model\CallsDialogRecordingRequest $callsDialogRecordingRequest): Request + { + $allData = [ + 'dialogId' => $dialogId, + 'callsDialogRecordingRequest' => $callsDialogRecordingRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'dialogId' => [ + new Assert\NotBlank(), + ], + 'callsDialogRecordingRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/dialogs/{dialogId}/start-recording'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($dialogId !== null) { + $resourcePath = str_replace( + '{' . 'dialogId' . '}', + $this->objectSerializer->toPathValue($dialogId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($callsDialogRecordingRequest)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($callsDialogRecordingRequest) + : $callsDialogRecordingRequest; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'dialogStartRecording' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function dialogStartRecordingResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsActionResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'dialogStartRecording' + */ + private function dialogStartRecordingApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation dialogStopPlayingFile + * + * Stop playing file + * + * @param string $dialogId Dialog ID. (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function dialogStopPlayingFile(string $dialogId) + { + $request = $this->dialogStopPlayingFileRequest($dialogId); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->dialogStopPlayingFileResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->dialogStopPlayingFileApiException($exception); + } + } + + /** + * Operation dialogStopPlayingFileAsync + * + * Stop playing file + * + * @param string $dialogId Dialog ID. (required) + * + * @throws InvalidArgumentException + */ + public function dialogStopPlayingFileAsync(string $dialogId): PromiseInterface + { + $request = $this->dialogStopPlayingFileRequest($dialogId); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->dialogStopPlayingFileResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->dialogStopPlayingFileApiException($exception); + } + ); + } + + /** + * Create request for operation 'dialogStopPlayingFile' + * + * @param string $dialogId Dialog ID. (required) + * + * @throws InvalidArgumentException + */ + private function dialogStopPlayingFileRequest(string $dialogId): Request + { + $allData = [ + 'dialogId' => $dialogId, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'dialogId' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/dialogs/{dialogId}/stop-play'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($dialogId !== null) { + $resourcePath = str_replace( + '{' . 'dialogId' . '}', + $this->objectSerializer->toPathValue($dialogId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'dialogStopPlayingFile' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function dialogStopPlayingFileResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsActionResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'dialogStopPlayingFile' + */ + private function dialogStopPlayingFileApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation dialogStopRecording + * + * Stop recording + * + * @param string $dialogId Dialog ID. (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function dialogStopRecording(string $dialogId) + { + $request = $this->dialogStopRecordingRequest($dialogId); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->dialogStopRecordingResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->dialogStopRecordingApiException($exception); + } + } + + /** + * Operation dialogStopRecordingAsync + * + * Stop recording + * + * @param string $dialogId Dialog ID. (required) + * + * @throws InvalidArgumentException + */ + public function dialogStopRecordingAsync(string $dialogId): PromiseInterface + { + $request = $this->dialogStopRecordingRequest($dialogId); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->dialogStopRecordingResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->dialogStopRecordingApiException($exception); + } + ); + } + + /** + * Create request for operation 'dialogStopRecording' + * + * @param string $dialogId Dialog ID. (required) + * + * @throws InvalidArgumentException + */ + private function dialogStopRecordingRequest(string $dialogId): Request + { + $allData = [ + 'dialogId' => $dialogId, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'dialogId' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/dialogs/{dialogId}/stop-recording'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($dialogId !== null) { + $resourcePath = str_replace( + '{' . 'dialogId' . '}', + $this->objectSerializer->toPathValue($dialogId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'dialogStopRecording' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function dialogStopRecordingResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsActionResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'dialogStopRecording' + */ + private function dialogStopRecordingApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation downloadRecordingFile + * + * Download recording file + * + * @param string $fileId File ID. (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \SplFileObject|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function downloadRecordingFile(string $fileId) + { + $request = $this->downloadRecordingFileRequest($fileId); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->downloadRecordingFileResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->downloadRecordingFileApiException($exception); + } + } + + /** + * Operation downloadRecordingFileAsync + * + * Download recording file + * + * @param string $fileId File ID. (required) + * + * @throws InvalidArgumentException + */ + public function downloadRecordingFileAsync(string $fileId): PromiseInterface + { + $request = $this->downloadRecordingFileRequest($fileId); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->downloadRecordingFileResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->downloadRecordingFileApiException($exception); + } + ); + } + + /** + * Create request for operation 'downloadRecordingFile' + * + * @param string $fileId File ID. (required) + * + * @throws InvalidArgumentException + */ + private function downloadRecordingFileRequest(string $fileId): Request + { + $allData = [ + 'fileId' => $fileId, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'fileId' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/recordings/files/{fileId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($fileId !== null) { + $resourcePath = str_replace( + '{' . 'fileId' . '}', + $this->objectSerializer->toPathValue($fileId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/octet-stream', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'downloadRecordingFile' + * @throws ApiException on non-2xx response + * @return \SplFileObject|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function downloadRecordingFileResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\SplFileObject', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'downloadRecordingFile' + */ + private function downloadRecordingFileApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation getBulkStatus + * + * Get bulk status + * + * @param string $bulkId Bulk ID. (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallBulkStatus|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function getBulkStatus(string $bulkId) + { + $request = $this->getBulkStatusRequest($bulkId); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->getBulkStatusResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->getBulkStatusApiException($exception); + } + } + + /** + * Operation getBulkStatusAsync + * + * Get bulk status + * + * @param string $bulkId Bulk ID. (required) + * + * @throws InvalidArgumentException + */ + public function getBulkStatusAsync(string $bulkId): PromiseInterface + { + $request = $this->getBulkStatusRequest($bulkId); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->getBulkStatusResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->getBulkStatusApiException($exception); + } + ); + } + + /** + * Create request for operation 'getBulkStatus' + * + * @param string $bulkId Bulk ID. (required) + * + * @throws InvalidArgumentException + */ + private function getBulkStatusRequest(string $bulkId): Request + { + $allData = [ + 'bulkId' => $bulkId, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'bulkId' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/bulks/{bulkId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($bulkId !== null) { + $resourcePath = str_replace( + '{' . 'bulkId' . '}', + $this->objectSerializer->toPathValue($bulkId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'getBulkStatus' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallBulkStatus|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function getBulkStatusResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallBulkStatus', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'getBulkStatus' + */ + private function getBulkStatusApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation getCall + * + * Get call + * + * @param string $callId Call ID. (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\Call|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function getCall(string $callId) + { + $request = $this->getCallRequest($callId); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->getCallResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->getCallApiException($exception); + } + } + + /** + * Operation getCallAsync + * + * Get call + * + * @param string $callId Call ID. (required) + * + * @throws InvalidArgumentException + */ + public function getCallAsync(string $callId): PromiseInterface + { + $request = $this->getCallRequest($callId); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->getCallResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->getCallApiException($exception); + } + ); + } + + /** + * Create request for operation 'getCall' + * + * @param string $callId Call ID. (required) + * + * @throws InvalidArgumentException + */ + private function getCallRequest(string $callId): Request + { + $allData = [ + 'callId' => $callId, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'callId' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/calls/{callId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($callId !== null) { + $resourcePath = str_replace( + '{' . 'callId' . '}', + $this->objectSerializer->toPathValue($callId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'getCall' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\Call|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function getCallResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\Call', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'getCall' + */ + private function getCallApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation getCallHistory + * + * Get call history + * + * @param string $callId Call ID. (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallLog|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function getCallHistory(string $callId) + { + $request = $this->getCallHistoryRequest($callId); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->getCallHistoryResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->getCallHistoryApiException($exception); + } + } + + /** + * Operation getCallHistoryAsync + * + * Get call history + * + * @param string $callId Call ID. (required) + * + * @throws InvalidArgumentException + */ + public function getCallHistoryAsync(string $callId): PromiseInterface + { + $request = $this->getCallHistoryRequest($callId); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->getCallHistoryResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->getCallHistoryApiException($exception); + } + ); + } + + /** + * Create request for operation 'getCallHistory' + * + * @param string $callId Call ID. (required) + * + * @throws InvalidArgumentException + */ + private function getCallHistoryRequest(string $callId): Request + { + $allData = [ + 'callId' => $callId, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'callId' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/calls/{callId}/history'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($callId !== null) { + $resourcePath = str_replace( + '{' . 'callId' . '}', + $this->objectSerializer->toPathValue($callId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'getCallHistory' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallLog|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function getCallHistoryResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallLog', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'getCallHistory' + */ + private function getCallHistoryApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation getCallRecordings + * + * Get call recordings + * + * @param string $callId Call ID. (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallRecording|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function getCallRecordings(string $callId) + { + $request = $this->getCallRecordingsRequest($callId); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->getCallRecordingsResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->getCallRecordingsApiException($exception); + } + } + + /** + * Operation getCallRecordingsAsync + * + * Get call recordings + * + * @param string $callId Call ID. (required) + * + * @throws InvalidArgumentException + */ + public function getCallRecordingsAsync(string $callId): PromiseInterface + { + $request = $this->getCallRecordingsRequest($callId); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->getCallRecordingsResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->getCallRecordingsApiException($exception); + } + ); + } + + /** + * Create request for operation 'getCallRecordings' + * + * @param string $callId Call ID. (required) + * + * @throws InvalidArgumentException + */ + private function getCallRecordingsRequest(string $callId): Request + { + $allData = [ + 'callId' => $callId, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'callId' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/recordings/calls/{callId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($callId !== null) { + $resourcePath = str_replace( + '{' . 'callId' . '}', + $this->objectSerializer->toPathValue($callId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'getCallRecordings' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallRecording|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function getCallRecordingsResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallRecording', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'getCallRecordings' + */ + private function getCallRecordingsApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation getCalls + * + * Get calls + * + * @param null|\Infobip\Model\CallEndpointType $type Call endpoint type. (optional) + * @param null|string $applicationId Application ID. (optional) + * @param null|string $from Caller identifier. (optional) + * @param null|string $to Callee identifier. (optional) + * @param null|\Infobip\Model\CallDirection $direction Call direction. (optional) + * @param null|\Infobip\Model\CallState $status Call state. (optional) + * @param null|\DateTime $startTimeAfter Date and time for when the call has been created. Has the following format: `yyyy-MM-dd'T'HH:mm:ss.SSS+ZZZZ`. (optional) + * @param null|string $conferenceId Conference ID. (optional) + * @param null|string $dialogId Dialog ID. (optional) + * @param int $page Results page to retrieve (0..N). (optional, default to 0) + * @param int $size Number of records per page. (optional, default to 20) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallPage|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function getCalls(?\Infobip\Model\CallEndpointType $type = null, ?string $applicationId = null, ?string $from = null, ?string $to = null, ?\Infobip\Model\CallDirection $direction = null, ?\Infobip\Model\CallState $status = null, ?\DateTime $startTimeAfter = null, ?string $conferenceId = null, ?string $dialogId = null, int $page = 0, int $size = 20) + { + $request = $this->getCallsRequest($type, $applicationId, $from, $to, $direction, $status, $startTimeAfter, $conferenceId, $dialogId, $page, $size); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->getCallsResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->getCallsApiException($exception); + } + } + + /** + * Operation getCallsAsync + * + * Get calls + * + * @param null|\Infobip\Model\CallEndpointType $type Call endpoint type. (optional) + * @param null|string $applicationId Application ID. (optional) + * @param null|string $from Caller identifier. (optional) + * @param null|string $to Callee identifier. (optional) + * @param null|\Infobip\Model\CallDirection $direction Call direction. (optional) + * @param null|\Infobip\Model\CallState $status Call state. (optional) + * @param null|\DateTime $startTimeAfter Date and time for when the call has been created. Has the following format: `yyyy-MM-dd'T'HH:mm:ss.SSS+ZZZZ`. (optional) + * @param null|string $conferenceId Conference ID. (optional) + * @param null|string $dialogId Dialog ID. (optional) + * @param int $page Results page to retrieve (0..N). (optional, default to 0) + * @param int $size Number of records per page. (optional, default to 20) + * + * @throws InvalidArgumentException + */ + public function getCallsAsync(?\Infobip\Model\CallEndpointType $type = null, ?string $applicationId = null, ?string $from = null, ?string $to = null, ?\Infobip\Model\CallDirection $direction = null, ?\Infobip\Model\CallState $status = null, ?\DateTime $startTimeAfter = null, ?string $conferenceId = null, ?string $dialogId = null, int $page = 0, int $size = 20): PromiseInterface + { + $request = $this->getCallsRequest($type, $applicationId, $from, $to, $direction, $status, $startTimeAfter, $conferenceId, $dialogId, $page, $size); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->getCallsResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->getCallsApiException($exception); + } + ); + } + + /** + * Create request for operation 'getCalls' + * + * @param null|\Infobip\Model\CallEndpointType $type Call endpoint type. (optional) + * @param null|string $applicationId Application ID. (optional) + * @param null|string $from Caller identifier. (optional) + * @param null|string $to Callee identifier. (optional) + * @param null|\Infobip\Model\CallDirection $direction Call direction. (optional) + * @param null|\Infobip\Model\CallState $status Call state. (optional) + * @param null|\DateTime $startTimeAfter Date and time for when the call has been created. Has the following format: `yyyy-MM-dd'T'HH:mm:ss.SSS+ZZZZ`. (optional) + * @param null|string $conferenceId Conference ID. (optional) + * @param null|string $dialogId Dialog ID. (optional) + * @param int $page Results page to retrieve (0..N). (optional, default to 0) + * @param int $size Number of records per page. (optional, default to 20) + * + * @throws InvalidArgumentException + */ + private function getCallsRequest(?\Infobip\Model\CallEndpointType $type = null, ?string $applicationId = null, ?string $from = null, ?string $to = null, ?\Infobip\Model\CallDirection $direction = null, ?\Infobip\Model\CallState $status = null, ?\DateTime $startTimeAfter = null, ?string $conferenceId = null, ?string $dialogId = null, int $page = 0, int $size = 20): Request + { + $allData = [ + 'type' => $type, + 'applicationId' => $applicationId, + 'from' => $from, + 'to' => $to, + 'direction' => $direction, + 'status' => $status, + 'startTimeAfter' => $startTimeAfter, + 'conferenceId' => $conferenceId, + 'dialogId' => $dialogId, + 'page' => $page, + 'size' => $size, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'type' => [ + new Assert\Choice(['PHONE','SIP','WEBRTC','VIBER',]), + ], + 'applicationId' => [ + ], + 'from' => [ + ], + 'to' => [ + ], + 'direction' => [ + new Assert\Choice(['INBOUND','OUTBOUND',]), + ], + 'status' => [ + new Assert\Choice(['CALLING','RINGING','PRE_ESTABLISHED','ESTABLISHED','FINISHED','FAILED','CANCELLED','NO_ANSWER','BUSY',]), + ], + 'startTimeAfter' => [ + ], + 'conferenceId' => [ + ], + 'dialogId' => [ + ], + 'page' => [ + new Assert\GreaterThan(0), + ], + 'size' => [ + new Assert\LessThan(100), + new Assert\GreaterThan(1), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/calls'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // query params + if ($type !== null) { + $queryParams['type'] = $type; + } + + // query params + if ($applicationId !== null) { + $queryParams['applicationId'] = $applicationId; + } + + // query params + if ($from !== null) { + $queryParams['from'] = $from; + } + + // query params + if ($to !== null) { + $queryParams['to'] = $to; + } + + // query params + if ($direction !== null) { + $queryParams['direction'] = $direction; + } + + // query params + if ($status !== null) { + $queryParams['status'] = $status; + } + + // query params + if ($startTimeAfter !== null) { + $queryParams['startTimeAfter'] = $startTimeAfter; + } + + // query params + if ($conferenceId !== null) { + $queryParams['conferenceId'] = $conferenceId; + } + + // query params + if ($dialogId !== null) { + $queryParams['dialogId'] = $dialogId; + } + + // query params + if ($page !== null) { + $queryParams['page'] = $page; + } + + // query params + if ($size !== null) { + $queryParams['size'] = $size; + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'getCalls' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallPage|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function getCallsResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallPage', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'getCalls' + */ + private function getCallsApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation getCallsFile + * + * Get file + * + * @param string $fileId File ID. (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsFile|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function getCallsFile(string $fileId) + { + $request = $this->getCallsFileRequest($fileId); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->getCallsFileResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->getCallsFileApiException($exception); + } + } + + /** + * Operation getCallsFileAsync + * + * Get file + * + * @param string $fileId File ID. (required) + * + * @throws InvalidArgumentException + */ + public function getCallsFileAsync(string $fileId): PromiseInterface + { + $request = $this->getCallsFileRequest($fileId); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->getCallsFileResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->getCallsFileApiException($exception); + } + ); + } + + /** + * Create request for operation 'getCallsFile' + * + * @param string $fileId File ID. (required) + * + * @throws InvalidArgumentException + */ + private function getCallsFileRequest(string $fileId): Request + { + $allData = [ + 'fileId' => $fileId, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'fileId' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/files/{fileId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($fileId !== null) { + $resourcePath = str_replace( + '{' . 'fileId' . '}', + $this->objectSerializer->toPathValue($fileId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'getCallsFile' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsFile|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function getCallsFileResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsFile', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'getCallsFile' + */ + private function getCallsFileApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation getCallsFiles + * + * Get files + * + * @param int $page Results page to retrieve (0..N). (optional, default to 0) + * @param int $size Number of records per page. (optional, default to 20) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsFilePage|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function getCallsFiles(int $page = 0, int $size = 20) + { + $request = $this->getCallsFilesRequest($page, $size); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->getCallsFilesResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->getCallsFilesApiException($exception); + } + } + + /** + * Operation getCallsFilesAsync + * + * Get files + * + * @param int $page Results page to retrieve (0..N). (optional, default to 0) + * @param int $size Number of records per page. (optional, default to 20) + * + * @throws InvalidArgumentException + */ + public function getCallsFilesAsync(int $page = 0, int $size = 20): PromiseInterface + { + $request = $this->getCallsFilesRequest($page, $size); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->getCallsFilesResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->getCallsFilesApiException($exception); + } + ); + } + + /** + * Create request for operation 'getCallsFiles' + * + * @param int $page Results page to retrieve (0..N). (optional, default to 0) + * @param int $size Number of records per page. (optional, default to 20) + * + * @throws InvalidArgumentException + */ + private function getCallsFilesRequest(int $page = 0, int $size = 20): Request + { + $allData = [ + 'page' => $page, + 'size' => $size, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'page' => [ + new Assert\GreaterThan(0), + ], + 'size' => [ + new Assert\LessThan(100), + new Assert\GreaterThan(1), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/files'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // query params + if ($page !== null) { + $queryParams['page'] = $page; + } + + // query params + if ($size !== null) { + $queryParams['size'] = $size; + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'getCallsFiles' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsFilePage|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function getCallsFilesResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsFilePage', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'getCallsFiles' + */ + private function getCallsFilesApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation getCallsHistory + * + * Get calls history + * + * @param null|\Infobip\Model\CallEndpointType $type Call endpoint type. (optional) + * @param null|string $applicationId Application ID. (optional) + * @param null|string $from Caller identifier. (optional) + * @param null|string $to Callee identifier. (optional) + * @param null|\Infobip\Model\CallDirection $direction Call direction. (optional) + * @param null|\Infobip\Model\CallState $status Call state. (optional) + * @param null|\DateTime $startTimeAfter Date and time for when the call has been created. Has the following format: `yyyy-MM-dd'T'HH:mm:ss.SSS+ZZZZ`. (optional) + * @param null|\DateTime $endTimeBefore Date and time for when the call has been finished. Has the following format: `yyyy-MM-dd'T'HH:mm:ss.SSS+ZZZZ`. (optional) + * @param null|string $conferenceId Conference ID. (optional) + * @param null|string $dialogId Dialog ID. (optional) + * @param int $page Results page to retrieve (0..N). (optional, default to 0) + * @param int $size Number of records per page. (optional, default to 20) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallLogPage|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function getCallsHistory(?\Infobip\Model\CallEndpointType $type = null, ?string $applicationId = null, ?string $from = null, ?string $to = null, ?\Infobip\Model\CallDirection $direction = null, ?\Infobip\Model\CallState $status = null, ?\DateTime $startTimeAfter = null, ?\DateTime $endTimeBefore = null, ?string $conferenceId = null, ?string $dialogId = null, int $page = 0, int $size = 20) + { + $request = $this->getCallsHistoryRequest($type, $applicationId, $from, $to, $direction, $status, $startTimeAfter, $endTimeBefore, $conferenceId, $dialogId, $page, $size); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->getCallsHistoryResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->getCallsHistoryApiException($exception); + } + } + + /** + * Operation getCallsHistoryAsync + * + * Get calls history + * + * @param null|\Infobip\Model\CallEndpointType $type Call endpoint type. (optional) + * @param null|string $applicationId Application ID. (optional) + * @param null|string $from Caller identifier. (optional) + * @param null|string $to Callee identifier. (optional) + * @param null|\Infobip\Model\CallDirection $direction Call direction. (optional) + * @param null|\Infobip\Model\CallState $status Call state. (optional) + * @param null|\DateTime $startTimeAfter Date and time for when the call has been created. Has the following format: `yyyy-MM-dd'T'HH:mm:ss.SSS+ZZZZ`. (optional) + * @param null|\DateTime $endTimeBefore Date and time for when the call has been finished. Has the following format: `yyyy-MM-dd'T'HH:mm:ss.SSS+ZZZZ`. (optional) + * @param null|string $conferenceId Conference ID. (optional) + * @param null|string $dialogId Dialog ID. (optional) + * @param int $page Results page to retrieve (0..N). (optional, default to 0) + * @param int $size Number of records per page. (optional, default to 20) + * + * @throws InvalidArgumentException + */ + public function getCallsHistoryAsync(?\Infobip\Model\CallEndpointType $type = null, ?string $applicationId = null, ?string $from = null, ?string $to = null, ?\Infobip\Model\CallDirection $direction = null, ?\Infobip\Model\CallState $status = null, ?\DateTime $startTimeAfter = null, ?\DateTime $endTimeBefore = null, ?string $conferenceId = null, ?string $dialogId = null, int $page = 0, int $size = 20): PromiseInterface + { + $request = $this->getCallsHistoryRequest($type, $applicationId, $from, $to, $direction, $status, $startTimeAfter, $endTimeBefore, $conferenceId, $dialogId, $page, $size); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->getCallsHistoryResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->getCallsHistoryApiException($exception); + } + ); + } + + /** + * Create request for operation 'getCallsHistory' + * + * @param null|\Infobip\Model\CallEndpointType $type Call endpoint type. (optional) + * @param null|string $applicationId Application ID. (optional) + * @param null|string $from Caller identifier. (optional) + * @param null|string $to Callee identifier. (optional) + * @param null|\Infobip\Model\CallDirection $direction Call direction. (optional) + * @param null|\Infobip\Model\CallState $status Call state. (optional) + * @param null|\DateTime $startTimeAfter Date and time for when the call has been created. Has the following format: `yyyy-MM-dd'T'HH:mm:ss.SSS+ZZZZ`. (optional) + * @param null|\DateTime $endTimeBefore Date and time for when the call has been finished. Has the following format: `yyyy-MM-dd'T'HH:mm:ss.SSS+ZZZZ`. (optional) + * @param null|string $conferenceId Conference ID. (optional) + * @param null|string $dialogId Dialog ID. (optional) + * @param int $page Results page to retrieve (0..N). (optional, default to 0) + * @param int $size Number of records per page. (optional, default to 20) + * + * @throws InvalidArgumentException + */ + private function getCallsHistoryRequest(?\Infobip\Model\CallEndpointType $type = null, ?string $applicationId = null, ?string $from = null, ?string $to = null, ?\Infobip\Model\CallDirection $direction = null, ?\Infobip\Model\CallState $status = null, ?\DateTime $startTimeAfter = null, ?\DateTime $endTimeBefore = null, ?string $conferenceId = null, ?string $dialogId = null, int $page = 0, int $size = 20): Request + { + $allData = [ + 'type' => $type, + 'applicationId' => $applicationId, + 'from' => $from, + 'to' => $to, + 'direction' => $direction, + 'status' => $status, + 'startTimeAfter' => $startTimeAfter, + 'endTimeBefore' => $endTimeBefore, + 'conferenceId' => $conferenceId, + 'dialogId' => $dialogId, + 'page' => $page, + 'size' => $size, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'type' => [ + new Assert\Choice(['PHONE','SIP','WEBRTC','VIBER',]), + ], + 'applicationId' => [ + ], + 'from' => [ + ], + 'to' => [ + ], + 'direction' => [ + new Assert\Choice(['INBOUND','OUTBOUND',]), + ], + 'status' => [ + new Assert\Choice(['CALLING','RINGING','PRE_ESTABLISHED','ESTABLISHED','FINISHED','FAILED','CANCELLED','NO_ANSWER','BUSY',]), + ], + 'startTimeAfter' => [ + ], + 'endTimeBefore' => [ + ], + 'conferenceId' => [ + ], + 'dialogId' => [ + ], + 'page' => [ + new Assert\GreaterThan(0), + ], + 'size' => [ + new Assert\LessThan(100), + new Assert\GreaterThan(1), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/calls/history'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // query params + if ($type !== null) { + $queryParams['type'] = $type; + } + + // query params + if ($applicationId !== null) { + $queryParams['applicationId'] = $applicationId; + } + + // query params + if ($from !== null) { + $queryParams['from'] = $from; + } + + // query params + if ($to !== null) { + $queryParams['to'] = $to; + } + + // query params + if ($direction !== null) { + $queryParams['direction'] = $direction; + } + + // query params + if ($status !== null) { + $queryParams['status'] = $status; + } + + // query params + if ($startTimeAfter !== null) { + $queryParams['startTimeAfter'] = $startTimeAfter; + } + + // query params + if ($endTimeBefore !== null) { + $queryParams['endTimeBefore'] = $endTimeBefore; + } + + // query params + if ($conferenceId !== null) { + $queryParams['conferenceId'] = $conferenceId; + } + + // query params + if ($dialogId !== null) { + $queryParams['dialogId'] = $dialogId; + } + + // query params + if ($page !== null) { + $queryParams['page'] = $page; + } + + // query params + if ($size !== null) { + $queryParams['size'] = $size; + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'getCallsHistory' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallLogPage|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function getCallsHistoryResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallLogPage', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'getCallsHistory' + */ + private function getCallsHistoryApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation getCallsRecordings + * + * Get calls recordings + * + * @param null|string $callId Call ID. (optional) + * @param null|string $applicationId Application ID. (optional) + * @param null|string $endpointIdentifier Endpoint identifier. (optional) + * @param null|\DateTime $startTimeAfter Date and time when the (first) call recording started. (optional) + * @param null|\DateTime $endTimeBefore Date and time when the (last) call recording ended. (optional) + * @param null|\Infobip\Model\CallDirection $direction Call direction. (optional) + * @param null|\Infobip\Model\CallEndpointType $endpointType Endpoint type. (optional) + * @param int $page Results page to retrieve (0..N). (optional, default to 0) + * @param int $size Number of records per page. (optional, default to 20) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallRecordingPage|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function getCallsRecordings(?string $callId = null, ?string $applicationId = null, ?string $endpointIdentifier = null, ?\DateTime $startTimeAfter = null, ?\DateTime $endTimeBefore = null, ?\Infobip\Model\CallDirection $direction = null, ?\Infobip\Model\CallEndpointType $endpointType = null, int $page = 0, int $size = 20) + { + $request = $this->getCallsRecordingsRequest($callId, $applicationId, $endpointIdentifier, $startTimeAfter, $endTimeBefore, $direction, $endpointType, $page, $size); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->getCallsRecordingsResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->getCallsRecordingsApiException($exception); + } + } + + /** + * Operation getCallsRecordingsAsync + * + * Get calls recordings + * + * @param null|string $callId Call ID. (optional) + * @param null|string $applicationId Application ID. (optional) + * @param null|string $endpointIdentifier Endpoint identifier. (optional) + * @param null|\DateTime $startTimeAfter Date and time when the (first) call recording started. (optional) + * @param null|\DateTime $endTimeBefore Date and time when the (last) call recording ended. (optional) + * @param null|\Infobip\Model\CallDirection $direction Call direction. (optional) + * @param null|\Infobip\Model\CallEndpointType $endpointType Endpoint type. (optional) + * @param int $page Results page to retrieve (0..N). (optional, default to 0) + * @param int $size Number of records per page. (optional, default to 20) + * + * @throws InvalidArgumentException + */ + public function getCallsRecordingsAsync(?string $callId = null, ?string $applicationId = null, ?string $endpointIdentifier = null, ?\DateTime $startTimeAfter = null, ?\DateTime $endTimeBefore = null, ?\Infobip\Model\CallDirection $direction = null, ?\Infobip\Model\CallEndpointType $endpointType = null, int $page = 0, int $size = 20): PromiseInterface + { + $request = $this->getCallsRecordingsRequest($callId, $applicationId, $endpointIdentifier, $startTimeAfter, $endTimeBefore, $direction, $endpointType, $page, $size); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->getCallsRecordingsResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->getCallsRecordingsApiException($exception); + } + ); + } + + /** + * Create request for operation 'getCallsRecordings' + * + * @param null|string $callId Call ID. (optional) + * @param null|string $applicationId Application ID. (optional) + * @param null|string $endpointIdentifier Endpoint identifier. (optional) + * @param null|\DateTime $startTimeAfter Date and time when the (first) call recording started. (optional) + * @param null|\DateTime $endTimeBefore Date and time when the (last) call recording ended. (optional) + * @param null|\Infobip\Model\CallDirection $direction Call direction. (optional) + * @param null|\Infobip\Model\CallEndpointType $endpointType Endpoint type. (optional) + * @param int $page Results page to retrieve (0..N). (optional, default to 0) + * @param int $size Number of records per page. (optional, default to 20) + * + * @throws InvalidArgumentException + */ + private function getCallsRecordingsRequest(?string $callId = null, ?string $applicationId = null, ?string $endpointIdentifier = null, ?\DateTime $startTimeAfter = null, ?\DateTime $endTimeBefore = null, ?\Infobip\Model\CallDirection $direction = null, ?\Infobip\Model\CallEndpointType $endpointType = null, int $page = 0, int $size = 20): Request + { + $allData = [ + 'callId' => $callId, + 'applicationId' => $applicationId, + 'endpointIdentifier' => $endpointIdentifier, + 'startTimeAfter' => $startTimeAfter, + 'endTimeBefore' => $endTimeBefore, + 'direction' => $direction, + 'endpointType' => $endpointType, + 'page' => $page, + 'size' => $size, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'callId' => [ + ], + 'applicationId' => [ + ], + 'endpointIdentifier' => [ + ], + 'startTimeAfter' => [ + ], + 'endTimeBefore' => [ + ], + 'direction' => [ + new Assert\Choice(['INBOUND','OUTBOUND',]), + ], + 'endpointType' => [ + new Assert\Choice(['PHONE','SIP','WEBRTC','VIBER',]), + ], + 'page' => [ + new Assert\GreaterThan(0), + ], + 'size' => [ + new Assert\LessThan(100), + new Assert\GreaterThan(1), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/recordings/calls'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // query params + if ($callId !== null) { + $queryParams['callId'] = $callId; + } + + // query params + if ($applicationId !== null) { + $queryParams['applicationId'] = $applicationId; + } + + // query params + if ($endpointIdentifier !== null) { + $queryParams['endpointIdentifier'] = $endpointIdentifier; + } + + // query params + if ($startTimeAfter !== null) { + $queryParams['startTimeAfter'] = $startTimeAfter; + } + + // query params + if ($endTimeBefore !== null) { + $queryParams['endTimeBefore'] = $endTimeBefore; + } + + // query params + if ($direction !== null) { + $queryParams['direction'] = $direction; + } + + // query params + if ($endpointType !== null) { + $queryParams['endpointType'] = $endpointType; + } + + // query params + if ($page !== null) { + $queryParams['page'] = $page; + } + + // query params + if ($size !== null) { + $queryParams['size'] = $size; + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'getCallsRecordings' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallRecordingPage|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function getCallsRecordingsResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallRecordingPage', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'getCallsRecordings' + */ + private function getCallsRecordingsApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation getConference + * + * Get conference + * + * @param string $conferenceId Conference ID. (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsConference|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function getConference(string $conferenceId) + { + $request = $this->getConferenceRequest($conferenceId); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->getConferenceResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->getConferenceApiException($exception); + } + } + + /** + * Operation getConferenceAsync + * + * Get conference + * + * @param string $conferenceId Conference ID. (required) + * + * @throws InvalidArgumentException + */ + public function getConferenceAsync(string $conferenceId): PromiseInterface + { + $request = $this->getConferenceRequest($conferenceId); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->getConferenceResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->getConferenceApiException($exception); + } + ); + } + + /** + * Create request for operation 'getConference' + * + * @param string $conferenceId Conference ID. (required) + * + * @throws InvalidArgumentException + */ + private function getConferenceRequest(string $conferenceId): Request + { + $allData = [ + 'conferenceId' => $conferenceId, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'conferenceId' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/conferences/{conferenceId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($conferenceId !== null) { + $resourcePath = str_replace( + '{' . 'conferenceId' . '}', + $this->objectSerializer->toPathValue($conferenceId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'getConference' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsConference|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function getConferenceResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsConference', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'getConference' + */ + private function getConferenceApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation getConferenceHistory + * + * Get conference history + * + * @param string $conferenceId Conference ID. (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsConferenceLog|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function getConferenceHistory(string $conferenceId) + { + $request = $this->getConferenceHistoryRequest($conferenceId); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->getConferenceHistoryResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->getConferenceHistoryApiException($exception); + } + } + + /** + * Operation getConferenceHistoryAsync + * + * Get conference history + * + * @param string $conferenceId Conference ID. (required) + * + * @throws InvalidArgumentException + */ + public function getConferenceHistoryAsync(string $conferenceId): PromiseInterface + { + $request = $this->getConferenceHistoryRequest($conferenceId); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->getConferenceHistoryResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->getConferenceHistoryApiException($exception); + } + ); + } + + /** + * Create request for operation 'getConferenceHistory' + * + * @param string $conferenceId Conference ID. (required) + * + * @throws InvalidArgumentException + */ + private function getConferenceHistoryRequest(string $conferenceId): Request + { + $allData = [ + 'conferenceId' => $conferenceId, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'conferenceId' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/conferences/{conferenceId}/history'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($conferenceId !== null) { + $resourcePath = str_replace( + '{' . 'conferenceId' . '}', + $this->objectSerializer->toPathValue($conferenceId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'getConferenceHistory' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsConferenceLog|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function getConferenceHistoryResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsConferenceLog', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'getConferenceHistory' + */ + private function getConferenceHistoryApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation getConferenceRecordings + * + * Get conference recordings + * + * @param string $conferenceId Conference ID. (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsConferenceRecording|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function getConferenceRecordings(string $conferenceId) + { + $request = $this->getConferenceRecordingsRequest($conferenceId); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->getConferenceRecordingsResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->getConferenceRecordingsApiException($exception); + } + } + + /** + * Operation getConferenceRecordingsAsync + * + * Get conference recordings + * + * @param string $conferenceId Conference ID. (required) + * + * @throws InvalidArgumentException + */ + public function getConferenceRecordingsAsync(string $conferenceId): PromiseInterface + { + $request = $this->getConferenceRecordingsRequest($conferenceId); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->getConferenceRecordingsResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->getConferenceRecordingsApiException($exception); + } + ); + } + + /** + * Create request for operation 'getConferenceRecordings' + * + * @param string $conferenceId Conference ID. (required) + * + * @throws InvalidArgumentException + */ + private function getConferenceRecordingsRequest(string $conferenceId): Request + { + $allData = [ + 'conferenceId' => $conferenceId, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'conferenceId' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/recordings/conferences/{conferenceId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($conferenceId !== null) { + $resourcePath = str_replace( + '{' . 'conferenceId' . '}', + $this->objectSerializer->toPathValue($conferenceId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'getConferenceRecordings' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsConferenceRecording|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function getConferenceRecordingsResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsConferenceRecording', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'getConferenceRecordings' + */ + private function getConferenceRecordingsApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation getConferences + * + * Get conferences + * + * @param null|string $name Conference name. (optional) + * @param null|string $callId Call ID. (optional) + * @param null|string $applicationId Application ID. (optional) + * @param null|\DateTime $startTimeAfter Date and time for when the conference has been created. Has the following format: `yyyy-MM-dd'T'HH:mm:ss.SSS+ZZZZ`. (optional) + * @param int $page Results page to retrieve (0..N). (optional, default to 0) + * @param int $size Number of records per page. (optional, default to 20) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsConferencePage|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function getConferences(?string $name = null, ?string $callId = null, ?string $applicationId = null, ?\DateTime $startTimeAfter = null, int $page = 0, int $size = 20) + { + $request = $this->getConferencesRequest($name, $callId, $applicationId, $startTimeAfter, $page, $size); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->getConferencesResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->getConferencesApiException($exception); + } + } + + /** + * Operation getConferencesAsync + * + * Get conferences + * + * @param null|string $name Conference name. (optional) + * @param null|string $callId Call ID. (optional) + * @param null|string $applicationId Application ID. (optional) + * @param null|\DateTime $startTimeAfter Date and time for when the conference has been created. Has the following format: `yyyy-MM-dd'T'HH:mm:ss.SSS+ZZZZ`. (optional) + * @param int $page Results page to retrieve (0..N). (optional, default to 0) + * @param int $size Number of records per page. (optional, default to 20) + * + * @throws InvalidArgumentException + */ + public function getConferencesAsync(?string $name = null, ?string $callId = null, ?string $applicationId = null, ?\DateTime $startTimeAfter = null, int $page = 0, int $size = 20): PromiseInterface + { + $request = $this->getConferencesRequest($name, $callId, $applicationId, $startTimeAfter, $page, $size); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->getConferencesResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->getConferencesApiException($exception); + } + ); + } + + /** + * Create request for operation 'getConferences' + * + * @param null|string $name Conference name. (optional) + * @param null|string $callId Call ID. (optional) + * @param null|string $applicationId Application ID. (optional) + * @param null|\DateTime $startTimeAfter Date and time for when the conference has been created. Has the following format: `yyyy-MM-dd'T'HH:mm:ss.SSS+ZZZZ`. (optional) + * @param int $page Results page to retrieve (0..N). (optional, default to 0) + * @param int $size Number of records per page. (optional, default to 20) + * + * @throws InvalidArgumentException + */ + private function getConferencesRequest(?string $name = null, ?string $callId = null, ?string $applicationId = null, ?\DateTime $startTimeAfter = null, int $page = 0, int $size = 20): Request + { + $allData = [ + 'name' => $name, + 'callId' => $callId, + 'applicationId' => $applicationId, + 'startTimeAfter' => $startTimeAfter, + 'page' => $page, + 'size' => $size, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'name' => [ + ], + 'callId' => [ + ], + 'applicationId' => [ + ], + 'startTimeAfter' => [ + ], + 'page' => [ + new Assert\GreaterThan(0), + ], + 'size' => [ + new Assert\LessThan(100), + new Assert\GreaterThan(1), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/conferences'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // query params + if ($name !== null) { + $queryParams['name'] = $name; + } + + // query params + if ($callId !== null) { + $queryParams['callId'] = $callId; + } + + // query params + if ($applicationId !== null) { + $queryParams['applicationId'] = $applicationId; + } + + // query params + if ($startTimeAfter !== null) { + $queryParams['startTimeAfter'] = $startTimeAfter; + } + + // query params + if ($page !== null) { + $queryParams['page'] = $page; + } + + // query params + if ($size !== null) { + $queryParams['size'] = $size; + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'getConferences' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsConferencePage|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function getConferencesResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsConferencePage', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'getConferences' + */ + private function getConferencesApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation getConferencesHistory + * + * Get conferences history + * + * @param null|string $name Conference name. (optional) + * @param null|string $callId Call ID. (optional) + * @param null|string $applicationId Application ID. (optional) + * @param null|\DateTime $startTimeAfter Date and time for when the conference has been created. Has the following format: `yyyy-MM-dd'T'HH:mm:ss.SSS+ZZZZ`. (optional) + * @param null|\DateTime $endTimeBefore Date and time for when the conference has been finished. Has the following format: `yyyy-MM-dd'T'HH:mm:ss.SSS+ZZZZ`. (optional) + * @param int $page Results page to retrieve (0..N). (optional, default to 0) + * @param int $size Number of records per page. (optional, default to 20) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsConferenceLogPage|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function getConferencesHistory(?string $name = null, ?string $callId = null, ?string $applicationId = null, ?\DateTime $startTimeAfter = null, ?\DateTime $endTimeBefore = null, int $page = 0, int $size = 20) + { + $request = $this->getConferencesHistoryRequest($name, $callId, $applicationId, $startTimeAfter, $endTimeBefore, $page, $size); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->getConferencesHistoryResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->getConferencesHistoryApiException($exception); + } + } + + /** + * Operation getConferencesHistoryAsync + * + * Get conferences history + * + * @param null|string $name Conference name. (optional) + * @param null|string $callId Call ID. (optional) + * @param null|string $applicationId Application ID. (optional) + * @param null|\DateTime $startTimeAfter Date and time for when the conference has been created. Has the following format: `yyyy-MM-dd'T'HH:mm:ss.SSS+ZZZZ`. (optional) + * @param null|\DateTime $endTimeBefore Date and time for when the conference has been finished. Has the following format: `yyyy-MM-dd'T'HH:mm:ss.SSS+ZZZZ`. (optional) + * @param int $page Results page to retrieve (0..N). (optional, default to 0) + * @param int $size Number of records per page. (optional, default to 20) + * + * @throws InvalidArgumentException + */ + public function getConferencesHistoryAsync(?string $name = null, ?string $callId = null, ?string $applicationId = null, ?\DateTime $startTimeAfter = null, ?\DateTime $endTimeBefore = null, int $page = 0, int $size = 20): PromiseInterface + { + $request = $this->getConferencesHistoryRequest($name, $callId, $applicationId, $startTimeAfter, $endTimeBefore, $page, $size); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->getConferencesHistoryResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->getConferencesHistoryApiException($exception); + } + ); + } + + /** + * Create request for operation 'getConferencesHistory' + * + * @param null|string $name Conference name. (optional) + * @param null|string $callId Call ID. (optional) + * @param null|string $applicationId Application ID. (optional) + * @param null|\DateTime $startTimeAfter Date and time for when the conference has been created. Has the following format: `yyyy-MM-dd'T'HH:mm:ss.SSS+ZZZZ`. (optional) + * @param null|\DateTime $endTimeBefore Date and time for when the conference has been finished. Has the following format: `yyyy-MM-dd'T'HH:mm:ss.SSS+ZZZZ`. (optional) + * @param int $page Results page to retrieve (0..N). (optional, default to 0) + * @param int $size Number of records per page. (optional, default to 20) + * + * @throws InvalidArgumentException + */ + private function getConferencesHistoryRequest(?string $name = null, ?string $callId = null, ?string $applicationId = null, ?\DateTime $startTimeAfter = null, ?\DateTime $endTimeBefore = null, int $page = 0, int $size = 20): Request + { + $allData = [ + 'name' => $name, + 'callId' => $callId, + 'applicationId' => $applicationId, + 'startTimeAfter' => $startTimeAfter, + 'endTimeBefore' => $endTimeBefore, + 'page' => $page, + 'size' => $size, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'name' => [ + ], + 'callId' => [ + ], + 'applicationId' => [ + ], + 'startTimeAfter' => [ + ], + 'endTimeBefore' => [ + ], + 'page' => [ + new Assert\GreaterThan(0), + ], + 'size' => [ + new Assert\LessThan(100), + new Assert\GreaterThan(1), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/conferences/history'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // query params + if ($name !== null) { + $queryParams['name'] = $name; + } + + // query params + if ($callId !== null) { + $queryParams['callId'] = $callId; + } + + // query params + if ($applicationId !== null) { + $queryParams['applicationId'] = $applicationId; + } + + // query params + if ($startTimeAfter !== null) { + $queryParams['startTimeAfter'] = $startTimeAfter; + } + + // query params + if ($endTimeBefore !== null) { + $queryParams['endTimeBefore'] = $endTimeBefore; + } + + // query params + if ($page !== null) { + $queryParams['page'] = $page; + } + + // query params + if ($size !== null) { + $queryParams['size'] = $size; + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'getConferencesHistory' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsConferenceLogPage|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function getConferencesHistoryResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsConferenceLogPage', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'getConferencesHistory' + */ + private function getConferencesHistoryApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation getConferencesRecordings + * + * Get conferences recordings + * + * @param null|string $conferenceId Conference ID. (optional) + * @param null|string $applicationId Application ID. (optional) + * @param null|string $conferenceName Conference name. (optional) + * @param null|string $callId Filter all conference recordings where call ID was included in the recording. (optional) + * @param null|\DateTime $startTimeAfter Date and time when the (first) conference recording started. (optional) + * @param null|\DateTime $endTimeBefore Date and time when the (last) conference recording ended. (optional) + * @param null|bool $composition Flag indicating whether auto-compose feature was turned on for the recording. (optional) + * @param int $page Results page to retrieve (0..N). (optional, default to 0) + * @param int $size Number of records per page. (optional, default to 20) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsConferenceRecordingPage|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function getConferencesRecordings(?string $conferenceId = null, ?string $applicationId = null, ?string $conferenceName = null, ?string $callId = null, ?\DateTime $startTimeAfter = null, ?\DateTime $endTimeBefore = null, ?bool $composition = null, int $page = 0, int $size = 20) + { + $request = $this->getConferencesRecordingsRequest($conferenceId, $applicationId, $conferenceName, $callId, $startTimeAfter, $endTimeBefore, $composition, $page, $size); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->getConferencesRecordingsResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->getConferencesRecordingsApiException($exception); + } + } + + /** + * Operation getConferencesRecordingsAsync + * + * Get conferences recordings + * + * @param null|string $conferenceId Conference ID. (optional) + * @param null|string $applicationId Application ID. (optional) + * @param null|string $conferenceName Conference name. (optional) + * @param null|string $callId Filter all conference recordings where call ID was included in the recording. (optional) + * @param null|\DateTime $startTimeAfter Date and time when the (first) conference recording started. (optional) + * @param null|\DateTime $endTimeBefore Date and time when the (last) conference recording ended. (optional) + * @param null|bool $composition Flag indicating whether auto-compose feature was turned on for the recording. (optional) + * @param int $page Results page to retrieve (0..N). (optional, default to 0) + * @param int $size Number of records per page. (optional, default to 20) + * + * @throws InvalidArgumentException + */ + public function getConferencesRecordingsAsync(?string $conferenceId = null, ?string $applicationId = null, ?string $conferenceName = null, ?string $callId = null, ?\DateTime $startTimeAfter = null, ?\DateTime $endTimeBefore = null, ?bool $composition = null, int $page = 0, int $size = 20): PromiseInterface + { + $request = $this->getConferencesRecordingsRequest($conferenceId, $applicationId, $conferenceName, $callId, $startTimeAfter, $endTimeBefore, $composition, $page, $size); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->getConferencesRecordingsResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->getConferencesRecordingsApiException($exception); + } + ); + } + + /** + * Create request for operation 'getConferencesRecordings' + * + * @param null|string $conferenceId Conference ID. (optional) + * @param null|string $applicationId Application ID. (optional) + * @param null|string $conferenceName Conference name. (optional) + * @param null|string $callId Filter all conference recordings where call ID was included in the recording. (optional) + * @param null|\DateTime $startTimeAfter Date and time when the (first) conference recording started. (optional) + * @param null|\DateTime $endTimeBefore Date and time when the (last) conference recording ended. (optional) + * @param null|bool $composition Flag indicating whether auto-compose feature was turned on for the recording. (optional) + * @param int $page Results page to retrieve (0..N). (optional, default to 0) + * @param int $size Number of records per page. (optional, default to 20) + * + * @throws InvalidArgumentException + */ + private function getConferencesRecordingsRequest(?string $conferenceId = null, ?string $applicationId = null, ?string $conferenceName = null, ?string $callId = null, ?\DateTime $startTimeAfter = null, ?\DateTime $endTimeBefore = null, ?bool $composition = null, int $page = 0, int $size = 20): Request + { + $allData = [ + 'conferenceId' => $conferenceId, + 'applicationId' => $applicationId, + 'conferenceName' => $conferenceName, + 'callId' => $callId, + 'startTimeAfter' => $startTimeAfter, + 'endTimeBefore' => $endTimeBefore, + 'composition' => $composition, + 'page' => $page, + 'size' => $size, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'conferenceId' => [ + ], + 'applicationId' => [ + ], + 'conferenceName' => [ + ], + 'callId' => [ + ], + 'startTimeAfter' => [ + ], + 'endTimeBefore' => [ + ], + 'composition' => [ + ], + 'page' => [ + new Assert\GreaterThan(0), + ], + 'size' => [ + new Assert\LessThan(100), + new Assert\GreaterThan(1), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/recordings/conferences'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // query params + if ($conferenceId !== null) { + $queryParams['conferenceId'] = $conferenceId; + } + + // query params + if ($applicationId !== null) { + $queryParams['applicationId'] = $applicationId; + } + + // query params + if ($conferenceName !== null) { + $queryParams['conferenceName'] = $conferenceName; + } + + // query params + if ($callId !== null) { + $queryParams['callId'] = $callId; + } + + // query params + if ($startTimeAfter !== null) { + $queryParams['startTimeAfter'] = $startTimeAfter; + } + + // query params + if ($endTimeBefore !== null) { + $queryParams['endTimeBefore'] = $endTimeBefore; + } + + // query params + if ($composition !== null) { + $queryParams['composition'] = $composition; + } + + // query params + if ($page !== null) { + $queryParams['page'] = $page; + } + + // query params + if ($size !== null) { + $queryParams['size'] = $size; + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'getConferencesRecordings' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsConferenceRecordingPage|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function getConferencesRecordingsResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsConferenceRecordingPage', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'getConferencesRecordings' + */ + private function getConferencesRecordingsApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation getDialog + * + * Get dialog + * + * @param string $dialogId Dialog ID. (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsDialogResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function getDialog(string $dialogId) + { + $request = $this->getDialogRequest($dialogId); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->getDialogResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->getDialogApiException($exception); + } + } + + /** + * Operation getDialogAsync + * + * Get dialog + * + * @param string $dialogId Dialog ID. (required) + * + * @throws InvalidArgumentException + */ + public function getDialogAsync(string $dialogId): PromiseInterface + { + $request = $this->getDialogRequest($dialogId); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->getDialogResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->getDialogApiException($exception); + } + ); + } + + /** + * Create request for operation 'getDialog' + * + * @param string $dialogId Dialog ID. (required) + * + * @throws InvalidArgumentException + */ + private function getDialogRequest(string $dialogId): Request + { + $allData = [ + 'dialogId' => $dialogId, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'dialogId' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/dialogs/{dialogId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($dialogId !== null) { + $resourcePath = str_replace( + '{' . 'dialogId' . '}', + $this->objectSerializer->toPathValue($dialogId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'getDialog' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsDialogResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function getDialogResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsDialogResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'getDialog' + */ + private function getDialogApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation getDialogHistory + * + * Get dialog history + * + * @param string $dialogId Dialog ID. (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsDialogLogResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function getDialogHistory(string $dialogId) + { + $request = $this->getDialogHistoryRequest($dialogId); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->getDialogHistoryResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->getDialogHistoryApiException($exception); + } + } + + /** + * Operation getDialogHistoryAsync + * + * Get dialog history + * + * @param string $dialogId Dialog ID. (required) + * + * @throws InvalidArgumentException + */ + public function getDialogHistoryAsync(string $dialogId): PromiseInterface + { + $request = $this->getDialogHistoryRequest($dialogId); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->getDialogHistoryResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->getDialogHistoryApiException($exception); + } + ); + } + + /** + * Create request for operation 'getDialogHistory' + * + * @param string $dialogId Dialog ID. (required) + * + * @throws InvalidArgumentException + */ + private function getDialogHistoryRequest(string $dialogId): Request + { + $allData = [ + 'dialogId' => $dialogId, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'dialogId' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/dialogs/{dialogId}/history'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($dialogId !== null) { + $resourcePath = str_replace( + '{' . 'dialogId' . '}', + $this->objectSerializer->toPathValue($dialogId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'getDialogHistory' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsDialogLogResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function getDialogHistoryResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsDialogLogResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'getDialogHistory' + */ + private function getDialogHistoryApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation getDialogRecordings + * + * Get dialog recordings + * + * @param string $dialogId Dialog ID. (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsDialogRecordingResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function getDialogRecordings(string $dialogId) + { + $request = $this->getDialogRecordingsRequest($dialogId); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->getDialogRecordingsResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->getDialogRecordingsApiException($exception); + } + } + + /** + * Operation getDialogRecordingsAsync + * + * Get dialog recordings + * + * @param string $dialogId Dialog ID. (required) + * + * @throws InvalidArgumentException + */ + public function getDialogRecordingsAsync(string $dialogId): PromiseInterface + { + $request = $this->getDialogRecordingsRequest($dialogId); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->getDialogRecordingsResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->getDialogRecordingsApiException($exception); + } + ); + } + + /** + * Create request for operation 'getDialogRecordings' + * + * @param string $dialogId Dialog ID. (required) + * + * @throws InvalidArgumentException + */ + private function getDialogRecordingsRequest(string $dialogId): Request + { + $allData = [ + 'dialogId' => $dialogId, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'dialogId' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/recordings/dialogs/{dialogId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($dialogId !== null) { + $resourcePath = str_replace( + '{' . 'dialogId' . '}', + $this->objectSerializer->toPathValue($dialogId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'getDialogRecordings' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsDialogRecordingResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function getDialogRecordingsResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsDialogRecordingResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'getDialogRecordings' + */ + private function getDialogRecordingsApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation getDialogs + * + * Get dialogs + * + * @param null|string $applicationId Application ID. (optional) + * @param null|\Infobip\Model\CallsDialogState $state Dialog state. (optional) + * @param null|string $parentCallId Parent call ID. (optional) + * @param null|string $childCallId Child call ID. (optional) + * @param null|\DateTime $startTimeAfter Date and time for when the dialog has been created. Has the following format: `yyyy-MM-dd'T'HH:mm:ss.SSS+ZZZZ`. (optional) + * @param int $page Results page to retrieve (0..N). (optional, default to 0) + * @param int $size Number of records per page. (optional, default to 20) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsDialogPage|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function getDialogs(?string $applicationId = null, ?\Infobip\Model\CallsDialogState $state = null, ?string $parentCallId = null, ?string $childCallId = null, ?\DateTime $startTimeAfter = null, int $page = 0, int $size = 20) + { + $request = $this->getDialogsRequest($applicationId, $state, $parentCallId, $childCallId, $startTimeAfter, $page, $size); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->getDialogsResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->getDialogsApiException($exception); + } + } + + /** + * Operation getDialogsAsync + * + * Get dialogs + * + * @param null|string $applicationId Application ID. (optional) + * @param null|\Infobip\Model\CallsDialogState $state Dialog state. (optional) + * @param null|string $parentCallId Parent call ID. (optional) + * @param null|string $childCallId Child call ID. (optional) + * @param null|\DateTime $startTimeAfter Date and time for when the dialog has been created. Has the following format: `yyyy-MM-dd'T'HH:mm:ss.SSS+ZZZZ`. (optional) + * @param int $page Results page to retrieve (0..N). (optional, default to 0) + * @param int $size Number of records per page. (optional, default to 20) + * + * @throws InvalidArgumentException + */ + public function getDialogsAsync(?string $applicationId = null, ?\Infobip\Model\CallsDialogState $state = null, ?string $parentCallId = null, ?string $childCallId = null, ?\DateTime $startTimeAfter = null, int $page = 0, int $size = 20): PromiseInterface + { + $request = $this->getDialogsRequest($applicationId, $state, $parentCallId, $childCallId, $startTimeAfter, $page, $size); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->getDialogsResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->getDialogsApiException($exception); + } + ); + } + + /** + * Create request for operation 'getDialogs' + * + * @param null|string $applicationId Application ID. (optional) + * @param null|\Infobip\Model\CallsDialogState $state Dialog state. (optional) + * @param null|string $parentCallId Parent call ID. (optional) + * @param null|string $childCallId Child call ID. (optional) + * @param null|\DateTime $startTimeAfter Date and time for when the dialog has been created. Has the following format: `yyyy-MM-dd'T'HH:mm:ss.SSS+ZZZZ`. (optional) + * @param int $page Results page to retrieve (0..N). (optional, default to 0) + * @param int $size Number of records per page. (optional, default to 20) + * + * @throws InvalidArgumentException + */ + private function getDialogsRequest(?string $applicationId = null, ?\Infobip\Model\CallsDialogState $state = null, ?string $parentCallId = null, ?string $childCallId = null, ?\DateTime $startTimeAfter = null, int $page = 0, int $size = 20): Request + { + $allData = [ + 'applicationId' => $applicationId, + 'state' => $state, + 'parentCallId' => $parentCallId, + 'childCallId' => $childCallId, + 'startTimeAfter' => $startTimeAfter, + 'page' => $page, + 'size' => $size, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'applicationId' => [ + ], + 'state' => [ + new Assert\Choice(['CREATED','ESTABLISHED','FINISHED','FAILED',]), + ], + 'parentCallId' => [ + ], + 'childCallId' => [ + ], + 'startTimeAfter' => [ + ], + 'page' => [ + new Assert\GreaterThan(0), + ], + 'size' => [ + new Assert\LessThan(100), + new Assert\GreaterThan(1), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/dialogs'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // query params + if ($applicationId !== null) { + $queryParams['applicationId'] = $applicationId; + } + + // query params + if ($state !== null) { + $queryParams['state'] = $state; + } + + // query params + if ($parentCallId !== null) { + $queryParams['parentCallId'] = $parentCallId; + } + + // query params + if ($childCallId !== null) { + $queryParams['childCallId'] = $childCallId; + } + + // query params + if ($startTimeAfter !== null) { + $queryParams['startTimeAfter'] = $startTimeAfter; + } + + // query params + if ($page !== null) { + $queryParams['page'] = $page; + } + + // query params + if ($size !== null) { + $queryParams['size'] = $size; + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'getDialogs' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsDialogPage|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function getDialogsResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsDialogPage', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'getDialogs' + */ + private function getDialogsApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation getDialogsHistory + * + * Get dialogs history + * + * @param null|string $applicationId Application ID. (optional) + * @param null|\Infobip\Model\CallsDialogState $state Dialog state. (optional) + * @param null|string $parentCallId Parent call ID. (optional) + * @param null|string $childCallId Child call ID. (optional) + * @param null|\DateTime $startTimeAfter Date and time for when the dialog has been created. Has the following format: `yyyy-MM-dd'T'HH:mm:ss.SSS+ZZZZ`. (optional) + * @param null|\DateTime $endTimeBefore Date and time for when the dialog has been finished. Has the following format: `yyyy-MM-dd'T'HH:mm:ss.SSS+ZZZZ`. (optional) + * @param int $page Results page to retrieve (0..N). (optional, default to 0) + * @param int $size Number of records per page. (optional, default to 20) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsDialogLogPage|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function getDialogsHistory(?string $applicationId = null, ?\Infobip\Model\CallsDialogState $state = null, ?string $parentCallId = null, ?string $childCallId = null, ?\DateTime $startTimeAfter = null, ?\DateTime $endTimeBefore = null, int $page = 0, int $size = 20) + { + $request = $this->getDialogsHistoryRequest($applicationId, $state, $parentCallId, $childCallId, $startTimeAfter, $endTimeBefore, $page, $size); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->getDialogsHistoryResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->getDialogsHistoryApiException($exception); + } + } + + /** + * Operation getDialogsHistoryAsync + * + * Get dialogs history + * + * @param null|string $applicationId Application ID. (optional) + * @param null|\Infobip\Model\CallsDialogState $state Dialog state. (optional) + * @param null|string $parentCallId Parent call ID. (optional) + * @param null|string $childCallId Child call ID. (optional) + * @param null|\DateTime $startTimeAfter Date and time for when the dialog has been created. Has the following format: `yyyy-MM-dd'T'HH:mm:ss.SSS+ZZZZ`. (optional) + * @param null|\DateTime $endTimeBefore Date and time for when the dialog has been finished. Has the following format: `yyyy-MM-dd'T'HH:mm:ss.SSS+ZZZZ`. (optional) + * @param int $page Results page to retrieve (0..N). (optional, default to 0) + * @param int $size Number of records per page. (optional, default to 20) + * + * @throws InvalidArgumentException + */ + public function getDialogsHistoryAsync(?string $applicationId = null, ?\Infobip\Model\CallsDialogState $state = null, ?string $parentCallId = null, ?string $childCallId = null, ?\DateTime $startTimeAfter = null, ?\DateTime $endTimeBefore = null, int $page = 0, int $size = 20): PromiseInterface + { + $request = $this->getDialogsHistoryRequest($applicationId, $state, $parentCallId, $childCallId, $startTimeAfter, $endTimeBefore, $page, $size); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->getDialogsHistoryResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->getDialogsHistoryApiException($exception); + } + ); + } + + /** + * Create request for operation 'getDialogsHistory' + * + * @param null|string $applicationId Application ID. (optional) + * @param null|\Infobip\Model\CallsDialogState $state Dialog state. (optional) + * @param null|string $parentCallId Parent call ID. (optional) + * @param null|string $childCallId Child call ID. (optional) + * @param null|\DateTime $startTimeAfter Date and time for when the dialog has been created. Has the following format: `yyyy-MM-dd'T'HH:mm:ss.SSS+ZZZZ`. (optional) + * @param null|\DateTime $endTimeBefore Date and time for when the dialog has been finished. Has the following format: `yyyy-MM-dd'T'HH:mm:ss.SSS+ZZZZ`. (optional) + * @param int $page Results page to retrieve (0..N). (optional, default to 0) + * @param int $size Number of records per page. (optional, default to 20) + * + * @throws InvalidArgumentException + */ + private function getDialogsHistoryRequest(?string $applicationId = null, ?\Infobip\Model\CallsDialogState $state = null, ?string $parentCallId = null, ?string $childCallId = null, ?\DateTime $startTimeAfter = null, ?\DateTime $endTimeBefore = null, int $page = 0, int $size = 20): Request + { + $allData = [ + 'applicationId' => $applicationId, + 'state' => $state, + 'parentCallId' => $parentCallId, + 'childCallId' => $childCallId, + 'startTimeAfter' => $startTimeAfter, + 'endTimeBefore' => $endTimeBefore, + 'page' => $page, + 'size' => $size, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'applicationId' => [ + ], + 'state' => [ + new Assert\Choice(['CREATED','ESTABLISHED','FINISHED','FAILED',]), + ], + 'parentCallId' => [ + ], + 'childCallId' => [ + ], + 'startTimeAfter' => [ + ], + 'endTimeBefore' => [ + ], + 'page' => [ + new Assert\GreaterThan(0), + ], + 'size' => [ + new Assert\LessThan(100), + new Assert\GreaterThan(1), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/dialogs/history'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // query params + if ($applicationId !== null) { + $queryParams['applicationId'] = $applicationId; + } + + // query params + if ($state !== null) { + $queryParams['state'] = $state; + } + + // query params + if ($parentCallId !== null) { + $queryParams['parentCallId'] = $parentCallId; + } + + // query params + if ($childCallId !== null) { + $queryParams['childCallId'] = $childCallId; + } + + // query params + if ($startTimeAfter !== null) { + $queryParams['startTimeAfter'] = $startTimeAfter; + } + + // query params + if ($endTimeBefore !== null) { + $queryParams['endTimeBefore'] = $endTimeBefore; + } + + // query params + if ($page !== null) { + $queryParams['page'] = $page; + } + + // query params + if ($size !== null) { + $queryParams['size'] = $size; + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'getDialogsHistory' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsDialogLogPage|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function getDialogsHistoryResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsDialogLogPage', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'getDialogsHistory' + */ + private function getDialogsHistoryApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation getDialogsRecordings + * + * Get dialogs recordings + * + * @param null|string $dialogId Dialog ID. (optional) + * @param null|string $applicationId Application ID. (optional) + * @param null|string $callId Filter all dialog recordings where call ID was included in the recording. (optional) + * @param null|\DateTime $startTimeAfter Date and time when the (first) dialog recording started. (optional) + * @param null|\DateTime $endTimeBefore Date and time when the (last) dialog recording ended. (optional) + * @param null|bool $composition Flag indicating whether auto-compose feature was turned on for the recording. (optional) + * @param int $page Results page to retrieve (0..N). (optional, default to 0) + * @param int $size Number of records per page. (optional, default to 20) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsDialogRecordingPage|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function getDialogsRecordings(?string $dialogId = null, ?string $applicationId = null, ?string $callId = null, ?\DateTime $startTimeAfter = null, ?\DateTime $endTimeBefore = null, ?bool $composition = null, int $page = 0, int $size = 20) + { + $request = $this->getDialogsRecordingsRequest($dialogId, $applicationId, $callId, $startTimeAfter, $endTimeBefore, $composition, $page, $size); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->getDialogsRecordingsResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->getDialogsRecordingsApiException($exception); + } + } + + /** + * Operation getDialogsRecordingsAsync + * + * Get dialogs recordings + * + * @param null|string $dialogId Dialog ID. (optional) + * @param null|string $applicationId Application ID. (optional) + * @param null|string $callId Filter all dialog recordings where call ID was included in the recording. (optional) + * @param null|\DateTime $startTimeAfter Date and time when the (first) dialog recording started. (optional) + * @param null|\DateTime $endTimeBefore Date and time when the (last) dialog recording ended. (optional) + * @param null|bool $composition Flag indicating whether auto-compose feature was turned on for the recording. (optional) + * @param int $page Results page to retrieve (0..N). (optional, default to 0) + * @param int $size Number of records per page. (optional, default to 20) + * + * @throws InvalidArgumentException + */ + public function getDialogsRecordingsAsync(?string $dialogId = null, ?string $applicationId = null, ?string $callId = null, ?\DateTime $startTimeAfter = null, ?\DateTime $endTimeBefore = null, ?bool $composition = null, int $page = 0, int $size = 20): PromiseInterface + { + $request = $this->getDialogsRecordingsRequest($dialogId, $applicationId, $callId, $startTimeAfter, $endTimeBefore, $composition, $page, $size); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->getDialogsRecordingsResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->getDialogsRecordingsApiException($exception); + } + ); + } + + /** + * Create request for operation 'getDialogsRecordings' + * + * @param null|string $dialogId Dialog ID. (optional) + * @param null|string $applicationId Application ID. (optional) + * @param null|string $callId Filter all dialog recordings where call ID was included in the recording. (optional) + * @param null|\DateTime $startTimeAfter Date and time when the (first) dialog recording started. (optional) + * @param null|\DateTime $endTimeBefore Date and time when the (last) dialog recording ended. (optional) + * @param null|bool $composition Flag indicating whether auto-compose feature was turned on for the recording. (optional) + * @param int $page Results page to retrieve (0..N). (optional, default to 0) + * @param int $size Number of records per page. (optional, default to 20) + * + * @throws InvalidArgumentException + */ + private function getDialogsRecordingsRequest(?string $dialogId = null, ?string $applicationId = null, ?string $callId = null, ?\DateTime $startTimeAfter = null, ?\DateTime $endTimeBefore = null, ?bool $composition = null, int $page = 0, int $size = 20): Request + { + $allData = [ + 'dialogId' => $dialogId, + 'applicationId' => $applicationId, + 'callId' => $callId, + 'startTimeAfter' => $startTimeAfter, + 'endTimeBefore' => $endTimeBefore, + 'composition' => $composition, + 'page' => $page, + 'size' => $size, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'dialogId' => [ + ], + 'applicationId' => [ + ], + 'callId' => [ + ], + 'startTimeAfter' => [ + ], + 'endTimeBefore' => [ + ], + 'composition' => [ + ], + 'page' => [ + new Assert\GreaterThan(0), + ], + 'size' => [ + new Assert\LessThan(100), + new Assert\GreaterThan(1), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/recordings/dialogs'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // query params + if ($dialogId !== null) { + $queryParams['dialogId'] = $dialogId; + } + + // query params + if ($applicationId !== null) { + $queryParams['applicationId'] = $applicationId; + } + + // query params + if ($callId !== null) { + $queryParams['callId'] = $callId; + } + + // query params + if ($startTimeAfter !== null) { + $queryParams['startTimeAfter'] = $startTimeAfter; + } + + // query params + if ($endTimeBefore !== null) { + $queryParams['endTimeBefore'] = $endTimeBefore; + } + + // query params + if ($composition !== null) { + $queryParams['composition'] = $composition; + } + + // query params + if ($page !== null) { + $queryParams['page'] = $page; + } + + // query params + if ($size !== null) { + $queryParams['size'] = $size; + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'getDialogsRecordings' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsDialogRecordingPage|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function getDialogsRecordingsResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsDialogRecordingPage', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'getDialogsRecordings' + */ + private function getDialogsRecordingsApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation getMediaStreamConfig + * + * Get media-stream configuration + * + * @param string $mediaStreamConfigId Media-stream configuration ID. (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsMediaStreamConfigResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function getMediaStreamConfig(string $mediaStreamConfigId) + { + $request = $this->getMediaStreamConfigRequest($mediaStreamConfigId); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->getMediaStreamConfigResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->getMediaStreamConfigApiException($exception); + } + } + + /** + * Operation getMediaStreamConfigAsync + * + * Get media-stream configuration + * + * @param string $mediaStreamConfigId Media-stream configuration ID. (required) + * + * @throws InvalidArgumentException + */ + public function getMediaStreamConfigAsync(string $mediaStreamConfigId): PromiseInterface + { + $request = $this->getMediaStreamConfigRequest($mediaStreamConfigId); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->getMediaStreamConfigResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->getMediaStreamConfigApiException($exception); + } + ); + } + + /** + * Create request for operation 'getMediaStreamConfig' + * + * @param string $mediaStreamConfigId Media-stream configuration ID. (required) + * + * @throws InvalidArgumentException + */ + private function getMediaStreamConfigRequest(string $mediaStreamConfigId): Request + { + $allData = [ + 'mediaStreamConfigId' => $mediaStreamConfigId, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'mediaStreamConfigId' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/media-stream-configs/{mediaStreamConfigId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($mediaStreamConfigId !== null) { + $resourcePath = str_replace( + '{' . 'mediaStreamConfigId' . '}', + $this->objectSerializer->toPathValue($mediaStreamConfigId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'getMediaStreamConfig' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsMediaStreamConfigResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function getMediaStreamConfigResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsMediaStreamConfigResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'getMediaStreamConfig' + */ + private function getMediaStreamConfigApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation getMediaStreamConfigs + * + * Get media-stream configs + * + * @param int $page Results page to retrieve (0..N). (optional, default to 0) + * @param int $size Number of records per page. (optional, default to 20) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsMediaStreamConfigPage|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function getMediaStreamConfigs(int $page = 0, int $size = 20) + { + $request = $this->getMediaStreamConfigsRequest($page, $size); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->getMediaStreamConfigsResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->getMediaStreamConfigsApiException($exception); + } + } + + /** + * Operation getMediaStreamConfigsAsync + * + * Get media-stream configs + * + * @param int $page Results page to retrieve (0..N). (optional, default to 0) + * @param int $size Number of records per page. (optional, default to 20) + * + * @throws InvalidArgumentException + */ + public function getMediaStreamConfigsAsync(int $page = 0, int $size = 20): PromiseInterface + { + $request = $this->getMediaStreamConfigsRequest($page, $size); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->getMediaStreamConfigsResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->getMediaStreamConfigsApiException($exception); + } + ); + } + + /** + * Create request for operation 'getMediaStreamConfigs' + * + * @param int $page Results page to retrieve (0..N). (optional, default to 0) + * @param int $size Number of records per page. (optional, default to 20) + * + * @throws InvalidArgumentException + */ + private function getMediaStreamConfigsRequest(int $page = 0, int $size = 20): Request + { + $allData = [ + 'page' => $page, + 'size' => $size, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'page' => [ + new Assert\GreaterThan(0), + ], + 'size' => [ + new Assert\LessThan(100), + new Assert\GreaterThan(1), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/media-stream-configs'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // query params + if ($page !== null) { + $queryParams['page'] = $page; + } + + // query params + if ($size !== null) { + $queryParams['size'] = $size; + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'getMediaStreamConfigs' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsMediaStreamConfigPage|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function getMediaStreamConfigsResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsMediaStreamConfigPage', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'getMediaStreamConfigs' + */ + private function getMediaStreamConfigsApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation hangupCall + * + * Hangup + * + * @param string $callId Call ID. (required) + * @param \Infobip\Model\CallsHangupRequest $callsHangupRequest callsHangupRequest (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\Call|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function hangupCall(string $callId, \Infobip\Model\CallsHangupRequest $callsHangupRequest) + { + $request = $this->hangupCallRequest($callId, $callsHangupRequest); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->hangupCallResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->hangupCallApiException($exception); + } + } + + /** + * Operation hangupCallAsync + * + * Hangup + * + * @param string $callId Call ID. (required) + * @param \Infobip\Model\CallsHangupRequest $callsHangupRequest (required) + * + * @throws InvalidArgumentException + */ + public function hangupCallAsync(string $callId, \Infobip\Model\CallsHangupRequest $callsHangupRequest): PromiseInterface + { + $request = $this->hangupCallRequest($callId, $callsHangupRequest); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->hangupCallResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->hangupCallApiException($exception); + } + ); + } + + /** + * Create request for operation 'hangupCall' + * + * @param string $callId Call ID. (required) + * @param \Infobip\Model\CallsHangupRequest $callsHangupRequest (required) + * + * @throws InvalidArgumentException + */ + private function hangupCallRequest(string $callId, \Infobip\Model\CallsHangupRequest $callsHangupRequest): Request + { + $allData = [ + 'callId' => $callId, + 'callsHangupRequest' => $callsHangupRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'callId' => [ + new Assert\NotBlank(), + ], + 'callsHangupRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/calls/{callId}/hangup'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($callId !== null) { + $resourcePath = str_replace( + '{' . 'callId' . '}', + $this->objectSerializer->toPathValue($callId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($callsHangupRequest)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($callsHangupRequest) + : $callsHangupRequest; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'hangupCall' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\Call|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function hangupCallResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\Call', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'hangupCall' + */ + private function hangupCallApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation hangupConference + * + * Hangup conference + * + * @param string $conferenceId Conference ID. (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsConference|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function hangupConference(string $conferenceId) + { + $request = $this->hangupConferenceRequest($conferenceId); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->hangupConferenceResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->hangupConferenceApiException($exception); + } + } + + /** + * Operation hangupConferenceAsync + * + * Hangup conference + * + * @param string $conferenceId Conference ID. (required) + * + * @throws InvalidArgumentException + */ + public function hangupConferenceAsync(string $conferenceId): PromiseInterface + { + $request = $this->hangupConferenceRequest($conferenceId); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->hangupConferenceResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->hangupConferenceApiException($exception); + } + ); + } + + /** + * Create request for operation 'hangupConference' + * + * @param string $conferenceId Conference ID. (required) + * + * @throws InvalidArgumentException + */ + private function hangupConferenceRequest(string $conferenceId): Request + { + $allData = [ + 'conferenceId' => $conferenceId, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'conferenceId' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/conferences/{conferenceId}/hangup'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($conferenceId !== null) { + $resourcePath = str_replace( + '{' . 'conferenceId' . '}', + $this->objectSerializer->toPathValue($conferenceId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'hangupConference' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsConference|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function hangupConferenceResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsConference', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'hangupConference' + */ + private function hangupConferenceApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation hangupDialog + * + * Hangup dialog + * + * @param string $dialogId Dialog ID. (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsDialogResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function hangupDialog(string $dialogId) + { + $request = $this->hangupDialogRequest($dialogId); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->hangupDialogResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->hangupDialogApiException($exception); + } + } + + /** + * Operation hangupDialogAsync + * + * Hangup dialog + * + * @param string $dialogId Dialog ID. (required) + * + * @throws InvalidArgumentException + */ + public function hangupDialogAsync(string $dialogId): PromiseInterface + { + $request = $this->hangupDialogRequest($dialogId); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->hangupDialogResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->hangupDialogApiException($exception); + } + ); + } + + /** + * Create request for operation 'hangupDialog' + * + * @param string $dialogId Dialog ID. (required) + * + * @throws InvalidArgumentException + */ + private function hangupDialogRequest(string $dialogId): Request + { + $allData = [ + 'dialogId' => $dialogId, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'dialogId' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/dialogs/{dialogId}/hangup'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($dialogId !== null) { + $resourcePath = str_replace( + '{' . 'dialogId' . '}', + $this->objectSerializer->toPathValue($dialogId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'hangupDialog' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsDialogResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function hangupDialogResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsDialogResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'hangupDialog' + */ + private function hangupDialogApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation pauseBulk + * + * Pause + * + * @param string $bulkId Bulk ID. (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallBulkStatus|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function pauseBulk(string $bulkId) + { + $request = $this->pauseBulkRequest($bulkId); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->pauseBulkResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->pauseBulkApiException($exception); + } + } + + /** + * Operation pauseBulkAsync + * + * Pause + * + * @param string $bulkId Bulk ID. (required) + * + * @throws InvalidArgumentException + */ + public function pauseBulkAsync(string $bulkId): PromiseInterface + { + $request = $this->pauseBulkRequest($bulkId); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->pauseBulkResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->pauseBulkApiException($exception); + } + ); + } + + /** + * Create request for operation 'pauseBulk' + * + * @param string $bulkId Bulk ID. (required) + * + * @throws InvalidArgumentException + */ + private function pauseBulkRequest(string $bulkId): Request + { + $allData = [ + 'bulkId' => $bulkId, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'bulkId' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/bulks/{bulkId}/pause'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($bulkId !== null) { + $resourcePath = str_replace( + '{' . 'bulkId' . '}', + $this->objectSerializer->toPathValue($bulkId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'pauseBulk' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallBulkStatus|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function pauseBulkResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallBulkStatus', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'pauseBulk' + */ + private function pauseBulkApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation preAnswerCall + * + * Pre-answer + * + * @param string $callId Call ID. (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function preAnswerCall(string $callId) + { + $request = $this->preAnswerCallRequest($callId); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->preAnswerCallResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->preAnswerCallApiException($exception); + } + } + + /** + * Operation preAnswerCallAsync + * + * Pre-answer + * + * @param string $callId Call ID. (required) + * + * @throws InvalidArgumentException + */ + public function preAnswerCallAsync(string $callId): PromiseInterface + { + $request = $this->preAnswerCallRequest($callId); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->preAnswerCallResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->preAnswerCallApiException($exception); + } + ); + } + + /** + * Create request for operation 'preAnswerCall' + * + * @param string $callId Call ID. (required) + * + * @throws InvalidArgumentException + */ + private function preAnswerCallRequest(string $callId): Request + { + $allData = [ + 'callId' => $callId, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'callId' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/calls/{callId}/pre-answer'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($callId !== null) { + $resourcePath = str_replace( + '{' . 'callId' . '}', + $this->objectSerializer->toPathValue($callId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'preAnswerCall' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function preAnswerCallResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsActionResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'preAnswerCall' + */ + private function preAnswerCallApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation removeConferenceCall + * + * Remove call + * + * @param string $conferenceId Conference ID. (required) + * @param string $callId Call ID. (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function removeConferenceCall(string $conferenceId, string $callId) + { + $request = $this->removeConferenceCallRequest($conferenceId, $callId); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->removeConferenceCallResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->removeConferenceCallApiException($exception); + } + } + + /** + * Operation removeConferenceCallAsync + * + * Remove call + * + * @param string $conferenceId Conference ID. (required) + * @param string $callId Call ID. (required) + * + * @throws InvalidArgumentException + */ + public function removeConferenceCallAsync(string $conferenceId, string $callId): PromiseInterface + { + $request = $this->removeConferenceCallRequest($conferenceId, $callId); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->removeConferenceCallResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->removeConferenceCallApiException($exception); + } + ); + } + + /** + * Create request for operation 'removeConferenceCall' + * + * @param string $conferenceId Conference ID. (required) + * @param string $callId Call ID. (required) + * + * @throws InvalidArgumentException + */ + private function removeConferenceCallRequest(string $conferenceId, string $callId): Request + { + $allData = [ + 'conferenceId' => $conferenceId, + 'callId' => $callId, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'conferenceId' => [ + new Assert\NotBlank(), + ], + 'callId' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/conferences/{conferenceId}/call/{callId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($conferenceId !== null) { + $resourcePath = str_replace( + '{' . 'conferenceId' . '}', + $this->objectSerializer->toPathValue($conferenceId), + $resourcePath + ); + } + + // path params + if ($callId !== null) { + $resourcePath = str_replace( + '{' . 'callId' . '}', + $this->objectSerializer->toPathValue($callId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'DELETE', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'removeConferenceCall' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function removeConferenceCallResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsActionResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'removeConferenceCall' + */ + private function removeConferenceCallApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation rescheduleBulk + * + * Reschedule + * + * @param string $bulkId Bulk ID. (required) + * @param \Infobip\Model\CallsRescheduleRequest $callsRescheduleRequest callsRescheduleRequest (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallBulkStatus|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function rescheduleBulk(string $bulkId, \Infobip\Model\CallsRescheduleRequest $callsRescheduleRequest) + { + $request = $this->rescheduleBulkRequest($bulkId, $callsRescheduleRequest); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->rescheduleBulkResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->rescheduleBulkApiException($exception); + } + } + + /** + * Operation rescheduleBulkAsync + * + * Reschedule + * + * @param string $bulkId Bulk ID. (required) + * @param \Infobip\Model\CallsRescheduleRequest $callsRescheduleRequest (required) + * + * @throws InvalidArgumentException + */ + public function rescheduleBulkAsync(string $bulkId, \Infobip\Model\CallsRescheduleRequest $callsRescheduleRequest): PromiseInterface + { + $request = $this->rescheduleBulkRequest($bulkId, $callsRescheduleRequest); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->rescheduleBulkResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->rescheduleBulkApiException($exception); + } + ); + } + + /** + * Create request for operation 'rescheduleBulk' + * + * @param string $bulkId Bulk ID. (required) + * @param \Infobip\Model\CallsRescheduleRequest $callsRescheduleRequest (required) + * + * @throws InvalidArgumentException + */ + private function rescheduleBulkRequest(string $bulkId, \Infobip\Model\CallsRescheduleRequest $callsRescheduleRequest): Request + { + $allData = [ + 'bulkId' => $bulkId, + 'callsRescheduleRequest' => $callsRescheduleRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'bulkId' => [ + new Assert\NotBlank(), + ], + 'callsRescheduleRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/bulks/{bulkId}/reschedule'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($bulkId !== null) { + $resourcePath = str_replace( + '{' . 'bulkId' . '}', + $this->objectSerializer->toPathValue($bulkId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($callsRescheduleRequest)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($callsRescheduleRequest) + : $callsRescheduleRequest; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'rescheduleBulk' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallBulkStatus|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function rescheduleBulkResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallBulkStatus', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'rescheduleBulk' + */ + private function rescheduleBulkApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation resumeBulk + * + * Resume + * + * @param string $bulkId Bulk ID. (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallBulkStatus|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function resumeBulk(string $bulkId) + { + $request = $this->resumeBulkRequest($bulkId); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->resumeBulkResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->resumeBulkApiException($exception); + } + } + + /** + * Operation resumeBulkAsync + * + * Resume + * + * @param string $bulkId Bulk ID. (required) + * + * @throws InvalidArgumentException + */ + public function resumeBulkAsync(string $bulkId): PromiseInterface + { + $request = $this->resumeBulkRequest($bulkId); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->resumeBulkResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->resumeBulkApiException($exception); + } + ); + } + + /** + * Create request for operation 'resumeBulk' + * + * @param string $bulkId Bulk ID. (required) + * + * @throws InvalidArgumentException + */ + private function resumeBulkRequest(string $bulkId): Request + { + $allData = [ + 'bulkId' => $bulkId, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'bulkId' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/bulks/{bulkId}/resume'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($bulkId !== null) { + $resourcePath = str_replace( + '{' . 'bulkId' . '}', + $this->objectSerializer->toPathValue($bulkId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'resumeBulk' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallBulkStatus|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function resumeBulkResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallBulkStatus', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'resumeBulk' + */ + private function resumeBulkApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation sendRinging + * + * Send ringing + * + * @param string $callId Call ID. (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function sendRinging(string $callId) + { + $request = $this->sendRingingRequest($callId); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->sendRingingResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->sendRingingApiException($exception); + } + } + + /** + * Operation sendRingingAsync + * + * Send ringing + * + * @param string $callId Call ID. (required) + * + * @throws InvalidArgumentException + */ + public function sendRingingAsync(string $callId): PromiseInterface + { + $request = $this->sendRingingRequest($callId); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->sendRingingResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->sendRingingApiException($exception); + } + ); + } + + /** + * Create request for operation 'sendRinging' + * + * @param string $callId Call ID. (required) + * + * @throws InvalidArgumentException + */ + private function sendRingingRequest(string $callId): Request + { + $allData = [ + 'callId' => $callId, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'callId' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/calls/{callId}/send-ringing'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($callId !== null) { + $resourcePath = str_replace( + '{' . 'callId' . '}', + $this->objectSerializer->toPathValue($callId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'sendRinging' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function sendRingingResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsActionResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'sendRinging' + */ + private function sendRingingApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation startMediaStream + * + * Start streaming media + * + * @param string $callId Call ID. (required) + * @param \Infobip\Model\CallsStartMediaStreamRequest $callsStartMediaStreamRequest callsStartMediaStreamRequest (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function startMediaStream(string $callId, \Infobip\Model\CallsStartMediaStreamRequest $callsStartMediaStreamRequest) + { + $request = $this->startMediaStreamRequest($callId, $callsStartMediaStreamRequest); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->startMediaStreamResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->startMediaStreamApiException($exception); + } + } + + /** + * Operation startMediaStreamAsync + * + * Start streaming media + * + * @param string $callId Call ID. (required) + * @param \Infobip\Model\CallsStartMediaStreamRequest $callsStartMediaStreamRequest (required) + * + * @throws InvalidArgumentException + */ + public function startMediaStreamAsync(string $callId, \Infobip\Model\CallsStartMediaStreamRequest $callsStartMediaStreamRequest): PromiseInterface + { + $request = $this->startMediaStreamRequest($callId, $callsStartMediaStreamRequest); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->startMediaStreamResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->startMediaStreamApiException($exception); + } + ); + } + + /** + * Create request for operation 'startMediaStream' + * + * @param string $callId Call ID. (required) + * @param \Infobip\Model\CallsStartMediaStreamRequest $callsStartMediaStreamRequest (required) + * + * @throws InvalidArgumentException + */ + private function startMediaStreamRequest(string $callId, \Infobip\Model\CallsStartMediaStreamRequest $callsStartMediaStreamRequest): Request + { + $allData = [ + 'callId' => $callId, + 'callsStartMediaStreamRequest' => $callsStartMediaStreamRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'callId' => [ + new Assert\NotBlank(), + ], + 'callsStartMediaStreamRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/calls/{callId}/start-media-stream'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($callId !== null) { + $resourcePath = str_replace( + '{' . 'callId' . '}', + $this->objectSerializer->toPathValue($callId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($callsStartMediaStreamRequest)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($callsStartMediaStreamRequest) + : $callsStartMediaStreamRequest; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'startMediaStream' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function startMediaStreamResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsActionResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'startMediaStream' + */ + private function startMediaStreamApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation stopMediaStream + * + * Stop streaming media + * + * @param string $callId Call ID. (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function stopMediaStream(string $callId) + { + $request = $this->stopMediaStreamRequest($callId); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->stopMediaStreamResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->stopMediaStreamApiException($exception); + } + } + + /** + * Operation stopMediaStreamAsync + * + * Stop streaming media + * + * @param string $callId Call ID. (required) + * + * @throws InvalidArgumentException + */ + public function stopMediaStreamAsync(string $callId): PromiseInterface + { + $request = $this->stopMediaStreamRequest($callId); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->stopMediaStreamResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->stopMediaStreamApiException($exception); + } + ); + } + + /** + * Create request for operation 'stopMediaStream' + * + * @param string $callId Call ID. (required) + * + * @throws InvalidArgumentException + */ + private function stopMediaStreamRequest(string $callId): Request + { + $allData = [ + 'callId' => $callId, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'callId' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/calls/{callId}/stop-media-stream'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($callId !== null) { + $resourcePath = str_replace( + '{' . 'callId' . '}', + $this->objectSerializer->toPathValue($callId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'stopMediaStream' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function stopMediaStreamResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsActionResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'stopMediaStream' + */ + private function stopMediaStreamApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation updateConference + * + * Update all calls + * + * @param string $conferenceId Conference ID. (required) + * @param \Infobip\Model\CallsUpdateRequest $callsUpdateRequest callsUpdateRequest (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function updateConference(string $conferenceId, \Infobip\Model\CallsUpdateRequest $callsUpdateRequest) + { + $request = $this->updateConferenceRequest($conferenceId, $callsUpdateRequest); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->updateConferenceResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->updateConferenceApiException($exception); + } + } + + /** + * Operation updateConferenceAsync + * + * Update all calls + * + * @param string $conferenceId Conference ID. (required) + * @param \Infobip\Model\CallsUpdateRequest $callsUpdateRequest (required) + * + * @throws InvalidArgumentException + */ + public function updateConferenceAsync(string $conferenceId, \Infobip\Model\CallsUpdateRequest $callsUpdateRequest): PromiseInterface + { + $request = $this->updateConferenceRequest($conferenceId, $callsUpdateRequest); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->updateConferenceResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->updateConferenceApiException($exception); + } + ); + } + + /** + * Create request for operation 'updateConference' + * + * @param string $conferenceId Conference ID. (required) + * @param \Infobip\Model\CallsUpdateRequest $callsUpdateRequest (required) + * + * @throws InvalidArgumentException + */ + private function updateConferenceRequest(string $conferenceId, \Infobip\Model\CallsUpdateRequest $callsUpdateRequest): Request + { + $allData = [ + 'conferenceId' => $conferenceId, + 'callsUpdateRequest' => $callsUpdateRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'conferenceId' => [ + new Assert\NotBlank(), + ], + 'callsUpdateRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/conferences/{conferenceId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($conferenceId !== null) { + $resourcePath = str_replace( + '{' . 'conferenceId' . '}', + $this->objectSerializer->toPathValue($conferenceId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($callsUpdateRequest)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($callsUpdateRequest) + : $callsUpdateRequest; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'PATCH', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'updateConference' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function updateConferenceResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsActionResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'updateConference' + */ + private function updateConferenceApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation updateConferenceCall + * + * Update call + * + * @param string $conferenceId Conference ID. (required) + * @param string $callId Call ID. (required) + * @param \Infobip\Model\CallsUpdateRequest $callsUpdateRequest callsUpdateRequest (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function updateConferenceCall(string $conferenceId, string $callId, \Infobip\Model\CallsUpdateRequest $callsUpdateRequest) + { + $request = $this->updateConferenceCallRequest($conferenceId, $callId, $callsUpdateRequest); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->updateConferenceCallResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->updateConferenceCallApiException($exception); + } + } + + /** + * Operation updateConferenceCallAsync + * + * Update call + * + * @param string $conferenceId Conference ID. (required) + * @param string $callId Call ID. (required) + * @param \Infobip\Model\CallsUpdateRequest $callsUpdateRequest (required) + * + * @throws InvalidArgumentException + */ + public function updateConferenceCallAsync(string $conferenceId, string $callId, \Infobip\Model\CallsUpdateRequest $callsUpdateRequest): PromiseInterface + { + $request = $this->updateConferenceCallRequest($conferenceId, $callId, $callsUpdateRequest); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->updateConferenceCallResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->updateConferenceCallApiException($exception); + } + ); + } + + /** + * Create request for operation 'updateConferenceCall' + * + * @param string $conferenceId Conference ID. (required) + * @param string $callId Call ID. (required) + * @param \Infobip\Model\CallsUpdateRequest $callsUpdateRequest (required) + * + * @throws InvalidArgumentException + */ + private function updateConferenceCallRequest(string $conferenceId, string $callId, \Infobip\Model\CallsUpdateRequest $callsUpdateRequest): Request + { + $allData = [ + 'conferenceId' => $conferenceId, + 'callId' => $callId, + 'callsUpdateRequest' => $callsUpdateRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'conferenceId' => [ + new Assert\NotBlank(), + ], + 'callId' => [ + new Assert\NotBlank(), + ], + 'callsUpdateRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/conferences/{conferenceId}/call/{callId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($conferenceId !== null) { + $resourcePath = str_replace( + '{' . 'conferenceId' . '}', + $this->objectSerializer->toPathValue($conferenceId), + $resourcePath + ); + } + + // path params + if ($callId !== null) { + $resourcePath = str_replace( + '{' . 'callId' . '}', + $this->objectSerializer->toPathValue($callId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($callsUpdateRequest)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($callsUpdateRequest) + : $callsUpdateRequest; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'PATCH', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'updateConferenceCall' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsActionResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function updateConferenceCallResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsActionResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'updateConferenceCall' + */ + private function updateConferenceCallApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation updateMediaStreamConfig + * + * Update a media-stream configuration + * + * @param string $mediaStreamConfigId Media-stream configuration ID. (required) + * @param \Infobip\Model\CallsMediaStreamConfigRequest $callsMediaStreamConfigRequest callsMediaStreamConfigRequest (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsMediaStreamConfigResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function updateMediaStreamConfig(string $mediaStreamConfigId, \Infobip\Model\CallsMediaStreamConfigRequest $callsMediaStreamConfigRequest) + { + $request = $this->updateMediaStreamConfigRequest($mediaStreamConfigId, $callsMediaStreamConfigRequest); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->updateMediaStreamConfigResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->updateMediaStreamConfigApiException($exception); + } + } + + /** + * Operation updateMediaStreamConfigAsync + * + * Update a media-stream configuration + * + * @param string $mediaStreamConfigId Media-stream configuration ID. (required) + * @param \Infobip\Model\CallsMediaStreamConfigRequest $callsMediaStreamConfigRequest (required) + * + * @throws InvalidArgumentException + */ + public function updateMediaStreamConfigAsync(string $mediaStreamConfigId, \Infobip\Model\CallsMediaStreamConfigRequest $callsMediaStreamConfigRequest): PromiseInterface + { + $request = $this->updateMediaStreamConfigRequest($mediaStreamConfigId, $callsMediaStreamConfigRequest); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->updateMediaStreamConfigResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->updateMediaStreamConfigApiException($exception); + } + ); + } + + /** + * Create request for operation 'updateMediaStreamConfig' + * + * @param string $mediaStreamConfigId Media-stream configuration ID. (required) + * @param \Infobip\Model\CallsMediaStreamConfigRequest $callsMediaStreamConfigRequest (required) + * + * @throws InvalidArgumentException + */ + private function updateMediaStreamConfigRequest(string $mediaStreamConfigId, \Infobip\Model\CallsMediaStreamConfigRequest $callsMediaStreamConfigRequest): Request + { + $allData = [ + 'mediaStreamConfigId' => $mediaStreamConfigId, + 'callsMediaStreamConfigRequest' => $callsMediaStreamConfigRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'mediaStreamConfigId' => [ + new Assert\NotBlank(), + ], + 'callsMediaStreamConfigRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/media-stream-configs/{mediaStreamConfigId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($mediaStreamConfigId !== null) { + $resourcePath = str_replace( + '{' . 'mediaStreamConfigId' . '}', + $this->objectSerializer->toPathValue($mediaStreamConfigId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($callsMediaStreamConfigRequest)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($callsMediaStreamConfigRequest) + : $callsMediaStreamConfigRequest; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'PUT', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'updateMediaStreamConfig' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsMediaStreamConfigResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function updateMediaStreamConfigResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsMediaStreamConfigResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'updateMediaStreamConfig' + */ + private function updateMediaStreamConfigApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation uploadCallsAudioFile + * + * Upload audio file + * + * @param \SplFileObject $file file (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\CallsFile|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function uploadCallsAudioFile(\SplFileObject $file) + { + $request = $this->uploadCallsAudioFileRequest($file); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->uploadCallsAudioFileResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->uploadCallsAudioFileApiException($exception); + } + } + + /** + * Operation uploadCallsAudioFileAsync + * + * Upload audio file + * + * @param \SplFileObject $file (required) + * + * @throws InvalidArgumentException + */ + public function uploadCallsAudioFileAsync(\SplFileObject $file): PromiseInterface + { + $request = $this->uploadCallsAudioFileRequest($file); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->uploadCallsAudioFileResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->uploadCallsAudioFileApiException($exception); + } + ); + } + + /** + * Create request for operation 'uploadCallsAudioFile' + * + * @param \SplFileObject $file (required) + * + * @throws InvalidArgumentException + */ + private function uploadCallsAudioFileRequest(\SplFileObject $file): Request + { + $allData = [ + 'file' => $file, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'file' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/calls/1/files'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // form params + if ($file !== null) { + $formParams['file'] = []; + $paramFiles = is_array($file) ? $file : [$file]; + foreach ($paramFiles as $paramFile) { + $formParams['file'][] = Utils::tryFopen( + $this->objectSerializer->toFormValue($paramFile), + 'rb' + ); + } + } + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'multipart/form-data', + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'uploadCallsAudioFile' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\CallsFile|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function uploadCallsAudioFileResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsFile', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'uploadCallsAudioFile' + */ + private function uploadCallsAudioFileApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } +} diff --git a/Infobip/Api/ClickToCallApi.php b/Infobip/Api/ClickToCallApi.php new file mode 100644 index 0000000..3b2033b --- /dev/null +++ b/Infobip/Api/ClickToCallApi.php @@ -0,0 +1,328 @@ +config = $config; + $this->client = $client ?: new Client(); + $this->objectSerializer = $objectSerializer ?: new ObjectSerializer(); + $this->logger = $logger ?: new NullLogger(); + $this->deprecationChecker = $deprecationChecker ?: new DeprecationChecker($this->logger); + } + + /** + * Operation sendClickToCallMessage + * + * Send click-to-call message + * + * @param \Infobip\Model\CallsClickToCallMessageBody $callsClickToCallMessageBody callsClickToCallMessageBody (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\CallsVoiceResponse + */ + public function sendClickToCallMessage(\Infobip\Model\CallsClickToCallMessageBody $callsClickToCallMessageBody) + { + $request = $this->sendClickToCallMessageRequest($callsClickToCallMessageBody); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->sendClickToCallMessageResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->sendClickToCallMessageApiException($exception); + } + } + + /** + * Operation sendClickToCallMessageAsync + * + * Send click-to-call message + * + * @param \Infobip\Model\CallsClickToCallMessageBody $callsClickToCallMessageBody (required) + * + * @throws InvalidArgumentException + */ + public function sendClickToCallMessageAsync(\Infobip\Model\CallsClickToCallMessageBody $callsClickToCallMessageBody): PromiseInterface + { + $request = $this->sendClickToCallMessageRequest($callsClickToCallMessageBody); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->sendClickToCallMessageResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->sendClickToCallMessageApiException($exception); + } + ); + } + + /** + * Create request for operation 'sendClickToCallMessage' + * + * @param \Infobip\Model\CallsClickToCallMessageBody $callsClickToCallMessageBody (required) + * + * @throws InvalidArgumentException + */ + private function sendClickToCallMessageRequest(\Infobip\Model\CallsClickToCallMessageBody $callsClickToCallMessageBody): Request + { + $allData = [ + 'callsClickToCallMessageBody' => $callsClickToCallMessageBody, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'callsClickToCallMessageBody' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/voice/ctc/1/send'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($callsClickToCallMessageBody)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($callsClickToCallMessageBody) + : $callsClickToCallMessageBody; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'sendClickToCallMessage' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\CallsVoiceResponse|null + */ + private function sendClickToCallMessageResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsVoiceResponse', $responseHeaders); + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'sendClickToCallMessage' + */ + private function sendClickToCallMessageApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode >= 400 && $statusCode <= 499) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode >= 500 && $statusCode <= 599) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\CallsVoiceResponse', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } +} diff --git a/Infobip/Api/EmailApi.php b/Infobip/Api/EmailApi.php new file mode 100644 index 0000000..2104ab6 --- /dev/null +++ b/Infobip/Api/EmailApi.php @@ -0,0 +1,4927 @@ +config = $config; + $this->client = $client ?: new Client(); + $this->objectSerializer = $objectSerializer ?: new ObjectSerializer(); + $this->logger = $logger ?: new NullLogger(); + $this->deprecationChecker = $deprecationChecker ?: new DeprecationChecker($this->logger); + } + + /** + * Operation addDomain + * + * Add new domain + * + * @param \Infobip\Model\EmailAddDomainRequest $emailAddDomainRequest emailAddDomainRequest (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\EmailDomainResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function addDomain(\Infobip\Model\EmailAddDomainRequest $emailAddDomainRequest) + { + $request = $this->addDomainRequest($emailAddDomainRequest); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->addDomainResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->addDomainApiException($exception); + } + } + + /** + * Operation addDomainAsync + * + * Add new domain + * + * @param \Infobip\Model\EmailAddDomainRequest $emailAddDomainRequest (required) + * + * @throws InvalidArgumentException + */ + public function addDomainAsync(\Infobip\Model\EmailAddDomainRequest $emailAddDomainRequest): PromiseInterface + { + $request = $this->addDomainRequest($emailAddDomainRequest); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->addDomainResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->addDomainApiException($exception); + } + ); + } + + /** + * Create request for operation 'addDomain' + * + * @param \Infobip\Model\EmailAddDomainRequest $emailAddDomainRequest (required) + * + * @throws InvalidArgumentException + */ + private function addDomainRequest(\Infobip\Model\EmailAddDomainRequest $emailAddDomainRequest): Request + { + $allData = [ + 'emailAddDomainRequest' => $emailAddDomainRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'emailAddDomainRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/email/1/domains'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($emailAddDomainRequest)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($emailAddDomainRequest) + : $emailAddDomainRequest; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'addDomain' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\EmailDomainResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function addDomainResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\EmailDomainResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'addDomain' + */ + private function addDomainApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 409) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation assignIpToDomain + * + * Assign dedicated ip address to the provided domain for the account id + * + * @param \Infobip\Model\EmailDomainIpRequest $emailDomainIpRequest emailDomainIpRequest (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\EmailSimpleApiResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function assignIpToDomain(\Infobip\Model\EmailDomainIpRequest $emailDomainIpRequest) + { + $request = $this->assignIpToDomainRequest($emailDomainIpRequest); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->assignIpToDomainResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->assignIpToDomainApiException($exception); + } + } + + /** + * Operation assignIpToDomainAsync + * + * Assign dedicated ip address to the provided domain for the account id + * + * @param \Infobip\Model\EmailDomainIpRequest $emailDomainIpRequest (required) + * + * @throws InvalidArgumentException + */ + public function assignIpToDomainAsync(\Infobip\Model\EmailDomainIpRequest $emailDomainIpRequest): PromiseInterface + { + $request = $this->assignIpToDomainRequest($emailDomainIpRequest); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->assignIpToDomainResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->assignIpToDomainApiException($exception); + } + ); + } + + /** + * Create request for operation 'assignIpToDomain' + * + * @param \Infobip\Model\EmailDomainIpRequest $emailDomainIpRequest (required) + * + * @throws InvalidArgumentException + */ + private function assignIpToDomainRequest(\Infobip\Model\EmailDomainIpRequest $emailDomainIpRequest): Request + { + $allData = [ + 'emailDomainIpRequest' => $emailDomainIpRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'emailDomainIpRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/email/1/domain-ips'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($emailDomainIpRequest)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($emailDomainIpRequest) + : $emailDomainIpRequest; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'assignIpToDomain' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\EmailSimpleApiResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function assignIpToDomainResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\EmailSimpleApiResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'assignIpToDomain' + */ + private function assignIpToDomainApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation deleteDomain + * + * Delete existing domain + * + * @param string $domainName Domain name which needs to be deleted. (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return void + */ + public function deleteDomain(string $domainName) + { + $request = $this->deleteDomainRequest($domainName); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->deleteDomainResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->deleteDomainApiException($exception); + } + } + + /** + * Operation deleteDomainAsync + * + * Delete existing domain + * + * @param string $domainName Domain name which needs to be deleted. (required) + * + * @throws InvalidArgumentException + */ + public function deleteDomainAsync(string $domainName): PromiseInterface + { + $request = $this->deleteDomainRequest($domainName); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->deleteDomainResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->deleteDomainApiException($exception); + } + ); + } + + /** + * Create request for operation 'deleteDomain' + * + * @param string $domainName Domain name which needs to be deleted. (required) + * + * @throws InvalidArgumentException + */ + private function deleteDomainRequest(string $domainName): Request + { + $allData = [ + 'domainName' => $domainName, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'domainName' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/email/1/domains/{domainName}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($domainName !== null) { + $resourcePath = str_replace( + '{' . 'domainName' . '}', + $this->objectSerializer->toPathValue($domainName), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'DELETE', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'deleteDomain' + * @throws ApiException on non-2xx response + * @return null + */ + private function deleteDomainResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'deleteDomain' + */ + private function deleteDomainApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation getAllDomainIps + * + * List all dedicated ips for domain and for provided account id + * + * @param string $domainName Name of the domain. (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\EmailDomainIpResponse|\Infobip\Model\ApiException + */ + public function getAllDomainIps(string $domainName) + { + $request = $this->getAllDomainIpsRequest($domainName); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->getAllDomainIpsResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->getAllDomainIpsApiException($exception); + } + } + + /** + * Operation getAllDomainIpsAsync + * + * List all dedicated ips for domain and for provided account id + * + * @param string $domainName Name of the domain. (required) + * + * @throws InvalidArgumentException + */ + public function getAllDomainIpsAsync(string $domainName): PromiseInterface + { + $request = $this->getAllDomainIpsRequest($domainName); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->getAllDomainIpsResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->getAllDomainIpsApiException($exception); + } + ); + } + + /** + * Create request for operation 'getAllDomainIps' + * + * @param string $domainName Name of the domain. (required) + * + * @throws InvalidArgumentException + */ + private function getAllDomainIpsRequest(string $domainName): Request + { + $allData = [ + 'domainName' => $domainName, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'domainName' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/email/1/domain-ips'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // query params + if ($domainName !== null) { + $queryParams['domainName'] = $domainName; + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'getAllDomainIps' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\EmailDomainIpResponse|\Infobip\Model\ApiException|null + */ + private function getAllDomainIpsResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\EmailDomainIpResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'getAllDomainIps' + */ + private function getAllDomainIpsApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation getAllDomains + * + * Get all domains for the account + * + * @param null|int $size Maximum number of domains to be viewed per page. Default value is 10 with a maximum of 20 records per page. (optional) + * @param null|int $page Page number you want to see. Default is 0. (optional) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\EmailAllDomainsResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function getAllDomains(?int $size = null, ?int $page = null) + { + $request = $this->getAllDomainsRequest($size, $page); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->getAllDomainsResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->getAllDomainsApiException($exception); + } + } + + /** + * Operation getAllDomainsAsync + * + * Get all domains for the account + * + * @param null|int $size Maximum number of domains to be viewed per page. Default value is 10 with a maximum of 20 records per page. (optional) + * @param null|int $page Page number you want to see. Default is 0. (optional) + * + * @throws InvalidArgumentException + */ + public function getAllDomainsAsync(?int $size = null, ?int $page = null): PromiseInterface + { + $request = $this->getAllDomainsRequest($size, $page); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->getAllDomainsResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->getAllDomainsApiException($exception); + } + ); + } + + /** + * Create request for operation 'getAllDomains' + * + * @param null|int $size Maximum number of domains to be viewed per page. Default value is 10 with a maximum of 20 records per page. (optional) + * @param null|int $page Page number you want to see. Default is 0. (optional) + * + * @throws InvalidArgumentException + */ + private function getAllDomainsRequest(?int $size = null, ?int $page = null): Request + { + $allData = [ + 'size' => $size, + 'page' => $page, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'size' => [ + new Assert\LessThan(20), + new Assert\GreaterThan(1), + ], + 'page' => [ + new Assert\GreaterThan(0), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/email/1/domains'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // query params + if ($size !== null) { + $queryParams['size'] = $size; + } + + // query params + if ($page !== null) { + $queryParams['page'] = $page; + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'getAllDomains' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\EmailAllDomainsResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function getAllDomainsResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\EmailAllDomainsResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'getAllDomains' + */ + private function getAllDomainsApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation getAllIps + * + * List all dedicated ips for provided account id + * + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\EmailDomainIpResponse|\Infobip\Model\ApiException + */ + public function getAllIps() + { + $request = $this->getAllIpsRequest(); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->getAllIpsResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->getAllIpsApiException($exception); + } + } + + /** + * Operation getAllIpsAsync + * + * List all dedicated ips for provided account id + * + * + * @throws InvalidArgumentException + */ + public function getAllIpsAsync(): PromiseInterface + { + $request = $this->getAllIpsRequest(); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->getAllIpsResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->getAllIpsApiException($exception); + } + ); + } + + /** + * Create request for operation 'getAllIps' + * + * + * @throws InvalidArgumentException + */ + private function getAllIpsRequest(): Request + { + $allData = [ + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/email/1/ips'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'getAllIps' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\EmailDomainIpResponse|\Infobip\Model\ApiException|null + */ + private function getAllIpsResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\EmailDomainIpResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'getAllIps' + */ + private function getAllIpsApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation getDomainDetails + * + * Get domain details + * + * @param string $domainName Domain for which the details need to be viewed. (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\EmailDomainResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function getDomainDetails(string $domainName) + { + $request = $this->getDomainDetailsRequest($domainName); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->getDomainDetailsResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->getDomainDetailsApiException($exception); + } + } + + /** + * Operation getDomainDetailsAsync + * + * Get domain details + * + * @param string $domainName Domain for which the details need to be viewed. (required) + * + * @throws InvalidArgumentException + */ + public function getDomainDetailsAsync(string $domainName): PromiseInterface + { + $request = $this->getDomainDetailsRequest($domainName); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->getDomainDetailsResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->getDomainDetailsApiException($exception); + } + ); + } + + /** + * Create request for operation 'getDomainDetails' + * + * @param string $domainName Domain for which the details need to be viewed. (required) + * + * @throws InvalidArgumentException + */ + private function getDomainDetailsRequest(string $domainName): Request + { + $allData = [ + 'domainName' => $domainName, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'domainName' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/email/1/domains/{domainName}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($domainName !== null) { + $resourcePath = str_replace( + '{' . 'domainName' . '}', + $this->objectSerializer->toPathValue($domainName), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'getDomainDetails' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\EmailDomainResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function getDomainDetailsResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\EmailDomainResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'getDomainDetails' + */ + private function getDomainDetailsApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation getEmailDeliveryReports + * + * Email delivery reports + * + * @param null|string $bulkId Bulk ID for which report is requested. (optional) + * @param null|string $messageId The ID that uniquely identifies the sent email. (optional) + * @param null|int $limit Maximum number of reports. (optional) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\EmailReportsResult|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function getEmailDeliveryReports(?string $bulkId = null, ?string $messageId = null, ?int $limit = null) + { + $request = $this->getEmailDeliveryReportsRequest($bulkId, $messageId, $limit); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->getEmailDeliveryReportsResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->getEmailDeliveryReportsApiException($exception); + } + } + + /** + * Operation getEmailDeliveryReportsAsync + * + * Email delivery reports + * + * @param null|string $bulkId Bulk ID for which report is requested. (optional) + * @param null|string $messageId The ID that uniquely identifies the sent email. (optional) + * @param null|int $limit Maximum number of reports. (optional) + * + * @throws InvalidArgumentException + */ + public function getEmailDeliveryReportsAsync(?string $bulkId = null, ?string $messageId = null, ?int $limit = null): PromiseInterface + { + $request = $this->getEmailDeliveryReportsRequest($bulkId, $messageId, $limit); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->getEmailDeliveryReportsResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->getEmailDeliveryReportsApiException($exception); + } + ); + } + + /** + * Create request for operation 'getEmailDeliveryReports' + * + * @param null|string $bulkId Bulk ID for which report is requested. (optional) + * @param null|string $messageId The ID that uniquely identifies the sent email. (optional) + * @param null|int $limit Maximum number of reports. (optional) + * + * @throws InvalidArgumentException + */ + private function getEmailDeliveryReportsRequest(?string $bulkId = null, ?string $messageId = null, ?int $limit = null): Request + { + $allData = [ + 'bulkId' => $bulkId, + 'messageId' => $messageId, + 'limit' => $limit, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'bulkId' => [ + ], + 'messageId' => [ + ], + 'limit' => [ + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/email/1/reports'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // query params + if ($bulkId !== null) { + $queryParams['bulkId'] = $bulkId; + } + + // query params + if ($messageId !== null) { + $queryParams['messageId'] = $messageId; + } + + // query params + if ($limit !== null) { + $queryParams['limit'] = $limit; + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'getEmailDeliveryReports' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\EmailReportsResult|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function getEmailDeliveryReportsResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\EmailReportsResult', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'getEmailDeliveryReports' + */ + private function getEmailDeliveryReportsApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation getEmailLogs + * + * Get email logs + * + * @param null|string $messageId The ID that uniquely identifies the sent email. (optional) + * @param null|string $from From email address. (optional) + * @param null|string $to The recipient email address. (optional) + * @param null|string $bulkId Bulk ID that uniquely identifies the request. (optional) + * @param null|string $generalStatus Indicates whether the initiated email has been successfully sent, not sent, delivered, not delivered, waiting for delivery or any other possible status. (optional) + * @param null|\DateTime $sentSince Tells when the email was initiated. Has the following format: `yyyy-MM-dd'T'HH:mm:ss.SSSZ`. (optional) + * @param null|\DateTime $sentUntil Tells when the email request was processed by Infobip.Has the following format: `yyyy-MM-dd'T'HH:mm:ss.SSSZ`. (optional) + * @param null|int $limit Maximum number of logs. (optional) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\EmailLogsResponse|\Infobip\Model\ApiException + */ + public function getEmailLogs(?string $messageId = null, ?string $from = null, ?string $to = null, ?string $bulkId = null, ?string $generalStatus = null, ?\DateTime $sentSince = null, ?\DateTime $sentUntil = null, ?int $limit = null) + { + $request = $this->getEmailLogsRequest($messageId, $from, $to, $bulkId, $generalStatus, $sentSince, $sentUntil, $limit); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->getEmailLogsResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->getEmailLogsApiException($exception); + } + } + + /** + * Operation getEmailLogsAsync + * + * Get email logs + * + * @param null|string $messageId The ID that uniquely identifies the sent email. (optional) + * @param null|string $from From email address. (optional) + * @param null|string $to The recipient email address. (optional) + * @param null|string $bulkId Bulk ID that uniquely identifies the request. (optional) + * @param null|string $generalStatus Indicates whether the initiated email has been successfully sent, not sent, delivered, not delivered, waiting for delivery or any other possible status. (optional) + * @param null|\DateTime $sentSince Tells when the email was initiated. Has the following format: `yyyy-MM-dd'T'HH:mm:ss.SSSZ`. (optional) + * @param null|\DateTime $sentUntil Tells when the email request was processed by Infobip.Has the following format: `yyyy-MM-dd'T'HH:mm:ss.SSSZ`. (optional) + * @param null|int $limit Maximum number of logs. (optional) + * + * @throws InvalidArgumentException + */ + public function getEmailLogsAsync(?string $messageId = null, ?string $from = null, ?string $to = null, ?string $bulkId = null, ?string $generalStatus = null, ?\DateTime $sentSince = null, ?\DateTime $sentUntil = null, ?int $limit = null): PromiseInterface + { + $request = $this->getEmailLogsRequest($messageId, $from, $to, $bulkId, $generalStatus, $sentSince, $sentUntil, $limit); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->getEmailLogsResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->getEmailLogsApiException($exception); + } + ); + } + + /** + * Create request for operation 'getEmailLogs' + * + * @param null|string $messageId The ID that uniquely identifies the sent email. (optional) + * @param null|string $from From email address. (optional) + * @param null|string $to The recipient email address. (optional) + * @param null|string $bulkId Bulk ID that uniquely identifies the request. (optional) + * @param null|string $generalStatus Indicates whether the initiated email has been successfully sent, not sent, delivered, not delivered, waiting for delivery or any other possible status. (optional) + * @param null|\DateTime $sentSince Tells when the email was initiated. Has the following format: `yyyy-MM-dd'T'HH:mm:ss.SSSZ`. (optional) + * @param null|\DateTime $sentUntil Tells when the email request was processed by Infobip.Has the following format: `yyyy-MM-dd'T'HH:mm:ss.SSSZ`. (optional) + * @param null|int $limit Maximum number of logs. (optional) + * + * @throws InvalidArgumentException + */ + private function getEmailLogsRequest(?string $messageId = null, ?string $from = null, ?string $to = null, ?string $bulkId = null, ?string $generalStatus = null, ?\DateTime $sentSince = null, ?\DateTime $sentUntil = null, ?int $limit = null): Request + { + $allData = [ + 'messageId' => $messageId, + 'from' => $from, + 'to' => $to, + 'bulkId' => $bulkId, + 'generalStatus' => $generalStatus, + 'sentSince' => $sentSince, + 'sentUntil' => $sentUntil, + 'limit' => $limit, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'messageId' => [ + ], + 'from' => [ + ], + 'to' => [ + ], + 'bulkId' => [ + ], + 'generalStatus' => [ + ], + 'sentSince' => [ + ], + 'sentUntil' => [ + ], + 'limit' => [ + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/email/1/logs'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // query params + if ($messageId !== null) { + $queryParams['messageId'] = $messageId; + } + + // query params + if ($from !== null) { + $queryParams['from'] = $from; + } + + // query params + if ($to !== null) { + $queryParams['to'] = $to; + } + + // query params + if ($bulkId !== null) { + $queryParams['bulkId'] = $bulkId; + } + + // query params + if ($generalStatus !== null) { + $queryParams['generalStatus'] = $generalStatus; + } + + // query params + if ($sentSince !== null) { + $queryParams['sentSince'] = $sentSince; + } + + // query params + if ($sentUntil !== null) { + $queryParams['sentUntil'] = $sentUntil; + } + + // query params + if ($limit !== null) { + $queryParams['limit'] = $limit; + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'getEmailLogs' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\EmailLogsResponse|\Infobip\Model\ApiException|null + */ + private function getEmailLogsResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\EmailLogsResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'getEmailLogs' + */ + private function getEmailLogsApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation getScheduledEmailStatuses + * + * Get sent email bulks status + * + * @param string $bulkId bulkId (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\EmailBulkStatusResponse + */ + public function getScheduledEmailStatuses(string $bulkId) + { + $request = $this->getScheduledEmailStatusesRequest($bulkId); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->getScheduledEmailStatusesResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->getScheduledEmailStatusesApiException($exception); + } + } + + /** + * Operation getScheduledEmailStatusesAsync + * + * Get sent email bulks status + * + * @param string $bulkId (required) + * + * @throws InvalidArgumentException + */ + public function getScheduledEmailStatusesAsync(string $bulkId): PromiseInterface + { + $request = $this->getScheduledEmailStatusesRequest($bulkId); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->getScheduledEmailStatusesResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->getScheduledEmailStatusesApiException($exception); + } + ); + } + + /** + * Create request for operation 'getScheduledEmailStatuses' + * + * @param string $bulkId (required) + * + * @throws InvalidArgumentException + */ + private function getScheduledEmailStatusesRequest(string $bulkId): Request + { + $allData = [ + 'bulkId' => $bulkId, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'bulkId' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/email/1/bulks/status'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // query params + if ($bulkId !== null) { + $queryParams['bulkId'] = $bulkId; + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'getScheduledEmailStatuses' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\EmailBulkStatusResponse|null + */ + private function getScheduledEmailStatusesResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\EmailBulkStatusResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'getScheduledEmailStatuses' + */ + private function getScheduledEmailStatusesApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + + return $apiException; + } + + /** + * Operation getScheduledEmails + * + * Get sent email bulks + * + * @param string $bulkId bulkId (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\EmailBulkScheduleResponse + */ + public function getScheduledEmails(string $bulkId) + { + $request = $this->getScheduledEmailsRequest($bulkId); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->getScheduledEmailsResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->getScheduledEmailsApiException($exception); + } + } + + /** + * Operation getScheduledEmailsAsync + * + * Get sent email bulks + * + * @param string $bulkId (required) + * + * @throws InvalidArgumentException + */ + public function getScheduledEmailsAsync(string $bulkId): PromiseInterface + { + $request = $this->getScheduledEmailsRequest($bulkId); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->getScheduledEmailsResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->getScheduledEmailsApiException($exception); + } + ); + } + + /** + * Create request for operation 'getScheduledEmails' + * + * @param string $bulkId (required) + * + * @throws InvalidArgumentException + */ + private function getScheduledEmailsRequest(string $bulkId): Request + { + $allData = [ + 'bulkId' => $bulkId, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'bulkId' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/email/1/bulks'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // query params + if ($bulkId !== null) { + $queryParams['bulkId'] = $bulkId; + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'getScheduledEmails' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\EmailBulkScheduleResponse|null + */ + private function getScheduledEmailsResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\EmailBulkScheduleResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'getScheduledEmails' + */ + private function getScheduledEmailsApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + + return $apiException; + } + + /** + * Operation removeIpFromDomain + * + * Remove dedicated ip address from the provided domain + * + * @param string $domainName Name of the domain. (required) + * @param string $ipAddress Dedicated ip address. (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\EmailSimpleApiResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function removeIpFromDomain(string $domainName, string $ipAddress) + { + $request = $this->removeIpFromDomainRequest($domainName, $ipAddress); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->removeIpFromDomainResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->removeIpFromDomainApiException($exception); + } + } + + /** + * Operation removeIpFromDomainAsync + * + * Remove dedicated ip address from the provided domain + * + * @param string $domainName Name of the domain. (required) + * @param string $ipAddress Dedicated ip address. (required) + * + * @throws InvalidArgumentException + */ + public function removeIpFromDomainAsync(string $domainName, string $ipAddress): PromiseInterface + { + $request = $this->removeIpFromDomainRequest($domainName, $ipAddress); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->removeIpFromDomainResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->removeIpFromDomainApiException($exception); + } + ); + } + + /** + * Create request for operation 'removeIpFromDomain' + * + * @param string $domainName Name of the domain. (required) + * @param string $ipAddress Dedicated ip address. (required) + * + * @throws InvalidArgumentException + */ + private function removeIpFromDomainRequest(string $domainName, string $ipAddress): Request + { + $allData = [ + 'domainName' => $domainName, + 'ipAddress' => $ipAddress, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'domainName' => [ + new Assert\NotBlank(), + ], + 'ipAddress' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/email/1/domain-ips'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // query params + if ($domainName !== null) { + $queryParams['domainName'] = $domainName; + } + + // query params + if ($ipAddress !== null) { + $queryParams['ipAddress'] = $ipAddress; + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'DELETE', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'removeIpFromDomain' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\EmailSimpleApiResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function removeIpFromDomainResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\EmailSimpleApiResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'removeIpFromDomain' + */ + private function removeIpFromDomainApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation rescheduleEmails + * + * Reschedule Email messages + * + * @param string $bulkId bulkId (required) + * @param \Infobip\Model\EmailBulkRescheduleRequest $emailBulkRescheduleRequest emailBulkRescheduleRequest (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\EmailBulkRescheduleResponse + */ + public function rescheduleEmails(string $bulkId, \Infobip\Model\EmailBulkRescheduleRequest $emailBulkRescheduleRequest) + { + $request = $this->rescheduleEmailsRequest($bulkId, $emailBulkRescheduleRequest); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->rescheduleEmailsResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->rescheduleEmailsApiException($exception); + } + } + + /** + * Operation rescheduleEmailsAsync + * + * Reschedule Email messages + * + * @param string $bulkId (required) + * @param \Infobip\Model\EmailBulkRescheduleRequest $emailBulkRescheduleRequest (required) + * + * @throws InvalidArgumentException + */ + public function rescheduleEmailsAsync(string $bulkId, \Infobip\Model\EmailBulkRescheduleRequest $emailBulkRescheduleRequest): PromiseInterface + { + $request = $this->rescheduleEmailsRequest($bulkId, $emailBulkRescheduleRequest); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->rescheduleEmailsResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->rescheduleEmailsApiException($exception); + } + ); + } + + /** + * Create request for operation 'rescheduleEmails' + * + * @param string $bulkId (required) + * @param \Infobip\Model\EmailBulkRescheduleRequest $emailBulkRescheduleRequest (required) + * + * @throws InvalidArgumentException + */ + private function rescheduleEmailsRequest(string $bulkId, \Infobip\Model\EmailBulkRescheduleRequest $emailBulkRescheduleRequest): Request + { + $allData = [ + 'bulkId' => $bulkId, + 'emailBulkRescheduleRequest' => $emailBulkRescheduleRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'bulkId' => [ + new Assert\NotBlank(), + ], + 'emailBulkRescheduleRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/email/1/bulks'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // query params + if ($bulkId !== null) { + $queryParams['bulkId'] = $bulkId; + } + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($emailBulkRescheduleRequest)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($emailBulkRescheduleRequest) + : $emailBulkRescheduleRequest; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'PUT', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'rescheduleEmails' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\EmailBulkRescheduleResponse|null + */ + private function rescheduleEmailsResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\EmailBulkRescheduleResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'rescheduleEmails' + */ + private function rescheduleEmailsApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + + return $apiException; + } + + /** + * Operation sendEmail + * + * Send fully featured email + * + * @param string[] $to Email address of the recipient in a form of `To=\\\"john.smith@somecompany.com\\\"`. As optional feature on this field, a specific placeholder can be defined whose value will apply only for this destination. Given `To` value should look like: `To= {\\\"to\\\": \\\"john.smith@somecompany.com\\\",\\\"placeholders\\\": {\\\"name\\\": \\\"John\\\"}}` `To= {\\\"to\\\": \\\"alice.grey@somecompany.com\\\",\\\"placeholders\\\": {\\\"name\\\": \\\"Alice\\\"}}` (required) + * @param null|string $from Email address with optional sender name. Note: This field is required if `templateId` is not present. (optional) + * @param null|string[] $cc CC recipient email address. (optional) + * @param null|string[] $bcc BCC recipient email address. (optional) + * @param null|string $subject Message subject. Note: This field is required if `templateId` is not present. (optional) + * @param null|string $text Body of the message. (optional) + * @param null|string $html HTML body of the message. If `html` and `text` fields are present, the `text` field will be ignored and `html` will be delivered as a message body. (optional) + * @param null|string $ampHtml Amp HTML body of the message. If `ampHtml` is present, `html` is mandatory. Amp HTML is not supported by all the email clients. Please check this link for configuring gmail client https://developers.google.com/gmail/ampemail/ (optional) + * @param null|int $templateId Template ID used for generating email content. The template is created over Infobip web interface. If `templateId` is present, then `html` and `text` values are ignored. Note: `templateId` only supports the value of `Broadcast`. `Content` and `Flow` are not supported. (optional) + * @param null|\SplFileObject[] $attachment File attachment. (optional) + * @param null|\SplFileObject[] $inlineImage Allows for inserting an image file inside the HTML code of the email by using `cid:FILENAME` instead of providing an external link to the image. (optional) + * @param null|bool $intermediateReport The real-time Intermediate delivery report that will be sent on your callback server. (optional) + * @param null|string $notifyUrl The URL on your callback server on which the Delivery report will be sent. (optional) + * @param null|string $notifyContentType Preferred Delivery report content type. Can be `application/json` or `application/xml`. (optional) + * @param null|string $callbackData Additional client data that will be sent on the notifyUrl. (optional) + * @param bool $track Enable or disable open and click tracking. Passing true will only enable tracking and the statistics would be visible in the web interface alone. This can be explicitly overridden by `trackClicks` and `trackOpens`. (optional, default to true) + * @param null|bool $trackClicks This parameter enables or disables track click feature. (optional) + * @param null|bool $trackOpens This parameter enables or disables track open feature. (optional) + * @param null|string $trackingUrl The URL on your callback server on which the open and click notifications will be sent. See [Tracking Notifications](https://www.infobip.com/docs/email/send-email-over-api#tracking-notifications) for details. (optional) + * @param null|string $bulkId The ID uniquely identifies the sent email request. This filter will enable you to query delivery reports for all the messages using just one request. You will receive a `bulkId` in the response after sending an email request. If you don't set your own `bulkId`, unique ID will be generated by our system and returned in the API response. (Optional Field) (optional) + * @param null|string $messageId The ID that uniquely identifies the message sent to a recipient. (Optional Field) (optional) + * @param null|string $replyTo Email address to which recipients of the email can reply. (optional) + * @param null|string $defaultPlaceholders General placeholder, given in a form of json example: `defaultPlaceholders={\\\"ph1\\\": \\\"Success\\\"}`, which will replace given key `{{ph1}}` with given value `Success` anywhere in the email (subject, text, html...). In case of more destinations in `To` field, this placeholder will resolve the same value for key `ph1` (optional) + * @param bool $preserveRecipients If set to `true`, the `to` recipients will see the list of all other recipients to get the email and the response will return only one `messageId`. Otherwise, each recipient will see just their own email and the response will return a unique `messageId` for each email recipient. (optional, default to false) + * @param null|\DateTime $sendAt To schedule message at a given time in future. Time provided should be in UTC in the following format: `yyyy-MM-dd'T'HH:mm:ss.SSSZ`. (optional) + * @param null|string $landingPagePlaceholders Personalize opt out landing page by inserting placeholders. Insert placeholder or tag while designing landing page. (optional) + * @param null|string $landingPageId Opt out landing page which will be used and displayed once end user clicks the unsubscribe link. If not present default opt out landing page will be displayed. Create a landing page on IB’s portal and use the last 6 digits from URL to use that opt out page. (optional) + * @param null|string $applicationId Required for application use in a send request for outbound traffic. Returned in notification events. (optional) + * @param null|string $entityId Required for entity use in a send request for outbound traffic. Returned in notification events. (optional) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\EmailSendResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function sendEmail(array $to, ?string $from = null, ?array $cc = null, ?array $bcc = null, ?string $subject = null, ?string $text = null, ?string $html = null, ?string $ampHtml = null, ?int $templateId = null, ?array $attachment = null, ?array $inlineImage = null, ?bool $intermediateReport = null, ?string $notifyUrl = null, ?string $notifyContentType = null, ?string $callbackData = null, bool $track = true, ?bool $trackClicks = null, ?bool $trackOpens = null, ?string $trackingUrl = null, ?string $bulkId = null, ?string $messageId = null, ?string $replyTo = null, ?string $defaultPlaceholders = null, bool $preserveRecipients = false, ?\DateTime $sendAt = null, ?string $landingPagePlaceholders = null, ?string $landingPageId = null, ?string $applicationId = null, ?string $entityId = null) + { + $request = $this->sendEmailRequest($to, $from, $cc, $bcc, $subject, $text, $html, $ampHtml, $templateId, $attachment, $inlineImage, $intermediateReport, $notifyUrl, $notifyContentType, $callbackData, $track, $trackClicks, $trackOpens, $trackingUrl, $bulkId, $messageId, $replyTo, $defaultPlaceholders, $preserveRecipients, $sendAt, $landingPagePlaceholders, $landingPageId, $applicationId, $entityId); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->sendEmailResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->sendEmailApiException($exception); + } + } + + /** + * Operation sendEmailAsync + * + * Send fully featured email + * + * @param string[] $to Email address of the recipient in a form of `To=\\\"john.smith@somecompany.com\\\"`. As optional feature on this field, a specific placeholder can be defined whose value will apply only for this destination. Given `To` value should look like: `To= {\\\"to\\\": \\\"john.smith@somecompany.com\\\",\\\"placeholders\\\": {\\\"name\\\": \\\"John\\\"}}` `To= {\\\"to\\\": \\\"alice.grey@somecompany.com\\\",\\\"placeholders\\\": {\\\"name\\\": \\\"Alice\\\"}}` (required) + * @param null|string $from Email address with optional sender name. Note: This field is required if `templateId` is not present. (optional) + * @param null|string[] $cc CC recipient email address. (optional) + * @param null|string[] $bcc BCC recipient email address. (optional) + * @param null|string $subject Message subject. Note: This field is required if `templateId` is not present. (optional) + * @param null|string $text Body of the message. (optional) + * @param null|string $html HTML body of the message. If `html` and `text` fields are present, the `text` field will be ignored and `html` will be delivered as a message body. (optional) + * @param null|string $ampHtml Amp HTML body of the message. If `ampHtml` is present, `html` is mandatory. Amp HTML is not supported by all the email clients. Please check this link for configuring gmail client https://developers.google.com/gmail/ampemail/ (optional) + * @param null|int $templateId Template ID used for generating email content. The template is created over Infobip web interface. If `templateId` is present, then `html` and `text` values are ignored. Note: `templateId` only supports the value of `Broadcast`. `Content` and `Flow` are not supported. (optional) + * @param null|\SplFileObject[] $attachment File attachment. (optional) + * @param null|\SplFileObject[] $inlineImage Allows for inserting an image file inside the HTML code of the email by using `cid:FILENAME` instead of providing an external link to the image. (optional) + * @param null|bool $intermediateReport The real-time Intermediate delivery report that will be sent on your callback server. (optional) + * @param null|string $notifyUrl The URL on your callback server on which the Delivery report will be sent. (optional) + * @param null|string $notifyContentType Preferred Delivery report content type. Can be `application/json` or `application/xml`. (optional) + * @param null|string $callbackData Additional client data that will be sent on the notifyUrl. (optional) + * @param bool $track Enable or disable open and click tracking. Passing true will only enable tracking and the statistics would be visible in the web interface alone. This can be explicitly overridden by `trackClicks` and `trackOpens`. (optional, default to true) + * @param null|bool $trackClicks This parameter enables or disables track click feature. (optional) + * @param null|bool $trackOpens This parameter enables or disables track open feature. (optional) + * @param null|string $trackingUrl The URL on your callback server on which the open and click notifications will be sent. See [Tracking Notifications](https://www.infobip.com/docs/email/send-email-over-api#tracking-notifications) for details. (optional) + * @param null|string $bulkId The ID uniquely identifies the sent email request. This filter will enable you to query delivery reports for all the messages using just one request. You will receive a `bulkId` in the response after sending an email request. If you don't set your own `bulkId`, unique ID will be generated by our system and returned in the API response. (Optional Field) (optional) + * @param null|string $messageId The ID that uniquely identifies the message sent to a recipient. (Optional Field) (optional) + * @param null|string $replyTo Email address to which recipients of the email can reply. (optional) + * @param null|string $defaultPlaceholders General placeholder, given in a form of json example: `defaultPlaceholders={\\\"ph1\\\": \\\"Success\\\"}`, which will replace given key `{{ph1}}` with given value `Success` anywhere in the email (subject, text, html...). In case of more destinations in `To` field, this placeholder will resolve the same value for key `ph1` (optional) + * @param bool $preserveRecipients If set to `true`, the `to` recipients will see the list of all other recipients to get the email and the response will return only one `messageId`. Otherwise, each recipient will see just their own email and the response will return a unique `messageId` for each email recipient. (optional, default to false) + * @param null|\DateTime $sendAt To schedule message at a given time in future. Time provided should be in UTC in the following format: `yyyy-MM-dd'T'HH:mm:ss.SSSZ`. (optional) + * @param null|string $landingPagePlaceholders Personalize opt out landing page by inserting placeholders. Insert placeholder or tag while designing landing page. (optional) + * @param null|string $landingPageId Opt out landing page which will be used and displayed once end user clicks the unsubscribe link. If not present default opt out landing page will be displayed. Create a landing page on IB’s portal and use the last 6 digits from URL to use that opt out page. (optional) + * @param null|string $applicationId Required for application use in a send request for outbound traffic. Returned in notification events. (optional) + * @param null|string $entityId Required for entity use in a send request for outbound traffic. Returned in notification events. (optional) + * + * @throws InvalidArgumentException + */ + public function sendEmailAsync(array $to, ?string $from = null, ?array $cc = null, ?array $bcc = null, ?string $subject = null, ?string $text = null, ?string $html = null, ?string $ampHtml = null, ?int $templateId = null, ?array $attachment = null, ?array $inlineImage = null, ?bool $intermediateReport = null, ?string $notifyUrl = null, ?string $notifyContentType = null, ?string $callbackData = null, bool $track = true, ?bool $trackClicks = null, ?bool $trackOpens = null, ?string $trackingUrl = null, ?string $bulkId = null, ?string $messageId = null, ?string $replyTo = null, ?string $defaultPlaceholders = null, bool $preserveRecipients = false, ?\DateTime $sendAt = null, ?string $landingPagePlaceholders = null, ?string $landingPageId = null, ?string $applicationId = null, ?string $entityId = null): PromiseInterface + { + $request = $this->sendEmailRequest($to, $from, $cc, $bcc, $subject, $text, $html, $ampHtml, $templateId, $attachment, $inlineImage, $intermediateReport, $notifyUrl, $notifyContentType, $callbackData, $track, $trackClicks, $trackOpens, $trackingUrl, $bulkId, $messageId, $replyTo, $defaultPlaceholders, $preserveRecipients, $sendAt, $landingPagePlaceholders, $landingPageId, $applicationId, $entityId); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->sendEmailResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->sendEmailApiException($exception); + } + ); + } + + /** + * Create request for operation 'sendEmail' + * + * @param string[] $to Email address of the recipient in a form of `To=\\\"john.smith@somecompany.com\\\"`. As optional feature on this field, a specific placeholder can be defined whose value will apply only for this destination. Given `To` value should look like: `To= {\\\"to\\\": \\\"john.smith@somecompany.com\\\",\\\"placeholders\\\": {\\\"name\\\": \\\"John\\\"}}` `To= {\\\"to\\\": \\\"alice.grey@somecompany.com\\\",\\\"placeholders\\\": {\\\"name\\\": \\\"Alice\\\"}}` (required) + * @param null|string $from Email address with optional sender name. Note: This field is required if `templateId` is not present. (optional) + * @param null|string[] $cc CC recipient email address. (optional) + * @param null|string[] $bcc BCC recipient email address. (optional) + * @param null|string $subject Message subject. Note: This field is required if `templateId` is not present. (optional) + * @param null|string $text Body of the message. (optional) + * @param null|string $html HTML body of the message. If `html` and `text` fields are present, the `text` field will be ignored and `html` will be delivered as a message body. (optional) + * @param null|string $ampHtml Amp HTML body of the message. If `ampHtml` is present, `html` is mandatory. Amp HTML is not supported by all the email clients. Please check this link for configuring gmail client https://developers.google.com/gmail/ampemail/ (optional) + * @param null|int $templateId Template ID used for generating email content. The template is created over Infobip web interface. If `templateId` is present, then `html` and `text` values are ignored. Note: `templateId` only supports the value of `Broadcast`. `Content` and `Flow` are not supported. (optional) + * @param null|\SplFileObject[] $attachment File attachment. (optional) + * @param null|\SplFileObject[] $inlineImage Allows for inserting an image file inside the HTML code of the email by using `cid:FILENAME` instead of providing an external link to the image. (optional) + * @param null|bool $intermediateReport The real-time Intermediate delivery report that will be sent on your callback server. (optional) + * @param null|string $notifyUrl The URL on your callback server on which the Delivery report will be sent. (optional) + * @param null|string $notifyContentType Preferred Delivery report content type. Can be `application/json` or `application/xml`. (optional) + * @param null|string $callbackData Additional client data that will be sent on the notifyUrl. (optional) + * @param bool $track Enable or disable open and click tracking. Passing true will only enable tracking and the statistics would be visible in the web interface alone. This can be explicitly overridden by `trackClicks` and `trackOpens`. (optional, default to true) + * @param null|bool $trackClicks This parameter enables or disables track click feature. (optional) + * @param null|bool $trackOpens This parameter enables or disables track open feature. (optional) + * @param null|string $trackingUrl The URL on your callback server on which the open and click notifications will be sent. See [Tracking Notifications](https://www.infobip.com/docs/email/send-email-over-api#tracking-notifications) for details. (optional) + * @param null|string $bulkId The ID uniquely identifies the sent email request. This filter will enable you to query delivery reports for all the messages using just one request. You will receive a `bulkId` in the response after sending an email request. If you don't set your own `bulkId`, unique ID will be generated by our system and returned in the API response. (Optional Field) (optional) + * @param null|string $messageId The ID that uniquely identifies the message sent to a recipient. (Optional Field) (optional) + * @param null|string $replyTo Email address to which recipients of the email can reply. (optional) + * @param null|string $defaultPlaceholders General placeholder, given in a form of json example: `defaultPlaceholders={\\\"ph1\\\": \\\"Success\\\"}`, which will replace given key `{{ph1}}` with given value `Success` anywhere in the email (subject, text, html...). In case of more destinations in `To` field, this placeholder will resolve the same value for key `ph1` (optional) + * @param bool $preserveRecipients If set to `true`, the `to` recipients will see the list of all other recipients to get the email and the response will return only one `messageId`. Otherwise, each recipient will see just their own email and the response will return a unique `messageId` for each email recipient. (optional, default to false) + * @param null|\DateTime $sendAt To schedule message at a given time in future. Time provided should be in UTC in the following format: `yyyy-MM-dd'T'HH:mm:ss.SSSZ`. (optional) + * @param null|string $landingPagePlaceholders Personalize opt out landing page by inserting placeholders. Insert placeholder or tag while designing landing page. (optional) + * @param null|string $landingPageId Opt out landing page which will be used and displayed once end user clicks the unsubscribe link. If not present default opt out landing page will be displayed. Create a landing page on IB’s portal and use the last 6 digits from URL to use that opt out page. (optional) + * @param null|string $applicationId Required for application use in a send request for outbound traffic. Returned in notification events. (optional) + * @param null|string $entityId Required for entity use in a send request for outbound traffic. Returned in notification events. (optional) + * + * @throws InvalidArgumentException + */ + private function sendEmailRequest(array $to, ?string $from = null, ?array $cc = null, ?array $bcc = null, ?string $subject = null, ?string $text = null, ?string $html = null, ?string $ampHtml = null, ?int $templateId = null, ?array $attachment = null, ?array $inlineImage = null, ?bool $intermediateReport = null, ?string $notifyUrl = null, ?string $notifyContentType = null, ?string $callbackData = null, bool $track = true, ?bool $trackClicks = null, ?bool $trackOpens = null, ?string $trackingUrl = null, ?string $bulkId = null, ?string $messageId = null, ?string $replyTo = null, ?string $defaultPlaceholders = null, bool $preserveRecipients = false, ?\DateTime $sendAt = null, ?string $landingPagePlaceholders = null, ?string $landingPageId = null, ?string $applicationId = null, ?string $entityId = null): Request + { + $allData = [ + 'to' => $to, + 'from' => $from, + 'cc' => $cc, + 'bcc' => $bcc, + 'subject' => $subject, + 'text' => $text, + 'html' => $html, + 'ampHtml' => $ampHtml, + 'templateId' => $templateId, + 'attachment' => $attachment, + 'inlineImage' => $inlineImage, + 'intermediateReport' => $intermediateReport, + 'notifyUrl' => $notifyUrl, + 'notifyContentType' => $notifyContentType, + 'callbackData' => $callbackData, + 'track' => $track, + 'trackClicks' => $trackClicks, + 'trackOpens' => $trackOpens, + 'trackingUrl' => $trackingUrl, + 'bulkId' => $bulkId, + 'messageId' => $messageId, + 'replyTo' => $replyTo, + 'defaultPlaceholders' => $defaultPlaceholders, + 'preserveRecipients' => $preserveRecipients, + 'sendAt' => $sendAt, + 'landingPagePlaceholders' => $landingPagePlaceholders, + 'landingPageId' => $landingPageId, + 'applicationId' => $applicationId, + 'entityId' => $entityId, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'to' => [ + new Assert\NotNull(), + ], + 'from' => [ + ], + 'cc' => [ + ], + 'bcc' => [ + ], + 'subject' => [ + ], + 'text' => [ + ], + 'html' => [ + ], + 'ampHtml' => [ + ], + 'templateId' => [ + ], + 'attachment' => [ + ], + 'inlineImage' => [ + ], + 'intermediateReport' => [ + ], + 'notifyUrl' => [ + ], + 'notifyContentType' => [ + ], + 'callbackData' => [ + ], + 'track' => [ + ], + 'trackClicks' => [ + ], + 'trackOpens' => [ + ], + 'trackingUrl' => [ + ], + 'bulkId' => [ + ], + 'messageId' => [ + ], + 'replyTo' => [ + ], + 'defaultPlaceholders' => [ + ], + 'preserveRecipients' => [ + ], + 'sendAt' => [ + ], + 'landingPagePlaceholders' => [ + ], + 'landingPageId' => [ + ], + 'applicationId' => [ + ], + 'entityId' => [ + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/email/3/send'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // form params + if ($from !== null) { + $formParams['from'] = $this->objectSerializer->toFormValue($from); + } + + // form params + if ($to !== null) { + $formParams['to'] = $this->objectSerializer->toFormValue($to); + } + + // form params + if ($cc !== null) { + $formParams['cc'] = $this->objectSerializer->toFormValue($cc); + } + + // form params + if ($bcc !== null) { + $formParams['bcc'] = $this->objectSerializer->toFormValue($bcc); + } + + // form params + if ($subject !== null) { + $formParams['subject'] = $this->objectSerializer->toFormValue($subject); + } + + // form params + if ($text !== null) { + $formParams['text'] = $this->objectSerializer->toFormValue($text); + } + + // form params + if ($html !== null) { + $formParams['html'] = $this->objectSerializer->toFormValue($html); + } + + // form params + if ($ampHtml !== null) { + $formParams['ampHtml'] = $this->objectSerializer->toFormValue($ampHtml); + } + + // form params + if ($templateId !== null) { + $formParams['templateId'] = $this->objectSerializer->toFormValue($templateId); + } + + // form params + if ($attachment !== null) { + $formParams['attachment'] = []; + $paramFiles = is_array($attachment) ? $attachment : [$attachment]; + foreach ($paramFiles as $paramFile) { + $formParams['attachment'][] = Utils::tryFopen( + $this->objectSerializer->toFormValue($paramFile), + 'rb' + ); + } + } + + // form params + if ($inlineImage !== null) { + $formParams['inlineImage'] = []; + $paramFiles = is_array($inlineImage) ? $inlineImage : [$inlineImage]; + foreach ($paramFiles as $paramFile) { + $formParams['inlineImage'][] = Utils::tryFopen( + $this->objectSerializer->toFormValue($paramFile), + 'rb' + ); + } + } + + // form params + if ($intermediateReport !== null) { + $formParams['intermediateReport'] = $this->objectSerializer->toFormValue($intermediateReport); + } + + // form params + if ($notifyUrl !== null) { + $formParams['notifyUrl'] = $this->objectSerializer->toFormValue($notifyUrl); + } + + // form params + if ($notifyContentType !== null) { + $formParams['notifyContentType'] = $this->objectSerializer->toFormValue($notifyContentType); + } + + // form params + if ($callbackData !== null) { + $formParams['callbackData'] = $this->objectSerializer->toFormValue($callbackData); + } + + // form params + if ($track !== null) { + $formParams['track'] = $this->objectSerializer->toFormValue($track); + } + + // form params + if ($trackClicks !== null) { + $formParams['trackClicks'] = $this->objectSerializer->toFormValue($trackClicks); + } + + // form params + if ($trackOpens !== null) { + $formParams['trackOpens'] = $this->objectSerializer->toFormValue($trackOpens); + } + + // form params + if ($trackingUrl !== null) { + $formParams['trackingUrl'] = $this->objectSerializer->toFormValue($trackingUrl); + } + + // form params + if ($bulkId !== null) { + $formParams['bulkId'] = $this->objectSerializer->toFormValue($bulkId); + } + + // form params + if ($messageId !== null) { + $formParams['messageId'] = $this->objectSerializer->toFormValue($messageId); + } + + // form params + if ($replyTo !== null) { + $formParams['replyTo'] = $this->objectSerializer->toFormValue($replyTo); + } + + // form params + if ($defaultPlaceholders !== null) { + $formParams['defaultPlaceholders'] = $this->objectSerializer->toFormValue($defaultPlaceholders); + } + + // form params + if ($preserveRecipients !== null) { + $formParams['preserveRecipients'] = $this->objectSerializer->toFormValue($preserveRecipients); + } + + // form params + if ($sendAt !== null) { + $formParams['sendAt'] = $this->objectSerializer->toFormValue($sendAt); + } + + // form params + if ($landingPagePlaceholders !== null) { + $formParams['landingPagePlaceholders'] = $this->objectSerializer->toFormValue($landingPagePlaceholders); + } + + // form params + if ($landingPageId !== null) { + $formParams['landingPageId'] = $this->objectSerializer->toFormValue($landingPageId); + } + + // form params + if ($applicationId !== null) { + $formParams['applicationId'] = $this->objectSerializer->toFormValue($applicationId); + } + + // form params + if ($entityId !== null) { + $formParams['entityId'] = $this->objectSerializer->toFormValue($entityId); + } + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'multipart/form-data', + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'sendEmail' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\EmailSendResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function sendEmailResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\EmailSendResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'sendEmail' + */ + private function sendEmailApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation updateScheduledEmailStatuses + * + * Update scheduled Email messages status + * + * @param string $bulkId bulkId (required) + * @param \Infobip\Model\EmailBulkUpdateStatusRequest $emailBulkUpdateStatusRequest emailBulkUpdateStatusRequest (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\EmailBulkUpdateStatusResponse + */ + public function updateScheduledEmailStatuses(string $bulkId, \Infobip\Model\EmailBulkUpdateStatusRequest $emailBulkUpdateStatusRequest) + { + $request = $this->updateScheduledEmailStatusesRequest($bulkId, $emailBulkUpdateStatusRequest); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->updateScheduledEmailStatusesResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->updateScheduledEmailStatusesApiException($exception); + } + } + + /** + * Operation updateScheduledEmailStatusesAsync + * + * Update scheduled Email messages status + * + * @param string $bulkId (required) + * @param \Infobip\Model\EmailBulkUpdateStatusRequest $emailBulkUpdateStatusRequest (required) + * + * @throws InvalidArgumentException + */ + public function updateScheduledEmailStatusesAsync(string $bulkId, \Infobip\Model\EmailBulkUpdateStatusRequest $emailBulkUpdateStatusRequest): PromiseInterface + { + $request = $this->updateScheduledEmailStatusesRequest($bulkId, $emailBulkUpdateStatusRequest); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->updateScheduledEmailStatusesResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->updateScheduledEmailStatusesApiException($exception); + } + ); + } + + /** + * Create request for operation 'updateScheduledEmailStatuses' + * + * @param string $bulkId (required) + * @param \Infobip\Model\EmailBulkUpdateStatusRequest $emailBulkUpdateStatusRequest (required) + * + * @throws InvalidArgumentException + */ + private function updateScheduledEmailStatusesRequest(string $bulkId, \Infobip\Model\EmailBulkUpdateStatusRequest $emailBulkUpdateStatusRequest): Request + { + $allData = [ + 'bulkId' => $bulkId, + 'emailBulkUpdateStatusRequest' => $emailBulkUpdateStatusRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'bulkId' => [ + new Assert\NotBlank(), + ], + 'emailBulkUpdateStatusRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/email/1/bulks/status'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // query params + if ($bulkId !== null) { + $queryParams['bulkId'] = $bulkId; + } + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($emailBulkUpdateStatusRequest)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($emailBulkUpdateStatusRequest) + : $emailBulkUpdateStatusRequest; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'PUT', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'updateScheduledEmailStatuses' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\EmailBulkUpdateStatusResponse|null + */ + private function updateScheduledEmailStatusesResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\EmailBulkUpdateStatusResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'updateScheduledEmailStatuses' + */ + private function updateScheduledEmailStatusesApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + + return $apiException; + } + + /** + * Operation updateTrackingEvents + * + * Update tracking events + * + * @param string $domainName Domain for which the tracking events need to be updated. (required) + * @param \Infobip\Model\EmailTrackingEventRequest $emailTrackingEventRequest emailTrackingEventRequest (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\EmailDomainResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function updateTrackingEvents(string $domainName, \Infobip\Model\EmailTrackingEventRequest $emailTrackingEventRequest) + { + $request = $this->updateTrackingEventsRequest($domainName, $emailTrackingEventRequest); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->updateTrackingEventsResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->updateTrackingEventsApiException($exception); + } + } + + /** + * Operation updateTrackingEventsAsync + * + * Update tracking events + * + * @param string $domainName Domain for which the tracking events need to be updated. (required) + * @param \Infobip\Model\EmailTrackingEventRequest $emailTrackingEventRequest (required) + * + * @throws InvalidArgumentException + */ + public function updateTrackingEventsAsync(string $domainName, \Infobip\Model\EmailTrackingEventRequest $emailTrackingEventRequest): PromiseInterface + { + $request = $this->updateTrackingEventsRequest($domainName, $emailTrackingEventRequest); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->updateTrackingEventsResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->updateTrackingEventsApiException($exception); + } + ); + } + + /** + * Create request for operation 'updateTrackingEvents' + * + * @param string $domainName Domain for which the tracking events need to be updated. (required) + * @param \Infobip\Model\EmailTrackingEventRequest $emailTrackingEventRequest (required) + * + * @throws InvalidArgumentException + */ + private function updateTrackingEventsRequest(string $domainName, \Infobip\Model\EmailTrackingEventRequest $emailTrackingEventRequest): Request + { + $allData = [ + 'domainName' => $domainName, + 'emailTrackingEventRequest' => $emailTrackingEventRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'domainName' => [ + new Assert\NotBlank(), + ], + 'emailTrackingEventRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/email/1/domains/{domainName}/tracking'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($domainName !== null) { + $resourcePath = str_replace( + '{' . 'domainName' . '}', + $this->objectSerializer->toPathValue($domainName), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($emailTrackingEventRequest)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($emailTrackingEventRequest) + : $emailTrackingEventRequest; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'PUT', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'updateTrackingEvents' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\EmailDomainResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function updateTrackingEventsResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\EmailDomainResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'updateTrackingEvents' + */ + private function updateTrackingEventsApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation validateEmailAddresses + * + * Validate email addresses + * + * @param \Infobip\Model\EmailValidationRequest $emailValidationRequest emailValidationRequest (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\EmailValidationResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function validateEmailAddresses(\Infobip\Model\EmailValidationRequest $emailValidationRequest) + { + $request = $this->validateEmailAddressesRequest($emailValidationRequest); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->validateEmailAddressesResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->validateEmailAddressesApiException($exception); + } + } + + /** + * Operation validateEmailAddressesAsync + * + * Validate email addresses + * + * @param \Infobip\Model\EmailValidationRequest $emailValidationRequest (required) + * + * @throws InvalidArgumentException + */ + public function validateEmailAddressesAsync(\Infobip\Model\EmailValidationRequest $emailValidationRequest): PromiseInterface + { + $request = $this->validateEmailAddressesRequest($emailValidationRequest); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->validateEmailAddressesResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->validateEmailAddressesApiException($exception); + } + ); + } + + /** + * Create request for operation 'validateEmailAddresses' + * + * @param \Infobip\Model\EmailValidationRequest $emailValidationRequest (required) + * + * @throws InvalidArgumentException + */ + private function validateEmailAddressesRequest(\Infobip\Model\EmailValidationRequest $emailValidationRequest): Request + { + $allData = [ + 'emailValidationRequest' => $emailValidationRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'emailValidationRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/email/2/validation'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($emailValidationRequest)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($emailValidationRequest) + : $emailValidationRequest; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'validateEmailAddresses' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\EmailValidationResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function validateEmailAddressesResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\EmailValidationResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'validateEmailAddresses' + */ + private function validateEmailAddressesApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation verifyDomain + * + * Verify Domain + * + * @param string $domainName Name of the domain that has to be verified. (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return void + */ + public function verifyDomain(string $domainName) + { + $request = $this->verifyDomainRequest($domainName); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->verifyDomainResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->verifyDomainApiException($exception); + } + } + + /** + * Operation verifyDomainAsync + * + * Verify Domain + * + * @param string $domainName Name of the domain that has to be verified. (required) + * + * @throws InvalidArgumentException + */ + public function verifyDomainAsync(string $domainName): PromiseInterface + { + $request = $this->verifyDomainRequest($domainName); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->verifyDomainResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->verifyDomainApiException($exception); + } + ); + } + + /** + * Create request for operation 'verifyDomain' + * + * @param string $domainName Name of the domain that has to be verified. (required) + * + * @throws InvalidArgumentException + */ + private function verifyDomainRequest(string $domainName): Request + { + $allData = [ + 'domainName' => $domainName, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'domainName' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/email/1/domains/{domainName}/verify'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($domainName !== null) { + $resourcePath = str_replace( + '{' . 'domainName' . '}', + $this->objectSerializer->toPathValue($domainName), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'verifyDomain' + * @throws ApiException on non-2xx response + * @return null + */ + private function verifyDomainResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'verifyDomain' + */ + private function verifyDomainApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } +} diff --git a/Infobip/Api/MmsApi.php b/Infobip/Api/MmsApi.php new file mode 100644 index 0000000..18e1f70 --- /dev/null +++ b/Infobip/Api/MmsApi.php @@ -0,0 +1,1084 @@ +config = $config; + $this->client = $client ?: new Client(); + $this->objectSerializer = $objectSerializer ?: new ObjectSerializer(); + $this->logger = $logger ?: new NullLogger(); + $this->deprecationChecker = $deprecationChecker ?: new DeprecationChecker($this->logger); + } + + /** + * Operation getInboundMmsMessages + * + * Get inbound MMS messages + * + * @param null|int $limit Maximal number of delivery reports that will be returned. (optional) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\MmsInboundReportResponse + */ + public function getInboundMmsMessages(?int $limit = null) + { + $request = $this->getInboundMmsMessagesRequest($limit); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->getInboundMmsMessagesResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->getInboundMmsMessagesApiException($exception); + } + } + + /** + * Operation getInboundMmsMessagesAsync + * + * Get inbound MMS messages + * + * @param null|int $limit Maximal number of delivery reports that will be returned. (optional) + * + * @throws InvalidArgumentException + */ + public function getInboundMmsMessagesAsync(?int $limit = null): PromiseInterface + { + $request = $this->getInboundMmsMessagesRequest($limit); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->getInboundMmsMessagesResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->getInboundMmsMessagesApiException($exception); + } + ); + } + + /** + * Create request for operation 'getInboundMmsMessages' + * + * @param null|int $limit Maximal number of delivery reports that will be returned. (optional) + * + * @throws InvalidArgumentException + */ + private function getInboundMmsMessagesRequest(?int $limit = null): Request + { + $allData = [ + 'limit' => $limit, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'limit' => [ + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/mms/1/inbox/reports'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // query params + if ($limit !== null) { + $queryParams['limit'] = $limit; + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'getInboundMmsMessages' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\MmsInboundReportResponse|null + */ + private function getInboundMmsMessagesResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\MmsInboundReportResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'getInboundMmsMessages' + */ + private function getInboundMmsMessagesApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + + return $apiException; + } + + /** + * Operation getOutboundMmsMessageDeliveryReports + * + * Get outbound MMS message delivery reports + * + * @param null|string $bulkId ID of bulk for which a delivery report is requested. (optional) + * @param null|string $messageId ID of MMS for which a delivery report is requested. (optional) + * @param null|int $limit Maximal number of delivery reports that will be returned. (optional) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\MmsReportResponse + */ + public function getOutboundMmsMessageDeliveryReports(?string $bulkId = null, ?string $messageId = null, ?int $limit = null) + { + $request = $this->getOutboundMmsMessageDeliveryReportsRequest($bulkId, $messageId, $limit); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->getOutboundMmsMessageDeliveryReportsResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->getOutboundMmsMessageDeliveryReportsApiException($exception); + } + } + + /** + * Operation getOutboundMmsMessageDeliveryReportsAsync + * + * Get outbound MMS message delivery reports + * + * @param null|string $bulkId ID of bulk for which a delivery report is requested. (optional) + * @param null|string $messageId ID of MMS for which a delivery report is requested. (optional) + * @param null|int $limit Maximal number of delivery reports that will be returned. (optional) + * + * @throws InvalidArgumentException + */ + public function getOutboundMmsMessageDeliveryReportsAsync(?string $bulkId = null, ?string $messageId = null, ?int $limit = null): PromiseInterface + { + $request = $this->getOutboundMmsMessageDeliveryReportsRequest($bulkId, $messageId, $limit); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->getOutboundMmsMessageDeliveryReportsResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->getOutboundMmsMessageDeliveryReportsApiException($exception); + } + ); + } + + /** + * Create request for operation 'getOutboundMmsMessageDeliveryReports' + * + * @param null|string $bulkId ID of bulk for which a delivery report is requested. (optional) + * @param null|string $messageId ID of MMS for which a delivery report is requested. (optional) + * @param null|int $limit Maximal number of delivery reports that will be returned. (optional) + * + * @throws InvalidArgumentException + */ + private function getOutboundMmsMessageDeliveryReportsRequest(?string $bulkId = null, ?string $messageId = null, ?int $limit = null): Request + { + $allData = [ + 'bulkId' => $bulkId, + 'messageId' => $messageId, + 'limit' => $limit, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'bulkId' => [ + ], + 'messageId' => [ + ], + 'limit' => [ + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/mms/1/reports'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // query params + if ($bulkId !== null) { + $queryParams['bulkId'] = $bulkId; + } + + // query params + if ($messageId !== null) { + $queryParams['messageId'] = $messageId; + } + + // query params + if ($limit !== null) { + $queryParams['limit'] = $limit; + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'getOutboundMmsMessageDeliveryReports' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\MmsReportResponse|null + */ + private function getOutboundMmsMessageDeliveryReportsResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\MmsReportResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'getOutboundMmsMessageDeliveryReports' + */ + private function getOutboundMmsMessageDeliveryReportsApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + + return $apiException; + } + + /** + * Operation sendMmsMessage + * + * Send MMS message + * + * @param \Infobip\Model\MmsAdvancedRequest $mmsAdvancedRequest mmsAdvancedRequest (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\MmsSendResult|\Infobip\Model\ApiException|object|object + */ + public function sendMmsMessage(\Infobip\Model\MmsAdvancedRequest $mmsAdvancedRequest) + { + $request = $this->sendMmsMessageRequest($mmsAdvancedRequest); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->sendMmsMessageResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->sendMmsMessageApiException($exception); + } + } + + /** + * Operation sendMmsMessageAsync + * + * Send MMS message + * + * @param \Infobip\Model\MmsAdvancedRequest $mmsAdvancedRequest (required) + * + * @throws InvalidArgumentException + */ + public function sendMmsMessageAsync(\Infobip\Model\MmsAdvancedRequest $mmsAdvancedRequest): PromiseInterface + { + $request = $this->sendMmsMessageRequest($mmsAdvancedRequest); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->sendMmsMessageResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->sendMmsMessageApiException($exception); + } + ); + } + + /** + * Create request for operation 'sendMmsMessage' + * + * @param \Infobip\Model\MmsAdvancedRequest $mmsAdvancedRequest (required) + * + * @throws InvalidArgumentException + */ + private function sendMmsMessageRequest(\Infobip\Model\MmsAdvancedRequest $mmsAdvancedRequest): Request + { + $allData = [ + 'mmsAdvancedRequest' => $mmsAdvancedRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'mmsAdvancedRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/mms/1/advanced'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($mmsAdvancedRequest)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($mmsAdvancedRequest) + : $mmsAdvancedRequest; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'sendMmsMessage' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\MmsSendResult|\Infobip\Model\ApiException|object|object|null + */ + private function sendMmsMessageResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\MmsSendResult', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'sendMmsMessage' + */ + private function sendMmsMessageApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + 'object', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + 'object', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation uploadBinary + * + * Upload binary content + * + * @param string $xContentId ContentId that uniquely identifies the binary content. (required) + * @param string $xMediaType Content mime type. Should be populated by standard MIME types (IANA media types). (required) + * @param \SplFileObject $body body (required) + * @param int $xValidityPeriodMinutes Validity period in minutes after which the content will be deleted. (default: 69120 minutes). (optional, default to 69120) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\ApiException|object|\Infobip\Model\MmsUploadBinaryResult|object + */ + public function uploadBinary(string $xContentId, string $xMediaType, \SplFileObject $body, int $xValidityPeriodMinutes = 69120) + { + $request = $this->uploadBinaryRequest($xContentId, $xMediaType, $body, $xValidityPeriodMinutes); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->uploadBinaryResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->uploadBinaryApiException($exception); + } + } + + /** + * Operation uploadBinaryAsync + * + * Upload binary content + * + * @param string $xContentId ContentId that uniquely identifies the binary content. (required) + * @param string $xMediaType Content mime type. Should be populated by standard MIME types (IANA media types). (required) + * @param \SplFileObject $body (required) + * @param int $xValidityPeriodMinutes Validity period in minutes after which the content will be deleted. (default: 69120 minutes). (optional, default to 69120) + * + * @throws InvalidArgumentException + */ + public function uploadBinaryAsync(string $xContentId, string $xMediaType, \SplFileObject $body, int $xValidityPeriodMinutes = 69120): PromiseInterface + { + $request = $this->uploadBinaryRequest($xContentId, $xMediaType, $body, $xValidityPeriodMinutes); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->uploadBinaryResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->uploadBinaryApiException($exception); + } + ); + } + + /** + * Create request for operation 'uploadBinary' + * + * @param string $xContentId ContentId that uniquely identifies the binary content. (required) + * @param string $xMediaType Content mime type. Should be populated by standard MIME types (IANA media types). (required) + * @param \SplFileObject $body (required) + * @param int $xValidityPeriodMinutes Validity period in minutes after which the content will be deleted. (default: 69120 minutes). (optional, default to 69120) + * + * @throws InvalidArgumentException + */ + private function uploadBinaryRequest(string $xContentId, string $xMediaType, \SplFileObject $body, int $xValidityPeriodMinutes = 69120): Request + { + $allData = [ + 'xContentId' => $xContentId, + 'xMediaType' => $xMediaType, + 'body' => $body, + 'xValidityPeriodMinutes' => $xValidityPeriodMinutes, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'xContentId' => [ + new Assert\NotBlank(), + ], + 'xMediaType' => [ + new Assert\NotBlank(), + ], + 'body' => [ + new Assert\NotBlank(), + ], + 'xValidityPeriodMinutes' => [ + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/mms/1/content'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // header params + if ($xContentId !== null) { + $headerParams['X-Content-Id'] = $this->objectSerializer->toHeaderValue($xContentId); + } + + // header params + if ($xMediaType !== null) { + $headerParams['X-Media-Type'] = $this->objectSerializer->toHeaderValue($xMediaType); + } + + // header params + if ($xValidityPeriodMinutes !== null) { + $headerParams['X-Validity-Period-Minutes'] = $this->objectSerializer->toHeaderValue($xValidityPeriodMinutes); + } + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/octet-stream', + ]; + + // for model (json/xml) + if (isset($body)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($body) + : $body; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'uploadBinary' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\ApiException|object|\Infobip\Model\MmsUploadBinaryResult|object|null + */ + private function uploadBinaryResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\MmsUploadBinaryResult', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'uploadBinary' + */ + private function uploadBinaryApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + 'object', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + 'object', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } +} diff --git a/Infobip/Api/SmsApi.php b/Infobip/Api/SmsApi.php new file mode 100644 index 0000000..6d9ed42 --- /dev/null +++ b/Infobip/Api/SmsApi.php @@ -0,0 +1,2685 @@ +config = $config; + $this->client = $client ?: new Client(); + $this->objectSerializer = $objectSerializer ?: new ObjectSerializer(); + $this->logger = $logger ?: new NullLogger(); + $this->deprecationChecker = $deprecationChecker ?: new DeprecationChecker($this->logger); + } + + /** + * Operation getInboundSmsMessages + * + * Get inbound SMS messages + * + * @param null|int $limit Maximum number of messages to be returned in a response. If not set, the latest 50 records are returned. Maximum limit value is `1000` and you can only access messages for the last 48h. (optional) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\SmsInboundMessageResult + */ + public function getInboundSmsMessages(?int $limit = null) + { + $request = $this->getInboundSmsMessagesRequest($limit); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->getInboundSmsMessagesResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->getInboundSmsMessagesApiException($exception); + } + } + + /** + * Operation getInboundSmsMessagesAsync + * + * Get inbound SMS messages + * + * @param null|int $limit Maximum number of messages to be returned in a response. If not set, the latest 50 records are returned. Maximum limit value is `1000` and you can only access messages for the last 48h. (optional) + * + * @throws InvalidArgumentException + */ + public function getInboundSmsMessagesAsync(?int $limit = null): PromiseInterface + { + $request = $this->getInboundSmsMessagesRequest($limit); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->getInboundSmsMessagesResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->getInboundSmsMessagesApiException($exception); + } + ); + } + + /** + * Create request for operation 'getInboundSmsMessages' + * + * @param null|int $limit Maximum number of messages to be returned in a response. If not set, the latest 50 records are returned. Maximum limit value is `1000` and you can only access messages for the last 48h. (optional) + * + * @throws InvalidArgumentException + */ + private function getInboundSmsMessagesRequest(?int $limit = null): Request + { + $allData = [ + 'limit' => $limit, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'limit' => [ + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/sms/1/inbox/reports'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // query params + if ($limit !== null) { + $queryParams['limit'] = $limit; + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'getInboundSmsMessages' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\SmsInboundMessageResult|null + */ + private function getInboundSmsMessagesResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\SmsInboundMessageResult', $responseHeaders); + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'getInboundSmsMessages' + */ + private function getInboundSmsMessagesApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode >= 400 && $statusCode <= 499) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode >= 500 && $statusCode <= 599) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\SmsInboundMessageResult', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + /** + * Operation getOutboundSmsMessageDeliveryReports + * + * Get outbound SMS message delivery reports + * + * @param null|string $bulkId Unique ID assigned to the request if messaging multiple recipients or sending multiple messages via a single API request. (optional) + * @param null|string $messageId Unique message ID for which a report is requested. (optional) + * @param int $limit Maximum number of delivery reports to be returned. If not set, the latest 50 records are returned. Maximum limit value is `1000` and you can only access reports for the last 48h. (optional, default to 50) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\SmsDeliveryResult|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function getOutboundSmsMessageDeliveryReports(?string $bulkId = null, ?string $messageId = null, int $limit = 50) + { + $request = $this->getOutboundSmsMessageDeliveryReportsRequest($bulkId, $messageId, $limit); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->getOutboundSmsMessageDeliveryReportsResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->getOutboundSmsMessageDeliveryReportsApiException($exception); + } + } + + /** + * Operation getOutboundSmsMessageDeliveryReportsAsync + * + * Get outbound SMS message delivery reports + * + * @param null|string $bulkId Unique ID assigned to the request if messaging multiple recipients or sending multiple messages via a single API request. (optional) + * @param null|string $messageId Unique message ID for which a report is requested. (optional) + * @param int $limit Maximum number of delivery reports to be returned. If not set, the latest 50 records are returned. Maximum limit value is `1000` and you can only access reports for the last 48h. (optional, default to 50) + * + * @throws InvalidArgumentException + */ + public function getOutboundSmsMessageDeliveryReportsAsync(?string $bulkId = null, ?string $messageId = null, int $limit = 50): PromiseInterface + { + $request = $this->getOutboundSmsMessageDeliveryReportsRequest($bulkId, $messageId, $limit); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->getOutboundSmsMessageDeliveryReportsResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->getOutboundSmsMessageDeliveryReportsApiException($exception); + } + ); + } + + /** + * Create request for operation 'getOutboundSmsMessageDeliveryReports' + * + * @param null|string $bulkId Unique ID assigned to the request if messaging multiple recipients or sending multiple messages via a single API request. (optional) + * @param null|string $messageId Unique message ID for which a report is requested. (optional) + * @param int $limit Maximum number of delivery reports to be returned. If not set, the latest 50 records are returned. Maximum limit value is `1000` and you can only access reports for the last 48h. (optional, default to 50) + * + * @throws InvalidArgumentException + */ + private function getOutboundSmsMessageDeliveryReportsRequest(?string $bulkId = null, ?string $messageId = null, int $limit = 50): Request + { + $allData = [ + 'bulkId' => $bulkId, + 'messageId' => $messageId, + 'limit' => $limit, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'bulkId' => [ + ], + 'messageId' => [ + ], + 'limit' => [ + new Assert\LessThan(1000), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/sms/1/reports'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // query params + if ($bulkId !== null) { + $queryParams['bulkId'] = $bulkId; + } + + // query params + if ($messageId !== null) { + $queryParams['messageId'] = $messageId; + } + + // query params + if ($limit !== null) { + $queryParams['limit'] = $limit; + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'getOutboundSmsMessageDeliveryReports' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\SmsDeliveryResult|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function getOutboundSmsMessageDeliveryReportsResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\SmsDeliveryResult', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'getOutboundSmsMessageDeliveryReports' + */ + private function getOutboundSmsMessageDeliveryReportsApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation getOutboundSmsMessageLogs + * + * Get outbound SMS message logs + * + * @param null|string $from The sender ID which can be alphanumeric or numeric. (optional) + * @param null|string $to Message destination address. (optional) + * @param null|string[] $bulkId Unique ID assigned to the request if messaging multiple recipients or sending multiple messages via a single API request. (optional) + * @param null|string[] $messageId Unique message ID for which a log is requested. (optional) + * @param null|string $generalStatus Sent [message status](https://www.infobip.com/docs/essentials/response-status-and-error-codes#api-status-codes). Possible values: `ACCEPTED`, `PENDING`, `UNDELIVERABLE`, `DELIVERED`, `REJECTED`, `EXPIRED`. (optional) + * @param null|\DateTime $sentSince The logs will only include messages sent after this date. Use it together with `sentUntil` to return a time range or if you want to fetch more than 1000 logs allowed per call. Has the following format: `yyyy-MM-dd'T'HH:mm:ss.SSSZ`. (optional) + * @param null|\DateTime $sentUntil The logs will only include messages sent before this date. Use it together with `sentBefore` to return a time range or if you want to fetch more than 1000 logs allowed per call. Has the following format: `yyyy-MM-dd'T'HH:mm:ss.SSSZ`. (optional) + * @param null|int $limit Maximum number of messages to include in logs. If not set, the latest 50 records are returned. Maximum limit value is `1000` and you can only access logs for the last 48h. If you want to fetch more than 1000 logs allowed per call, use `sentBefore` and `sentUntil` to retrieve them in pages. (optional) + * @param null|string $mcc Mobile Country Code. (optional) + * @param null|string $mnc Mobile Network Code. (optional) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\SmsLogsResponse + */ + public function getOutboundSmsMessageLogs(?string $from = null, ?string $to = null, ?array $bulkId = null, ?array $messageId = null, ?string $generalStatus = null, ?\DateTime $sentSince = null, ?\DateTime $sentUntil = null, ?int $limit = null, ?string $mcc = null, ?string $mnc = null) + { + $request = $this->getOutboundSmsMessageLogsRequest($from, $to, $bulkId, $messageId, $generalStatus, $sentSince, $sentUntil, $limit, $mcc, $mnc); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->getOutboundSmsMessageLogsResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->getOutboundSmsMessageLogsApiException($exception); + } + } + + /** + * Operation getOutboundSmsMessageLogsAsync + * + * Get outbound SMS message logs + * + * @param null|string $from The sender ID which can be alphanumeric or numeric. (optional) + * @param null|string $to Message destination address. (optional) + * @param null|string[] $bulkId Unique ID assigned to the request if messaging multiple recipients or sending multiple messages via a single API request. (optional) + * @param null|string[] $messageId Unique message ID for which a log is requested. (optional) + * @param null|string $generalStatus Sent [message status](https://www.infobip.com/docs/essentials/response-status-and-error-codes#api-status-codes). Possible values: `ACCEPTED`, `PENDING`, `UNDELIVERABLE`, `DELIVERED`, `REJECTED`, `EXPIRED`. (optional) + * @param null|\DateTime $sentSince The logs will only include messages sent after this date. Use it together with `sentUntil` to return a time range or if you want to fetch more than 1000 logs allowed per call. Has the following format: `yyyy-MM-dd'T'HH:mm:ss.SSSZ`. (optional) + * @param null|\DateTime $sentUntil The logs will only include messages sent before this date. Use it together with `sentBefore` to return a time range or if you want to fetch more than 1000 logs allowed per call. Has the following format: `yyyy-MM-dd'T'HH:mm:ss.SSSZ`. (optional) + * @param null|int $limit Maximum number of messages to include in logs. If not set, the latest 50 records are returned. Maximum limit value is `1000` and you can only access logs for the last 48h. If you want to fetch more than 1000 logs allowed per call, use `sentBefore` and `sentUntil` to retrieve them in pages. (optional) + * @param null|string $mcc Mobile Country Code. (optional) + * @param null|string $mnc Mobile Network Code. (optional) + * + * @throws InvalidArgumentException + */ + public function getOutboundSmsMessageLogsAsync(?string $from = null, ?string $to = null, ?array $bulkId = null, ?array $messageId = null, ?string $generalStatus = null, ?\DateTime $sentSince = null, ?\DateTime $sentUntil = null, ?int $limit = null, ?string $mcc = null, ?string $mnc = null): PromiseInterface + { + $request = $this->getOutboundSmsMessageLogsRequest($from, $to, $bulkId, $messageId, $generalStatus, $sentSince, $sentUntil, $limit, $mcc, $mnc); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->getOutboundSmsMessageLogsResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->getOutboundSmsMessageLogsApiException($exception); + } + ); + } + + /** + * Create request for operation 'getOutboundSmsMessageLogs' + * + * @param null|string $from The sender ID which can be alphanumeric or numeric. (optional) + * @param null|string $to Message destination address. (optional) + * @param null|string[] $bulkId Unique ID assigned to the request if messaging multiple recipients or sending multiple messages via a single API request. (optional) + * @param null|string[] $messageId Unique message ID for which a log is requested. (optional) + * @param null|string $generalStatus Sent [message status](https://www.infobip.com/docs/essentials/response-status-and-error-codes#api-status-codes). Possible values: `ACCEPTED`, `PENDING`, `UNDELIVERABLE`, `DELIVERED`, `REJECTED`, `EXPIRED`. (optional) + * @param null|\DateTime $sentSince The logs will only include messages sent after this date. Use it together with `sentUntil` to return a time range or if you want to fetch more than 1000 logs allowed per call. Has the following format: `yyyy-MM-dd'T'HH:mm:ss.SSSZ`. (optional) + * @param null|\DateTime $sentUntil The logs will only include messages sent before this date. Use it together with `sentBefore` to return a time range or if you want to fetch more than 1000 logs allowed per call. Has the following format: `yyyy-MM-dd'T'HH:mm:ss.SSSZ`. (optional) + * @param null|int $limit Maximum number of messages to include in logs. If not set, the latest 50 records are returned. Maximum limit value is `1000` and you can only access logs for the last 48h. If you want to fetch more than 1000 logs allowed per call, use `sentBefore` and `sentUntil` to retrieve them in pages. (optional) + * @param null|string $mcc Mobile Country Code. (optional) + * @param null|string $mnc Mobile Network Code. (optional) + * + * @throws InvalidArgumentException + */ + private function getOutboundSmsMessageLogsRequest(?string $from = null, ?string $to = null, ?array $bulkId = null, ?array $messageId = null, ?string $generalStatus = null, ?\DateTime $sentSince = null, ?\DateTime $sentUntil = null, ?int $limit = null, ?string $mcc = null, ?string $mnc = null): Request + { + $allData = [ + 'from' => $from, + 'to' => $to, + 'bulkId' => $bulkId, + 'messageId' => $messageId, + 'generalStatus' => $generalStatus, + 'sentSince' => $sentSince, + 'sentUntil' => $sentUntil, + 'limit' => $limit, + 'mcc' => $mcc, + 'mnc' => $mnc, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'from' => [ + ], + 'to' => [ + ], + 'bulkId' => [ + ], + 'messageId' => [ + ], + 'generalStatus' => [ + ], + 'sentSince' => [ + ], + 'sentUntil' => [ + ], + 'limit' => [ + ], + 'mcc' => [ + ], + 'mnc' => [ + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/sms/1/logs'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // query params + if ($from !== null) { + $queryParams['from'] = $from; + } + + // query params + if ($to !== null) { + $queryParams['to'] = $to; + } + + // query params + if ($bulkId !== null) { + $queryParams['bulkId'] = $bulkId; + } + + // query params + if ($messageId !== null) { + $queryParams['messageId'] = $messageId; + } + + // query params + if ($generalStatus !== null) { + $queryParams['generalStatus'] = $generalStatus; + } + + // query params + if ($sentSince !== null) { + $queryParams['sentSince'] = $sentSince; + } + + // query params + if ($sentUntil !== null) { + $queryParams['sentUntil'] = $sentUntil; + } + + // query params + if ($limit !== null) { + $queryParams['limit'] = $limit; + } + + // query params + if ($mcc !== null) { + $queryParams['mcc'] = $mcc; + } + + // query params + if ($mnc !== null) { + $queryParams['mnc'] = $mnc; + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'getOutboundSmsMessageLogs' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\SmsLogsResponse|null + */ + private function getOutboundSmsMessageLogsResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\SmsLogsResponse', $responseHeaders); + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'getOutboundSmsMessageLogs' + */ + private function getOutboundSmsMessageLogsApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode >= 400 && $statusCode <= 499) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode >= 500 && $statusCode <= 599) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\SmsLogsResponse', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + /** + * Operation getScheduledSmsMessages + * + * Get scheduled SMS messages + * + * @param string $bulkId (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\SmsBulkResponse + */ + public function getScheduledSmsMessages(string $bulkId) + { + $request = $this->getScheduledSmsMessagesRequest($bulkId); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->getScheduledSmsMessagesResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->getScheduledSmsMessagesApiException($exception); + } + } + + /** + * Operation getScheduledSmsMessagesAsync + * + * Get scheduled SMS messages + * + * @param string $bulkId (required) + * + * @throws InvalidArgumentException + */ + public function getScheduledSmsMessagesAsync(string $bulkId): PromiseInterface + { + $request = $this->getScheduledSmsMessagesRequest($bulkId); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->getScheduledSmsMessagesResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->getScheduledSmsMessagesApiException($exception); + } + ); + } + + /** + * Create request for operation 'getScheduledSmsMessages' + * + * @param string $bulkId (required) + * + * @throws InvalidArgumentException + */ + private function getScheduledSmsMessagesRequest(string $bulkId): Request + { + $allData = [ + 'bulkId' => $bulkId, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'bulkId' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/sms/1/bulks'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // query params + if ($bulkId !== null) { + $queryParams['bulkId'] = $bulkId; + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'getScheduledSmsMessages' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\SmsBulkResponse|null + */ + private function getScheduledSmsMessagesResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\SmsBulkResponse', $responseHeaders); + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'getScheduledSmsMessages' + */ + private function getScheduledSmsMessagesApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode >= 400 && $statusCode <= 499) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode >= 500 && $statusCode <= 599) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\SmsBulkResponse', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + /** + * Operation getScheduledSmsMessagesStatus + * + * Get scheduled SMS messages status + * + * @param string $bulkId bulkId (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\SmsBulkStatusResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function getScheduledSmsMessagesStatus(string $bulkId) + { + $request = $this->getScheduledSmsMessagesStatusRequest($bulkId); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->getScheduledSmsMessagesStatusResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->getScheduledSmsMessagesStatusApiException($exception); + } + } + + /** + * Operation getScheduledSmsMessagesStatusAsync + * + * Get scheduled SMS messages status + * + * @param string $bulkId (required) + * + * @throws InvalidArgumentException + */ + public function getScheduledSmsMessagesStatusAsync(string $bulkId): PromiseInterface + { + $request = $this->getScheduledSmsMessagesStatusRequest($bulkId); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->getScheduledSmsMessagesStatusResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->getScheduledSmsMessagesStatusApiException($exception); + } + ); + } + + /** + * Create request for operation 'getScheduledSmsMessagesStatus' + * + * @param string $bulkId (required) + * + * @throws InvalidArgumentException + */ + private function getScheduledSmsMessagesStatusRequest(string $bulkId): Request + { + $allData = [ + 'bulkId' => $bulkId, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'bulkId' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/sms/1/bulks/status'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // query params + if ($bulkId !== null) { + $queryParams['bulkId'] = $bulkId; + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'getScheduledSmsMessagesStatus' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\SmsBulkStatusResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function getScheduledSmsMessagesStatusResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\SmsBulkStatusResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'getScheduledSmsMessagesStatus' + */ + private function getScheduledSmsMessagesStatusApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 404) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation previewSmsMessage + * + * Preview SMS message + * + * @param \Infobip\Model\SmsPreviewRequest $smsPreviewRequest smsPreviewRequest (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\SmsPreviewResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function previewSmsMessage(\Infobip\Model\SmsPreviewRequest $smsPreviewRequest) + { + $request = $this->previewSmsMessageRequest($smsPreviewRequest); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->previewSmsMessageResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->previewSmsMessageApiException($exception); + } + } + + /** + * Operation previewSmsMessageAsync + * + * Preview SMS message + * + * @param \Infobip\Model\SmsPreviewRequest $smsPreviewRequest (required) + * + * @throws InvalidArgumentException + */ + public function previewSmsMessageAsync(\Infobip\Model\SmsPreviewRequest $smsPreviewRequest): PromiseInterface + { + $request = $this->previewSmsMessageRequest($smsPreviewRequest); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->previewSmsMessageResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->previewSmsMessageApiException($exception); + } + ); + } + + /** + * Create request for operation 'previewSmsMessage' + * + * @param \Infobip\Model\SmsPreviewRequest $smsPreviewRequest (required) + * + * @throws InvalidArgumentException + */ + private function previewSmsMessageRequest(\Infobip\Model\SmsPreviewRequest $smsPreviewRequest): Request + { + $allData = [ + 'smsPreviewRequest' => $smsPreviewRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'smsPreviewRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/sms/1/preview'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($smsPreviewRequest)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($smsPreviewRequest) + : $smsPreviewRequest; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'previewSmsMessage' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\SmsPreviewResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function previewSmsMessageResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\SmsPreviewResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'previewSmsMessage' + */ + private function previewSmsMessageApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation rescheduleSmsMessages + * + * Reschedule SMS messages + * + * @param string $bulkId (required) + * @param \Infobip\Model\SmsBulkRequest $smsBulkRequest smsBulkRequest (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\SmsBulkResponse + */ + public function rescheduleSmsMessages(string $bulkId, \Infobip\Model\SmsBulkRequest $smsBulkRequest) + { + $request = $this->rescheduleSmsMessagesRequest($bulkId, $smsBulkRequest); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->rescheduleSmsMessagesResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->rescheduleSmsMessagesApiException($exception); + } + } + + /** + * Operation rescheduleSmsMessagesAsync + * + * Reschedule SMS messages + * + * @param string $bulkId (required) + * @param \Infobip\Model\SmsBulkRequest $smsBulkRequest (required) + * + * @throws InvalidArgumentException + */ + public function rescheduleSmsMessagesAsync(string $bulkId, \Infobip\Model\SmsBulkRequest $smsBulkRequest): PromiseInterface + { + $request = $this->rescheduleSmsMessagesRequest($bulkId, $smsBulkRequest); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->rescheduleSmsMessagesResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->rescheduleSmsMessagesApiException($exception); + } + ); + } + + /** + * Create request for operation 'rescheduleSmsMessages' + * + * @param string $bulkId (required) + * @param \Infobip\Model\SmsBulkRequest $smsBulkRequest (required) + * + * @throws InvalidArgumentException + */ + private function rescheduleSmsMessagesRequest(string $bulkId, \Infobip\Model\SmsBulkRequest $smsBulkRequest): Request + { + $allData = [ + 'bulkId' => $bulkId, + 'smsBulkRequest' => $smsBulkRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'bulkId' => [ + new Assert\NotBlank(), + ], + 'smsBulkRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/sms/1/bulks'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // query params + if ($bulkId !== null) { + $queryParams['bulkId'] = $bulkId; + } + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($smsBulkRequest)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($smsBulkRequest) + : $smsBulkRequest; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'PUT', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'rescheduleSmsMessages' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\SmsBulkResponse|null + */ + private function rescheduleSmsMessagesResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\SmsBulkResponse', $responseHeaders); + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'rescheduleSmsMessages' + */ + private function rescheduleSmsMessagesApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode >= 400 && $statusCode <= 499) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode >= 500 && $statusCode <= 599) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\SmsBulkResponse', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + /** + * Operation sendBinarySmsMessage + * + * Send binary SMS message + * + * @param \Infobip\Model\SmsAdvancedBinaryRequest $smsAdvancedBinaryRequest smsAdvancedBinaryRequest (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\SmsResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function sendBinarySmsMessage(\Infobip\Model\SmsAdvancedBinaryRequest $smsAdvancedBinaryRequest) + { + $request = $this->sendBinarySmsMessageRequest($smsAdvancedBinaryRequest); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->sendBinarySmsMessageResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->sendBinarySmsMessageApiException($exception); + } + } + + /** + * Operation sendBinarySmsMessageAsync + * + * Send binary SMS message + * + * @param \Infobip\Model\SmsAdvancedBinaryRequest $smsAdvancedBinaryRequest (required) + * + * @throws InvalidArgumentException + */ + public function sendBinarySmsMessageAsync(\Infobip\Model\SmsAdvancedBinaryRequest $smsAdvancedBinaryRequest): PromiseInterface + { + $request = $this->sendBinarySmsMessageRequest($smsAdvancedBinaryRequest); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->sendBinarySmsMessageResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->sendBinarySmsMessageApiException($exception); + } + ); + } + + /** + * Create request for operation 'sendBinarySmsMessage' + * + * @param \Infobip\Model\SmsAdvancedBinaryRequest $smsAdvancedBinaryRequest (required) + * + * @throws InvalidArgumentException + */ + private function sendBinarySmsMessageRequest(\Infobip\Model\SmsAdvancedBinaryRequest $smsAdvancedBinaryRequest): Request + { + $allData = [ + 'smsAdvancedBinaryRequest' => $smsAdvancedBinaryRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'smsAdvancedBinaryRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/sms/2/binary/advanced'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($smsAdvancedBinaryRequest)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($smsAdvancedBinaryRequest) + : $smsAdvancedBinaryRequest; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'sendBinarySmsMessage' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\SmsResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function sendBinarySmsMessageResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\SmsResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'sendBinarySmsMessage' + */ + private function sendBinarySmsMessageApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation sendSmsMessage + * + * Send SMS message + * + * @param \Infobip\Model\SmsAdvancedTextualRequest $smsAdvancedTextualRequest smsAdvancedTextualRequest (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\SmsResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function sendSmsMessage(\Infobip\Model\SmsAdvancedTextualRequest $smsAdvancedTextualRequest) + { + $request = $this->sendSmsMessageRequest($smsAdvancedTextualRequest); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->sendSmsMessageResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->sendSmsMessageApiException($exception); + } + } + + /** + * Operation sendSmsMessageAsync + * + * Send SMS message + * + * @param \Infobip\Model\SmsAdvancedTextualRequest $smsAdvancedTextualRequest (required) + * + * @throws InvalidArgumentException + */ + public function sendSmsMessageAsync(\Infobip\Model\SmsAdvancedTextualRequest $smsAdvancedTextualRequest): PromiseInterface + { + $request = $this->sendSmsMessageRequest($smsAdvancedTextualRequest); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->sendSmsMessageResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->sendSmsMessageApiException($exception); + } + ); + } + + /** + * Create request for operation 'sendSmsMessage' + * + * @param \Infobip\Model\SmsAdvancedTextualRequest $smsAdvancedTextualRequest (required) + * + * @throws InvalidArgumentException + */ + private function sendSmsMessageRequest(\Infobip\Model\SmsAdvancedTextualRequest $smsAdvancedTextualRequest): Request + { + $allData = [ + 'smsAdvancedTextualRequest' => $smsAdvancedTextualRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'smsAdvancedTextualRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/sms/2/text/advanced'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($smsAdvancedTextualRequest)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($smsAdvancedTextualRequest) + : $smsAdvancedTextualRequest; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'sendSmsMessage' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\SmsResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function sendSmsMessageResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\SmsResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'sendSmsMessage' + */ + private function sendSmsMessageApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation updateScheduledSmsMessagesStatus + * + * Update scheduled SMS messages status + * + * @param string $bulkId (required) + * @param \Infobip\Model\SmsUpdateStatusRequest $smsUpdateStatusRequest smsUpdateStatusRequest (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\SmsBulkStatusResponse + */ + public function updateScheduledSmsMessagesStatus(string $bulkId, \Infobip\Model\SmsUpdateStatusRequest $smsUpdateStatusRequest) + { + $request = $this->updateScheduledSmsMessagesStatusRequest($bulkId, $smsUpdateStatusRequest); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->updateScheduledSmsMessagesStatusResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->updateScheduledSmsMessagesStatusApiException($exception); + } + } + + /** + * Operation updateScheduledSmsMessagesStatusAsync + * + * Update scheduled SMS messages status + * + * @param string $bulkId (required) + * @param \Infobip\Model\SmsUpdateStatusRequest $smsUpdateStatusRequest (required) + * + * @throws InvalidArgumentException + */ + public function updateScheduledSmsMessagesStatusAsync(string $bulkId, \Infobip\Model\SmsUpdateStatusRequest $smsUpdateStatusRequest): PromiseInterface + { + $request = $this->updateScheduledSmsMessagesStatusRequest($bulkId, $smsUpdateStatusRequest); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->updateScheduledSmsMessagesStatusResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->updateScheduledSmsMessagesStatusApiException($exception); + } + ); + } + + /** + * Create request for operation 'updateScheduledSmsMessagesStatus' + * + * @param string $bulkId (required) + * @param \Infobip\Model\SmsUpdateStatusRequest $smsUpdateStatusRequest (required) + * + * @throws InvalidArgumentException + */ + private function updateScheduledSmsMessagesStatusRequest(string $bulkId, \Infobip\Model\SmsUpdateStatusRequest $smsUpdateStatusRequest): Request + { + $allData = [ + 'bulkId' => $bulkId, + 'smsUpdateStatusRequest' => $smsUpdateStatusRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'bulkId' => [ + new Assert\NotBlank(), + ], + 'smsUpdateStatusRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/sms/1/bulks/status'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // query params + if ($bulkId !== null) { + $queryParams['bulkId'] = $bulkId; + } + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($smsUpdateStatusRequest)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($smsUpdateStatusRequest) + : $smsUpdateStatusRequest; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'PUT', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'updateScheduledSmsMessagesStatus' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\SmsBulkStatusResponse|null + */ + private function updateScheduledSmsMessagesStatusResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\SmsBulkStatusResponse', $responseHeaders); + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'updateScheduledSmsMessagesStatus' + */ + private function updateScheduledSmsMessagesStatusApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode >= 400 && $statusCode <= 499) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode >= 500 && $statusCode <= 599) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\SmsBulkStatusResponse', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } +} diff --git a/Infobip/Api/TfaApi.php b/Infobip/Api/TfaApi.php index 1677b20..8ae6c8f 100644 --- a/Infobip/Api/TfaApi.php +++ b/Infobip/Api/TfaApi.php @@ -1,7 +1,10 @@ config = $config; $this->client = $client ?: new Client(); - $this->config = $config ?: new Configuration(); - $this->headerSelector = $selector ?: new HeaderSelector(); - } - - /** - * @return Configuration - */ - public function getConfig() - { - return $this->config; + $this->objectSerializer = $objectSerializer ?: new ObjectSerializer(); + $this->logger = $logger ?: new NullLogger(); + $this->deprecationChecker = $deprecationChecker ?: new DeprecationChecker($this->logger); } /** @@ -87,48 +84,33 @@ public function getConfig() * * Create 2FA application * - * @param \Infobip\Model\TfaApplicationRequest $tfaApplicationRequest tfaApplicationRequest (optional) - * - * @throws \Infobip\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \Infobip\Model\TfaApiException|\Infobip\Model\TfaApiException|\Infobip\Model\TfaApplicationResponse - */ - public function createTfaApplication($tfaApplicationRequest = null) - { - list($response) = $this->createTfaApplicationWithHttpInfo($tfaApplicationRequest); - return $response; - } - - /** - * Operation createTfaApplicationWithHttpInfo - * - * Create 2FA application - * - * @param \Infobip\Model\TfaApplicationRequest $tfaApplicationRequest (optional) + * @param \Infobip\Model\TfaApplicationRequest $tfaApplicationRequest tfaApplicationRequest (required) * - * @throws \Infobip\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \Infobip\Model\TfaApiException|\Infobip\Model\TfaApiException|\Infobip\Model\TfaApplicationResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\TfaApplicationResponse */ - public function createTfaApplicationWithHttpInfo($tfaApplicationRequest = null) + public function createTfaApplication(\Infobip\Model\TfaApplicationRequest $tfaApplicationRequest) { $request = $this->createTfaApplicationRequest($tfaApplicationRequest); try { - $options = $this->createHttpClientOption(); try { - $response = $this->client->send($request, $options); + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); return $this->createTfaApplicationResponse($response, $request->getUri()); - } catch (RequestException $e) { + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null ); } - } catch (ApiException $e) { - throw $this->createTfaApplicationApiException($e); + } catch (ApiException $exception) { + throw $this->createTfaApplicationApiException($exception); } } @@ -137,51 +119,35 @@ public function createTfaApplicationWithHttpInfo($tfaApplicationRequest = null) * * Create 2FA application * - * @param \Infobip\Model\TfaApplicationRequest $tfaApplicationRequest (optional) + * @param \Infobip\Model\TfaApplicationRequest $tfaApplicationRequest (required) * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws InvalidArgumentException */ - public function createTfaApplicationAsync($tfaApplicationRequest = null) - { - return $this->createTfaApplicationAsyncWithHttpInfo($tfaApplicationRequest) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation createTfaApplicationAsyncWithHttpInfo - * - * Create 2FA application - * - * @param \Infobip\Model\TfaApplicationRequest $tfaApplicationRequest (optional) - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function createTfaApplicationAsyncWithHttpInfo($tfaApplicationRequest = null) + public function createTfaApplicationAsync(\Infobip\Model\TfaApplicationRequest $tfaApplicationRequest): PromiseInterface { $request = $this->createTfaApplicationRequest($tfaApplicationRequest); - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) + return $this + ->client + ->sendAsync($request) ->then( function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); return $this->createTfaApplicationResponse($response, $request->getUri()); }, - function ($exception) { + function (GuzzleException $exception) { $statusCode = $exception->getCode(); - $response = $exception->getResponse(); - $e = new ApiException( + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( "[{$statusCode}] {$exception->getMessage()}", $statusCode, - $response ? $response->getHeaders() : null, - $response ? (string) $response->getBody() : null + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null ); - throw $this->createTfaApplicationApiException($e); + + throw $this->createTfaApplicationApiException($exception); } ); } @@ -189,42 +155,57 @@ function ($exception) { /** * Create request for operation 'createTfaApplication' * - * @param \Infobip\Model\TfaApplicationRequest $tfaApplicationRequest (optional) + * @param \Infobip\Model\TfaApplicationRequest $tfaApplicationRequest (required) * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws InvalidArgumentException */ - protected function createTfaApplicationRequest($tfaApplicationRequest = null) + private function createTfaApplicationRequest(\Infobip\Model\TfaApplicationRequest $tfaApplicationRequest): Request { + $allData = [ + 'tfaApplicationRequest' => $tfaApplicationRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'tfaApplicationRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + $resourcePath = '/2fa/2/applications'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; - - - - - $headers = $this->headerSelector->selectHeaders( - ['application/json', 'application/xml'], - ['application/json', 'application/xml'] - ); + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; // for model (json/xml) if (isset($tfaApplicationRequest)) { - if ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($tfaApplicationRequest)); - } else { - $httpBody = $tfaApplicationRequest; - } + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($tfaApplicationRequest) + : $tfaApplicationRequest; } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + if ($headers['Content-Type'] === 'multipart/form-data') { - $boundary = '----'.hash('sha256', uniqid('', true)); + $boundary = '----' . hash('sha256', uniqid('', true)); $headers['Content-Type'] .= '; boundary=' . $boundary; $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + $formParamValueItems = (\is_array($formParamValue)) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { $multipartContents[] = [ 'name' => $formParamName, @@ -232,47 +213,45 @@ protected function createTfaApplicationRequest($tfaApplicationRequest = null) ]; } } + // for HTTP post (form) $httpBody = new MultipartStream($multipartContents, $boundary); } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); + $httpBody = $this->objectSerializer->serialize($formParams); } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); + $httpBody = Query::build($formParams); } } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('Authorization'); - if ($apiKey !== null) { - $headers['Authorization'] = $apiKey; - } - // this endpoint requires HTTP basic authentication - if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) { - $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); - } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('Authorization'); + $apiKey = $this->config->getApiKey(); + if ($apiKey !== null) { - $headers['Authorization'] = $apiKey; - } - // this endpoint requires OAuth (access token) - if (!empty($this->config->getAccessToken())) { - $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + $headers[$this->config->getApiKeyHeader()] = $apiKey; } $defaultHeaders = []; + if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } - $headers = array_merge( + $headers = \array_merge( $defaultHeaders, $headerParams, $headers ); - $query = \GuzzleHttp\Psr7\Query::build($queryParams); + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), @@ -283,14 +262,10 @@ protected function createTfaApplicationRequest($tfaApplicationRequest = null) /** * Create response for operation 'createTfaApplication' - * - * @param \GuzzleHttp\Psr7\Response $response - * @param string $requestUri - * - * @throws \Infobip\ApiException on non-2xx response - * @return array of \Infobip\Model\TfaApiException|\Infobip\Model\TfaApiException|\Infobip\Model\TfaApplicationResponse|null, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\TfaApplicationResponse|null */ - protected function createTfaApplicationResponse($response, $requestUri) + private function createTfaApplicationResponse(ResponseInterface $response, UriInterface $requestUri): mixed { $statusCode = $response->getStatusCode(); $responseBody = $response->getBody(); @@ -298,67 +273,56 @@ protected function createTfaApplicationResponse($response, $requestUri) if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( - sprintf('[%d] Error connecting to the API (%s)', $statusCode, $requestUri), + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), $statusCode, $responseHeaders, $responseBody ); } - $responseObject = null; - + $responseResult = null; - $type = '\Infobip\Model\TfaApplicationResponse'; - if ($type === '\SplFileObject') { - $content = $responseBody; //stream goes to serializer - } else { - $content = (string) $responseBody; - } - $responseObject = ObjectSerializer::deserialize($content, $type, $responseHeaders); - - return [ - $responseObject, - $statusCode, - $responseHeaders - ]; + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\TfaApplicationResponse', $responseHeaders); + return $responseResult; } /** - * Adapt given \Infobip\ApiException for operation 'createTfaApplication' - * - * @param \Infobip\ApiException $apiException - * - * @return \Infobip\ApiException + * Adapt given ApiException for operation 'createTfaApplication' */ - protected function createTfaApplicationApiException($apiException) + private function createTfaApplicationApiException(ApiException $apiException): ApiException { $statusCode = $apiException->getCode(); if ($statusCode >= 400 && $statusCode <= 499) { - $data = ObjectSerializer::deserialize( + $data = $this->objectSerializer->deserialize( $apiException->getResponseBody(), - '\Infobip\Model\TfaApiException', + '\Infobip\Model\ApiException', $apiException->getResponseHeaders() ); + $apiException->setResponseObject($data); + return $apiException; } if ($statusCode >= 500 && $statusCode <= 599) { - $data = ObjectSerializer::deserialize( + $data = $this->objectSerializer->deserialize( $apiException->getResponseBody(), - '\Infobip\Model\TfaApiException', + '\Infobip\Model\ApiException', $apiException->getResponseHeaders() ); + $apiException->setResponseObject($data); + return $apiException; } - - $data = ObjectSerializer::deserialize( + $data = $this->objectSerializer->deserialize( $apiException->getResponseBody(), '\Infobip\Model\TfaApplicationResponse', $apiException->getResponseHeaders() ); + $apiException->setResponseObject($data); + return $apiException; } @@ -367,50 +331,34 @@ protected function createTfaApplicationApiException($apiException) * * Create 2FA message template * - * @param string $appId ID of application for which requested message was created. (required) - * @param \Infobip\Model\TfaCreateMessageRequest $tfaCreateMessageRequest tfaCreateMessageRequest (optional) - * - * @throws \Infobip\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \Infobip\Model\TfaApiException|\Infobip\Model\TfaApiException|\Infobip\Model\TfaMessage - */ - public function createTfaMessageTemplate($appId, $tfaCreateMessageRequest = null) - { - list($response) = $this->createTfaMessageTemplateWithHttpInfo($appId, $tfaCreateMessageRequest); - return $response; - } - - /** - * Operation createTfaMessageTemplateWithHttpInfo - * - * Create 2FA message template - * - * @param string $appId ID of application for which requested message was created. (required) - * @param \Infobip\Model\TfaCreateMessageRequest $tfaCreateMessageRequest (optional) + * @param string $appId ID of application for which requested message was created. (required) + * @param \Infobip\Model\TfaCreateMessageRequest $tfaCreateMessageRequest tfaCreateMessageRequest (required) * - * @throws \Infobip\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \Infobip\Model\TfaApiException|\Infobip\Model\TfaApiException|\Infobip\Model\TfaMessage, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\TfaMessage */ - public function createTfaMessageTemplateWithHttpInfo($appId, $tfaCreateMessageRequest = null) + public function createTfaMessageTemplate(string $appId, \Infobip\Model\TfaCreateMessageRequest $tfaCreateMessageRequest) { $request = $this->createTfaMessageTemplateRequest($appId, $tfaCreateMessageRequest); try { - $options = $this->createHttpClientOption(); try { - $response = $this->client->send($request, $options); + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); return $this->createTfaMessageTemplateResponse($response, $request->getUri()); - } catch (RequestException $e) { + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null ); } - } catch (ApiException $e) { - throw $this->createTfaMessageTemplateApiException($e); + } catch (ApiException $exception) { + throw $this->createTfaMessageTemplateApiException($exception); } } @@ -419,53 +367,36 @@ public function createTfaMessageTemplateWithHttpInfo($appId, $tfaCreateMessageRe * * Create 2FA message template * - * @param string $appId ID of application for which requested message was created. (required) - * @param \Infobip\Model\TfaCreateMessageRequest $tfaCreateMessageRequest (optional) - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function createTfaMessageTemplateAsync($appId, $tfaCreateMessageRequest = null) - { - return $this->createTfaMessageTemplateAsyncWithHttpInfo($appId, $tfaCreateMessageRequest) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation createTfaMessageTemplateAsyncWithHttpInfo - * - * Create 2FA message template - * - * @param string $appId ID of application for which requested message was created. (required) - * @param \Infobip\Model\TfaCreateMessageRequest $tfaCreateMessageRequest (optional) + * @param string $appId ID of application for which requested message was created. (required) + * @param \Infobip\Model\TfaCreateMessageRequest $tfaCreateMessageRequest (required) * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws InvalidArgumentException */ - public function createTfaMessageTemplateAsyncWithHttpInfo($appId, $tfaCreateMessageRequest = null) + public function createTfaMessageTemplateAsync(string $appId, \Infobip\Model\TfaCreateMessageRequest $tfaCreateMessageRequest): PromiseInterface { $request = $this->createTfaMessageTemplateRequest($appId, $tfaCreateMessageRequest); - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) + return $this + ->client + ->sendAsync($request) ->then( function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); return $this->createTfaMessageTemplateResponse($response, $request->getUri()); }, - function ($exception) { + function (GuzzleException $exception) { $statusCode = $exception->getCode(); - $response = $exception->getResponse(); - $e = new ApiException( + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( "[{$statusCode}] {$exception->getMessage()}", $statusCode, - $response ? $response->getHeaders() : null, - $response ? (string) $response->getBody() : null + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null ); - throw $this->createTfaMessageTemplateApiException($e); + + throw $this->createTfaMessageTemplateApiException($exception); } ); } @@ -473,20 +404,34 @@ function ($exception) { /** * Create request for operation 'createTfaMessageTemplate' * - * @param string $appId ID of application for which requested message was created. (required) - * @param \Infobip\Model\TfaCreateMessageRequest $tfaCreateMessageRequest (optional) + * @param string $appId ID of application for which requested message was created. (required) + * @param \Infobip\Model\TfaCreateMessageRequest $tfaCreateMessageRequest (required) * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws InvalidArgumentException */ - protected function createTfaMessageTemplateRequest($appId, $tfaCreateMessageRequest = null) + private function createTfaMessageTemplateRequest(string $appId, \Infobip\Model\TfaCreateMessageRequest $tfaCreateMessageRequest): Request { - // verify the required parameter 'appId' is set - if ($appId === null || (is_array($appId) && count($appId) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $appId when calling createTfaMessageTemplate' + $allData = [ + 'appId' => $appId, + 'tfaCreateMessageRequest' => $tfaCreateMessageRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'appId' => [ + new Assert\NotBlank(), + ], + 'tfaCreateMessageRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints ); - } + + $this->validateParams($allData, $validationConstraints); $resourcePath = '/2fa/2/applications/{appId}/messages'; $formParams = []; @@ -494,37 +439,36 @@ protected function createTfaMessageTemplateRequest($appId, $tfaCreateMessageRequ $headerParams = []; $httpBody = ''; - - // path params if ($appId !== null) { $resourcePath = str_replace( '{' . 'appId' . '}', - ObjectSerializer::toPathValue($appId), + $this->objectSerializer->toPathValue($appId), $resourcePath ); } - - $headers = $this->headerSelector->selectHeaders( - ['application/json', 'application/xml'], - ['application/json', 'application/xml'] - ); + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; // for model (json/xml) if (isset($tfaCreateMessageRequest)) { - if ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($tfaCreateMessageRequest)); - } else { - $httpBody = $tfaCreateMessageRequest; - } + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($tfaCreateMessageRequest) + : $tfaCreateMessageRequest; } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + if ($headers['Content-Type'] === 'multipart/form-data') { - $boundary = '----'.hash('sha256', uniqid('', true)); + $boundary = '----' . hash('sha256', uniqid('', true)); $headers['Content-Type'] .= '; boundary=' . $boundary; $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + $formParamValueItems = (\is_array($formParamValue)) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { $multipartContents[] = [ 'name' => $formParamName, @@ -532,47 +476,45 @@ protected function createTfaMessageTemplateRequest($appId, $tfaCreateMessageRequ ]; } } + // for HTTP post (form) $httpBody = new MultipartStream($multipartContents, $boundary); } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); + $httpBody = $this->objectSerializer->serialize($formParams); } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); + $httpBody = Query::build($formParams); } } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('Authorization'); - if ($apiKey !== null) { - $headers['Authorization'] = $apiKey; - } - // this endpoint requires HTTP basic authentication - if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) { - $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); - } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('Authorization'); + $apiKey = $this->config->getApiKey(); + if ($apiKey !== null) { - $headers['Authorization'] = $apiKey; - } - // this endpoint requires OAuth (access token) - if (!empty($this->config->getAccessToken())) { - $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + $headers[$this->config->getApiKeyHeader()] = $apiKey; } $defaultHeaders = []; + if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } - $headers = array_merge( + $headers = \array_merge( $defaultHeaders, $headerParams, $headers ); - $query = \GuzzleHttp\Psr7\Query::build($queryParams); + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), @@ -583,14 +525,10 @@ protected function createTfaMessageTemplateRequest($appId, $tfaCreateMessageRequ /** * Create response for operation 'createTfaMessageTemplate' - * - * @param \GuzzleHttp\Psr7\Response $response - * @param string $requestUri - * - * @throws \Infobip\ApiException on non-2xx response - * @return array of \Infobip\Model\TfaApiException|\Infobip\Model\TfaApiException|\Infobip\Model\TfaMessage|null, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\TfaMessage|null */ - protected function createTfaMessageTemplateResponse($response, $requestUri) + private function createTfaMessageTemplateResponse(ResponseInterface $response, UriInterface $requestUri): mixed { $statusCode = $response->getStatusCode(); $responseBody = $response->getBody(); @@ -598,67 +536,56 @@ protected function createTfaMessageTemplateResponse($response, $requestUri) if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( - sprintf('[%d] Error connecting to the API (%s)', $statusCode, $requestUri), + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), $statusCode, $responseHeaders, $responseBody ); } - $responseObject = null; - - - $type = '\Infobip\Model\TfaMessage'; - if ($type === '\SplFileObject') { - $content = $responseBody; //stream goes to serializer - } else { - $content = (string) $responseBody; - } - $responseObject = ObjectSerializer::deserialize($content, $type, $responseHeaders); + $responseResult = null; - return [ - $responseObject, - $statusCode, - $responseHeaders - ]; + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\TfaMessage', $responseHeaders); + return $responseResult; } /** - * Adapt given \Infobip\ApiException for operation 'createTfaMessageTemplate' - * - * @param \Infobip\ApiException $apiException - * - * @return \Infobip\ApiException + * Adapt given ApiException for operation 'createTfaMessageTemplate' */ - protected function createTfaMessageTemplateApiException($apiException) + private function createTfaMessageTemplateApiException(ApiException $apiException): ApiException { $statusCode = $apiException->getCode(); if ($statusCode >= 400 && $statusCode <= 499) { - $data = ObjectSerializer::deserialize( + $data = $this->objectSerializer->deserialize( $apiException->getResponseBody(), - '\Infobip\Model\TfaApiException', + '\Infobip\Model\ApiException', $apiException->getResponseHeaders() ); + $apiException->setResponseObject($data); + return $apiException; } if ($statusCode >= 500 && $statusCode <= 599) { - $data = ObjectSerializer::deserialize( + $data = $this->objectSerializer->deserialize( $apiException->getResponseBody(), - '\Infobip\Model\TfaApiException', + '\Infobip\Model\ApiException', $apiException->getResponseHeaders() ); + $apiException->setResponseObject($data); + return $apiException; } - - $data = ObjectSerializer::deserialize( + $data = $this->objectSerializer->deserialize( $apiException->getResponseBody(), '\Infobip\Model\TfaMessage', $apiException->getResponseHeaders() ); + $apiException->setResponseObject($data); + return $apiException; } @@ -667,48 +594,33 @@ protected function createTfaMessageTemplateApiException($apiException) * * Get 2FA application * - * @param string $appId ID of application for which configuration view was requested. (required) + * @param string $appId ID of application for which configuration view was requested. (required) * - * @throws \Infobip\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \Infobip\Model\TfaApiException|\Infobip\Model\TfaApiException|\Infobip\Model\TfaApplicationResponse + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\TfaApplicationResponse */ - public function getTfaApplication($appId) - { - list($response) = $this->getTfaApplicationWithHttpInfo($appId); - return $response; - } - - /** - * Operation getTfaApplicationWithHttpInfo - * - * Get 2FA application - * - * @param string $appId ID of application for which configuration view was requested. (required) - * - * @throws \Infobip\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \Infobip\Model\TfaApiException|\Infobip\Model\TfaApiException|\Infobip\Model\TfaApplicationResponse, HTTP status code, HTTP response headers (array of strings) - */ - public function getTfaApplicationWithHttpInfo($appId) + public function getTfaApplication(string $appId) { $request = $this->getTfaApplicationRequest($appId); try { - $options = $this->createHttpClientOption(); try { - $response = $this->client->send($request, $options); + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); return $this->getTfaApplicationResponse($response, $request->getUri()); - } catch (RequestException $e) { + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null ); } - } catch (ApiException $e) { - throw $this->getTfaApplicationApiException($e); + } catch (ApiException $exception) { + throw $this->getTfaApplicationApiException($exception); } } @@ -717,51 +629,35 @@ public function getTfaApplicationWithHttpInfo($appId) * * Get 2FA application * - * @param string $appId ID of application for which configuration view was requested. (required) + * @param string $appId ID of application for which configuration view was requested. (required) * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws InvalidArgumentException */ - public function getTfaApplicationAsync($appId) - { - return $this->getTfaApplicationAsyncWithHttpInfo($appId) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation getTfaApplicationAsyncWithHttpInfo - * - * Get 2FA application - * - * @param string $appId ID of application for which configuration view was requested. (required) - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getTfaApplicationAsyncWithHttpInfo($appId) + public function getTfaApplicationAsync(string $appId): PromiseInterface { $request = $this->getTfaApplicationRequest($appId); - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) + return $this + ->client + ->sendAsync($request) ->then( function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); return $this->getTfaApplicationResponse($response, $request->getUri()); }, - function ($exception) { + function (GuzzleException $exception) { $statusCode = $exception->getCode(); - $response = $exception->getResponse(); - $e = new ApiException( + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( "[{$statusCode}] {$exception->getMessage()}", $statusCode, - $response ? $response->getHeaders() : null, - $response ? (string) $response->getBody() : null + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null ); - throw $this->getTfaApplicationApiException($e); + + throw $this->getTfaApplicationApiException($exception); } ); } @@ -769,19 +665,29 @@ function ($exception) { /** * Create request for operation 'getTfaApplication' * - * @param string $appId ID of application for which configuration view was requested. (required) + * @param string $appId ID of application for which configuration view was requested. (required) * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws InvalidArgumentException */ - protected function getTfaApplicationRequest($appId) + private function getTfaApplicationRequest(string $appId): Request { - // verify the required parameter 'appId' is set - if ($appId === null || (is_array($appId) && count($appId) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $appId when calling getTfaApplication' + $allData = [ + 'appId' => $appId, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'appId' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints ); - } + + $this->validateParams($allData, $validationConstraints); $resourcePath = '/2fa/2/applications/{appId}'; $formParams = []; @@ -789,31 +695,32 @@ protected function getTfaApplicationRequest($appId) $headerParams = []; $httpBody = ''; - - // path params if ($appId !== null) { $resourcePath = str_replace( '{' . 'appId' . '}', - ObjectSerializer::toPathValue($appId), + $this->objectSerializer->toPathValue($appId), $resourcePath ); } + $headers = [ + 'Accept' => 'application/json', - $headers = $this->headerSelector->selectHeaders( - ['application/json', 'application/xml'], - [] - ); + ]; // for model (json/xml) if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + if ($headers['Content-Type'] === 'multipart/form-data') { - $boundary = '----'.hash('sha256', uniqid('', true)); + $boundary = '----' . hash('sha256', uniqid('', true)); $headers['Content-Type'] .= '; boundary=' . $boundary; $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + $formParamValueItems = (\is_array($formParamValue)) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { $multipartContents[] = [ 'name' => $formParamName, @@ -821,47 +728,45 @@ protected function getTfaApplicationRequest($appId) ]; } } + // for HTTP post (form) $httpBody = new MultipartStream($multipartContents, $boundary); } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); + $httpBody = $this->objectSerializer->serialize($formParams); } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); + $httpBody = Query::build($formParams); } } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('Authorization'); - if ($apiKey !== null) { - $headers['Authorization'] = $apiKey; - } - // this endpoint requires HTTP basic authentication - if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) { - $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); - } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('Authorization'); + $apiKey = $this->config->getApiKey(); + if ($apiKey !== null) { - $headers['Authorization'] = $apiKey; - } - // this endpoint requires OAuth (access token) - if (!empty($this->config->getAccessToken())) { - $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + $headers[$this->config->getApiKeyHeader()] = $apiKey; } $defaultHeaders = []; + if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } - $headers = array_merge( + $headers = \array_merge( $defaultHeaders, $headerParams, $headers ); - $query = \GuzzleHttp\Psr7\Query::build($queryParams); + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), @@ -872,14 +777,10 @@ protected function getTfaApplicationRequest($appId) /** * Create response for operation 'getTfaApplication' - * - * @param \GuzzleHttp\Psr7\Response $response - * @param string $requestUri - * - * @throws \Infobip\ApiException on non-2xx response - * @return array of \Infobip\Model\TfaApiException|\Infobip\Model\TfaApiException|\Infobip\Model\TfaApplicationResponse|null, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\TfaApplicationResponse|null */ - protected function getTfaApplicationResponse($response, $requestUri) + private function getTfaApplicationResponse(ResponseInterface $response, UriInterface $requestUri): mixed { $statusCode = $response->getStatusCode(); $responseBody = $response->getBody(); @@ -887,67 +788,56 @@ protected function getTfaApplicationResponse($response, $requestUri) if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( - sprintf('[%d] Error connecting to the API (%s)', $statusCode, $requestUri), + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), $statusCode, $responseHeaders, $responseBody ); } - $responseObject = null; - - - $type = '\Infobip\Model\TfaApplicationResponse'; - if ($type === '\SplFileObject') { - $content = $responseBody; //stream goes to serializer - } else { - $content = (string) $responseBody; - } - $responseObject = ObjectSerializer::deserialize($content, $type, $responseHeaders); + $responseResult = null; - return [ - $responseObject, - $statusCode, - $responseHeaders - ]; + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\TfaApplicationResponse', $responseHeaders); + return $responseResult; } /** - * Adapt given \Infobip\ApiException for operation 'getTfaApplication' - * - * @param \Infobip\ApiException $apiException - * - * @return \Infobip\ApiException + * Adapt given ApiException for operation 'getTfaApplication' */ - protected function getTfaApplicationApiException($apiException) + private function getTfaApplicationApiException(ApiException $apiException): ApiException { $statusCode = $apiException->getCode(); if ($statusCode >= 400 && $statusCode <= 499) { - $data = ObjectSerializer::deserialize( + $data = $this->objectSerializer->deserialize( $apiException->getResponseBody(), - '\Infobip\Model\TfaApiException', + '\Infobip\Model\ApiException', $apiException->getResponseHeaders() ); + $apiException->setResponseObject($data); + return $apiException; } if ($statusCode >= 500 && $statusCode <= 599) { - $data = ObjectSerializer::deserialize( + $data = $this->objectSerializer->deserialize( $apiException->getResponseBody(), - '\Infobip\Model\TfaApiException', + '\Infobip\Model\ApiException', $apiException->getResponseHeaders() ); + $apiException->setResponseObject($data); + return $apiException; } - - $data = ObjectSerializer::deserialize( + $data = $this->objectSerializer->deserialize( $apiException->getResponseBody(), '\Infobip\Model\TfaApplicationResponse', $apiException->getResponseHeaders() ); + $apiException->setResponseObject($data); + return $apiException; } @@ -957,45 +847,31 @@ protected function getTfaApplicationApiException($apiException) * Get 2FA applications * * - * @throws \Infobip\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \Infobip\Model\TfaApiException|\Infobip\Model\TfaApiException|\Infobip\Model\TfaApplicationResponse[] + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\TfaApplicationResponse[] */ public function getTfaApplications() - { - list($response) = $this->getTfaApplicationsWithHttpInfo(); - return $response; - } - - /** - * Operation getTfaApplicationsWithHttpInfo - * - * Get 2FA applications - * - * - * @throws \Infobip\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \Infobip\Model\TfaApiException|\Infobip\Model\TfaApiException|\Infobip\Model\TfaApplicationResponse[], HTTP status code, HTTP response headers (array of strings) - */ - public function getTfaApplicationsWithHttpInfo() { $request = $this->getTfaApplicationsRequest(); try { - $options = $this->createHttpClientOption(); try { - $response = $this->client->send($request, $options); + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); return $this->getTfaApplicationsResponse($response, $request->getUri()); - } catch (RequestException $e) { + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null ); } - } catch (ApiException $e) { - throw $this->getTfaApplicationsApiException($e); + } catch (ApiException $exception) { + throw $this->getTfaApplicationsApiException($exception); } } @@ -1005,48 +881,33 @@ public function getTfaApplicationsWithHttpInfo() * Get 2FA applications * * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getTfaApplicationsAsync() - { - return $this->getTfaApplicationsAsyncWithHttpInfo() - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation getTfaApplicationsAsyncWithHttpInfo - * - * Get 2FA applications - * - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws InvalidArgumentException */ - public function getTfaApplicationsAsyncWithHttpInfo() + public function getTfaApplicationsAsync(): PromiseInterface { $request = $this->getTfaApplicationsRequest(); - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) + return $this + ->client + ->sendAsync($request) ->then( function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); return $this->getTfaApplicationsResponse($response, $request->getUri()); }, - function ($exception) { + function (GuzzleException $exception) { $statusCode = $exception->getCode(); - $response = $exception->getResponse(); - $e = new ApiException( + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( "[{$statusCode}] {$exception->getMessage()}", $statusCode, - $response ? $response->getHeaders() : null, - $response ? (string) $response->getBody() : null + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null ); - throw $this->getTfaApplicationsApiException($e); + + throw $this->getTfaApplicationsApiException($exception); } ); } @@ -1055,34 +916,47 @@ function ($exception) { * Create request for operation 'getTfaApplications' * * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws InvalidArgumentException */ - protected function getTfaApplicationsRequest() + private function getTfaApplicationsRequest(): Request { + $allData = [ + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + $resourcePath = '/2fa/2/applications'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; + $headers = [ + 'Accept' => 'application/json', - - - - $headers = $this->headerSelector->selectHeaders( - ['application/json', 'application/xml'], - [] - ); + ]; // for model (json/xml) if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + if ($headers['Content-Type'] === 'multipart/form-data') { - $boundary = '----'.hash('sha256', uniqid('', true)); + $boundary = '----' . hash('sha256', uniqid('', true)); $headers['Content-Type'] .= '; boundary=' . $boundary; $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + $formParamValueItems = (\is_array($formParamValue)) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { $multipartContents[] = [ 'name' => $formParamName, @@ -1090,47 +964,45 @@ protected function getTfaApplicationsRequest() ]; } } + // for HTTP post (form) $httpBody = new MultipartStream($multipartContents, $boundary); } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); + $httpBody = $this->objectSerializer->serialize($formParams); } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); + $httpBody = Query::build($formParams); } } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('Authorization'); - if ($apiKey !== null) { - $headers['Authorization'] = $apiKey; - } - // this endpoint requires HTTP basic authentication - if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) { - $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); - } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('Authorization'); + $apiKey = $this->config->getApiKey(); + if ($apiKey !== null) { - $headers['Authorization'] = $apiKey; - } - // this endpoint requires OAuth (access token) - if (!empty($this->config->getAccessToken())) { - $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + $headers[$this->config->getApiKeyHeader()] = $apiKey; } $defaultHeaders = []; + if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } - $headers = array_merge( + $headers = \array_merge( $defaultHeaders, $headerParams, $headers ); - $query = \GuzzleHttp\Psr7\Query::build($queryParams); + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), @@ -1141,14 +1013,10 @@ protected function getTfaApplicationsRequest() /** * Create response for operation 'getTfaApplications' - * - * @param \GuzzleHttp\Psr7\Response $response - * @param string $requestUri - * - * @throws \Infobip\ApiException on non-2xx response - * @return array of \Infobip\Model\TfaApiException|\Infobip\Model\TfaApiException|\Infobip\Model\TfaApplicationResponse[]|null, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\TfaApplicationResponse[]|null */ - protected function getTfaApplicationsResponse($response, $requestUri) + private function getTfaApplicationsResponse(ResponseInterface $response, UriInterface $requestUri): mixed { $statusCode = $response->getStatusCode(); $responseBody = $response->getBody(); @@ -1156,67 +1024,56 @@ protected function getTfaApplicationsResponse($response, $requestUri) if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( - sprintf('[%d] Error connecting to the API (%s)', $statusCode, $requestUri), + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), $statusCode, $responseHeaders, $responseBody ); } - $responseObject = null; + $responseResult = null; - - $type = '\Infobip\Model\TfaApplicationResponse[]'; - if ($type === '\SplFileObject') { - $content = $responseBody; //stream goes to serializer - } else { - $content = (string) $responseBody; - } - $responseObject = ObjectSerializer::deserialize($content, $type, $responseHeaders); - - return [ - $responseObject, - $statusCode, - $responseHeaders - ]; + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\TfaApplicationResponse[]', $responseHeaders); + return $responseResult; } /** - * Adapt given \Infobip\ApiException for operation 'getTfaApplications' - * - * @param \Infobip\ApiException $apiException - * - * @return \Infobip\ApiException + * Adapt given ApiException for operation 'getTfaApplications' */ - protected function getTfaApplicationsApiException($apiException) + private function getTfaApplicationsApiException(ApiException $apiException): ApiException { $statusCode = $apiException->getCode(); if ($statusCode >= 400 && $statusCode <= 499) { - $data = ObjectSerializer::deserialize( + $data = $this->objectSerializer->deserialize( $apiException->getResponseBody(), - '\Infobip\Model\TfaApiException', + '\Infobip\Model\ApiException', $apiException->getResponseHeaders() ); + $apiException->setResponseObject($data); + return $apiException; } if ($statusCode >= 500 && $statusCode <= 599) { - $data = ObjectSerializer::deserialize( + $data = $this->objectSerializer->deserialize( $apiException->getResponseBody(), - '\Infobip\Model\TfaApiException', + '\Infobip\Model\ApiException', $apiException->getResponseHeaders() ); + $apiException->setResponseObject($data); + return $apiException; } - - $data = ObjectSerializer::deserialize( + $data = $this->objectSerializer->deserialize( $apiException->getResponseBody(), '\Infobip\Model\TfaApplicationResponse[]', $apiException->getResponseHeaders() ); + $apiException->setResponseObject($data); + return $apiException; } @@ -1225,50 +1082,34 @@ protected function getTfaApplicationsApiException($apiException) * * Get 2FA message template * - * @param string $appId ID of application for which requested message was created. (required) - * @param string $msgId Requested message ID. (required) + * @param string $appId ID of application for which requested message was created. (required) + * @param string $msgId Requested message ID. (required) * - * @throws \Infobip\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \Infobip\Model\TfaApiException|\Infobip\Model\TfaApiException|\Infobip\Model\TfaMessage + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\TfaMessage */ - public function getTfaMessageTemplate($appId, $msgId) - { - list($response) = $this->getTfaMessageTemplateWithHttpInfo($appId, $msgId); - return $response; - } - - /** - * Operation getTfaMessageTemplateWithHttpInfo - * - * Get 2FA message template - * - * @param string $appId ID of application for which requested message was created. (required) - * @param string $msgId Requested message ID. (required) - * - * @throws \Infobip\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \Infobip\Model\TfaApiException|\Infobip\Model\TfaApiException|\Infobip\Model\TfaMessage, HTTP status code, HTTP response headers (array of strings) - */ - public function getTfaMessageTemplateWithHttpInfo($appId, $msgId) + public function getTfaMessageTemplate(string $appId, string $msgId) { $request = $this->getTfaMessageTemplateRequest($appId, $msgId); try { - $options = $this->createHttpClientOption(); try { - $response = $this->client->send($request, $options); + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); return $this->getTfaMessageTemplateResponse($response, $request->getUri()); - } catch (RequestException $e) { + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null ); } - } catch (ApiException $e) { - throw $this->getTfaMessageTemplateApiException($e); + } catch (ApiException $exception) { + throw $this->getTfaMessageTemplateApiException($exception); } } @@ -1277,53 +1118,36 @@ public function getTfaMessageTemplateWithHttpInfo($appId, $msgId) * * Get 2FA message template * - * @param string $appId ID of application for which requested message was created. (required) - * @param string $msgId Requested message ID. (required) + * @param string $appId ID of application for which requested message was created. (required) + * @param string $msgId Requested message ID. (required) * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws InvalidArgumentException */ - public function getTfaMessageTemplateAsync($appId, $msgId) - { - return $this->getTfaMessageTemplateAsyncWithHttpInfo($appId, $msgId) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation getTfaMessageTemplateAsyncWithHttpInfo - * - * Get 2FA message template - * - * @param string $appId ID of application for which requested message was created. (required) - * @param string $msgId Requested message ID. (required) - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getTfaMessageTemplateAsyncWithHttpInfo($appId, $msgId) + public function getTfaMessageTemplateAsync(string $appId, string $msgId): PromiseInterface { $request = $this->getTfaMessageTemplateRequest($appId, $msgId); - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) + return $this + ->client + ->sendAsync($request) ->then( function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); return $this->getTfaMessageTemplateResponse($response, $request->getUri()); }, - function ($exception) { + function (GuzzleException $exception) { $statusCode = $exception->getCode(); - $response = $exception->getResponse(); - $e = new ApiException( + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( "[{$statusCode}] {$exception->getMessage()}", $statusCode, - $response ? $response->getHeaders() : null, - $response ? (string) $response->getBody() : null + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null ); - throw $this->getTfaMessageTemplateApiException($e); + + throw $this->getTfaMessageTemplateApiException($exception); } ); } @@ -1331,26 +1155,34 @@ function ($exception) { /** * Create request for operation 'getTfaMessageTemplate' * - * @param string $appId ID of application for which requested message was created. (required) - * @param string $msgId Requested message ID. (required) + * @param string $appId ID of application for which requested message was created. (required) + * @param string $msgId Requested message ID. (required) * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws InvalidArgumentException */ - protected function getTfaMessageTemplateRequest($appId, $msgId) + private function getTfaMessageTemplateRequest(string $appId, string $msgId): Request { - // verify the required parameter 'appId' is set - if ($appId === null || (is_array($appId) && count($appId) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $appId when calling getTfaMessageTemplate' - ); - } - // verify the required parameter 'msgId' is set - if ($msgId === null || (is_array($msgId) && count($msgId) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $msgId when calling getTfaMessageTemplate' + $allData = [ + 'appId' => $appId, + 'msgId' => $msgId, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'appId' => [ + new Assert\NotBlank(), + ], + 'msgId' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints ); - } + + $this->validateParams($allData, $validationConstraints); $resourcePath = '/2fa/2/applications/{appId}/messages/{msgId}'; $formParams = []; @@ -1358,39 +1190,41 @@ protected function getTfaMessageTemplateRequest($appId, $msgId) $headerParams = []; $httpBody = ''; - - // path params if ($appId !== null) { $resourcePath = str_replace( '{' . 'appId' . '}', - ObjectSerializer::toPathValue($appId), + $this->objectSerializer->toPathValue($appId), $resourcePath ); } + // path params if ($msgId !== null) { $resourcePath = str_replace( '{' . 'msgId' . '}', - ObjectSerializer::toPathValue($msgId), + $this->objectSerializer->toPathValue($msgId), $resourcePath ); } + $headers = [ + 'Accept' => 'application/json', - $headers = $this->headerSelector->selectHeaders( - ['application/json', 'application/xml'], - [] - ); + ]; // for model (json/xml) if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + if ($headers['Content-Type'] === 'multipart/form-data') { - $boundary = '----'.hash('sha256', uniqid('', true)); + $boundary = '----' . hash('sha256', uniqid('', true)); $headers['Content-Type'] .= '; boundary=' . $boundary; $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + $formParamValueItems = (\is_array($formParamValue)) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { $multipartContents[] = [ 'name' => $formParamName, @@ -1398,47 +1232,45 @@ protected function getTfaMessageTemplateRequest($appId, $msgId) ]; } } + // for HTTP post (form) $httpBody = new MultipartStream($multipartContents, $boundary); } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); + $httpBody = $this->objectSerializer->serialize($formParams); } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); + $httpBody = Query::build($formParams); } } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('Authorization'); - if ($apiKey !== null) { - $headers['Authorization'] = $apiKey; - } - // this endpoint requires HTTP basic authentication - if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) { - $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); - } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('Authorization'); + $apiKey = $this->config->getApiKey(); + if ($apiKey !== null) { - $headers['Authorization'] = $apiKey; - } - // this endpoint requires OAuth (access token) - if (!empty($this->config->getAccessToken())) { - $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + $headers[$this->config->getApiKeyHeader()] = $apiKey; } $defaultHeaders = []; + if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } - $headers = array_merge( + $headers = \array_merge( $defaultHeaders, $headerParams, $headers ); - $query = \GuzzleHttp\Psr7\Query::build($queryParams); + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), @@ -1449,14 +1281,10 @@ protected function getTfaMessageTemplateRequest($appId, $msgId) /** * Create response for operation 'getTfaMessageTemplate' - * - * @param \GuzzleHttp\Psr7\Response $response - * @param string $requestUri - * - * @throws \Infobip\ApiException on non-2xx response - * @return array of \Infobip\Model\TfaApiException|\Infobip\Model\TfaApiException|\Infobip\Model\TfaMessage|null, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\TfaMessage|null */ - protected function getTfaMessageTemplateResponse($response, $requestUri) + private function getTfaMessageTemplateResponse(ResponseInterface $response, UriInterface $requestUri): mixed { $statusCode = $response->getStatusCode(); $responseBody = $response->getBody(); @@ -1464,67 +1292,56 @@ protected function getTfaMessageTemplateResponse($response, $requestUri) if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( - sprintf('[%d] Error connecting to the API (%s)', $statusCode, $requestUri), + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), $statusCode, $responseHeaders, $responseBody ); } - $responseObject = null; - + $responseResult = null; - $type = '\Infobip\Model\TfaMessage'; - if ($type === '\SplFileObject') { - $content = $responseBody; //stream goes to serializer - } else { - $content = (string) $responseBody; - } - $responseObject = ObjectSerializer::deserialize($content, $type, $responseHeaders); - - return [ - $responseObject, - $statusCode, - $responseHeaders - ]; + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\TfaMessage', $responseHeaders); + return $responseResult; } /** - * Adapt given \Infobip\ApiException for operation 'getTfaMessageTemplate' - * - * @param \Infobip\ApiException $apiException - * - * @return \Infobip\ApiException + * Adapt given ApiException for operation 'getTfaMessageTemplate' */ - protected function getTfaMessageTemplateApiException($apiException) + private function getTfaMessageTemplateApiException(ApiException $apiException): ApiException { $statusCode = $apiException->getCode(); if ($statusCode >= 400 && $statusCode <= 499) { - $data = ObjectSerializer::deserialize( + $data = $this->objectSerializer->deserialize( $apiException->getResponseBody(), - '\Infobip\Model\TfaApiException', + '\Infobip\Model\ApiException', $apiException->getResponseHeaders() ); + $apiException->setResponseObject($data); + return $apiException; } if ($statusCode >= 500 && $statusCode <= 599) { - $data = ObjectSerializer::deserialize( + $data = $this->objectSerializer->deserialize( $apiException->getResponseBody(), - '\Infobip\Model\TfaApiException', + '\Infobip\Model\ApiException', $apiException->getResponseHeaders() ); + $apiException->setResponseObject($data); + return $apiException; } - - $data = ObjectSerializer::deserialize( + $data = $this->objectSerializer->deserialize( $apiException->getResponseBody(), '\Infobip\Model\TfaMessage', $apiException->getResponseHeaders() ); + $apiException->setResponseObject($data); + return $apiException; } @@ -1533,48 +1350,33 @@ protected function getTfaMessageTemplateApiException($apiException) * * Get 2FA message templates * - * @param string $appId ID of application for which requested message was created. (required) + * @param string $appId ID of application for which requested message was created. (required) * - * @throws \Infobip\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \Infobip\Model\TfaApiException|\Infobip\Model\TfaApiException|\Infobip\Model\TfaMessage[] + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\TfaMessage[] */ - public function getTfaMessageTemplates($appId) - { - list($response) = $this->getTfaMessageTemplatesWithHttpInfo($appId); - return $response; - } - - /** - * Operation getTfaMessageTemplatesWithHttpInfo - * - * Get 2FA message templates - * - * @param string $appId ID of application for which requested message was created. (required) - * - * @throws \Infobip\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \Infobip\Model\TfaApiException|\Infobip\Model\TfaApiException|\Infobip\Model\TfaMessage[], HTTP status code, HTTP response headers (array of strings) - */ - public function getTfaMessageTemplatesWithHttpInfo($appId) + public function getTfaMessageTemplates(string $appId) { $request = $this->getTfaMessageTemplatesRequest($appId); try { - $options = $this->createHttpClientOption(); try { - $response = $this->client->send($request, $options); + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); return $this->getTfaMessageTemplatesResponse($response, $request->getUri()); - } catch (RequestException $e) { + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null ); } - } catch (ApiException $e) { - throw $this->getTfaMessageTemplatesApiException($e); + } catch (ApiException $exception) { + throw $this->getTfaMessageTemplatesApiException($exception); } } @@ -1583,51 +1385,35 @@ public function getTfaMessageTemplatesWithHttpInfo($appId) * * Get 2FA message templates * - * @param string $appId ID of application for which requested message was created. (required) + * @param string $appId ID of application for which requested message was created. (required) * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws InvalidArgumentException */ - public function getTfaMessageTemplatesAsync($appId) - { - return $this->getTfaMessageTemplatesAsyncWithHttpInfo($appId) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation getTfaMessageTemplatesAsyncWithHttpInfo - * - * Get 2FA message templates - * - * @param string $appId ID of application for which requested message was created. (required) - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getTfaMessageTemplatesAsyncWithHttpInfo($appId) + public function getTfaMessageTemplatesAsync(string $appId): PromiseInterface { $request = $this->getTfaMessageTemplatesRequest($appId); - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) + return $this + ->client + ->sendAsync($request) ->then( function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); return $this->getTfaMessageTemplatesResponse($response, $request->getUri()); }, - function ($exception) { + function (GuzzleException $exception) { $statusCode = $exception->getCode(); - $response = $exception->getResponse(); - $e = new ApiException( + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( "[{$statusCode}] {$exception->getMessage()}", $statusCode, - $response ? $response->getHeaders() : null, - $response ? (string) $response->getBody() : null + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null ); - throw $this->getTfaMessageTemplatesApiException($e); + + throw $this->getTfaMessageTemplatesApiException($exception); } ); } @@ -1635,19 +1421,29 @@ function ($exception) { /** * Create request for operation 'getTfaMessageTemplates' * - * @param string $appId ID of application for which requested message was created. (required) + * @param string $appId ID of application for which requested message was created. (required) * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws InvalidArgumentException */ - protected function getTfaMessageTemplatesRequest($appId) + private function getTfaMessageTemplatesRequest(string $appId): Request { - // verify the required parameter 'appId' is set - if ($appId === null || (is_array($appId) && count($appId) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $appId when calling getTfaMessageTemplates' + $allData = [ + 'appId' => $appId, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'appId' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints ); - } + + $this->validateParams($allData, $validationConstraints); $resourcePath = '/2fa/2/applications/{appId}/messages'; $formParams = []; @@ -1655,31 +1451,32 @@ protected function getTfaMessageTemplatesRequest($appId) $headerParams = []; $httpBody = ''; - - // path params if ($appId !== null) { $resourcePath = str_replace( '{' . 'appId' . '}', - ObjectSerializer::toPathValue($appId), + $this->objectSerializer->toPathValue($appId), $resourcePath ); } + $headers = [ + 'Accept' => 'application/json', - $headers = $this->headerSelector->selectHeaders( - ['application/json', 'application/xml'], - [] - ); + ]; // for model (json/xml) if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + if ($headers['Content-Type'] === 'multipart/form-data') { - $boundary = '----'.hash('sha256', uniqid('', true)); + $boundary = '----' . hash('sha256', uniqid('', true)); $headers['Content-Type'] .= '; boundary=' . $boundary; $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + $formParamValueItems = (\is_array($formParamValue)) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { $multipartContents[] = [ 'name' => $formParamName, @@ -1687,47 +1484,45 @@ protected function getTfaMessageTemplatesRequest($appId) ]; } } + // for HTTP post (form) $httpBody = new MultipartStream($multipartContents, $boundary); } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); + $httpBody = $this->objectSerializer->serialize($formParams); } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); + $httpBody = Query::build($formParams); } } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('Authorization'); - if ($apiKey !== null) { - $headers['Authorization'] = $apiKey; - } - // this endpoint requires HTTP basic authentication - if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) { - $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); - } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('Authorization'); + $apiKey = $this->config->getApiKey(); + if ($apiKey !== null) { - $headers['Authorization'] = $apiKey; - } - // this endpoint requires OAuth (access token) - if (!empty($this->config->getAccessToken())) { - $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + $headers[$this->config->getApiKeyHeader()] = $apiKey; } $defaultHeaders = []; + if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } - $headers = array_merge( + $headers = \array_merge( $defaultHeaders, $headerParams, $headers ); - $query = \GuzzleHttp\Psr7\Query::build($queryParams); + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), @@ -1738,14 +1533,10 @@ protected function getTfaMessageTemplatesRequest($appId) /** * Create response for operation 'getTfaMessageTemplates' - * - * @param \GuzzleHttp\Psr7\Response $response - * @param string $requestUri - * - * @throws \Infobip\ApiException on non-2xx response - * @return array of \Infobip\Model\TfaApiException|\Infobip\Model\TfaApiException|\Infobip\Model\TfaMessage[]|null, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\TfaMessage[]|null */ - protected function getTfaMessageTemplatesResponse($response, $requestUri) + private function getTfaMessageTemplatesResponse(ResponseInterface $response, UriInterface $requestUri): mixed { $statusCode = $response->getStatusCode(); $responseBody = $response->getBody(); @@ -1753,67 +1544,56 @@ protected function getTfaMessageTemplatesResponse($response, $requestUri) if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( - sprintf('[%d] Error connecting to the API (%s)', $statusCode, $requestUri), + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), $statusCode, $responseHeaders, $responseBody ); } - $responseObject = null; - - - $type = '\Infobip\Model\TfaMessage[]'; - if ($type === '\SplFileObject') { - $content = $responseBody; //stream goes to serializer - } else { - $content = (string) $responseBody; - } - $responseObject = ObjectSerializer::deserialize($content, $type, $responseHeaders); + $responseResult = null; - return [ - $responseObject, - $statusCode, - $responseHeaders - ]; + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\TfaMessage[]', $responseHeaders); + return $responseResult; } /** - * Adapt given \Infobip\ApiException for operation 'getTfaMessageTemplates' - * - * @param \Infobip\ApiException $apiException - * - * @return \Infobip\ApiException + * Adapt given ApiException for operation 'getTfaMessageTemplates' */ - protected function getTfaMessageTemplatesApiException($apiException) + private function getTfaMessageTemplatesApiException(ApiException $apiException): ApiException { $statusCode = $apiException->getCode(); if ($statusCode >= 400 && $statusCode <= 499) { - $data = ObjectSerializer::deserialize( + $data = $this->objectSerializer->deserialize( $apiException->getResponseBody(), - '\Infobip\Model\TfaApiException', + '\Infobip\Model\ApiException', $apiException->getResponseHeaders() ); + $apiException->setResponseObject($data); + return $apiException; } if ($statusCode >= 500 && $statusCode <= 599) { - $data = ObjectSerializer::deserialize( + $data = $this->objectSerializer->deserialize( $apiException->getResponseBody(), - '\Infobip\Model\TfaApiException', + '\Infobip\Model\ApiException', $apiException->getResponseHeaders() ); + $apiException->setResponseObject($data); + return $apiException; } - - $data = ObjectSerializer::deserialize( + $data = $this->objectSerializer->deserialize( $apiException->getResponseBody(), '\Infobip\Model\TfaMessage[]', $apiException->getResponseHeaders() ); + $apiException->setResponseObject($data); + return $apiException; } @@ -1822,54 +1602,36 @@ protected function getTfaMessageTemplatesApiException($apiException) * * Get 2FA verification status * - * @param string $msisdn Filter by msisdn (phone number) for which verification status is checked. (required) - * @param string $appId ID of 2-FA application for which phone number verification status is requested. (required) - * @param bool $verified Filter by verified (true or false). (optional) - * @param bool $sent Filter by message sent status (true or false). (optional) - * - * @throws \Infobip\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \Infobip\Model\TfaApiException|\Infobip\Model\TfaApiException|\Infobip\Model\TfaVerificationResponse - */ - public function getTfaVerificationStatus($msisdn, $appId, $verified = null, $sent = null) - { - list($response) = $this->getTfaVerificationStatusWithHttpInfo($msisdn, $appId, $verified, $sent); - return $response; - } - - /** - * Operation getTfaVerificationStatusWithHttpInfo - * - * Get 2FA verification status - * - * @param string $msisdn Filter by msisdn (phone number) for which verification status is checked. (required) - * @param string $appId ID of 2-FA application for which phone number verification status is requested. (required) - * @param bool $verified Filter by verified (true or false). (optional) - * @param bool $sent Filter by message sent status (true or false). (optional) + * @param string $msisdn Filter by msisdn (phone number) for which verification status is checked. (required) + * @param string $appId ID of 2-FA application for which phone number verification status is requested. (required) + * @param null|bool $verified Filter by verified (true or false). (optional) + * @param null|bool $sent Filter by message sent status (true or false). (optional) * - * @throws \Infobip\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \Infobip\Model\TfaApiException|\Infobip\Model\TfaApiException|\Infobip\Model\TfaVerificationResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\TfaVerificationResponse */ - public function getTfaVerificationStatusWithHttpInfo($msisdn, $appId, $verified = null, $sent = null) + public function getTfaVerificationStatus(string $msisdn, string $appId, ?bool $verified = null, ?bool $sent = null) { $request = $this->getTfaVerificationStatusRequest($msisdn, $appId, $verified, $sent); try { - $options = $this->createHttpClientOption(); try { - $response = $this->client->send($request, $options); + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); return $this->getTfaVerificationStatusResponse($response, $request->getUri()); - } catch (RequestException $e) { + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null ); } - } catch (ApiException $e) { - throw $this->getTfaVerificationStatusApiException($e); + } catch (ApiException $exception) { + throw $this->getTfaVerificationStatusApiException($exception); } } @@ -1878,57 +1640,38 @@ public function getTfaVerificationStatusWithHttpInfo($msisdn, $appId, $verified * * Get 2FA verification status * - * @param string $msisdn Filter by msisdn (phone number) for which verification status is checked. (required) - * @param string $appId ID of 2-FA application for which phone number verification status is requested. (required) - * @param bool $verified Filter by verified (true or false). (optional) - * @param bool $sent Filter by message sent status (true or false). (optional) + * @param string $msisdn Filter by msisdn (phone number) for which verification status is checked. (required) + * @param string $appId ID of 2-FA application for which phone number verification status is requested. (required) + * @param null|bool $verified Filter by verified (true or false). (optional) + * @param null|bool $sent Filter by message sent status (true or false). (optional) * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws InvalidArgumentException */ - public function getTfaVerificationStatusAsync($msisdn, $appId, $verified = null, $sent = null) - { - return $this->getTfaVerificationStatusAsyncWithHttpInfo($msisdn, $appId, $verified, $sent) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation getTfaVerificationStatusAsyncWithHttpInfo - * - * Get 2FA verification status - * - * @param string $msisdn Filter by msisdn (phone number) for which verification status is checked. (required) - * @param string $appId ID of 2-FA application for which phone number verification status is requested. (required) - * @param bool $verified Filter by verified (true or false). (optional) - * @param bool $sent Filter by message sent status (true or false). (optional) - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getTfaVerificationStatusAsyncWithHttpInfo($msisdn, $appId, $verified = null, $sent = null) + public function getTfaVerificationStatusAsync(string $msisdn, string $appId, ?bool $verified = null, ?bool $sent = null): PromiseInterface { $request = $this->getTfaVerificationStatusRequest($msisdn, $appId, $verified, $sent); - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) + return $this + ->client + ->sendAsync($request) ->then( function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); return $this->getTfaVerificationStatusResponse($response, $request->getUri()); }, - function ($exception) { + function (GuzzleException $exception) { $statusCode = $exception->getCode(); - $response = $exception->getResponse(); - $e = new ApiException( + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( "[{$statusCode}] {$exception->getMessage()}", $statusCode, - $response ? $response->getHeaders() : null, - $response ? (string) $response->getBody() : null + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null ); - throw $this->getTfaVerificationStatusApiException($e); + + throw $this->getTfaVerificationStatusApiException($exception); } ); } @@ -1936,28 +1679,42 @@ function ($exception) { /** * Create request for operation 'getTfaVerificationStatus' * - * @param string $msisdn Filter by msisdn (phone number) for which verification status is checked. (required) - * @param string $appId ID of 2-FA application for which phone number verification status is requested. (required) - * @param bool $verified Filter by verified (true or false). (optional) - * @param bool $sent Filter by message sent status (true or false). (optional) + * @param string $msisdn Filter by msisdn (phone number) for which verification status is checked. (required) + * @param string $appId ID of 2-FA application for which phone number verification status is requested. (required) + * @param null|bool $verified Filter by verified (true or false). (optional) + * @param null|bool $sent Filter by message sent status (true or false). (optional) * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws InvalidArgumentException */ - protected function getTfaVerificationStatusRequest($msisdn, $appId, $verified = null, $sent = null) + private function getTfaVerificationStatusRequest(string $msisdn, string $appId, ?bool $verified = null, ?bool $sent = null): Request { - // verify the required parameter 'msisdn' is set - if ($msisdn === null || (is_array($msisdn) && count($msisdn) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $msisdn when calling getTfaVerificationStatus' - ); - } - // verify the required parameter 'appId' is set - if ($appId === null || (is_array($appId) && count($appId) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $appId when calling getTfaVerificationStatus' + $allData = [ + 'msisdn' => $msisdn, + 'appId' => $appId, + 'verified' => $verified, + 'sent' => $sent, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'msisdn' => [ + new Assert\NotBlank(), + ], + 'appId' => [ + new Assert\NotBlank(), + ], + 'verified' => [ + ], + 'sent' => [ + ], + ], + $validationConstraints ); - } + + $this->validateParams($allData, $validationConstraints); $resourcePath = '/2fa/2/applications/{appId}/verifications'; $formParams = []; @@ -1969,39 +1726,43 @@ protected function getTfaVerificationStatusRequest($msisdn, $appId, $verified = if ($msisdn !== null) { $queryParams['msisdn'] = $msisdn; } + // query params if ($verified !== null) { $queryParams['verified'] = $verified; } + // query params if ($sent !== null) { $queryParams['sent'] = $sent; } - // path params if ($appId !== null) { $resourcePath = str_replace( '{' . 'appId' . '}', - ObjectSerializer::toPathValue($appId), + $this->objectSerializer->toPathValue($appId), $resourcePath ); } + $headers = [ + 'Accept' => 'application/json', - $headers = $this->headerSelector->selectHeaders( - ['application/json', 'application/xml'], - [] - ); + ]; // for model (json/xml) if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + if ($headers['Content-Type'] === 'multipart/form-data') { - $boundary = '----'.hash('sha256', uniqid('', true)); + $boundary = '----' . hash('sha256', uniqid('', true)); $headers['Content-Type'] .= '; boundary=' . $boundary; $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + $formParamValueItems = (\is_array($formParamValue)) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { $multipartContents[] = [ 'name' => $formParamName, @@ -2009,47 +1770,45 @@ protected function getTfaVerificationStatusRequest($msisdn, $appId, $verified = ]; } } + // for HTTP post (form) $httpBody = new MultipartStream($multipartContents, $boundary); } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); + $httpBody = $this->objectSerializer->serialize($formParams); } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); + $httpBody = Query::build($formParams); } } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('Authorization'); - if ($apiKey !== null) { - $headers['Authorization'] = $apiKey; - } - // this endpoint requires HTTP basic authentication - if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) { - $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); - } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('Authorization'); + $apiKey = $this->config->getApiKey(); + if ($apiKey !== null) { - $headers['Authorization'] = $apiKey; - } - // this endpoint requires OAuth (access token) - if (!empty($this->config->getAccessToken())) { - $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + $headers[$this->config->getApiKeyHeader()] = $apiKey; } $defaultHeaders = []; + if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } - $headers = array_merge( + $headers = \array_merge( $defaultHeaders, $headerParams, $headers ); - $query = \GuzzleHttp\Psr7\Query::build($queryParams); + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), @@ -2060,14 +1819,10 @@ protected function getTfaVerificationStatusRequest($msisdn, $appId, $verified = /** * Create response for operation 'getTfaVerificationStatus' - * - * @param \GuzzleHttp\Psr7\Response $response - * @param string $requestUri - * - * @throws \Infobip\ApiException on non-2xx response - * @return array of \Infobip\Model\TfaApiException|\Infobip\Model\TfaApiException|\Infobip\Model\TfaVerificationResponse|null, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\TfaVerificationResponse|null */ - protected function getTfaVerificationStatusResponse($response, $requestUri) + private function getTfaVerificationStatusResponse(ResponseInterface $response, UriInterface $requestUri): mixed { $statusCode = $response->getStatusCode(); $responseBody = $response->getBody(); @@ -2075,67 +1830,56 @@ protected function getTfaVerificationStatusResponse($response, $requestUri) if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( - sprintf('[%d] Error connecting to the API (%s)', $statusCode, $requestUri), + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), $statusCode, $responseHeaders, $responseBody ); } - $responseObject = null; - + $responseResult = null; - $type = '\Infobip\Model\TfaVerificationResponse'; - if ($type === '\SplFileObject') { - $content = $responseBody; //stream goes to serializer - } else { - $content = (string) $responseBody; - } - $responseObject = ObjectSerializer::deserialize($content, $type, $responseHeaders); - - return [ - $responseObject, - $statusCode, - $responseHeaders - ]; + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\TfaVerificationResponse', $responseHeaders); + return $responseResult; } /** - * Adapt given \Infobip\ApiException for operation 'getTfaVerificationStatus' - * - * @param \Infobip\ApiException $apiException - * - * @return \Infobip\ApiException + * Adapt given ApiException for operation 'getTfaVerificationStatus' */ - protected function getTfaVerificationStatusApiException($apiException) + private function getTfaVerificationStatusApiException(ApiException $apiException): ApiException { $statusCode = $apiException->getCode(); if ($statusCode >= 400 && $statusCode <= 499) { - $data = ObjectSerializer::deserialize( + $data = $this->objectSerializer->deserialize( $apiException->getResponseBody(), - '\Infobip\Model\TfaApiException', + '\Infobip\Model\ApiException', $apiException->getResponseHeaders() ); + $apiException->setResponseObject($data); + return $apiException; } if ($statusCode >= 500 && $statusCode <= 599) { - $data = ObjectSerializer::deserialize( + $data = $this->objectSerializer->deserialize( $apiException->getResponseBody(), - '\Infobip\Model\TfaApiException', + '\Infobip\Model\ApiException', $apiException->getResponseHeaders() ); + $apiException->setResponseObject($data); + return $apiException; } - - $data = ObjectSerializer::deserialize( + $data = $this->objectSerializer->deserialize( $apiException->getResponseBody(), '\Infobip\Model\TfaVerificationResponse', $apiException->getResponseHeaders() ); + $apiException->setResponseObject($data); + return $apiException; } @@ -2144,50 +1888,34 @@ protected function getTfaVerificationStatusApiException($apiException) * * Resend 2FA PIN code over SMS * - * @param string $pinId ID of the pin code that has to be verified. (required) - * @param \Infobip\Model\TfaResendPinRequest $tfaResendPinRequest tfaResendPinRequest (optional) - * - * @throws \Infobip\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \Infobip\Model\TfaApiException|\Infobip\Model\TfaApiException|\Infobip\Model\TfaStartAuthenticationResponse - */ - public function resendTfaPinCodeOverSms($pinId, $tfaResendPinRequest = null) - { - list($response) = $this->resendTfaPinCodeOverSmsWithHttpInfo($pinId, $tfaResendPinRequest); - return $response; - } - - /** - * Operation resendTfaPinCodeOverSmsWithHttpInfo - * - * Resend 2FA PIN code over SMS - * - * @param string $pinId ID of the pin code that has to be verified. (required) - * @param \Infobip\Model\TfaResendPinRequest $tfaResendPinRequest (optional) + * @param string $pinId ID of the pin code that has to be verified. (required) + * @param \Infobip\Model\TfaResendPinRequest $tfaResendPinRequest tfaResendPinRequest (required) * - * @throws \Infobip\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \Infobip\Model\TfaApiException|\Infobip\Model\TfaApiException|\Infobip\Model\TfaStartAuthenticationResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\TfaStartAuthenticationResponse */ - public function resendTfaPinCodeOverSmsWithHttpInfo($pinId, $tfaResendPinRequest = null) + public function resendTfaPinCodeOverSms(string $pinId, \Infobip\Model\TfaResendPinRequest $tfaResendPinRequest) { $request = $this->resendTfaPinCodeOverSmsRequest($pinId, $tfaResendPinRequest); try { - $options = $this->createHttpClientOption(); try { - $response = $this->client->send($request, $options); + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); return $this->resendTfaPinCodeOverSmsResponse($response, $request->getUri()); - } catch (RequestException $e) { + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null ); } - } catch (ApiException $e) { - throw $this->resendTfaPinCodeOverSmsApiException($e); + } catch (ApiException $exception) { + throw $this->resendTfaPinCodeOverSmsApiException($exception); } } @@ -2196,53 +1924,36 @@ public function resendTfaPinCodeOverSmsWithHttpInfo($pinId, $tfaResendPinRequest * * Resend 2FA PIN code over SMS * - * @param string $pinId ID of the pin code that has to be verified. (required) - * @param \Infobip\Model\TfaResendPinRequest $tfaResendPinRequest (optional) - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function resendTfaPinCodeOverSmsAsync($pinId, $tfaResendPinRequest = null) - { - return $this->resendTfaPinCodeOverSmsAsyncWithHttpInfo($pinId, $tfaResendPinRequest) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation resendTfaPinCodeOverSmsAsyncWithHttpInfo - * - * Resend 2FA PIN code over SMS - * - * @param string $pinId ID of the pin code that has to be verified. (required) - * @param \Infobip\Model\TfaResendPinRequest $tfaResendPinRequest (optional) + * @param string $pinId ID of the pin code that has to be verified. (required) + * @param \Infobip\Model\TfaResendPinRequest $tfaResendPinRequest (required) * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws InvalidArgumentException */ - public function resendTfaPinCodeOverSmsAsyncWithHttpInfo($pinId, $tfaResendPinRequest = null) + public function resendTfaPinCodeOverSmsAsync(string $pinId, \Infobip\Model\TfaResendPinRequest $tfaResendPinRequest): PromiseInterface { $request = $this->resendTfaPinCodeOverSmsRequest($pinId, $tfaResendPinRequest); - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) + return $this + ->client + ->sendAsync($request) ->then( function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); return $this->resendTfaPinCodeOverSmsResponse($response, $request->getUri()); }, - function ($exception) { + function (GuzzleException $exception) { $statusCode = $exception->getCode(); - $response = $exception->getResponse(); - $e = new ApiException( + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( "[{$statusCode}] {$exception->getMessage()}", $statusCode, - $response ? $response->getHeaders() : null, - $response ? (string) $response->getBody() : null + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null ); - throw $this->resendTfaPinCodeOverSmsApiException($e); + + throw $this->resendTfaPinCodeOverSmsApiException($exception); } ); } @@ -2250,20 +1961,34 @@ function ($exception) { /** * Create request for operation 'resendTfaPinCodeOverSms' * - * @param string $pinId ID of the pin code that has to be verified. (required) - * @param \Infobip\Model\TfaResendPinRequest $tfaResendPinRequest (optional) + * @param string $pinId ID of the pin code that has to be verified. (required) + * @param \Infobip\Model\TfaResendPinRequest $tfaResendPinRequest (required) * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws InvalidArgumentException */ - protected function resendTfaPinCodeOverSmsRequest($pinId, $tfaResendPinRequest = null) + private function resendTfaPinCodeOverSmsRequest(string $pinId, \Infobip\Model\TfaResendPinRequest $tfaResendPinRequest): Request { - // verify the required parameter 'pinId' is set - if ($pinId === null || (is_array($pinId) && count($pinId) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $pinId when calling resendTfaPinCodeOverSms' + $allData = [ + 'pinId' => $pinId, + 'tfaResendPinRequest' => $tfaResendPinRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'pinId' => [ + new Assert\NotBlank(), + ], + 'tfaResendPinRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints ); - } + + $this->validateParams($allData, $validationConstraints); $resourcePath = '/2fa/2/pin/{pinId}/resend'; $formParams = []; @@ -2271,37 +1996,36 @@ protected function resendTfaPinCodeOverSmsRequest($pinId, $tfaResendPinRequest = $headerParams = []; $httpBody = ''; - - // path params if ($pinId !== null) { $resourcePath = str_replace( '{' . 'pinId' . '}', - ObjectSerializer::toPathValue($pinId), + $this->objectSerializer->toPathValue($pinId), $resourcePath ); } - - $headers = $this->headerSelector->selectHeaders( - ['application/json', 'application/xml'], - ['application/json', 'application/xml'] - ); + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; // for model (json/xml) if (isset($tfaResendPinRequest)) { - if ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($tfaResendPinRequest)); - } else { - $httpBody = $tfaResendPinRequest; - } + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($tfaResendPinRequest) + : $tfaResendPinRequest; } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + if ($headers['Content-Type'] === 'multipart/form-data') { - $boundary = '----'.hash('sha256', uniqid('', true)); + $boundary = '----' . hash('sha256', uniqid('', true)); $headers['Content-Type'] .= '; boundary=' . $boundary; $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + $formParamValueItems = (\is_array($formParamValue)) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { $multipartContents[] = [ 'name' => $formParamName, @@ -2309,47 +2033,45 @@ protected function resendTfaPinCodeOverSmsRequest($pinId, $tfaResendPinRequest = ]; } } + // for HTTP post (form) $httpBody = new MultipartStream($multipartContents, $boundary); } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); + $httpBody = $this->objectSerializer->serialize($formParams); } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); + $httpBody = Query::build($formParams); } } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('Authorization'); - if ($apiKey !== null) { - $headers['Authorization'] = $apiKey; - } - // this endpoint requires HTTP basic authentication - if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) { - $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); - } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('Authorization'); + $apiKey = $this->config->getApiKey(); + if ($apiKey !== null) { - $headers['Authorization'] = $apiKey; - } - // this endpoint requires OAuth (access token) - if (!empty($this->config->getAccessToken())) { - $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + $headers[$this->config->getApiKeyHeader()] = $apiKey; } $defaultHeaders = []; + if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } - $headers = array_merge( + $headers = \array_merge( $defaultHeaders, $headerParams, $headers ); - $query = \GuzzleHttp\Psr7\Query::build($queryParams); + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), @@ -2360,14 +2082,10 @@ protected function resendTfaPinCodeOverSmsRequest($pinId, $tfaResendPinRequest = /** * Create response for operation 'resendTfaPinCodeOverSms' - * - * @param \GuzzleHttp\Psr7\Response $response - * @param string $requestUri - * - * @throws \Infobip\ApiException on non-2xx response - * @return array of \Infobip\Model\TfaApiException|\Infobip\Model\TfaApiException|\Infobip\Model\TfaStartAuthenticationResponse|null, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\TfaStartAuthenticationResponse|null */ - protected function resendTfaPinCodeOverSmsResponse($response, $requestUri) + private function resendTfaPinCodeOverSmsResponse(ResponseInterface $response, UriInterface $requestUri): mixed { $statusCode = $response->getStatusCode(); $responseBody = $response->getBody(); @@ -2375,67 +2093,56 @@ protected function resendTfaPinCodeOverSmsResponse($response, $requestUri) if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( - sprintf('[%d] Error connecting to the API (%s)', $statusCode, $requestUri), + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), $statusCode, $responseHeaders, $responseBody ); } - $responseObject = null; - - - $type = '\Infobip\Model\TfaStartAuthenticationResponse'; - if ($type === '\SplFileObject') { - $content = $responseBody; //stream goes to serializer - } else { - $content = (string) $responseBody; - } - $responseObject = ObjectSerializer::deserialize($content, $type, $responseHeaders); + $responseResult = null; - return [ - $responseObject, - $statusCode, - $responseHeaders - ]; + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\TfaStartAuthenticationResponse', $responseHeaders); + return $responseResult; } /** - * Adapt given \Infobip\ApiException for operation 'resendTfaPinCodeOverSms' - * - * @param \Infobip\ApiException $apiException - * - * @return \Infobip\ApiException + * Adapt given ApiException for operation 'resendTfaPinCodeOverSms' */ - protected function resendTfaPinCodeOverSmsApiException($apiException) + private function resendTfaPinCodeOverSmsApiException(ApiException $apiException): ApiException { $statusCode = $apiException->getCode(); if ($statusCode >= 400 && $statusCode <= 499) { - $data = ObjectSerializer::deserialize( + $data = $this->objectSerializer->deserialize( $apiException->getResponseBody(), - '\Infobip\Model\TfaApiException', + '\Infobip\Model\ApiException', $apiException->getResponseHeaders() ); + $apiException->setResponseObject($data); + return $apiException; } if ($statusCode >= 500 && $statusCode <= 599) { - $data = ObjectSerializer::deserialize( + $data = $this->objectSerializer->deserialize( $apiException->getResponseBody(), - '\Infobip\Model\TfaApiException', + '\Infobip\Model\ApiException', $apiException->getResponseHeaders() ); + $apiException->setResponseObject($data); + return $apiException; } - - $data = ObjectSerializer::deserialize( + $data = $this->objectSerializer->deserialize( $apiException->getResponseBody(), '\Infobip\Model\TfaStartAuthenticationResponse', $apiException->getResponseHeaders() ); + $apiException->setResponseObject($data); + return $apiException; } @@ -2444,50 +2151,34 @@ protected function resendTfaPinCodeOverSmsApiException($apiException) * * Resend 2FA PIN code over Voice * - * @param string $pinId ID of the pin code that has to be verified. (required) - * @param \Infobip\Model\TfaResendPinRequest $tfaResendPinRequest tfaResendPinRequest (optional) - * - * @throws \Infobip\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \Infobip\Model\TfaApiException|\Infobip\Model\TfaApiException|\Infobip\Model\TfaStartAuthenticationResponse - */ - public function resendTfaPinCodeOverVoice($pinId, $tfaResendPinRequest = null) - { - list($response) = $this->resendTfaPinCodeOverVoiceWithHttpInfo($pinId, $tfaResendPinRequest); - return $response; - } - - /** - * Operation resendTfaPinCodeOverVoiceWithHttpInfo - * - * Resend 2FA PIN code over Voice - * - * @param string $pinId ID of the pin code that has to be verified. (required) - * @param \Infobip\Model\TfaResendPinRequest $tfaResendPinRequest (optional) + * @param string $pinId ID of the pin code that has to be verified. (required) + * @param \Infobip\Model\TfaResendPinRequest $tfaResendPinRequest tfaResendPinRequest (required) * - * @throws \Infobip\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \Infobip\Model\TfaApiException|\Infobip\Model\TfaApiException|\Infobip\Model\TfaStartAuthenticationResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\TfaStartAuthenticationResponse */ - public function resendTfaPinCodeOverVoiceWithHttpInfo($pinId, $tfaResendPinRequest = null) + public function resendTfaPinCodeOverVoice(string $pinId, \Infobip\Model\TfaResendPinRequest $tfaResendPinRequest) { $request = $this->resendTfaPinCodeOverVoiceRequest($pinId, $tfaResendPinRequest); try { - $options = $this->createHttpClientOption(); try { - $response = $this->client->send($request, $options); + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); return $this->resendTfaPinCodeOverVoiceResponse($response, $request->getUri()); - } catch (RequestException $e) { + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null ); } - } catch (ApiException $e) { - throw $this->resendTfaPinCodeOverVoiceApiException($e); + } catch (ApiException $exception) { + throw $this->resendTfaPinCodeOverVoiceApiException($exception); } } @@ -2496,53 +2187,36 @@ public function resendTfaPinCodeOverVoiceWithHttpInfo($pinId, $tfaResendPinReque * * Resend 2FA PIN code over Voice * - * @param string $pinId ID of the pin code that has to be verified. (required) - * @param \Infobip\Model\TfaResendPinRequest $tfaResendPinRequest (optional) - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function resendTfaPinCodeOverVoiceAsync($pinId, $tfaResendPinRequest = null) - { - return $this->resendTfaPinCodeOverVoiceAsyncWithHttpInfo($pinId, $tfaResendPinRequest) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation resendTfaPinCodeOverVoiceAsyncWithHttpInfo - * - * Resend 2FA PIN code over Voice - * - * @param string $pinId ID of the pin code that has to be verified. (required) - * @param \Infobip\Model\TfaResendPinRequest $tfaResendPinRequest (optional) + * @param string $pinId ID of the pin code that has to be verified. (required) + * @param \Infobip\Model\TfaResendPinRequest $tfaResendPinRequest (required) * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws InvalidArgumentException */ - public function resendTfaPinCodeOverVoiceAsyncWithHttpInfo($pinId, $tfaResendPinRequest = null) + public function resendTfaPinCodeOverVoiceAsync(string $pinId, \Infobip\Model\TfaResendPinRequest $tfaResendPinRequest): PromiseInterface { $request = $this->resendTfaPinCodeOverVoiceRequest($pinId, $tfaResendPinRequest); - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) + return $this + ->client + ->sendAsync($request) ->then( function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); return $this->resendTfaPinCodeOverVoiceResponse($response, $request->getUri()); }, - function ($exception) { + function (GuzzleException $exception) { $statusCode = $exception->getCode(); - $response = $exception->getResponse(); - $e = new ApiException( + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( "[{$statusCode}] {$exception->getMessage()}", $statusCode, - $response ? $response->getHeaders() : null, - $response ? (string) $response->getBody() : null + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null ); - throw $this->resendTfaPinCodeOverVoiceApiException($e); + + throw $this->resendTfaPinCodeOverVoiceApiException($exception); } ); } @@ -2550,20 +2224,34 @@ function ($exception) { /** * Create request for operation 'resendTfaPinCodeOverVoice' * - * @param string $pinId ID of the pin code that has to be verified. (required) - * @param \Infobip\Model\TfaResendPinRequest $tfaResendPinRequest (optional) + * @param string $pinId ID of the pin code that has to be verified. (required) + * @param \Infobip\Model\TfaResendPinRequest $tfaResendPinRequest (required) * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws InvalidArgumentException */ - protected function resendTfaPinCodeOverVoiceRequest($pinId, $tfaResendPinRequest = null) + private function resendTfaPinCodeOverVoiceRequest(string $pinId, \Infobip\Model\TfaResendPinRequest $tfaResendPinRequest): Request { - // verify the required parameter 'pinId' is set - if ($pinId === null || (is_array($pinId) && count($pinId) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $pinId when calling resendTfaPinCodeOverVoice' + $allData = [ + 'pinId' => $pinId, + 'tfaResendPinRequest' => $tfaResendPinRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'pinId' => [ + new Assert\NotBlank(), + ], + 'tfaResendPinRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints ); - } + + $this->validateParams($allData, $validationConstraints); $resourcePath = '/2fa/2/pin/{pinId}/resend/voice'; $formParams = []; @@ -2571,37 +2259,36 @@ protected function resendTfaPinCodeOverVoiceRequest($pinId, $tfaResendPinRequest $headerParams = []; $httpBody = ''; - - // path params if ($pinId !== null) { $resourcePath = str_replace( '{' . 'pinId' . '}', - ObjectSerializer::toPathValue($pinId), + $this->objectSerializer->toPathValue($pinId), $resourcePath ); } - - $headers = $this->headerSelector->selectHeaders( - ['application/json', 'application/xml'], - ['application/json', 'application/xml'] - ); + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; // for model (json/xml) if (isset($tfaResendPinRequest)) { - if ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($tfaResendPinRequest)); - } else { - $httpBody = $tfaResendPinRequest; - } + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($tfaResendPinRequest) + : $tfaResendPinRequest; } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + if ($headers['Content-Type'] === 'multipart/form-data') { - $boundary = '----'.hash('sha256', uniqid('', true)); + $boundary = '----' . hash('sha256', uniqid('', true)); $headers['Content-Type'] .= '; boundary=' . $boundary; $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + $formParamValueItems = (\is_array($formParamValue)) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { $multipartContents[] = [ 'name' => $formParamName, @@ -2609,47 +2296,45 @@ protected function resendTfaPinCodeOverVoiceRequest($pinId, $tfaResendPinRequest ]; } } + // for HTTP post (form) $httpBody = new MultipartStream($multipartContents, $boundary); } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); + $httpBody = $this->objectSerializer->serialize($formParams); } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); + $httpBody = Query::build($formParams); } } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('Authorization'); - if ($apiKey !== null) { - $headers['Authorization'] = $apiKey; - } - // this endpoint requires HTTP basic authentication - if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) { - $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); - } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('Authorization'); + $apiKey = $this->config->getApiKey(); + if ($apiKey !== null) { - $headers['Authorization'] = $apiKey; - } - // this endpoint requires OAuth (access token) - if (!empty($this->config->getAccessToken())) { - $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + $headers[$this->config->getApiKeyHeader()] = $apiKey; } $defaultHeaders = []; + if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } - $headers = array_merge( + $headers = \array_merge( $defaultHeaders, $headerParams, $headers ); - $query = \GuzzleHttp\Psr7\Query::build($queryParams); + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), @@ -2660,14 +2345,10 @@ protected function resendTfaPinCodeOverVoiceRequest($pinId, $tfaResendPinRequest /** * Create response for operation 'resendTfaPinCodeOverVoice' - * - * @param \GuzzleHttp\Psr7\Response $response - * @param string $requestUri - * - * @throws \Infobip\ApiException on non-2xx response - * @return array of \Infobip\Model\TfaApiException|\Infobip\Model\TfaApiException|\Infobip\Model\TfaStartAuthenticationResponse|null, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\TfaStartAuthenticationResponse|null */ - protected function resendTfaPinCodeOverVoiceResponse($response, $requestUri) + private function resendTfaPinCodeOverVoiceResponse(ResponseInterface $response, UriInterface $requestUri): mixed { $statusCode = $response->getStatusCode(); $responseBody = $response->getBody(); @@ -2675,67 +2356,56 @@ protected function resendTfaPinCodeOverVoiceResponse($response, $requestUri) if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( - sprintf('[%d] Error connecting to the API (%s)', $statusCode, $requestUri), + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), $statusCode, $responseHeaders, $responseBody ); } - $responseObject = null; - - - $type = '\Infobip\Model\TfaStartAuthenticationResponse'; - if ($type === '\SplFileObject') { - $content = $responseBody; //stream goes to serializer - } else { - $content = (string) $responseBody; - } - $responseObject = ObjectSerializer::deserialize($content, $type, $responseHeaders); + $responseResult = null; - return [ - $responseObject, - $statusCode, - $responseHeaders - ]; + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\TfaStartAuthenticationResponse', $responseHeaders); + return $responseResult; } /** - * Adapt given \Infobip\ApiException for operation 'resendTfaPinCodeOverVoice' - * - * @param \Infobip\ApiException $apiException - * - * @return \Infobip\ApiException + * Adapt given ApiException for operation 'resendTfaPinCodeOverVoice' */ - protected function resendTfaPinCodeOverVoiceApiException($apiException) + private function resendTfaPinCodeOverVoiceApiException(ApiException $apiException): ApiException { $statusCode = $apiException->getCode(); if ($statusCode >= 400 && $statusCode <= 499) { - $data = ObjectSerializer::deserialize( + $data = $this->objectSerializer->deserialize( $apiException->getResponseBody(), - '\Infobip\Model\TfaApiException', + '\Infobip\Model\ApiException', $apiException->getResponseHeaders() ); + $apiException->setResponseObject($data); + return $apiException; } if ($statusCode >= 500 && $statusCode <= 599) { - $data = ObjectSerializer::deserialize( + $data = $this->objectSerializer->deserialize( $apiException->getResponseBody(), - '\Infobip\Model\TfaApiException', + '\Infobip\Model\ApiException', $apiException->getResponseHeaders() ); + $apiException->setResponseObject($data); + return $apiException; } - - $data = ObjectSerializer::deserialize( + $data = $this->objectSerializer->deserialize( $apiException->getResponseBody(), '\Infobip\Model\TfaStartAuthenticationResponse', $apiException->getResponseHeaders() ); + $apiException->setResponseObject($data); + return $apiException; } @@ -2744,50 +2414,34 @@ protected function resendTfaPinCodeOverVoiceApiException($apiException) * * Send 2FA PIN code over SMS * - * @param bool $ncNeeded Indicates if Number Lookup is needed before sending the 2FA message. If the parameter value is true, Number Lookup will be requested before sending the SMS. If the value is false, the SMS will be sent without requesting Number Lookup. Field's default value is `true`. (optional) - * @param \Infobip\Model\TfaStartAuthenticationRequest $tfaStartAuthenticationRequest tfaStartAuthenticationRequest (optional) - * - * @throws \Infobip\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \Infobip\Model\TfaApiException|\Infobip\Model\TfaApiException|\Infobip\Model\TfaStartAuthenticationResponse - */ - public function sendTfaPinCodeOverSms($ncNeeded = null, $tfaStartAuthenticationRequest = null) - { - list($response) = $this->sendTfaPinCodeOverSmsWithHttpInfo($ncNeeded, $tfaStartAuthenticationRequest); - return $response; - } - - /** - * Operation sendTfaPinCodeOverSmsWithHttpInfo - * - * Send 2FA PIN code over SMS - * - * @param bool $ncNeeded Indicates if Number Lookup is needed before sending the 2FA message. If the parameter value is true, Number Lookup will be requested before sending the SMS. If the value is false, the SMS will be sent without requesting Number Lookup. Field's default value is `true`. (optional) - * @param \Infobip\Model\TfaStartAuthenticationRequest $tfaStartAuthenticationRequest (optional) + * @param \Infobip\Model\TfaStartAuthenticationRequest $tfaStartAuthenticationRequest tfaStartAuthenticationRequest (required) + * @param null|bool $ncNeeded Indicates if Number Lookup is needed before sending the 2FA message. If the parameter value is true, Number Lookup will be requested before sending the SMS. If the value is false, the SMS will be sent without requesting Number Lookup. Field's default value is `true`. (optional) * - * @throws \Infobip\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \Infobip\Model\TfaApiException|\Infobip\Model\TfaApiException|\Infobip\Model\TfaStartAuthenticationResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\TfaStartAuthenticationResponse */ - public function sendTfaPinCodeOverSmsWithHttpInfo($ncNeeded = null, $tfaStartAuthenticationRequest = null) + public function sendTfaPinCodeOverSms(\Infobip\Model\TfaStartAuthenticationRequest $tfaStartAuthenticationRequest, ?bool $ncNeeded = null) { - $request = $this->sendTfaPinCodeOverSmsRequest($ncNeeded, $tfaStartAuthenticationRequest); + $request = $this->sendTfaPinCodeOverSmsRequest($tfaStartAuthenticationRequest, $ncNeeded); try { - $options = $this->createHttpClientOption(); try { - $response = $this->client->send($request, $options); + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); return $this->sendTfaPinCodeOverSmsResponse($response, $request->getUri()); - } catch (RequestException $e) { + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null ); } - } catch (ApiException $e) { - throw $this->sendTfaPinCodeOverSmsApiException($e); + } catch (ApiException $exception) { + throw $this->sendTfaPinCodeOverSmsApiException($exception); } } @@ -2796,53 +2450,36 @@ public function sendTfaPinCodeOverSmsWithHttpInfo($ncNeeded = null, $tfaStartAut * * Send 2FA PIN code over SMS * - * @param bool $ncNeeded Indicates if Number Lookup is needed before sending the 2FA message. If the parameter value is true, Number Lookup will be requested before sending the SMS. If the value is false, the SMS will be sent without requesting Number Lookup. Field's default value is `true`. (optional) - * @param \Infobip\Model\TfaStartAuthenticationRequest $tfaStartAuthenticationRequest (optional) - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function sendTfaPinCodeOverSmsAsync($ncNeeded = null, $tfaStartAuthenticationRequest = null) - { - return $this->sendTfaPinCodeOverSmsAsyncWithHttpInfo($ncNeeded, $tfaStartAuthenticationRequest) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation sendTfaPinCodeOverSmsAsyncWithHttpInfo - * - * Send 2FA PIN code over SMS - * - * @param bool $ncNeeded Indicates if Number Lookup is needed before sending the 2FA message. If the parameter value is true, Number Lookup will be requested before sending the SMS. If the value is false, the SMS will be sent without requesting Number Lookup. Field's default value is `true`. (optional) - * @param \Infobip\Model\TfaStartAuthenticationRequest $tfaStartAuthenticationRequest (optional) + * @param \Infobip\Model\TfaStartAuthenticationRequest $tfaStartAuthenticationRequest (required) + * @param null|bool $ncNeeded Indicates if Number Lookup is needed before sending the 2FA message. If the parameter value is true, Number Lookup will be requested before sending the SMS. If the value is false, the SMS will be sent without requesting Number Lookup. Field's default value is `true`. (optional) * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws InvalidArgumentException */ - public function sendTfaPinCodeOverSmsAsyncWithHttpInfo($ncNeeded = null, $tfaStartAuthenticationRequest = null) + public function sendTfaPinCodeOverSmsAsync(\Infobip\Model\TfaStartAuthenticationRequest $tfaStartAuthenticationRequest, ?bool $ncNeeded = null): PromiseInterface { - $request = $this->sendTfaPinCodeOverSmsRequest($ncNeeded, $tfaStartAuthenticationRequest); + $request = $this->sendTfaPinCodeOverSmsRequest($tfaStartAuthenticationRequest, $ncNeeded); - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) + return $this + ->client + ->sendAsync($request) ->then( function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); return $this->sendTfaPinCodeOverSmsResponse($response, $request->getUri()); }, - function ($exception) { + function (GuzzleException $exception) { $statusCode = $exception->getCode(); - $response = $exception->getResponse(); - $e = new ApiException( + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( "[{$statusCode}] {$exception->getMessage()}", $statusCode, - $response ? $response->getHeaders() : null, - $response ? (string) $response->getBody() : null + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null ); - throw $this->sendTfaPinCodeOverSmsApiException($e); + + throw $this->sendTfaPinCodeOverSmsApiException($exception); } ); } @@ -2850,14 +2487,34 @@ function ($exception) { /** * Create request for operation 'sendTfaPinCodeOverSms' * - * @param bool $ncNeeded Indicates if Number Lookup is needed before sending the 2FA message. If the parameter value is true, Number Lookup will be requested before sending the SMS. If the value is false, the SMS will be sent without requesting Number Lookup. Field's default value is `true`. (optional) - * @param \Infobip\Model\TfaStartAuthenticationRequest $tfaStartAuthenticationRequest (optional) + * @param \Infobip\Model\TfaStartAuthenticationRequest $tfaStartAuthenticationRequest (required) + * @param null|bool $ncNeeded Indicates if Number Lookup is needed before sending the 2FA message. If the parameter value is true, Number Lookup will be requested before sending the SMS. If the value is false, the SMS will be sent without requesting Number Lookup. Field's default value is `true`. (optional) * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws InvalidArgumentException */ - protected function sendTfaPinCodeOverSmsRequest($ncNeeded = null, $tfaStartAuthenticationRequest = null) + private function sendTfaPinCodeOverSmsRequest(\Infobip\Model\TfaStartAuthenticationRequest $tfaStartAuthenticationRequest, ?bool $ncNeeded = null): Request { + $allData = [ + 'tfaStartAuthenticationRequest' => $tfaStartAuthenticationRequest, + 'ncNeeded' => $ncNeeded, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'tfaStartAuthenticationRequest' => [ + new Assert\NotNull(), + ], + 'ncNeeded' => [ + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + $resourcePath = '/2fa/2/pin'; $formParams = []; $queryParams = []; @@ -2869,28 +2526,27 @@ protected function sendTfaPinCodeOverSmsRequest($ncNeeded = null, $tfaStartAuthe $queryParams['ncNeeded'] = $ncNeeded; } - - - - $headers = $this->headerSelector->selectHeaders( - ['application/json', 'application/xml'], - ['application/json', 'application/xml'] - ); + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; // for model (json/xml) if (isset($tfaStartAuthenticationRequest)) { - if ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($tfaStartAuthenticationRequest)); - } else { - $httpBody = $tfaStartAuthenticationRequest; - } + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($tfaStartAuthenticationRequest) + : $tfaStartAuthenticationRequest; } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + if ($headers['Content-Type'] === 'multipart/form-data') { - $boundary = '----'.hash('sha256', uniqid('', true)); + $boundary = '----' . hash('sha256', uniqid('', true)); $headers['Content-Type'] .= '; boundary=' . $boundary; $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + $formParamValueItems = (\is_array($formParamValue)) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { $multipartContents[] = [ 'name' => $formParamName, @@ -2898,47 +2554,45 @@ protected function sendTfaPinCodeOverSmsRequest($ncNeeded = null, $tfaStartAuthe ]; } } + // for HTTP post (form) $httpBody = new MultipartStream($multipartContents, $boundary); } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); + $httpBody = $this->objectSerializer->serialize($formParams); } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); + $httpBody = Query::build($formParams); } } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('Authorization'); - if ($apiKey !== null) { - $headers['Authorization'] = $apiKey; - } - // this endpoint requires HTTP basic authentication - if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) { - $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); - } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('Authorization'); + $apiKey = $this->config->getApiKey(); + if ($apiKey !== null) { - $headers['Authorization'] = $apiKey; - } - // this endpoint requires OAuth (access token) - if (!empty($this->config->getAccessToken())) { - $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + $headers[$this->config->getApiKeyHeader()] = $apiKey; } $defaultHeaders = []; + if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } - $headers = array_merge( + $headers = \array_merge( $defaultHeaders, $headerParams, $headers ); - $query = \GuzzleHttp\Psr7\Query::build($queryParams); + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), @@ -2949,14 +2603,10 @@ protected function sendTfaPinCodeOverSmsRequest($ncNeeded = null, $tfaStartAuthe /** * Create response for operation 'sendTfaPinCodeOverSms' - * - * @param \GuzzleHttp\Psr7\Response $response - * @param string $requestUri - * - * @throws \Infobip\ApiException on non-2xx response - * @return array of \Infobip\Model\TfaApiException|\Infobip\Model\TfaApiException|\Infobip\Model\TfaStartAuthenticationResponse|null, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\TfaStartAuthenticationResponse|null */ - protected function sendTfaPinCodeOverSmsResponse($response, $requestUri) + private function sendTfaPinCodeOverSmsResponse(ResponseInterface $response, UriInterface $requestUri): mixed { $statusCode = $response->getStatusCode(); $responseBody = $response->getBody(); @@ -2964,67 +2614,56 @@ protected function sendTfaPinCodeOverSmsResponse($response, $requestUri) if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( - sprintf('[%d] Error connecting to the API (%s)', $statusCode, $requestUri), + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), $statusCode, $responseHeaders, $responseBody ); } - $responseObject = null; - - - $type = '\Infobip\Model\TfaStartAuthenticationResponse'; - if ($type === '\SplFileObject') { - $content = $responseBody; //stream goes to serializer - } else { - $content = (string) $responseBody; - } - $responseObject = ObjectSerializer::deserialize($content, $type, $responseHeaders); + $responseResult = null; - return [ - $responseObject, - $statusCode, - $responseHeaders - ]; + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\TfaStartAuthenticationResponse', $responseHeaders); + return $responseResult; } /** - * Adapt given \Infobip\ApiException for operation 'sendTfaPinCodeOverSms' - * - * @param \Infobip\ApiException $apiException - * - * @return \Infobip\ApiException + * Adapt given ApiException for operation 'sendTfaPinCodeOverSms' */ - protected function sendTfaPinCodeOverSmsApiException($apiException) + private function sendTfaPinCodeOverSmsApiException(ApiException $apiException): ApiException { $statusCode = $apiException->getCode(); if ($statusCode >= 400 && $statusCode <= 499) { - $data = ObjectSerializer::deserialize( + $data = $this->objectSerializer->deserialize( $apiException->getResponseBody(), - '\Infobip\Model\TfaApiException', + '\Infobip\Model\ApiException', $apiException->getResponseHeaders() ); + $apiException->setResponseObject($data); + return $apiException; } if ($statusCode >= 500 && $statusCode <= 599) { - $data = ObjectSerializer::deserialize( + $data = $this->objectSerializer->deserialize( $apiException->getResponseBody(), - '\Infobip\Model\TfaApiException', + '\Infobip\Model\ApiException', $apiException->getResponseHeaders() ); + $apiException->setResponseObject($data); + return $apiException; } - - $data = ObjectSerializer::deserialize( + $data = $this->objectSerializer->deserialize( $apiException->getResponseBody(), '\Infobip\Model\TfaStartAuthenticationResponse', $apiException->getResponseHeaders() ); + $apiException->setResponseObject($data); + return $apiException; } @@ -3033,48 +2672,33 @@ protected function sendTfaPinCodeOverSmsApiException($apiException) * * Send 2FA PIN code over Voice * - * @param \Infobip\Model\TfaStartAuthenticationRequest $tfaStartAuthenticationRequest tfaStartAuthenticationRequest (optional) - * - * @throws \Infobip\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \Infobip\Model\TfaApiException|\Infobip\Model\TfaApiException|\Infobip\Model\TfaStartAuthenticationResponse - */ - public function sendTfaPinCodeOverVoice($tfaStartAuthenticationRequest = null) - { - list($response) = $this->sendTfaPinCodeOverVoiceWithHttpInfo($tfaStartAuthenticationRequest); - return $response; - } - - /** - * Operation sendTfaPinCodeOverVoiceWithHttpInfo - * - * Send 2FA PIN code over Voice - * - * @param \Infobip\Model\TfaStartAuthenticationRequest $tfaStartAuthenticationRequest (optional) + * @param \Infobip\Model\TfaStartAuthenticationRequest $tfaStartAuthenticationRequest tfaStartAuthenticationRequest (required) * - * @throws \Infobip\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \Infobip\Model\TfaApiException|\Infobip\Model\TfaApiException|\Infobip\Model\TfaStartAuthenticationResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\TfaStartAuthenticationResponse */ - public function sendTfaPinCodeOverVoiceWithHttpInfo($tfaStartAuthenticationRequest = null) + public function sendTfaPinCodeOverVoice(\Infobip\Model\TfaStartAuthenticationRequest $tfaStartAuthenticationRequest) { $request = $this->sendTfaPinCodeOverVoiceRequest($tfaStartAuthenticationRequest); try { - $options = $this->createHttpClientOption(); try { - $response = $this->client->send($request, $options); + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); return $this->sendTfaPinCodeOverVoiceResponse($response, $request->getUri()); - } catch (RequestException $e) { + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null ); } - } catch (ApiException $e) { - throw $this->sendTfaPinCodeOverVoiceApiException($e); + } catch (ApiException $exception) { + throw $this->sendTfaPinCodeOverVoiceApiException($exception); } } @@ -3083,51 +2707,35 @@ public function sendTfaPinCodeOverVoiceWithHttpInfo($tfaStartAuthenticationReque * * Send 2FA PIN code over Voice * - * @param \Infobip\Model\TfaStartAuthenticationRequest $tfaStartAuthenticationRequest (optional) + * @param \Infobip\Model\TfaStartAuthenticationRequest $tfaStartAuthenticationRequest (required) * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws InvalidArgumentException */ - public function sendTfaPinCodeOverVoiceAsync($tfaStartAuthenticationRequest = null) - { - return $this->sendTfaPinCodeOverVoiceAsyncWithHttpInfo($tfaStartAuthenticationRequest) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation sendTfaPinCodeOverVoiceAsyncWithHttpInfo - * - * Send 2FA PIN code over Voice - * - * @param \Infobip\Model\TfaStartAuthenticationRequest $tfaStartAuthenticationRequest (optional) - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function sendTfaPinCodeOverVoiceAsyncWithHttpInfo($tfaStartAuthenticationRequest = null) + public function sendTfaPinCodeOverVoiceAsync(\Infobip\Model\TfaStartAuthenticationRequest $tfaStartAuthenticationRequest): PromiseInterface { $request = $this->sendTfaPinCodeOverVoiceRequest($tfaStartAuthenticationRequest); - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) + return $this + ->client + ->sendAsync($request) ->then( function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); return $this->sendTfaPinCodeOverVoiceResponse($response, $request->getUri()); }, - function ($exception) { + function (GuzzleException $exception) { $statusCode = $exception->getCode(); - $response = $exception->getResponse(); - $e = new ApiException( + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( "[{$statusCode}] {$exception->getMessage()}", $statusCode, - $response ? $response->getHeaders() : null, - $response ? (string) $response->getBody() : null + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null ); - throw $this->sendTfaPinCodeOverVoiceApiException($e); + + throw $this->sendTfaPinCodeOverVoiceApiException($exception); } ); } @@ -3135,42 +2743,57 @@ function ($exception) { /** * Create request for operation 'sendTfaPinCodeOverVoice' * - * @param \Infobip\Model\TfaStartAuthenticationRequest $tfaStartAuthenticationRequest (optional) + * @param \Infobip\Model\TfaStartAuthenticationRequest $tfaStartAuthenticationRequest (required) * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws InvalidArgumentException */ - protected function sendTfaPinCodeOverVoiceRequest($tfaStartAuthenticationRequest = null) + private function sendTfaPinCodeOverVoiceRequest(\Infobip\Model\TfaStartAuthenticationRequest $tfaStartAuthenticationRequest): Request { + $allData = [ + 'tfaStartAuthenticationRequest' => $tfaStartAuthenticationRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'tfaStartAuthenticationRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + $resourcePath = '/2fa/2/pin/voice'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; - - - - - $headers = $this->headerSelector->selectHeaders( - ['application/json', 'application/xml'], - ['application/json', 'application/xml'] - ); + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; // for model (json/xml) if (isset($tfaStartAuthenticationRequest)) { - if ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($tfaStartAuthenticationRequest)); - } else { - $httpBody = $tfaStartAuthenticationRequest; - } + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($tfaStartAuthenticationRequest) + : $tfaStartAuthenticationRequest; } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + if ($headers['Content-Type'] === 'multipart/form-data') { - $boundary = '----'.hash('sha256', uniqid('', true)); + $boundary = '----' . hash('sha256', uniqid('', true)); $headers['Content-Type'] .= '; boundary=' . $boundary; $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + $formParamValueItems = (\is_array($formParamValue)) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { $multipartContents[] = [ 'name' => $formParamName, @@ -3178,47 +2801,45 @@ protected function sendTfaPinCodeOverVoiceRequest($tfaStartAuthenticationRequest ]; } } + // for HTTP post (form) $httpBody = new MultipartStream($multipartContents, $boundary); } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); + $httpBody = $this->objectSerializer->serialize($formParams); } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); + $httpBody = Query::build($formParams); } } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('Authorization'); - if ($apiKey !== null) { - $headers['Authorization'] = $apiKey; - } - // this endpoint requires HTTP basic authentication - if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) { - $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); - } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('Authorization'); + $apiKey = $this->config->getApiKey(); + if ($apiKey !== null) { - $headers['Authorization'] = $apiKey; - } - // this endpoint requires OAuth (access token) - if (!empty($this->config->getAccessToken())) { - $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + $headers[$this->config->getApiKeyHeader()] = $apiKey; } $defaultHeaders = []; + if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } - $headers = array_merge( + $headers = \array_merge( $defaultHeaders, $headerParams, $headers ); - $query = \GuzzleHttp\Psr7\Query::build($queryParams); + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), @@ -3229,14 +2850,10 @@ protected function sendTfaPinCodeOverVoiceRequest($tfaStartAuthenticationRequest /** * Create response for operation 'sendTfaPinCodeOverVoice' - * - * @param \GuzzleHttp\Psr7\Response $response - * @param string $requestUri - * - * @throws \Infobip\ApiException on non-2xx response - * @return array of \Infobip\Model\TfaApiException|\Infobip\Model\TfaApiException|\Infobip\Model\TfaStartAuthenticationResponse|null, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\TfaStartAuthenticationResponse|null */ - protected function sendTfaPinCodeOverVoiceResponse($response, $requestUri) + private function sendTfaPinCodeOverVoiceResponse(ResponseInterface $response, UriInterface $requestUri): mixed { $statusCode = $response->getStatusCode(); $responseBody = $response->getBody(); @@ -3244,67 +2861,56 @@ protected function sendTfaPinCodeOverVoiceResponse($response, $requestUri) if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( - sprintf('[%d] Error connecting to the API (%s)', $statusCode, $requestUri), + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), $statusCode, $responseHeaders, $responseBody ); } - $responseObject = null; - - - $type = '\Infobip\Model\TfaStartAuthenticationResponse'; - if ($type === '\SplFileObject') { - $content = $responseBody; //stream goes to serializer - } else { - $content = (string) $responseBody; - } - $responseObject = ObjectSerializer::deserialize($content, $type, $responseHeaders); + $responseResult = null; - return [ - $responseObject, - $statusCode, - $responseHeaders - ]; + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\TfaStartAuthenticationResponse', $responseHeaders); + return $responseResult; } /** - * Adapt given \Infobip\ApiException for operation 'sendTfaPinCodeOverVoice' - * - * @param \Infobip\ApiException $apiException - * - * @return \Infobip\ApiException + * Adapt given ApiException for operation 'sendTfaPinCodeOverVoice' */ - protected function sendTfaPinCodeOverVoiceApiException($apiException) + private function sendTfaPinCodeOverVoiceApiException(ApiException $apiException): ApiException { $statusCode = $apiException->getCode(); if ($statusCode >= 400 && $statusCode <= 499) { - $data = ObjectSerializer::deserialize( + $data = $this->objectSerializer->deserialize( $apiException->getResponseBody(), - '\Infobip\Model\TfaApiException', + '\Infobip\Model\ApiException', $apiException->getResponseHeaders() ); + $apiException->setResponseObject($data); + return $apiException; } if ($statusCode >= 500 && $statusCode <= 599) { - $data = ObjectSerializer::deserialize( + $data = $this->objectSerializer->deserialize( $apiException->getResponseBody(), - '\Infobip\Model\TfaApiException', + '\Infobip\Model\ApiException', $apiException->getResponseHeaders() ); + $apiException->setResponseObject($data); + return $apiException; } - - $data = ObjectSerializer::deserialize( + $data = $this->objectSerializer->deserialize( $apiException->getResponseBody(), '\Infobip\Model\TfaStartAuthenticationResponse', $apiException->getResponseHeaders() ); + $apiException->setResponseObject($data); + return $apiException; } @@ -3313,50 +2919,34 @@ protected function sendTfaPinCodeOverVoiceApiException($apiException) * * Update 2FA application * - * @param string $appId ID of application that should be updated. (required) - * @param \Infobip\Model\TfaApplicationRequest $tfaApplicationRequest tfaApplicationRequest (optional) - * - * @throws \Infobip\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \Infobip\Model\TfaApiException|\Infobip\Model\TfaApiException|\Infobip\Model\TfaApplicationResponse - */ - public function updateTfaApplication($appId, $tfaApplicationRequest = null) - { - list($response) = $this->updateTfaApplicationWithHttpInfo($appId, $tfaApplicationRequest); - return $response; - } - - /** - * Operation updateTfaApplicationWithHttpInfo - * - * Update 2FA application - * - * @param string $appId ID of application that should be updated. (required) - * @param \Infobip\Model\TfaApplicationRequest $tfaApplicationRequest (optional) + * @param string $appId ID of application that should be updated. (required) + * @param \Infobip\Model\TfaApplicationRequest $tfaApplicationRequest tfaApplicationRequest (required) * - * @throws \Infobip\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \Infobip\Model\TfaApiException|\Infobip\Model\TfaApiException|\Infobip\Model\TfaApplicationResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\TfaApplicationResponse */ - public function updateTfaApplicationWithHttpInfo($appId, $tfaApplicationRequest = null) + public function updateTfaApplication(string $appId, \Infobip\Model\TfaApplicationRequest $tfaApplicationRequest) { $request = $this->updateTfaApplicationRequest($appId, $tfaApplicationRequest); try { - $options = $this->createHttpClientOption(); try { - $response = $this->client->send($request, $options); + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); return $this->updateTfaApplicationResponse($response, $request->getUri()); - } catch (RequestException $e) { + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null ); } - } catch (ApiException $e) { - throw $this->updateTfaApplicationApiException($e); + } catch (ApiException $exception) { + throw $this->updateTfaApplicationApiException($exception); } } @@ -3365,53 +2955,36 @@ public function updateTfaApplicationWithHttpInfo($appId, $tfaApplicationRequest * * Update 2FA application * - * @param string $appId ID of application that should be updated. (required) - * @param \Infobip\Model\TfaApplicationRequest $tfaApplicationRequest (optional) - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function updateTfaApplicationAsync($appId, $tfaApplicationRequest = null) - { - return $this->updateTfaApplicationAsyncWithHttpInfo($appId, $tfaApplicationRequest) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation updateTfaApplicationAsyncWithHttpInfo - * - * Update 2FA application - * - * @param string $appId ID of application that should be updated. (required) - * @param \Infobip\Model\TfaApplicationRequest $tfaApplicationRequest (optional) + * @param string $appId ID of application that should be updated. (required) + * @param \Infobip\Model\TfaApplicationRequest $tfaApplicationRequest (required) * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws InvalidArgumentException */ - public function updateTfaApplicationAsyncWithHttpInfo($appId, $tfaApplicationRequest = null) + public function updateTfaApplicationAsync(string $appId, \Infobip\Model\TfaApplicationRequest $tfaApplicationRequest): PromiseInterface { $request = $this->updateTfaApplicationRequest($appId, $tfaApplicationRequest); - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) + return $this + ->client + ->sendAsync($request) ->then( function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); return $this->updateTfaApplicationResponse($response, $request->getUri()); }, - function ($exception) { + function (GuzzleException $exception) { $statusCode = $exception->getCode(); - $response = $exception->getResponse(); - $e = new ApiException( + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( "[{$statusCode}] {$exception->getMessage()}", $statusCode, - $response ? $response->getHeaders() : null, - $response ? (string) $response->getBody() : null + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null ); - throw $this->updateTfaApplicationApiException($e); + + throw $this->updateTfaApplicationApiException($exception); } ); } @@ -3419,20 +2992,34 @@ function ($exception) { /** * Create request for operation 'updateTfaApplication' * - * @param string $appId ID of application that should be updated. (required) - * @param \Infobip\Model\TfaApplicationRequest $tfaApplicationRequest (optional) + * @param string $appId ID of application that should be updated. (required) + * @param \Infobip\Model\TfaApplicationRequest $tfaApplicationRequest (required) * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws InvalidArgumentException */ - protected function updateTfaApplicationRequest($appId, $tfaApplicationRequest = null) + private function updateTfaApplicationRequest(string $appId, \Infobip\Model\TfaApplicationRequest $tfaApplicationRequest): Request { - // verify the required parameter 'appId' is set - if ($appId === null || (is_array($appId) && count($appId) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $appId when calling updateTfaApplication' + $allData = [ + 'appId' => $appId, + 'tfaApplicationRequest' => $tfaApplicationRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'appId' => [ + new Assert\NotBlank(), + ], + 'tfaApplicationRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints ); - } + + $this->validateParams($allData, $validationConstraints); $resourcePath = '/2fa/2/applications/{appId}'; $formParams = []; @@ -3440,37 +3027,36 @@ protected function updateTfaApplicationRequest($appId, $tfaApplicationRequest = $headerParams = []; $httpBody = ''; - - // path params if ($appId !== null) { $resourcePath = str_replace( '{' . 'appId' . '}', - ObjectSerializer::toPathValue($appId), + $this->objectSerializer->toPathValue($appId), $resourcePath ); } - - $headers = $this->headerSelector->selectHeaders( - ['application/json', 'application/xml'], - ['application/json', 'application/xml'] - ); + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; // for model (json/xml) if (isset($tfaApplicationRequest)) { - if ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($tfaApplicationRequest)); - } else { - $httpBody = $tfaApplicationRequest; - } + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($tfaApplicationRequest) + : $tfaApplicationRequest; } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + if ($headers['Content-Type'] === 'multipart/form-data') { - $boundary = '----'.hash('sha256', uniqid('', true)); + $boundary = '----' . hash('sha256', uniqid('', true)); $headers['Content-Type'] .= '; boundary=' . $boundary; $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + $formParamValueItems = (\is_array($formParamValue)) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { $multipartContents[] = [ 'name' => $formParamName, @@ -3478,47 +3064,45 @@ protected function updateTfaApplicationRequest($appId, $tfaApplicationRequest = ]; } } + // for HTTP post (form) $httpBody = new MultipartStream($multipartContents, $boundary); } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); + $httpBody = $this->objectSerializer->serialize($formParams); } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); + $httpBody = Query::build($formParams); } } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('Authorization'); - if ($apiKey !== null) { - $headers['Authorization'] = $apiKey; - } - // this endpoint requires HTTP basic authentication - if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) { - $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); - } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('Authorization'); + $apiKey = $this->config->getApiKey(); + if ($apiKey !== null) { - $headers['Authorization'] = $apiKey; - } - // this endpoint requires OAuth (access token) - if (!empty($this->config->getAccessToken())) { - $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + $headers[$this->config->getApiKeyHeader()] = $apiKey; } $defaultHeaders = []; + if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } - $headers = array_merge( + $headers = \array_merge( $defaultHeaders, $headerParams, $headers ); - $query = \GuzzleHttp\Psr7\Query::build($queryParams); + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + return new Request( 'PUT', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), @@ -3529,14 +3113,10 @@ protected function updateTfaApplicationRequest($appId, $tfaApplicationRequest = /** * Create response for operation 'updateTfaApplication' - * - * @param \GuzzleHttp\Psr7\Response $response - * @param string $requestUri - * - * @throws \Infobip\ApiException on non-2xx response - * @return array of \Infobip\Model\TfaApiException|\Infobip\Model\TfaApiException|\Infobip\Model\TfaApplicationResponse|null, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\TfaApplicationResponse|null */ - protected function updateTfaApplicationResponse($response, $requestUri) + private function updateTfaApplicationResponse(ResponseInterface $response, UriInterface $requestUri): mixed { $statusCode = $response->getStatusCode(); $responseBody = $response->getBody(); @@ -3544,67 +3124,56 @@ protected function updateTfaApplicationResponse($response, $requestUri) if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( - sprintf('[%d] Error connecting to the API (%s)', $statusCode, $requestUri), + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), $statusCode, $responseHeaders, $responseBody ); } - $responseObject = null; - - - $type = '\Infobip\Model\TfaApplicationResponse'; - if ($type === '\SplFileObject') { - $content = $responseBody; //stream goes to serializer - } else { - $content = (string) $responseBody; - } - $responseObject = ObjectSerializer::deserialize($content, $type, $responseHeaders); + $responseResult = null; - return [ - $responseObject, - $statusCode, - $responseHeaders - ]; + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\TfaApplicationResponse', $responseHeaders); + return $responseResult; } /** - * Adapt given \Infobip\ApiException for operation 'updateTfaApplication' - * - * @param \Infobip\ApiException $apiException - * - * @return \Infobip\ApiException + * Adapt given ApiException for operation 'updateTfaApplication' */ - protected function updateTfaApplicationApiException($apiException) + private function updateTfaApplicationApiException(ApiException $apiException): ApiException { $statusCode = $apiException->getCode(); if ($statusCode >= 400 && $statusCode <= 499) { - $data = ObjectSerializer::deserialize( + $data = $this->objectSerializer->deserialize( $apiException->getResponseBody(), - '\Infobip\Model\TfaApiException', + '\Infobip\Model\ApiException', $apiException->getResponseHeaders() ); + $apiException->setResponseObject($data); + return $apiException; } if ($statusCode >= 500 && $statusCode <= 599) { - $data = ObjectSerializer::deserialize( + $data = $this->objectSerializer->deserialize( $apiException->getResponseBody(), - '\Infobip\Model\TfaApiException', + '\Infobip\Model\ApiException', $apiException->getResponseHeaders() ); + $apiException->setResponseObject($data); + return $apiException; } - - $data = ObjectSerializer::deserialize( + $data = $this->objectSerializer->deserialize( $apiException->getResponseBody(), '\Infobip\Model\TfaApplicationResponse', $apiException->getResponseHeaders() ); + $apiException->setResponseObject($data); + return $apiException; } @@ -3613,52 +3182,35 @@ protected function updateTfaApplicationApiException($apiException) * * Update 2FA message template * - * @param string $appId ID of application for which requested message was created. (required) - * @param string $msgId Requested message ID. (required) - * @param \Infobip\Model\TfaUpdateMessageRequest $tfaUpdateMessageRequest tfaUpdateMessageRequest (optional) - * - * @throws \Infobip\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \Infobip\Model\TfaApiException|\Infobip\Model\TfaApiException|\Infobip\Model\TfaMessage - */ - public function updateTfaMessageTemplate($appId, $msgId, $tfaUpdateMessageRequest = null) - { - list($response) = $this->updateTfaMessageTemplateWithHttpInfo($appId, $msgId, $tfaUpdateMessageRequest); - return $response; - } - - /** - * Operation updateTfaMessageTemplateWithHttpInfo - * - * Update 2FA message template - * - * @param string $appId ID of application for which requested message was created. (required) - * @param string $msgId Requested message ID. (required) - * @param \Infobip\Model\TfaUpdateMessageRequest $tfaUpdateMessageRequest (optional) + * @param string $appId ID of application for which requested message was created. (required) + * @param string $msgId Requested message ID. (required) + * @param \Infobip\Model\TfaUpdateMessageRequest $tfaUpdateMessageRequest tfaUpdateMessageRequest (required) * - * @throws \Infobip\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \Infobip\Model\TfaApiException|\Infobip\Model\TfaApiException|\Infobip\Model\TfaMessage, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\TfaMessage */ - public function updateTfaMessageTemplateWithHttpInfo($appId, $msgId, $tfaUpdateMessageRequest = null) + public function updateTfaMessageTemplate(string $appId, string $msgId, \Infobip\Model\TfaUpdateMessageRequest $tfaUpdateMessageRequest) { $request = $this->updateTfaMessageTemplateRequest($appId, $msgId, $tfaUpdateMessageRequest); try { - $options = $this->createHttpClientOption(); try { - $response = $this->client->send($request, $options); + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); return $this->updateTfaMessageTemplateResponse($response, $request->getUri()); - } catch (RequestException $e) { + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null ); } - } catch (ApiException $e) { - throw $this->updateTfaMessageTemplateApiException($e); + } catch (ApiException $exception) { + throw $this->updateTfaMessageTemplateApiException($exception); } } @@ -3667,55 +3219,37 @@ public function updateTfaMessageTemplateWithHttpInfo($appId, $msgId, $tfaUpdateM * * Update 2FA message template * - * @param string $appId ID of application for which requested message was created. (required) - * @param string $msgId Requested message ID. (required) - * @param \Infobip\Model\TfaUpdateMessageRequest $tfaUpdateMessageRequest (optional) - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function updateTfaMessageTemplateAsync($appId, $msgId, $tfaUpdateMessageRequest = null) - { - return $this->updateTfaMessageTemplateAsyncWithHttpInfo($appId, $msgId, $tfaUpdateMessageRequest) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation updateTfaMessageTemplateAsyncWithHttpInfo - * - * Update 2FA message template - * - * @param string $appId ID of application for which requested message was created. (required) - * @param string $msgId Requested message ID. (required) - * @param \Infobip\Model\TfaUpdateMessageRequest $tfaUpdateMessageRequest (optional) + * @param string $appId ID of application for which requested message was created. (required) + * @param string $msgId Requested message ID. (required) + * @param \Infobip\Model\TfaUpdateMessageRequest $tfaUpdateMessageRequest (required) * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws InvalidArgumentException */ - public function updateTfaMessageTemplateAsyncWithHttpInfo($appId, $msgId, $tfaUpdateMessageRequest = null) + public function updateTfaMessageTemplateAsync(string $appId, string $msgId, \Infobip\Model\TfaUpdateMessageRequest $tfaUpdateMessageRequest): PromiseInterface { $request = $this->updateTfaMessageTemplateRequest($appId, $msgId, $tfaUpdateMessageRequest); - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) + return $this + ->client + ->sendAsync($request) ->then( function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); return $this->updateTfaMessageTemplateResponse($response, $request->getUri()); }, - function ($exception) { + function (GuzzleException $exception) { $statusCode = $exception->getCode(); - $response = $exception->getResponse(); - $e = new ApiException( + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( "[{$statusCode}] {$exception->getMessage()}", $statusCode, - $response ? $response->getHeaders() : null, - $response ? (string) $response->getBody() : null + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null ); - throw $this->updateTfaMessageTemplateApiException($e); + + throw $this->updateTfaMessageTemplateApiException($exception); } ); } @@ -3723,27 +3257,39 @@ function ($exception) { /** * Create request for operation 'updateTfaMessageTemplate' * - * @param string $appId ID of application for which requested message was created. (required) - * @param string $msgId Requested message ID. (required) - * @param \Infobip\Model\TfaUpdateMessageRequest $tfaUpdateMessageRequest (optional) + * @param string $appId ID of application for which requested message was created. (required) + * @param string $msgId Requested message ID. (required) + * @param \Infobip\Model\TfaUpdateMessageRequest $tfaUpdateMessageRequest (required) * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws InvalidArgumentException */ - protected function updateTfaMessageTemplateRequest($appId, $msgId, $tfaUpdateMessageRequest = null) + private function updateTfaMessageTemplateRequest(string $appId, string $msgId, \Infobip\Model\TfaUpdateMessageRequest $tfaUpdateMessageRequest): Request { - // verify the required parameter 'appId' is set - if ($appId === null || (is_array($appId) && count($appId) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $appId when calling updateTfaMessageTemplate' - ); - } - // verify the required parameter 'msgId' is set - if ($msgId === null || (is_array($msgId) && count($msgId) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $msgId when calling updateTfaMessageTemplate' + $allData = [ + 'appId' => $appId, + 'msgId' => $msgId, + 'tfaUpdateMessageRequest' => $tfaUpdateMessageRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'appId' => [ + new Assert\NotBlank(), + ], + 'msgId' => [ + new Assert\NotBlank(), + ], + 'tfaUpdateMessageRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints ); - } + + $this->validateParams($allData, $validationConstraints); $resourcePath = '/2fa/2/applications/{appId}/messages/{msgId}'; $formParams = []; @@ -3751,45 +3297,45 @@ protected function updateTfaMessageTemplateRequest($appId, $msgId, $tfaUpdateMes $headerParams = []; $httpBody = ''; - - // path params if ($appId !== null) { $resourcePath = str_replace( '{' . 'appId' . '}', - ObjectSerializer::toPathValue($appId), + $this->objectSerializer->toPathValue($appId), $resourcePath ); } + // path params if ($msgId !== null) { $resourcePath = str_replace( '{' . 'msgId' . '}', - ObjectSerializer::toPathValue($msgId), + $this->objectSerializer->toPathValue($msgId), $resourcePath ); } - - $headers = $this->headerSelector->selectHeaders( - ['application/json', 'application/xml'], - ['application/json', 'application/xml'] - ); + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; // for model (json/xml) if (isset($tfaUpdateMessageRequest)) { - if ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($tfaUpdateMessageRequest)); - } else { - $httpBody = $tfaUpdateMessageRequest; - } + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($tfaUpdateMessageRequest) + : $tfaUpdateMessageRequest; } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + if ($headers['Content-Type'] === 'multipart/form-data') { - $boundary = '----'.hash('sha256', uniqid('', true)); + $boundary = '----' . hash('sha256', uniqid('', true)); $headers['Content-Type'] .= '; boundary=' . $boundary; $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + $formParamValueItems = (\is_array($formParamValue)) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { $multipartContents[] = [ 'name' => $formParamName, @@ -3797,47 +3343,45 @@ protected function updateTfaMessageTemplateRequest($appId, $msgId, $tfaUpdateMes ]; } } + // for HTTP post (form) $httpBody = new MultipartStream($multipartContents, $boundary); } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); + $httpBody = $this->objectSerializer->serialize($formParams); } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); + $httpBody = Query::build($formParams); } } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('Authorization'); - if ($apiKey !== null) { - $headers['Authorization'] = $apiKey; - } - // this endpoint requires HTTP basic authentication - if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) { - $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); - } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('Authorization'); + $apiKey = $this->config->getApiKey(); + if ($apiKey !== null) { - $headers['Authorization'] = $apiKey; - } - // this endpoint requires OAuth (access token) - if (!empty($this->config->getAccessToken())) { - $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + $headers[$this->config->getApiKeyHeader()] = $apiKey; } $defaultHeaders = []; + if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } - $headers = array_merge( + $headers = \array_merge( $defaultHeaders, $headerParams, $headers ); - $query = \GuzzleHttp\Psr7\Query::build($queryParams); + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + return new Request( 'PUT', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), @@ -3848,14 +3392,10 @@ protected function updateTfaMessageTemplateRequest($appId, $msgId, $tfaUpdateMes /** * Create response for operation 'updateTfaMessageTemplate' - * - * @param \GuzzleHttp\Psr7\Response $response - * @param string $requestUri - * - * @throws \Infobip\ApiException on non-2xx response - * @return array of \Infobip\Model\TfaApiException|\Infobip\Model\TfaApiException|\Infobip\Model\TfaMessage|null, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\TfaMessage|null */ - protected function updateTfaMessageTemplateResponse($response, $requestUri) + private function updateTfaMessageTemplateResponse(ResponseInterface $response, UriInterface $requestUri): mixed { $statusCode = $response->getStatusCode(); $responseBody = $response->getBody(); @@ -3863,67 +3403,56 @@ protected function updateTfaMessageTemplateResponse($response, $requestUri) if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( - sprintf('[%d] Error connecting to the API (%s)', $statusCode, $requestUri), + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), $statusCode, $responseHeaders, $responseBody ); } - $responseObject = null; - + $responseResult = null; - $type = '\Infobip\Model\TfaMessage'; - if ($type === '\SplFileObject') { - $content = $responseBody; //stream goes to serializer - } else { - $content = (string) $responseBody; - } - $responseObject = ObjectSerializer::deserialize($content, $type, $responseHeaders); - - return [ - $responseObject, - $statusCode, - $responseHeaders - ]; + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\TfaMessage', $responseHeaders); + return $responseResult; } /** - * Adapt given \Infobip\ApiException for operation 'updateTfaMessageTemplate' - * - * @param \Infobip\ApiException $apiException - * - * @return \Infobip\ApiException + * Adapt given ApiException for operation 'updateTfaMessageTemplate' */ - protected function updateTfaMessageTemplateApiException($apiException) + private function updateTfaMessageTemplateApiException(ApiException $apiException): ApiException { $statusCode = $apiException->getCode(); if ($statusCode >= 400 && $statusCode <= 499) { - $data = ObjectSerializer::deserialize( + $data = $this->objectSerializer->deserialize( $apiException->getResponseBody(), - '\Infobip\Model\TfaApiException', + '\Infobip\Model\ApiException', $apiException->getResponseHeaders() ); + $apiException->setResponseObject($data); + return $apiException; } if ($statusCode >= 500 && $statusCode <= 599) { - $data = ObjectSerializer::deserialize( + $data = $this->objectSerializer->deserialize( $apiException->getResponseBody(), - '\Infobip\Model\TfaApiException', + '\Infobip\Model\ApiException', $apiException->getResponseHeaders() ); + $apiException->setResponseObject($data); + return $apiException; } - - $data = ObjectSerializer::deserialize( + $data = $this->objectSerializer->deserialize( $apiException->getResponseBody(), '\Infobip\Model\TfaMessage', $apiException->getResponseHeaders() ); + $apiException->setResponseObject($data); + return $apiException; } @@ -3932,50 +3461,34 @@ protected function updateTfaMessageTemplateApiException($apiException) * * Verify phone number * - * @param string $pinId ID of the pin code that has to be verified. (required) - * @param \Infobip\Model\TfaVerifyPinRequest $tfaVerifyPinRequest tfaVerifyPinRequest (optional) - * - * @throws \Infobip\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \Infobip\Model\TfaApiException|\Infobip\Model\TfaApiException|\Infobip\Model\TfaVerifyPinResponse - */ - public function verifyTfaPhoneNumber($pinId, $tfaVerifyPinRequest = null) - { - list($response) = $this->verifyTfaPhoneNumberWithHttpInfo($pinId, $tfaVerifyPinRequest); - return $response; - } - - /** - * Operation verifyTfaPhoneNumberWithHttpInfo - * - * Verify phone number - * - * @param string $pinId ID of the pin code that has to be verified. (required) - * @param \Infobip\Model\TfaVerifyPinRequest $tfaVerifyPinRequest (optional) + * @param string $pinId ID of the pin code that has to be verified. (required) + * @param \Infobip\Model\TfaVerifyPinRequest $tfaVerifyPinRequest tfaVerifyPinRequest (required) * - * @throws \Infobip\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \Infobip\Model\TfaApiException|\Infobip\Model\TfaApiException|\Infobip\Model\TfaVerifyPinResponse, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\TfaVerifyPinResponse */ - public function verifyTfaPhoneNumberWithHttpInfo($pinId, $tfaVerifyPinRequest = null) + public function verifyTfaPhoneNumber(string $pinId, \Infobip\Model\TfaVerifyPinRequest $tfaVerifyPinRequest) { $request = $this->verifyTfaPhoneNumberRequest($pinId, $tfaVerifyPinRequest); try { - $options = $this->createHttpClientOption(); try { - $response = $this->client->send($request, $options); + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); return $this->verifyTfaPhoneNumberResponse($response, $request->getUri()); - } catch (RequestException $e) { + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null ); } - } catch (ApiException $e) { - throw $this->verifyTfaPhoneNumberApiException($e); + } catch (ApiException $exception) { + throw $this->verifyTfaPhoneNumberApiException($exception); } } @@ -3984,53 +3497,36 @@ public function verifyTfaPhoneNumberWithHttpInfo($pinId, $tfaVerifyPinRequest = * * Verify phone number * - * @param string $pinId ID of the pin code that has to be verified. (required) - * @param \Infobip\Model\TfaVerifyPinRequest $tfaVerifyPinRequest (optional) - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function verifyTfaPhoneNumberAsync($pinId, $tfaVerifyPinRequest = null) - { - return $this->verifyTfaPhoneNumberAsyncWithHttpInfo($pinId, $tfaVerifyPinRequest) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation verifyTfaPhoneNumberAsyncWithHttpInfo - * - * Verify phone number - * - * @param string $pinId ID of the pin code that has to be verified. (required) - * @param \Infobip\Model\TfaVerifyPinRequest $tfaVerifyPinRequest (optional) + * @param string $pinId ID of the pin code that has to be verified. (required) + * @param \Infobip\Model\TfaVerifyPinRequest $tfaVerifyPinRequest (required) * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface + * @throws InvalidArgumentException */ - public function verifyTfaPhoneNumberAsyncWithHttpInfo($pinId, $tfaVerifyPinRequest = null) + public function verifyTfaPhoneNumberAsync(string $pinId, \Infobip\Model\TfaVerifyPinRequest $tfaVerifyPinRequest): PromiseInterface { $request = $this->verifyTfaPhoneNumberRequest($pinId, $tfaVerifyPinRequest); - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) + return $this + ->client + ->sendAsync($request) ->then( function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); return $this->verifyTfaPhoneNumberResponse($response, $request->getUri()); }, - function ($exception) { + function (GuzzleException $exception) { $statusCode = $exception->getCode(); - $response = $exception->getResponse(); - $e = new ApiException( + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( "[{$statusCode}] {$exception->getMessage()}", $statusCode, - $response ? $response->getHeaders() : null, - $response ? (string) $response->getBody() : null + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null ); - throw $this->verifyTfaPhoneNumberApiException($e); + + throw $this->verifyTfaPhoneNumberApiException($exception); } ); } @@ -4038,20 +3534,34 @@ function ($exception) { /** * Create request for operation 'verifyTfaPhoneNumber' * - * @param string $pinId ID of the pin code that has to be verified. (required) - * @param \Infobip\Model\TfaVerifyPinRequest $tfaVerifyPinRequest (optional) + * @param string $pinId ID of the pin code that has to be verified. (required) + * @param \Infobip\Model\TfaVerifyPinRequest $tfaVerifyPinRequest (required) * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request + * @throws InvalidArgumentException */ - protected function verifyTfaPhoneNumberRequest($pinId, $tfaVerifyPinRequest = null) + private function verifyTfaPhoneNumberRequest(string $pinId, \Infobip\Model\TfaVerifyPinRequest $tfaVerifyPinRequest): Request { - // verify the required parameter 'pinId' is set - if ($pinId === null || (is_array($pinId) && count($pinId) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $pinId when calling verifyTfaPhoneNumber' + $allData = [ + 'pinId' => $pinId, + 'tfaVerifyPinRequest' => $tfaVerifyPinRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'pinId' => [ + new Assert\NotBlank(), + ], + 'tfaVerifyPinRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints ); - } + + $this->validateParams($allData, $validationConstraints); $resourcePath = '/2fa/2/pin/{pinId}/verify'; $formParams = []; @@ -4059,37 +3569,36 @@ protected function verifyTfaPhoneNumberRequest($pinId, $tfaVerifyPinRequest = nu $headerParams = []; $httpBody = ''; - - // path params if ($pinId !== null) { $resourcePath = str_replace( '{' . 'pinId' . '}', - ObjectSerializer::toPathValue($pinId), + $this->objectSerializer->toPathValue($pinId), $resourcePath ); } - - $headers = $this->headerSelector->selectHeaders( - ['application/json', 'application/xml'], - ['application/json', 'application/xml'] - ); + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; // for model (json/xml) if (isset($tfaVerifyPinRequest)) { - if ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($tfaVerifyPinRequest)); - } else { - $httpBody = $tfaVerifyPinRequest; - } + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($tfaVerifyPinRequest) + : $tfaVerifyPinRequest; } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + if ($headers['Content-Type'] === 'multipart/form-data') { - $boundary = '----'.hash('sha256', uniqid('', true)); + $boundary = '----' . hash('sha256', uniqid('', true)); $headers['Content-Type'] .= '; boundary=' . $boundary; $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + $formParamValueItems = (\is_array($formParamValue)) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { $multipartContents[] = [ 'name' => $formParamName, @@ -4097,47 +3606,45 @@ protected function verifyTfaPhoneNumberRequest($pinId, $tfaVerifyPinRequest = nu ]; } } + // for HTTP post (form) $httpBody = new MultipartStream($multipartContents, $boundary); } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); + $httpBody = $this->objectSerializer->serialize($formParams); } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); + $httpBody = Query::build($formParams); } } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('Authorization'); - if ($apiKey !== null) { - $headers['Authorization'] = $apiKey; - } - // this endpoint requires HTTP basic authentication - if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) { - $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); - } - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('Authorization'); + $apiKey = $this->config->getApiKey(); + if ($apiKey !== null) { - $headers['Authorization'] = $apiKey; - } - // this endpoint requires OAuth (access token) - if (!empty($this->config->getAccessToken())) { - $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + $headers[$this->config->getApiKeyHeader()] = $apiKey; } $defaultHeaders = []; + if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } - $headers = array_merge( + $headers = \array_merge( $defaultHeaders, $headerParams, $headers ); - $query = \GuzzleHttp\Psr7\Query::build($queryParams); + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), @@ -4148,14 +3655,10 @@ protected function verifyTfaPhoneNumberRequest($pinId, $tfaVerifyPinRequest = nu /** * Create response for operation 'verifyTfaPhoneNumber' - * - * @param \GuzzleHttp\Psr7\Response $response - * @param string $requestUri - * - * @throws \Infobip\ApiException on non-2xx response - * @return array of \Infobip\Model\TfaApiException|\Infobip\Model\TfaApiException|\Infobip\Model\TfaVerifyPinResponse|null, HTTP status code, HTTP response headers (array of strings) + * @throws ApiException on non-2xx response + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\TfaVerifyPinResponse|null */ - protected function verifyTfaPhoneNumberResponse($response, $requestUri) + private function verifyTfaPhoneNumberResponse(ResponseInterface $response, UriInterface $requestUri): mixed { $statusCode = $response->getStatusCode(); $responseBody = $response->getBody(); @@ -4163,86 +3666,56 @@ protected function verifyTfaPhoneNumberResponse($response, $requestUri) if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( - sprintf('[%d] Error connecting to the API (%s)', $statusCode, $requestUri), + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), $statusCode, $responseHeaders, $responseBody ); } - $responseObject = null; - - - $type = '\Infobip\Model\TfaVerifyPinResponse'; - if ($type === '\SplFileObject') { - $content = $responseBody; //stream goes to serializer - } else { - $content = (string) $responseBody; - } - $responseObject = ObjectSerializer::deserialize($content, $type, $responseHeaders); + $responseResult = null; - return [ - $responseObject, - $statusCode, - $responseHeaders - ]; + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\TfaVerifyPinResponse', $responseHeaders); + return $responseResult; } /** - * Adapt given \Infobip\ApiException for operation 'verifyTfaPhoneNumber' - * - * @param \Infobip\ApiException $apiException - * - * @return \Infobip\ApiException + * Adapt given ApiException for operation 'verifyTfaPhoneNumber' */ - protected function verifyTfaPhoneNumberApiException($apiException) + private function verifyTfaPhoneNumberApiException(ApiException $apiException): ApiException { $statusCode = $apiException->getCode(); if ($statusCode >= 400 && $statusCode <= 499) { - $data = ObjectSerializer::deserialize( + $data = $this->objectSerializer->deserialize( $apiException->getResponseBody(), - '\Infobip\Model\TfaApiException', + '\Infobip\Model\ApiException', $apiException->getResponseHeaders() ); + $apiException->setResponseObject($data); + return $apiException; } if ($statusCode >= 500 && $statusCode <= 599) { - $data = ObjectSerializer::deserialize( + $data = $this->objectSerializer->deserialize( $apiException->getResponseBody(), - '\Infobip\Model\TfaApiException', + '\Infobip\Model\ApiException', $apiException->getResponseHeaders() ); + $apiException->setResponseObject($data); + return $apiException; } - - $data = ObjectSerializer::deserialize( + $data = $this->objectSerializer->deserialize( $apiException->getResponseBody(), '\Infobip\Model\TfaVerifyPinResponse', $apiException->getResponseHeaders() ); - $apiException->setResponseObject($data); - return $apiException; - } - /** - * Create http client option - * - * @throws \RuntimeException on file opening failure - * @return array of http client options - */ - protected function createHttpClientOption() - { - $options = []; - if ($this->config->getDebug()) { - $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); - if (!$options[RequestOptions::DEBUG]) { - throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); - } - } + $apiException->setResponseObject($data); - return $options; + return $apiException; } } diff --git a/Infobip/Api/ViberApi.php b/Infobip/Api/ViberApi.php new file mode 100644 index 0000000..2868fd5 --- /dev/null +++ b/Infobip/Api/ViberApi.php @@ -0,0 +1,1137 @@ +config = $config; + $this->client = $client ?: new Client(); + $this->objectSerializer = $objectSerializer ?: new ObjectSerializer(); + $this->logger = $logger ?: new NullLogger(); + $this->deprecationChecker = $deprecationChecker ?: new DeprecationChecker($this->logger); + } + + /** + * Operation sendViberFileMessage + * + * Send Viber file message + * + * @param \Infobip\Model\ViberFileMessage $viberFileMessage viberFileMessage (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\ViberSingleMessageInfo|\Infobip\Model\ApiException|object|object|object + */ + public function sendViberFileMessage(\Infobip\Model\ViberFileMessage $viberFileMessage) + { + $request = $this->sendViberFileMessageRequest($viberFileMessage); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->sendViberFileMessageResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->sendViberFileMessageApiException($exception); + } + } + + /** + * Operation sendViberFileMessageAsync + * + * Send Viber file message + * + * @param \Infobip\Model\ViberFileMessage $viberFileMessage (required) + * + * @throws InvalidArgumentException + */ + public function sendViberFileMessageAsync(\Infobip\Model\ViberFileMessage $viberFileMessage): PromiseInterface + { + $request = $this->sendViberFileMessageRequest($viberFileMessage); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->sendViberFileMessageResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->sendViberFileMessageApiException($exception); + } + ); + } + + /** + * Create request for operation 'sendViberFileMessage' + * + * @param \Infobip\Model\ViberFileMessage $viberFileMessage (required) + * + * @throws InvalidArgumentException + */ + private function sendViberFileMessageRequest(\Infobip\Model\ViberFileMessage $viberFileMessage): Request + { + $allData = [ + 'viberFileMessage' => $viberFileMessage, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'viberFileMessage' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/viber/1/message/file'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($viberFileMessage)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($viberFileMessage) + : $viberFileMessage; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'sendViberFileMessage' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\ViberSingleMessageInfo|\Infobip\Model\ApiException|object|object|object|null + */ + private function sendViberFileMessageResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\ViberSingleMessageInfo', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'sendViberFileMessage' + */ + private function sendViberFileMessageApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + 'object', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + 'object', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + 'object', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation sendViberImageMessage + * + * Send Viber image message + * + * @param \Infobip\Model\ViberImageMessage $viberImageMessage viberImageMessage (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\ViberSingleMessageInfo|\Infobip\Model\ApiException|object|object|object + */ + public function sendViberImageMessage(\Infobip\Model\ViberImageMessage $viberImageMessage) + { + $request = $this->sendViberImageMessageRequest($viberImageMessage); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->sendViberImageMessageResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->sendViberImageMessageApiException($exception); + } + } + + /** + * Operation sendViberImageMessageAsync + * + * Send Viber image message + * + * @param \Infobip\Model\ViberImageMessage $viberImageMessage (required) + * + * @throws InvalidArgumentException + */ + public function sendViberImageMessageAsync(\Infobip\Model\ViberImageMessage $viberImageMessage): PromiseInterface + { + $request = $this->sendViberImageMessageRequest($viberImageMessage); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->sendViberImageMessageResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->sendViberImageMessageApiException($exception); + } + ); + } + + /** + * Create request for operation 'sendViberImageMessage' + * + * @param \Infobip\Model\ViberImageMessage $viberImageMessage (required) + * + * @throws InvalidArgumentException + */ + private function sendViberImageMessageRequest(\Infobip\Model\ViberImageMessage $viberImageMessage): Request + { + $allData = [ + 'viberImageMessage' => $viberImageMessage, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'viberImageMessage' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/viber/1/message/image'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($viberImageMessage)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($viberImageMessage) + : $viberImageMessage; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'sendViberImageMessage' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\ViberSingleMessageInfo|\Infobip\Model\ApiException|object|object|object|null + */ + private function sendViberImageMessageResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\ViberSingleMessageInfo', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'sendViberImageMessage' + */ + private function sendViberImageMessageApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + 'object', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + 'object', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + 'object', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation sendViberTextMessage + * + * Send Viber text message(s) + * + * @param \Infobip\Model\ViberBulkTextMessage $viberBulkTextMessage viberBulkTextMessage (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\ViberBulkMessageInfo|\Infobip\Model\ApiException|object|object|object + */ + public function sendViberTextMessage(\Infobip\Model\ViberBulkTextMessage $viberBulkTextMessage) + { + $request = $this->sendViberTextMessageRequest($viberBulkTextMessage); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->sendViberTextMessageResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->sendViberTextMessageApiException($exception); + } + } + + /** + * Operation sendViberTextMessageAsync + * + * Send Viber text message(s) + * + * @param \Infobip\Model\ViberBulkTextMessage $viberBulkTextMessage (required) + * + * @throws InvalidArgumentException + */ + public function sendViberTextMessageAsync(\Infobip\Model\ViberBulkTextMessage $viberBulkTextMessage): PromiseInterface + { + $request = $this->sendViberTextMessageRequest($viberBulkTextMessage); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->sendViberTextMessageResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->sendViberTextMessageApiException($exception); + } + ); + } + + /** + * Create request for operation 'sendViberTextMessage' + * + * @param \Infobip\Model\ViberBulkTextMessage $viberBulkTextMessage (required) + * + * @throws InvalidArgumentException + */ + private function sendViberTextMessageRequest(\Infobip\Model\ViberBulkTextMessage $viberBulkTextMessage): Request + { + $allData = [ + 'viberBulkTextMessage' => $viberBulkTextMessage, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'viberBulkTextMessage' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/viber/1/message/text'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($viberBulkTextMessage)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($viberBulkTextMessage) + : $viberBulkTextMessage; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'sendViberTextMessage' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\ViberBulkMessageInfo|\Infobip\Model\ApiException|object|object|object|null + */ + private function sendViberTextMessageResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\ViberBulkMessageInfo', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'sendViberTextMessage' + */ + private function sendViberTextMessageApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + 'object', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + 'object', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + 'object', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation sendViberVideoMessage + * + * Send Viber video message + * + * @param \Infobip\Model\ViberVideoMessage $viberVideoMessage viberVideoMessage (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\ViberSingleMessageInfo|\Infobip\Model\ApiException|object|object|object + */ + public function sendViberVideoMessage(\Infobip\Model\ViberVideoMessage $viberVideoMessage) + { + $request = $this->sendViberVideoMessageRequest($viberVideoMessage); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->sendViberVideoMessageResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->sendViberVideoMessageApiException($exception); + } + } + + /** + * Operation sendViberVideoMessageAsync + * + * Send Viber video message + * + * @param \Infobip\Model\ViberVideoMessage $viberVideoMessage (required) + * + * @throws InvalidArgumentException + */ + public function sendViberVideoMessageAsync(\Infobip\Model\ViberVideoMessage $viberVideoMessage): PromiseInterface + { + $request = $this->sendViberVideoMessageRequest($viberVideoMessage); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->sendViberVideoMessageResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->sendViberVideoMessageApiException($exception); + } + ); + } + + /** + * Create request for operation 'sendViberVideoMessage' + * + * @param \Infobip\Model\ViberVideoMessage $viberVideoMessage (required) + * + * @throws InvalidArgumentException + */ + private function sendViberVideoMessageRequest(\Infobip\Model\ViberVideoMessage $viberVideoMessage): Request + { + $allData = [ + 'viberVideoMessage' => $viberVideoMessage, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'viberVideoMessage' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/viber/1/message/video'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($viberVideoMessage)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($viberVideoMessage) + : $viberVideoMessage; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'sendViberVideoMessage' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\ViberSingleMessageInfo|\Infobip\Model\ApiException|object|object|object|null + */ + private function sendViberVideoMessageResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\ViberSingleMessageInfo', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'sendViberVideoMessage' + */ + private function sendViberVideoMessageApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + 'object', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + 'object', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 500) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + 'object', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } +} diff --git a/Infobip/Api/VoiceApi.php b/Infobip/Api/VoiceApi.php new file mode 100644 index 0000000..1a90df2 --- /dev/null +++ b/Infobip/Api/VoiceApi.php @@ -0,0 +1,2088 @@ +config = $config; + $this->client = $client ?: new Client(); + $this->objectSerializer = $objectSerializer ?: new ObjectSerializer(); + $this->logger = $logger ?: new NullLogger(); + $this->deprecationChecker = $deprecationChecker ?: new DeprecationChecker($this->logger); + } + + /** + * Operation getSentBulks + * + * Get sent bulks + * + * @param string $bulkId Unique ID of the bulk. (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\CallsBulkResponse + */ + public function getSentBulks(string $bulkId) + { + $request = $this->getSentBulksRequest($bulkId); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->getSentBulksResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->getSentBulksApiException($exception); + } + } + + /** + * Operation getSentBulksAsync + * + * Get sent bulks + * + * @param string $bulkId Unique ID of the bulk. (required) + * + * @throws InvalidArgumentException + */ + public function getSentBulksAsync(string $bulkId): PromiseInterface + { + $request = $this->getSentBulksRequest($bulkId); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->getSentBulksResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->getSentBulksApiException($exception); + } + ); + } + + /** + * Create request for operation 'getSentBulks' + * + * @param string $bulkId Unique ID of the bulk. (required) + * + * @throws InvalidArgumentException + */ + private function getSentBulksRequest(string $bulkId): Request + { + $allData = [ + 'bulkId' => $bulkId, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'bulkId' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/tts/3/bulks'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // query params + if ($bulkId !== null) { + $queryParams['bulkId'] = $bulkId; + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'getSentBulks' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\CallsBulkResponse|null + */ + private function getSentBulksResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsBulkResponse', $responseHeaders); + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'getSentBulks' + */ + private function getSentBulksApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode >= 400 && $statusCode <= 499) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode >= 500 && $statusCode <= 599) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\CallsBulkResponse', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + /** + * Operation getSentBulksStatus + * + * Get sent bulk's status + * + * @param string $bulkId Unique ID of the bulk. (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\CallsBulkStatusResponse + */ + public function getSentBulksStatus(string $bulkId) + { + $request = $this->getSentBulksStatusRequest($bulkId); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->getSentBulksStatusResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->getSentBulksStatusApiException($exception); + } + } + + /** + * Operation getSentBulksStatusAsync + * + * Get sent bulk's status + * + * @param string $bulkId Unique ID of the bulk. (required) + * + * @throws InvalidArgumentException + */ + public function getSentBulksStatusAsync(string $bulkId): PromiseInterface + { + $request = $this->getSentBulksStatusRequest($bulkId); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->getSentBulksStatusResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->getSentBulksStatusApiException($exception); + } + ); + } + + /** + * Create request for operation 'getSentBulksStatus' + * + * @param string $bulkId Unique ID of the bulk. (required) + * + * @throws InvalidArgumentException + */ + private function getSentBulksStatusRequest(string $bulkId): Request + { + $allData = [ + 'bulkId' => $bulkId, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'bulkId' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/tts/3/bulks/status'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // query params + if ($bulkId !== null) { + $queryParams['bulkId'] = $bulkId; + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'getSentBulksStatus' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\CallsBulkStatusResponse|null + */ + private function getSentBulksStatusResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsBulkStatusResponse', $responseHeaders); + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'getSentBulksStatus' + */ + private function getSentBulksStatusApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode >= 400 && $statusCode <= 499) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode >= 500 && $statusCode <= 599) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\CallsBulkStatusResponse', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + /** + * Operation getVoices + * + * Get Voices + * + * @param string $language Represents the language abbreviation. (e.g. `en`). You can find the list of supported languages in corresponding section for sending voice message. (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\CallsGetVoicesResponse + */ + public function getVoices(string $language) + { + $request = $this->getVoicesRequest($language); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->getVoicesResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->getVoicesApiException($exception); + } + } + + /** + * Operation getVoicesAsync + * + * Get Voices + * + * @param string $language Represents the language abbreviation. (e.g. `en`). You can find the list of supported languages in corresponding section for sending voice message. (required) + * + * @throws InvalidArgumentException + */ + public function getVoicesAsync(string $language): PromiseInterface + { + $request = $this->getVoicesRequest($language); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->getVoicesResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->getVoicesApiException($exception); + } + ); + } + + /** + * Create request for operation 'getVoices' + * + * @param string $language Represents the language abbreviation. (e.g. `en`). You can find the list of supported languages in corresponding section for sending voice message. (required) + * + * @throws InvalidArgumentException + */ + private function getVoicesRequest(string $language): Request + { + $allData = [ + 'language' => $language, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'language' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/tts/3/voices/{language}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($language !== null) { + $resourcePath = str_replace( + '{' . 'language' . '}', + $this->objectSerializer->toPathValue($language), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'getVoices' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\CallsGetVoicesResponse|null + */ + private function getVoicesResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsGetVoicesResponse', $responseHeaders); + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'getVoices' + */ + private function getVoicesApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode >= 400 && $statusCode <= 499) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode >= 500 && $statusCode <= 599) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\CallsGetVoicesResponse', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + /** + * Operation manageSentBulksStatus + * + * Manage sent bulk's status + * + * @param string $bulkId Unique ID of the bulk. (required) + * @param \Infobip\Model\CallsUpdateStatusRequest $callsUpdateStatusRequest callsUpdateStatusRequest (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\CallsBulkStatusResponse + */ + public function manageSentBulksStatus(string $bulkId, \Infobip\Model\CallsUpdateStatusRequest $callsUpdateStatusRequest) + { + $request = $this->manageSentBulksStatusRequest($bulkId, $callsUpdateStatusRequest); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->manageSentBulksStatusResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->manageSentBulksStatusApiException($exception); + } + } + + /** + * Operation manageSentBulksStatusAsync + * + * Manage sent bulk's status + * + * @param string $bulkId Unique ID of the bulk. (required) + * @param \Infobip\Model\CallsUpdateStatusRequest $callsUpdateStatusRequest (required) + * + * @throws InvalidArgumentException + */ + public function manageSentBulksStatusAsync(string $bulkId, \Infobip\Model\CallsUpdateStatusRequest $callsUpdateStatusRequest): PromiseInterface + { + $request = $this->manageSentBulksStatusRequest($bulkId, $callsUpdateStatusRequest); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->manageSentBulksStatusResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->manageSentBulksStatusApiException($exception); + } + ); + } + + /** + * Create request for operation 'manageSentBulksStatus' + * + * @param string $bulkId Unique ID of the bulk. (required) + * @param \Infobip\Model\CallsUpdateStatusRequest $callsUpdateStatusRequest (required) + * + * @throws InvalidArgumentException + */ + private function manageSentBulksStatusRequest(string $bulkId, \Infobip\Model\CallsUpdateStatusRequest $callsUpdateStatusRequest): Request + { + $allData = [ + 'bulkId' => $bulkId, + 'callsUpdateStatusRequest' => $callsUpdateStatusRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'bulkId' => [ + new Assert\NotBlank(), + ], + 'callsUpdateStatusRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/tts/3/bulks/status'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // query params + if ($bulkId !== null) { + $queryParams['bulkId'] = $bulkId; + } + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($callsUpdateStatusRequest)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($callsUpdateStatusRequest) + : $callsUpdateStatusRequest; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'PUT', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'manageSentBulksStatus' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\CallsBulkStatusResponse|null + */ + private function manageSentBulksStatusResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsBulkStatusResponse', $responseHeaders); + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'manageSentBulksStatus' + */ + private function manageSentBulksStatusApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode >= 400 && $statusCode <= 499) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode >= 500 && $statusCode <= 599) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\CallsBulkStatusResponse', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + /** + * Operation rescheduleSentBulk + * + * Reschedule sent bulk + * + * @param string $bulkId Unique ID of the bulk. (required) + * @param \Infobip\Model\CallsBulkRequest $callsBulkRequest callsBulkRequest (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\CallsBulkResponse + */ + public function rescheduleSentBulk(string $bulkId, \Infobip\Model\CallsBulkRequest $callsBulkRequest) + { + $request = $this->rescheduleSentBulkRequest($bulkId, $callsBulkRequest); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->rescheduleSentBulkResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->rescheduleSentBulkApiException($exception); + } + } + + /** + * Operation rescheduleSentBulkAsync + * + * Reschedule sent bulk + * + * @param string $bulkId Unique ID of the bulk. (required) + * @param \Infobip\Model\CallsBulkRequest $callsBulkRequest (required) + * + * @throws InvalidArgumentException + */ + public function rescheduleSentBulkAsync(string $bulkId, \Infobip\Model\CallsBulkRequest $callsBulkRequest): PromiseInterface + { + $request = $this->rescheduleSentBulkRequest($bulkId, $callsBulkRequest); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->rescheduleSentBulkResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->rescheduleSentBulkApiException($exception); + } + ); + } + + /** + * Create request for operation 'rescheduleSentBulk' + * + * @param string $bulkId Unique ID of the bulk. (required) + * @param \Infobip\Model\CallsBulkRequest $callsBulkRequest (required) + * + * @throws InvalidArgumentException + */ + private function rescheduleSentBulkRequest(string $bulkId, \Infobip\Model\CallsBulkRequest $callsBulkRequest): Request + { + $allData = [ + 'bulkId' => $bulkId, + 'callsBulkRequest' => $callsBulkRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'bulkId' => [ + new Assert\NotBlank(), + ], + 'callsBulkRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/tts/3/bulks'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // query params + if ($bulkId !== null) { + $queryParams['bulkId'] = $bulkId; + } + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($callsBulkRequest)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($callsBulkRequest) + : $callsBulkRequest; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'PUT', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'rescheduleSentBulk' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\CallsBulkResponse|null + */ + private function rescheduleSentBulkResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsBulkResponse', $responseHeaders); + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'rescheduleSentBulk' + */ + private function rescheduleSentBulkApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode >= 400 && $statusCode <= 499) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode >= 500 && $statusCode <= 599) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\CallsBulkResponse', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + /** + * Operation sendAdvancedVoiceTts + * + * Send advanced voice message + * + * @param \Infobip\Model\CallsAdvancedBody $callsAdvancedBody callsAdvancedBody (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\CallsVoiceResponse + */ + public function sendAdvancedVoiceTts(\Infobip\Model\CallsAdvancedBody $callsAdvancedBody) + { + $request = $this->sendAdvancedVoiceTtsRequest($callsAdvancedBody); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->sendAdvancedVoiceTtsResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->sendAdvancedVoiceTtsApiException($exception); + } + } + + /** + * Operation sendAdvancedVoiceTtsAsync + * + * Send advanced voice message + * + * @param \Infobip\Model\CallsAdvancedBody $callsAdvancedBody (required) + * + * @throws InvalidArgumentException + */ + public function sendAdvancedVoiceTtsAsync(\Infobip\Model\CallsAdvancedBody $callsAdvancedBody): PromiseInterface + { + $request = $this->sendAdvancedVoiceTtsRequest($callsAdvancedBody); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->sendAdvancedVoiceTtsResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->sendAdvancedVoiceTtsApiException($exception); + } + ); + } + + /** + * Create request for operation 'sendAdvancedVoiceTts' + * + * @param \Infobip\Model\CallsAdvancedBody $callsAdvancedBody (required) + * + * @throws InvalidArgumentException + */ + private function sendAdvancedVoiceTtsRequest(\Infobip\Model\CallsAdvancedBody $callsAdvancedBody): Request + { + $allData = [ + 'callsAdvancedBody' => $callsAdvancedBody, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'callsAdvancedBody' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/tts/3/advanced'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($callsAdvancedBody)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($callsAdvancedBody) + : $callsAdvancedBody; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'sendAdvancedVoiceTts' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\CallsVoiceResponse|null + */ + private function sendAdvancedVoiceTtsResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsVoiceResponse', $responseHeaders); + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'sendAdvancedVoiceTts' + */ + private function sendAdvancedVoiceTtsApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode >= 400 && $statusCode <= 499) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode >= 500 && $statusCode <= 599) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\CallsVoiceResponse', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + /** + * Operation sendMultipleVoiceTts + * + * Send multiple voice messages + * + * @param \Infobip\Model\CallsMultiBody $callsMultiBody callsMultiBody (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\CallsVoiceResponse + */ + public function sendMultipleVoiceTts(\Infobip\Model\CallsMultiBody $callsMultiBody) + { + $request = $this->sendMultipleVoiceTtsRequest($callsMultiBody); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->sendMultipleVoiceTtsResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->sendMultipleVoiceTtsApiException($exception); + } + } + + /** + * Operation sendMultipleVoiceTtsAsync + * + * Send multiple voice messages + * + * @param \Infobip\Model\CallsMultiBody $callsMultiBody (required) + * + * @throws InvalidArgumentException + */ + public function sendMultipleVoiceTtsAsync(\Infobip\Model\CallsMultiBody $callsMultiBody): PromiseInterface + { + $request = $this->sendMultipleVoiceTtsRequest($callsMultiBody); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->sendMultipleVoiceTtsResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->sendMultipleVoiceTtsApiException($exception); + } + ); + } + + /** + * Create request for operation 'sendMultipleVoiceTts' + * + * @param \Infobip\Model\CallsMultiBody $callsMultiBody (required) + * + * @throws InvalidArgumentException + */ + private function sendMultipleVoiceTtsRequest(\Infobip\Model\CallsMultiBody $callsMultiBody): Request + { + $allData = [ + 'callsMultiBody' => $callsMultiBody, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'callsMultiBody' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/tts/3/multi'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($callsMultiBody)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($callsMultiBody) + : $callsMultiBody; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'sendMultipleVoiceTts' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\CallsVoiceResponse|null + */ + private function sendMultipleVoiceTtsResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsVoiceResponse', $responseHeaders); + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'sendMultipleVoiceTts' + */ + private function sendMultipleVoiceTtsApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode >= 400 && $statusCode <= 499) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode >= 500 && $statusCode <= 599) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\CallsVoiceResponse', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + /** + * Operation sendSingleVoiceTts + * + * Send single voice message + * + * @param \Infobip\Model\CallsSingleBody $callsSingleBody callsSingleBody (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\CallsVoiceResponse + */ + public function sendSingleVoiceTts(\Infobip\Model\CallsSingleBody $callsSingleBody) + { + $request = $this->sendSingleVoiceTtsRequest($callsSingleBody); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->sendSingleVoiceTtsResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->sendSingleVoiceTtsApiException($exception); + } + } + + /** + * Operation sendSingleVoiceTtsAsync + * + * Send single voice message + * + * @param \Infobip\Model\CallsSingleBody $callsSingleBody (required) + * + * @throws InvalidArgumentException + */ + public function sendSingleVoiceTtsAsync(\Infobip\Model\CallsSingleBody $callsSingleBody): PromiseInterface + { + $request = $this->sendSingleVoiceTtsRequest($callsSingleBody); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->sendSingleVoiceTtsResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->sendSingleVoiceTtsApiException($exception); + } + ); + } + + /** + * Create request for operation 'sendSingleVoiceTts' + * + * @param \Infobip\Model\CallsSingleBody $callsSingleBody (required) + * + * @throws InvalidArgumentException + */ + private function sendSingleVoiceTtsRequest(\Infobip\Model\CallsSingleBody $callsSingleBody): Request + { + $allData = [ + 'callsSingleBody' => $callsSingleBody, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'callsSingleBody' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/tts/3/single'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($callsSingleBody)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($callsSingleBody) + : $callsSingleBody; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'sendSingleVoiceTts' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\CallsVoiceResponse|null + */ + private function sendSingleVoiceTtsResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\CallsVoiceResponse', $responseHeaders); + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'sendSingleVoiceTts' + */ + private function sendSingleVoiceTtsApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode >= 400 && $statusCode <= 499) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode >= 500 && $statusCode <= 599) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\CallsVoiceResponse', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } +} diff --git a/Infobip/Api/WebRtcApi.php b/Infobip/Api/WebRtcApi.php new file mode 100644 index 0000000..fcce95e --- /dev/null +++ b/Infobip/Api/WebRtcApi.php @@ -0,0 +1,1572 @@ +config = $config; + $this->client = $client ?: new Client(); + $this->objectSerializer = $objectSerializer ?: new ObjectSerializer(); + $this->logger = $logger ?: new NullLogger(); + $this->deprecationChecker = $deprecationChecker ?: new DeprecationChecker($this->logger); + } + + /** + * Operation deletePushConfiguration + * + * Delete WebRTC push configuration + * + * @param string $id Id of the WebRTC push configuration to delete. (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return void + */ + public function deletePushConfiguration(string $id) + { + $request = $this->deletePushConfigurationRequest($id); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->deletePushConfigurationResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->deletePushConfigurationApiException($exception); + } + } + + /** + * Operation deletePushConfigurationAsync + * + * Delete WebRTC push configuration + * + * @param string $id Id of the WebRTC push configuration to delete. (required) + * + * @throws InvalidArgumentException + */ + public function deletePushConfigurationAsync(string $id): PromiseInterface + { + $request = $this->deletePushConfigurationRequest($id); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->deletePushConfigurationResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->deletePushConfigurationApiException($exception); + } + ); + } + + /** + * Create request for operation 'deletePushConfiguration' + * + * @param string $id Id of the WebRTC push configuration to delete. (required) + * + * @throws InvalidArgumentException + */ + private function deletePushConfigurationRequest(string $id): Request + { + $allData = [ + 'id' => $id, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'id' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/webrtc/1/webrtc-push-config/{id}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($id !== null) { + $resourcePath = str_replace( + '{' . 'id' . '}', + $this->objectSerializer->toPathValue($id), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'DELETE', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'deletePushConfiguration' + * @throws ApiException on non-2xx response + * @return null + */ + private function deletePushConfigurationResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'deletePushConfiguration' + */ + private function deletePushConfigurationApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation generateWebRtcToken + * + * Generate WebRTC Token + * + * @param \Infobip\Model\WebRtcTokenRequestModel $webRtcTokenRequestModel webRtcTokenRequestModel (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\WebRtcTokenResponseModel + */ + public function generateWebRtcToken(\Infobip\Model\WebRtcTokenRequestModel $webRtcTokenRequestModel) + { + $request = $this->generateWebRtcTokenRequest($webRtcTokenRequestModel); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->generateWebRtcTokenResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->generateWebRtcTokenApiException($exception); + } + } + + /** + * Operation generateWebRtcTokenAsync + * + * Generate WebRTC Token + * + * @param \Infobip\Model\WebRtcTokenRequestModel $webRtcTokenRequestModel (required) + * + * @throws InvalidArgumentException + */ + public function generateWebRtcTokenAsync(\Infobip\Model\WebRtcTokenRequestModel $webRtcTokenRequestModel): PromiseInterface + { + $request = $this->generateWebRtcTokenRequest($webRtcTokenRequestModel); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->generateWebRtcTokenResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->generateWebRtcTokenApiException($exception); + } + ); + } + + /** + * Create request for operation 'generateWebRtcToken' + * + * @param \Infobip\Model\WebRtcTokenRequestModel $webRtcTokenRequestModel (required) + * + * @throws InvalidArgumentException + */ + private function generateWebRtcTokenRequest(\Infobip\Model\WebRtcTokenRequestModel $webRtcTokenRequestModel): Request + { + $allData = [ + 'webRtcTokenRequestModel' => $webRtcTokenRequestModel, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'webRtcTokenRequestModel' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/webrtc/1/token'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($webRtcTokenRequestModel)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($webRtcTokenRequestModel) + : $webRtcTokenRequestModel; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'generateWebRtcToken' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\WebRtcTokenResponseModel|null + */ + private function generateWebRtcTokenResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\WebRtcTokenResponseModel', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'generateWebRtcToken' + */ + private function generateWebRtcTokenApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + + return $apiException; + } + + /** + * Operation getPushConfiguration + * + * Get WebRTC push configuration + * + * @param string $id Id of the WebRTC push configuration to get. (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\WebRtcPushConfigurationResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function getPushConfiguration(string $id) + { + $request = $this->getPushConfigurationRequest($id); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->getPushConfigurationResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->getPushConfigurationApiException($exception); + } + } + + /** + * Operation getPushConfigurationAsync + * + * Get WebRTC push configuration + * + * @param string $id Id of the WebRTC push configuration to get. (required) + * + * @throws InvalidArgumentException + */ + public function getPushConfigurationAsync(string $id): PromiseInterface + { + $request = $this->getPushConfigurationRequest($id); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->getPushConfigurationResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->getPushConfigurationApiException($exception); + } + ); + } + + /** + * Create request for operation 'getPushConfiguration' + * + * @param string $id Id of the WebRTC push configuration to get. (required) + * + * @throws InvalidArgumentException + */ + private function getPushConfigurationRequest(string $id): Request + { + $allData = [ + 'id' => $id, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'id' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/webrtc/1/webrtc-push-config/{id}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($id !== null) { + $resourcePath = str_replace( + '{' . 'id' . '}', + $this->objectSerializer->toPathValue($id), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'getPushConfiguration' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\WebRtcPushConfigurationResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function getPushConfigurationResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\WebRtcPushConfigurationResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'getPushConfiguration' + */ + private function getPushConfigurationApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation getPushConfigurations + * + * Get WebRTC push configurations + * + * @param int $page Results page to retrieve (0..N). (required) + * @param int $size Number of records per page. (required) + * @param null|string $applicationId Id of the application to associate the push configuration with. (optional) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\WebRtcPushConfigurationPageResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function getPushConfigurations(int $page, int $size, ?string $applicationId = null) + { + $request = $this->getPushConfigurationsRequest($page, $size, $applicationId); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->getPushConfigurationsResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->getPushConfigurationsApiException($exception); + } + } + + /** + * Operation getPushConfigurationsAsync + * + * Get WebRTC push configurations + * + * @param int $page Results page to retrieve (0..N). (required) + * @param int $size Number of records per page. (required) + * @param null|string $applicationId Id of the application to associate the push configuration with. (optional) + * + * @throws InvalidArgumentException + */ + public function getPushConfigurationsAsync(int $page, int $size, ?string $applicationId = null): PromiseInterface + { + $request = $this->getPushConfigurationsRequest($page, $size, $applicationId); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->getPushConfigurationsResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->getPushConfigurationsApiException($exception); + } + ); + } + + /** + * Create request for operation 'getPushConfigurations' + * + * @param int $page Results page to retrieve (0..N). (required) + * @param int $size Number of records per page. (required) + * @param null|string $applicationId Id of the application to associate the push configuration with. (optional) + * + * @throws InvalidArgumentException + */ + private function getPushConfigurationsRequest(int $page, int $size, ?string $applicationId = null): Request + { + $allData = [ + 'page' => $page, + 'size' => $size, + 'applicationId' => $applicationId, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'page' => [ + new Assert\NotBlank(), + new Assert\GreaterThan(0), + ], + 'size' => [ + new Assert\NotBlank(), + new Assert\LessThan(100), + new Assert\GreaterThan(1), + ], + 'applicationId' => [ + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/webrtc/1/webrtc-push-config'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // query params + if ($applicationId !== null) { + $queryParams['applicationId'] = $applicationId; + } + + // query params + if ($page !== null) { + $queryParams['page'] = $page; + } + + // query params + if ($size !== null) { + $queryParams['size'] = $size; + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'getPushConfigurations' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\WebRtcPushConfigurationPageResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function getPushConfigurationsResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\WebRtcPushConfigurationPageResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'getPushConfigurations' + */ + private function getPushConfigurationsApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation savePushConfiguration + * + * Create WebRTC push configuration + * + * @param \Infobip\Model\WebRtcPushConfigurationRequest $webRtcPushConfigurationRequest webRtcPushConfigurationRequest (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\WebRtcPushConfigurationResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function savePushConfiguration(\Infobip\Model\WebRtcPushConfigurationRequest $webRtcPushConfigurationRequest) + { + $request = $this->savePushConfigurationRequest($webRtcPushConfigurationRequest); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->savePushConfigurationResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->savePushConfigurationApiException($exception); + } + } + + /** + * Operation savePushConfigurationAsync + * + * Create WebRTC push configuration + * + * @param \Infobip\Model\WebRtcPushConfigurationRequest $webRtcPushConfigurationRequest (required) + * + * @throws InvalidArgumentException + */ + public function savePushConfigurationAsync(\Infobip\Model\WebRtcPushConfigurationRequest $webRtcPushConfigurationRequest): PromiseInterface + { + $request = $this->savePushConfigurationRequest($webRtcPushConfigurationRequest); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->savePushConfigurationResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->savePushConfigurationApiException($exception); + } + ); + } + + /** + * Create request for operation 'savePushConfiguration' + * + * @param \Infobip\Model\WebRtcPushConfigurationRequest $webRtcPushConfigurationRequest (required) + * + * @throws InvalidArgumentException + */ + private function savePushConfigurationRequest(\Infobip\Model\WebRtcPushConfigurationRequest $webRtcPushConfigurationRequest): Request + { + $allData = [ + 'webRtcPushConfigurationRequest' => $webRtcPushConfigurationRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'webRtcPushConfigurationRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/webrtc/1/webrtc-push-config'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($webRtcPushConfigurationRequest)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($webRtcPushConfigurationRequest) + : $webRtcPushConfigurationRequest; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'savePushConfiguration' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\WebRtcPushConfigurationResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function savePushConfigurationResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\WebRtcPushConfigurationResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'savePushConfiguration' + */ + private function savePushConfigurationApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation updatePushConfiguration + * + * Update WebRTC push configuration + * + * @param string $id Id of the WebRTC push configuration to update. (required) + * @param \Infobip\Model\WebRtcPushConfigurationRequest $webRtcPushConfigurationRequest webRtcPushConfigurationRequest (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\WebRtcPushConfigurationResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function updatePushConfiguration(string $id, \Infobip\Model\WebRtcPushConfigurationRequest $webRtcPushConfigurationRequest) + { + $request = $this->updatePushConfigurationRequest($id, $webRtcPushConfigurationRequest); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->updatePushConfigurationResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->updatePushConfigurationApiException($exception); + } + } + + /** + * Operation updatePushConfigurationAsync + * + * Update WebRTC push configuration + * + * @param string $id Id of the WebRTC push configuration to update. (required) + * @param \Infobip\Model\WebRtcPushConfigurationRequest $webRtcPushConfigurationRequest (required) + * + * @throws InvalidArgumentException + */ + public function updatePushConfigurationAsync(string $id, \Infobip\Model\WebRtcPushConfigurationRequest $webRtcPushConfigurationRequest): PromiseInterface + { + $request = $this->updatePushConfigurationRequest($id, $webRtcPushConfigurationRequest); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->updatePushConfigurationResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->updatePushConfigurationApiException($exception); + } + ); + } + + /** + * Create request for operation 'updatePushConfiguration' + * + * @param string $id Id of the WebRTC push configuration to update. (required) + * @param \Infobip\Model\WebRtcPushConfigurationRequest $webRtcPushConfigurationRequest (required) + * + * @throws InvalidArgumentException + */ + private function updatePushConfigurationRequest(string $id, \Infobip\Model\WebRtcPushConfigurationRequest $webRtcPushConfigurationRequest): Request + { + $allData = [ + 'id' => $id, + 'webRtcPushConfigurationRequest' => $webRtcPushConfigurationRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'id' => [ + new Assert\NotBlank(), + ], + 'webRtcPushConfigurationRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/webrtc/1/webrtc-push-config/{id}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($id !== null) { + $resourcePath = str_replace( + '{' . 'id' . '}', + $this->objectSerializer->toPathValue($id), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($webRtcPushConfigurationRequest)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($webRtcPushConfigurationRequest) + : $webRtcPushConfigurationRequest; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'PUT', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'updatePushConfiguration' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\WebRtcPushConfigurationResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function updatePushConfigurationResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\WebRtcPushConfigurationResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'updatePushConfiguration' + */ + private function updatePushConfigurationApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } +} diff --git a/Infobip/Api/WhatsAppApi.php b/Infobip/Api/WhatsAppApi.php new file mode 100644 index 0000000..4156641 --- /dev/null +++ b/Infobip/Api/WhatsAppApi.php @@ -0,0 +1,5685 @@ +config = $config; + $this->client = $client ?: new Client(); + $this->objectSerializer = $objectSerializer ?: new ObjectSerializer(); + $this->logger = $logger ?: new NullLogger(); + $this->deprecationChecker = $deprecationChecker ?: new DeprecationChecker($this->logger); + } + + /** + * Operation confirmWhatsAppIdentity + * + * Confirm identity + * + * @param string $sender Registered WhatsApp sender number. Must be in international format. (required) + * @param string $userNumber End user's number. Must be in international format. (required) + * @param \Infobip\Model\WhatsAppIdentityConfirmation $whatsAppIdentityConfirmation whatsAppIdentityConfirmation (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return void + */ + public function confirmWhatsAppIdentity(string $sender, string $userNumber, \Infobip\Model\WhatsAppIdentityConfirmation $whatsAppIdentityConfirmation) + { + $request = $this->confirmWhatsAppIdentityRequest($sender, $userNumber, $whatsAppIdentityConfirmation); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->confirmWhatsAppIdentityResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->confirmWhatsAppIdentityApiException($exception); + } + } + + /** + * Operation confirmWhatsAppIdentityAsync + * + * Confirm identity + * + * @param string $sender Registered WhatsApp sender number. Must be in international format. (required) + * @param string $userNumber End user's number. Must be in international format. (required) + * @param \Infobip\Model\WhatsAppIdentityConfirmation $whatsAppIdentityConfirmation (required) + * + * @throws InvalidArgumentException + */ + public function confirmWhatsAppIdentityAsync(string $sender, string $userNumber, \Infobip\Model\WhatsAppIdentityConfirmation $whatsAppIdentityConfirmation): PromiseInterface + { + $request = $this->confirmWhatsAppIdentityRequest($sender, $userNumber, $whatsAppIdentityConfirmation); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->confirmWhatsAppIdentityResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->confirmWhatsAppIdentityApiException($exception); + } + ); + } + + /** + * Create request for operation 'confirmWhatsAppIdentity' + * + * @param string $sender Registered WhatsApp sender number. Must be in international format. (required) + * @param string $userNumber End user's number. Must be in international format. (required) + * @param \Infobip\Model\WhatsAppIdentityConfirmation $whatsAppIdentityConfirmation (required) + * + * @throws InvalidArgumentException + */ + private function confirmWhatsAppIdentityRequest(string $sender, string $userNumber, \Infobip\Model\WhatsAppIdentityConfirmation $whatsAppIdentityConfirmation): Request + { + $allData = [ + 'sender' => $sender, + 'userNumber' => $userNumber, + 'whatsAppIdentityConfirmation' => $whatsAppIdentityConfirmation, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'sender' => [ + new Assert\NotBlank(), + ], + 'userNumber' => [ + new Assert\NotBlank(), + ], + 'whatsAppIdentityConfirmation' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/whatsapp/1/{sender}/contacts/{userNumber}/identity'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($sender !== null) { + $resourcePath = str_replace( + '{' . 'sender' . '}', + $this->objectSerializer->toPathValue($sender), + $resourcePath + ); + } + + // path params + if ($userNumber !== null) { + $resourcePath = str_replace( + '{' . 'userNumber' . '}', + $this->objectSerializer->toPathValue($userNumber), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($whatsAppIdentityConfirmation)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($whatsAppIdentityConfirmation) + : $whatsAppIdentityConfirmation; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'PUT', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'confirmWhatsAppIdentity' + * @throws ApiException on non-2xx response + * @return null + */ + private function confirmWhatsAppIdentityResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'confirmWhatsAppIdentity' + */ + private function confirmWhatsAppIdentityApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation createWhatsAppTemplate + * + * Create WhatsApp Template + * + * @param string $sender Registered WhatsApp sender number. Must be in international format. (required) + * @param \Infobip\Model\WhatsAppTemplatePublicApiRequest $whatsAppTemplatePublicApiRequest whatsAppTemplatePublicApiRequest (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\WhatsAppTemplateApiResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function createWhatsAppTemplate(string $sender, \Infobip\Model\WhatsAppTemplatePublicApiRequest $whatsAppTemplatePublicApiRequest) + { + $request = $this->createWhatsAppTemplateRequest($sender, $whatsAppTemplatePublicApiRequest); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->createWhatsAppTemplateResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->createWhatsAppTemplateApiException($exception); + } + } + + /** + * Operation createWhatsAppTemplateAsync + * + * Create WhatsApp Template + * + * @param string $sender Registered WhatsApp sender number. Must be in international format. (required) + * @param \Infobip\Model\WhatsAppTemplatePublicApiRequest $whatsAppTemplatePublicApiRequest (required) + * + * @throws InvalidArgumentException + */ + public function createWhatsAppTemplateAsync(string $sender, \Infobip\Model\WhatsAppTemplatePublicApiRequest $whatsAppTemplatePublicApiRequest): PromiseInterface + { + $request = $this->createWhatsAppTemplateRequest($sender, $whatsAppTemplatePublicApiRequest); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->createWhatsAppTemplateResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->createWhatsAppTemplateApiException($exception); + } + ); + } + + /** + * Create request for operation 'createWhatsAppTemplate' + * + * @param string $sender Registered WhatsApp sender number. Must be in international format. (required) + * @param \Infobip\Model\WhatsAppTemplatePublicApiRequest $whatsAppTemplatePublicApiRequest (required) + * + * @throws InvalidArgumentException + */ + private function createWhatsAppTemplateRequest(string $sender, \Infobip\Model\WhatsAppTemplatePublicApiRequest $whatsAppTemplatePublicApiRequest): Request + { + $allData = [ + 'sender' => $sender, + 'whatsAppTemplatePublicApiRequest' => $whatsAppTemplatePublicApiRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'sender' => [ + new Assert\NotBlank(), + ], + 'whatsAppTemplatePublicApiRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/whatsapp/2/senders/{sender}/templates'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($sender !== null) { + $resourcePath = str_replace( + '{' . 'sender' . '}', + $this->objectSerializer->toPathValue($sender), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($whatsAppTemplatePublicApiRequest)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($whatsAppTemplatePublicApiRequest) + : $whatsAppTemplatePublicApiRequest; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'createWhatsAppTemplate' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\WhatsAppTemplateApiResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function createWhatsAppTemplateResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 201) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\WhatsAppTemplateApiResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'createWhatsAppTemplate' + */ + private function createWhatsAppTemplateApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 403) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation deleteWhatsAppMedia + * + * Delete media + * + * @param string $sender Registered WhatsApp sender number. Must be in international format. (required) + * @param \Infobip\Model\WhatsAppUrlDeletionRequest $whatsAppUrlDeletionRequest whatsAppUrlDeletionRequest (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return void + */ + public function deleteWhatsAppMedia(string $sender, \Infobip\Model\WhatsAppUrlDeletionRequest $whatsAppUrlDeletionRequest) + { + $request = $this->deleteWhatsAppMediaRequest($sender, $whatsAppUrlDeletionRequest); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->deleteWhatsAppMediaResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->deleteWhatsAppMediaApiException($exception); + } + } + + /** + * Operation deleteWhatsAppMediaAsync + * + * Delete media + * + * @param string $sender Registered WhatsApp sender number. Must be in international format. (required) + * @param \Infobip\Model\WhatsAppUrlDeletionRequest $whatsAppUrlDeletionRequest (required) + * + * @throws InvalidArgumentException + */ + public function deleteWhatsAppMediaAsync(string $sender, \Infobip\Model\WhatsAppUrlDeletionRequest $whatsAppUrlDeletionRequest): PromiseInterface + { + $request = $this->deleteWhatsAppMediaRequest($sender, $whatsAppUrlDeletionRequest); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->deleteWhatsAppMediaResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->deleteWhatsAppMediaApiException($exception); + } + ); + } + + /** + * Create request for operation 'deleteWhatsAppMedia' + * + * @param string $sender Registered WhatsApp sender number. Must be in international format. (required) + * @param \Infobip\Model\WhatsAppUrlDeletionRequest $whatsAppUrlDeletionRequest (required) + * + * @throws InvalidArgumentException + */ + private function deleteWhatsAppMediaRequest(string $sender, \Infobip\Model\WhatsAppUrlDeletionRequest $whatsAppUrlDeletionRequest): Request + { + $allData = [ + 'sender' => $sender, + 'whatsAppUrlDeletionRequest' => $whatsAppUrlDeletionRequest, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'sender' => [ + new Assert\NotBlank(), + ], + 'whatsAppUrlDeletionRequest' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/whatsapp/1/senders/{sender}/media'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($sender !== null) { + $resourcePath = str_replace( + '{' . 'sender' . '}', + $this->objectSerializer->toPathValue($sender), + $resourcePath + ); + } + + $headers = [ + + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($whatsAppUrlDeletionRequest)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($whatsAppUrlDeletionRequest) + : $whatsAppUrlDeletionRequest; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'DELETE', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'deleteWhatsAppMedia' + * @throws ApiException on non-2xx response + * @return null + */ + private function deleteWhatsAppMediaResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'deleteWhatsAppMedia' + */ + private function deleteWhatsAppMediaApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + + return $apiException; + } + + /** + * Operation deleteWhatsAppTemplate + * + * Delete WhatsApp Template + * + * @param string $sender Registered WhatsApp sender number. Must be in international format. (required) + * @param string $templateName Template name. Must only contain lowercase alphanumeric characters and underscores. (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return void + */ + public function deleteWhatsAppTemplate(string $sender, string $templateName) + { + $request = $this->deleteWhatsAppTemplateRequest($sender, $templateName); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->deleteWhatsAppTemplateResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->deleteWhatsAppTemplateApiException($exception); + } + } + + /** + * Operation deleteWhatsAppTemplateAsync + * + * Delete WhatsApp Template + * + * @param string $sender Registered WhatsApp sender number. Must be in international format. (required) + * @param string $templateName Template name. Must only contain lowercase alphanumeric characters and underscores. (required) + * + * @throws InvalidArgumentException + */ + public function deleteWhatsAppTemplateAsync(string $sender, string $templateName): PromiseInterface + { + $request = $this->deleteWhatsAppTemplateRequest($sender, $templateName); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->deleteWhatsAppTemplateResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->deleteWhatsAppTemplateApiException($exception); + } + ); + } + + /** + * Create request for operation 'deleteWhatsAppTemplate' + * + * @param string $sender Registered WhatsApp sender number. Must be in international format. (required) + * @param string $templateName Template name. Must only contain lowercase alphanumeric characters and underscores. (required) + * + * @throws InvalidArgumentException + */ + private function deleteWhatsAppTemplateRequest(string $sender, string $templateName): Request + { + $allData = [ + 'sender' => $sender, + 'templateName' => $templateName, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'sender' => [ + new Assert\NotBlank(), + ], + 'templateName' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/whatsapp/2/senders/{sender}/templates/{templateName}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($sender !== null) { + $resourcePath = str_replace( + '{' . 'sender' . '}', + $this->objectSerializer->toPathValue($sender), + $resourcePath + ); + } + + // path params + if ($templateName !== null) { + $resourcePath = str_replace( + '{' . 'templateName' . '}', + $this->objectSerializer->toPathValue($templateName), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'DELETE', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'deleteWhatsAppTemplate' + * @throws ApiException on non-2xx response + * @return null + */ + private function deleteWhatsAppTemplateResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'deleteWhatsAppTemplate' + */ + private function deleteWhatsAppTemplateApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 403) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation downloadWhatsAppInboundMedia + * + * Download inbound media + * + * @param string $sender Registered WhatsApp sender number. Must be in international format. (required) + * @param string $mediaId ID of the media. (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \SplFileObject + */ + public function downloadWhatsAppInboundMedia(string $sender, string $mediaId) + { + $request = $this->downloadWhatsAppInboundMediaRequest($sender, $mediaId); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->downloadWhatsAppInboundMediaResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->downloadWhatsAppInboundMediaApiException($exception); + } + } + + /** + * Operation downloadWhatsAppInboundMediaAsync + * + * Download inbound media + * + * @param string $sender Registered WhatsApp sender number. Must be in international format. (required) + * @param string $mediaId ID of the media. (required) + * + * @throws InvalidArgumentException + */ + public function downloadWhatsAppInboundMediaAsync(string $sender, string $mediaId): PromiseInterface + { + $request = $this->downloadWhatsAppInboundMediaRequest($sender, $mediaId); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->downloadWhatsAppInboundMediaResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->downloadWhatsAppInboundMediaApiException($exception); + } + ); + } + + /** + * Create request for operation 'downloadWhatsAppInboundMedia' + * + * @param string $sender Registered WhatsApp sender number. Must be in international format. (required) + * @param string $mediaId ID of the media. (required) + * + * @throws InvalidArgumentException + */ + private function downloadWhatsAppInboundMediaRequest(string $sender, string $mediaId): Request + { + $allData = [ + 'sender' => $sender, + 'mediaId' => $mediaId, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'sender' => [ + new Assert\NotBlank(), + ], + 'mediaId' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/whatsapp/1/senders/{sender}/media/{mediaId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($sender !== null) { + $resourcePath = str_replace( + '{' . 'sender' . '}', + $this->objectSerializer->toPathValue($sender), + $resourcePath + ); + } + + // path params + if ($mediaId !== null) { + $resourcePath = str_replace( + '{' . 'mediaId' . '}', + $this->objectSerializer->toPathValue($mediaId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'downloadWhatsAppInboundMedia' + * @throws ApiException on non-2xx response + * @return \SplFileObject|null + */ + private function downloadWhatsAppInboundMediaResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\SplFileObject', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'downloadWhatsAppInboundMedia' + */ + private function downloadWhatsAppInboundMediaApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + + return $apiException; + } + + /** + * Operation getWhatsAppIdentity + * + * Get identity + * + * @param string $sender Registered WhatsApp sender number. Must be in international format. (required) + * @param string $userNumber End user's number. Must be in international format. (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\WhatsAppIdentityInfo|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function getWhatsAppIdentity(string $sender, string $userNumber) + { + $request = $this->getWhatsAppIdentityRequest($sender, $userNumber); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->getWhatsAppIdentityResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->getWhatsAppIdentityApiException($exception); + } + } + + /** + * Operation getWhatsAppIdentityAsync + * + * Get identity + * + * @param string $sender Registered WhatsApp sender number. Must be in international format. (required) + * @param string $userNumber End user's number. Must be in international format. (required) + * + * @throws InvalidArgumentException + */ + public function getWhatsAppIdentityAsync(string $sender, string $userNumber): PromiseInterface + { + $request = $this->getWhatsAppIdentityRequest($sender, $userNumber); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->getWhatsAppIdentityResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->getWhatsAppIdentityApiException($exception); + } + ); + } + + /** + * Create request for operation 'getWhatsAppIdentity' + * + * @param string $sender Registered WhatsApp sender number. Must be in international format. (required) + * @param string $userNumber End user's number. Must be in international format. (required) + * + * @throws InvalidArgumentException + */ + private function getWhatsAppIdentityRequest(string $sender, string $userNumber): Request + { + $allData = [ + 'sender' => $sender, + 'userNumber' => $userNumber, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'sender' => [ + new Assert\NotBlank(), + ], + 'userNumber' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/whatsapp/1/{sender}/contacts/{userNumber}/identity'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($sender !== null) { + $resourcePath = str_replace( + '{' . 'sender' . '}', + $this->objectSerializer->toPathValue($sender), + $resourcePath + ); + } + + // path params + if ($userNumber !== null) { + $resourcePath = str_replace( + '{' . 'userNumber' . '}', + $this->objectSerializer->toPathValue($userNumber), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'getWhatsAppIdentity' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\WhatsAppIdentityInfo|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function getWhatsAppIdentityResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\WhatsAppIdentityInfo', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'getWhatsAppIdentity' + */ + private function getWhatsAppIdentityApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation getWhatsAppMediaMetadata + * + * Get media metadata + * + * @param string $sender Registered WhatsApp sender number. Must be in international format. (required) + * @param string $mediaId ID of the media. (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return void + */ + public function getWhatsAppMediaMetadata(string $sender, string $mediaId) + { + $request = $this->getWhatsAppMediaMetadataRequest($sender, $mediaId); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->getWhatsAppMediaMetadataResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->getWhatsAppMediaMetadataApiException($exception); + } + } + + /** + * Operation getWhatsAppMediaMetadataAsync + * + * Get media metadata + * + * @param string $sender Registered WhatsApp sender number. Must be in international format. (required) + * @param string $mediaId ID of the media. (required) + * + * @throws InvalidArgumentException + */ + public function getWhatsAppMediaMetadataAsync(string $sender, string $mediaId): PromiseInterface + { + $request = $this->getWhatsAppMediaMetadataRequest($sender, $mediaId); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->getWhatsAppMediaMetadataResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->getWhatsAppMediaMetadataApiException($exception); + } + ); + } + + /** + * Create request for operation 'getWhatsAppMediaMetadata' + * + * @param string $sender Registered WhatsApp sender number. Must be in international format. (required) + * @param string $mediaId ID of the media. (required) + * + * @throws InvalidArgumentException + */ + private function getWhatsAppMediaMetadataRequest(string $sender, string $mediaId): Request + { + $allData = [ + 'sender' => $sender, + 'mediaId' => $mediaId, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'sender' => [ + new Assert\NotBlank(), + ], + 'mediaId' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/whatsapp/1/senders/{sender}/media/{mediaId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($sender !== null) { + $resourcePath = str_replace( + '{' . 'sender' . '}', + $this->objectSerializer->toPathValue($sender), + $resourcePath + ); + } + + // path params + if ($mediaId !== null) { + $resourcePath = str_replace( + '{' . 'mediaId' . '}', + $this->objectSerializer->toPathValue($mediaId), + $resourcePath + ); + } + + $headers = [ + + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'HEAD', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'getWhatsAppMediaMetadata' + * @throws ApiException on non-2xx response + * @return null + */ + private function getWhatsAppMediaMetadataResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'getWhatsAppMediaMetadata' + */ + private function getWhatsAppMediaMetadataApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + + return $apiException; + } + + /** + * Operation getWhatsAppTemplates + * + * Get WhatsApp Templates + * + * @param string $sender Registered WhatsApp sender number. Must be in international format. (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\WhatsAppTemplatesApiResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function getWhatsAppTemplates(string $sender) + { + $request = $this->getWhatsAppTemplatesRequest($sender); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->getWhatsAppTemplatesResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->getWhatsAppTemplatesApiException($exception); + } + } + + /** + * Operation getWhatsAppTemplatesAsync + * + * Get WhatsApp Templates + * + * @param string $sender Registered WhatsApp sender number. Must be in international format. (required) + * + * @throws InvalidArgumentException + */ + public function getWhatsAppTemplatesAsync(string $sender): PromiseInterface + { + $request = $this->getWhatsAppTemplatesRequest($sender); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->getWhatsAppTemplatesResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->getWhatsAppTemplatesApiException($exception); + } + ); + } + + /** + * Create request for operation 'getWhatsAppTemplates' + * + * @param string $sender Registered WhatsApp sender number. Must be in international format. (required) + * + * @throws InvalidArgumentException + */ + private function getWhatsAppTemplatesRequest(string $sender): Request + { + $allData = [ + 'sender' => $sender, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'sender' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/whatsapp/2/senders/{sender}/templates'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($sender !== null) { + $resourcePath = str_replace( + '{' . 'sender' . '}', + $this->objectSerializer->toPathValue($sender), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'getWhatsAppTemplates' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\WhatsAppTemplatesApiResponse|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function getWhatsAppTemplatesResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\WhatsAppTemplatesApiResponse', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'getWhatsAppTemplates' + */ + private function getWhatsAppTemplatesApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 403) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation markWhatsAppMessageAsRead + * + * Mark as read + * + * @param string $sender Registered WhatsApp sender number. Must be in international format. (required) + * @param string $messageId ID of the message to be marked as read. (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return void + */ + public function markWhatsAppMessageAsRead(string $sender, string $messageId) + { + $request = $this->markWhatsAppMessageAsReadRequest($sender, $messageId); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->markWhatsAppMessageAsReadResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->markWhatsAppMessageAsReadApiException($exception); + } + } + + /** + * Operation markWhatsAppMessageAsReadAsync + * + * Mark as read + * + * @param string $sender Registered WhatsApp sender number. Must be in international format. (required) + * @param string $messageId ID of the message to be marked as read. (required) + * + * @throws InvalidArgumentException + */ + public function markWhatsAppMessageAsReadAsync(string $sender, string $messageId): PromiseInterface + { + $request = $this->markWhatsAppMessageAsReadRequest($sender, $messageId); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->markWhatsAppMessageAsReadResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->markWhatsAppMessageAsReadApiException($exception); + } + ); + } + + /** + * Create request for operation 'markWhatsAppMessageAsRead' + * + * @param string $sender Registered WhatsApp sender number. Must be in international format. (required) + * @param string $messageId ID of the message to be marked as read. (required) + * + * @throws InvalidArgumentException + */ + private function markWhatsAppMessageAsReadRequest(string $sender, string $messageId): Request + { + $allData = [ + 'sender' => $sender, + 'messageId' => $messageId, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'sender' => [ + new Assert\NotBlank(), + ], + 'messageId' => [ + new Assert\NotBlank(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/whatsapp/1/senders/{sender}/message/{messageId}/read'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + // path params + if ($sender !== null) { + $resourcePath = str_replace( + '{' . 'sender' . '}', + $this->objectSerializer->toPathValue($sender), + $resourcePath + ); + } + + // path params + if ($messageId !== null) { + $resourcePath = str_replace( + '{' . 'messageId' . '}', + $this->objectSerializer->toPathValue($messageId), + $resourcePath + ); + } + + $headers = [ + 'Accept' => 'application/json', + + ]; + + // for model (json/xml) + if (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'markWhatsAppMessageAsRead' + * @throws ApiException on non-2xx response + * @return null + */ + private function markWhatsAppMessageAsReadResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'markWhatsAppMessageAsRead' + */ + private function markWhatsAppMessageAsReadApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\WhatsAppMarkAsReadErrorResponse', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation sendWhatsAppAudioMessage + * + * Send WhatsApp audio message + * + * @param \Infobip\Model\WhatsAppAudioMessage $whatsAppAudioMessage whatsAppAudioMessage (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\WhatsAppSingleMessageInfo|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function sendWhatsAppAudioMessage(\Infobip\Model\WhatsAppAudioMessage $whatsAppAudioMessage) + { + $request = $this->sendWhatsAppAudioMessageRequest($whatsAppAudioMessage); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->sendWhatsAppAudioMessageResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->sendWhatsAppAudioMessageApiException($exception); + } + } + + /** + * Operation sendWhatsAppAudioMessageAsync + * + * Send WhatsApp audio message + * + * @param \Infobip\Model\WhatsAppAudioMessage $whatsAppAudioMessage (required) + * + * @throws InvalidArgumentException + */ + public function sendWhatsAppAudioMessageAsync(\Infobip\Model\WhatsAppAudioMessage $whatsAppAudioMessage): PromiseInterface + { + $request = $this->sendWhatsAppAudioMessageRequest($whatsAppAudioMessage); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->sendWhatsAppAudioMessageResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->sendWhatsAppAudioMessageApiException($exception); + } + ); + } + + /** + * Create request for operation 'sendWhatsAppAudioMessage' + * + * @param \Infobip\Model\WhatsAppAudioMessage $whatsAppAudioMessage (required) + * + * @throws InvalidArgumentException + */ + private function sendWhatsAppAudioMessageRequest(\Infobip\Model\WhatsAppAudioMessage $whatsAppAudioMessage): Request + { + $allData = [ + 'whatsAppAudioMessage' => $whatsAppAudioMessage, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'whatsAppAudioMessage' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/whatsapp/1/message/audio'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($whatsAppAudioMessage)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($whatsAppAudioMessage) + : $whatsAppAudioMessage; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'sendWhatsAppAudioMessage' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\WhatsAppSingleMessageInfo|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function sendWhatsAppAudioMessageResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\WhatsAppSingleMessageInfo', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'sendWhatsAppAudioMessage' + */ + private function sendWhatsAppAudioMessageApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation sendWhatsAppContactMessage + * + * Send WhatsApp contact message + * + * @param \Infobip\Model\WhatsAppContactsMessage $whatsAppContactsMessage whatsAppContactsMessage (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\WhatsAppSingleMessageInfo|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function sendWhatsAppContactMessage(\Infobip\Model\WhatsAppContactsMessage $whatsAppContactsMessage) + { + $request = $this->sendWhatsAppContactMessageRequest($whatsAppContactsMessage); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->sendWhatsAppContactMessageResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->sendWhatsAppContactMessageApiException($exception); + } + } + + /** + * Operation sendWhatsAppContactMessageAsync + * + * Send WhatsApp contact message + * + * @param \Infobip\Model\WhatsAppContactsMessage $whatsAppContactsMessage (required) + * + * @throws InvalidArgumentException + */ + public function sendWhatsAppContactMessageAsync(\Infobip\Model\WhatsAppContactsMessage $whatsAppContactsMessage): PromiseInterface + { + $request = $this->sendWhatsAppContactMessageRequest($whatsAppContactsMessage); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->sendWhatsAppContactMessageResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->sendWhatsAppContactMessageApiException($exception); + } + ); + } + + /** + * Create request for operation 'sendWhatsAppContactMessage' + * + * @param \Infobip\Model\WhatsAppContactsMessage $whatsAppContactsMessage (required) + * + * @throws InvalidArgumentException + */ + private function sendWhatsAppContactMessageRequest(\Infobip\Model\WhatsAppContactsMessage $whatsAppContactsMessage): Request + { + $allData = [ + 'whatsAppContactsMessage' => $whatsAppContactsMessage, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'whatsAppContactsMessage' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/whatsapp/1/message/contact'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($whatsAppContactsMessage)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($whatsAppContactsMessage) + : $whatsAppContactsMessage; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'sendWhatsAppContactMessage' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\WhatsAppSingleMessageInfo|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function sendWhatsAppContactMessageResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\WhatsAppSingleMessageInfo', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'sendWhatsAppContactMessage' + */ + private function sendWhatsAppContactMessageApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation sendWhatsAppDocumentMessage + * + * Send WhatsApp document message + * + * @param \Infobip\Model\WhatsAppDocumentMessage $whatsAppDocumentMessage whatsAppDocumentMessage (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\WhatsAppSingleMessageInfo|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function sendWhatsAppDocumentMessage(\Infobip\Model\WhatsAppDocumentMessage $whatsAppDocumentMessage) + { + $request = $this->sendWhatsAppDocumentMessageRequest($whatsAppDocumentMessage); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->sendWhatsAppDocumentMessageResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->sendWhatsAppDocumentMessageApiException($exception); + } + } + + /** + * Operation sendWhatsAppDocumentMessageAsync + * + * Send WhatsApp document message + * + * @param \Infobip\Model\WhatsAppDocumentMessage $whatsAppDocumentMessage (required) + * + * @throws InvalidArgumentException + */ + public function sendWhatsAppDocumentMessageAsync(\Infobip\Model\WhatsAppDocumentMessage $whatsAppDocumentMessage): PromiseInterface + { + $request = $this->sendWhatsAppDocumentMessageRequest($whatsAppDocumentMessage); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->sendWhatsAppDocumentMessageResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->sendWhatsAppDocumentMessageApiException($exception); + } + ); + } + + /** + * Create request for operation 'sendWhatsAppDocumentMessage' + * + * @param \Infobip\Model\WhatsAppDocumentMessage $whatsAppDocumentMessage (required) + * + * @throws InvalidArgumentException + */ + private function sendWhatsAppDocumentMessageRequest(\Infobip\Model\WhatsAppDocumentMessage $whatsAppDocumentMessage): Request + { + $allData = [ + 'whatsAppDocumentMessage' => $whatsAppDocumentMessage, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'whatsAppDocumentMessage' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/whatsapp/1/message/document'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($whatsAppDocumentMessage)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($whatsAppDocumentMessage) + : $whatsAppDocumentMessage; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'sendWhatsAppDocumentMessage' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\WhatsAppSingleMessageInfo|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function sendWhatsAppDocumentMessageResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\WhatsAppSingleMessageInfo', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'sendWhatsAppDocumentMessage' + */ + private function sendWhatsAppDocumentMessageApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation sendWhatsAppImageMessage + * + * Send WhatsApp image message + * + * @param \Infobip\Model\WhatsAppImageMessage $whatsAppImageMessage whatsAppImageMessage (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\WhatsAppSingleMessageInfo|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function sendWhatsAppImageMessage(\Infobip\Model\WhatsAppImageMessage $whatsAppImageMessage) + { + $request = $this->sendWhatsAppImageMessageRequest($whatsAppImageMessage); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->sendWhatsAppImageMessageResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->sendWhatsAppImageMessageApiException($exception); + } + } + + /** + * Operation sendWhatsAppImageMessageAsync + * + * Send WhatsApp image message + * + * @param \Infobip\Model\WhatsAppImageMessage $whatsAppImageMessage (required) + * + * @throws InvalidArgumentException + */ + public function sendWhatsAppImageMessageAsync(\Infobip\Model\WhatsAppImageMessage $whatsAppImageMessage): PromiseInterface + { + $request = $this->sendWhatsAppImageMessageRequest($whatsAppImageMessage); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->sendWhatsAppImageMessageResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->sendWhatsAppImageMessageApiException($exception); + } + ); + } + + /** + * Create request for operation 'sendWhatsAppImageMessage' + * + * @param \Infobip\Model\WhatsAppImageMessage $whatsAppImageMessage (required) + * + * @throws InvalidArgumentException + */ + private function sendWhatsAppImageMessageRequest(\Infobip\Model\WhatsAppImageMessage $whatsAppImageMessage): Request + { + $allData = [ + 'whatsAppImageMessage' => $whatsAppImageMessage, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'whatsAppImageMessage' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/whatsapp/1/message/image'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($whatsAppImageMessage)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($whatsAppImageMessage) + : $whatsAppImageMessage; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'sendWhatsAppImageMessage' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\WhatsAppSingleMessageInfo|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function sendWhatsAppImageMessageResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\WhatsAppSingleMessageInfo', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'sendWhatsAppImageMessage' + */ + private function sendWhatsAppImageMessageApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation sendWhatsAppInteractiveButtonsMessage + * + * Send WhatsApp interactive buttons message + * + * @param \Infobip\Model\WhatsAppInteractiveButtonsMessage $whatsAppInteractiveButtonsMessage whatsAppInteractiveButtonsMessage (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\WhatsAppSingleMessageInfo|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function sendWhatsAppInteractiveButtonsMessage(\Infobip\Model\WhatsAppInteractiveButtonsMessage $whatsAppInteractiveButtonsMessage) + { + $request = $this->sendWhatsAppInteractiveButtonsMessageRequest($whatsAppInteractiveButtonsMessage); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->sendWhatsAppInteractiveButtonsMessageResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->sendWhatsAppInteractiveButtonsMessageApiException($exception); + } + } + + /** + * Operation sendWhatsAppInteractiveButtonsMessageAsync + * + * Send WhatsApp interactive buttons message + * + * @param \Infobip\Model\WhatsAppInteractiveButtonsMessage $whatsAppInteractiveButtonsMessage (required) + * + * @throws InvalidArgumentException + */ + public function sendWhatsAppInteractiveButtonsMessageAsync(\Infobip\Model\WhatsAppInteractiveButtonsMessage $whatsAppInteractiveButtonsMessage): PromiseInterface + { + $request = $this->sendWhatsAppInteractiveButtonsMessageRequest($whatsAppInteractiveButtonsMessage); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->sendWhatsAppInteractiveButtonsMessageResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->sendWhatsAppInteractiveButtonsMessageApiException($exception); + } + ); + } + + /** + * Create request for operation 'sendWhatsAppInteractiveButtonsMessage' + * + * @param \Infobip\Model\WhatsAppInteractiveButtonsMessage $whatsAppInteractiveButtonsMessage (required) + * + * @throws InvalidArgumentException + */ + private function sendWhatsAppInteractiveButtonsMessageRequest(\Infobip\Model\WhatsAppInteractiveButtonsMessage $whatsAppInteractiveButtonsMessage): Request + { + $allData = [ + 'whatsAppInteractiveButtonsMessage' => $whatsAppInteractiveButtonsMessage, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'whatsAppInteractiveButtonsMessage' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/whatsapp/1/message/interactive/buttons'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($whatsAppInteractiveButtonsMessage)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($whatsAppInteractiveButtonsMessage) + : $whatsAppInteractiveButtonsMessage; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'sendWhatsAppInteractiveButtonsMessage' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\WhatsAppSingleMessageInfo|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function sendWhatsAppInteractiveButtonsMessageResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\WhatsAppSingleMessageInfo', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'sendWhatsAppInteractiveButtonsMessage' + */ + private function sendWhatsAppInteractiveButtonsMessageApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation sendWhatsAppInteractiveListMessage + * + * Send WhatsApp interactive list message + * + * @param \Infobip\Model\WhatsAppInteractiveListMessage $whatsAppInteractiveListMessage whatsAppInteractiveListMessage (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\WhatsAppSingleMessageInfo|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function sendWhatsAppInteractiveListMessage(\Infobip\Model\WhatsAppInteractiveListMessage $whatsAppInteractiveListMessage) + { + $request = $this->sendWhatsAppInteractiveListMessageRequest($whatsAppInteractiveListMessage); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->sendWhatsAppInteractiveListMessageResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->sendWhatsAppInteractiveListMessageApiException($exception); + } + } + + /** + * Operation sendWhatsAppInteractiveListMessageAsync + * + * Send WhatsApp interactive list message + * + * @param \Infobip\Model\WhatsAppInteractiveListMessage $whatsAppInteractiveListMessage (required) + * + * @throws InvalidArgumentException + */ + public function sendWhatsAppInteractiveListMessageAsync(\Infobip\Model\WhatsAppInteractiveListMessage $whatsAppInteractiveListMessage): PromiseInterface + { + $request = $this->sendWhatsAppInteractiveListMessageRequest($whatsAppInteractiveListMessage); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->sendWhatsAppInteractiveListMessageResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->sendWhatsAppInteractiveListMessageApiException($exception); + } + ); + } + + /** + * Create request for operation 'sendWhatsAppInteractiveListMessage' + * + * @param \Infobip\Model\WhatsAppInteractiveListMessage $whatsAppInteractiveListMessage (required) + * + * @throws InvalidArgumentException + */ + private function sendWhatsAppInteractiveListMessageRequest(\Infobip\Model\WhatsAppInteractiveListMessage $whatsAppInteractiveListMessage): Request + { + $allData = [ + 'whatsAppInteractiveListMessage' => $whatsAppInteractiveListMessage, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'whatsAppInteractiveListMessage' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/whatsapp/1/message/interactive/list'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($whatsAppInteractiveListMessage)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($whatsAppInteractiveListMessage) + : $whatsAppInteractiveListMessage; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'sendWhatsAppInteractiveListMessage' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\WhatsAppSingleMessageInfo|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function sendWhatsAppInteractiveListMessageResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\WhatsAppSingleMessageInfo', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'sendWhatsAppInteractiveListMessage' + */ + private function sendWhatsAppInteractiveListMessageApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation sendWhatsAppInteractiveMultiProductMessage + * + * Send WhatsApp interactive multi-product message + * + * @param \Infobip\Model\WhatsAppInteractiveMultiProductMessage $whatsAppInteractiveMultiProductMessage whatsAppInteractiveMultiProductMessage (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\WhatsAppSingleMessageInfo|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function sendWhatsAppInteractiveMultiProductMessage(\Infobip\Model\WhatsAppInteractiveMultiProductMessage $whatsAppInteractiveMultiProductMessage) + { + $request = $this->sendWhatsAppInteractiveMultiProductMessageRequest($whatsAppInteractiveMultiProductMessage); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->sendWhatsAppInteractiveMultiProductMessageResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->sendWhatsAppInteractiveMultiProductMessageApiException($exception); + } + } + + /** + * Operation sendWhatsAppInteractiveMultiProductMessageAsync + * + * Send WhatsApp interactive multi-product message + * + * @param \Infobip\Model\WhatsAppInteractiveMultiProductMessage $whatsAppInteractiveMultiProductMessage (required) + * + * @throws InvalidArgumentException + */ + public function sendWhatsAppInteractiveMultiProductMessageAsync(\Infobip\Model\WhatsAppInteractiveMultiProductMessage $whatsAppInteractiveMultiProductMessage): PromiseInterface + { + $request = $this->sendWhatsAppInteractiveMultiProductMessageRequest($whatsAppInteractiveMultiProductMessage); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->sendWhatsAppInteractiveMultiProductMessageResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->sendWhatsAppInteractiveMultiProductMessageApiException($exception); + } + ); + } + + /** + * Create request for operation 'sendWhatsAppInteractiveMultiProductMessage' + * + * @param \Infobip\Model\WhatsAppInteractiveMultiProductMessage $whatsAppInteractiveMultiProductMessage (required) + * + * @throws InvalidArgumentException + */ + private function sendWhatsAppInteractiveMultiProductMessageRequest(\Infobip\Model\WhatsAppInteractiveMultiProductMessage $whatsAppInteractiveMultiProductMessage): Request + { + $allData = [ + 'whatsAppInteractiveMultiProductMessage' => $whatsAppInteractiveMultiProductMessage, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'whatsAppInteractiveMultiProductMessage' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/whatsapp/1/message/interactive/multi-product'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($whatsAppInteractiveMultiProductMessage)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($whatsAppInteractiveMultiProductMessage) + : $whatsAppInteractiveMultiProductMessage; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'sendWhatsAppInteractiveMultiProductMessage' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\WhatsAppSingleMessageInfo|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function sendWhatsAppInteractiveMultiProductMessageResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\WhatsAppSingleMessageInfo', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'sendWhatsAppInteractiveMultiProductMessage' + */ + private function sendWhatsAppInteractiveMultiProductMessageApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation sendWhatsAppInteractiveProductMessage + * + * Send WhatsApp interactive product message + * + * @param \Infobip\Model\WhatsAppInteractiveProductMessage $whatsAppInteractiveProductMessage whatsAppInteractiveProductMessage (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\WhatsAppSingleMessageInfo|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function sendWhatsAppInteractiveProductMessage(\Infobip\Model\WhatsAppInteractiveProductMessage $whatsAppInteractiveProductMessage) + { + $request = $this->sendWhatsAppInteractiveProductMessageRequest($whatsAppInteractiveProductMessage); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->sendWhatsAppInteractiveProductMessageResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->sendWhatsAppInteractiveProductMessageApiException($exception); + } + } + + /** + * Operation sendWhatsAppInteractiveProductMessageAsync + * + * Send WhatsApp interactive product message + * + * @param \Infobip\Model\WhatsAppInteractiveProductMessage $whatsAppInteractiveProductMessage (required) + * + * @throws InvalidArgumentException + */ + public function sendWhatsAppInteractiveProductMessageAsync(\Infobip\Model\WhatsAppInteractiveProductMessage $whatsAppInteractiveProductMessage): PromiseInterface + { + $request = $this->sendWhatsAppInteractiveProductMessageRequest($whatsAppInteractiveProductMessage); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->sendWhatsAppInteractiveProductMessageResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->sendWhatsAppInteractiveProductMessageApiException($exception); + } + ); + } + + /** + * Create request for operation 'sendWhatsAppInteractiveProductMessage' + * + * @param \Infobip\Model\WhatsAppInteractiveProductMessage $whatsAppInteractiveProductMessage (required) + * + * @throws InvalidArgumentException + */ + private function sendWhatsAppInteractiveProductMessageRequest(\Infobip\Model\WhatsAppInteractiveProductMessage $whatsAppInteractiveProductMessage): Request + { + $allData = [ + 'whatsAppInteractiveProductMessage' => $whatsAppInteractiveProductMessage, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'whatsAppInteractiveProductMessage' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/whatsapp/1/message/interactive/product'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($whatsAppInteractiveProductMessage)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($whatsAppInteractiveProductMessage) + : $whatsAppInteractiveProductMessage; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'sendWhatsAppInteractiveProductMessage' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\WhatsAppSingleMessageInfo|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function sendWhatsAppInteractiveProductMessageResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\WhatsAppSingleMessageInfo', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'sendWhatsAppInteractiveProductMessage' + */ + private function sendWhatsAppInteractiveProductMessageApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation sendWhatsAppLocationMessage + * + * Send WhatsApp location message + * + * @param \Infobip\Model\WhatsAppLocationMessage $whatsAppLocationMessage whatsAppLocationMessage (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\WhatsAppSingleMessageInfo|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function sendWhatsAppLocationMessage(\Infobip\Model\WhatsAppLocationMessage $whatsAppLocationMessage) + { + $request = $this->sendWhatsAppLocationMessageRequest($whatsAppLocationMessage); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->sendWhatsAppLocationMessageResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->sendWhatsAppLocationMessageApiException($exception); + } + } + + /** + * Operation sendWhatsAppLocationMessageAsync + * + * Send WhatsApp location message + * + * @param \Infobip\Model\WhatsAppLocationMessage $whatsAppLocationMessage (required) + * + * @throws InvalidArgumentException + */ + public function sendWhatsAppLocationMessageAsync(\Infobip\Model\WhatsAppLocationMessage $whatsAppLocationMessage): PromiseInterface + { + $request = $this->sendWhatsAppLocationMessageRequest($whatsAppLocationMessage); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->sendWhatsAppLocationMessageResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->sendWhatsAppLocationMessageApiException($exception); + } + ); + } + + /** + * Create request for operation 'sendWhatsAppLocationMessage' + * + * @param \Infobip\Model\WhatsAppLocationMessage $whatsAppLocationMessage (required) + * + * @throws InvalidArgumentException + */ + private function sendWhatsAppLocationMessageRequest(\Infobip\Model\WhatsAppLocationMessage $whatsAppLocationMessage): Request + { + $allData = [ + 'whatsAppLocationMessage' => $whatsAppLocationMessage, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'whatsAppLocationMessage' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/whatsapp/1/message/location'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($whatsAppLocationMessage)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($whatsAppLocationMessage) + : $whatsAppLocationMessage; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'sendWhatsAppLocationMessage' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\WhatsAppSingleMessageInfo|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function sendWhatsAppLocationMessageResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\WhatsAppSingleMessageInfo', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'sendWhatsAppLocationMessage' + */ + private function sendWhatsAppLocationMessageApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation sendWhatsAppStickerMessage + * + * Send WhatsApp sticker message + * + * @param \Infobip\Model\WhatsAppStickerMessage $whatsAppStickerMessage whatsAppStickerMessage (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\WhatsAppSingleMessageInfo|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function sendWhatsAppStickerMessage(\Infobip\Model\WhatsAppStickerMessage $whatsAppStickerMessage) + { + $request = $this->sendWhatsAppStickerMessageRequest($whatsAppStickerMessage); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->sendWhatsAppStickerMessageResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->sendWhatsAppStickerMessageApiException($exception); + } + } + + /** + * Operation sendWhatsAppStickerMessageAsync + * + * Send WhatsApp sticker message + * + * @param \Infobip\Model\WhatsAppStickerMessage $whatsAppStickerMessage (required) + * + * @throws InvalidArgumentException + */ + public function sendWhatsAppStickerMessageAsync(\Infobip\Model\WhatsAppStickerMessage $whatsAppStickerMessage): PromiseInterface + { + $request = $this->sendWhatsAppStickerMessageRequest($whatsAppStickerMessage); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->sendWhatsAppStickerMessageResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->sendWhatsAppStickerMessageApiException($exception); + } + ); + } + + /** + * Create request for operation 'sendWhatsAppStickerMessage' + * + * @param \Infobip\Model\WhatsAppStickerMessage $whatsAppStickerMessage (required) + * + * @throws InvalidArgumentException + */ + private function sendWhatsAppStickerMessageRequest(\Infobip\Model\WhatsAppStickerMessage $whatsAppStickerMessage): Request + { + $allData = [ + 'whatsAppStickerMessage' => $whatsAppStickerMessage, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'whatsAppStickerMessage' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/whatsapp/1/message/sticker'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($whatsAppStickerMessage)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($whatsAppStickerMessage) + : $whatsAppStickerMessage; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'sendWhatsAppStickerMessage' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\WhatsAppSingleMessageInfo|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function sendWhatsAppStickerMessageResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\WhatsAppSingleMessageInfo', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'sendWhatsAppStickerMessage' + */ + private function sendWhatsAppStickerMessageApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation sendWhatsAppTemplateMessage + * + * Send WhatsApp template message + * + * @param \Infobip\Model\WhatsAppBulkMessage $whatsAppBulkMessage whatsAppBulkMessage (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\WhatsAppBulkMessageInfo|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function sendWhatsAppTemplateMessage(\Infobip\Model\WhatsAppBulkMessage $whatsAppBulkMessage) + { + $request = $this->sendWhatsAppTemplateMessageRequest($whatsAppBulkMessage); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->sendWhatsAppTemplateMessageResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->sendWhatsAppTemplateMessageApiException($exception); + } + } + + /** + * Operation sendWhatsAppTemplateMessageAsync + * + * Send WhatsApp template message + * + * @param \Infobip\Model\WhatsAppBulkMessage $whatsAppBulkMessage (required) + * + * @throws InvalidArgumentException + */ + public function sendWhatsAppTemplateMessageAsync(\Infobip\Model\WhatsAppBulkMessage $whatsAppBulkMessage): PromiseInterface + { + $request = $this->sendWhatsAppTemplateMessageRequest($whatsAppBulkMessage); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->sendWhatsAppTemplateMessageResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->sendWhatsAppTemplateMessageApiException($exception); + } + ); + } + + /** + * Create request for operation 'sendWhatsAppTemplateMessage' + * + * @param \Infobip\Model\WhatsAppBulkMessage $whatsAppBulkMessage (required) + * + * @throws InvalidArgumentException + */ + private function sendWhatsAppTemplateMessageRequest(\Infobip\Model\WhatsAppBulkMessage $whatsAppBulkMessage): Request + { + $allData = [ + 'whatsAppBulkMessage' => $whatsAppBulkMessage, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'whatsAppBulkMessage' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/whatsapp/1/message/template'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($whatsAppBulkMessage)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($whatsAppBulkMessage) + : $whatsAppBulkMessage; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'sendWhatsAppTemplateMessage' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\WhatsAppBulkMessageInfo|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function sendWhatsAppTemplateMessageResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\WhatsAppBulkMessageInfo', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'sendWhatsAppTemplateMessage' + */ + private function sendWhatsAppTemplateMessageApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation sendWhatsAppTextMessage + * + * Send WhatsApp text message + * + * @param \Infobip\Model\WhatsAppTextMessage $whatsAppTextMessage whatsAppTextMessage (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\WhatsAppSingleMessageInfo|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function sendWhatsAppTextMessage(\Infobip\Model\WhatsAppTextMessage $whatsAppTextMessage) + { + $request = $this->sendWhatsAppTextMessageRequest($whatsAppTextMessage); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->sendWhatsAppTextMessageResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->sendWhatsAppTextMessageApiException($exception); + } + } + + /** + * Operation sendWhatsAppTextMessageAsync + * + * Send WhatsApp text message + * + * @param \Infobip\Model\WhatsAppTextMessage $whatsAppTextMessage (required) + * + * @throws InvalidArgumentException + */ + public function sendWhatsAppTextMessageAsync(\Infobip\Model\WhatsAppTextMessage $whatsAppTextMessage): PromiseInterface + { + $request = $this->sendWhatsAppTextMessageRequest($whatsAppTextMessage); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->sendWhatsAppTextMessageResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->sendWhatsAppTextMessageApiException($exception); + } + ); + } + + /** + * Create request for operation 'sendWhatsAppTextMessage' + * + * @param \Infobip\Model\WhatsAppTextMessage $whatsAppTextMessage (required) + * + * @throws InvalidArgumentException + */ + private function sendWhatsAppTextMessageRequest(\Infobip\Model\WhatsAppTextMessage $whatsAppTextMessage): Request + { + $allData = [ + 'whatsAppTextMessage' => $whatsAppTextMessage, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'whatsAppTextMessage' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/whatsapp/1/message/text'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($whatsAppTextMessage)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($whatsAppTextMessage) + : $whatsAppTextMessage; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'sendWhatsAppTextMessage' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\WhatsAppSingleMessageInfo|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function sendWhatsAppTextMessageResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\WhatsAppSingleMessageInfo', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'sendWhatsAppTextMessage' + */ + private function sendWhatsAppTextMessageApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } + + /** + * Operation sendWhatsAppVideoMessage + * + * Send WhatsApp video message + * + * @param \Infobip\Model\WhatsAppVideoMessage $whatsAppVideoMessage whatsAppVideoMessage (required) + * + * @throws ApiException on non-2xx response + * @throws InvalidArgumentException + * @return \Infobip\Model\WhatsAppSingleMessageInfo|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException + */ + public function sendWhatsAppVideoMessage(\Infobip\Model\WhatsAppVideoMessage $whatsAppVideoMessage) + { + $request = $this->sendWhatsAppVideoMessageRequest($whatsAppVideoMessage); + + try { + try { + $response = $this->client->send($request); + $this->deprecationChecker->check($request, $response); + return $this->sendWhatsAppVideoMessageResponse($response, $request->getUri()); + } catch (GuzzleException $exception) { + $errorResponse = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + throw new ApiException( + "[{$exception->getCode()}] {$exception->getMessage()}", + $exception->getCode(), + $errorResponse?->getHeaders(), + ($errorResponse !== null) ? (string)$errorResponse->getBody() : null + ); + } + } catch (ApiException $exception) { + throw $this->sendWhatsAppVideoMessageApiException($exception); + } + } + + /** + * Operation sendWhatsAppVideoMessageAsync + * + * Send WhatsApp video message + * + * @param \Infobip\Model\WhatsAppVideoMessage $whatsAppVideoMessage (required) + * + * @throws InvalidArgumentException + */ + public function sendWhatsAppVideoMessageAsync(\Infobip\Model\WhatsAppVideoMessage $whatsAppVideoMessage): PromiseInterface + { + $request = $this->sendWhatsAppVideoMessageRequest($whatsAppVideoMessage); + + return $this + ->client + ->sendAsync($request) + ->then( + function ($response) use ($request) { + $this->deprecationChecker->check($request, $response); + return $this->sendWhatsAppVideoMessageResponse($response, $request->getUri()); + }, + function (GuzzleException $exception) { + $statusCode = $exception->getCode(); + + $response = ($exception instanceof RequestException) ? $exception->getResponse() : null; + + $exception = new ApiException( + "[{$statusCode}] {$exception->getMessage()}", + $statusCode, + $response?->getHeaders(), + ($response !== null) ? (string)$response->getBody() : null + ); + + throw $this->sendWhatsAppVideoMessageApiException($exception); + } + ); + } + + /** + * Create request for operation 'sendWhatsAppVideoMessage' + * + * @param \Infobip\Model\WhatsAppVideoMessage $whatsAppVideoMessage (required) + * + * @throws InvalidArgumentException + */ + private function sendWhatsAppVideoMessageRequest(\Infobip\Model\WhatsAppVideoMessage $whatsAppVideoMessage): Request + { + $allData = [ + 'whatsAppVideoMessage' => $whatsAppVideoMessage, + ]; + + $validationConstraints = []; + + $this + ->addParamConstraints( + [ + 'whatsAppVideoMessage' => [ + new Assert\NotNull(), + ], + ], + $validationConstraints + ); + + $this->validateParams($allData, $validationConstraints); + + $resourcePath = '/whatsapp/1/message/video'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + + // for model (json/xml) + if (isset($whatsAppVideoMessage)) { + $httpBody = ($headers['Content-Type'] === 'application/json') + ? $this->objectSerializer->serialize($whatsAppVideoMessage) + : $whatsAppVideoMessage; + } elseif (count($formParams) > 0) { + $formParams = \json_decode($this->objectSerializer->serialize($formParams), true); + + if ($headers['Content-Type'] === 'multipart/form-data') { + $boundary = '----' . hash('sha256', uniqid('', true)); + $headers['Content-Type'] .= '; boundary=' . $boundary; + $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, $boundary); + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = $this->objectSerializer->serialize($formParams); + } else { + // for HTTP post (form) + $httpBody = Query::build($formParams); + } + } + + $apiKey = $this->config->getApiKey(); + + if ($apiKey !== null) { + $headers[$this->config->getApiKeyHeader()] = $apiKey; + } + + $defaultHeaders = []; + + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = \array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + foreach ($queryParams as $key => $value) { + if (\is_array($value)) { + continue; + } + + $queryParams[$key] = $this->objectSerializer->toString($value); + } + + $query = Query::build($queryParams); + + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create response for operation 'sendWhatsAppVideoMessage' + * @throws ApiException on non-2xx response + * @return \Infobip\Model\WhatsAppSingleMessageInfo|\Infobip\Model\ApiException|\Infobip\Model\ApiException|\Infobip\Model\ApiException|null + */ + private function sendWhatsAppVideoMessageResponse(ResponseInterface $response, UriInterface $requestUri): mixed + { + $statusCode = $response->getStatusCode(); + $responseBody = $response->getBody(); + $responseHeaders = $response->getHeaders(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf('[%d] API Error (%s)', $statusCode, $requestUri), + $statusCode, + $responseHeaders, + $responseBody + ); + } + + $responseResult = null; + + if ($statusCode === 200) { + $responseResult = $this->deserialize($responseBody, '\Infobip\Model\WhatsAppSingleMessageInfo', $responseHeaders); + } + return $responseResult; + } + + /** + * Adapt given ApiException for operation 'sendWhatsAppVideoMessage' + */ + private function sendWhatsAppVideoMessageApiException(ApiException $apiException): ApiException + { + $statusCode = $apiException->getCode(); + + if ($statusCode === 400) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 401) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + if ($statusCode === 429) { + $data = $this->objectSerializer->deserialize( + $apiException->getResponseBody(), + '\Infobip\Model\ApiException', + $apiException->getResponseHeaders() + ); + + $apiException->setResponseObject($data); + + return $apiException; + } + + return $apiException; + } +} diff --git a/Infobip/ApiException.php b/Infobip/ApiException.php index 4c5d6e1..89d3349 100644 --- a/Infobip/ApiException.php +++ b/Infobip/ApiException.php @@ -1,7 +1,7 @@ tempFolderPath = sys_get_temp_dir(); - } - - /** - * Sets API key - * - * @param string $apiKeyIdentifier API key identifier (authentication scheme) - * @param string $key API key or token - * - * @return $this - */ - public function setApiKey($apiKeyIdentifier, $key) - { - $this->apiKeys[$apiKeyIdentifier] = $key; - return $this; - } - - /** - * Gets API key - * - * @param string $apiKeyIdentifier API key identifier (authentication scheme) - * - * @return null|string API key or token - */ - public function getApiKey($apiKeyIdentifier) - { - return isset($this->apiKeys[$apiKeyIdentifier]) ? $this->apiKeys[$apiKeyIdentifier] : null; - } - - /** - * Sets the prefix for API key (e.g. Bearer) - * - * @param string $apiKeyIdentifier API key identifier (authentication scheme) - * @param string $prefix API key prefix, e.g. Bearer - * - * @return $this - */ - public function setApiKeyPrefix($apiKeyIdentifier, $prefix) - { - $this->apiKeyPrefixes[$apiKeyIdentifier] = $prefix; - return $this; - } - - /** - * Gets API key prefix - * - * @param string $apiKeyIdentifier API key identifier (authentication scheme) - * - * @return null|string - */ - public function getApiKeyPrefix($apiKeyIdentifier) - { - return isset($this->apiKeyPrefixes[$apiKeyIdentifier]) ? $this->apiKeyPrefixes[$apiKeyIdentifier] : null; - } - - /** - * Sets the access token for OAuth - * - * @param string $accessToken Token for OAuth - * - * @return $this - */ - public function setAccessToken($accessToken) - { - $this->accessToken = $accessToken; - return $this; - } - - /** - * Gets the access token for OAuth - * - * @return string Access token for OAuth - */ - public function getAccessToken() - { - return $this->accessToken; - } - - /** - * Sets the username for HTTP basic authentication - * - * @param string $username Username for HTTP basic authentication - * - * @return $this - */ - public function setUsername($username) - { - $this->username = $username; - return $this; - } - - /** - * Gets the username for HTTP basic authentication - * - * @return string Username for HTTP basic authentication - */ - public function getUsername() - { - return $this->username; - } - - /** - * Sets the password for HTTP basic authentication - * - * @param string $password Password for HTTP basic authentication - * - * @return $this - */ - public function setPassword($password) - { - $this->password = $password; - return $this; - } - - /** - * Gets the password for HTTP basic authentication - * - * @return string Password for HTTP basic authentication - */ - public function getPassword() - { - return $this->password; - } - - /** - * Sets the host - * - * @param string $host Host - * - * @return $this - */ - public function setHost($host) - { - $this->host = $host; - return $this; + public const API_KEY_HEADER = 'Authorization'; + public const API_KEY_PREFIX = 'App'; + + public function __construct( + private string $host, + private string $apiKey, + private ?string $tempFolderPath = null + ) { + if ($this->tempFolderPath === null) { + $this->tempFolderPath = \sys_get_temp_dir(); + } } - /** - * Gets the host - * - * @return string Host - */ - public function getHost() + public function getHost(): string { return $this->host; } - /** - * Gets the user agent of the api client - * - * @return string user agent - */ - public function getUserAgent() - { - return $this->userAgent; - } - - /** - * Sets debug flag - * - * @param bool $debug Debug flag - * - * @return $this - */ - public function setDebug($debug) - { - $this->debug = $debug; - return $this; - } - - /** - * Gets the debug flag - * - * @return bool - */ - public function getDebug() - { - return $this->debug; - } - - /** - * Sets the debug file - * - * @param string $debugFile Debug file - * - * @return $this - */ - public function setDebugFile($debugFile) + public function getApiKeyHeader(): string { - $this->debugFile = $debugFile; - return $this; + return self::API_KEY_HEADER; } - /** - * Gets the debug file - * - * @return string - */ - public function getDebugFile() + public function getApiKey(): string { - return $this->debugFile; + return sprintf('%s %s', self::API_KEY_PREFIX, $this->apiKey); } - /** - * Sets the temp folder path - * - * @param string $tempFolderPath Temp folder path - * - * @return $this - */ - public function setTempFolderPath($tempFolderPath) + public function getUserAgent(): string { - $this->tempFolderPath = $tempFolderPath; - return $this; + return 'infobip-api-client-php/5.0.0/PHP'; } - /** - * Gets the temp folder path - * - * @return string Temp folder path - */ - public function getTempFolderPath() + public function getTempFolderPath(): string { return $this->tempFolderPath; } - - /** - * Gets the default configuration instance - * - * @return Configuration - */ - public static function getDefaultConfiguration() - { - if (self::$defaultConfiguration === null) { - self::$defaultConfiguration = new Configuration(); - } - - return self::$defaultConfiguration; - } - - /** - * Sets the default configuration instance - * - * @param Configuration $config An instance of the Configuration Object - * - * @return void - */ - public static function setDefaultConfiguration(Configuration $config) - { - self::$defaultConfiguration = $config; - } - - /** - * Gets the essential information for debugging - * - * @return string The report for debugging - */ - public static function toDebugReport() - { - $report = 'PHP SDK (Infobip) Debug Report:' . PHP_EOL; - $report .= ' OS: ' . php_uname() . PHP_EOL; - $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; - $report .= ' SDK Package Version: 4.0.0' . PHP_EOL; - $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; - - return $report; - } - - /** - * Get API key (with prefix if set) - * - * @param string $apiKeyIdentifier name of apikey - * - * @return null|string API key with the prefix - */ - public function getApiKeyWithPrefix($apiKeyIdentifier) - { - $prefix = $this->getApiKeyPrefix($apiKeyIdentifier); - $apiKey = $this->getApiKey($apiKeyIdentifier); - - if ($apiKey === null) { - return null; - } - - if ($prefix === null) { - $keyWithPrefix = $apiKey; - } else { - $keyWithPrefix = $prefix . ' ' . $apiKey; - } - - return $keyWithPrefix; - } } diff --git a/Infobip/DeprecationChecker.php b/Infobip/DeprecationChecker.php new file mode 100644 index 0000000..37c72e0 --- /dev/null +++ b/Infobip/DeprecationChecker.php @@ -0,0 +1,122 @@ +getHeaderLine(self::SUNSET_HEADER); + $deprecationHeader = $response->getHeaderLine(self::DEPRECATION_HEADER); + + $timezone = new DateTimeZone('UTC'); + $now = \date_create('now', $timezone); + + $method = $request->getMethod(); + $path = $request->getUri()->__toString(); + + if (!empty($sunsetHeader)) { + $sunsetDate = \date_create_from_format(DATE_RFC1123, $sunsetHeader, $timezone); + + if ($sunsetDate !== false) { + $formattedSunsetDate = $sunsetDate->format(self::LOG_DATE_FORMAT); + + if ($sunsetDate < $now) { + $this->logGone($method, $path, $formattedSunsetDate); + return; + } + + $this->logDeprecation($method, $path, $formattedSunsetDate); + return; + } + } + + if (!empty($deprecationHeader)) { + $this->logDeprecation($method, $path); + } + } + + private function logGone(string $method, string $path, string $sunsetHeader): void + { + $this + ->logger + ->warning( + sprintf( + "As of %s UTC, the endpoint %s %s has been discontinued. " + . "To avoid disruption, kindly update the library or reach out to %s.", + $sunsetHeader, + $method, + $path, + self::SUPPORT_EMAIL + ) + ); + } + + private function logDeprecation(string $method, string $path, ?string $sunsetHeader = null): void + { + $message = ($sunsetHeader !== null) + ? sprintf( + 'As of %s UTC, the endpoint %s %s will no longer be available. ' + . 'To avoid disruption, kindly update the library or reach out to %s.', + $sunsetHeader, + $method, + $path, + self::SUPPORT_EMAIL + ) + : sprintf( + 'The endpoint %s %s is deprecated. ' + . 'Please consider updating the library or reaching out to %s for assistance.', + $method, + $path, + self::SUPPORT_EMAIL + ); + + $this + ->logger + ->warning($message); + } +} diff --git a/Infobip/EnumNormalizer.php b/Infobip/EnumNormalizer.php new file mode 100644 index 0000000..f61e341 --- /dev/null +++ b/Infobip/EnumNormalizer.php @@ -0,0 +1,84 @@ +__toString(); + } + + /** + * @inheritdoc + */ + public function supportsNormalization(mixed $data, string $format = null): bool + { + return $data instanceof EnumInterface; + } + + /** + * @inheritdoc + * @throws NotNormalizableValueException + */ + public function denormalize(mixed $data, string $type, string $format = null, array $context = []): EnumInterface + { + if (null === $data || (\is_string($data) && '' === trim($data))) { + throw NotNormalizableValueException::createForUnexpectedDataType( + 'The data is either an empty string or null', + $data, + [Type::BUILTIN_TYPE_STRING], + $context['deserialization_path'] ?? null, + true + ); + } + + return new $type($data); + } + + /** + * @inheritdoc + */ + public function supportsDenormalization(mixed $data, string $type, string $format = null): bool + { + return \class_exists($type) && \is_subclass_of($type, EnumInterface::class); + } +} diff --git a/Infobip/Model/ApiException.php b/Infobip/Model/ApiException.php new file mode 100644 index 0000000..ad4f770 --- /dev/null +++ b/Infobip/Model/ApiException.php @@ -0,0 +1,67 @@ + null + ]; + + /** + */ + public function __construct( + #[Assert\Valid] + + protected ?\Infobip\Model\InfobipApiRequestError $requestError = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getRequestError(): \Infobip\Model\InfobipApiRequestError|null + { + return $this->requestError; + } + + public function setRequestError(?\Infobip\Model\InfobipApiRequestError $requestError): self + { + $this->requestError = $requestError; + return $this; + } +} diff --git a/Infobip/Model/Call.php b/Infobip/Model/Call.php new file mode 100644 index 0000000..fe90473 --- /dev/null +++ b/Infobip/Model/Call.php @@ -0,0 +1,297 @@ + null, + 'endpoint' => null, + 'from' => null, + 'to' => null, + 'direction' => null, + 'state' => null, + 'media' => null, + 'startTime' => 'date-time', + 'answerTime' => 'date-time', + 'endTime' => 'date-time', + 'parentCallId' => null, + 'machineDetection' => null, + 'ringDuration' => 'int32', + 'applicationId' => null, + 'conferenceId' => null, + 'customData' => null, + 'dialogId' => null + ]; + + /** + * @param array $customData + */ + public function __construct( + #[Assert\Valid] + #[Assert\NotBlank] + + protected \Infobip\Model\CallEndpoint $endpoint, + protected ?string $id = null, + protected ?string $from = null, + protected ?string $to = null, + #[Assert\Choice(['INBOUND','OUTBOUND',])] + + protected ?string $direction = null, + #[Assert\Choice(['CALLING','RINGING','PRE_ESTABLISHED','ESTABLISHED','FINISHED','FAILED','CANCELLED','NO_ANSWER','BUSY',])] + + protected ?string $state = null, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsMediaProperties $media = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $startTime = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $answerTime = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $endTime = null, + protected ?string $parentCallId = null, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsMachineDetectionProperties $machineDetection = null, + protected ?int $ringDuration = null, + protected ?string $applicationId = null, + protected ?string $conferenceId = null, + protected ?array $customData = null, + protected ?string $dialogId = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getId(): string|null + { + return $this->id; + } + + public function setId(?string $id): self + { + $this->id = $id; + return $this; + } + + public function getEndpoint(): \Infobip\Model\CallEndpoint + { + return $this->endpoint; + } + + public function setEndpoint(\Infobip\Model\CallEndpoint $endpoint): self + { + $this->endpoint = $endpoint; + return $this; + } + + public function getFrom(): string|null + { + return $this->from; + } + + public function setFrom(?string $from): self + { + $this->from = $from; + return $this; + } + + public function getTo(): string|null + { + return $this->to; + } + + public function setTo(?string $to): self + { + $this->to = $to; + return $this; + } + + public function getDirection(): mixed + { + return $this->direction; + } + + public function setDirection($direction): self + { + $this->direction = $direction; + return $this; + } + + public function getState(): mixed + { + return $this->state; + } + + public function setState($state): self + { + $this->state = $state; + return $this; + } + + public function getMedia(): \Infobip\Model\CallsMediaProperties|null + { + return $this->media; + } + + public function setMedia(?\Infobip\Model\CallsMediaProperties $media): self + { + $this->media = $media; + return $this; + } + + public function getStartTime(): \DateTime|null + { + return $this->startTime; + } + + public function setStartTime(?\DateTime $startTime): self + { + $this->startTime = $startTime; + return $this; + } + + public function getAnswerTime(): \DateTime|null + { + return $this->answerTime; + } + + public function setAnswerTime(?\DateTime $answerTime): self + { + $this->answerTime = $answerTime; + return $this; + } + + public function getEndTime(): \DateTime|null + { + return $this->endTime; + } + + public function setEndTime(?\DateTime $endTime): self + { + $this->endTime = $endTime; + return $this; + } + + public function getParentCallId(): string|null + { + return $this->parentCallId; + } + + public function setParentCallId(?string $parentCallId): self + { + $this->parentCallId = $parentCallId; + return $this; + } + + public function getMachineDetection(): \Infobip\Model\CallsMachineDetectionProperties|null + { + return $this->machineDetection; + } + + public function setMachineDetection(?\Infobip\Model\CallsMachineDetectionProperties $machineDetection): self + { + $this->machineDetection = $machineDetection; + return $this; + } + + public function getRingDuration(): int|null + { + return $this->ringDuration; + } + + public function setRingDuration(?int $ringDuration): self + { + $this->ringDuration = $ringDuration; + return $this; + } + + public function getApplicationId(): string|null + { + return $this->applicationId; + } + + public function setApplicationId(?string $applicationId): self + { + $this->applicationId = $applicationId; + return $this; + } + + public function getConferenceId(): string|null + { + return $this->conferenceId; + } + + public function setConferenceId(?string $conferenceId): self + { + $this->conferenceId = $conferenceId; + return $this; + } + + /** + * @return array|null + */ + public function getCustomData() + { + return $this->customData; + } + + /** + * @param array|null $customData Custom data. + */ + public function setCustomData(?array $customData): self + { + $this->customData = $customData; + return $this; + } + + public function getDialogId(): string|null + { + return $this->dialogId; + } + + public function setDialogId(?string $dialogId): self + { + $this->dialogId = $dialogId; + return $this; + } +} diff --git a/Infobip/Model/CallBulkRequest.php b/Infobip/Model/CallBulkRequest.php new file mode 100644 index 0000000..774500e --- /dev/null +++ b/Infobip/Model/CallBulkRequest.php @@ -0,0 +1,102 @@ + null, + 'applicationId' => null, + 'items' => null + ]; + + /** + * @param \Infobip\Model\CallsBulkItem[] $items + */ + public function __construct( + #[Assert\NotBlank] + + protected string $applicationId, + #[Assert\NotBlank] + + protected array $items, + protected ?string $bulkId = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getBulkId(): string|null + { + return $this->bulkId; + } + + public function setBulkId(?string $bulkId): self + { + $this->bulkId = $bulkId; + return $this; + } + + public function getApplicationId(): string + { + return $this->applicationId; + } + + public function setApplicationId(string $applicationId): self + { + $this->applicationId = $applicationId; + return $this; + } + + /** + * @return \Infobip\Model\CallsBulkItem[] + */ + public function getItems(): array + { + return $this->items; + } + + /** + * @param \Infobip\Model\CallsBulkItem[] $items Bulk item list. + */ + public function setItems(array $items): self + { + $this->items = $items; + return $this; + } +} diff --git a/Infobip/Model/CallBulkResponse.php b/Infobip/Model/CallBulkResponse.php new file mode 100644 index 0000000..b92a434 --- /dev/null +++ b/Infobip/Model/CallBulkResponse.php @@ -0,0 +1,85 @@ + null, + 'calls' => null + ]; + + /** + * @param \Infobip\Model\CallsBulkCall[] $calls + */ + public function __construct( + protected ?string $bulkId = null, + protected ?array $calls = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getBulkId(): string|null + { + return $this->bulkId; + } + + public function setBulkId(?string $bulkId): self + { + $this->bulkId = $bulkId; + return $this; + } + + /** + * @return \Infobip\Model\CallsBulkCall[]|null + */ + public function getCalls(): ?array + { + return $this->calls; + } + + /** + * @param \Infobip\Model\CallsBulkCall[]|null $calls Bulk call list. + */ + public function setCalls(?array $calls): self + { + $this->calls = $calls; + return $this; + } +} diff --git a/Infobip/Model/CallBulkStatus.php b/Infobip/Model/CallBulkStatus.php new file mode 100644 index 0000000..1e092eb --- /dev/null +++ b/Infobip/Model/CallBulkStatus.php @@ -0,0 +1,95 @@ + null, + 'startTime' => 'date-time', + 'status' => null + ]; + + /** + */ + public function __construct( + protected ?string $bulkId = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $startTime = null, + #[Assert\Choice(['PENDING','PAUSED','PROCESSING','CANCELED','FINISHED','FAILED',])] + + protected ?string $status = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getBulkId(): string|null + { + return $this->bulkId; + } + + public function setBulkId(?string $bulkId): self + { + $this->bulkId = $bulkId; + return $this; + } + + public function getStartTime(): \DateTime|null + { + return $this->startTime; + } + + public function setStartTime(?\DateTime $startTime): self + { + $this->startTime = $startTime; + return $this; + } + + public function getStatus(): mixed + { + return $this->status; + } + + public function setStatus($status): self + { + $this->status = $status; + return $this; + } +} diff --git a/Infobip/Model/CallDirection.php b/Infobip/Model/CallDirection.php new file mode 100644 index 0000000..891752d --- /dev/null +++ b/Infobip/Model/CallDirection.php @@ -0,0 +1,64 @@ +value = $value; + } + + public static function INBOUND(): CallDirection + { + return new self('INBOUND'); + } + + public static function OUTBOUND(): CallDirection + { + return new self('OUTBOUND'); + } + + public function __toString(): string + { + return $this->value; + } +} diff --git a/Infobip/Model/CallEndpoint.php b/Infobip/Model/CallEndpoint.php new file mode 100644 index 0000000..2a71ea4 --- /dev/null +++ b/Infobip/Model/CallEndpoint.php @@ -0,0 +1,77 @@ + "\Infobip\Model\CallsPhoneEndpoint", + "CallsSipEndpoint" => "\Infobip\Model\CallsSipEndpoint", + "CallsViberEndpoint" => "\Infobip\Model\CallsViberEndpoint", + "CallsWebRtcEndpoint" => "\Infobip\Model\CallsWebRtcEndpoint", + "PHONE" => "\Infobip\Model\CallsPhoneEndpoint", + "SIP" => "\Infobip\Model\CallsSipEndpoint", + "VIBER" => "\Infobip\Model\CallsViberEndpoint", + "WEBRTC" => "\Infobip\Model\CallsWebRtcEndpoint", +])] +class CallEndpoint implements ModelInterface +{ + public const DISCRIMINATOR = 'type'; + public const OPENAPI_MODEL_NAME = 'CallEndpoint'; + + public const OPENAPI_FORMATS = [ + 'type' => null + ]; + + /** + */ + public function __construct( + #[Assert\Choice(['PHONE','SIP','WEBRTC','VIBER',])] + + protected ?string $type = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getType(): mixed + { + return $this->type; + } + + public function setType($type): self + { + $this->type = $type; + return $this; + } +} diff --git a/Infobip/Model/CallEndpointType.php b/Infobip/Model/CallEndpointType.php new file mode 100644 index 0000000..177feba --- /dev/null +++ b/Infobip/Model/CallEndpointType.php @@ -0,0 +1,78 @@ +value = $value; + } + + public static function PHONE(): CallEndpointType + { + return new self('PHONE'); + } + + public static function SIP(): CallEndpointType + { + return new self('SIP'); + } + + public static function WEBRTC(): CallEndpointType + { + return new self('WEBRTC'); + } + + public static function VIBER(): CallEndpointType + { + return new self('VIBER'); + } + + public function __toString(): string + { + return $this->value; + } +} diff --git a/Infobip/Model/CallLog.php b/Infobip/Model/CallLog.php new file mode 100644 index 0000000..19f586c --- /dev/null +++ b/Infobip/Model/CallLog.php @@ -0,0 +1,350 @@ + null, + 'endpoint' => null, + 'from' => null, + 'to' => null, + 'direction' => null, + 'state' => null, + 'startTime' => 'date-time', + 'answerTime' => 'date-time', + 'endTime' => 'date-time', + 'parentCallId' => null, + 'machineDetection' => null, + 'ringDuration' => 'int64', + 'applicationIds' => null, + 'conferenceIds' => null, + 'duration' => 'int64', + 'hasCameraVideo' => null, + 'hasScreenshareVideo' => null, + 'errorCode' => null, + 'customData' => null, + 'dialogId' => null + ]; + + /** + * @param string[] $applicationIds + * @param string[] $conferenceIds + * @param array $customData + */ + public function __construct( + #[Assert\Valid] + #[Assert\NotBlank] + + protected \Infobip\Model\CallEndpoint $endpoint, + protected ?string $callId = null, + protected ?string $from = null, + protected ?string $to = null, + #[Assert\Choice(['INBOUND','OUTBOUND',])] + + protected ?string $direction = null, + #[Assert\Choice(['CALLING','RINGING','PRE_ESTABLISHED','ESTABLISHED','FINISHED','FAILED','CANCELLED','NO_ANSWER','BUSY',])] + + protected ?string $state = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $startTime = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $answerTime = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $endTime = null, + protected ?string $parentCallId = null, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsMachineDetectionProperties $machineDetection = null, + protected ?int $ringDuration = null, + protected ?array $applicationIds = null, + protected ?array $conferenceIds = null, + protected ?int $duration = null, + protected ?bool $hasCameraVideo = null, + protected ?bool $hasScreenshareVideo = null, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsErrorCodeInfo $errorCode = null, + protected ?array $customData = null, + protected ?string $dialogId = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getCallId(): string|null + { + return $this->callId; + } + + public function setCallId(?string $callId): self + { + $this->callId = $callId; + return $this; + } + + public function getEndpoint(): \Infobip\Model\CallEndpoint + { + return $this->endpoint; + } + + public function setEndpoint(\Infobip\Model\CallEndpoint $endpoint): self + { + $this->endpoint = $endpoint; + return $this; + } + + public function getFrom(): string|null + { + return $this->from; + } + + public function setFrom(?string $from): self + { + $this->from = $from; + return $this; + } + + public function getTo(): string|null + { + return $this->to; + } + + public function setTo(?string $to): self + { + $this->to = $to; + return $this; + } + + public function getDirection(): mixed + { + return $this->direction; + } + + public function setDirection($direction): self + { + $this->direction = $direction; + return $this; + } + + public function getState(): mixed + { + return $this->state; + } + + public function setState($state): self + { + $this->state = $state; + return $this; + } + + public function getStartTime(): \DateTime|null + { + return $this->startTime; + } + + public function setStartTime(?\DateTime $startTime): self + { + $this->startTime = $startTime; + return $this; + } + + public function getAnswerTime(): \DateTime|null + { + return $this->answerTime; + } + + public function setAnswerTime(?\DateTime $answerTime): self + { + $this->answerTime = $answerTime; + return $this; + } + + public function getEndTime(): \DateTime|null + { + return $this->endTime; + } + + public function setEndTime(?\DateTime $endTime): self + { + $this->endTime = $endTime; + return $this; + } + + public function getParentCallId(): string|null + { + return $this->parentCallId; + } + + public function setParentCallId(?string $parentCallId): self + { + $this->parentCallId = $parentCallId; + return $this; + } + + public function getMachineDetection(): \Infobip\Model\CallsMachineDetectionProperties|null + { + return $this->machineDetection; + } + + public function setMachineDetection(?\Infobip\Model\CallsMachineDetectionProperties $machineDetection): self + { + $this->machineDetection = $machineDetection; + return $this; + } + + public function getRingDuration(): int|null + { + return $this->ringDuration; + } + + public function setRingDuration(?int $ringDuration): self + { + $this->ringDuration = $ringDuration; + return $this; + } + + /** + * @return string[]|null + */ + public function getApplicationIds(): ?array + { + return $this->applicationIds; + } + + /** + * @param string[]|null $applicationIds IDs of the applications used during the call. + */ + public function setApplicationIds(?array $applicationIds): self + { + $this->applicationIds = $applicationIds; + return $this; + } + + /** + * @return string[]|null + */ + public function getConferenceIds(): ?array + { + return $this->conferenceIds; + } + + /** + * @param string[]|null $conferenceIds IDs of the conferences where the call was a participant. + */ + public function setConferenceIds(?array $conferenceIds): self + { + $this->conferenceIds = $conferenceIds; + return $this; + } + + public function getDuration(): int|null + { + return $this->duration; + } + + public function setDuration(?int $duration): self + { + $this->duration = $duration; + return $this; + } + + public function getHasCameraVideo(): bool|null + { + return $this->hasCameraVideo; + } + + public function setHasCameraVideo(?bool $hasCameraVideo): self + { + $this->hasCameraVideo = $hasCameraVideo; + return $this; + } + + public function getHasScreenshareVideo(): bool|null + { + return $this->hasScreenshareVideo; + } + + public function setHasScreenshareVideo(?bool $hasScreenshareVideo): self + { + $this->hasScreenshareVideo = $hasScreenshareVideo; + return $this; + } + + public function getErrorCode(): \Infobip\Model\CallsErrorCodeInfo|null + { + return $this->errorCode; + } + + public function setErrorCode(?\Infobip\Model\CallsErrorCodeInfo $errorCode): self + { + $this->errorCode = $errorCode; + return $this; + } + + /** + * @return array|null + */ + public function getCustomData() + { + return $this->customData; + } + + /** + * @param array|null $customData Custom data. + */ + public function setCustomData(?array $customData): self + { + $this->customData = $customData; + return $this; + } + + public function getDialogId(): string|null + { + return $this->dialogId; + } + + public function setDialogId(?string $dialogId): self + { + $this->dialogId = $dialogId; + return $this; + } +} diff --git a/Infobip/Model/CallLogPage.php b/Infobip/Model/CallLogPage.php new file mode 100644 index 0000000..384a147 --- /dev/null +++ b/Infobip/Model/CallLogPage.php @@ -0,0 +1,87 @@ + null, + 'paging' => null + ]; + + /** + * @param \Infobip\Model\CallLog[] $results + */ + public function __construct( + protected ?array $results = null, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsPageInfo $paging = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + /** + * @return \Infobip\Model\CallLog[]|null + */ + public function getResults(): ?array + { + return $this->results; + } + + /** + * @param \Infobip\Model\CallLog[]|null $results The list of the results for this page. + */ + public function setResults(?array $results): self + { + $this->results = $results; + return $this; + } + + public function getPaging(): \Infobip\Model\CallsPageInfo|null + { + return $this->paging; + } + + public function setPaging(?\Infobip\Model\CallsPageInfo $paging): self + { + $this->paging = $paging; + return $this; + } +} diff --git a/Infobip/Model/CallPage.php b/Infobip/Model/CallPage.php new file mode 100644 index 0000000..a74edf0 --- /dev/null +++ b/Infobip/Model/CallPage.php @@ -0,0 +1,87 @@ + null, + 'paging' => null + ]; + + /** + * @param \Infobip\Model\Call[] $results + */ + public function __construct( + protected ?array $results = null, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsPageInfo $paging = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + /** + * @return \Infobip\Model\Call[]|null + */ + public function getResults(): ?array + { + return $this->results; + } + + /** + * @param \Infobip\Model\Call[]|null $results The list of the results for this page. + */ + public function setResults(?array $results): self + { + $this->results = $results; + return $this; + } + + public function getPaging(): \Infobip\Model\CallsPageInfo|null + { + return $this->paging; + } + + public function setPaging(?\Infobip\Model\CallsPageInfo $paging): self + { + $this->paging = $paging; + return $this; + } +} diff --git a/Infobip/Model/CallRate.php b/Infobip/Model/CallRate.php new file mode 100644 index 0000000..5d1eabc --- /dev/null +++ b/Infobip/Model/CallRate.php @@ -0,0 +1,80 @@ + 'int32', + 'timeUnit' => null + ]; + + /** + */ + public function __construct( + protected ?int $maxCalls = null, + #[Assert\Choice(['SECONDS','MINUTES','HOURS','DAYS',])] + + protected ?string $timeUnit = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getMaxCalls(): int|null + { + return $this->maxCalls; + } + + public function setMaxCalls(?int $maxCalls): self + { + $this->maxCalls = $maxCalls; + return $this; + } + + public function getTimeUnit(): mixed + { + return $this->timeUnit; + } + + public function setTimeUnit($timeUnit): self + { + $this->timeUnit = $timeUnit; + return $this; + } +} diff --git a/Infobip/Model/CallRecording.php b/Infobip/Model/CallRecording.php new file mode 100644 index 0000000..c4cc89a --- /dev/null +++ b/Infobip/Model/CallRecording.php @@ -0,0 +1,187 @@ + null, + 'endpoint' => null, + 'direction' => null, + 'files' => null, + 'status' => null, + 'reason' => null, + 'applicationId' => null, + 'startTime' => 'date-time', + 'endTime' => 'date-time' + ]; + + /** + * @param \Infobip\Model\CallsRecordingFile[] $files + */ + public function __construct( + #[Assert\Valid] + #[Assert\NotBlank] + + protected \Infobip\Model\CallEndpoint $endpoint, + protected ?string $callId = null, + #[Assert\Choice(['INBOUND','OUTBOUND',])] + + protected ?string $direction = null, + protected ?array $files = null, + #[Assert\Choice(['SUCCESSFUL','PARTIALLY_FAILED','FAILED',])] + + protected ?string $status = null, + protected ?string $reason = null, + protected ?string $applicationId = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $startTime = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $endTime = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getCallId(): string|null + { + return $this->callId; + } + + public function setCallId(?string $callId): self + { + $this->callId = $callId; + return $this; + } + + public function getEndpoint(): \Infobip\Model\CallEndpoint + { + return $this->endpoint; + } + + public function setEndpoint(\Infobip\Model\CallEndpoint $endpoint): self + { + $this->endpoint = $endpoint; + return $this; + } + + public function getDirection(): mixed + { + return $this->direction; + } + + public function setDirection($direction): self + { + $this->direction = $direction; + return $this; + } + + /** + * @return \Infobip\Model\CallsRecordingFile[]|null + */ + public function getFiles(): ?array + { + return $this->files; + } + + /** + * @param \Infobip\Model\CallsRecordingFile[]|null $files Call recording files. + */ + public function setFiles(?array $files): self + { + $this->files = $files; + return $this; + } + + public function getStatus(): mixed + { + return $this->status; + } + + public function setStatus($status): self + { + $this->status = $status; + return $this; + } + + public function getReason(): string|null + { + return $this->reason; + } + + public function setReason(?string $reason): self + { + $this->reason = $reason; + return $this; + } + + public function getApplicationId(): string|null + { + return $this->applicationId; + } + + public function setApplicationId(?string $applicationId): self + { + $this->applicationId = $applicationId; + return $this; + } + + public function getStartTime(): \DateTime|null + { + return $this->startTime; + } + + public function setStartTime(?\DateTime $startTime): self + { + $this->startTime = $startTime; + return $this; + } + + public function getEndTime(): \DateTime|null + { + return $this->endTime; + } + + public function setEndTime(?\DateTime $endTime): self + { + $this->endTime = $endTime; + return $this; + } +} diff --git a/Infobip/Model/CallRecordingPage.php b/Infobip/Model/CallRecordingPage.php new file mode 100644 index 0000000..6c30ac2 --- /dev/null +++ b/Infobip/Model/CallRecordingPage.php @@ -0,0 +1,87 @@ + null, + 'paging' => null + ]; + + /** + * @param \Infobip\Model\CallRecording[] $results + */ + public function __construct( + protected ?array $results = null, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsPageInfo $paging = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + /** + * @return \Infobip\Model\CallRecording[]|null + */ + public function getResults(): ?array + { + return $this->results; + } + + /** + * @param \Infobip\Model\CallRecording[]|null $results The list of the results for this page. + */ + public function setResults(?array $results): self + { + $this->results = $results; + return $this; + } + + public function getPaging(): \Infobip\Model\CallsPageInfo|null + { + return $this->paging; + } + + public function setPaging(?\Infobip\Model\CallsPageInfo $paging): self + { + $this->paging = $paging; + return $this; + } +} diff --git a/Infobip/Model/CallRecordingRequest.php b/Infobip/Model/CallRecordingRequest.php new file mode 100644 index 0000000..c4de793 --- /dev/null +++ b/Infobip/Model/CallRecordingRequest.php @@ -0,0 +1,68 @@ + null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + #[Assert\Choice(['AUDIO','AUDIO_AND_VIDEO',])] + + protected string $recordingType, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getRecordingType(): mixed + { + return $this->recordingType; + } + + public function setRecordingType($recordingType): self + { + $this->recordingType = $recordingType; + return $this; + } +} diff --git a/Infobip/Model/CallRequest.php b/Infobip/Model/CallRequest.php new file mode 100644 index 0000000..6af0b47 --- /dev/null +++ b/Infobip/Model/CallRequest.php @@ -0,0 +1,187 @@ + null, + 'from' => null, + 'fromDisplayName' => null, + 'connectTimeout' => 'int32', + 'recording' => null, + 'machineDetection' => null, + 'maxDuration' => 'int32', + 'customData' => null, + 'applicationId' => null + ]; + + /** + * @param array $customData + */ + public function __construct( + #[Assert\Valid] + #[Assert\NotBlank] + + protected \Infobip\Model\CallEndpoint $endpoint, + #[Assert\NotBlank] + + protected string $from, + #[Assert\NotBlank] + + protected string $applicationId, + protected ?string $fromDisplayName = null, + protected ?int $connectTimeout = null, + #[Assert\Valid] + + protected ?\Infobip\Model\CallRecordingRequest $recording = null, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsMachineDetectionRequest $machineDetection = null, + protected ?int $maxDuration = 28800, + protected ?array $customData = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getEndpoint(): \Infobip\Model\CallEndpoint + { + return $this->endpoint; + } + + public function setEndpoint(\Infobip\Model\CallEndpoint $endpoint): self + { + $this->endpoint = $endpoint; + return $this; + } + + public function getFrom(): string + { + return $this->from; + } + + public function setFrom(string $from): self + { + $this->from = $from; + return $this; + } + + public function getFromDisplayName(): string|null + { + return $this->fromDisplayName; + } + + public function setFromDisplayName(?string $fromDisplayName): self + { + $this->fromDisplayName = $fromDisplayName; + return $this; + } + + public function getConnectTimeout(): int|null + { + return $this->connectTimeout; + } + + public function setConnectTimeout(?int $connectTimeout): self + { + $this->connectTimeout = $connectTimeout; + return $this; + } + + public function getRecording(): \Infobip\Model\CallRecordingRequest|null + { + return $this->recording; + } + + public function setRecording(?\Infobip\Model\CallRecordingRequest $recording): self + { + $this->recording = $recording; + return $this; + } + + public function getMachineDetection(): \Infobip\Model\CallsMachineDetectionRequest|null + { + return $this->machineDetection; + } + + public function setMachineDetection(?\Infobip\Model\CallsMachineDetectionRequest $machineDetection): self + { + $this->machineDetection = $machineDetection; + return $this; + } + + public function getMaxDuration(): int|null + { + return $this->maxDuration; + } + + public function setMaxDuration(?int $maxDuration): self + { + $this->maxDuration = $maxDuration; + return $this; + } + + /** + * @return array|null + */ + public function getCustomData() + { + return $this->customData; + } + + /** + * @param array|null $customData Custom data. + */ + public function setCustomData(?array $customData): self + { + $this->customData = $customData; + return $this; + } + + public function getApplicationId(): string + { + return $this->applicationId; + } + + public function setApplicationId(string $applicationId): self + { + $this->applicationId = $applicationId; + return $this; + } +} diff --git a/Infobip/Model/CallState.php b/Infobip/Model/CallState.php new file mode 100644 index 0000000..d29defe --- /dev/null +++ b/Infobip/Model/CallState.php @@ -0,0 +1,113 @@ +value = $value; + } + + public static function CALLING(): CallState + { + return new self('CALLING'); + } + + public static function RINGING(): CallState + { + return new self('RINGING'); + } + + public static function PRE_ESTABLISHED(): CallState + { + return new self('PRE_ESTABLISHED'); + } + + public static function ESTABLISHED(): CallState + { + return new self('ESTABLISHED'); + } + + public static function FINISHED(): CallState + { + return new self('FINISHED'); + } + + public static function FAILED(): CallState + { + return new self('FAILED'); + } + + public static function CANCELLED(): CallState + { + return new self('CANCELLED'); + } + + public static function NO_ANSWER(): CallState + { + return new self('NO_ANSWER'); + } + + public static function BUSY(): CallState + { + return new self('BUSY'); + } + + public function __toString(): string + { + return $this->value; + } +} diff --git a/Infobip/Model/CallTransfer.php b/Infobip/Model/CallTransfer.php new file mode 100644 index 0000000..fe70030 --- /dev/null +++ b/Infobip/Model/CallTransfer.php @@ -0,0 +1,110 @@ + 'int32', + 'equals' => null, + 'if' => null, + 'transferTo' => null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + + protected string $equals, + #[Assert\NotBlank] + + protected string $if, + #[Assert\NotBlank] + + protected string $transferTo, + protected ?int $callTransferMaxDuration = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getCallTransferMaxDuration(): int|null + { + return $this->callTransferMaxDuration; + } + + public function setCallTransferMaxDuration(?int $callTransferMaxDuration): self + { + $this->callTransferMaxDuration = $callTransferMaxDuration; + return $this; + } + + public function getEquals(): string + { + return $this->equals; + } + + public function setEquals(string $equals): self + { + $this->equals = $equals; + return $this; + } + + public function getIf(): string + { + return $this->if; + } + + public function setIf(string $if): self + { + $this->if = $if; + return $this; + } + + public function getTransferTo(): string + { + return $this->transferTo; + } + + public function setTransferTo(string $transferTo): self + { + $this->transferTo = $transferTo; + return $this; + } +} diff --git a/Infobip/Model/CallVoice.php b/Infobip/Model/CallVoice.php new file mode 100644 index 0000000..3939a1b --- /dev/null +++ b/Infobip/Model/CallVoice.php @@ -0,0 +1,1345 @@ +value = $value; + } + + public static function HODA(): CallVoice + { + return new self('Hoda'); + } + + public static function ZEINA(): CallVoice + { + return new self('Zeina'); + } + + public static function NAAYF(): CallVoice + { + return new self('Naayf'); + } + + public static function AISHA__BETA(): CallVoice + { + return new self('Aisha (beta)'); + } + + public static function FAROOQ__BETA(): CallVoice + { + return new self('Farooq (beta)'); + } + + public static function HUSSEIN__BETA(): CallVoice + { + return new self('Hussein (beta)'); + } + + public static function AMAL__BETA(): CallVoice + { + return new self('Amal (beta)'); + } + + public static function SAYAN__BETA(): CallVoice + { + return new self('Sayan (beta)'); + } + + public static function SUSHMITA__BETA(): CallVoice + { + return new self('Sushmita (beta)'); + } + + public static function IVAN(): CallVoice + { + return new self('Ivan'); + } + + public static function CONCHITA(): CallVoice + { + return new self('Conchita'); + } + + public static function HERENA(): CallVoice + { + return new self('Herena'); + } + + public static function HUIHUI(): CallVoice + { + return new self('Huihui'); + } + + public static function ZHIYU(): CallVoice + { + return new self('Zhiyu'); + } + + public static function YAOYAO(): CallVoice + { + return new self('Yaoyao'); + } + + public static function KANGKANG(): CallVoice + { + return new self('Kangkang'); + } + + public static function LIU__BETA(): CallVoice + { + return new self('Liu (beta)'); + } + + public static function WANG__BETA(): CallVoice + { + return new self('Wang (beta)'); + } + + public static function ZHANG__BETA(): CallVoice + { + return new self('Zhang (beta)'); + } + + public static function LIN__BETA(): CallVoice + { + return new self('Lin (beta)'); + } + + public static function AKEMI__BETA(): CallVoice + { + return new self('Akemi (beta)'); + } + + public static function CHEN__BETA(): CallVoice + { + return new self('Chen (beta)'); + } + + public static function HUANG__BETA(): CallVoice + { + return new self('Huang (beta)'); + } + + public static function DANNY(): CallVoice + { + return new self('Danny'); + } + + public static function TRACY(): CallVoice + { + return new self('Tracy'); + } + + public static function HANHAN(): CallVoice + { + return new self('Hanhan'); + } + + public static function ZHIWEI(): CallVoice + { + return new self('Zhiwei'); + } + + public static function YATING(): CallVoice + { + return new self('Yating'); + } + + public static function MATEJ(): CallVoice + { + return new self('Matej'); + } + + public static function JAKUB(): CallVoice + { + return new self('Jakub'); + } + + public static function HELLE(): CallVoice + { + return new self('Helle'); + } + + public static function NAJA(): CallVoice + { + return new self('Naja'); + } + + public static function MADS(): CallVoice + { + return new self('Mads'); + } + + public static function RUBEN(): CallVoice + { + return new self('Ruben'); + } + + public static function LOTTE(): CallVoice + { + return new self('Lotte'); + } + + public static function HANNA(): CallVoice + { + return new self('Hanna'); + } + + public static function JOANNA(): CallVoice + { + return new self('Joanna'); + } + + public static function ZIRA(): CallVoice + { + return new self('Zira'); + } + + public static function IVY(): CallVoice + { + return new self('Ivy'); + } + + public static function KENDRA(): CallVoice + { + return new self('Kendra'); + } + + public static function KIMBERLY(): CallVoice + { + return new self('Kimberly'); + } + + public static function SALLI(): CallVoice + { + return new self('Salli'); + } + + public static function JOEY(): CallVoice + { + return new self('Joey'); + } + + public static function JUSTIN(): CallVoice + { + return new self('Justin'); + } + + public static function MATTHEW(): CallVoice + { + return new self('Matthew'); + } + + public static function BENJAMIN(): CallVoice + { + return new self('Benjamin'); + } + + public static function JESSICA(): CallVoice + { + return new self('Jessica'); + } + + public static function JANE(): CallVoice + { + return new self('Jane'); + } + + public static function GUY(): CallVoice + { + return new self('Guy'); + } + + public static function RUSSELL(): CallVoice + { + return new self('Russell'); + } + + public static function CATHERINE(): CallVoice + { + return new self('Catherine'); + } + + public static function NICOLE(): CallVoice + { + return new self('Nicole'); + } + + public static function HAYLEY(): CallVoice + { + return new self('Hayley'); + } + + public static function BRIAN(): CallVoice + { + return new self('Brian'); + } + + public static function HAZEL(): CallVoice + { + return new self('Hazel'); + } + + public static function AMY(): CallVoice + { + return new self('Amy'); + } + + public static function EMMA(): CallVoice + { + return new self('Emma'); + } + + public static function ROSIE(): CallVoice + { + return new self('Rosie'); + } + + public static function GEORGE(): CallVoice + { + return new self('George'); + } + + public static function HEATHER(): CallVoice + { + return new self('Heather'); + } + + public static function ALICE(): CallVoice + { + return new self('Alice'); + } + + public static function HEERA(): CallVoice + { + return new self('Heera'); + } + + public static function ADITI(): CallVoice + { + return new self('Aditi'); + } + + public static function RAVEENA(): CallVoice + { + return new self('Raveena'); + } + + public static function PRIYA(): CallVoice + { + return new self('Priya'); + } + + public static function RAVI(): CallVoice + { + return new self('Ravi'); + } + + public static function SEAN(): CallVoice + { + return new self('Sean'); + } + + public static function GERAINT(): CallVoice + { + return new self('Geraint'); + } + + public static function HEIDI(): CallVoice + { + return new self('Heidi'); + } + + public static function EVELIN__BETA(): CallVoice + { + return new self('Evelin (beta)'); + } + + public static function HORTENSE(): CallVoice + { + return new self('Hortense'); + } + + public static function CELINE(): CallVoice + { + return new self('Celine'); + } + + public static function LEA(): CallVoice + { + return new self('Lea'); + } + + public static function MATHIEU(): CallVoice + { + return new self('Mathieu'); + } + + public static function JULIETTE(): CallVoice + { + return new self('Juliette'); + } + + public static function PICARD(): CallVoice + { + return new self('Picard'); + } + + public static function CAROLINE(): CallVoice + { + return new self('Caroline'); + } + + public static function HARMONIE(): CallVoice + { + return new self('Harmonie'); + } + + public static function CHANTAL(): CallVoice + { + return new self('Chantal'); + } + + public static function GUILLAUME(): CallVoice + { + return new self('Guillaume'); + } + + public static function VICKI(): CallVoice + { + return new self('Vicki'); + } + + public static function HANS(): CallVoice + { + return new self('Hans'); + } + + public static function STEFAN(): CallVoice + { + return new self('Stefan'); + } + + public static function MARLENE(): CallVoice + { + return new self('Marlene'); + } + + public static function HEDDA(): CallVoice + { + return new self('Hedda'); + } + + public static function ANGELA(): CallVoice + { + return new self('Angela'); + } + + public static function MICHAEL(): CallVoice + { + return new self('Michael'); + } + + public static function KARSTEN(): CallVoice + { + return new self('Karsten'); + } + + public static function STEFANOS(): CallVoice + { + return new self('Stefanos'); + } + + public static function SOPHIA__BETA(): CallVoice + { + return new self('Sophia (beta)'); + } + + public static function DINESH__BETA(): CallVoice + { + return new self('Dinesh (beta)'); + } + + public static function LEELA__BETA(): CallVoice + { + return new self('Leela (beta)'); + } + + public static function ASAF(): CallVoice + { + return new self('Asaf'); + } + + public static function AADITA(): CallVoice + { + return new self('Aadita'); + } + + public static function KALPANA(): CallVoice + { + return new self('Kalpana'); + } + + public static function HEMANT(): CallVoice + { + return new self('Hemant'); + } + + public static function SZABOLCS(): CallVoice + { + return new self('Szabolcs'); + } + + public static function DORA(): CallVoice + { + return new self('Dora'); + } + + public static function KARL(): CallVoice + { + return new self('Karl'); + } + + public static function INDAH__BETA(): CallVoice + { + return new self('Indah (beta)'); + } + + public static function ARIF__BETA(): CallVoice + { + return new self('Arif (beta)'); + } + + public static function REZA__BETA(): CallVoice + { + return new self('Reza (beta)'); + } + + public static function ANDIKA(): CallVoice + { + return new self('Andika'); + } + + public static function NURUL__BETA(): CallVoice + { + return new self('Nurul (beta)'); + } + + public static function GIANNA__BETA(): CallVoice + { + return new self('Gianna (beta)'); + } + + public static function COSIMO(): CallVoice + { + return new self('Cosimo'); + } + + public static function CARLA(): CallVoice + { + return new self('Carla'); + } + + public static function BIANCA(): CallVoice + { + return new self('Bianca'); + } + + public static function GIORGIO(): CallVoice + { + return new self('Giorgio'); + } + + public static function LUCIA(): CallVoice + { + return new self('Lucia'); + } + + public static function TAKUMI(): CallVoice + { + return new self('Takumi'); + } + + public static function HARUKA(): CallVoice + { + return new self('Haruka'); + } + + public static function ICHIRO(): CallVoice + { + return new self('Ichiro'); + } + + public static function MIZUKI(): CallVoice + { + return new self('Mizuki'); + } + + public static function AYUMI(): CallVoice + { + return new self('Ayumi'); + } + + public static function SHASHANK__BETA(): CallVoice + { + return new self('Shashank (beta)'); + } + + public static function NAMRATHA__BETA(): CallVoice + { + return new self('Namratha (beta)'); + } + + public static function SEOYEON(): CallVoice + { + return new self('Seoyeon'); + } + + public static function HEAMI(): CallVoice + { + return new self('Heami'); + } + + public static function SUMI__BETA(): CallVoice + { + return new self('Sumi (beta)'); + } + + public static function JINA__BETA(): CallVoice + { + return new self('Jina (beta)'); + } + + public static function HIMCHAN__BETA(): CallVoice + { + return new self('Himchan (beta)'); + } + + public static function MINHO__BETA(): CallVoice + { + return new self('Minho (beta)'); + } + + public static function RIZWAN(): CallVoice + { + return new self('Rizwan'); + } + + public static function VISHNU__BETA(): CallVoice + { + return new self('Vishnu (beta)'); + } + + public static function KIRTI__BETA(): CallVoice + { + return new self('Kirti (beta)'); + } + + public static function HULDA(): CallVoice + { + return new self('Hulda'); + } + + public static function LIV(): CallVoice + { + return new self('Liv'); + } + + public static function EWA(): CallVoice + { + return new self('Ewa'); + } + + public static function PAULINA(): CallVoice + { + return new self('Paulina'); + } + + public static function MAJA(): CallVoice + { + return new self('Maja'); + } + + public static function JACEK(): CallVoice + { + return new self('Jacek'); + } + + public static function JAN(): CallVoice + { + return new self('Jan'); + } + + public static function CRISTIANO(): CallVoice + { + return new self('Cristiano'); + } + + public static function HELIA(): CallVoice + { + return new self('Helia'); + } + + public static function INES(): CallVoice + { + return new self('Ines'); + } + + public static function ABRIELLE__BETA(): CallVoice + { + return new self('Abrielle (beta)'); + } + + public static function HENRIQUES__BETA(): CallVoice + { + return new self('Henriques (beta)'); + } + + public static function JERALDO__BETA(): CallVoice + { + return new self('Jeraldo (beta)'); + } + + public static function JACINDA__BETA(): CallVoice + { + return new self('Jacinda (beta)'); + } + + public static function CAMILA(): CallVoice + { + return new self('Camila'); + } + + public static function RICARDO(): CallVoice + { + return new self('Ricardo'); + } + + public static function DANIEL(): CallVoice + { + return new self('Daniel'); + } + + public static function VITORIA(): CallVoice + { + return new self('Vitoria'); + } + + public static function HELOISA(): CallVoice + { + return new self('Heloisa'); + } + + public static function CARMEN(): CallVoice + { + return new self('Carmen'); + } + + public static function ANDREI(): CallVoice + { + return new self('Andrei'); + } + + public static function MAXIM(): CallVoice + { + return new self('Maxim'); + } + + public static function EKATERINA(): CallVoice + { + return new self('Ekaterina'); + } + + public static function PAVEL(): CallVoice + { + return new self('Pavel'); + } + + public static function TATYANA(): CallVoice + { + return new self('Tatyana'); + } + + public static function IRINA(): CallVoice + { + return new self('Irina'); + } + + public static function FILIP(): CallVoice + { + return new self('Filip'); + } + + public static function LADO(): CallVoice + { + return new self('Lado'); + } + + public static function MIGUEL(): CallVoice + { + return new self('Miguel'); + } + + public static function LINDA(): CallVoice + { + return new self('Linda'); + } + + public static function ENRIQUE(): CallVoice + { + return new self('Enrique'); + } + + public static function JUANA(): CallVoice + { + return new self('Juana'); + } + + public static function PABLO(): CallVoice + { + return new self('Pablo'); + } + + public static function GABRIELA__BETA(): CallVoice + { + return new self('Gabriela (beta)'); + } + + public static function LUPE(): CallVoice + { + return new self('Lupe'); + } + + public static function LAURA(): CallVoice + { + return new self('Laura'); + } + + public static function PENELOPE(): CallVoice + { + return new self('Penelope'); + } + + public static function HILDA(): CallVoice + { + return new self('Hilda'); + } + + public static function RAUL(): CallVoice + { + return new self('Raul'); + } + + public static function MIA(): CallVoice + { + return new self('Mia'); + } + + public static function HEDVIG(): CallVoice + { + return new self('Hedvig'); + } + + public static function ASTRID(): CallVoice + { + return new self('Astrid'); + } + + public static function VALLUVAR(): CallVoice + { + return new self('Valluvar'); + } + + public static function GANESH__BETA(): CallVoice + { + return new self('Ganesh (beta)'); + } + + public static function SHRUTI__BETA(): CallVoice + { + return new self('Shruti (beta)'); + } + + public static function CHITRA(): CallVoice + { + return new self('Chitra'); + } + + public static function VIJAY__BETA(): CallVoice + { + return new self('Vijay (beta)'); + } + + public static function SAMANTHA__BETA(): CallVoice + { + return new self('Samantha (beta)'); + } + + public static function NATCHAYA__BETA(): CallVoice + { + return new self('Natchaya (beta)'); + } + + public static function PATTARA(): CallVoice + { + return new self('Pattara'); + } + + public static function SEDA(): CallVoice + { + return new self('Seda'); + } + + public static function FILIZ(): CallVoice + { + return new self('Filiz'); + } + + public static function ULYANA(): CallVoice + { + return new self('Ulyana'); + } + + public static function AN(): CallVoice + { + return new self('An'); + } + + public static function LIEN__BETA(): CallVoice + { + return new self('Lien (beta)'); + } + + public static function QUAN__BETA(): CallVoice + { + return new self('Quan (beta)'); + } + + public static function MAI__BETA(): CallVoice + { + return new self('Mai (beta)'); + } + + public static function TUAN__BETA(): CallVoice + { + return new self('Tuan (beta)'); + } + + public static function GWYNETH(): CallVoice + { + return new self('Gwyneth'); + } + + public function __toString(): string + { + return $this->value; + } +} diff --git a/Infobip/Model/CallsActionCallRequest.php b/Infobip/Model/CallsActionCallRequest.php new file mode 100644 index 0000000..da721f1 --- /dev/null +++ b/Infobip/Model/CallsActionCallRequest.php @@ -0,0 +1,172 @@ + null, + 'from' => null, + 'fromDisplayName' => null, + 'connectTimeout' => 'int32', + 'recording' => null, + 'machineDetection' => null, + 'maxDuration' => 'int32', + 'customData' => null + ]; + + /** + * @param array $customData + */ + public function __construct( + #[Assert\Valid] + #[Assert\NotBlank] + + protected \Infobip\Model\CallEndpoint $endpoint, + #[Assert\NotBlank] + + protected string $from, + protected ?string $fromDisplayName = null, + protected ?int $connectTimeout = null, + #[Assert\Valid] + + protected ?\Infobip\Model\CallRecordingRequest $recording = null, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsMachineDetectionRequest $machineDetection = null, + protected ?int $maxDuration = 28800, + protected ?array $customData = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getEndpoint(): \Infobip\Model\CallEndpoint + { + return $this->endpoint; + } + + public function setEndpoint(\Infobip\Model\CallEndpoint $endpoint): self + { + $this->endpoint = $endpoint; + return $this; + } + + public function getFrom(): string + { + return $this->from; + } + + public function setFrom(string $from): self + { + $this->from = $from; + return $this; + } + + public function getFromDisplayName(): string|null + { + return $this->fromDisplayName; + } + + public function setFromDisplayName(?string $fromDisplayName): self + { + $this->fromDisplayName = $fromDisplayName; + return $this; + } + + public function getConnectTimeout(): int|null + { + return $this->connectTimeout; + } + + public function setConnectTimeout(?int $connectTimeout): self + { + $this->connectTimeout = $connectTimeout; + return $this; + } + + public function getRecording(): \Infobip\Model\CallRecordingRequest|null + { + return $this->recording; + } + + public function setRecording(?\Infobip\Model\CallRecordingRequest $recording): self + { + $this->recording = $recording; + return $this; + } + + public function getMachineDetection(): \Infobip\Model\CallsMachineDetectionRequest|null + { + return $this->machineDetection; + } + + public function setMachineDetection(?\Infobip\Model\CallsMachineDetectionRequest $machineDetection): self + { + $this->machineDetection = $machineDetection; + return $this; + } + + public function getMaxDuration(): int|null + { + return $this->maxDuration; + } + + public function setMaxDuration(?int $maxDuration): self + { + $this->maxDuration = $maxDuration; + return $this; + } + + /** + * @return array|null + */ + public function getCustomData() + { + return $this->customData; + } + + /** + * @param array|null $customData Custom data. + */ + public function setCustomData(?array $customData): self + { + $this->customData = $customData; + return $this; + } +} diff --git a/Infobip/Model/CallsActionConferenceRequest.php b/Infobip/Model/CallsActionConferenceRequest.php new file mode 100644 index 0000000..6f2d46d --- /dev/null +++ b/Infobip/Model/CallsActionConferenceRequest.php @@ -0,0 +1,93 @@ + null, + 'recording' => null, + 'maxDuration' => 'int32' + ]; + + /** + */ + public function __construct( + protected ?string $name = null, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsConferenceRecordingRequest $recording = null, + protected ?int $maxDuration = 28800, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getName(): string|null + { + return $this->name; + } + + public function setName(?string $name): self + { + $this->name = $name; + return $this; + } + + public function getRecording(): \Infobip\Model\CallsConferenceRecordingRequest|null + { + return $this->recording; + } + + public function setRecording(?\Infobip\Model\CallsConferenceRecordingRequest $recording): self + { + $this->recording = $recording; + return $this; + } + + public function getMaxDuration(): int|null + { + return $this->maxDuration; + } + + public function setMaxDuration(?int $maxDuration): self + { + $this->maxDuration = $maxDuration; + return $this; + } +} diff --git a/Infobip/Model/CallsActionResponse.php b/Infobip/Model/CallsActionResponse.php new file mode 100644 index 0000000..234de7a --- /dev/null +++ b/Infobip/Model/CallsActionResponse.php @@ -0,0 +1,67 @@ + null + ]; + + /** + */ + public function __construct( + #[Assert\Choice(['PENDING','IN_PROGRESS','COMPLETED','FAILED',])] + + protected ?string $status = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getStatus(): mixed + { + return $this->status; + } + + public function setStatus($status): self + { + $this->status = $status; + return $this; + } +} diff --git a/Infobip/Model/CallsActionStatus.php b/Infobip/Model/CallsActionStatus.php new file mode 100644 index 0000000..9d76f08 --- /dev/null +++ b/Infobip/Model/CallsActionStatus.php @@ -0,0 +1,78 @@ +value = $value; + } + + public static function PENDING(): CallsActionStatus + { + return new self('PENDING'); + } + + public static function IN_PROGRESS(): CallsActionStatus + { + return new self('IN_PROGRESS'); + } + + public static function COMPLETED(): CallsActionStatus + { + return new self('COMPLETED'); + } + + public static function FAILED(): CallsActionStatus + { + return new self('FAILED'); + } + + public function __toString(): string + { + return $this->value; + } +} diff --git a/Infobip/Model/CallsAddExistingCallRequest.php b/Infobip/Model/CallsAddExistingCallRequest.php new file mode 100644 index 0000000..35cfef9 --- /dev/null +++ b/Infobip/Model/CallsAddExistingCallRequest.php @@ -0,0 +1,65 @@ + null + ]; + + /** + */ + public function __construct( + protected ?bool $connectOnEarlyMedia = false, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getConnectOnEarlyMedia(): bool|null + { + return $this->connectOnEarlyMedia; + } + + public function setConnectOnEarlyMedia(?bool $connectOnEarlyMedia): self + { + $this->connectOnEarlyMedia = $connectOnEarlyMedia; + return $this; + } +} diff --git a/Infobip/Model/CallsAddNewCallRequest.php b/Infobip/Model/CallsAddNewCallRequest.php new file mode 100644 index 0000000..d8ca519 --- /dev/null +++ b/Infobip/Model/CallsAddNewCallRequest.php @@ -0,0 +1,81 @@ + null, + 'connectOnEarlyMedia' => null + ]; + + /** + */ + public function __construct( + #[Assert\Valid] + #[Assert\NotBlank] + + protected \Infobip\Model\CallsActionCallRequest $callRequest, + protected ?bool $connectOnEarlyMedia = false, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getCallRequest(): \Infobip\Model\CallsActionCallRequest + { + return $this->callRequest; + } + + public function setCallRequest(\Infobip\Model\CallsActionCallRequest $callRequest): self + { + $this->callRequest = $callRequest; + return $this; + } + + public function getConnectOnEarlyMedia(): bool|null + { + return $this->connectOnEarlyMedia; + } + + public function setConnectOnEarlyMedia(?bool $connectOnEarlyMedia): self + { + $this->connectOnEarlyMedia = $connectOnEarlyMedia; + return $this; + } +} diff --git a/Infobip/Model/CallsAdvancedBody.php b/Infobip/Model/CallsAdvancedBody.php new file mode 100644 index 0000000..00c19e5 --- /dev/null +++ b/Infobip/Model/CallsAdvancedBody.php @@ -0,0 +1,87 @@ + null, + 'messages' => null + ]; + + /** + * @param \Infobip\Model\CallsAdvancedMessage[] $messages + */ + public function __construct( + #[Assert\NotBlank] + + protected array $messages, + protected ?string $bulkId = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getBulkId(): string|null + { + return $this->bulkId; + } + + public function setBulkId(?string $bulkId): self + { + $this->bulkId = $bulkId; + return $this; + } + + /** + * @return \Infobip\Model\CallsAdvancedMessage[] + */ + public function getMessages(): array + { + return $this->messages; + } + + /** + * @param \Infobip\Model\CallsAdvancedMessage[] $messages Array of messages to be sent, one object per every message + */ + public function setMessages(array $messages): self + { + $this->messages = $messages; + return $this; + } +} diff --git a/Infobip/Model/CallsAdvancedMessage.php b/Infobip/Model/CallsAdvancedMessage.php new file mode 100644 index 0000000..1c84978 --- /dev/null +++ b/Infobip/Model/CallsAdvancedMessage.php @@ -0,0 +1,403 @@ + null, + 'callTimeout' => 'int32', + 'callTransfers' => null, + 'callbackData' => null, + 'deliveryTimeWindow' => null, + 'destinations' => null, + 'dtmfTimeout' => 'int32', + 'from' => null, + 'language' => null, + 'machineDetection' => null, + 'maxDtmf' => 'int32', + 'notifyContentType' => null, + 'notifyContentVersion' => 'int32', + 'notifyUrl' => null, + 'pause' => 'int32', + 'record' => null, + 'repeatDtmf' => null, + 'retry' => null, + 'ringTimeout' => 'int32', + 'sendAt' => 'date-time', + 'sendingSpeed' => null, + 'speechRate' => 'double', + 'text' => null, + 'validityPeriod' => 'int32', + 'voice' => null + ]; + + /** + * @param \Infobip\Model\CallTransfer[] $callTransfers + * @param \Infobip\Model\CallsDestination[] $destinations + */ + public function __construct( + #[Assert\NotBlank] + + protected array $destinations, + protected ?string $audioFileUrl = null, + protected ?int $callTimeout = null, + protected ?array $callTransfers = null, + protected ?string $callbackData = null, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsDeliveryTimeWindow $deliveryTimeWindow = null, + protected ?int $dtmfTimeout = null, + protected ?string $from = null, + protected ?string $language = null, + protected ?string $machineDetection = null, + protected ?int $maxDtmf = null, + protected ?string $notifyContentType = null, + protected ?int $notifyContentVersion = null, + protected ?string $notifyUrl = null, + protected ?int $pause = null, + protected ?bool $record = null, + protected ?string $repeatDtmf = null, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsRetry $retry = null, + protected ?int $ringTimeout = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $sendAt = null, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsSendingSpeed $sendingSpeed = null, + protected ?float $speechRate = null, + protected ?string $text = null, + protected ?int $validityPeriod = null, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsVoice $voice = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getAudioFileUrl(): string|null + { + return $this->audioFileUrl; + } + + public function setAudioFileUrl(?string $audioFileUrl): self + { + $this->audioFileUrl = $audioFileUrl; + return $this; + } + + public function getCallTimeout(): int|null + { + return $this->callTimeout; + } + + public function setCallTimeout(?int $callTimeout): self + { + $this->callTimeout = $callTimeout; + return $this; + } + + /** + * @return \Infobip\Model\CallTransfer[]|null + */ + public function getCallTransfers(): ?array + { + return $this->callTransfers; + } + + /** + * @param \Infobip\Model\CallTransfer[]|null $callTransfers Call transfers object enables transferring the ongoing call to another recipient(s) and establish a communication between your original recipient and additional one. + */ + public function setCallTransfers(?array $callTransfers): self + { + $this->callTransfers = $callTransfers; + return $this; + } + + public function getCallbackData(): string|null + { + return $this->callbackData; + } + + public function setCallbackData(?string $callbackData): self + { + $this->callbackData = $callbackData; + return $this; + } + + public function getDeliveryTimeWindow(): \Infobip\Model\CallsDeliveryTimeWindow|null + { + return $this->deliveryTimeWindow; + } + + public function setDeliveryTimeWindow(?\Infobip\Model\CallsDeliveryTimeWindow $deliveryTimeWindow): self + { + $this->deliveryTimeWindow = $deliveryTimeWindow; + return $this; + } + + /** + * @return \Infobip\Model\CallsDestination[] + */ + public function getDestinations(): array + { + return $this->destinations; + } + + /** + * @param \Infobip\Model\CallsDestination[] $destinations Message destination addresses. Destination address must be in the E.164 standard format (Example: 41793026727). + */ + public function setDestinations(array $destinations): self + { + $this->destinations = $destinations; + return $this; + } + + public function getDtmfTimeout(): int|null + { + return $this->dtmfTimeout; + } + + public function setDtmfTimeout(?int $dtmfTimeout): self + { + $this->dtmfTimeout = $dtmfTimeout; + return $this; + } + + public function getFrom(): string|null + { + return $this->from; + } + + public function setFrom(?string $from): self + { + $this->from = $from; + return $this; + } + + public function getLanguage(): string|null + { + return $this->language; + } + + public function setLanguage(?string $language): self + { + $this->language = $language; + return $this; + } + + public function getMachineDetection(): string|null + { + return $this->machineDetection; + } + + public function setMachineDetection(?string $machineDetection): self + { + $this->machineDetection = $machineDetection; + return $this; + } + + public function getMaxDtmf(): int|null + { + return $this->maxDtmf; + } + + public function setMaxDtmf(?int $maxDtmf): self + { + $this->maxDtmf = $maxDtmf; + return $this; + } + + public function getNotifyContentType(): string|null + { + return $this->notifyContentType; + } + + public function setNotifyContentType(?string $notifyContentType): self + { + $this->notifyContentType = $notifyContentType; + return $this; + } + + public function getNotifyContentVersion(): int|null + { + return $this->notifyContentVersion; + } + + public function setNotifyContentVersion(?int $notifyContentVersion): self + { + $this->notifyContentVersion = $notifyContentVersion; + return $this; + } + + public function getNotifyUrl(): string|null + { + return $this->notifyUrl; + } + + public function setNotifyUrl(?string $notifyUrl): self + { + $this->notifyUrl = $notifyUrl; + return $this; + } + + public function getPause(): int|null + { + return $this->pause; + } + + public function setPause(?int $pause): self + { + $this->pause = $pause; + return $this; + } + + public function getRecord(): bool|null + { + return $this->record; + } + + public function setRecord(?bool $record): self + { + $this->record = $record; + return $this; + } + + public function getRepeatDtmf(): string|null + { + return $this->repeatDtmf; + } + + public function setRepeatDtmf(?string $repeatDtmf): self + { + $this->repeatDtmf = $repeatDtmf; + return $this; + } + + public function getRetry(): \Infobip\Model\CallsRetry|null + { + return $this->retry; + } + + public function setRetry(?\Infobip\Model\CallsRetry $retry): self + { + $this->retry = $retry; + return $this; + } + + public function getRingTimeout(): int|null + { + return $this->ringTimeout; + } + + public function setRingTimeout(?int $ringTimeout): self + { + $this->ringTimeout = $ringTimeout; + return $this; + } + + public function getSendAt(): \DateTime|null + { + return $this->sendAt; + } + + public function setSendAt(?\DateTime $sendAt): self + { + $this->sendAt = $sendAt; + return $this; + } + + public function getSendingSpeed(): \Infobip\Model\CallsSendingSpeed|null + { + return $this->sendingSpeed; + } + + public function setSendingSpeed(?\Infobip\Model\CallsSendingSpeed $sendingSpeed): self + { + $this->sendingSpeed = $sendingSpeed; + return $this; + } + + public function getSpeechRate(): float|null + { + return $this->speechRate; + } + + public function setSpeechRate(?float $speechRate): self + { + $this->speechRate = $speechRate; + return $this; + } + + public function getText(): string|null + { + return $this->text; + } + + public function setText(?string $text): self + { + $this->text = $text; + return $this; + } + + public function getValidityPeriod(): int|null + { + return $this->validityPeriod; + } + + public function setValidityPeriod(?int $validityPeriod): self + { + $this->validityPeriod = $validityPeriod; + return $this; + } + + public function getVoice(): \Infobip\Model\CallsVoice|null + { + return $this->voice; + } + + public function setVoice(?\Infobip\Model\CallsVoice $voice): self + { + $this->voice = $voice; + return $this; + } +} diff --git a/Infobip/Model/CallsAnswerRequest.php b/Infobip/Model/CallsAnswerRequest.php new file mode 100644 index 0000000..4b1eb46 --- /dev/null +++ b/Infobip/Model/CallsAnswerRequest.php @@ -0,0 +1,67 @@ + null + ]; + + /** + */ + public function __construct( + #[Assert\Valid] + + protected ?\Infobip\Model\CallRecordingRequest $recording = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getRecording(): \Infobip\Model\CallRecordingRequest|null + { + return $this->recording; + } + + public function setRecording(?\Infobip\Model\CallRecordingRequest $recording): self + { + $this->recording = $recording; + return $this; + } +} diff --git a/Infobip/Model/CallsApplicationTransferRequest.php b/Infobip/Model/CallsApplicationTransferRequest.php new file mode 100644 index 0000000..4367093 --- /dev/null +++ b/Infobip/Model/CallsApplicationTransferRequest.php @@ -0,0 +1,100 @@ + null, + 'timeout' => 'int32', + 'context' => null + ]; + + /** + * @param array $context + */ + public function __construct( + #[Assert\NotBlank] + + protected string $destinationApplicationId, + protected ?int $timeout = 30, + protected ?array $context = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getDestinationApplicationId(): string + { + return $this->destinationApplicationId; + } + + public function setDestinationApplicationId(string $destinationApplicationId): self + { + $this->destinationApplicationId = $destinationApplicationId; + return $this; + } + + public function getTimeout(): int|null + { + return $this->timeout; + } + + public function setTimeout(?int $timeout): self + { + $this->timeout = $timeout; + return $this; + } + + /** + * @return array|null + */ + public function getContext() + { + return $this->context; + } + + /** + * @param array|null $context Client defined data to be passed to the destination application. + */ + public function setContext(?array $context): self + { + $this->context = $context; + return $this; + } +} diff --git a/Infobip/Model/CallsAudioMediaProperties.php b/Infobip/Model/CallsAudioMediaProperties.php new file mode 100644 index 0000000..35639a3 --- /dev/null +++ b/Infobip/Model/CallsAudioMediaProperties.php @@ -0,0 +1,91 @@ + null, + 'userMuted' => null, + 'deaf' => null + ]; + + /** + */ + public function __construct( + protected ?bool $muted = null, + protected ?bool $userMuted = null, + protected ?bool $deaf = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getMuted(): bool|null + { + return $this->muted; + } + + public function setMuted(?bool $muted): self + { + $this->muted = $muted; + return $this; + } + + public function getUserMuted(): bool|null + { + return $this->userMuted; + } + + public function setUserMuted(?bool $userMuted): self + { + $this->userMuted = $userMuted; + return $this; + } + + public function getDeaf(): bool|null + { + return $this->deaf; + } + + public function setDeaf(?bool $deaf): self + { + $this->deaf = $deaf; + return $this; + } +} diff --git a/Infobip/Model/CallsBasicUrlSecurityConfig.php b/Infobip/Model/CallsBasicUrlSecurityConfig.php new file mode 100644 index 0000000..b7aa5fb --- /dev/null +++ b/Infobip/Model/CallsBasicUrlSecurityConfig.php @@ -0,0 +1,88 @@ + null, + 'password' => null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + + protected string $username, + #[Assert\NotBlank] + + protected string $password, + ) { + $modelDiscriminatorValue = 'BASIC'; + + parent::__construct( + type: $modelDiscriminatorValue, + ); + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getUsername(): string + { + return $this->username; + } + + public function setUsername(string $username): self + { + $this->username = $username; + return $this; + } + + public function getPassword(): string + { + return $this->password; + } + + public function setPassword(string $password): self + { + $this->password = $password; + return $this; + } +} diff --git a/Infobip/Model/CallsBulkCall.php b/Infobip/Model/CallsBulkCall.php new file mode 100644 index 0000000..207c19c --- /dev/null +++ b/Infobip/Model/CallsBulkCall.php @@ -0,0 +1,147 @@ + null, + 'callId' => null, + 'externalId' => null, + 'from' => null, + 'endpoint' => null, + 'status' => null, + 'reason' => null + ]; + + /** + */ + public function __construct( + protected ?string $applicationId = null, + protected ?string $callId = null, + protected ?string $externalId = null, + protected ?string $from = null, + #[Assert\Valid] + + protected ?\Infobip\Model\CallEndpoint $endpoint = null, + #[Assert\Choice(['PENDING','IN_PROGRESS','COMPLETED','FAILED',])] + + protected ?string $status = null, + protected ?string $reason = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getApplicationId(): string|null + { + return $this->applicationId; + } + + public function setApplicationId(?string $applicationId): self + { + $this->applicationId = $applicationId; + return $this; + } + + public function getCallId(): string|null + { + return $this->callId; + } + + public function setCallId(?string $callId): self + { + $this->callId = $callId; + return $this; + } + + public function getExternalId(): string|null + { + return $this->externalId; + } + + public function setExternalId(?string $externalId): self + { + $this->externalId = $externalId; + return $this; + } + + public function getFrom(): string|null + { + return $this->from; + } + + public function setFrom(?string $from): self + { + $this->from = $from; + return $this; + } + + public function getEndpoint(): \Infobip\Model\CallEndpoint|null + { + return $this->endpoint; + } + + public function setEndpoint(?\Infobip\Model\CallEndpoint $endpoint): self + { + $this->endpoint = $endpoint; + return $this; + } + + public function getStatus(): mixed + { + return $this->status; + } + + public function setStatus($status): self + { + $this->status = $status; + return $this; + } + + public function getReason(): string|null + { + return $this->reason; + } + + public function setReason(?string $reason): self + { + $this->reason = $reason; + return $this; + } +} diff --git a/Infobip/Model/CallsBulkCallRequest.php b/Infobip/Model/CallsBulkCallRequest.php new file mode 100644 index 0000000..7a0d09c --- /dev/null +++ b/Infobip/Model/CallsBulkCallRequest.php @@ -0,0 +1,81 @@ + null, + 'endpoint' => null + ]; + + /** + */ + public function __construct( + #[Assert\Valid] + #[Assert\NotBlank] + + protected \Infobip\Model\CallEndpoint $endpoint, + protected ?string $externalId = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getExternalId(): string|null + { + return $this->externalId; + } + + public function setExternalId(?string $externalId): self + { + $this->externalId = $externalId; + return $this; + } + + public function getEndpoint(): \Infobip\Model\CallEndpoint + { + return $this->endpoint; + } + + public function setEndpoint(\Infobip\Model\CallEndpoint $endpoint): self + { + $this->endpoint = $endpoint; + return $this; + } +} diff --git a/Infobip/Model/CallsBulkItem.php b/Infobip/Model/CallsBulkItem.php new file mode 100644 index 0000000..ec6b53d --- /dev/null +++ b/Infobip/Model/CallsBulkItem.php @@ -0,0 +1,223 @@ + null, + 'callRequests' => null, + 'recording' => null, + 'machineDetection' => null, + 'maxDuration' => 'int32', + 'connectTimeout' => 'int32', + 'callRate' => null, + 'validityPeriod' => 'int32', + 'retryOptions' => null, + 'schedulingOptions' => null, + 'customData' => null + ]; + + /** + * @param \Infobip\Model\CallsBulkCallRequest[] $callRequests + * @param array $customData + */ + public function __construct( + #[Assert\NotBlank] + + protected string $from, + #[Assert\NotBlank] + + protected array $callRequests, + #[Assert\Valid] + + protected ?\Infobip\Model\CallRecordingRequest $recording = null, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsMachineDetectionRequest $machineDetection = null, + protected ?int $maxDuration = 28800, + protected ?int $connectTimeout = null, + #[Assert\Valid] + + protected ?\Infobip\Model\CallRate $callRate = null, + protected ?int $validityPeriod = null, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsRetryOptions $retryOptions = null, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsSchedulingOptions $schedulingOptions = null, + protected ?array $customData = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getFrom(): string + { + return $this->from; + } + + public function setFrom(string $from): self + { + $this->from = $from; + return $this; + } + + /** + * @return \Infobip\Model\CallsBulkCallRequest[] + */ + public function getCallRequests(): array + { + return $this->callRequests; + } + + /** + * @param \Infobip\Model\CallsBulkCallRequest[] $callRequests Call request list. + */ + public function setCallRequests(array $callRequests): self + { + $this->callRequests = $callRequests; + return $this; + } + + public function getRecording(): \Infobip\Model\CallRecordingRequest|null + { + return $this->recording; + } + + public function setRecording(?\Infobip\Model\CallRecordingRequest $recording): self + { + $this->recording = $recording; + return $this; + } + + public function getMachineDetection(): \Infobip\Model\CallsMachineDetectionRequest|null + { + return $this->machineDetection; + } + + public function setMachineDetection(?\Infobip\Model\CallsMachineDetectionRequest $machineDetection): self + { + $this->machineDetection = $machineDetection; + return $this; + } + + public function getMaxDuration(): int|null + { + return $this->maxDuration; + } + + public function setMaxDuration(?int $maxDuration): self + { + $this->maxDuration = $maxDuration; + return $this; + } + + public function getConnectTimeout(): int|null + { + return $this->connectTimeout; + } + + public function setConnectTimeout(?int $connectTimeout): self + { + $this->connectTimeout = $connectTimeout; + return $this; + } + + public function getCallRate(): \Infobip\Model\CallRate|null + { + return $this->callRate; + } + + public function setCallRate(?\Infobip\Model\CallRate $callRate): self + { + $this->callRate = $callRate; + return $this; + } + + public function getValidityPeriod(): int|null + { + return $this->validityPeriod; + } + + public function setValidityPeriod(?int $validityPeriod): self + { + $this->validityPeriod = $validityPeriod; + return $this; + } + + public function getRetryOptions(): \Infobip\Model\CallsRetryOptions|null + { + return $this->retryOptions; + } + + public function setRetryOptions(?\Infobip\Model\CallsRetryOptions $retryOptions): self + { + $this->retryOptions = $retryOptions; + return $this; + } + + public function getSchedulingOptions(): \Infobip\Model\CallsSchedulingOptions|null + { + return $this->schedulingOptions; + } + + public function setSchedulingOptions(?\Infobip\Model\CallsSchedulingOptions $schedulingOptions): self + { + $this->schedulingOptions = $schedulingOptions; + return $this; + } + + /** + * @return array|null + */ + public function getCustomData() + { + return $this->customData; + } + + /** + * @param array|null $customData Client-defined, bulk-level custom data. + */ + public function setCustomData(?array $customData): self + { + $this->customData = $customData; + return $this; + } +} diff --git a/Infobip/Model/CallsBulkRequest.php b/Infobip/Model/CallsBulkRequest.php new file mode 100644 index 0000000..24f08f3 --- /dev/null +++ b/Infobip/Model/CallsBulkRequest.php @@ -0,0 +1,68 @@ + 'date-time' + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected \DateTime $sendAt, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getSendAt(): \DateTime + { + return $this->sendAt; + } + + public function setSendAt(\DateTime $sendAt): self + { + $this->sendAt = $sendAt; + return $this; + } +} diff --git a/Infobip/Model/CallsBulkResponse.php b/Infobip/Model/CallsBulkResponse.php new file mode 100644 index 0000000..9f5cd29 --- /dev/null +++ b/Infobip/Model/CallsBulkResponse.php @@ -0,0 +1,80 @@ + null, + 'sendAt' => 'date-time' + ]; + + /** + */ + public function __construct( + protected ?string $bulkId = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $sendAt = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getBulkId(): string|null + { + return $this->bulkId; + } + + public function setBulkId(?string $bulkId): self + { + $this->bulkId = $bulkId; + return $this; + } + + public function getSendAt(): \DateTime|null + { + return $this->sendAt; + } + + public function setSendAt(?\DateTime $sendAt): self + { + $this->sendAt = $sendAt; + return $this; + } +} diff --git a/Infobip/Model/CallsBulkStatus.php b/Infobip/Model/CallsBulkStatus.php new file mode 100644 index 0000000..c6d61f8 --- /dev/null +++ b/Infobip/Model/CallsBulkStatus.php @@ -0,0 +1,92 @@ +value = $value; + } + + public static function PENDING(): CallsBulkStatus + { + return new self('PENDING'); + } + + public static function PAUSED(): CallsBulkStatus + { + return new self('PAUSED'); + } + + public static function PROCESSING(): CallsBulkStatus + { + return new self('PROCESSING'); + } + + public static function CANCELED(): CallsBulkStatus + { + return new self('CANCELED'); + } + + public static function FINISHED(): CallsBulkStatus + { + return new self('FINISHED'); + } + + public static function FAILED(): CallsBulkStatus + { + return new self('FAILED'); + } + + public function __toString(): string + { + return $this->value; + } +} diff --git a/Infobip/Model/CallsBulkStatusResponse.php b/Infobip/Model/CallsBulkStatusResponse.php new file mode 100644 index 0000000..912419d --- /dev/null +++ b/Infobip/Model/CallsBulkStatusResponse.php @@ -0,0 +1,80 @@ + null, + 'status' => null + ]; + + /** + */ + public function __construct( + protected ?string $bulkId = null, + #[Assert\Choice(['PENDING','PAUSED','PROCESSING','CANCELED','FINISHED','FAILED',])] + + protected ?string $status = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getBulkId(): string|null + { + return $this->bulkId; + } + + public function setBulkId(?string $bulkId): self + { + $this->bulkId = $bulkId; + return $this; + } + + public function getStatus(): mixed + { + return $this->status; + } + + public function setStatus($status): self + { + $this->status = $status; + return $this; + } +} diff --git a/Infobip/Model/CallsClickToCallMessage.php b/Infobip/Model/CallsClickToCallMessage.php new file mode 100644 index 0000000..72c7570 --- /dev/null +++ b/Infobip/Model/CallsClickToCallMessage.php @@ -0,0 +1,309 @@ + null, + 'audioFileUrl' => null, + 'deliveryTimeWindow' => null, + 'destinationA' => null, + 'destinationB' => null, + 'from' => null, + 'fromB' => null, + 'language' => null, + 'machineDetection' => null, + 'maxDuration' => 'int32', + 'messageId' => null, + 'notifyContentType' => null, + 'notifyContentVersion' => 'int32', + 'notifyUrl' => null, + 'record' => null, + 'retry' => null, + 'text' => null, + 'voice' => null, + 'warningTime' => 'int32' + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + + protected string $destinationA, + #[Assert\NotBlank] + + protected string $destinationB, + protected ?bool $anonymization = null, + protected ?string $audioFileUrl = null, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsDeliveryTimeWindow $deliveryTimeWindow = null, + protected ?string $from = null, + protected ?string $fromB = null, + protected ?string $language = null, + protected ?string $machineDetection = null, + protected ?int $maxDuration = null, + protected ?string $messageId = null, + protected ?string $notifyContentType = null, + protected ?int $notifyContentVersion = null, + protected ?string $notifyUrl = null, + protected ?bool $record = null, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsRetry $retry = null, + protected ?string $text = null, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsVoice $voice = null, + protected ?int $warningTime = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getAnonymization(): bool|null + { + return $this->anonymization; + } + + public function setAnonymization(?bool $anonymization): self + { + $this->anonymization = $anonymization; + return $this; + } + + public function getAudioFileUrl(): string|null + { + return $this->audioFileUrl; + } + + public function setAudioFileUrl(?string $audioFileUrl): self + { + $this->audioFileUrl = $audioFileUrl; + return $this; + } + + public function getDeliveryTimeWindow(): \Infobip\Model\CallsDeliveryTimeWindow|null + { + return $this->deliveryTimeWindow; + } + + public function setDeliveryTimeWindow(?\Infobip\Model\CallsDeliveryTimeWindow $deliveryTimeWindow): self + { + $this->deliveryTimeWindow = $deliveryTimeWindow; + return $this; + } + + public function getDestinationA(): string + { + return $this->destinationA; + } + + public function setDestinationA(string $destinationA): self + { + $this->destinationA = $destinationA; + return $this; + } + + public function getDestinationB(): string + { + return $this->destinationB; + } + + public function setDestinationB(string $destinationB): self + { + $this->destinationB = $destinationB; + return $this; + } + + public function getFrom(): string|null + { + return $this->from; + } + + public function setFrom(?string $from): self + { + $this->from = $from; + return $this; + } + + public function getFromB(): string|null + { + return $this->fromB; + } + + public function setFromB(?string $fromB): self + { + $this->fromB = $fromB; + return $this; + } + + public function getLanguage(): string|null + { + return $this->language; + } + + public function setLanguage(?string $language): self + { + $this->language = $language; + return $this; + } + + public function getMachineDetection(): string|null + { + return $this->machineDetection; + } + + public function setMachineDetection(?string $machineDetection): self + { + $this->machineDetection = $machineDetection; + return $this; + } + + public function getMaxDuration(): int|null + { + return $this->maxDuration; + } + + public function setMaxDuration(?int $maxDuration): self + { + $this->maxDuration = $maxDuration; + return $this; + } + + public function getMessageId(): string|null + { + return $this->messageId; + } + + public function setMessageId(?string $messageId): self + { + $this->messageId = $messageId; + return $this; + } + + public function getNotifyContentType(): string|null + { + return $this->notifyContentType; + } + + public function setNotifyContentType(?string $notifyContentType): self + { + $this->notifyContentType = $notifyContentType; + return $this; + } + + public function getNotifyContentVersion(): int|null + { + return $this->notifyContentVersion; + } + + public function setNotifyContentVersion(?int $notifyContentVersion): self + { + $this->notifyContentVersion = $notifyContentVersion; + return $this; + } + + public function getNotifyUrl(): string|null + { + return $this->notifyUrl; + } + + public function setNotifyUrl(?string $notifyUrl): self + { + $this->notifyUrl = $notifyUrl; + return $this; + } + + public function getRecord(): bool|null + { + return $this->record; + } + + public function setRecord(?bool $record): self + { + $this->record = $record; + return $this; + } + + public function getRetry(): \Infobip\Model\CallsRetry|null + { + return $this->retry; + } + + public function setRetry(?\Infobip\Model\CallsRetry $retry): self + { + $this->retry = $retry; + return $this; + } + + public function getText(): string|null + { + return $this->text; + } + + public function setText(?string $text): self + { + $this->text = $text; + return $this; + } + + public function getVoice(): \Infobip\Model\CallsVoice|null + { + return $this->voice; + } + + public function setVoice(?\Infobip\Model\CallsVoice $voice): self + { + $this->voice = $voice; + return $this; + } + + public function getWarningTime(): int|null + { + return $this->warningTime; + } + + public function setWarningTime(?int $warningTime): self + { + $this->warningTime = $warningTime; + return $this; + } +} diff --git a/Infobip/Model/CallsClickToCallMessageBody.php b/Infobip/Model/CallsClickToCallMessageBody.php new file mode 100644 index 0000000..cb0bafa --- /dev/null +++ b/Infobip/Model/CallsClickToCallMessageBody.php @@ -0,0 +1,87 @@ + null, + 'messages' => null + ]; + + /** + * @param \Infobip\Model\CallsClickToCallMessage[] $messages + */ + public function __construct( + #[Assert\NotBlank] + + protected array $messages, + protected ?string $bulkId = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getBulkId(): string|null + { + return $this->bulkId; + } + + public function setBulkId(?string $bulkId): self + { + $this->bulkId = $bulkId; + return $this; + } + + /** + * @return \Infobip\Model\CallsClickToCallMessage[] + */ + public function getMessages(): array + { + return $this->messages; + } + + /** + * @param \Infobip\Model\CallsClickToCallMessage[] $messages Array of click to call messages to be sent. + */ + public function setMessages(array $messages): self + { + $this->messages = $messages; + return $this; + } +} diff --git a/Infobip/Model/CallsConference.php b/Infobip/Model/CallsConference.php new file mode 100644 index 0000000..de0ea52 --- /dev/null +++ b/Infobip/Model/CallsConference.php @@ -0,0 +1,111 @@ + null, + 'name' => null, + 'participants' => null, + 'applicationId' => null + ]; + + /** + * @param \Infobip\Model\CallsParticipant[] $participants + */ + public function __construct( + protected ?string $id = null, + protected ?string $name = null, + protected ?array $participants = null, + protected ?string $applicationId = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getId(): string|null + { + return $this->id; + } + + public function setId(?string $id): self + { + $this->id = $id; + return $this; + } + + public function getName(): string|null + { + return $this->name; + } + + public function setName(?string $name): self + { + $this->name = $name; + return $this; + } + + /** + * @return \Infobip\Model\CallsParticipant[]|null + */ + public function getParticipants(): ?array + { + return $this->participants; + } + + /** + * @param \Infobip\Model\CallsParticipant[]|null $participants The list of conference participants. + */ + public function setParticipants(?array $participants): self + { + $this->participants = $participants; + return $this; + } + + public function getApplicationId(): string|null + { + return $this->applicationId; + } + + public function setApplicationId(?string $applicationId): self + { + $this->applicationId = $applicationId; + return $this; + } +} diff --git a/Infobip/Model/CallsConferenceAndCall.php b/Infobip/Model/CallsConferenceAndCall.php new file mode 100644 index 0000000..2804823 --- /dev/null +++ b/Infobip/Model/CallsConferenceAndCall.php @@ -0,0 +1,82 @@ + null, + 'call' => null + ]; + + /** + */ + public function __construct( + #[Assert\Valid] + + protected ?\Infobip\Model\CallsConference $conference = null, + #[Assert\Valid] + + protected ?\Infobip\Model\Call $call = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getConference(): \Infobip\Model\CallsConference|null + { + return $this->conference; + } + + public function setConference(?\Infobip\Model\CallsConference $conference): self + { + $this->conference = $conference; + return $this; + } + + public function getCall(): \Infobip\Model\Call|null + { + return $this->call; + } + + public function setCall(?\Infobip\Model\Call $call): self + { + $this->call = $call; + return $this; + } +} diff --git a/Infobip/Model/CallsConferenceComposition.php b/Infobip/Model/CallsConferenceComposition.php new file mode 100644 index 0000000..edc8097 --- /dev/null +++ b/Infobip/Model/CallsConferenceComposition.php @@ -0,0 +1,67 @@ + null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + + protected bool $enabled = false, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getEnabled(): bool + { + return $this->enabled; + } + + public function setEnabled(bool $enabled): self + { + $this->enabled = $enabled; + return $this; + } +} diff --git a/Infobip/Model/CallsConferenceLog.php b/Infobip/Model/CallsConferenceLog.php new file mode 100644 index 0000000..210d70b --- /dev/null +++ b/Infobip/Model/CallsConferenceLog.php @@ -0,0 +1,184 @@ + null, + 'name' => null, + 'applicationId' => null, + 'startTime' => 'date-time', + 'endTime' => 'date-time', + 'duration' => 'int64', + 'sessions' => null, + 'recording' => null, + 'errorCode' => null + ]; + + /** + * @param \Infobip\Model\CallsParticipantSession[] $sessions + */ + public function __construct( + protected ?string $conferenceId = null, + protected ?string $name = null, + protected ?string $applicationId = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $startTime = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $endTime = null, + protected ?int $duration = null, + protected ?array $sessions = null, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsConferenceRecordingLog $recording = null, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsErrorCodeInfo $errorCode = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getConferenceId(): string|null + { + return $this->conferenceId; + } + + public function setConferenceId(?string $conferenceId): self + { + $this->conferenceId = $conferenceId; + return $this; + } + + public function getName(): string|null + { + return $this->name; + } + + public function setName(?string $name): self + { + $this->name = $name; + return $this; + } + + public function getApplicationId(): string|null + { + return $this->applicationId; + } + + public function setApplicationId(?string $applicationId): self + { + $this->applicationId = $applicationId; + return $this; + } + + public function getStartTime(): \DateTime|null + { + return $this->startTime; + } + + public function setStartTime(?\DateTime $startTime): self + { + $this->startTime = $startTime; + return $this; + } + + public function getEndTime(): \DateTime|null + { + return $this->endTime; + } + + public function setEndTime(?\DateTime $endTime): self + { + $this->endTime = $endTime; + return $this; + } + + public function getDuration(): int|null + { + return $this->duration; + } + + public function setDuration(?int $duration): self + { + $this->duration = $duration; + return $this; + } + + /** + * @return \Infobip\Model\CallsParticipantSession[]|null + */ + public function getSessions(): ?array + { + return $this->sessions; + } + + /** + * @param \Infobip\Model\CallsParticipantSession[]|null $sessions List of participant sessions. + */ + public function setSessions(?array $sessions): self + { + $this->sessions = $sessions; + return $this; + } + + public function getRecording(): \Infobip\Model\CallsConferenceRecordingLog|null + { + return $this->recording; + } + + public function setRecording(?\Infobip\Model\CallsConferenceRecordingLog $recording): self + { + $this->recording = $recording; + return $this; + } + + public function getErrorCode(): \Infobip\Model\CallsErrorCodeInfo|null + { + return $this->errorCode; + } + + public function setErrorCode(?\Infobip\Model\CallsErrorCodeInfo $errorCode): self + { + $this->errorCode = $errorCode; + return $this; + } +} diff --git a/Infobip/Model/CallsConferenceLogPage.php b/Infobip/Model/CallsConferenceLogPage.php new file mode 100644 index 0000000..88b7c6a --- /dev/null +++ b/Infobip/Model/CallsConferenceLogPage.php @@ -0,0 +1,87 @@ + null, + 'paging' => null + ]; + + /** + * @param \Infobip\Model\CallsConferenceLog[] $results + */ + public function __construct( + protected ?array $results = null, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsPageInfo $paging = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + /** + * @return \Infobip\Model\CallsConferenceLog[]|null + */ + public function getResults(): ?array + { + return $this->results; + } + + /** + * @param \Infobip\Model\CallsConferenceLog[]|null $results The list of the results for this page. + */ + public function setResults(?array $results): self + { + $this->results = $results; + return $this; + } + + public function getPaging(): \Infobip\Model\CallsPageInfo|null + { + return $this->paging; + } + + public function setPaging(?\Infobip\Model\CallsPageInfo $paging): self + { + $this->paging = $paging; + return $this; + } +} diff --git a/Infobip/Model/CallsConferencePage.php b/Infobip/Model/CallsConferencePage.php new file mode 100644 index 0000000..59144f6 --- /dev/null +++ b/Infobip/Model/CallsConferencePage.php @@ -0,0 +1,87 @@ + null, + 'paging' => null + ]; + + /** + * @param \Infobip\Model\CallsConference[] $results + */ + public function __construct( + protected ?array $results = null, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsPageInfo $paging = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + /** + * @return \Infobip\Model\CallsConference[]|null + */ + public function getResults(): ?array + { + return $this->results; + } + + /** + * @param \Infobip\Model\CallsConference[]|null $results The list of the results for this page. + */ + public function setResults(?array $results): self + { + $this->results = $results; + return $this; + } + + public function getPaging(): \Infobip\Model\CallsPageInfo|null + { + return $this->paging; + } + + public function setPaging(?\Infobip\Model\CallsPageInfo $paging): self + { + $this->paging = $paging; + return $this; + } +} diff --git a/Infobip/Model/CallsConferenceRecording.php b/Infobip/Model/CallsConferenceRecording.php new file mode 100644 index 0000000..09a430a --- /dev/null +++ b/Infobip/Model/CallsConferenceRecording.php @@ -0,0 +1,161 @@ + null, + 'conferenceName' => null, + 'applicationId' => null, + 'composedFiles' => null, + 'callRecordings' => null, + 'startTime' => 'date-time', + 'endTime' => 'date-time' + ]; + + /** + * @param \Infobip\Model\CallsRecordingFile[] $composedFiles + * @param \Infobip\Model\CallRecording[] $callRecordings + */ + public function __construct( + protected ?string $conferenceId = null, + protected ?string $conferenceName = null, + protected ?string $applicationId = null, + protected ?array $composedFiles = null, + protected ?array $callRecordings = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $startTime = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $endTime = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getConferenceId(): string|null + { + return $this->conferenceId; + } + + public function setConferenceId(?string $conferenceId): self + { + $this->conferenceId = $conferenceId; + return $this; + } + + public function getConferenceName(): string|null + { + return $this->conferenceName; + } + + public function setConferenceName(?string $conferenceName): self + { + $this->conferenceName = $conferenceName; + return $this; + } + + public function getApplicationId(): string|null + { + return $this->applicationId; + } + + public function setApplicationId(?string $applicationId): self + { + $this->applicationId = $applicationId; + return $this; + } + + /** + * @return \Infobip\Model\CallsRecordingFile[]|null + */ + public function getComposedFiles(): ?array + { + return $this->composedFiles; + } + + /** + * @param \Infobip\Model\CallsRecordingFile[]|null $composedFiles File(s) with a recording of all conference participants. + */ + public function setComposedFiles(?array $composedFiles): self + { + $this->composedFiles = $composedFiles; + return $this; + } + + /** + * @return \Infobip\Model\CallRecording[]|null + */ + public function getCallRecordings(): ?array + { + return $this->callRecordings; + } + + /** + * @param \Infobip\Model\CallRecording[]|null $callRecordings File(s) with a recording of one conference participant. + */ + public function setCallRecordings(?array $callRecordings): self + { + $this->callRecordings = $callRecordings; + return $this; + } + + public function getStartTime(): \DateTime|null + { + return $this->startTime; + } + + public function setStartTime(?\DateTime $startTime): self + { + $this->startTime = $startTime; + return $this; + } + + public function getEndTime(): \DateTime|null + { + return $this->endTime; + } + + public function setEndTime(?\DateTime $endTime): self + { + $this->endTime = $endTime; + return $this; + } +} diff --git a/Infobip/Model/CallsConferenceRecordingLog.php b/Infobip/Model/CallsConferenceRecordingLog.php new file mode 100644 index 0000000..c554c3a --- /dev/null +++ b/Infobip/Model/CallsConferenceRecordingLog.php @@ -0,0 +1,92 @@ + null, + 'callRecordings' => null + ]; + + /** + * @param \Infobip\Model\CallsRecordingFile[] $composedFiles + * @param \Infobip\Model\CallRecording[] $callRecordings + */ + public function __construct( + protected ?array $composedFiles = null, + protected ?array $callRecordings = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + /** + * @return \Infobip\Model\CallsRecordingFile[]|null + */ + public function getComposedFiles(): ?array + { + return $this->composedFiles; + } + + /** + * @param \Infobip\Model\CallsRecordingFile[]|null $composedFiles File(s) with a recording of all conference participants. + */ + public function setComposedFiles(?array $composedFiles): self + { + $this->composedFiles = $composedFiles; + return $this; + } + + /** + * @return \Infobip\Model\CallRecording[]|null + */ + public function getCallRecordings(): ?array + { + return $this->callRecordings; + } + + /** + * @param \Infobip\Model\CallRecording[]|null $callRecordings File(s) with a recording of one conference participant. + */ + public function setCallRecordings(?array $callRecordings): self + { + $this->callRecordings = $callRecordings; + return $this; + } +} diff --git a/Infobip/Model/CallsConferenceRecordingPage.php b/Infobip/Model/CallsConferenceRecordingPage.php new file mode 100644 index 0000000..ae1ad09 --- /dev/null +++ b/Infobip/Model/CallsConferenceRecordingPage.php @@ -0,0 +1,87 @@ + null, + 'paging' => null + ]; + + /** + * @param \Infobip\Model\CallsConferenceRecording[] $results + */ + public function __construct( + protected ?array $results = null, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsPageInfo $paging = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + /** + * @return \Infobip\Model\CallsConferenceRecording[]|null + */ + public function getResults(): ?array + { + return $this->results; + } + + /** + * @param \Infobip\Model\CallsConferenceRecording[]|null $results The list of the results for this page. + */ + public function setResults(?array $results): self + { + $this->results = $results; + return $this; + } + + public function getPaging(): \Infobip\Model\CallsPageInfo|null + { + return $this->paging; + } + + public function setPaging(?\Infobip\Model\CallsPageInfo $paging): self + { + $this->paging = $paging; + return $this; + } +} diff --git a/Infobip/Model/CallsConferenceRecordingRequest.php b/Infobip/Model/CallsConferenceRecordingRequest.php new file mode 100644 index 0000000..7c1751f --- /dev/null +++ b/Infobip/Model/CallsConferenceRecordingRequest.php @@ -0,0 +1,83 @@ + null, + 'conferenceComposition' => null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + #[Assert\Choice(['AUDIO','AUDIO_AND_VIDEO',])] + + protected string $recordingType, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsConferenceComposition $conferenceComposition = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getRecordingType(): mixed + { + return $this->recordingType; + } + + public function setRecordingType($recordingType): self + { + $this->recordingType = $recordingType; + return $this; + } + + public function getConferenceComposition(): \Infobip\Model\CallsConferenceComposition|null + { + return $this->conferenceComposition; + } + + public function setConferenceComposition(?\Infobip\Model\CallsConferenceComposition $conferenceComposition): self + { + $this->conferenceComposition = $conferenceComposition; + return $this; + } +} diff --git a/Infobip/Model/CallsConferenceRequest.php b/Infobip/Model/CallsConferenceRequest.php new file mode 100644 index 0000000..a6e4166 --- /dev/null +++ b/Infobip/Model/CallsConferenceRequest.php @@ -0,0 +1,108 @@ + null, + 'recording' => null, + 'maxDuration' => 'int32', + 'applicationId' => null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + + protected string $applicationId, + protected ?string $name = null, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsConferenceRecordingRequest $recording = null, + protected ?int $maxDuration = 28800, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getName(): string|null + { + return $this->name; + } + + public function setName(?string $name): self + { + $this->name = $name; + return $this; + } + + public function getRecording(): \Infobip\Model\CallsConferenceRecordingRequest|null + { + return $this->recording; + } + + public function setRecording(?\Infobip\Model\CallsConferenceRecordingRequest $recording): self + { + $this->recording = $recording; + return $this; + } + + public function getMaxDuration(): int|null + { + return $this->maxDuration; + } + + public function setMaxDuration(?int $maxDuration): self + { + $this->maxDuration = $maxDuration; + return $this; + } + + public function getApplicationId(): string + { + return $this->applicationId; + } + + public function setApplicationId(string $applicationId): self + { + $this->applicationId = $applicationId; + return $this; + } +} diff --git a/Infobip/Model/CallsConnectRequest.php b/Infobip/Model/CallsConnectRequest.php new file mode 100644 index 0000000..bd94df4 --- /dev/null +++ b/Infobip/Model/CallsConnectRequest.php @@ -0,0 +1,89 @@ + null, + 'conferenceRequest' => null + ]; + + /** + * @param string[] $callIds + */ + public function __construct( + #[Assert\NotBlank] + + protected array $callIds, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsActionConferenceRequest $conferenceRequest = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + /** + * @return string[] + */ + public function getCallIds(): array + { + return $this->callIds; + } + + /** + * @param string[] $callIds IDs of the calls to connect. + */ + public function setCallIds(array $callIds): self + { + $this->callIds = $callIds; + return $this; + } + + public function getConferenceRequest(): \Infobip\Model\CallsActionConferenceRequest|null + { + return $this->conferenceRequest; + } + + public function setConferenceRequest(?\Infobip\Model\CallsActionConferenceRequest $conferenceRequest): self + { + $this->conferenceRequest = $conferenceRequest; + return $this; + } +} diff --git a/Infobip/Model/CallsConnectWithNewCallRequest.php b/Infobip/Model/CallsConnectWithNewCallRequest.php new file mode 100644 index 0000000..67a5e00 --- /dev/null +++ b/Infobip/Model/CallsConnectWithNewCallRequest.php @@ -0,0 +1,95 @@ + null, + 'connectOnEarlyMedia' => null, + 'conferenceRequest' => null + ]; + + /** + */ + public function __construct( + #[Assert\Valid] + + protected ?\Infobip\Model\CallsActionCallRequest $callRequest = null, + protected ?bool $connectOnEarlyMedia = false, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsActionConferenceRequest $conferenceRequest = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getCallRequest(): \Infobip\Model\CallsActionCallRequest|null + { + return $this->callRequest; + } + + public function setCallRequest(?\Infobip\Model\CallsActionCallRequest $callRequest): self + { + $this->callRequest = $callRequest; + return $this; + } + + public function getConnectOnEarlyMedia(): bool|null + { + return $this->connectOnEarlyMedia; + } + + public function setConnectOnEarlyMedia(?bool $connectOnEarlyMedia): self + { + $this->connectOnEarlyMedia = $connectOnEarlyMedia; + return $this; + } + + public function getConferenceRequest(): \Infobip\Model\CallsActionConferenceRequest|null + { + return $this->conferenceRequest; + } + + public function setConferenceRequest(?\Infobip\Model\CallsActionConferenceRequest $conferenceRequest): self + { + $this->conferenceRequest = $conferenceRequest; + return $this; + } +} diff --git a/Infobip/Model/CallsCreationMethod.php b/Infobip/Model/CallsCreationMethod.php new file mode 100644 index 0000000..a09672f --- /dev/null +++ b/Infobip/Model/CallsCreationMethod.php @@ -0,0 +1,71 @@ +value = $value; + } + + public static function UPLOADED(): CallsCreationMethod + { + return new self('UPLOADED'); + } + + public static function SYNTHESIZED(): CallsCreationMethod + { + return new self('SYNTHESIZED'); + } + + public static function RECORDED(): CallsCreationMethod + { + return new self('RECORDED'); + } + + public function __toString(): string + { + return $this->value; + } +} diff --git a/Infobip/Model/CallsDeliveryDay.php b/Infobip/Model/CallsDeliveryDay.php new file mode 100644 index 0000000..2539d19 --- /dev/null +++ b/Infobip/Model/CallsDeliveryDay.php @@ -0,0 +1,99 @@ +value = $value; + } + + public static function MONDAY(): CallsDeliveryDay + { + return new self('MONDAY'); + } + + public static function TUESDAY(): CallsDeliveryDay + { + return new self('TUESDAY'); + } + + public static function WEDNESDAY(): CallsDeliveryDay + { + return new self('WEDNESDAY'); + } + + public static function THURSDAY(): CallsDeliveryDay + { + return new self('THURSDAY'); + } + + public static function FRIDAY(): CallsDeliveryDay + { + return new self('FRIDAY'); + } + + public static function SATURDAY(): CallsDeliveryDay + { + return new self('SATURDAY'); + } + + public static function SUNDAY(): CallsDeliveryDay + { + return new self('SUNDAY'); + } + + public function __toString(): string + { + return $this->value; + } +} diff --git a/Infobip/Model/CallsDeliveryTime.php b/Infobip/Model/CallsDeliveryTime.php new file mode 100644 index 0000000..eaf9980 --- /dev/null +++ b/Infobip/Model/CallsDeliveryTime.php @@ -0,0 +1,78 @@ + 'int32', + 'minute' => 'int32' + ]; + + /** + */ + public function __construct( + protected ?int $hour = null, + protected ?int $minute = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getHour(): int|null + { + return $this->hour; + } + + public function setHour(?int $hour): self + { + $this->hour = $hour; + return $this; + } + + public function getMinute(): int|null + { + return $this->minute; + } + + public function setMinute(?int $minute): self + { + $this->minute = $minute; + return $this; + } +} diff --git a/Infobip/Model/CallsDeliveryTimeWindow.php b/Infobip/Model/CallsDeliveryTimeWindow.php new file mode 100644 index 0000000..1cd7b1c --- /dev/null +++ b/Infobip/Model/CallsDeliveryTimeWindow.php @@ -0,0 +1,104 @@ + null, + 'from' => null, + 'to' => null + ]; + + /** + * @param \Infobip\Model\CallsDeliveryDay[] $days + */ + public function __construct( + #[Assert\Valid] + #[Assert\NotBlank] + + protected \Infobip\Model\CallsDeliveryTime $from, + #[Assert\Valid] + #[Assert\NotBlank] + + protected \Infobip\Model\CallsDeliveryTime $to, + protected ?array $days = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + /** + * @return \Infobip\Model\CallsDeliveryDay[]|null + */ + public function getDays(): ?array + { + return $this->days; + } + + /** + * @param \Infobip\Model\CallsDeliveryDay[]|null $days days + */ + public function setDays(?array $days): self + { + $this->days = $days; + return $this; + } + + public function getFrom(): \Infobip\Model\CallsDeliveryTime + { + return $this->from; + } + + public function setFrom(\Infobip\Model\CallsDeliveryTime $from): self + { + $this->from = $from; + return $this; + } + + public function getTo(): \Infobip\Model\CallsDeliveryTime + { + return $this->to; + } + + public function setTo(\Infobip\Model\CallsDeliveryTime $to): self + { + $this->to = $to; + return $this; + } +} diff --git a/Infobip/Model/CallsDestination.php b/Infobip/Model/CallsDestination.php new file mode 100644 index 0000000..51a38f5 --- /dev/null +++ b/Infobip/Model/CallsDestination.php @@ -0,0 +1,80 @@ + null, + 'to' => null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + + protected string $to, + protected ?string $messageId = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getMessageId(): string|null + { + return $this->messageId; + } + + public function setMessageId(?string $messageId): self + { + $this->messageId = $messageId; + return $this; + } + + public function getTo(): string + { + return $this->to; + } + + public function setTo(string $to): self + { + $this->to = $to; + return $this; + } +} diff --git a/Infobip/Model/CallsDetectionResult.php b/Infobip/Model/CallsDetectionResult.php new file mode 100644 index 0000000..5be7a4d --- /dev/null +++ b/Infobip/Model/CallsDetectionResult.php @@ -0,0 +1,71 @@ +value = $value; + } + + public static function HUMAN(): CallsDetectionResult + { + return new self('HUMAN'); + } + + public static function MACHINE(): CallsDetectionResult + { + return new self('MACHINE'); + } + + public static function UNKNOWN(): CallsDetectionResult + { + return new self('UNKNOWN'); + } + + public function __toString(): string + { + return $this->value; + } +} diff --git a/Infobip/Model/CallsDialogCallRequest.php b/Infobip/Model/CallsDialogCallRequest.php new file mode 100644 index 0000000..5f529ec --- /dev/null +++ b/Infobip/Model/CallsDialogCallRequest.php @@ -0,0 +1,143 @@ + null, + 'from' => null, + 'fromDisplayName' => null, + 'connectTimeout' => 'int32', + 'machineDetection' => null, + 'customData' => null + ]; + + /** + * @param array $customData + */ + public function __construct( + #[Assert\NotBlank] + + protected string $from, + #[Assert\Valid] + + protected ?\Infobip\Model\CallEndpoint $endpoint = null, + protected ?string $fromDisplayName = null, + protected ?int $connectTimeout = null, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsMachineDetectionRequest $machineDetection = null, + protected ?array $customData = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getEndpoint(): \Infobip\Model\CallEndpoint|null + { + return $this->endpoint; + } + + public function setEndpoint(?\Infobip\Model\CallEndpoint $endpoint): self + { + $this->endpoint = $endpoint; + return $this; + } + + public function getFrom(): string + { + return $this->from; + } + + public function setFrom(string $from): self + { + $this->from = $from; + return $this; + } + + public function getFromDisplayName(): string|null + { + return $this->fromDisplayName; + } + + public function setFromDisplayName(?string $fromDisplayName): self + { + $this->fromDisplayName = $fromDisplayName; + return $this; + } + + public function getConnectTimeout(): int|null + { + return $this->connectTimeout; + } + + public function setConnectTimeout(?int $connectTimeout): self + { + $this->connectTimeout = $connectTimeout; + return $this; + } + + public function getMachineDetection(): \Infobip\Model\CallsMachineDetectionRequest|null + { + return $this->machineDetection; + } + + public function setMachineDetection(?\Infobip\Model\CallsMachineDetectionRequest $machineDetection): self + { + $this->machineDetection = $machineDetection; + return $this; + } + + /** + * @return array|null + */ + public function getCustomData() + { + return $this->customData; + } + + /** + * @param array|null $customData Custom data is used for storing call-specific data defined by the client. + */ + public function setCustomData(?array $customData): self + { + $this->customData = $customData; + return $this; + } +} diff --git a/Infobip/Model/CallsDialogLogPage.php b/Infobip/Model/CallsDialogLogPage.php new file mode 100644 index 0000000..cfe4d86 --- /dev/null +++ b/Infobip/Model/CallsDialogLogPage.php @@ -0,0 +1,87 @@ + null, + 'paging' => null + ]; + + /** + * @param \Infobip\Model\CallsDialogLogResponse[] $results + */ + public function __construct( + protected ?array $results = null, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsPageInfo $paging = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + /** + * @return \Infobip\Model\CallsDialogLogResponse[]|null + */ + public function getResults(): ?array + { + return $this->results; + } + + /** + * @param \Infobip\Model\CallsDialogLogResponse[]|null $results The list of the results for this page. + */ + public function setResults(?array $results): self + { + $this->results = $results; + return $this; + } + + public function getPaging(): \Infobip\Model\CallsPageInfo|null + { + return $this->paging; + } + + public function setPaging(?\Infobip\Model\CallsPageInfo $paging): self + { + $this->paging = $paging; + return $this; + } +} diff --git a/Infobip/Model/CallsDialogLogResponse.php b/Infobip/Model/CallsDialogLogResponse.php new file mode 100644 index 0000000..b4c85b3 --- /dev/null +++ b/Infobip/Model/CallsDialogLogResponse.php @@ -0,0 +1,207 @@ + null, + 'applicationId' => null, + 'state' => null, + 'startTime' => 'date-time', + 'establishTime' => 'date-time', + 'endTime' => 'date-time', + 'parentCallId' => null, + 'childCallId' => null, + 'duration' => 'int64', + 'recording' => null, + 'errorCode' => null + ]; + + /** + */ + public function __construct( + protected ?string $dialogId = null, + protected ?string $applicationId = null, + #[Assert\Choice(['CREATED','ESTABLISHED','FINISHED','FAILED',])] + + protected ?string $state = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $startTime = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $establishTime = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $endTime = null, + protected ?string $parentCallId = null, + protected ?string $childCallId = null, + protected ?int $duration = null, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsDialogRecordingLog $recording = null, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsErrorCodeInfo $errorCode = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getDialogId(): string|null + { + return $this->dialogId; + } + + public function setDialogId(?string $dialogId): self + { + $this->dialogId = $dialogId; + return $this; + } + + public function getApplicationId(): string|null + { + return $this->applicationId; + } + + public function setApplicationId(?string $applicationId): self + { + $this->applicationId = $applicationId; + return $this; + } + + public function getState(): mixed + { + return $this->state; + } + + public function setState($state): self + { + $this->state = $state; + return $this; + } + + public function getStartTime(): \DateTime|null + { + return $this->startTime; + } + + public function setStartTime(?\DateTime $startTime): self + { + $this->startTime = $startTime; + return $this; + } + + public function getEstablishTime(): \DateTime|null + { + return $this->establishTime; + } + + public function setEstablishTime(?\DateTime $establishTime): self + { + $this->establishTime = $establishTime; + return $this; + } + + public function getEndTime(): \DateTime|null + { + return $this->endTime; + } + + public function setEndTime(?\DateTime $endTime): self + { + $this->endTime = $endTime; + return $this; + } + + public function getParentCallId(): string|null + { + return $this->parentCallId; + } + + public function setParentCallId(?string $parentCallId): self + { + $this->parentCallId = $parentCallId; + return $this; + } + + public function getChildCallId(): string|null + { + return $this->childCallId; + } + + public function setChildCallId(?string $childCallId): self + { + $this->childCallId = $childCallId; + return $this; + } + + public function getDuration(): int|null + { + return $this->duration; + } + + public function setDuration(?int $duration): self + { + $this->duration = $duration; + return $this; + } + + public function getRecording(): \Infobip\Model\CallsDialogRecordingLog|null + { + return $this->recording; + } + + public function setRecording(?\Infobip\Model\CallsDialogRecordingLog $recording): self + { + $this->recording = $recording; + return $this; + } + + public function getErrorCode(): \Infobip\Model\CallsErrorCodeInfo|null + { + return $this->errorCode; + } + + public function setErrorCode(?\Infobip\Model\CallsErrorCodeInfo $errorCode): self + { + $this->errorCode = $errorCode; + return $this; + } +} diff --git a/Infobip/Model/CallsDialogPage.php b/Infobip/Model/CallsDialogPage.php new file mode 100644 index 0000000..3c4b76f --- /dev/null +++ b/Infobip/Model/CallsDialogPage.php @@ -0,0 +1,87 @@ + null, + 'paging' => null + ]; + + /** + * @param \Infobip\Model\CallsDialogResponse[] $results + */ + public function __construct( + protected ?array $results = null, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsPageInfo $paging = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + /** + * @return \Infobip\Model\CallsDialogResponse[]|null + */ + public function getResults(): ?array + { + return $this->results; + } + + /** + * @param \Infobip\Model\CallsDialogResponse[]|null $results The list of the results for this page. + */ + public function setResults(?array $results): self + { + $this->results = $results; + return $this; + } + + public function getPaging(): \Infobip\Model\CallsPageInfo|null + { + return $this->paging; + } + + public function setPaging(?\Infobip\Model\CallsPageInfo $paging): self + { + $this->paging = $paging; + return $this; + } +} diff --git a/Infobip/Model/CallsDialogPlayRequest.php b/Infobip/Model/CallsDialogPlayRequest.php new file mode 100644 index 0000000..44380c5 --- /dev/null +++ b/Infobip/Model/CallsDialogPlayRequest.php @@ -0,0 +1,80 @@ + 'int32', + 'content' => null + ]; + + /** + */ + public function __construct( + protected ?int $loopCount = null, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsPlayContent $content = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getLoopCount(): int|null + { + return $this->loopCount; + } + + public function setLoopCount(?int $loopCount): self + { + $this->loopCount = $loopCount; + return $this; + } + + public function getContent(): \Infobip\Model\CallsPlayContent|null + { + return $this->content; + } + + public function setContent(?\Infobip\Model\CallsPlayContent $content): self + { + $this->content = $content; + return $this; + } +} diff --git a/Infobip/Model/CallsDialogPropagationOptions.php b/Infobip/Model/CallsDialogPropagationOptions.php new file mode 100644 index 0000000..2d6bf17 --- /dev/null +++ b/Infobip/Model/CallsDialogPropagationOptions.php @@ -0,0 +1,65 @@ + null + ]; + + /** + */ + public function __construct( + protected ?bool $childCallHangup = true, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getChildCallHangup(): bool|null + { + return $this->childCallHangup; + } + + public function setChildCallHangup(?bool $childCallHangup): self + { + $this->childCallHangup = $childCallHangup; + return $this; + } +} diff --git a/Infobip/Model/CallsDialogRecordingComposition.php b/Infobip/Model/CallsDialogRecordingComposition.php new file mode 100644 index 0000000..3b04b17 --- /dev/null +++ b/Infobip/Model/CallsDialogRecordingComposition.php @@ -0,0 +1,65 @@ + null + ]; + + /** + */ + public function __construct( + protected ?bool $enabled = false, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getEnabled(): bool|null + { + return $this->enabled; + } + + public function setEnabled(?bool $enabled): self + { + $this->enabled = $enabled; + return $this; + } +} diff --git a/Infobip/Model/CallsDialogRecordingLog.php b/Infobip/Model/CallsDialogRecordingLog.php new file mode 100644 index 0000000..7520ba7 --- /dev/null +++ b/Infobip/Model/CallsDialogRecordingLog.php @@ -0,0 +1,92 @@ + null, + 'callRecordings' => null + ]; + + /** + * @param \Infobip\Model\CallsRecordingFile[] $composedFiles + * @param \Infobip\Model\CallRecording[] $callRecordings + */ + public function __construct( + protected ?array $composedFiles = null, + protected ?array $callRecordings = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + /** + * @return \Infobip\Model\CallsRecordingFile[]|null + */ + public function getComposedFiles(): ?array + { + return $this->composedFiles; + } + + /** + * @param \Infobip\Model\CallsRecordingFile[]|null $composedFiles File(s) with a recording of both dialog calls. + */ + public function setComposedFiles(?array $composedFiles): self + { + $this->composedFiles = $composedFiles; + return $this; + } + + /** + * @return \Infobip\Model\CallRecording[]|null + */ + public function getCallRecordings(): ?array + { + return $this->callRecordings; + } + + /** + * @param \Infobip\Model\CallRecording[]|null $callRecordings File(s) with a recording of individual dialog calls. + */ + public function setCallRecordings(?array $callRecordings): self + { + $this->callRecordings = $callRecordings; + return $this; + } +} diff --git a/Infobip/Model/CallsDialogRecordingPage.php b/Infobip/Model/CallsDialogRecordingPage.php new file mode 100644 index 0000000..4a6332b --- /dev/null +++ b/Infobip/Model/CallsDialogRecordingPage.php @@ -0,0 +1,87 @@ + null, + 'paging' => null + ]; + + /** + * @param \Infobip\Model\CallsDialogRecordingResponse[] $results + */ + public function __construct( + protected ?array $results = null, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsPageInfo $paging = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + /** + * @return \Infobip\Model\CallsDialogRecordingResponse[]|null + */ + public function getResults(): ?array + { + return $this->results; + } + + /** + * @param \Infobip\Model\CallsDialogRecordingResponse[]|null $results The list of the results for this page. + */ + public function setResults(?array $results): self + { + $this->results = $results; + return $this; + } + + public function getPaging(): \Infobip\Model\CallsPageInfo|null + { + return $this->paging; + } + + public function setPaging(?\Infobip\Model\CallsPageInfo $paging): self + { + $this->paging = $paging; + return $this; + } +} diff --git a/Infobip/Model/CallsDialogRecordingRequest.php b/Infobip/Model/CallsDialogRecordingRequest.php new file mode 100644 index 0000000..4ca712f --- /dev/null +++ b/Infobip/Model/CallsDialogRecordingRequest.php @@ -0,0 +1,83 @@ + null, + 'dialogComposition' => null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + #[Assert\Choice(['AUDIO','AUDIO_AND_VIDEO',])] + + protected string $recordingType, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsDialogRecordingComposition $dialogComposition = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getRecordingType(): mixed + { + return $this->recordingType; + } + + public function setRecordingType($recordingType): self + { + $this->recordingType = $recordingType; + return $this; + } + + public function getDialogComposition(): \Infobip\Model\CallsDialogRecordingComposition|null + { + return $this->dialogComposition; + } + + public function setDialogComposition(?\Infobip\Model\CallsDialogRecordingComposition $dialogComposition): self + { + $this->dialogComposition = $dialogComposition; + return $this; + } +} diff --git a/Infobip/Model/CallsDialogRecordingResponse.php b/Infobip/Model/CallsDialogRecordingResponse.php new file mode 100644 index 0000000..7781d42 --- /dev/null +++ b/Infobip/Model/CallsDialogRecordingResponse.php @@ -0,0 +1,148 @@ + null, + 'applicationId' => null, + 'composedFiles' => null, + 'callRecordings' => null, + 'startTime' => 'date-time', + 'endTime' => 'date-time' + ]; + + /** + * @param \Infobip\Model\CallsRecordingFile[] $composedFiles + * @param \Infobip\Model\CallRecording[] $callRecordings + */ + public function __construct( + protected ?string $dialogId = null, + protected ?string $applicationId = null, + protected ?array $composedFiles = null, + protected ?array $callRecordings = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $startTime = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $endTime = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getDialogId(): string|null + { + return $this->dialogId; + } + + public function setDialogId(?string $dialogId): self + { + $this->dialogId = $dialogId; + return $this; + } + + public function getApplicationId(): string|null + { + return $this->applicationId; + } + + public function setApplicationId(?string $applicationId): self + { + $this->applicationId = $applicationId; + return $this; + } + + /** + * @return \Infobip\Model\CallsRecordingFile[]|null + */ + public function getComposedFiles(): ?array + { + return $this->composedFiles; + } + + /** + * @param \Infobip\Model\CallsRecordingFile[]|null $composedFiles File(s) with a recording of both dialog participants. + */ + public function setComposedFiles(?array $composedFiles): self + { + $this->composedFiles = $composedFiles; + return $this; + } + + /** + * @return \Infobip\Model\CallRecording[]|null + */ + public function getCallRecordings(): ?array + { + return $this->callRecordings; + } + + /** + * @param \Infobip\Model\CallRecording[]|null $callRecordings File(s) with a recording of one dialog participant. + */ + public function setCallRecordings(?array $callRecordings): self + { + $this->callRecordings = $callRecordings; + return $this; + } + + public function getStartTime(): \DateTime|null + { + return $this->startTime; + } + + public function setStartTime(?\DateTime $startTime): self + { + $this->startTime = $startTime; + return $this; + } + + public function getEndTime(): \DateTime|null + { + return $this->endTime; + } + + public function setEndTime(?\DateTime $endTime): self + { + $this->endTime = $endTime; + return $this; + } +} diff --git a/Infobip/Model/CallsDialogRequest.php b/Infobip/Model/CallsDialogRequest.php new file mode 100644 index 0000000..3afae44 --- /dev/null +++ b/Infobip/Model/CallsDialogRequest.php @@ -0,0 +1,123 @@ + null, + 'childCallRequest' => null, + 'recording' => null, + 'maxDuration' => 'int32', + 'propagationOptions' => null + ]; + + /** + */ + public function __construct( + protected ?string $parentCallId = null, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsDialogCallRequest $childCallRequest = null, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsDialogRecordingRequest $recording = null, + protected ?int $maxDuration = 28800, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsDialogPropagationOptions $propagationOptions = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getParentCallId(): string|null + { + return $this->parentCallId; + } + + public function setParentCallId(?string $parentCallId): self + { + $this->parentCallId = $parentCallId; + return $this; + } + + public function getChildCallRequest(): \Infobip\Model\CallsDialogCallRequest|null + { + return $this->childCallRequest; + } + + public function setChildCallRequest(?\Infobip\Model\CallsDialogCallRequest $childCallRequest): self + { + $this->childCallRequest = $childCallRequest; + return $this; + } + + public function getRecording(): \Infobip\Model\CallsDialogRecordingRequest|null + { + return $this->recording; + } + + public function setRecording(?\Infobip\Model\CallsDialogRecordingRequest $recording): self + { + $this->recording = $recording; + return $this; + } + + public function getMaxDuration(): int|null + { + return $this->maxDuration; + } + + public function setMaxDuration(?int $maxDuration): self + { + $this->maxDuration = $maxDuration; + return $this; + } + + public function getPropagationOptions(): \Infobip\Model\CallsDialogPropagationOptions|null + { + return $this->propagationOptions; + } + + public function setPropagationOptions(?\Infobip\Model\CallsDialogPropagationOptions $propagationOptions): self + { + $this->propagationOptions = $propagationOptions; + return $this; + } +} diff --git a/Infobip/Model/CallsDialogResponse.php b/Infobip/Model/CallsDialogResponse.php new file mode 100644 index 0000000..70afb1b --- /dev/null +++ b/Infobip/Model/CallsDialogResponse.php @@ -0,0 +1,168 @@ + null, + 'applicationId' => null, + 'state' => null, + 'startTime' => 'date-time', + 'establishTime' => 'date-time', + 'endTime' => 'date-time', + 'parentCall' => null, + 'childCall' => null + ]; + + /** + */ + public function __construct( + protected ?string $id = null, + protected ?string $applicationId = null, + #[Assert\Choice(['CREATED','ESTABLISHED','FINISHED','FAILED',])] + + protected ?string $state = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $startTime = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $establishTime = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $endTime = null, + #[Assert\Valid] + + protected ?\Infobip\Model\Call $parentCall = null, + #[Assert\Valid] + + protected ?\Infobip\Model\Call $childCall = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getId(): string|null + { + return $this->id; + } + + public function setId(?string $id): self + { + $this->id = $id; + return $this; + } + + public function getApplicationId(): string|null + { + return $this->applicationId; + } + + public function setApplicationId(?string $applicationId): self + { + $this->applicationId = $applicationId; + return $this; + } + + public function getState(): mixed + { + return $this->state; + } + + public function setState($state): self + { + $this->state = $state; + return $this; + } + + public function getStartTime(): \DateTime|null + { + return $this->startTime; + } + + public function setStartTime(?\DateTime $startTime): self + { + $this->startTime = $startTime; + return $this; + } + + public function getEstablishTime(): \DateTime|null + { + return $this->establishTime; + } + + public function setEstablishTime(?\DateTime $establishTime): self + { + $this->establishTime = $establishTime; + return $this; + } + + public function getEndTime(): \DateTime|null + { + return $this->endTime; + } + + public function setEndTime(?\DateTime $endTime): self + { + $this->endTime = $endTime; + return $this; + } + + public function getParentCall(): \Infobip\Model\Call|null + { + return $this->parentCall; + } + + public function setParentCall(?\Infobip\Model\Call $parentCall): self + { + $this->parentCall = $parentCall; + return $this; + } + + public function getChildCall(): \Infobip\Model\Call|null + { + return $this->childCall; + } + + public function setChildCall(?\Infobip\Model\Call $childCall): self + { + $this->childCall = $childCall; + return $this; + } +} diff --git a/Infobip/Model/CallsDialogSayRequest.php b/Infobip/Model/CallsDialogSayRequest.php new file mode 100644 index 0000000..970cfe8 --- /dev/null +++ b/Infobip/Model/CallsDialogSayRequest.php @@ -0,0 +1,124 @@ + null, + 'language' => null, + 'speechRate' => 'double', + 'loopCount' => 'int32', + 'preferences' => null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + + protected string $text, + #[Assert\NotBlank] + #[Assert\Choice(['ar','bn','bg','ca','zh-cn','zh-tw','hr','cs','da','nl','en','en-au','en-gb','en-ca','en-in','en-ie','en-gb-wls','epo','fil-ph','fi','fr','fr-ca','fr-ch','de','de-at','de-ch','el','gu','he','hi','hu','is','id','it','ja','kn','ko','ms','ml','no','pl','pt-pt','pt-br','ro','ru','sk','sl','es','es-gl','es-mx','sv','ta','te','th','tr','uk','vi','wls',])] + + protected string $language, + protected ?float $speechRate = null, + protected ?int $loopCount = null, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsVoicePreferences $preferences = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getText(): string + { + return $this->text; + } + + public function setText(string $text): self + { + $this->text = $text; + return $this; + } + + public function getLanguage(): mixed + { + return $this->language; + } + + public function setLanguage($language): self + { + $this->language = $language; + return $this; + } + + public function getSpeechRate(): float|null + { + return $this->speechRate; + } + + public function setSpeechRate(?float $speechRate): self + { + $this->speechRate = $speechRate; + return $this; + } + + public function getLoopCount(): int|null + { + return $this->loopCount; + } + + public function setLoopCount(?int $loopCount): self + { + $this->loopCount = $loopCount; + return $this; + } + + public function getPreferences(): \Infobip\Model\CallsVoicePreferences|null + { + return $this->preferences; + } + + public function setPreferences(?\Infobip\Model\CallsVoicePreferences $preferences): self + { + $this->preferences = $preferences; + return $this; + } +} diff --git a/Infobip/Model/CallsDialogState.php b/Infobip/Model/CallsDialogState.php new file mode 100644 index 0000000..e77e1da --- /dev/null +++ b/Infobip/Model/CallsDialogState.php @@ -0,0 +1,78 @@ +value = $value; + } + + public static function CREATED(): CallsDialogState + { + return new self('CREATED'); + } + + public static function ESTABLISHED(): CallsDialogState + { + return new self('ESTABLISHED'); + } + + public static function FINISHED(): CallsDialogState + { + return new self('FINISHED'); + } + + public static function FAILED(): CallsDialogState + { + return new self('FAILED'); + } + + public function __toString(): string + { + return $this->value; + } +} diff --git a/Infobip/Model/CallsDtmfCaptureRequest.php b/Infobip/Model/CallsDtmfCaptureRequest.php new file mode 100644 index 0000000..0f1895c --- /dev/null +++ b/Infobip/Model/CallsDtmfCaptureRequest.php @@ -0,0 +1,108 @@ + 'int32', + 'timeout' => 'int32', + 'terminator' => null, + 'digitTimeout' => 'int32' + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + + protected int $maxLength, + #[Assert\NotBlank] + + protected int $timeout, + protected ?string $terminator = null, + protected ?int $digitTimeout = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getMaxLength(): int + { + return $this->maxLength; + } + + public function setMaxLength(int $maxLength): self + { + $this->maxLength = $maxLength; + return $this; + } + + public function getTimeout(): int + { + return $this->timeout; + } + + public function setTimeout(int $timeout): self + { + $this->timeout = $timeout; + return $this; + } + + public function getTerminator(): string|null + { + return $this->terminator; + } + + public function setTerminator(?string $terminator): self + { + $this->terminator = $terminator; + return $this; + } + + public function getDigitTimeout(): int|null + { + return $this->digitTimeout; + } + + public function setDigitTimeout(?int $digitTimeout): self + { + $this->digitTimeout = $digitTimeout; + return $this; + } +} diff --git a/Infobip/Model/CallsDtmfSendRequest.php b/Infobip/Model/CallsDtmfSendRequest.php new file mode 100644 index 0000000..eab6226 --- /dev/null +++ b/Infobip/Model/CallsDtmfSendRequest.php @@ -0,0 +1,67 @@ + null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + + protected string $dtmf, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getDtmf(): string + { + return $this->dtmf; + } + + public function setDtmf(string $dtmf): self + { + $this->dtmf = $dtmf; + return $this; + } +} diff --git a/Infobip/Model/CallsDtmfTermination.php b/Infobip/Model/CallsDtmfTermination.php new file mode 100644 index 0000000..55765ea --- /dev/null +++ b/Infobip/Model/CallsDtmfTermination.php @@ -0,0 +1,80 @@ + null, + 'type' => null + ]; + + /** + */ + public function __construct( + protected ?string $terminator = null, + #[Assert\Choice(['DTMF',])] + + protected ?string $type = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getTerminator(): string|null + { + return $this->terminator; + } + + public function setTerminator(?string $terminator): self + { + $this->terminator = $terminator; + return $this; + } + + public function getType(): mixed + { + return $this->type; + } + + public function setType($type): self + { + $this->type = $type; + return $this; + } +} diff --git a/Infobip/Model/CallsErrorCode.php b/Infobip/Model/CallsErrorCode.php new file mode 100644 index 0000000..f74113f --- /dev/null +++ b/Infobip/Model/CallsErrorCode.php @@ -0,0 +1,253 @@ +value = $value; + } + + public static function NORMAL_HANGUP(): CallsErrorCode + { + return new self('NORMAL_HANGUP'); + } + + public static function ANSWERED_ELSEWHERE(): CallsErrorCode + { + return new self('ANSWERED_ELSEWHERE'); + } + + public static function MACHINE_DETECTED(): CallsErrorCode + { + return new self('MACHINE_DETECTED'); + } + + public static function HUMAN_DETECTED(): CallsErrorCode + { + return new self('HUMAN_DETECTED'); + } + + public static function MAX_DURATION_REACHED(): CallsErrorCode + { + return new self('MAX_DURATION_REACHED'); + } + + public static function DEVICE_FORBIDDEN(): CallsErrorCode + { + return new self('DEVICE_FORBIDDEN'); + } + + public static function DEVICE_NOT_FOUND(): CallsErrorCode + { + return new self('DEVICE_NOT_FOUND'); + } + + public static function DEVICE_UNAVAILABLE(): CallsErrorCode + { + return new self('DEVICE_UNAVAILABLE'); + } + + public static function MEDIA_ERROR(): CallsErrorCode + { + return new self('MEDIA_ERROR'); + } + + public static function NO_ANSWER(): CallsErrorCode + { + return new self('NO_ANSWER'); + } + + public static function BUSY(): CallsErrorCode + { + return new self('BUSY'); + } + + public static function CANCELLED(): CallsErrorCode + { + return new self('CANCELLED'); + } + + public static function REJECTED(): CallsErrorCode + { + return new self('REJECTED'); + } + + public static function FORBIDDEN(): CallsErrorCode + { + return new self('FORBIDDEN'); + } + + public static function INSUFFICIENT_FUNDS(): CallsErrorCode + { + return new self('INSUFFICIENT_FUNDS'); + } + + public static function UNAUTHENTICATED(): CallsErrorCode + { + return new self('UNAUTHENTICATED'); + } + + public static function DESTINATION_NOT_FOUND(): CallsErrorCode + { + return new self('DESTINATION_NOT_FOUND'); + } + + public static function DESTINATION_UNAVAILABLE(): CallsErrorCode + { + return new self('DESTINATION_UNAVAILABLE'); + } + + public static function INVALID_DESTINATION(): CallsErrorCode + { + return new self('INVALID_DESTINATION'); + } + + public static function INVALID_REQUEST(): CallsErrorCode + { + return new self('INVALID_REQUEST'); + } + + public static function REQUEST_TIMEOUT(): CallsErrorCode + { + return new self('REQUEST_TIMEOUT'); + } + + public static function NETWORK_ERROR(): CallsErrorCode + { + return new self('NETWORK_ERROR'); + } + + public static function SERVICE_UNAVAILABLE(): CallsErrorCode + { + return new self('SERVICE_UNAVAILABLE'); + } + + public static function UNKNOWN(): CallsErrorCode + { + return new self('UNKNOWN'); + } + + public static function FEATURE_UNAVAILABLE(): CallsErrorCode + { + return new self('FEATURE_UNAVAILABLE'); + } + + public static function CONGESTION(): CallsErrorCode + { + return new self('CONGESTION'); + } + + public static function URL_NOT_FOUND(): CallsErrorCode + { + return new self('URL_NOT_FOUND'); + } + + public static function URL_UNREACHABLE(): CallsErrorCode + { + return new self('URL_UNREACHABLE'); + } + + public static function INVALID_RESPONSE(): CallsErrorCode + { + return new self('INVALID_RESPONSE'); + } + + public function __toString(): string + { + return $this->value; + } +} diff --git a/Infobip/Model/CallsErrorCodeInfo.php b/Infobip/Model/CallsErrorCodeInfo.php new file mode 100644 index 0000000..892108a --- /dev/null +++ b/Infobip/Model/CallsErrorCodeInfo.php @@ -0,0 +1,91 @@ + 'int32', + 'name' => null, + 'description' => null + ]; + + /** + */ + public function __construct( + protected ?int $id = null, + protected ?string $name = null, + protected ?string $description = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getId(): int|null + { + return $this->id; + } + + public function setId(?int $id): self + { + $this->id = $id; + return $this; + } + + public function getName(): string|null + { + return $this->name; + } + + public function setName(?string $name): self + { + $this->name = $name; + return $this; + } + + public function getDescription(): string|null + { + return $this->description; + } + + public function setDescription(?string $description): self + { + $this->description = $description; + return $this; + } +} diff --git a/Infobip/Model/CallsFile.php b/Infobip/Model/CallsFile.php new file mode 100644 index 0000000..df70988 --- /dev/null +++ b/Infobip/Model/CallsFile.php @@ -0,0 +1,167 @@ + null, + 'name' => null, + 'fileFormat' => null, + 'size' => 'int64', + 'creationMethod' => null, + 'creationTime' => 'date-time', + 'expirationTime' => 'date-time', + 'duration' => 'int64' + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + + protected string $name, + #[Assert\NotBlank] + #[Assert\Choice(['MP3','WAV','MP4',])] + + protected string $fileFormat, + protected ?string $id = null, + protected ?int $size = null, + #[Assert\Choice(['UPLOADED','SYNTHESIZED','RECORDED',])] + + protected ?string $creationMethod = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $creationTime = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $expirationTime = null, + protected ?int $duration = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getId(): string|null + { + return $this->id; + } + + public function setId(?string $id): self + { + $this->id = $id; + return $this; + } + + public function getName(): string + { + return $this->name; + } + + public function setName(string $name): self + { + $this->name = $name; + return $this; + } + + public function getFileFormat(): mixed + { + return $this->fileFormat; + } + + public function setFileFormat($fileFormat): self + { + $this->fileFormat = $fileFormat; + return $this; + } + + public function getSize(): int|null + { + return $this->size; + } + + public function setSize(?int $size): self + { + $this->size = $size; + return $this; + } + + public function getCreationMethod(): mixed + { + return $this->creationMethod; + } + + public function setCreationMethod($creationMethod): self + { + $this->creationMethod = $creationMethod; + return $this; + } + + public function getCreationTime(): \DateTime|null + { + return $this->creationTime; + } + + public function setCreationTime(?\DateTime $creationTime): self + { + $this->creationTime = $creationTime; + return $this; + } + + public function getExpirationTime(): \DateTime|null + { + return $this->expirationTime; + } + + public function setExpirationTime(?\DateTime $expirationTime): self + { + $this->expirationTime = $expirationTime; + return $this; + } + + public function getDuration(): int|null + { + return $this->duration; + } + + public function setDuration(?int $duration): self + { + $this->duration = $duration; + return $this; + } +} diff --git a/Infobip/Model/CallsFileFormat.php b/Infobip/Model/CallsFileFormat.php new file mode 100644 index 0000000..5e86173 --- /dev/null +++ b/Infobip/Model/CallsFileFormat.php @@ -0,0 +1,71 @@ +value = $value; + } + + public static function MP3(): CallsFileFormat + { + return new self('MP3'); + } + + public static function WAV(): CallsFileFormat + { + return new self('WAV'); + } + + public static function MP4(): CallsFileFormat + { + return new self('MP4'); + } + + public function __toString(): string + { + return $this->value; + } +} diff --git a/Infobip/Model/CallsFilePage.php b/Infobip/Model/CallsFilePage.php new file mode 100644 index 0000000..055f236 --- /dev/null +++ b/Infobip/Model/CallsFilePage.php @@ -0,0 +1,87 @@ + null, + 'paging' => null + ]; + + /** + * @param \Infobip\Model\CallsFile[] $results + */ + public function __construct( + protected ?array $results = null, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsPageInfo $paging = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + /** + * @return \Infobip\Model\CallsFile[]|null + */ + public function getResults(): ?array + { + return $this->results; + } + + /** + * @param \Infobip\Model\CallsFile[]|null $results The list of the results for this page. + */ + public function setResults(?array $results): self + { + $this->results = $results; + return $this; + } + + public function getPaging(): \Infobip\Model\CallsPageInfo|null + { + return $this->paging; + } + + public function setPaging(?\Infobip\Model\CallsPageInfo $paging): self + { + $this->paging = $paging; + return $this; + } +} diff --git a/Infobip/Model/CallsFilePlayContent.php b/Infobip/Model/CallsFilePlayContent.php new file mode 100644 index 0000000..1d91e30 --- /dev/null +++ b/Infobip/Model/CallsFilePlayContent.php @@ -0,0 +1,73 @@ + null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + + protected string $fileId, + ) { + $modelDiscriminatorValue = 'FILE'; + + parent::__construct( + type: $modelDiscriminatorValue, + ); + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getFileId(): string + { + return $this->fileId; + } + + public function setFileId(string $fileId): self + { + $this->fileId = $fileId; + return $this; + } +} diff --git a/Infobip/Model/CallsGender.php b/Infobip/Model/CallsGender.php new file mode 100644 index 0000000..5b8fa16 --- /dev/null +++ b/Infobip/Model/CallsGender.php @@ -0,0 +1,64 @@ +value = $value; + } + + public static function FEMALE(): CallsGender + { + return new self('FEMALE'); + } + + public static function MALE(): CallsGender + { + return new self('MALE'); + } + + public function __toString(): string + { + return $this->value; + } +} diff --git a/Infobip/Model/CallsGetVoicesResponse.php b/Infobip/Model/CallsGetVoicesResponse.php new file mode 100644 index 0000000..6cad9e8 --- /dev/null +++ b/Infobip/Model/CallsGetVoicesResponse.php @@ -0,0 +1,72 @@ + null + ]; + + /** + * @param \Infobip\Model\CallsVoice[] $voices + */ + public function __construct( + protected ?array $voices = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + /** + * @return \Infobip\Model\CallsVoice[]|null + */ + public function getVoices(): ?array + { + return $this->voices; + } + + /** + * @param \Infobip\Model\CallsVoice[]|null $voices Array of voices belonging to the specified language. + */ + public function setVoices(?array $voices): self + { + $this->voices = $voices; + return $this; + } +} diff --git a/Infobip/Model/CallsHangupRequest.php b/Infobip/Model/CallsHangupRequest.php new file mode 100644 index 0000000..2c9192a --- /dev/null +++ b/Infobip/Model/CallsHangupRequest.php @@ -0,0 +1,67 @@ + null + ]; + + /** + */ + public function __construct( + #[Assert\Choice(['NORMAL_HANGUP','ANSWERED_ELSEWHERE','MACHINE_DETECTED','HUMAN_DETECTED','MAX_DURATION_REACHED','DEVICE_FORBIDDEN','DEVICE_NOT_FOUND','DEVICE_UNAVAILABLE','MEDIA_ERROR','NO_ANSWER','BUSY','CANCELLED','REJECTED','FORBIDDEN','INSUFFICIENT_FUNDS','UNAUTHENTICATED','DESTINATION_NOT_FOUND','DESTINATION_UNAVAILABLE','INVALID_DESTINATION','INVALID_REQUEST','REQUEST_TIMEOUT','NETWORK_ERROR','SERVICE_UNAVAILABLE','UNKNOWN','FEATURE_UNAVAILABLE','CONGESTION','URL_NOT_FOUND','URL_UNREACHABLE','INVALID_RESPONSE',])] + + protected ?string $errorCode = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getErrorCode(): mixed + { + return $this->errorCode; + } + + public function setErrorCode($errorCode): self + { + $this->errorCode = $errorCode; + return $this; + } +} diff --git a/Infobip/Model/CallsHmacAlgorithm.php b/Infobip/Model/CallsHmacAlgorithm.php new file mode 100644 index 0000000..6b5272c --- /dev/null +++ b/Infobip/Model/CallsHmacAlgorithm.php @@ -0,0 +1,92 @@ +value = $value; + } + + public static function MD5(): CallsHmacAlgorithm + { + return new self('HMAC_MD5'); + } + + public static function SHA_1(): CallsHmacAlgorithm + { + return new self('HMAC_SHA_1'); + } + + public static function SHA_224(): CallsHmacAlgorithm + { + return new self('HMAC_SHA_224'); + } + + public static function SHA_256(): CallsHmacAlgorithm + { + return new self('HMAC_SHA_256'); + } + + public static function SHA_384(): CallsHmacAlgorithm + { + return new self('HMAC_SHA_384'); + } + + public static function SHA_512(): CallsHmacAlgorithm + { + return new self('HMAC_SHA_512'); + } + + public function __toString(): string + { + return $this->value; + } +} diff --git a/Infobip/Model/CallsHmacUrlSecurityConfig.php b/Infobip/Model/CallsHmacUrlSecurityConfig.php new file mode 100644 index 0000000..340f1b9 --- /dev/null +++ b/Infobip/Model/CallsHmacUrlSecurityConfig.php @@ -0,0 +1,89 @@ + null, + 'algorithm' => null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + + protected string $secretKey, + #[Assert\NotBlank] + #[Assert\Choice(['HMAC_MD5','HMAC_SHA_1','HMAC_SHA_224','HMAC_SHA_256','HMAC_SHA_384','HMAC_SHA_512',])] + + protected string $algorithm, + ) { + $modelDiscriminatorValue = 'HMAC'; + + parent::__construct( + type: $modelDiscriminatorValue, + ); + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getSecretKey(): string + { + return $this->secretKey; + } + + public function setSecretKey(string $secretKey): self + { + $this->secretKey = $secretKey; + return $this; + } + + public function getAlgorithm(): mixed + { + return $this->algorithm; + } + + public function setAlgorithm($algorithm): self + { + $this->algorithm = $algorithm; + return $this; + } +} diff --git a/Infobip/Model/CallsLanguage.php b/Infobip/Model/CallsLanguage.php new file mode 100644 index 0000000..9271a2b --- /dev/null +++ b/Infobip/Model/CallsLanguage.php @@ -0,0 +1,456 @@ +value = $value; + } + + public static function AR(): CallsLanguage + { + return new self('ar'); + } + + public static function BN(): CallsLanguage + { + return new self('bn'); + } + + public static function BG(): CallsLanguage + { + return new self('bg'); + } + + public static function CA(): CallsLanguage + { + return new self('ca'); + } + + public static function ZH_CN(): CallsLanguage + { + return new self('zh-cn'); + } + + public static function ZH_TW(): CallsLanguage + { + return new self('zh-tw'); + } + + public static function HR(): CallsLanguage + { + return new self('hr'); + } + + public static function CS(): CallsLanguage + { + return new self('cs'); + } + + public static function DA(): CallsLanguage + { + return new self('da'); + } + + public static function NL(): CallsLanguage + { + return new self('nl'); + } + + public static function EN(): CallsLanguage + { + return new self('en'); + } + + public static function EN_AU(): CallsLanguage + { + return new self('en-au'); + } + + public static function EN_GB(): CallsLanguage + { + return new self('en-gb'); + } + + public static function EN_CA(): CallsLanguage + { + return new self('en-ca'); + } + + public static function EN_IN(): CallsLanguage + { + return new self('en-in'); + } + + public static function EN_IE(): CallsLanguage + { + return new self('en-ie'); + } + + public static function EN_GB_WLS(): CallsLanguage + { + return new self('en-gb-wls'); + } + + public static function EPO(): CallsLanguage + { + return new self('epo'); + } + + public static function FIL_PH(): CallsLanguage + { + return new self('fil-ph'); + } + + public static function FI(): CallsLanguage + { + return new self('fi'); + } + + public static function FR(): CallsLanguage + { + return new self('fr'); + } + + public static function FR_CA(): CallsLanguage + { + return new self('fr-ca'); + } + + public static function FR_CH(): CallsLanguage + { + return new self('fr-ch'); + } + + public static function DE(): CallsLanguage + { + return new self('de'); + } + + public static function DE_AT(): CallsLanguage + { + return new self('de-at'); + } + + public static function DE_CH(): CallsLanguage + { + return new self('de-ch'); + } + + public static function EL(): CallsLanguage + { + return new self('el'); + } + + public static function GU(): CallsLanguage + { + return new self('gu'); + } + + public static function HE(): CallsLanguage + { + return new self('he'); + } + + public static function HI(): CallsLanguage + { + return new self('hi'); + } + + public static function HU(): CallsLanguage + { + return new self('hu'); + } + + public static function IS(): CallsLanguage + { + return new self('is'); + } + + public static function ID(): CallsLanguage + { + return new self('id'); + } + + public static function IT(): CallsLanguage + { + return new self('it'); + } + + public static function JA(): CallsLanguage + { + return new self('ja'); + } + + public static function KN(): CallsLanguage + { + return new self('kn'); + } + + public static function KO(): CallsLanguage + { + return new self('ko'); + } + + public static function MS(): CallsLanguage + { + return new self('ms'); + } + + public static function ML(): CallsLanguage + { + return new self('ml'); + } + + public static function NO(): CallsLanguage + { + return new self('no'); + } + + public static function PL(): CallsLanguage + { + return new self('pl'); + } + + public static function PT_PT(): CallsLanguage + { + return new self('pt-pt'); + } + + public static function PT_BR(): CallsLanguage + { + return new self('pt-br'); + } + + public static function RO(): CallsLanguage + { + return new self('ro'); + } + + public static function RU(): CallsLanguage + { + return new self('ru'); + } + + public static function SK(): CallsLanguage + { + return new self('sk'); + } + + public static function SL(): CallsLanguage + { + return new self('sl'); + } + + public static function ES(): CallsLanguage + { + return new self('es'); + } + + public static function ES_GL(): CallsLanguage + { + return new self('es-gl'); + } + + public static function ES_MX(): CallsLanguage + { + return new self('es-mx'); + } + + public static function SV(): CallsLanguage + { + return new self('sv'); + } + + public static function TA(): CallsLanguage + { + return new self('ta'); + } + + public static function TE(): CallsLanguage + { + return new self('te'); + } + + public static function TH(): CallsLanguage + { + return new self('th'); + } + + public static function TR(): CallsLanguage + { + return new self('tr'); + } + + public static function UK(): CallsLanguage + { + return new self('uk'); + } + + public static function VI(): CallsLanguage + { + return new self('vi'); + } + + public static function WLS(): CallsLanguage + { + return new self('wls'); + } + + public function __toString(): string + { + return $this->value; + } +} diff --git a/Infobip/Model/CallsMachineDetectionProperties.php b/Infobip/Model/CallsMachineDetectionProperties.php new file mode 100644 index 0000000..46d6bf0 --- /dev/null +++ b/Infobip/Model/CallsMachineDetectionProperties.php @@ -0,0 +1,67 @@ + null + ]; + + /** + */ + public function __construct( + #[Assert\Choice(['HUMAN','MACHINE','UNKNOWN',])] + + protected ?string $detectionResult = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getDetectionResult(): mixed + { + return $this->detectionResult; + } + + public function setDetectionResult($detectionResult): self + { + $this->detectionResult = $detectionResult; + return $this; + } +} diff --git a/Infobip/Model/CallsMachineDetectionRequest.php b/Infobip/Model/CallsMachineDetectionRequest.php new file mode 100644 index 0000000..049d020 --- /dev/null +++ b/Infobip/Model/CallsMachineDetectionRequest.php @@ -0,0 +1,65 @@ + null + ]; + + /** + */ + public function __construct( + protected ?bool $enabled = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getEnabled(): bool|null + { + return $this->enabled; + } + + public function setEnabled(?bool $enabled): self + { + $this->enabled = $enabled; + return $this; + } +} diff --git a/Infobip/Model/CallsMediaProperties.php b/Infobip/Model/CallsMediaProperties.php new file mode 100644 index 0000000..da9a807 --- /dev/null +++ b/Infobip/Model/CallsMediaProperties.php @@ -0,0 +1,82 @@ + null, + 'video' => null + ]; + + /** + */ + public function __construct( + #[Assert\Valid] + + protected ?\Infobip\Model\CallsAudioMediaProperties $audio = null, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsVideoMediaProperties $video = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getAudio(): \Infobip\Model\CallsAudioMediaProperties|null + { + return $this->audio; + } + + public function setAudio(?\Infobip\Model\CallsAudioMediaProperties $audio): self + { + $this->audio = $audio; + return $this; + } + + public function getVideo(): \Infobip\Model\CallsVideoMediaProperties|null + { + return $this->video; + } + + public function setVideo(?\Infobip\Model\CallsVideoMediaProperties $video): self + { + $this->video = $video; + return $this; + } +} diff --git a/Infobip/Model/CallsMediaStream.php b/Infobip/Model/CallsMediaStream.php new file mode 100644 index 0000000..451c34a --- /dev/null +++ b/Infobip/Model/CallsMediaStream.php @@ -0,0 +1,67 @@ + null + ]; + + /** + */ + public function __construct( + #[Assert\Valid] + + protected ?\Infobip\Model\CallsMediaStreamAudioProperties $audioProperties = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getAudioProperties(): \Infobip\Model\CallsMediaStreamAudioProperties|null + { + return $this->audioProperties; + } + + public function setAudioProperties(?\Infobip\Model\CallsMediaStreamAudioProperties $audioProperties): self + { + $this->audioProperties = $audioProperties; + return $this; + } +} diff --git a/Infobip/Model/CallsMediaStreamAudioProperties.php b/Infobip/Model/CallsMediaStreamAudioProperties.php new file mode 100644 index 0000000..ae2a4b5 --- /dev/null +++ b/Infobip/Model/CallsMediaStreamAudioProperties.php @@ -0,0 +1,80 @@ + null, + 'replaceMedia' => null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + + protected string $mediaStreamConfigId, + protected ?bool $replaceMedia = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getMediaStreamConfigId(): string + { + return $this->mediaStreamConfigId; + } + + public function setMediaStreamConfigId(string $mediaStreamConfigId): self + { + $this->mediaStreamConfigId = $mediaStreamConfigId; + return $this; + } + + public function getReplaceMedia(): bool|null + { + return $this->replaceMedia; + } + + public function setReplaceMedia(?bool $replaceMedia): self + { + $this->replaceMedia = $replaceMedia; + return $this; + } +} diff --git a/Infobip/Model/CallsMediaStreamConfigPage.php b/Infobip/Model/CallsMediaStreamConfigPage.php new file mode 100644 index 0000000..b6a3082 --- /dev/null +++ b/Infobip/Model/CallsMediaStreamConfigPage.php @@ -0,0 +1,87 @@ + null, + 'paging' => null + ]; + + /** + * @param \Infobip\Model\CallsMediaStreamConfigResponse[] $results + */ + public function __construct( + protected ?array $results = null, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsPageInfo $paging = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + /** + * @return \Infobip\Model\CallsMediaStreamConfigResponse[]|null + */ + public function getResults(): ?array + { + return $this->results; + } + + /** + * @param \Infobip\Model\CallsMediaStreamConfigResponse[]|null $results The list of the results for this page. + */ + public function setResults(?array $results): self + { + $this->results = $results; + return $this; + } + + public function getPaging(): \Infobip\Model\CallsPageInfo|null + { + return $this->paging; + } + + public function setPaging(?\Infobip\Model\CallsPageInfo $paging): self + { + $this->paging = $paging; + return $this; + } +} diff --git a/Infobip/Model/CallsMediaStreamConfigRequest.php b/Infobip/Model/CallsMediaStreamConfigRequest.php new file mode 100644 index 0000000..95aaf6d --- /dev/null +++ b/Infobip/Model/CallsMediaStreamConfigRequest.php @@ -0,0 +1,82 @@ + null, + 'securityConfig' => null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + + protected string $url, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsUrlSecurityConfig $securityConfig = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getUrl(): string + { + return $this->url; + } + + public function setUrl(string $url): self + { + $this->url = $url; + return $this; + } + + public function getSecurityConfig(): \Infobip\Model\CallsUrlSecurityConfig|null + { + return $this->securityConfig; + } + + public function setSecurityConfig(?\Infobip\Model\CallsUrlSecurityConfig $securityConfig): self + { + $this->securityConfig = $securityConfig; + return $this; + } +} diff --git a/Infobip/Model/CallsMediaStreamConfigResponse.php b/Infobip/Model/CallsMediaStreamConfigResponse.php new file mode 100644 index 0000000..037387c --- /dev/null +++ b/Infobip/Model/CallsMediaStreamConfigResponse.php @@ -0,0 +1,80 @@ + null, + 'url' => null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + + protected string $url, + protected ?string $id = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getId(): string|null + { + return $this->id; + } + + public function setId(?string $id): self + { + $this->id = $id; + return $this; + } + + public function getUrl(): string + { + return $this->url; + } + + public function setUrl(string $url): self + { + $this->url = $url; + return $this; + } +} diff --git a/Infobip/Model/CallsMultiBody.php b/Infobip/Model/CallsMultiBody.php new file mode 100644 index 0000000..602c1fb --- /dev/null +++ b/Infobip/Model/CallsMultiBody.php @@ -0,0 +1,74 @@ + null + ]; + + /** + * @param \Infobip\Model\CallsMultiMessage[] $messages + */ + public function __construct( + #[Assert\NotBlank] + + protected array $messages, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + /** + * @return \Infobip\Model\CallsMultiMessage[] + */ + public function getMessages(): array + { + return $this->messages; + } + + /** + * @param \Infobip\Model\CallsMultiMessage[] $messages Array of messages to be sent, one per every message + */ + public function setMessages(array $messages): self + { + $this->messages = $messages; + return $this; + } +} diff --git a/Infobip/Model/CallsMultiMessage.php b/Infobip/Model/CallsMultiMessage.php new file mode 100644 index 0000000..aa24fd5 --- /dev/null +++ b/Infobip/Model/CallsMultiMessage.php @@ -0,0 +1,141 @@ + null, + 'from' => null, + 'language' => null, + 'text' => null, + 'to' => null, + 'voice' => null + ]; + + /** + * @param string[] $to + */ + public function __construct( + #[Assert\NotBlank] + + protected array $to, + protected ?string $audioFileUrl = null, + protected ?string $from = null, + protected ?string $language = null, + protected ?string $text = null, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsVoice $voice = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getAudioFileUrl(): string|null + { + return $this->audioFileUrl; + } + + public function setAudioFileUrl(?string $audioFileUrl): self + { + $this->audioFileUrl = $audioFileUrl; + return $this; + } + + public function getFrom(): string|null + { + return $this->from; + } + + public function setFrom(?string $from): self + { + $this->from = $from; + return $this; + } + + public function getLanguage(): string|null + { + return $this->language; + } + + public function setLanguage(?string $language): self + { + $this->language = $language; + return $this; + } + + public function getText(): string|null + { + return $this->text; + } + + public function setText(?string $text): self + { + $this->text = $text; + return $this; + } + + /** + * @return string[] + */ + public function getTo(): array + { + return $this->to; + } + + /** + * @param string[] $to Phone number of the recipient. Phone number must be written in E.164 standard format (Example: 41793026727). + */ + public function setTo(array $to): self + { + $this->to = $to; + return $this; + } + + public function getVoice(): \Infobip\Model\CallsVoice|null + { + return $this->voice; + } + + public function setVoice(?\Infobip\Model\CallsVoice $voice): self + { + $this->voice = $voice; + return $this; + } +} diff --git a/Infobip/Model/CallsOnDemandComposition.php b/Infobip/Model/CallsOnDemandComposition.php new file mode 100644 index 0000000..c44edd2 --- /dev/null +++ b/Infobip/Model/CallsOnDemandComposition.php @@ -0,0 +1,65 @@ + null + ]; + + /** + */ + public function __construct( + protected ?bool $deleteCallRecordings = true, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getDeleteCallRecordings(): bool|null + { + return $this->deleteCallRecordings; + } + + public function setDeleteCallRecordings(?bool $deleteCallRecordings): self + { + $this->deleteCallRecordings = $deleteCallRecordings; + return $this; + } +} diff --git a/Infobip/Model/CallsPageInfo.php b/Infobip/Model/CallsPageInfo.php new file mode 100644 index 0000000..2c66263 --- /dev/null +++ b/Infobip/Model/CallsPageInfo.php @@ -0,0 +1,116 @@ + 'int32', + 'size' => 'int32', + 'totalPages' => 'int32', + 'totalResults' => 'int64' + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + #[Assert\GreaterThan(0)] + + protected int $page, + #[Assert\NotBlank] + #[Assert\GreaterThan(1)] + + protected int $size, + #[Assert\NotBlank] + #[Assert\GreaterThan(0)] + + protected int $totalPages, + #[Assert\NotBlank] + #[Assert\GreaterThan(0)] + + protected int $totalResults, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getPage(): int + { + return $this->page; + } + + public function setPage(int $page): self + { + $this->page = $page; + return $this; + } + + public function getSize(): int + { + return $this->size; + } + + public function setSize(int $size): self + { + $this->size = $size; + return $this; + } + + public function getTotalPages(): int + { + return $this->totalPages; + } + + public function setTotalPages(int $totalPages): self + { + $this->totalPages = $totalPages; + return $this; + } + + public function getTotalResults(): int + { + return $this->totalResults; + } + + public function setTotalResults(int $totalResults): self + { + $this->totalResults = $totalResults; + return $this; + } +} diff --git a/Infobip/Model/CallsParticipant.php b/Infobip/Model/CallsParticipant.php new file mode 100644 index 0000000..4c776ef --- /dev/null +++ b/Infobip/Model/CallsParticipant.php @@ -0,0 +1,126 @@ + null, + 'endpoint' => null, + 'state' => null, + 'joinTime' => 'date-time', + 'media' => null + ]; + + /** + */ + public function __construct( + #[Assert\Valid] + #[Assert\NotBlank] + + protected \Infobip\Model\CallEndpoint $endpoint, + protected ?string $callId = null, + #[Assert\Choice(['JOINING','JOINED',])] + + protected ?string $state = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $joinTime = null, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsMediaProperties $media = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getCallId(): string|null + { + return $this->callId; + } + + public function setCallId(?string $callId): self + { + $this->callId = $callId; + return $this; + } + + public function getEndpoint(): \Infobip\Model\CallEndpoint + { + return $this->endpoint; + } + + public function setEndpoint(\Infobip\Model\CallEndpoint $endpoint): self + { + $this->endpoint = $endpoint; + return $this; + } + + public function getState(): mixed + { + return $this->state; + } + + public function setState($state): self + { + $this->state = $state; + return $this; + } + + public function getJoinTime(): \DateTime|null + { + return $this->joinTime; + } + + public function setJoinTime(?\DateTime $joinTime): self + { + $this->joinTime = $joinTime; + return $this; + } + + public function getMedia(): \Infobip\Model\CallsMediaProperties|null + { + return $this->media; + } + + public function setMedia(?\Infobip\Model\CallsMediaProperties $media): self + { + $this->media = $media; + return $this; + } +} diff --git a/Infobip/Model/CallsParticipantSession.php b/Infobip/Model/CallsParticipantSession.php new file mode 100644 index 0000000..b96e93d --- /dev/null +++ b/Infobip/Model/CallsParticipantSession.php @@ -0,0 +1,95 @@ + null, + 'joinTime' => 'date-time', + 'leaveTime' => 'date-time' + ]; + + /** + */ + public function __construct( + protected ?string $callId = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $joinTime = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $leaveTime = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getCallId(): string|null + { + return $this->callId; + } + + public function setCallId(?string $callId): self + { + $this->callId = $callId; + return $this; + } + + public function getJoinTime(): \DateTime|null + { + return $this->joinTime; + } + + public function setJoinTime(?\DateTime $joinTime): self + { + $this->joinTime = $joinTime; + return $this; + } + + public function getLeaveTime(): \DateTime|null + { + return $this->leaveTime; + } + + public function setLeaveTime(?\DateTime $leaveTime): self + { + $this->leaveTime = $leaveTime; + return $this; + } +} diff --git a/Infobip/Model/CallsParticipantState.php b/Infobip/Model/CallsParticipantState.php new file mode 100644 index 0000000..4ac4ea8 --- /dev/null +++ b/Infobip/Model/CallsParticipantState.php @@ -0,0 +1,64 @@ +value = $value; + } + + public static function JOINING(): CallsParticipantState + { + return new self('JOINING'); + } + + public static function JOINED(): CallsParticipantState + { + return new self('JOINED'); + } + + public function __toString(): string + { + return $this->value; + } +} diff --git a/Infobip/Model/CallsPhoneEndpoint.php b/Infobip/Model/CallsPhoneEndpoint.php new file mode 100644 index 0000000..c12e64b --- /dev/null +++ b/Infobip/Model/CallsPhoneEndpoint.php @@ -0,0 +1,73 @@ + null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + + protected string $phoneNumber, + ) { + $modelDiscriminatorValue = 'PHONE'; + + parent::__construct( + type: $modelDiscriminatorValue, + ); + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getPhoneNumber(): string + { + return $this->phoneNumber; + } + + public function setPhoneNumber(string $phoneNumber): self + { + $this->phoneNumber = $phoneNumber; + return $this; + } +} diff --git a/Infobip/Model/CallsPlayContent.php b/Infobip/Model/CallsPlayContent.php new file mode 100644 index 0000000..39a763b --- /dev/null +++ b/Infobip/Model/CallsPlayContent.php @@ -0,0 +1,73 @@ + "\Infobip\Model\CallsFilePlayContent", + "CallsUrlPlayContent" => "\Infobip\Model\CallsUrlPlayContent", + "FILE" => "\Infobip\Model\CallsFilePlayContent", + "URL" => "\Infobip\Model\CallsUrlPlayContent", +])] +class CallsPlayContent implements ModelInterface +{ + public const DISCRIMINATOR = 'type'; + public const OPENAPI_MODEL_NAME = 'CallsPlayContent'; + + public const OPENAPI_FORMATS = [ + 'type' => null + ]; + + /** + */ + public function __construct( + #[Assert\Choice(['FILE','URL','RECORDING',])] + + protected ?string $type = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getType(): mixed + { + return $this->type; + } + + public function setType($type): self + { + $this->type = $type; + return $this; + } +} diff --git a/Infobip/Model/CallsPlayContentType.php b/Infobip/Model/CallsPlayContentType.php new file mode 100644 index 0000000..827e873 --- /dev/null +++ b/Infobip/Model/CallsPlayContentType.php @@ -0,0 +1,71 @@ +value = $value; + } + + public static function FILE(): CallsPlayContentType + { + return new self('FILE'); + } + + public static function URL(): CallsPlayContentType + { + return new self('URL'); + } + + public static function RECORDING(): CallsPlayContentType + { + return new self('RECORDING'); + } + + public function __toString(): string + { + return $this->value; + } +} diff --git a/Infobip/Model/CallsPlayRequest.php b/Infobip/Model/CallsPlayRequest.php new file mode 100644 index 0000000..83aeb1a --- /dev/null +++ b/Infobip/Model/CallsPlayRequest.php @@ -0,0 +1,81 @@ + 'int32', + 'content' => null + ]; + + /** + */ + public function __construct( + #[Assert\Valid] + #[Assert\NotBlank] + + protected \Infobip\Model\CallsPlayContent $content, + protected ?int $loopCount = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getLoopCount(): int|null + { + return $this->loopCount; + } + + public function setLoopCount(?int $loopCount): self + { + $this->loopCount = $loopCount; + return $this; + } + + public function getContent(): \Infobip\Model\CallsPlayContent + { + return $this->content; + } + + public function setContent(\Infobip\Model\CallsPlayContent $content): self + { + $this->content = $content; + return $this; + } +} diff --git a/Infobip/Model/CallsRecordingFile.php b/Infobip/Model/CallsRecordingFile.php new file mode 100644 index 0000000..09a08bf --- /dev/null +++ b/Infobip/Model/CallsRecordingFile.php @@ -0,0 +1,212 @@ + null, + 'name' => null, + 'fileFormat' => null, + 'size' => 'int64', + 'creationMethod' => null, + 'creationTime' => 'date-time', + 'expirationTime' => 'date-time', + 'duration' => 'int64', + 'startTime' => 'date-time', + 'endTime' => 'date-time', + 'location' => null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + + protected string $name, + #[Assert\NotBlank] + #[Assert\Choice(['MP3','WAV','MP4',])] + + protected string $fileFormat, + protected ?string $id = null, + protected ?int $size = null, + #[Assert\Choice(['UPLOADED','SYNTHESIZED','RECORDED',])] + + protected ?string $creationMethod = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $creationTime = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $expirationTime = null, + protected ?int $duration = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $startTime = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $endTime = null, + #[Assert\Choice(['SFTP','HOSTED',])] + + protected ?string $location = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getId(): string|null + { + return $this->id; + } + + public function setId(?string $id): self + { + $this->id = $id; + return $this; + } + + public function getName(): string + { + return $this->name; + } + + public function setName(string $name): self + { + $this->name = $name; + return $this; + } + + public function getFileFormat(): mixed + { + return $this->fileFormat; + } + + public function setFileFormat($fileFormat): self + { + $this->fileFormat = $fileFormat; + return $this; + } + + public function getSize(): int|null + { + return $this->size; + } + + public function setSize(?int $size): self + { + $this->size = $size; + return $this; + } + + public function getCreationMethod(): mixed + { + return $this->creationMethod; + } + + public function setCreationMethod($creationMethod): self + { + $this->creationMethod = $creationMethod; + return $this; + } + + public function getCreationTime(): \DateTime|null + { + return $this->creationTime; + } + + public function setCreationTime(?\DateTime $creationTime): self + { + $this->creationTime = $creationTime; + return $this; + } + + public function getExpirationTime(): \DateTime|null + { + return $this->expirationTime; + } + + public function setExpirationTime(?\DateTime $expirationTime): self + { + $this->expirationTime = $expirationTime; + return $this; + } + + public function getDuration(): int|null + { + return $this->duration; + } + + public function setDuration(?int $duration): self + { + $this->duration = $duration; + return $this; + } + + public function getStartTime(): \DateTime|null + { + return $this->startTime; + } + + public function setStartTime(?\DateTime $startTime): self + { + $this->startTime = $startTime; + return $this; + } + + public function getEndTime(): \DateTime|null + { + return $this->endTime; + } + + public function setEndTime(?\DateTime $endTime): self + { + $this->endTime = $endTime; + return $this; + } + + public function getLocation(): mixed + { + return $this->location; + } + + public function setLocation($location): self + { + $this->location = $location; + return $this; + } +} diff --git a/Infobip/Model/CallsRecordingFileLocation.php b/Infobip/Model/CallsRecordingFileLocation.php new file mode 100644 index 0000000..7a3e6dc --- /dev/null +++ b/Infobip/Model/CallsRecordingFileLocation.php @@ -0,0 +1,64 @@ +value = $value; + } + + public static function SFTP(): CallsRecordingFileLocation + { + return new self('SFTP'); + } + + public static function HOSTED(): CallsRecordingFileLocation + { + return new self('HOSTED'); + } + + public function __toString(): string + { + return $this->value; + } +} diff --git a/Infobip/Model/CallsRecordingRequest.php b/Infobip/Model/CallsRecordingRequest.php new file mode 100644 index 0000000..657a209 --- /dev/null +++ b/Infobip/Model/CallsRecordingRequest.php @@ -0,0 +1,94 @@ + null, + 'maxSilence' => 'int32', + 'beep' => null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + #[Assert\Choice(['AUDIO','AUDIO_AND_VIDEO',])] + + protected string $recordingType, + protected ?int $maxSilence = null, + protected ?bool $beep = false, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getRecordingType(): mixed + { + return $this->recordingType; + } + + public function setRecordingType($recordingType): self + { + $this->recordingType = $recordingType; + return $this; + } + + public function getMaxSilence(): int|null + { + return $this->maxSilence; + } + + public function setMaxSilence(?int $maxSilence): self + { + $this->maxSilence = $maxSilence; + return $this; + } + + public function getBeep(): bool|null + { + return $this->beep; + } + + public function setBeep(?bool $beep): self + { + $this->beep = $beep; + return $this; + } +} diff --git a/Infobip/Model/CallsRecordingStartRequest.php b/Infobip/Model/CallsRecordingStartRequest.php new file mode 100644 index 0000000..bfe00ec --- /dev/null +++ b/Infobip/Model/CallsRecordingStartRequest.php @@ -0,0 +1,67 @@ + null + ]; + + /** + */ + public function __construct( + #[Assert\Valid] + + protected ?\Infobip\Model\CallsRecordingRequest $recording = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getRecording(): \Infobip\Model\CallsRecordingRequest|null + { + return $this->recording; + } + + public function setRecording(?\Infobip\Model\CallsRecordingRequest $recording): self + { + $this->recording = $recording; + return $this; + } +} diff --git a/Infobip/Model/CallsRecordingStatus.php b/Infobip/Model/CallsRecordingStatus.php new file mode 100644 index 0000000..ff5a929 --- /dev/null +++ b/Infobip/Model/CallsRecordingStatus.php @@ -0,0 +1,71 @@ +value = $value; + } + + public static function SUCCESSFUL(): CallsRecordingStatus + { + return new self('SUCCESSFUL'); + } + + public static function PARTIALLY_FAILED(): CallsRecordingStatus + { + return new self('PARTIALLY_FAILED'); + } + + public static function FAILED(): CallsRecordingStatus + { + return new self('FAILED'); + } + + public function __toString(): string + { + return $this->value; + } +} diff --git a/Infobip/Model/CallsRecordingType.php b/Infobip/Model/CallsRecordingType.php new file mode 100644 index 0000000..1d1a456 --- /dev/null +++ b/Infobip/Model/CallsRecordingType.php @@ -0,0 +1,64 @@ +value = $value; + } + + public static function AUDIO(): CallsRecordingType + { + return new self('AUDIO'); + } + + public static function AUDIO_AND_VIDEO(): CallsRecordingType + { + return new self('AUDIO_AND_VIDEO'); + } + + public function __toString(): string + { + return $this->value; + } +} diff --git a/Infobip/Model/CallsRescheduleRequest.php b/Infobip/Model/CallsRescheduleRequest.php new file mode 100644 index 0000000..f75824c --- /dev/null +++ b/Infobip/Model/CallsRescheduleRequest.php @@ -0,0 +1,68 @@ + 'date-time' + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected \DateTime $startTime, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getStartTime(): \DateTime + { + return $this->startTime; + } + + public function setStartTime(\DateTime $startTime): self + { + $this->startTime = $startTime; + return $this; + } +} diff --git a/Infobip/Model/CallsRetry.php b/Infobip/Model/CallsRetry.php new file mode 100644 index 0000000..4bb0354 --- /dev/null +++ b/Infobip/Model/CallsRetry.php @@ -0,0 +1,99 @@ + 'int32', + 'maxPeriod' => 'int32', + 'minPeriod' => 'int32' + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + #[Assert\LessThan(32767)] + #[Assert\GreaterThan(-32768)] + + protected int $maxCount, + #[Assert\NotBlank] + + protected int $maxPeriod, + #[Assert\NotBlank] + + protected int $minPeriod, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getMaxCount(): int + { + return $this->maxCount; + } + + public function setMaxCount(int $maxCount): self + { + $this->maxCount = $maxCount; + return $this; + } + + public function getMaxPeriod(): int + { + return $this->maxPeriod; + } + + public function setMaxPeriod(int $maxPeriod): self + { + $this->maxPeriod = $maxPeriod; + return $this; + } + + public function getMinPeriod(): int + { + return $this->minPeriod; + } + + public function setMinPeriod(int $minPeriod): self + { + $this->minPeriod = $minPeriod; + return $this; + } +} diff --git a/Infobip/Model/CallsRetryOptions.php b/Infobip/Model/CallsRetryOptions.php new file mode 100644 index 0000000..0261a9e --- /dev/null +++ b/Infobip/Model/CallsRetryOptions.php @@ -0,0 +1,91 @@ + 'int32', + 'maxWaitPeriod' => 'int32', + 'maxAttempts' => 'int32' + ]; + + /** + */ + public function __construct( + protected ?int $minWaitPeriod = null, + protected ?int $maxWaitPeriod = null, + protected ?int $maxAttempts = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getMinWaitPeriod(): int|null + { + return $this->minWaitPeriod; + } + + public function setMinWaitPeriod(?int $minWaitPeriod): self + { + $this->minWaitPeriod = $minWaitPeriod; + return $this; + } + + public function getMaxWaitPeriod(): int|null + { + return $this->maxWaitPeriod; + } + + public function setMaxWaitPeriod(?int $maxWaitPeriod): self + { + $this->maxWaitPeriod = $maxWaitPeriod; + return $this; + } + + public function getMaxAttempts(): int|null + { + return $this->maxAttempts; + } + + public function setMaxAttempts(?int $maxAttempts): self + { + $this->maxAttempts = $maxAttempts; + return $this; + } +} diff --git a/Infobip/Model/CallsSayRequest.php b/Infobip/Model/CallsSayRequest.php new file mode 100644 index 0000000..f33b12c --- /dev/null +++ b/Infobip/Model/CallsSayRequest.php @@ -0,0 +1,139 @@ + null, + 'language' => null, + 'speechRate' => 'double', + 'loopCount' => 'int32', + 'preferences' => null, + 'stopOn' => null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + + protected string $text, + #[Assert\NotBlank] + #[Assert\Choice(['ar','bn','bg','ca','zh-cn','zh-tw','hr','cs','da','nl','en','en-au','en-gb','en-ca','en-in','en-ie','en-gb-wls','epo','fil-ph','fi','fr','fr-ca','fr-ch','de','de-at','de-ch','el','gu','he','hi','hu','is','id','it','ja','kn','ko','ms','ml','no','pl','pt-pt','pt-br','ro','ru','sk','sl','es','es-gl','es-mx','sv','ta','te','th','tr','uk','vi','wls',])] + + protected string $language, + protected ?float $speechRate = null, + protected ?int $loopCount = null, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsVoicePreferences $preferences = null, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsDtmfTermination $stopOn = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getText(): string + { + return $this->text; + } + + public function setText(string $text): self + { + $this->text = $text; + return $this; + } + + public function getLanguage(): mixed + { + return $this->language; + } + + public function setLanguage($language): self + { + $this->language = $language; + return $this; + } + + public function getSpeechRate(): float|null + { + return $this->speechRate; + } + + public function setSpeechRate(?float $speechRate): self + { + $this->speechRate = $speechRate; + return $this; + } + + public function getLoopCount(): int|null + { + return $this->loopCount; + } + + public function setLoopCount(?int $loopCount): self + { + $this->loopCount = $loopCount; + return $this; + } + + public function getPreferences(): \Infobip\Model\CallsVoicePreferences|null + { + return $this->preferences; + } + + public function setPreferences(?\Infobip\Model\CallsVoicePreferences $preferences): self + { + $this->preferences = $preferences; + return $this; + } + + public function getStopOn(): \Infobip\Model\CallsDtmfTermination|null + { + return $this->stopOn; + } + + public function setStopOn(?\Infobip\Model\CallsDtmfTermination $stopOn): self + { + $this->stopOn = $stopOn; + return $this; + } +} diff --git a/Infobip/Model/CallsSchedulingOptions.php b/Infobip/Model/CallsSchedulingOptions.php new file mode 100644 index 0000000..f47ce2d --- /dev/null +++ b/Infobip/Model/CallsSchedulingOptions.php @@ -0,0 +1,82 @@ + 'date-time', + 'callingTimeWindow' => null + ]; + + /** + */ + public function __construct( + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $startTime = null, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsTimeWindow $callingTimeWindow = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getStartTime(): \DateTime|null + { + return $this->startTime; + } + + public function setStartTime(?\DateTime $startTime): self + { + $this->startTime = $startTime; + return $this; + } + + public function getCallingTimeWindow(): \Infobip\Model\CallsTimeWindow|null + { + return $this->callingTimeWindow; + } + + public function setCallingTimeWindow(?\Infobip\Model\CallsTimeWindow $callingTimeWindow): self + { + $this->callingTimeWindow = $callingTimeWindow; + return $this; + } +} diff --git a/Infobip/Model/CallsSendingSpeed.php b/Infobip/Model/CallsSendingSpeed.php new file mode 100644 index 0000000..5b62feb --- /dev/null +++ b/Infobip/Model/CallsSendingSpeed.php @@ -0,0 +1,78 @@ + 'int32', + 'timeUnit' => null + ]; + + /** + */ + public function __construct( + protected ?int $speed = null, + protected ?string $timeUnit = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getSpeed(): int|null + { + return $this->speed; + } + + public function setSpeed(?int $speed): self + { + $this->speed = $speed; + return $this; + } + + public function getTimeUnit(): string|null + { + return $this->timeUnit; + } + + public function setTimeUnit(?string $timeUnit): self + { + $this->timeUnit = $timeUnit; + return $this; + } +} diff --git a/Infobip/Model/CallsSingleBody.php b/Infobip/Model/CallsSingleBody.php new file mode 100644 index 0000000..854623e --- /dev/null +++ b/Infobip/Model/CallsSingleBody.php @@ -0,0 +1,136 @@ + null, + 'from' => null, + 'language' => null, + 'text' => null, + 'to' => null, + 'voice' => null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + + protected string $from, + #[Assert\NotBlank] + + protected string $to, + protected ?string $audioFileUrl = null, + protected ?string $language = null, + protected ?string $text = null, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsVoice $voice = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getAudioFileUrl(): string|null + { + return $this->audioFileUrl; + } + + public function setAudioFileUrl(?string $audioFileUrl): self + { + $this->audioFileUrl = $audioFileUrl; + return $this; + } + + public function getFrom(): string + { + return $this->from; + } + + public function setFrom(string $from): self + { + $this->from = $from; + return $this; + } + + public function getLanguage(): string|null + { + return $this->language; + } + + public function setLanguage(?string $language): self + { + $this->language = $language; + return $this; + } + + public function getText(): string|null + { + return $this->text; + } + + public function setText(?string $text): self + { + $this->text = $text; + return $this; + } + + public function getTo(): string + { + return $this->to; + } + + public function setTo(string $to): self + { + $this->to = $to; + return $this; + } + + public function getVoice(): \Infobip\Model\CallsVoice|null + { + return $this->voice; + } + + public function setVoice(?\Infobip\Model\CallsVoice $voice): self + { + $this->voice = $voice; + return $this; + } +} diff --git a/Infobip/Model/CallsSingleMessageStatus.php b/Infobip/Model/CallsSingleMessageStatus.php new file mode 100644 index 0000000..7303e24 --- /dev/null +++ b/Infobip/Model/CallsSingleMessageStatus.php @@ -0,0 +1,117 @@ + null, + 'groupId' => 'int32', + 'groupName' => null, + 'id' => 'int32', + 'name' => null + ]; + + /** + */ + public function __construct( + protected ?string $description = null, + protected ?int $groupId = null, + protected ?string $groupName = null, + protected ?int $id = null, + protected ?string $name = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getDescription(): string|null + { + return $this->description; + } + + public function setDescription(?string $description): self + { + $this->description = $description; + return $this; + } + + public function getGroupId(): int|null + { + return $this->groupId; + } + + public function setGroupId(?int $groupId): self + { + $this->groupId = $groupId; + return $this; + } + + public function getGroupName(): string|null + { + return $this->groupName; + } + + public function setGroupName(?string $groupName): self + { + $this->groupName = $groupName; + return $this; + } + + public function getId(): int|null + { + return $this->id; + } + + public function setId(?int $id): self + { + $this->id = $id; + return $this; + } + + public function getName(): string|null + { + return $this->name; + } + + public function setName(?string $name): self + { + $this->name = $name; + return $this; + } +} diff --git a/Infobip/Model/CallsSipEndpoint.php b/Infobip/Model/CallsSipEndpoint.php new file mode 100644 index 0000000..eed547f --- /dev/null +++ b/Infobip/Model/CallsSipEndpoint.php @@ -0,0 +1,119 @@ + null, + 'sipTrunkId' => null, + 'sipTrunkGroupId' => null, + 'customHeaders' => null + ]; + + /** + * @param array $customHeaders + */ + public function __construct( + #[Assert\NotBlank] + + protected string $username, + protected ?string $sipTrunkId = null, + protected ?string $sipTrunkGroupId = null, + protected ?array $customHeaders = null, + ) { + $modelDiscriminatorValue = 'SIP'; + + parent::__construct( + type: $modelDiscriminatorValue, + ); + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getUsername(): string + { + return $this->username; + } + + public function setUsername(string $username): self + { + $this->username = $username; + return $this; + } + + public function getSipTrunkId(): string|null + { + return $this->sipTrunkId; + } + + public function setSipTrunkId(?string $sipTrunkId): self + { + $this->sipTrunkId = $sipTrunkId; + return $this; + } + + public function getSipTrunkGroupId(): string|null + { + return $this->sipTrunkGroupId; + } + + public function setSipTrunkGroupId(?string $sipTrunkGroupId): self + { + $this->sipTrunkGroupId = $sipTrunkGroupId; + return $this; + } + + /** + * @return array|null + */ + public function getCustomHeaders() + { + return $this->customHeaders; + } + + /** + * @param array|null $customHeaders Custom headers. + */ + public function setCustomHeaders(?array $customHeaders): self + { + $this->customHeaders = $customHeaders; + return $this; + } +} diff --git a/Infobip/Model/CallsStartMediaStreamRequest.php b/Infobip/Model/CallsStartMediaStreamRequest.php new file mode 100644 index 0000000..9067691 --- /dev/null +++ b/Infobip/Model/CallsStartMediaStreamRequest.php @@ -0,0 +1,68 @@ + null + ]; + + /** + */ + public function __construct( + #[Assert\Valid] + #[Assert\NotBlank] + + protected \Infobip\Model\CallsMediaStream $mediaStream, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getMediaStream(): \Infobip\Model\CallsMediaStream + { + return $this->mediaStream; + } + + public function setMediaStream(\Infobip\Model\CallsMediaStream $mediaStream): self + { + $this->mediaStream = $mediaStream; + return $this; + } +} diff --git a/Infobip/Model/CallsStartRecordingRequest.php b/Infobip/Model/CallsStartRecordingRequest.php new file mode 100644 index 0000000..d5d17e5 --- /dev/null +++ b/Infobip/Model/CallsStartRecordingRequest.php @@ -0,0 +1,68 @@ + null + ]; + + /** + */ + public function __construct( + #[Assert\Valid] + #[Assert\NotBlank] + + protected \Infobip\Model\CallsConferenceRecordingRequest $recording, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getRecording(): \Infobip\Model\CallsConferenceRecordingRequest + { + return $this->recording; + } + + public function setRecording(\Infobip\Model\CallsConferenceRecordingRequest $recording): self + { + $this->recording = $recording; + return $this; + } +} diff --git a/Infobip/Model/CallsStatus.php b/Infobip/Model/CallsStatus.php new file mode 100644 index 0000000..93e46b5 --- /dev/null +++ b/Infobip/Model/CallsStatus.php @@ -0,0 +1,92 @@ +value = $value; + } + + public static function PENDING(): CallsStatus + { + return new self('PENDING'); + } + + public static function PAUSED(): CallsStatus + { + return new self('PAUSED'); + } + + public static function PROCESSING(): CallsStatus + { + return new self('PROCESSING'); + } + + public static function CANCELED(): CallsStatus + { + return new self('CANCELED'); + } + + public static function FINISHED(): CallsStatus + { + return new self('FINISHED'); + } + + public static function FAILED(): CallsStatus + { + return new self('FAILED'); + } + + public function __toString(): string + { + return $this->value; + } +} diff --git a/Infobip/Model/CallsTerminationType.php b/Infobip/Model/CallsTerminationType.php new file mode 100644 index 0000000..2fbb0f8 --- /dev/null +++ b/Infobip/Model/CallsTerminationType.php @@ -0,0 +1,57 @@ +value = $value; + } + + public static function DTMF(): CallsTerminationType + { + return new self('DTMF'); + } + + public function __toString(): string + { + return $this->value; + } +} diff --git a/Infobip/Model/CallsTimeWindow.php b/Infobip/Model/CallsTimeWindow.php new file mode 100644 index 0000000..86c3f89 --- /dev/null +++ b/Infobip/Model/CallsTimeWindow.php @@ -0,0 +1,105 @@ + null, + 'to' => null, + 'days' => null + ]; + + /** + * @param string[] $days + */ + public function __construct( + #[Assert\NotBlank] + #[Assert\Choice(['MONDAY','TUESDAY','WEDNESDAY','THURSDAY','FRIDAY','SATURDAY','SUNDAY',])] + + protected string $days, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsTimeWindowPoint $from = null, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsTimeWindowPoint $to = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getFrom(): \Infobip\Model\CallsTimeWindowPoint|null + { + return $this->from; + } + + public function setFrom(?\Infobip\Model\CallsTimeWindowPoint $from): self + { + $this->from = $from; + return $this; + } + + public function getTo(): \Infobip\Model\CallsTimeWindowPoint|null + { + return $this->to; + } + + public function setTo(?\Infobip\Model\CallsTimeWindowPoint $to): self + { + $this->to = $to; + return $this; + } + + /** + * @return string[] + */ + public function getDays(): array + { + return $this->days; + } + + /** + * @param string[] $days Days when scheduling call establishment will be attempted. + */ + public function setDays(array $days): self + { + $this->days = $days; + return $this; + } +} diff --git a/Infobip/Model/CallsTimeWindowPoint.php b/Infobip/Model/CallsTimeWindowPoint.php new file mode 100644 index 0000000..d568f29 --- /dev/null +++ b/Infobip/Model/CallsTimeWindowPoint.php @@ -0,0 +1,78 @@ + 'int32', + 'minute' => 'int32' + ]; + + /** + */ + public function __construct( + protected ?int $hour = null, + protected ?int $minute = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getHour(): int|null + { + return $this->hour; + } + + public function setHour(?int $hour): self + { + $this->hour = $hour; + return $this; + } + + public function getMinute(): int|null + { + return $this->minute; + } + + public function setMinute(?int $minute): self + { + $this->minute = $minute; + return $this; + } +} diff --git a/Infobip/Model/CallsUpdateRequest.php b/Infobip/Model/CallsUpdateRequest.php new file mode 100644 index 0000000..6c666cf --- /dev/null +++ b/Infobip/Model/CallsUpdateRequest.php @@ -0,0 +1,78 @@ + null, + 'deaf' => null + ]; + + /** + */ + public function __construct( + protected ?bool $muted = null, + protected ?bool $deaf = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getMuted(): bool|null + { + return $this->muted; + } + + public function setMuted(?bool $muted): self + { + $this->muted = $muted; + return $this; + } + + public function getDeaf(): bool|null + { + return $this->deaf; + } + + public function setDeaf(?bool $deaf): self + { + $this->deaf = $deaf; + return $this; + } +} diff --git a/Infobip/Model/CallsUpdateStatusRequest.php b/Infobip/Model/CallsUpdateStatusRequest.php new file mode 100644 index 0000000..b8b30b9 --- /dev/null +++ b/Infobip/Model/CallsUpdateStatusRequest.php @@ -0,0 +1,68 @@ + null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + #[Assert\Choice(['PENDING','PAUSED','PROCESSING','CANCELED','FINISHED','FAILED',])] + + protected string $status, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getStatus(): mixed + { + return $this->status; + } + + public function setStatus($status): self + { + $this->status = $status; + return $this; + } +} diff --git a/Infobip/Model/CallsUrlPlayContent.php b/Infobip/Model/CallsUrlPlayContent.php new file mode 100644 index 0000000..23a24f8 --- /dev/null +++ b/Infobip/Model/CallsUrlPlayContent.php @@ -0,0 +1,73 @@ + null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + + protected string $fileUrl, + ) { + $modelDiscriminatorValue = 'URL'; + + parent::__construct( + type: $modelDiscriminatorValue, + ); + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getFileUrl(): string + { + return $this->fileUrl; + } + + public function setFileUrl(string $fileUrl): self + { + $this->fileUrl = $fileUrl; + return $this; + } +} diff --git a/Infobip/Model/CallsUrlSecurityConfig.php b/Infobip/Model/CallsUrlSecurityConfig.php new file mode 100644 index 0000000..bb4f461 --- /dev/null +++ b/Infobip/Model/CallsUrlSecurityConfig.php @@ -0,0 +1,73 @@ + "\Infobip\Model\CallsBasicUrlSecurityConfig", + "CallsBasicUrlSecurityConfig" => "\Infobip\Model\CallsBasicUrlSecurityConfig", + "CallsHmacUrlSecurityConfig" => "\Infobip\Model\CallsHmacUrlSecurityConfig", + "HMAC" => "\Infobip\Model\CallsHmacUrlSecurityConfig", +])] +class CallsUrlSecurityConfig implements ModelInterface +{ + public const DISCRIMINATOR = 'type'; + public const OPENAPI_MODEL_NAME = 'CallsUrlSecurityConfig'; + + public const OPENAPI_FORMATS = [ + 'type' => null + ]; + + /** + */ + public function __construct( + #[Assert\Choice(['BASIC','HMAC',])] + + protected ?string $type = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getType(): mixed + { + return $this->type; + } + + public function setType($type): self + { + $this->type = $type; + return $this; + } +} diff --git a/Infobip/Model/CallsUrlSecurityConfigType.php b/Infobip/Model/CallsUrlSecurityConfigType.php new file mode 100644 index 0000000..1d33521 --- /dev/null +++ b/Infobip/Model/CallsUrlSecurityConfigType.php @@ -0,0 +1,64 @@ +value = $value; + } + + public static function BASIC(): CallsUrlSecurityConfigType + { + return new self('BASIC'); + } + + public static function HMAC(): CallsUrlSecurityConfigType + { + return new self('HMAC'); + } + + public function __toString(): string + { + return $this->value; + } +} diff --git a/Infobip/Model/CallsViberEndpoint.php b/Infobip/Model/CallsViberEndpoint.php new file mode 100644 index 0000000..253662a --- /dev/null +++ b/Infobip/Model/CallsViberEndpoint.php @@ -0,0 +1,73 @@ + null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + + protected string $phoneNumber, + ) { + $modelDiscriminatorValue = 'VIBER'; + + parent::__construct( + type: $modelDiscriminatorValue, + ); + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getPhoneNumber(): string + { + return $this->phoneNumber; + } + + public function setPhoneNumber(string $phoneNumber): self + { + $this->phoneNumber = $phoneNumber; + return $this; + } +} diff --git a/Infobip/Model/CallsVideoMediaProperties.php b/Infobip/Model/CallsVideoMediaProperties.php new file mode 100644 index 0000000..35dcc77 --- /dev/null +++ b/Infobip/Model/CallsVideoMediaProperties.php @@ -0,0 +1,78 @@ + null, + 'screenShare' => null + ]; + + /** + */ + public function __construct( + protected ?bool $camera = null, + protected ?bool $screenShare = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getCamera(): bool|null + { + return $this->camera; + } + + public function setCamera(?bool $camera): self + { + $this->camera = $camera; + return $this; + } + + public function getScreenShare(): bool|null + { + return $this->screenShare; + } + + public function setScreenShare(?bool $screenShare): self + { + $this->screenShare = $screenShare; + return $this; + } +} diff --git a/Infobip/Model/CallsVoice.php b/Infobip/Model/CallsVoice.php new file mode 100644 index 0000000..42ea672 --- /dev/null +++ b/Infobip/Model/CallsVoice.php @@ -0,0 +1,78 @@ + null, + 'name' => null + ]; + + /** + */ + public function __construct( + protected ?string $gender = null, + protected ?string $name = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getGender(): string|null + { + return $this->gender; + } + + public function setGender(?string $gender): self + { + $this->gender = $gender; + return $this; + } + + public function getName(): string|null + { + return $this->name; + } + + public function setName(?string $name): self + { + $this->name = $name; + return $this; + } +} diff --git a/Infobip/Model/CallsVoicePreferences.php b/Infobip/Model/CallsVoicePreferences.php new file mode 100644 index 0000000..723cb48 --- /dev/null +++ b/Infobip/Model/CallsVoicePreferences.php @@ -0,0 +1,82 @@ + null, + 'voiceName' => null + ]; + + /** + */ + public function __construct( + #[Assert\Choice(['FEMALE','MALE',])] + + protected ?string $voiceGender = null, + #[Assert\Choice(['Hoda','Zeina','Naayf','Aisha (beta)','Farooq (beta)','Hussein (beta)','Amal (beta)','Sayan (beta)','Sushmita (beta)','Ivan','Conchita','Herena','Huihui','Zhiyu','Yaoyao','Kangkang','Liu (beta)','Wang (beta)','Zhang (beta)','Lin (beta)','Akemi (beta)','Chen (beta)','Huang (beta)','Danny','Tracy','Hanhan','Zhiwei','Yating','Matej','Jakub','Helle','Naja','Mads','Ruben','Lotte','Hanna','Joanna','Zira','Ivy','Kendra','Kimberly','Salli','Joey','Justin','Matthew','Benjamin','Jessica','Jane','Guy','Russell','Catherine','Nicole','Hayley','Brian','Hazel','Amy','Emma','Rosie','George','Heather','Alice','Heera','Aditi','Raveena','Priya','Ravi','Sean','Geraint','Heidi','Evelin (beta)','Hortense','Celine','Lea','Mathieu','Juliette','Picard','Caroline','Harmonie','Chantal','Guillaume','Vicki','Hans','Stefan','Marlene','Hedda','Angela','Michael','Karsten','Stefanos','Sophia (beta)','Dinesh (beta)','Leela (beta)','Asaf','Aadita','Kalpana','Hemant','Szabolcs','Dora','Karl','Indah (beta)','Arif (beta)','Reza (beta)','Andika','Nurul (beta)','Gianna (beta)','Cosimo','Carla','Bianca','Giorgio','Lucia','Takumi','Haruka','Ichiro','Mizuki','Ayumi','Shashank (beta)','Namratha (beta)','Seoyeon','Heami','Sumi (beta)','Jina (beta)','Himchan (beta)','Minho (beta)','Rizwan','Vishnu (beta)','Kirti (beta)','Hulda','Liv','Ewa','Paulina','Maja','Jacek','Jan','Cristiano','Helia','Ines','Abrielle (beta)','Henriques (beta)','Jeraldo (beta)','Jacinda (beta)','Camila','Ricardo','Daniel','Vitoria','Heloisa','Carmen','Andrei','Maxim','Ekaterina','Pavel','Tatyana','Irina','Filip','Lado','Miguel','Linda','Enrique','Juana','Pablo','Gabriela (beta)','Lupe','Laura','Penelope','Hilda','Raul','Mia','Hedvig','Astrid','Valluvar','Ganesh (beta)','Shruti (beta)','Chitra','Vijay (beta)','Samantha (beta)','Natchaya (beta)','Pattara','Seda','Filiz','Ulyana','An','Lien (beta)','Quan (beta)','Mai (beta)','Tuan (beta)','Gwyneth',])] + + protected ?string $voiceName = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getVoiceGender(): mixed + { + return $this->voiceGender; + } + + public function setVoiceGender($voiceGender): self + { + $this->voiceGender = $voiceGender; + return $this; + } + + public function getVoiceName(): mixed + { + return $this->voiceName; + } + + public function setVoiceName($voiceName): self + { + $this->voiceName = $voiceName; + return $this; + } +} diff --git a/Infobip/Model/CallsVoiceResponse.php b/Infobip/Model/CallsVoiceResponse.php new file mode 100644 index 0000000..dcf8987 --- /dev/null +++ b/Infobip/Model/CallsVoiceResponse.php @@ -0,0 +1,85 @@ + null, + 'messages' => null + ]; + + /** + * @param \Infobip\Model\CallsVoiceResponseDetails[] $messages + */ + public function __construct( + protected ?string $bulkId = null, + protected ?array $messages = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getBulkId(): string|null + { + return $this->bulkId; + } + + public function setBulkId(?string $bulkId): self + { + $this->bulkId = $bulkId; + return $this; + } + + /** + * @return \Infobip\Model\CallsVoiceResponseDetails[]|null + */ + public function getMessages(): ?array + { + return $this->messages; + } + + /** + * @param \Infobip\Model\CallsVoiceResponseDetails[]|null $messages Array of sent messages, one object per every message. + */ + public function setMessages(?array $messages): self + { + $this->messages = $messages; + return $this; + } +} diff --git a/Infobip/Model/CallsVoiceResponseDetails.php b/Infobip/Model/CallsVoiceResponseDetails.php new file mode 100644 index 0000000..33e3382 --- /dev/null +++ b/Infobip/Model/CallsVoiceResponseDetails.php @@ -0,0 +1,93 @@ + null, + 'status' => null, + 'to' => null + ]; + + /** + */ + public function __construct( + protected ?string $messageId = null, + #[Assert\Valid] + + protected ?\Infobip\Model\CallsSingleMessageStatus $status = null, + protected ?string $to = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getMessageId(): string|null + { + return $this->messageId; + } + + public function setMessageId(?string $messageId): self + { + $this->messageId = $messageId; + return $this; + } + + public function getStatus(): \Infobip\Model\CallsSingleMessageStatus|null + { + return $this->status; + } + + public function setStatus(?\Infobip\Model\CallsSingleMessageStatus $status): self + { + $this->status = $status; + return $this; + } + + public function getTo(): string|null + { + return $this->to; + } + + public function setTo(?string $to): self + { + $this->to = $to; + return $this; + } +} diff --git a/Infobip/Model/CallsWebRtcEndpoint.php b/Infobip/Model/CallsWebRtcEndpoint.php new file mode 100644 index 0000000..39a77a1 --- /dev/null +++ b/Infobip/Model/CallsWebRtcEndpoint.php @@ -0,0 +1,86 @@ + null, + 'displayName' => null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + + protected string $identity, + protected ?string $displayName = null, + ) { + $modelDiscriminatorValue = 'WEBRTC'; + + parent::__construct( + type: $modelDiscriminatorValue, + ); + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getIdentity(): string + { + return $this->identity; + } + + public function setIdentity(string $identity): self + { + $this->identity = $identity; + return $this; + } + + public function getDisplayName(): string|null + { + return $this->displayName; + } + + public function setDisplayName(?string $displayName): self + { + $this->displayName = $displayName; + return $this; + } +} diff --git a/Infobip/Model/EmailAddDomainRequest.php b/Infobip/Model/EmailAddDomainRequest.php new file mode 100644 index 0000000..5932eae --- /dev/null +++ b/Infobip/Model/EmailAddDomainRequest.php @@ -0,0 +1,108 @@ + null, + 'dkimKeyLength' => 'int32', + 'applicationId' => null, + 'entityId' => null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + + protected string $domainName, + #[Assert\Choice([1024,2048,])] + + protected ?string $dkimKeyLength = self::DKIM_KEY_LENGTH_2048, + protected ?string $applicationId = null, + protected ?string $entityId = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getDomainName(): string + { + return $this->domainName; + } + + public function setDomainName(string $domainName): self + { + $this->domainName = $domainName; + return $this; + } + + public function getDkimKeyLength(): mixed + { + return $this->dkimKeyLength; + } + + public function setDkimKeyLength($dkimKeyLength): self + { + $this->dkimKeyLength = $dkimKeyLength; + return $this; + } + + public function getApplicationId(): string|null + { + return $this->applicationId; + } + + public function setApplicationId(?string $applicationId): self + { + $this->applicationId = $applicationId; + return $this; + } + + public function getEntityId(): string|null + { + return $this->entityId; + } + + public function setEntityId(?string $entityId): self + { + $this->entityId = $entityId; + return $this; + } +} diff --git a/Infobip/Model/EmailAllDomainsResponse.php b/Infobip/Model/EmailAllDomainsResponse.php new file mode 100644 index 0000000..460265e --- /dev/null +++ b/Infobip/Model/EmailAllDomainsResponse.php @@ -0,0 +1,87 @@ + null, + 'results' => null + ]; + + /** + * @param \Infobip\Model\EmailDomainResponse[] $results + */ + public function __construct( + #[Assert\Valid] + + protected ?\Infobip\Model\EmailPaging $paging = null, + protected ?array $results = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getPaging(): \Infobip\Model\EmailPaging|null + { + return $this->paging; + } + + public function setPaging(?\Infobip\Model\EmailPaging $paging): self + { + $this->paging = $paging; + return $this; + } + + /** + * @return \Infobip\Model\EmailDomainResponse[]|null + */ + public function getResults(): ?array + { + return $this->results; + } + + /** + * @param \Infobip\Model\EmailDomainResponse[]|null $results List of domains that belong to the account. + */ + public function setResults(?array $results): self + { + $this->results = $results; + return $this; + } +} diff --git a/Infobip/Model/EmailBulkInfo.php b/Infobip/Model/EmailBulkInfo.php index 6985849..41e3264 100644 --- a/Infobip/Model/EmailBulkInfo.php +++ b/Infobip/Model/EmailBulkInfo.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class EmailBulkInfo implements ModelInterface, ArrayAccess, \JsonSerializable +class EmailBulkInfo implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'EmailBulkInfo'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'bulkId' => 'string', - 'sendAt' => '\DateTime' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'EmailBulkInfo'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'bulkId' => null, 'sendAt' => 'date-time' ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'bulkId' => 'bulkId', - 'sendAt' => 'sendAt' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'bulkId' => 'setBulkId', - 'sendAt' => 'setSendAt' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] */ - protected static $getters = [ - 'bulkId' => 'getBulkId', - 'sendAt' => 'getSendAt' - ]; + public function __construct( + protected ?string $bulkId = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; + protected ?\DateTime $sendAt = null, + ) { } - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() + #[Ignore] + public function getModelName(): string { - return self::$setters; + return self::OPENAPI_MODEL_NAME; } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$getters; + return self::DISCRIMINATOR; } - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() + public function getBulkId(): string|null { - return self::$openAPIModelName; + return $this->bulkId; } - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['bulkId'] = $data['bulkId'] ?? null; - $this->container['sendAt'] = $data['sendAt'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + public function setBulkId(?string $bulkId): self { - $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() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets bulkId - * - * @return string|null - */ - public function getBulkId() - { - return $this->container['bulkId']; - } - - /** - * Sets bulkId - * - * @param string|null $bulkId bulkId - * - * @return self - */ - public function setBulkId($bulkId) - { - $this->container['bulkId'] = $bulkId; - + $this->bulkId = $bulkId; return $this; } - /** - * Gets sendAt - * - * @return \DateTime|null - */ - public function getSendAt() + public function getSendAt(): \DateTime|null { - return $this->container['sendAt']; + return $this->sendAt; } - /** - * Sets sendAt - * - * @param \DateTime|null $sendAt sendAt - * - * @return self - */ - public function setSendAt($sendAt) + public function setSendAt(?\DateTime $sendAt): self { - $this->container['sendAt'] = $sendAt; - + $this->sendAt = $sendAt; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/EmailBulkRescheduleRequest.php b/Infobip/Model/EmailBulkRescheduleRequest.php index c9c3066..3e2a738 100644 --- a/Infobip/Model/EmailBulkRescheduleRequest.php +++ b/Infobip/Model/EmailBulkRescheduleRequest.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class EmailBulkRescheduleRequest implements ModelInterface, ArrayAccess, \JsonSerializable +class EmailBulkRescheduleRequest implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'EmailBulkRescheduleRequest'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'sendAt' => '\DateTime' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'EmailBulkRescheduleRequest'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'sendAt' => 'date-time' ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'sendAt' => 'sendAt' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'sendAt' => 'setSendAt' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'sendAt' => 'getSendAt' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] */ - protected $container = []; + public function __construct( + #[Assert\NotBlank] + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['sendAt'] = $data['sendAt'] ?? null; + protected \DateTime $sendAt, + ) { } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - if ($this->container['sendAt'] === null) { - $invalidProperties[] = "'sendAt' can't be null"; - } - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets sendAt - * - * @return \DateTime - */ - public function getSendAt() + public function getSendAt(): \DateTime { - return $this->container['sendAt']; + return $this->sendAt; } - /** - * Sets sendAt - * - * @param \DateTime $sendAt sendAt - * - * @return self - */ - public function setSendAt($sendAt) + public function setSendAt(\DateTime $sendAt): self { - $this->container['sendAt'] = $sendAt; - + $this->sendAt = $sendAt; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/EmailBulkRescheduleResponse.php b/Infobip/Model/EmailBulkRescheduleResponse.php index f2ed5b3..925227f 100644 --- a/Infobip/Model/EmailBulkRescheduleResponse.php +++ b/Infobip/Model/EmailBulkRescheduleResponse.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class EmailBulkRescheduleResponse implements ModelInterface, ArrayAccess, \JsonSerializable +class EmailBulkRescheduleResponse implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'EmailBulkRescheduleResponse'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'bulkId' => 'string', - 'sendAt' => '\DateTime' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'EmailBulkRescheduleResponse'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'bulkId' => null, 'sendAt' => 'date-time' ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'bulkId' => 'bulkId', - 'sendAt' => 'sendAt' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'bulkId' => 'setBulkId', - 'sendAt' => 'setSendAt' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] */ - protected static $getters = [ - 'bulkId' => 'getBulkId', - 'sendAt' => 'getSendAt' - ]; + public function __construct( + protected ?string $bulkId = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; + protected ?\DateTime $sendAt = null, + ) { } - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() + #[Ignore] + public function getModelName(): string { - return self::$setters; + return self::OPENAPI_MODEL_NAME; } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$getters; + return self::DISCRIMINATOR; } - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() + public function getBulkId(): string|null { - return self::$openAPIModelName; + return $this->bulkId; } - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['bulkId'] = $data['bulkId'] ?? null; - $this->container['sendAt'] = $data['sendAt'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + public function setBulkId(?string $bulkId): self { - $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() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets bulkId - * - * @return string|null - */ - public function getBulkId() - { - return $this->container['bulkId']; - } - - /** - * Sets bulkId - * - * @param string|null $bulkId bulkId - * - * @return self - */ - public function setBulkId($bulkId) - { - $this->container['bulkId'] = $bulkId; - + $this->bulkId = $bulkId; return $this; } - /** - * Gets sendAt - * - * @return \DateTime|null - */ - public function getSendAt() + public function getSendAt(): \DateTime|null { - return $this->container['sendAt']; + return $this->sendAt; } - /** - * Sets sendAt - * - * @param \DateTime|null $sendAt sendAt - * - * @return self - */ - public function setSendAt($sendAt) + public function setSendAt(?\DateTime $sendAt): self { - $this->container['sendAt'] = $sendAt; - + $this->sendAt = $sendAt; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/EmailBulkScheduleResponse.php b/Infobip/Model/EmailBulkScheduleResponse.php index 7df6fd1..cfa1077 100644 --- a/Infobip/Model/EmailBulkScheduleResponse.php +++ b/Infobip/Model/EmailBulkScheduleResponse.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class EmailBulkScheduleResponse implements ModelInterface, ArrayAccess, \JsonSerializable +class EmailBulkScheduleResponse implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'EmailBulkScheduleResponse'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'externalBulkId' => 'string', - 'bulks' => '\Infobip\Model\EmailBulkInfo[]' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'EmailBulkScheduleResponse'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'externalBulkId' => null, 'bulks' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'externalBulkId' => 'externalBulkId', - 'bulks' => 'bulks' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'externalBulkId' => 'setExternalBulkId', - 'bulks' => 'setBulks' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'externalBulkId' => 'getExternalBulkId', - 'bulks' => 'getBulks' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model + * @param \Infobip\Model\EmailBulkInfo[] $bulks */ - public function __construct(array $data = null) - { - $this->container['externalBulkId'] = $data['externalBulkId'] ?? null; - $this->container['bulks'] = $data['bulks'] ?? null; + public function __construct( + protected ?string $externalBulkId = null, + protected ?array $bulks = null, + ) { } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets externalBulkId - * - * @return string|null - */ - public function getExternalBulkId() + public function getExternalBulkId(): string|null { - return $this->container['externalBulkId']; + return $this->externalBulkId; } - /** - * Sets externalBulkId - * - * @param string|null $externalBulkId externalBulkId - * - * @return self - */ - public function setExternalBulkId($externalBulkId) + public function setExternalBulkId(?string $externalBulkId): self { - $this->container['externalBulkId'] = $externalBulkId; - + $this->externalBulkId = $externalBulkId; return $this; } /** - * Gets bulks - * * @return \Infobip\Model\EmailBulkInfo[]|null */ - public function getBulks() + public function getBulks(): ?array { - return $this->container['bulks']; + return $this->bulks; } /** - * Sets bulks - * * @param \Infobip\Model\EmailBulkInfo[]|null $bulks bulks - * - * @return self */ - public function setBulks($bulks) + public function setBulks(?array $bulks): self { - $this->container['bulks'] = $bulks; - + $this->bulks = $bulks; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/EmailBulkStatus.php b/Infobip/Model/EmailBulkStatus.php index 7b3db16..d047385 100644 --- a/Infobip/Model/EmailBulkStatus.php +++ b/Infobip/Model/EmailBulkStatus.php @@ -1,14 +1,8 @@ value = $value; + } + + public static function PENDING(): EmailBulkStatus + { + return new self('PENDING'); + } + + public static function PAUSED(): EmailBulkStatus + { + return new self('PAUSED'); + } + + public static function PROCESSING(): EmailBulkStatus + { + return new self('PROCESSING'); + } + + public static function CANCELED(): EmailBulkStatus + { + return new self('CANCELED'); + } + + public static function FINISHED(): EmailBulkStatus + { + return new self('FINISHED'); + } + + public static function FAILED(): EmailBulkStatus + { + return new self('FAILED'); + } + + public function __toString(): string + { + return $this->value; } } diff --git a/Infobip/Model/EmailBulkStatusInfo.php b/Infobip/Model/EmailBulkStatusInfo.php index 4ca86b3..2e0b569 100644 --- a/Infobip/Model/EmailBulkStatusInfo.php +++ b/Infobip/Model/EmailBulkStatusInfo.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class EmailBulkStatusInfo implements ModelInterface, ArrayAccess, \JsonSerializable +class EmailBulkStatusInfo implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'EmailBulkStatusInfo'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'bulkId' => 'string', - 'status' => '\Infobip\Model\EmailBulkStatus' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'EmailBulkStatusInfo'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'bulkId' => null, 'status' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'bulkId' => 'bulkId', - 'status' => 'status' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'bulkId' => 'setBulkId', - 'status' => 'setStatus' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] */ - protected static $getters = [ - 'bulkId' => 'getBulkId', - 'status' => 'getStatus' - ]; + public function __construct( + protected ?string $bulkId = null, + #[Assert\Choice(['PENDING','PAUSED','PROCESSING','CANCELED','FINISHED','FAILED',])] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; + protected ?string $status = null, + ) { } - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() + #[Ignore] + public function getModelName(): string { - return self::$setters; + return self::OPENAPI_MODEL_NAME; } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$getters; + return self::DISCRIMINATOR; } - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() + public function getBulkId(): string|null { - return self::$openAPIModelName; + return $this->bulkId; } - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['bulkId'] = $data['bulkId'] ?? null; - $this->container['status'] = $data['status'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + public function setBulkId(?string $bulkId): self { - $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() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets bulkId - * - * @return string|null - */ - public function getBulkId() - { - return $this->container['bulkId']; - } - - /** - * Sets bulkId - * - * @param string|null $bulkId bulkId - * - * @return self - */ - public function setBulkId($bulkId) - { - $this->container['bulkId'] = $bulkId; - + $this->bulkId = $bulkId; return $this; } - /** - * Gets status - * - * @return \Infobip\Model\EmailBulkStatus|null - */ - public function getStatus() + public function getStatus(): mixed { - return $this->container['status']; + return $this->status; } - /** - * Sets status - * - * @param \Infobip\Model\EmailBulkStatus|null $status status - * - * @return self - */ - public function setStatus($status) + public function setStatus($status): self { - $this->container['status'] = $status; - + $this->status = $status; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/EmailBulkStatusResponse.php b/Infobip/Model/EmailBulkStatusResponse.php index 1aac8c0..8f01ea3 100644 --- a/Infobip/Model/EmailBulkStatusResponse.php +++ b/Infobip/Model/EmailBulkStatusResponse.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class EmailBulkStatusResponse implements ModelInterface, ArrayAccess, \JsonSerializable +class EmailBulkStatusResponse implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'EmailBulkStatusResponse'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'externalBulkId' => 'string', - 'bulks' => '\Infobip\Model\EmailBulkStatusInfo[]' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'EmailBulkStatusResponse'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'externalBulkId' => null, 'bulks' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'externalBulkId' => 'externalBulkId', - 'bulks' => 'bulks' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'externalBulkId' => 'setExternalBulkId', - 'bulks' => 'setBulks' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'externalBulkId' => 'getExternalBulkId', - 'bulks' => 'getBulks' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model + * @param \Infobip\Model\EmailBulkStatusInfo[] $bulks */ - public function __construct(array $data = null) - { - $this->container['externalBulkId'] = $data['externalBulkId'] ?? null; - $this->container['bulks'] = $data['bulks'] ?? null; + public function __construct( + protected ?string $externalBulkId = null, + protected ?array $bulks = null, + ) { } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets externalBulkId - * - * @return string|null - */ - public function getExternalBulkId() + public function getExternalBulkId(): string|null { - return $this->container['externalBulkId']; + return $this->externalBulkId; } - /** - * Sets externalBulkId - * - * @param string|null $externalBulkId externalBulkId - * - * @return self - */ - public function setExternalBulkId($externalBulkId) + public function setExternalBulkId(?string $externalBulkId): self { - $this->container['externalBulkId'] = $externalBulkId; - + $this->externalBulkId = $externalBulkId; return $this; } /** - * Gets bulks - * * @return \Infobip\Model\EmailBulkStatusInfo[]|null */ - public function getBulks() + public function getBulks(): ?array { - return $this->container['bulks']; + return $this->bulks; } /** - * Sets bulks - * * @param \Infobip\Model\EmailBulkStatusInfo[]|null $bulks bulks - * - * @return self */ - public function setBulks($bulks) + public function setBulks(?array $bulks): self { - $this->container['bulks'] = $bulks; - + $this->bulks = $bulks; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/EmailBulkUpdateStatusRequest.php b/Infobip/Model/EmailBulkUpdateStatusRequest.php index 1e3d02a..d01f198 100644 --- a/Infobip/Model/EmailBulkUpdateStatusRequest.php +++ b/Infobip/Model/EmailBulkUpdateStatusRequest.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class EmailBulkUpdateStatusRequest implements ModelInterface, ArrayAccess, \JsonSerializable +class EmailBulkUpdateStatusRequest implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'EmailBulkUpdateStatusRequest'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'status' => '\Infobip\Model\EmailBulkStatus' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'EmailBulkUpdateStatusRequest'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'status' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'status' => 'status' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'status' => 'setStatus' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'status' => 'getStatus' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] */ - protected $container = []; + public function __construct( + #[Assert\NotBlank] + #[Assert\Choice(['PENDING','PAUSED','PROCESSING','CANCELED','FINISHED','FAILED',])] - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['status'] = $data['status'] ?? null; + protected string $status, + ) { } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - if ($this->container['status'] === null) { - $invalidProperties[] = "'status' can't be null"; - } - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets status - * - * @return \Infobip\Model\EmailBulkStatus - */ - public function getStatus() + public function getStatus(): mixed { - return $this->container['status']; + return $this->status; } - /** - * Sets status - * - * @param \Infobip\Model\EmailBulkStatus $status status - * - * @return self - */ - public function setStatus($status) + public function setStatus($status): self { - $this->container['status'] = $status; - + $this->status = $status; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/EmailBulkUpdateStatusResponse.php b/Infobip/Model/EmailBulkUpdateStatusResponse.php index 93142e0..5572f65 100644 --- a/Infobip/Model/EmailBulkUpdateStatusResponse.php +++ b/Infobip/Model/EmailBulkUpdateStatusResponse.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class EmailBulkUpdateStatusResponse implements ModelInterface, ArrayAccess, \JsonSerializable +class EmailBulkUpdateStatusResponse implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'EmailBulkUpdateStatusResponse'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'bulkId' => 'string', - 'status' => '\Infobip\Model\EmailBulkStatus' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'EmailBulkUpdateStatusResponse'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'bulkId' => null, 'status' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'bulkId' => 'bulkId', - 'status' => 'status' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'bulkId' => 'setBulkId', - 'status' => 'setStatus' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] */ - protected static $getters = [ - 'bulkId' => 'getBulkId', - 'status' => 'getStatus' - ]; + public function __construct( + protected ?string $bulkId = null, + #[Assert\Choice(['PENDING','PAUSED','PROCESSING','CANCELED','FINISHED','FAILED',])] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; + protected ?string $status = null, + ) { } - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() + #[Ignore] + public function getModelName(): string { - return self::$setters; + return self::OPENAPI_MODEL_NAME; } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$getters; + return self::DISCRIMINATOR; } - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() + public function getBulkId(): string|null { - return self::$openAPIModelName; + return $this->bulkId; } - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['bulkId'] = $data['bulkId'] ?? null; - $this->container['status'] = $data['status'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + public function setBulkId(?string $bulkId): self { - $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() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets bulkId - * - * @return string|null - */ - public function getBulkId() - { - return $this->container['bulkId']; - } - - /** - * Sets bulkId - * - * @param string|null $bulkId bulkId - * - * @return self - */ - public function setBulkId($bulkId) - { - $this->container['bulkId'] = $bulkId; - + $this->bulkId = $bulkId; return $this; } - /** - * Gets status - * - * @return \Infobip\Model\EmailBulkStatus|null - */ - public function getStatus() + public function getStatus(): mixed { - return $this->container['status']; + return $this->status; } - /** - * Sets status - * - * @param \Infobip\Model\EmailBulkStatus|null $status status - * - * @return self - */ - public function setStatus($status) + public function setStatus($status): self { - $this->container['status'] = $status; - + $this->status = $status; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/EmailDnsRecordResponse.php b/Infobip/Model/EmailDnsRecordResponse.php new file mode 100644 index 0000000..26985fb --- /dev/null +++ b/Infobip/Model/EmailDnsRecordResponse.php @@ -0,0 +1,104 @@ + null, + 'name' => null, + 'expectedValue' => null, + 'verified' => null + ]; + + /** + */ + public function __construct( + protected ?string $recordType = null, + protected ?string $name = null, + protected ?string $expectedValue = null, + protected ?bool $verified = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getRecordType(): string|null + { + return $this->recordType; + } + + public function setRecordType(?string $recordType): self + { + $this->recordType = $recordType; + return $this; + } + + public function getName(): string|null + { + return $this->name; + } + + public function setName(?string $name): self + { + $this->name = $name; + return $this; + } + + public function getExpectedValue(): string|null + { + return $this->expectedValue; + } + + public function setExpectedValue(?string $expectedValue): self + { + $this->expectedValue = $expectedValue; + return $this; + } + + public function getVerified(): bool|null + { + return $this->verified; + } + + public function setVerified(?bool $verified): self + { + $this->verified = $verified; + return $this; + } +} diff --git a/Infobip/Model/EmailDomainIp.php b/Infobip/Model/EmailDomainIp.php new file mode 100644 index 0000000..571a188 --- /dev/null +++ b/Infobip/Model/EmailDomainIp.php @@ -0,0 +1,112 @@ + null, + 'dedicated' => null, + 'assignedDomainCount' => 'int32', + 'status' => null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + + protected string $ipAddress, + #[Assert\NotBlank] + + protected bool $dedicated, + #[Assert\NotBlank] + + protected int $assignedDomainCount, + #[Assert\NotBlank] + + protected string $status, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getIpAddress(): string + { + return $this->ipAddress; + } + + public function setIpAddress(string $ipAddress): self + { + $this->ipAddress = $ipAddress; + return $this; + } + + public function getDedicated(): bool + { + return $this->dedicated; + } + + public function setDedicated(bool $dedicated): self + { + $this->dedicated = $dedicated; + return $this; + } + + public function getAssignedDomainCount(): int + { + return $this->assignedDomainCount; + } + + public function setAssignedDomainCount(int $assignedDomainCount): self + { + $this->assignedDomainCount = $assignedDomainCount; + return $this; + } + + public function getStatus(): string + { + return $this->status; + } + + public function setStatus(string $status): self + { + $this->status = $status; + return $this; + } +} diff --git a/Infobip/Model/EmailDomainIpRequest.php b/Infobip/Model/EmailDomainIpRequest.php new file mode 100644 index 0000000..78f36b9 --- /dev/null +++ b/Infobip/Model/EmailDomainIpRequest.php @@ -0,0 +1,82 @@ + null, + 'ipAddress' => null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + + protected string $domainName, + #[Assert\NotBlank] + + protected string $ipAddress, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getDomainName(): string + { + return $this->domainName; + } + + public function setDomainName(string $domainName): self + { + $this->domainName = $domainName; + return $this; + } + + public function getIpAddress(): string + { + return $this->ipAddress; + } + + public function setIpAddress(string $ipAddress): self + { + $this->ipAddress = $ipAddress; + return $this; + } +} diff --git a/Infobip/Model/EmailDomainIpResponse.php b/Infobip/Model/EmailDomainIpResponse.php new file mode 100644 index 0000000..f55ffeb --- /dev/null +++ b/Infobip/Model/EmailDomainIpResponse.php @@ -0,0 +1,74 @@ + null + ]; + + /** + * @param \Infobip\Model\EmailDomainIp[] $result + */ + public function __construct( + #[Assert\NotBlank] + + protected array $result, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + /** + * @return \Infobip\Model\EmailDomainIp[] + */ + public function getResult(): array + { + return $this->result; + } + + /** + * @param \Infobip\Model\EmailDomainIp[] $result List of ip details. + */ + public function setResult(array $result): self + { + $this->result = $result; + return $this; + } +} diff --git a/Infobip/Model/EmailDomainResponse.php b/Infobip/Model/EmailDomainResponse.php new file mode 100644 index 0000000..03de86e --- /dev/null +++ b/Infobip/Model/EmailDomainResponse.php @@ -0,0 +1,154 @@ + 'int64', + 'domainName' => null, + 'active' => null, + 'tracking' => null, + 'dnsRecords' => null, + 'blocked' => null, + 'createdAt' => 'date-time' + ]; + + /** + * @param \Infobip\Model\EmailDnsRecordResponse[] $dnsRecords + */ + public function __construct( + protected ?int $domainId = null, + protected ?string $domainName = null, + protected ?bool $active = null, + #[Assert\Valid] + + protected ?\Infobip\Model\EmailTrackingResponse $tracking = null, + protected ?array $dnsRecords = null, + protected ?bool $blocked = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $createdAt = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getDomainId(): int|null + { + return $this->domainId; + } + + public function setDomainId(?int $domainId): self + { + $this->domainId = $domainId; + return $this; + } + + public function getDomainName(): string|null + { + return $this->domainName; + } + + public function setDomainName(?string $domainName): self + { + $this->domainName = $domainName; + return $this; + } + + public function getActive(): bool|null + { + return $this->active; + } + + public function setActive(?bool $active): self + { + $this->active = $active; + return $this; + } + + public function getTracking(): \Infobip\Model\EmailTrackingResponse|null + { + return $this->tracking; + } + + public function setTracking(?\Infobip\Model\EmailTrackingResponse $tracking): self + { + $this->tracking = $tracking; + return $this; + } + + /** + * @return \Infobip\Model\EmailDnsRecordResponse[]|null + */ + public function getDnsRecords(): ?array + { + return $this->dnsRecords; + } + + /** + * @param \Infobip\Model\EmailDnsRecordResponse[]|null $dnsRecords DNS records for the domain. + */ + public function setDnsRecords(?array $dnsRecords): self + { + $this->dnsRecords = $dnsRecords; + return $this; + } + + public function getBlocked(): bool|null + { + return $this->blocked; + } + + public function setBlocked(?bool $blocked): self + { + $this->blocked = $blocked; + return $this; + } + + public function getCreatedAt(): \DateTime|null + { + return $this->createdAt; + } + + public function setCreatedAt(?\DateTime $createdAt): self + { + $this->createdAt = $createdAt; + return $this; + } +} diff --git a/Infobip/Model/EmailLog.php b/Infobip/Model/EmailLog.php index cb4b05d..4928ec4 100644 --- a/Infobip/Model/EmailLog.php +++ b/Infobip/Model/EmailLog.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class EmailLog implements ModelInterface, ArrayAccess, \JsonSerializable +class EmailLog implements ModelInterface { - public const DISCRIMINATOR = null; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'EmailLog'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'EmailLog'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'messageId' => 'string', - 'to' => 'string', - 'from' => 'string', - 'text' => 'string', - 'sentAt' => '\DateTime', - 'doneAt' => '\DateTime', - 'messageCount' => 'int', - 'price' => '\Infobip\Model\EmailPrice', - 'status' => '\Infobip\Model\EmailStatus', - 'bulkId' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'messageId' => null, 'to' => null, 'from' => null, @@ -88,500 +43,148 @@ class EmailLog implements ModelInterface, ArrayAccess, \JsonSerializable ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'messageId' => 'messageId', - 'to' => 'to', - 'from' => 'from', - 'text' => 'text', - 'sentAt' => 'sentAt', - 'doneAt' => 'doneAt', - 'messageCount' => 'messageCount', - 'price' => 'price', - 'status' => 'status', - 'bulkId' => 'bulkId' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'messageId' => 'setMessageId', - 'to' => 'setTo', - 'from' => 'setFrom', - 'text' => 'setText', - 'sentAt' => 'setSentAt', - 'doneAt' => 'setDoneAt', - 'messageCount' => 'setMessageCount', - 'price' => 'setPrice', - 'status' => 'setStatus', - 'bulkId' => 'setBulkId' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'messageId' => 'getMessageId', - 'to' => 'getTo', - 'from' => 'getFrom', - 'text' => 'getText', - 'sentAt' => 'getSentAt', - 'doneAt' => 'getDoneAt', - 'messageCount' => 'getMessageCount', - 'price' => 'getPrice', - 'status' => 'getStatus', - 'bulkId' => 'getBulkId' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - + public function __construct( + protected ?string $messageId = null, + protected ?string $to = null, + protected ?string $from = null, + protected ?string $text = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + protected ?\DateTime $sentAt = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + protected ?\DateTime $doneAt = null, + protected ?int $messageCount = null, + #[Assert\Valid] - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; + protected ?\Infobip\Model\EmailPrice $price = null, + #[Assert\Valid] - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['messageId'] = $data['messageId'] ?? null; - $this->container['to'] = $data['to'] ?? null; - $this->container['from'] = $data['from'] ?? null; - $this->container['text'] = $data['text'] ?? null; - $this->container['sentAt'] = $data['sentAt'] ?? null; - $this->container['doneAt'] = $data['doneAt'] ?? null; - $this->container['messageCount'] = $data['messageCount'] ?? null; - $this->container['price'] = $data['price'] ?? null; - $this->container['status'] = $data['status'] ?? null; - $this->container['bulkId'] = $data['bulkId'] ?? null; + protected ?\Infobip\Model\EmailStatus $status = null, + protected ?string $bulkId = null, + ) { } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets messageId - * - * @return string|null - */ - public function getMessageId() + public function getMessageId(): string|null { - return $this->container['messageId']; + return $this->messageId; } - /** - * Sets messageId - * - * @param string|null $messageId The ID that uniquely identifies the sent email request. - * - * @return self - */ - public function setMessageId($messageId) + public function setMessageId(?string $messageId): self { - $this->container['messageId'] = $messageId; - + $this->messageId = $messageId; return $this; } - /** - * Gets to - * - * @return string|null - */ - public function getTo() + public function getTo(): string|null { - return $this->container['to']; + return $this->to; } - /** - * Sets to - * - * @param string|null $to The recipient email address. - * - * @return self - */ - public function setTo($to) + public function setTo(?string $to): self { - $this->container['to'] = $to; - + $this->to = $to; return $this; } - /** - * Gets from - * - * @return string|null - */ - public function getFrom() + public function getFrom(): string|null { - return $this->container['from']; + return $this->from; } - /** - * Sets from - * - * @param string|null $from From email address. - * - * @return self - */ - public function setFrom($from) + public function setFrom(?string $from): self { - $this->container['from'] = $from; - + $this->from = $from; return $this; } - /** - * Gets text - * - * @return string|null - */ - public function getText() + public function getText(): string|null { - return $this->container['text']; + return $this->text; } - /** - * Sets text - * - * @param string|null $text The text from email body. - * - * @return self - */ - public function setText($text) + public function setText(?string $text): self { - $this->container['text'] = $text; - + $this->text = $text; return $this; } - /** - * Gets sentAt - * - * @return \DateTime|null - */ - public function getSentAt() + public function getSentAt(): \DateTime|null { - return $this->container['sentAt']; + return $this->sentAt; } - /** - * Sets sentAt - * - * @param \DateTime|null $sentAt Tells when the email was initiated. Has the following format: `yyyy-MM-dd'T'HH:mm:ss.SSSZ`. - * - * @return self - */ - public function setSentAt($sentAt) + public function setSentAt(?\DateTime $sentAt): self { - $this->container['sentAt'] = $sentAt; - + $this->sentAt = $sentAt; return $this; } - /** - * Gets doneAt - * - * @return \DateTime|null - */ - public function getDoneAt() + public function getDoneAt(): \DateTime|null { - return $this->container['doneAt']; + return $this->doneAt; } - /** - * Sets doneAt - * - * @param \DateTime|null $doneAt Tells when the email request was processed by Infobip - * - * @return self - */ - public function setDoneAt($doneAt) + public function setDoneAt(?\DateTime $doneAt): self { - $this->container['doneAt'] = $doneAt; - + $this->doneAt = $doneAt; return $this; } - /** - * Gets messageCount - * - * @return int|null - */ - public function getMessageCount() + public function getMessageCount(): int|null { - return $this->container['messageCount']; + return $this->messageCount; } - /** - * Sets messageCount - * - * @param int|null $messageCount Email request count. - * - * @return self - */ - public function setMessageCount($messageCount) + public function setMessageCount(?int $messageCount): self { - $this->container['messageCount'] = $messageCount; - + $this->messageCount = $messageCount; return $this; } - /** - * Gets price - * - * @return \Infobip\Model\EmailPrice|null - */ - public function getPrice() + public function getPrice(): \Infobip\Model\EmailPrice|null { - return $this->container['price']; + return $this->price; } - /** - * Sets price - * - * @param \Infobip\Model\EmailPrice|null $price price - * - * @return self - */ - public function setPrice($price) + public function setPrice(?\Infobip\Model\EmailPrice $price): self { - $this->container['price'] = $price; - + $this->price = $price; return $this; } - /** - * Gets status - * - * @return \Infobip\Model\EmailStatus|null - */ - public function getStatus() + public function getStatus(): \Infobip\Model\EmailStatus|null { - return $this->container['status']; + return $this->status; } - /** - * Sets status - * - * @param \Infobip\Model\EmailStatus|null $status status - * - * @return self - */ - public function setStatus($status) + public function setStatus(?\Infobip\Model\EmailStatus $status): self { - $this->container['status'] = $status; - + $this->status = $status; return $this; } - /** - * Gets bulkId - * - * @return string|null - */ - public function getBulkId() + public function getBulkId(): string|null { - return $this->container['bulkId']; + return $this->bulkId; } - /** - * Sets bulkId - * - * @param string|null $bulkId The ID that uniquely identifies the request. - * - * @return self - */ - public function setBulkId($bulkId) + public function setBulkId(?string $bulkId): self { - $this->container['bulkId'] = $bulkId; - + $this->bulkId = $bulkId; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/EmailLogsResponse.php b/Infobip/Model/EmailLogsResponse.php index 2e81848..34becec 100644 --- a/Infobip/Model/EmailLogsResponse.php +++ b/Infobip/Model/EmailLogsResponse.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class EmailLogsResponse implements ModelInterface, ArrayAccess, \JsonSerializable +class EmailLogsResponse implements ModelInterface { - public const DISCRIMINATOR = null; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'EmailLogsResponse'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'EmailLogsResponse'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'results' => '\Infobip\Model\EmailLog[]' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'results' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'results' => 'results' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'results' => 'setResults' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] + * @param \Infobip\Model\EmailLog[] $results */ - protected static $getters = [ - 'results' => 'getResults' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; + public function __construct( + protected ?array $results = null, + ) { } - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() + #[Ignore] + public function getModelName(): string { - return self::$setters; + return self::OPENAPI_MODEL_NAME; } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$getters; + return self::DISCRIMINATOR; } /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['results'] = $data['results'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $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() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets results - * * @return \Infobip\Model\EmailLog[]|null */ - public function getResults() + public function getResults(): ?array { - return $this->container['results']; + return $this->results; } /** - * Sets results - * * @param \Infobip\Model\EmailLog[]|null $results Array of email logs, one object per each email request. - * - * @return self */ - public function setResults($results) + public function setResults(?array $results): self { - $this->container['results'] = $results; - + $this->results = $results; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/EmailPaging.php b/Infobip/Model/EmailPaging.php new file mode 100644 index 0000000..6472a7b --- /dev/null +++ b/Infobip/Model/EmailPaging.php @@ -0,0 +1,104 @@ + 'int32', + 'size' => 'int32', + 'totalPages' => 'int32', + 'totalResults' => 'int32' + ]; + + /** + */ + public function __construct( + protected ?int $page = null, + protected ?int $size = null, + protected ?int $totalPages = null, + protected ?int $totalResults = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getPage(): int|null + { + return $this->page; + } + + public function setPage(?int $page): self + { + $this->page = $page; + return $this; + } + + public function getSize(): int|null + { + return $this->size; + } + + public function setSize(?int $size): self + { + $this->size = $size; + return $this; + } + + public function getTotalPages(): int|null + { + return $this->totalPages; + } + + public function setTotalPages(?int $totalPages): self + { + $this->totalPages = $totalPages; + return $this; + } + + public function getTotalResults(): int|null + { + return $this->totalResults; + } + + public function setTotalResults(?int $totalResults): self + { + $this->totalResults = $totalResults; + return $this; + } +} diff --git a/Infobip/Model/EmailPrice.php b/Infobip/Model/EmailPrice.php index 4947ce8..58085dd 100644 --- a/Infobip/Model/EmailPrice.php +++ b/Infobip/Model/EmailPrice.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class EmailPrice implements ModelInterface, ArrayAccess, \JsonSerializable +class EmailPrice implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'EmailPrice'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'pricePerMessage' => 'float', - 'currency' => 'string' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'EmailPrice'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'pricePerMessage' => null, 'currency' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'pricePerMessage' => 'pricePerMessage', - 'currency' => 'currency' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'pricePerMessage' => 'setPricePerMessage', - 'currency' => 'setCurrency' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'pricePerMessage' => 'getPricePerMessage', - '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() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['pricePerMessage'] = $data['pricePerMessage'] ?? null; - $this->container['currency'] = $data['currency'] ?? null; + public function __construct( + protected ?float $pricePerMessage = null, + protected ?string $currency = null, + ) { } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets pricePerMessage - * - * @return float|null - */ - public function getPricePerMessage() + public function getPricePerMessage(): float|null { - return $this->container['pricePerMessage']; + return $this->pricePerMessage; } - /** - * Sets pricePerMessage - * - * @param float|null $pricePerMessage Price per one email request. - * - * @return self - */ - public function setPricePerMessage($pricePerMessage) + public function setPricePerMessage(?float $pricePerMessage): self { - $this->container['pricePerMessage'] = $pricePerMessage; - + $this->pricePerMessage = $pricePerMessage; return $this; } - /** - * Gets currency - * - * @return string|null - */ - public function getCurrency() + public function getCurrency(): string|null { - return $this->container['currency']; + return $this->currency; } - /** - * Sets currency - * - * @param string|null $currency The currency in which the price is expressed. - * - * @return self - */ - public function setCurrency($currency) + public function setCurrency(?string $currency): self { - $this->container['currency'] = $currency; - + $this->currency = $currency; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/EmailReport.php b/Infobip/Model/EmailReport.php index 9364822..7c5fa94 100644 --- a/Infobip/Model/EmailReport.php +++ b/Infobip/Model/EmailReport.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class EmailReport implements ModelInterface, ArrayAccess, \JsonSerializable +class EmailReport implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'EmailReport'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'bulkId' => 'string', - 'messageId' => 'string', - 'to' => 'string', - 'sentAt' => '\DateTime', - 'doneAt' => '\DateTime', - 'messageCount' => 'int', - 'price' => '\Infobip\Model\EmailPrice', - 'status' => '\Infobip\Model\EmailStatus', - 'error' => '\Infobip\Model\EmailReportError' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'EmailReport'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ + 'applicationId' => null, + 'entityId' => null, 'bulkId' => null, 'messageId' => null, 'to' => null, @@ -85,472 +44,162 @@ class EmailReport implements ModelInterface, ArrayAccess, \JsonSerializable ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'bulkId' => 'bulkId', - 'messageId' => 'messageId', - 'to' => 'to', - 'sentAt' => 'sentAt', - 'doneAt' => 'doneAt', - 'messageCount' => 'messageCount', - 'price' => 'price', - 'status' => 'status', - 'error' => 'error' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'bulkId' => 'setBulkId', - 'messageId' => 'setMessageId', - 'to' => 'setTo', - 'sentAt' => 'setSentAt', - 'doneAt' => 'setDoneAt', - 'messageCount' => 'setMessageCount', - 'price' => 'setPrice', - 'status' => 'setStatus', - 'error' => 'setError' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] */ - protected static $getters = [ - 'bulkId' => 'getBulkId', - 'messageId' => 'getMessageId', - 'to' => 'getTo', - 'sentAt' => 'getSentAt', - 'doneAt' => 'getDoneAt', - 'messageCount' => 'getMessageCount', - 'price' => 'getPrice', - 'status' => 'getStatus', - 'error' => 'getError' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } + public function __construct( + protected ?string $applicationId = null, + protected ?string $entityId = null, + protected ?string $bulkId = null, + protected ?string $messageId = null, + protected ?string $to = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + protected ?\DateTime $sentAt = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + protected ?\DateTime $doneAt = null, + protected ?int $messageCount = null, + #[Assert\Valid] + protected ?\Infobip\Model\EmailPrice $price = null, + #[Assert\Valid] + protected ?\Infobip\Model\EmailStatus $status = null, + #[Assert\Valid] - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['bulkId'] = $data['bulkId'] ?? null; - $this->container['messageId'] = $data['messageId'] ?? null; - $this->container['to'] = $data['to'] ?? null; - $this->container['sentAt'] = $data['sentAt'] ?? null; - $this->container['doneAt'] = $data['doneAt'] ?? null; - $this->container['messageCount'] = $data['messageCount'] ?? null; - $this->container['price'] = $data['price'] ?? null; - $this->container['status'] = $data['status'] ?? null; - $this->container['error'] = $data['error'] ?? null; + protected ?\Infobip\Model\EmailReportError $error = null, + ) { } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets bulkId - * - * @return string|null - */ - public function getBulkId() + public function getApplicationId(): string|null { - return $this->container['bulkId']; + return $this->applicationId; } - /** - * Sets bulkId - * - * @param string|null $bulkId The ID that uniquely identifies bulks of request. - * - * @return self - */ - public function setBulkId($bulkId) + public function setApplicationId(?string $applicationId): self { - $this->container['bulkId'] = $bulkId; - + $this->applicationId = $applicationId; return $this; } - /** - * Gets messageId - * - * @return string|null - */ - public function getMessageId() + public function getEntityId(): string|null { - return $this->container['messageId']; + return $this->entityId; } - /** - * Sets messageId - * - * @param string|null $messageId The ID that uniquely identifies the sent email request. - * - * @return self - */ - public function setMessageId($messageId) + public function setEntityId(?string $entityId): self { - $this->container['messageId'] = $messageId; - + $this->entityId = $entityId; return $this; } - /** - * Gets to - * - * @return string|null - */ - public function getTo() + public function getBulkId(): string|null { - return $this->container['to']; + return $this->bulkId; } - /** - * Sets to - * - * @param string|null $to The recipient email address. - * - * @return self - */ - public function setTo($to) + public function setBulkId(?string $bulkId): self { - $this->container['to'] = $to; - + $this->bulkId = $bulkId; return $this; } - /** - * Gets sentAt - * - * @return \DateTime|null - */ - public function getSentAt() + public function getMessageId(): string|null { - return $this->container['sentAt']; + return $this->messageId; } - /** - * Sets sentAt - * - * @param \DateTime|null $sentAt Tells when the email was initiated. Has the following format: `yyyy-MM-dd'T'HH:mm:ss.SSSZ`. - * - * @return self - */ - public function setSentAt($sentAt) + public function setMessageId(?string $messageId): self { - $this->container['sentAt'] = $sentAt; - + $this->messageId = $messageId; return $this; } - /** - * Gets doneAt - * - * @return \DateTime|null - */ - public function getDoneAt() + public function getTo(): string|null { - return $this->container['doneAt']; + return $this->to; } - /** - * Sets doneAt - * - * @param \DateTime|null $doneAt Tells when the email request was processed by Infobip - * - * @return self - */ - public function setDoneAt($doneAt) + public function setTo(?string $to): self { - $this->container['doneAt'] = $doneAt; - + $this->to = $to; return $this; } - /** - * Gets messageCount - * - * @return int|null - */ - public function getMessageCount() + public function getSentAt(): \DateTime|null { - return $this->container['messageCount']; + return $this->sentAt; } - /** - * Sets messageCount - * - * @param int|null $messageCount Email request count. - * - * @return self - */ - public function setMessageCount($messageCount) + public function setSentAt(?\DateTime $sentAt): self { - $this->container['messageCount'] = $messageCount; - + $this->sentAt = $sentAt; return $this; } - /** - * Gets price - * - * @return \Infobip\Model\EmailPrice|null - */ - public function getPrice() + public function getDoneAt(): \DateTime|null { - return $this->container['price']; + return $this->doneAt; } - /** - * Sets price - * - * @param \Infobip\Model\EmailPrice|null $price price - * - * @return self - */ - public function setPrice($price) + public function setDoneAt(?\DateTime $doneAt): self { - $this->container['price'] = $price; - + $this->doneAt = $doneAt; return $this; } - /** - * Gets status - * - * @return \Infobip\Model\EmailStatus|null - */ - public function getStatus() + public function getMessageCount(): int|null { - return $this->container['status']; + return $this->messageCount; } - /** - * Sets status - * - * @param \Infobip\Model\EmailStatus|null $status status - * - * @return self - */ - public function setStatus($status) + public function setMessageCount(?int $messageCount): self { - $this->container['status'] = $status; - + $this->messageCount = $messageCount; return $this; } - /** - * Gets error - * - * @return \Infobip\Model\EmailReportError|null - */ - public function getError() + public function getPrice(): \Infobip\Model\EmailPrice|null { - return $this->container['error']; + return $this->price; } - /** - * Sets error - * - * @param \Infobip\Model\EmailReportError|null $error error - * - * @return self - */ - public function setError($error) + public function setPrice(?\Infobip\Model\EmailPrice $price): self { - $this->container['error'] = $error; - + $this->price = $price; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void + public function getStatus(): \Infobip\Model\EmailStatus|null { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } + return $this->status; } - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void + public function setStatus(?\Infobip\Model\EmailStatus $status): self { - 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. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); + $this->status = $status; + return $this; } - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() + public function getError(): \Infobip\Model\EmailReportError|null { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); + return $this->error; } - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() + public function setError(?\Infobip\Model\EmailReportError $error): self { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + $this->error = $error; + return $this; } } diff --git a/Infobip/Model/EmailReportError.php b/Infobip/Model/EmailReportError.php index bb8d827..723220c 100644 --- a/Infobip/Model/EmailReportError.php +++ b/Infobip/Model/EmailReportError.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class EmailReportError implements ModelInterface, ArrayAccess, \JsonSerializable +class EmailReportError implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'EmailReportError'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'groupId' => 'int', - 'groupName' => 'string', - 'id' => 'int', - 'name' => 'string', - 'description' => 'string', - 'permanent' => 'bool' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'EmailReportError'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'groupId' => 'int32', 'groupName' => null, 'id' => 'int32', @@ -79,388 +39,92 @@ class EmailReportError implements ModelInterface, ArrayAccess, \JsonSerializable ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'groupId' => 'groupId', - 'groupName' => 'groupName', - 'id' => 'id', - 'name' => 'name', - 'description' => 'description', - 'permanent' => 'permanent' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'groupId' => 'setGroupId', - 'groupName' => 'setGroupName', - 'id' => 'setId', - 'name' => 'setName', - 'description' => 'setDescription', - 'permanent' => 'setPermanent' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] */ - protected static $getters = [ - 'groupId' => 'getGroupId', - 'groupName' => 'getGroupName', - 'id' => 'getId', - 'name' => 'getName', - 'description' => 'getDescription', - 'permanent' => 'getPermanent' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; + public function __construct( + protected ?int $groupId = null, + protected ?string $groupName = null, + protected ?int $id = null, + protected ?string $name = null, + protected ?string $description = null, + protected ?bool $permanent = null, + ) { } - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['groupId'] = $data['groupId'] ?? null; - $this->container['groupName'] = $data['groupName'] ?? null; - $this->container['id'] = $data['id'] ?? null; - $this->container['name'] = $data['name'] ?? null; - $this->container['description'] = $data['description'] ?? null; - $this->container['permanent'] = $data['permanent'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets groupId - * - * @return int|null - */ - public function getGroupId() + public function getGroupId(): int|null { - return $this->container['groupId']; + return $this->groupId; } - /** - * Sets groupId - * - * @param int|null $groupId groupId - * - * @return self - */ - public function setGroupId($groupId) + public function setGroupId(?int $groupId): self { - $this->container['groupId'] = $groupId; - + $this->groupId = $groupId; return $this; } - /** - * Gets groupName - * - * @return string|null - */ - public function getGroupName() + public function getGroupName(): string|null { - return $this->container['groupName']; + return $this->groupName; } - /** - * Sets groupName - * - * @param string|null $groupName groupName - * - * @return self - */ - public function setGroupName($groupName) + public function setGroupName(?string $groupName): self { - $this->container['groupName'] = $groupName; - + $this->groupName = $groupName; return $this; } - /** - * Gets id - * - * @return int|null - */ - public function getId() + public function getId(): int|null { - return $this->container['id']; + return $this->id; } - /** - * Sets id - * - * @param int|null $id id - * - * @return self - */ - public function setId($id) + public function setId(?int $id): self { - $this->container['id'] = $id; - + $this->id = $id; return $this; } - /** - * Gets name - * - * @return string|null - */ - public function getName() + public function getName(): string|null { - return $this->container['name']; + return $this->name; } - /** - * Sets name - * - * @param string|null $name name - * - * @return self - */ - public function setName($name) + public function setName(?string $name): self { - $this->container['name'] = $name; - + $this->name = $name; return $this; } - /** - * Gets description - * - * @return string|null - */ - public function getDescription() + public function getDescription(): string|null { - return $this->container['description']; + return $this->description; } - /** - * Sets description - * - * @param string|null $description description - * - * @return self - */ - public function setDescription($description) + public function setDescription(?string $description): self { - $this->container['description'] = $description; - + $this->description = $description; return $this; } - /** - * Gets permanent - * - * @return bool|null - */ - public function getPermanent() + public function getPermanent(): bool|null { - return $this->container['permanent']; + return $this->permanent; } - /** - * Sets permanent - * - * @param bool|null $permanent permanent - * - * @return self - */ - public function setPermanent($permanent) + public function setPermanent(?bool $permanent): self { - $this->container['permanent'] = $permanent; - + $this->permanent = $permanent; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/EmailReportsResult.php b/Infobip/Model/EmailReportsResult.php index 05e7145..15da531 100644 --- a/Infobip/Model/EmailReportsResult.php +++ b/Infobip/Model/EmailReportsResult.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class EmailReportsResult implements ModelInterface, ArrayAccess, \JsonSerializable +class EmailReportsResult implements ModelInterface { - public const DISCRIMINATOR = null; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'EmailReportsResult'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'EmailReportsResult'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'results' => '\Infobip\Model\EmailReport[]' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'results' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'results' => 'results' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'results' => 'setResults' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] + * @param \Infobip\Model\EmailReport[] $results */ - protected static $getters = [ - 'results' => 'getResults' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; + public function __construct( + protected ?array $results = null, + ) { } - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() + #[Ignore] + public function getModelName(): string { - return self::$setters; + return self::OPENAPI_MODEL_NAME; } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$getters; + return self::DISCRIMINATOR; } /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['results'] = $data['results'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $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() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets results - * * @return \Infobip\Model\EmailReport[]|null */ - public function getResults() + public function getResults(): ?array { - return $this->container['results']; + return $this->results; } /** - * Sets results - * * @param \Infobip\Model\EmailReport[]|null $results results - * - * @return self */ - public function setResults($results) + public function setResults(?array $results): self { - $this->container['results'] = $results; - + $this->results = $results; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/EmailResponseDetails.php b/Infobip/Model/EmailResponseDetails.php new file mode 100644 index 0000000..4dcf8ea --- /dev/null +++ b/Infobip/Model/EmailResponseDetails.php @@ -0,0 +1,93 @@ + null, + 'messageId' => null, + 'status' => null + ]; + + /** + */ + public function __construct( + protected ?string $to = null, + protected ?string $messageId = null, + #[Assert\Valid] + + protected ?\Infobip\Model\EmailSingleMessageStatus $status = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getTo(): string|null + { + return $this->to; + } + + public function setTo(?string $to): self + { + $this->to = $to; + return $this; + } + + public function getMessageId(): string|null + { + return $this->messageId; + } + + public function setMessageId(?string $messageId): self + { + $this->messageId = $messageId; + return $this; + } + + public function getStatus(): \Infobip\Model\EmailSingleMessageStatus|null + { + return $this->status; + } + + public function setStatus(?\Infobip\Model\EmailSingleMessageStatus $status): self + { + $this->status = $status; + return $this; + } +} diff --git a/Infobip/Model/EmailSendResponse.php b/Infobip/Model/EmailSendResponse.php index 8f05b78..15c6fdd 100644 --- a/Infobip/Model/EmailSendResponse.php +++ b/Infobip/Model/EmailSendResponse.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class EmailSendResponse implements ModelInterface, ArrayAccess, \JsonSerializable +class EmailSendResponse implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'EmailSendResponse'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'bulkId' => 'string', - 'messages' => '\Infobip\Model\EmailMessageInfo[]' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'EmailSendResponse'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'bulkId' => null, 'messages' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'bulkId' => 'bulkId', - 'messages' => 'messages' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'bulkId' => 'setBulkId', - 'messages' => 'setMessages' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'bulkId' => 'getBulkId', - 'messages' => 'getMessages' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model + * @param \Infobip\Model\EmailResponseDetails[] $messages */ - public function __construct(array $data = null) - { - $this->container['bulkId'] = $data['bulkId'] ?? null; - $this->container['messages'] = $data['messages'] ?? null; + public function __construct( + protected ?string $bulkId = null, + protected ?array $messages = null, + ) { } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets bulkId - * - * @return string|null - */ - public function getBulkId() + public function getBulkId(): string|null { - return $this->container['bulkId']; + return $this->bulkId; } - /** - * Sets bulkId - * - * @param string|null $bulkId bulkId - * - * @return self - */ - public function setBulkId($bulkId) + public function setBulkId(?string $bulkId): self { - $this->container['bulkId'] = $bulkId; - + $this->bulkId = $bulkId; return $this; } /** - * Gets messages - * - * @return \Infobip\Model\EmailMessageInfo[]|null + * @return \Infobip\Model\EmailResponseDetails[]|null */ - public function getMessages() + public function getMessages(): ?array { - return $this->container['messages']; + return $this->messages; } /** - * Sets messages - * - * @param \Infobip\Model\EmailMessageInfo[]|null $messages messages - * - * @return self + * @param \Infobip\Model\EmailResponseDetails[]|null $messages List of message response details. */ - public function setMessages($messages) + public function setMessages(?array $messages): self { - $this->container['messages'] = $messages; - + $this->messages = $messages; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/EmailSimpleApiResponse.php b/Infobip/Model/EmailSimpleApiResponse.php new file mode 100644 index 0000000..640455f --- /dev/null +++ b/Infobip/Model/EmailSimpleApiResponse.php @@ -0,0 +1,67 @@ + null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + + protected string $result, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getResult(): string + { + return $this->result; + } + + public function setResult(string $result): self + { + $this->result = $result; + return $this; + } +} diff --git a/Infobip/Model/EmailSingleMessageStatus.php b/Infobip/Model/EmailSingleMessageStatus.php new file mode 100644 index 0000000..35ac578 --- /dev/null +++ b/Infobip/Model/EmailSingleMessageStatus.php @@ -0,0 +1,117 @@ + 'int32', + 'groupName' => null, + 'id' => 'int32', + 'name' => null, + 'description' => null + ]; + + /** + */ + public function __construct( + protected ?int $groupId = null, + protected ?string $groupName = null, + protected ?int $id = null, + protected ?string $name = null, + protected ?string $description = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getGroupId(): int|null + { + return $this->groupId; + } + + public function setGroupId(?int $groupId): self + { + $this->groupId = $groupId; + return $this; + } + + public function getGroupName(): string|null + { + return $this->groupName; + } + + public function setGroupName(?string $groupName): self + { + $this->groupName = $groupName; + return $this; + } + + public function getId(): int|null + { + return $this->id; + } + + public function setId(?int $id): self + { + $this->id = $id; + return $this; + } + + public function getName(): string|null + { + return $this->name; + } + + public function setName(?string $name): self + { + $this->name = $name; + return $this; + } + + public function getDescription(): string|null + { + return $this->description; + } + + public function setDescription(?string $description): self + { + $this->description = $description; + return $this; + } +} diff --git a/Infobip/Model/EmailStatus.php b/Infobip/Model/EmailStatus.php index 0e5e35a..880572d 100644 --- a/Infobip/Model/EmailStatus.php +++ b/Infobip/Model/EmailStatus.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class EmailStatus implements ModelInterface, ArrayAccess, \JsonSerializable +class EmailStatus implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'EmailStatus'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'groupId' => 'int', - 'groupName' => 'string', - 'id' => 'int', - 'name' => 'string', - 'description' => 'string', - 'action' => 'string' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'EmailStatus'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'groupId' => 'int32', 'groupName' => null, 'id' => 'int32', @@ -80,388 +39,92 @@ class EmailStatus implements ModelInterface, ArrayAccess, \JsonSerializable ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'groupId' => 'groupId', - 'groupName' => 'groupName', - 'id' => 'id', - 'name' => 'name', - 'description' => 'description', - 'action' => 'action' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'groupId' => 'setGroupId', - 'groupName' => 'setGroupName', - 'id' => 'setId', - 'name' => 'setName', - 'description' => 'setDescription', - 'action' => 'setAction' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] */ - protected static $getters = [ - 'groupId' => 'getGroupId', - 'groupName' => 'getGroupName', - 'id' => 'getId', - 'name' => 'getName', - 'description' => 'getDescription', - 'action' => 'getAction' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; + public function __construct( + protected ?int $groupId = null, + protected ?string $groupName = null, + protected ?int $id = null, + protected ?string $name = null, + protected ?string $description = null, + protected ?string $action = null, + ) { } - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['groupId'] = $data['groupId'] ?? null; - $this->container['groupName'] = $data['groupName'] ?? null; - $this->container['id'] = $data['id'] ?? null; - $this->container['name'] = $data['name'] ?? null; - $this->container['description'] = $data['description'] ?? null; - $this->container['action'] = $data['action'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets groupId - * - * @return int|null - */ - public function getGroupId() + public function getGroupId(): int|null { - return $this->container['groupId']; + return $this->groupId; } - /** - * Sets groupId - * - * @param int|null $groupId Status group ID. - * - * @return self - */ - public function setGroupId($groupId) + public function setGroupId(?int $groupId): self { - $this->container['groupId'] = $groupId; - + $this->groupId = $groupId; return $this; } - /** - * Gets groupName - * - * @return string|null - */ - public function getGroupName() + public function getGroupName(): string|null { - return $this->container['groupName']; + return $this->groupName; } - /** - * Sets groupName - * - * @param string|null $groupName Status group name. - * - * @return self - */ - public function setGroupName($groupName) + public function setGroupName(?string $groupName): self { - $this->container['groupName'] = $groupName; - + $this->groupName = $groupName; return $this; } - /** - * Gets id - * - * @return int|null - */ - public function getId() + public function getId(): int|null { - return $this->container['id']; + return $this->id; } - /** - * Sets id - * - * @param int|null $id Status ID. - * - * @return self - */ - public function setId($id) + public function setId(?int $id): self { - $this->container['id'] = $id; - + $this->id = $id; return $this; } - /** - * Gets name - * - * @return string|null - */ - public function getName() + public function getName(): string|null { - return $this->container['name']; + return $this->name; } - /** - * Sets name - * - * @param string|null $name Status name. - * - * @return self - */ - public function setName($name) + public function setName(?string $name): self { - $this->container['name'] = $name; - + $this->name = $name; return $this; } - /** - * Gets description - * - * @return string|null - */ - public function getDescription() + public function getDescription(): string|null { - return $this->container['description']; + return $this->description; } - /** - * Sets description - * - * @param string|null $description Human-readable description of the status. - * - * @return self - */ - public function setDescription($description) + public function setDescription(?string $description): self { - $this->container['description'] = $description; - + $this->description = $description; return $this; } - /** - * Gets action - * - * @return string|null - */ - public function getAction() + public function getAction(): string|null { - return $this->container['action']; + return $this->action; } - /** - * Sets action - * - * @param string|null $action Action name. - * - * @return self - */ - public function setAction($action) + public function setAction(?string $action): self { - $this->container['action'] = $action; - + $this->action = $action; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/EmailTrackingEventRequest.php b/Infobip/Model/EmailTrackingEventRequest.php new file mode 100644 index 0000000..bd965bb --- /dev/null +++ b/Infobip/Model/EmailTrackingEventRequest.php @@ -0,0 +1,91 @@ + null, + 'clicks' => null, + 'unsubscribe' => null + ]; + + /** + */ + public function __construct( + protected ?bool $open = null, + protected ?bool $clicks = null, + protected ?bool $unsubscribe = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getOpen(): bool|null + { + return $this->open; + } + + public function setOpen(?bool $open): self + { + $this->open = $open; + return $this; + } + + public function getClicks(): bool|null + { + return $this->clicks; + } + + public function setClicks(?bool $clicks): self + { + $this->clicks = $clicks; + return $this; + } + + public function getUnsubscribe(): bool|null + { + return $this->unsubscribe; + } + + public function setUnsubscribe(?bool $unsubscribe): self + { + $this->unsubscribe = $unsubscribe; + return $this; + } +} diff --git a/Infobip/Model/EmailTrackingResponse.php b/Infobip/Model/EmailTrackingResponse.php new file mode 100644 index 0000000..3ac263b --- /dev/null +++ b/Infobip/Model/EmailTrackingResponse.php @@ -0,0 +1,91 @@ + null, + 'opens' => null, + 'unsubscribe' => null + ]; + + /** + */ + public function __construct( + protected ?bool $clicks = null, + protected ?bool $opens = null, + protected ?bool $unsubscribe = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getClicks(): bool|null + { + return $this->clicks; + } + + public function setClicks(?bool $clicks): self + { + $this->clicks = $clicks; + return $this; + } + + public function getOpens(): bool|null + { + return $this->opens; + } + + public function setOpens(?bool $opens): self + { + $this->opens = $opens; + return $this; + } + + public function getUnsubscribe(): bool|null + { + return $this->unsubscribe; + } + + public function setUnsubscribe(?bool $unsubscribe): self + { + $this->unsubscribe = $unsubscribe; + return $this; + } +} diff --git a/Infobip/Model/EmailValidationRequest.php b/Infobip/Model/EmailValidationRequest.php index 4565247..1350755 100644 --- a/Infobip/Model/EmailValidationRequest.php +++ b/Infobip/Model/EmailValidationRequest.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class EmailValidationRequest implements ModelInterface, ArrayAccess, \JsonSerializable +class EmailValidationRequest implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'EmailValidationRequest'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'to' => 'string' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'EmailValidationRequest'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'to' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array */ - public static function openAPITypes() - { - return self::$openAPITypes; - } + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 2147483647)] + #[Assert\Length(min: 1)] - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; + protected string $to, + ) { } - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'to' => 'to' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'to' => 'setTo' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'to' => 'getTo' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() + #[Ignore] + public function getModelName(): string { - return self::$setters; + return self::OPENAPI_MODEL_NAME; } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$getters; + return self::DISCRIMINATOR; } - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() + public function getTo(): string { - return self::$openAPIModelName; + return $this->to; } - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) + public function setTo(string $to): self { - $this->container['to'] = $data['to'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - if ($this->container['to'] === null) { - $invalidProperties[] = "'to' can't be null"; - } - if ((mb_strlen($this->container['to']) > 2147483647)) { - $invalidProperties[] = "invalid value for 'to', the character length must be smaller than or equal to 2147483647."; - } - - if ((mb_strlen($this->container['to']) < 1)) { - $invalidProperties[] = "invalid value for 'to', the character length must be bigger than or equal to 1."; - } - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets to - * - * @return string - */ - public function getTo() - { - return $this->container['to']; - } - - /** - * Sets to - * - * @param string $to Email address of the recipient. - * - * @return self - */ - public function setTo($to) - { - if ((mb_strlen($to) > 2147483647)) { - throw new \InvalidArgumentException('invalid length for $to when calling EmailValidationRequest., must be smaller than or equal to 2147483647.'); - } - if ((mb_strlen($to) < 1)) { - throw new \InvalidArgumentException('invalid length for $to when calling EmailValidationRequest., must be bigger than or equal to 1.'); - } - - $this->container['to'] = $to; - + $this->to = $to; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/EmailValidationResponse.php b/Infobip/Model/EmailValidationResponse.php index d09faf5..3cca17b 100644 --- a/Infobip/Model/EmailValidationResponse.php +++ b/Infobip/Model/EmailValidationResponse.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class EmailValidationResponse implements ModelInterface, ArrayAccess, \JsonSerializable +class EmailValidationResponse implements ModelInterface { - public const DISCRIMINATOR = null; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'EmailValidationResponse'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'EmailValidationResponse'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'to' => 'string', - 'validMailbox' => 'string', - 'validSyntax' => 'bool', - 'catchAll' => 'bool', - 'didYouMean' => 'string', - 'disposable' => 'bool', - 'roleBased' => 'bool', - 'reason' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'to' => null, 'validMailbox' => null, 'validSyntax' => null, @@ -83,444 +41,116 @@ class EmailValidationResponse implements ModelInterface, ArrayAccess, \JsonSeria ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array */ - public static function openAPITypes() - { - return self::$openAPITypes; + public function __construct( + protected ?string $to = null, + protected ?string $validMailbox = null, + protected ?bool $validSyntax = null, + protected ?bool $catchAll = null, + protected ?string $didYouMean = null, + protected ?bool $disposable = null, + protected ?bool $roleBased = null, + protected ?string $reason = null, + ) { } - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() + #[Ignore] + public function getModelName(): string { - return self::$openAPIFormats; + return self::OPENAPI_MODEL_NAME; } - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'to' => 'to', - 'validMailbox' => 'validMailbox', - 'validSyntax' => 'validSyntax', - 'catchAll' => 'catchAll', - 'didYouMean' => 'didYouMean', - 'disposable' => 'disposable', - 'roleBased' => 'roleBased', - 'reason' => 'reason' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'to' => 'setTo', - 'validMailbox' => 'setValidMailbox', - 'validSyntax' => 'setValidSyntax', - 'catchAll' => 'setCatchAll', - 'didYouMean' => 'setDidYouMean', - 'disposable' => 'setDisposable', - 'roleBased' => 'setRoleBased', - 'reason' => 'setReason' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'to' => 'getTo', - 'validMailbox' => 'getValidMailbox', - 'validSyntax' => 'getValidSyntax', - 'catchAll' => 'getCatchAll', - 'didYouMean' => 'getDidYouMean', - 'disposable' => 'getDisposable', - 'roleBased' => 'getRoleBased', - 'reason' => 'getReason' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$attributeMap; + return self::DISCRIMINATOR; } - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['to'] = $data['to'] ?? null; - $this->container['validMailbox'] = $data['validMailbox'] ?? null; - $this->container['validSyntax'] = $data['validSyntax'] ?? null; - $this->container['catchAll'] = $data['catchAll'] ?? null; - $this->container['didYouMean'] = $data['didYouMean'] ?? null; - $this->container['disposable'] = $data['disposable'] ?? null; - $this->container['roleBased'] = $data['roleBased'] ?? null; - $this->container['reason'] = $data['reason'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $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() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets to - * - * @return string|null - */ - public function getTo() + public function getTo(): string|null { - return $this->container['to']; + return $this->to; } - /** - * Sets to - * - * @param string|null $to Email address of the recipient. - * - * @return self - */ - public function setTo($to) + public function setTo(?string $to): self { - $this->container['to'] = $to; - + $this->to = $to; return $this; } - /** - * Gets validMailbox - * - * @return string|null - */ - public function getValidMailbox() + public function getValidMailbox(): string|null { - return $this->container['validMailbox']; + return $this->validMailbox; } - /** - * Sets validMailbox - * - * @param string|null $validMailbox Represents status of recipient email address. - * - * @return self - */ - public function setValidMailbox($validMailbox) + public function setValidMailbox(?string $validMailbox): self { - $this->container['validMailbox'] = $validMailbox; - + $this->validMailbox = $validMailbox; return $this; } - /** - * Gets validSyntax - * - * @return bool|null - */ - public function getValidSyntax() + public function getValidSyntax(): bool|null { - return $this->container['validSyntax']; + return $this->validSyntax; } - /** - * Sets validSyntax - * - * @param bool|null $validSyntax Represents syntax of recipient email address. - * - * @return self - */ - public function setValidSyntax($validSyntax) + public function setValidSyntax(?bool $validSyntax): self { - $this->container['validSyntax'] = $validSyntax; - + $this->validSyntax = $validSyntax; return $this; } - /** - * Gets catchAll - * - * @return bool|null - */ - public function getCatchAll() + public function getCatchAll(): bool|null { - return $this->container['catchAll']; + return $this->catchAll; } - /** - * Sets catchAll - * - * @param bool|null $catchAll Denotes catch all status of recipient email address. - * - * @return self - */ - public function setCatchAll($catchAll) + public function setCatchAll(?bool $catchAll): self { - $this->container['catchAll'] = $catchAll; - + $this->catchAll = $catchAll; return $this; } - /** - * Gets didYouMean - * - * @return string|null - */ - public function getDidYouMean() + public function getDidYouMean(): string|null { - return $this->container['didYouMean']; + return $this->didYouMean; } - /** - * Sets didYouMean - * - * @param string|null $didYouMean Suggests alternate addresses that maybe valid. - * - * @return self - */ - public function setDidYouMean($didYouMean) + public function setDidYouMean(?string $didYouMean): self { - $this->container['didYouMean'] = $didYouMean; - + $this->didYouMean = $didYouMean; return $this; } - /** - * Gets disposable - * - * @return bool|null - */ - public function getDisposable() + public function getDisposable(): bool|null { - return $this->container['disposable']; + return $this->disposable; } - /** - * Sets disposable - * - * @param bool|null $disposable disposable - * - * @return self - */ - public function setDisposable($disposable) + public function setDisposable(?bool $disposable): self { - $this->container['disposable'] = $disposable; - + $this->disposable = $disposable; return $this; } - /** - * Gets roleBased - * - * @return bool|null - */ - public function getRoleBased() + public function getRoleBased(): bool|null { - return $this->container['roleBased']; + return $this->roleBased; } - /** - * Sets roleBased - * - * @param bool|null $roleBased roleBased - * - * @return self - */ - public function setRoleBased($roleBased) + public function setRoleBased(?bool $roleBased): self { - $this->container['roleBased'] = $roleBased; - + $this->roleBased = $roleBased; return $this; } - /** - * Gets reason - * - * @return string|null - */ - public function getReason() + public function getReason(): string|null { - return $this->container['reason']; + return $this->reason; } - /** - * Sets reason - * - * @param string|null $reason Reason is provided when validMailbox status is unknown. 1. INBOX_FULL - The user quota exceeded / The user inbox is full / The user doesn't accept any more requests. 2. UNEXPECTED_FAILURE - The mail Server returned a temporary error. 3. THROTTLED - The mail server is not allowing us momentarily because of too many requests. 4. TIMED_OUT - The Mail Server took a longer time to respond / there was a delay in the network. 5. TEMP_REJECTION - Mail server temporarily rejected. 6. UNABLE_TO_CONNECT - Unable to connect to the Mail Server. - * - * @return self - */ - public function setReason($reason) + public function setReason(?string $reason): self { - $this->container['reason'] = $reason; - + $this->reason = $reason; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/EmailWebhookDLRReportResponse.php b/Infobip/Model/EmailWebhookDLRReportResponse.php new file mode 100644 index 0000000..d867d36 --- /dev/null +++ b/Infobip/Model/EmailWebhookDLRReportResponse.php @@ -0,0 +1,72 @@ + null + ]; + + /** + * @param \Infobip\Model\EmailWebhookDeliveryReport[] $results + */ + public function __construct( + protected ?array $results = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + /** + * @return \Infobip\Model\EmailWebhookDeliveryReport[]|null + */ + public function getResults(): ?array + { + return $this->results; + } + + /** + * @param \Infobip\Model\EmailWebhookDeliveryReport[]|null $results results + */ + public function setResults(?array $results): self + { + $this->results = $results; + return $this; + } +} diff --git a/Infobip/Model/EmailWebhookDeliveryReport.php b/Infobip/Model/EmailWebhookDeliveryReport.php new file mode 100644 index 0000000..7df5a12 --- /dev/null +++ b/Infobip/Model/EmailWebhookDeliveryReport.php @@ -0,0 +1,205 @@ + null, + 'messageId' => null, + 'to' => null, + 'sentAt' => 'date-time', + 'doneAt' => 'date-time', + 'smsCount' => 'int32', + 'callbackData' => null, + 'price' => null, + 'status' => null, + 'error' => null, + 'browserLink' => null + ]; + + /** + */ + public function __construct( + protected ?string $bulkId = null, + protected ?string $messageId = null, + protected ?string $to = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $sentAt = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $doneAt = null, + protected ?int $smsCount = null, + protected ?string $callbackData = null, + #[Assert\Valid] + + protected ?\Infobip\Model\EmailWebhookPrice $price = null, + #[Assert\Valid] + + protected ?\Infobip\Model\MessageStatus $status = null, + #[Assert\Valid] + + protected ?\Infobip\Model\MessageError $error = null, + protected ?string $browserLink = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getBulkId(): string|null + { + return $this->bulkId; + } + + public function setBulkId(?string $bulkId): self + { + $this->bulkId = $bulkId; + return $this; + } + + public function getMessageId(): string|null + { + return $this->messageId; + } + + public function setMessageId(?string $messageId): self + { + $this->messageId = $messageId; + return $this; + } + + public function getTo(): string|null + { + return $this->to; + } + + public function setTo(?string $to): self + { + $this->to = $to; + return $this; + } + + public function getSentAt(): \DateTime|null + { + return $this->sentAt; + } + + public function setSentAt(?\DateTime $sentAt): self + { + $this->sentAt = $sentAt; + return $this; + } + + public function getDoneAt(): \DateTime|null + { + return $this->doneAt; + } + + public function setDoneAt(?\DateTime $doneAt): self + { + $this->doneAt = $doneAt; + return $this; + } + + public function getSmsCount(): int|null + { + return $this->smsCount; + } + + public function setSmsCount(?int $smsCount): self + { + $this->smsCount = $smsCount; + return $this; + } + + public function getCallbackData(): string|null + { + return $this->callbackData; + } + + public function setCallbackData(?string $callbackData): self + { + $this->callbackData = $callbackData; + return $this; + } + + public function getPrice(): \Infobip\Model\EmailWebhookPrice|null + { + return $this->price; + } + + public function setPrice(?\Infobip\Model\EmailWebhookPrice $price): self + { + $this->price = $price; + return $this; + } + + public function getStatus(): \Infobip\Model\MessageStatus|null + { + return $this->status; + } + + public function setStatus(?\Infobip\Model\MessageStatus $status): self + { + $this->status = $status; + return $this; + } + + public function getError(): \Infobip\Model\MessageError|null + { + return $this->error; + } + + public function setError(?\Infobip\Model\MessageError $error): self + { + $this->error = $error; + return $this; + } + + public function getBrowserLink(): string|null + { + return $this->browserLink; + } + + public function setBrowserLink(?string $browserLink): self + { + $this->browserLink = $browserLink; + return $this; + } +} diff --git a/Infobip/Model/EmailWebhookGeoLocation.php b/Infobip/Model/EmailWebhookGeoLocation.php new file mode 100644 index 0000000..fba07fa --- /dev/null +++ b/Infobip/Model/EmailWebhookGeoLocation.php @@ -0,0 +1,104 @@ + null, + 'city' => null, + 'latitude' => null, + 'longitude' => null + ]; + + /** + */ + public function __construct( + protected ?string $countryName = null, + protected ?string $city = null, + protected ?string $latitude = null, + protected ?string $longitude = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getCountryName(): string|null + { + return $this->countryName; + } + + public function setCountryName(?string $countryName): self + { + $this->countryName = $countryName; + return $this; + } + + public function getCity(): string|null + { + return $this->city; + } + + public function setCity(?string $city): self + { + $this->city = $city; + return $this; + } + + public function getLatitude(): string|null + { + return $this->latitude; + } + + public function setLatitude(?string $latitude): self + { + $this->latitude = $latitude; + return $this; + } + + public function getLongitude(): string|null + { + return $this->longitude; + } + + public function setLongitude(?string $longitude): self + { + $this->longitude = $longitude; + return $this; + } +} diff --git a/Infobip/Model/EmailWebhookPrice.php b/Infobip/Model/EmailWebhookPrice.php new file mode 100644 index 0000000..0ff2870 --- /dev/null +++ b/Infobip/Model/EmailWebhookPrice.php @@ -0,0 +1,78 @@ + null, + 'pricePerMessage' => 'double' + ]; + + /** + */ + public function __construct( + protected ?string $currency = null, + protected ?float $pricePerMessage = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getCurrency(): string|null + { + return $this->currency; + } + + public function setCurrency(?string $currency): self + { + $this->currency = $currency; + return $this; + } + + public function getPricePerMessage(): float|null + { + return $this->pricePerMessage; + } + + public function setPricePerMessage(?float $pricePerMessage): self + { + $this->pricePerMessage = $pricePerMessage; + return $this; + } +} diff --git a/Infobip/Model/EmailWebhookRecipientInfo.php b/Infobip/Model/EmailWebhookRecipientInfo.php new file mode 100644 index 0000000..fd0a13c --- /dev/null +++ b/Infobip/Model/EmailWebhookRecipientInfo.php @@ -0,0 +1,91 @@ + null, + 'os' => null, + 'deviceName' => null + ]; + + /** + */ + public function __construct( + protected ?string $deviceType = null, + protected ?string $os = null, + protected ?string $deviceName = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getDeviceType(): string|null + { + return $this->deviceType; + } + + public function setDeviceType(?string $deviceType): self + { + $this->deviceType = $deviceType; + return $this; + } + + public function getOs(): string|null + { + return $this->os; + } + + public function setOs(?string $os): self + { + $this->os = $os; + return $this; + } + + public function getDeviceName(): string|null + { + return $this->deviceName; + } + + public function setDeviceName(?string $deviceName): self + { + $this->deviceName = $deviceName; + return $this; + } +} diff --git a/Infobip/Model/EmailWebhookTrackReport.php b/Infobip/Model/EmailWebhookTrackReport.php new file mode 100644 index 0000000..70629ae --- /dev/null +++ b/Infobip/Model/EmailWebhookTrackReport.php @@ -0,0 +1,173 @@ + null, + 'domain' => null, + 'recipient' => null, + 'url' => null, + 'sendDateTime' => null, + 'messageId' => null, + 'bulkId' => null, + 'recipientInfo' => null, + 'geoLocation' => null + ]; + + /** + */ + public function __construct( + protected ?string $notificationType = null, + protected ?string $domain = null, + protected ?string $recipient = null, + protected ?string $url = null, + protected ?float $sendDateTime = null, + protected ?string $messageId = null, + protected ?string $bulkId = null, + #[Assert\Valid] + + protected ?\Infobip\Model\EmailWebhookRecipientInfo $recipientInfo = null, + #[Assert\Valid] + + protected ?\Infobip\Model\EmailWebhookGeoLocation $geoLocation = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getNotificationType(): string|null + { + return $this->notificationType; + } + + public function setNotificationType(?string $notificationType): self + { + $this->notificationType = $notificationType; + return $this; + } + + public function getDomain(): string|null + { + return $this->domain; + } + + public function setDomain(?string $domain): self + { + $this->domain = $domain; + return $this; + } + + public function getRecipient(): string|null + { + return $this->recipient; + } + + public function setRecipient(?string $recipient): self + { + $this->recipient = $recipient; + return $this; + } + + public function getUrl(): string|null + { + return $this->url; + } + + public function setUrl(?string $url): self + { + $this->url = $url; + return $this; + } + + public function getSendDateTime(): float|null + { + return $this->sendDateTime; + } + + public function setSendDateTime(?float $sendDateTime): self + { + $this->sendDateTime = $sendDateTime; + return $this; + } + + public function getMessageId(): string|null + { + return $this->messageId; + } + + public function setMessageId(?string $messageId): self + { + $this->messageId = $messageId; + return $this; + } + + public function getBulkId(): string|null + { + return $this->bulkId; + } + + public function setBulkId(?string $bulkId): self + { + $this->bulkId = $bulkId; + return $this; + } + + public function getRecipientInfo(): \Infobip\Model\EmailWebhookRecipientInfo|null + { + return $this->recipientInfo; + } + + public function setRecipientInfo(?\Infobip\Model\EmailWebhookRecipientInfo $recipientInfo): self + { + $this->recipientInfo = $recipientInfo; + return $this; + } + + public function getGeoLocation(): \Infobip\Model\EmailWebhookGeoLocation|null + { + return $this->geoLocation; + } + + public function setGeoLocation(?\Infobip\Model\EmailWebhookGeoLocation $geoLocation): self + { + $this->geoLocation = $geoLocation; + return $this; + } +} diff --git a/Infobip/Model/EmailWebhookTrackResponse.php b/Infobip/Model/EmailWebhookTrackResponse.php new file mode 100644 index 0000000..d0b636b --- /dev/null +++ b/Infobip/Model/EmailWebhookTrackResponse.php @@ -0,0 +1,173 @@ + null, + 'domain' => null, + 'recipient' => null, + 'url' => null, + 'sendDateTime' => null, + 'messageId' => null, + 'bulkId' => null, + 'recipientInfo' => null, + 'geoLocation' => null + ]; + + /** + */ + public function __construct( + protected ?string $notificationType = null, + protected ?string $domain = null, + protected ?string $recipient = null, + protected ?string $url = null, + protected ?float $sendDateTime = null, + protected ?string $messageId = null, + protected ?string $bulkId = null, + #[Assert\Valid] + + protected ?\Infobip\Model\EmailWebhookRecipientInfo $recipientInfo = null, + #[Assert\Valid] + + protected ?\Infobip\Model\EmailWebhookGeoLocation $geoLocation = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getNotificationType(): string|null + { + return $this->notificationType; + } + + public function setNotificationType(?string $notificationType): self + { + $this->notificationType = $notificationType; + return $this; + } + + public function getDomain(): string|null + { + return $this->domain; + } + + public function setDomain(?string $domain): self + { + $this->domain = $domain; + return $this; + } + + public function getRecipient(): string|null + { + return $this->recipient; + } + + public function setRecipient(?string $recipient): self + { + $this->recipient = $recipient; + return $this; + } + + public function getUrl(): string|null + { + return $this->url; + } + + public function setUrl(?string $url): self + { + $this->url = $url; + return $this; + } + + public function getSendDateTime(): float|null + { + return $this->sendDateTime; + } + + public function setSendDateTime(?float $sendDateTime): self + { + $this->sendDateTime = $sendDateTime; + return $this; + } + + public function getMessageId(): string|null + { + return $this->messageId; + } + + public function setMessageId(?string $messageId): self + { + $this->messageId = $messageId; + return $this; + } + + public function getBulkId(): string|null + { + return $this->bulkId; + } + + public function setBulkId(?string $bulkId): self + { + $this->bulkId = $bulkId; + return $this; + } + + public function getRecipientInfo(): \Infobip\Model\EmailWebhookRecipientInfo|null + { + return $this->recipientInfo; + } + + public function setRecipientInfo(?\Infobip\Model\EmailWebhookRecipientInfo $recipientInfo): self + { + $this->recipientInfo = $recipientInfo; + return $this; + } + + public function getGeoLocation(): \Infobip\Model\EmailWebhookGeoLocation|null + { + return $this->geoLocation; + } + + public function setGeoLocation(?\Infobip\Model\EmailWebhookGeoLocation $geoLocation): self + { + $this->geoLocation = $geoLocation; + return $this; + } +} diff --git a/Infobip/Model/EnumInterface.php b/Infobip/Model/EnumInterface.php new file mode 100644 index 0000000..a965d7d --- /dev/null +++ b/Infobip/Model/EnumInterface.php @@ -0,0 +1,29 @@ + null + ]; + + /** + */ + public function __construct( + #[Assert\Valid] + + protected ?\Infobip\Model\SmsApiRequestErrorDetails $serviceException = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getServiceException(): \Infobip\Model\SmsApiRequestErrorDetails|null + { + return $this->serviceException; + } + + public function setServiceException(?\Infobip\Model\SmsApiRequestErrorDetails $serviceException): self + { + $this->serviceException = $serviceException; + return $this; + } +} diff --git a/Infobip/Model/MessageError.php b/Infobip/Model/MessageError.php index d145549..b32ef4a 100644 --- a/Infobip/Model/MessageError.php +++ b/Infobip/Model/MessageError.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class MessageError implements ModelInterface, ArrayAccess, \JsonSerializable +class MessageError implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'MessageError'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'description' => 'string', - 'permanent' => 'bool', - 'name' => 'string', - 'id' => 'int', - 'groupName' => 'string', - 'groupId' => 'int' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'MessageError'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'description' => null, 'permanent' => null, 'name' => null, @@ -79,388 +39,92 @@ class MessageError implements ModelInterface, ArrayAccess, \JsonSerializable ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'description' => 'description', - 'permanent' => 'permanent', - 'name' => 'name', - 'id' => 'id', - 'groupName' => 'groupName', - 'groupId' => 'groupId' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'description' => 'setDescription', - 'permanent' => 'setPermanent', - 'name' => 'setName', - 'id' => 'setId', - 'groupName' => 'setGroupName', - 'groupId' => 'setGroupId' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] */ - protected static $getters = [ - 'description' => 'getDescription', - 'permanent' => 'getPermanent', - 'name' => 'getName', - 'id' => 'getId', - 'groupName' => 'getGroupName', - 'groupId' => 'getGroupId' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; + public function __construct( + protected ?string $description = null, + protected ?bool $permanent = null, + protected ?string $name = null, + protected ?int $id = null, + protected ?string $groupName = null, + protected ?int $groupId = null, + ) { } - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['description'] = $data['description'] ?? null; - $this->container['permanent'] = $data['permanent'] ?? null; - $this->container['name'] = $data['name'] ?? null; - $this->container['id'] = $data['id'] ?? null; - $this->container['groupName'] = $data['groupName'] ?? null; - $this->container['groupId'] = $data['groupId'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets description - * - * @return string|null - */ - public function getDescription() + public function getDescription(): string|null { - return $this->container['description']; + return $this->description; } - /** - * Sets description - * - * @param string|null $description Human-readable description of the error. - * - * @return self - */ - public function setDescription($description) + public function setDescription(?string $description): self { - $this->container['description'] = $description; - + $this->description = $description; return $this; } - /** - * Gets permanent - * - * @return bool|null - */ - public function getPermanent() + public function getPermanent(): bool|null { - return $this->container['permanent']; + return $this->permanent; } - /** - * Sets permanent - * - * @param bool|null $permanent Indicates whether the error is permanent. - * - * @return self - */ - public function setPermanent($permanent) + public function setPermanent(?bool $permanent): self { - $this->container['permanent'] = $permanent; - + $this->permanent = $permanent; return $this; } - /** - * Gets name - * - * @return string|null - */ - public function getName() + public function getName(): string|null { - return $this->container['name']; + return $this->name; } - /** - * Sets name - * - * @param string|null $name Error name. - * - * @return self - */ - public function setName($name) + public function setName(?string $name): self { - $this->container['name'] = $name; - + $this->name = $name; return $this; } - /** - * Gets id - * - * @return int|null - */ - public function getId() + public function getId(): int|null { - return $this->container['id']; + return $this->id; } - /** - * Sets id - * - * @param int|null $id Error ID. - * - * @return self - */ - public function setId($id) + public function setId(?int $id): self { - $this->container['id'] = $id; - + $this->id = $id; return $this; } - /** - * Gets groupName - * - * @return string|null - */ - public function getGroupName() + public function getGroupName(): string|null { - return $this->container['groupName']; + return $this->groupName; } - /** - * Sets groupName - * - * @param string|null $groupName Error group name. - * - * @return self - */ - public function setGroupName($groupName) + public function setGroupName(?string $groupName): self { - $this->container['groupName'] = $groupName; - + $this->groupName = $groupName; return $this; } - /** - * Gets groupId - * - * @return int|null - */ - public function getGroupId() + public function getGroupId(): int|null { - return $this->container['groupId']; + return $this->groupId; } - /** - * Sets groupId - * - * @param int|null $groupId Error group ID. - * - * @return self - */ - public function setGroupId($groupId) + public function setGroupId(?int $groupId): self { - $this->container['groupId'] = $groupId; - + $this->groupId = $groupId; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/MessagePrice.php b/Infobip/Model/MessagePrice.php index 94a4c9a..d5f1570 100644 --- a/Infobip/Model/MessagePrice.php +++ b/Infobip/Model/MessagePrice.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class MessagePrice implements ModelInterface, ArrayAccess, \JsonSerializable +class MessagePrice implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'MessagePrice'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'currency' => 'string', - 'pricePerMessage' => 'double' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'MessagePrice'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'currency' => null, 'pricePerMessage' => 'double' ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array */ - public static function openAPITypes() - { - return self::$openAPITypes; + public function __construct( + protected ?string $currency = null, + protected ?float $pricePerMessage = null, + ) { } - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() + #[Ignore] + public function getModelName(): string { - return self::$openAPIFormats; + return self::OPENAPI_MODEL_NAME; } - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'currency' => 'currency', - 'pricePerMessage' => 'pricePerMessage' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'currency' => 'setCurrency', - 'pricePerMessage' => 'setPricePerMessage' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'currency' => 'getCurrency', - 'pricePerMessage' => 'getPricePerMessage' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$attributeMap; + return self::DISCRIMINATOR; } - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() + public function getCurrency(): string|null { - return self::$setters; + return $this->currency; } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + public function setCurrency(?string $currency): self { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['currency'] = $data['currency'] ?? null; - $this->container['pricePerMessage'] = $data['pricePerMessage'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $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() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets currency - * - * @return string|null - */ - public function getCurrency() - { - return $this->container['currency']; - } - - /** - * Sets currency - * - * @param string|null $currency The currency in which the price is displayed. - * - * @return self - */ - public function setCurrency($currency) - { - $this->container['currency'] = $currency; - + $this->currency = $currency; return $this; } - /** - * Gets pricePerMessage - * - * @return double|null - */ - public function getPricePerMessage() + public function getPricePerMessage(): float|null { - return $this->container['pricePerMessage']; + return $this->pricePerMessage; } - /** - * Sets pricePerMessage - * - * @param double|null $pricePerMessage The price per individual message. - * - * @return self - */ - public function setPricePerMessage($pricePerMessage) + public function setPricePerMessage(?float $pricePerMessage): self { - $this->container['pricePerMessage'] = $pricePerMessage; - + $this->pricePerMessage = $pricePerMessage; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/MessageStatus.php b/Infobip/Model/MessageStatus.php index 1e3f71c..d031590 100644 --- a/Infobip/Model/MessageStatus.php +++ b/Infobip/Model/MessageStatus.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class MessageStatus implements ModelInterface, ArrayAccess, \JsonSerializable +class MessageStatus implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'MessageStatus'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'groupName' => 'string', - 'id' => 'int', - 'groupId' => 'int', - 'name' => 'string', - 'action' => 'string', - 'description' => 'string' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'MessageStatus'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'groupName' => null, 'id' => 'int32', 'groupId' => 'int32', @@ -79,388 +39,92 @@ class MessageStatus implements ModelInterface, ArrayAccess, \JsonSerializable ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'groupName' => 'groupName', - 'id' => 'id', - 'groupId' => 'groupId', - 'name' => 'name', - 'action' => 'action', - 'description' => 'description' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'groupName' => 'setGroupName', - 'id' => 'setId', - 'groupId' => 'setGroupId', - 'name' => 'setName', - 'action' => 'setAction', - 'description' => 'setDescription' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] */ - protected static $getters = [ - 'groupName' => 'getGroupName', - 'id' => 'getId', - 'groupId' => 'getGroupId', - 'name' => 'getName', - 'action' => 'getAction', - 'description' => 'getDescription' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; + public function __construct( + protected ?string $groupName = null, + protected ?int $id = null, + protected ?int $groupId = null, + protected ?string $name = null, + protected ?string $action = null, + protected ?string $description = null, + ) { } - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['groupName'] = $data['groupName'] ?? null; - $this->container['id'] = $data['id'] ?? null; - $this->container['groupId'] = $data['groupId'] ?? null; - $this->container['name'] = $data['name'] ?? null; - $this->container['action'] = $data['action'] ?? null; - $this->container['description'] = $data['description'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets groupName - * - * @return string|null - */ - public function getGroupName() + public function getGroupName(): string|null { - return $this->container['groupName']; + return $this->groupName; } - /** - * Sets groupName - * - * @param string|null $groupName Group name for the status. - * - * @return self - */ - public function setGroupName($groupName) + public function setGroupName(?string $groupName): self { - $this->container['groupName'] = $groupName; - + $this->groupName = $groupName; return $this; } - /** - * Gets id - * - * @return int|null - */ - public function getId() + public function getId(): int|null { - return $this->container['id']; + return $this->id; } - /** - * Sets id - * - * @param int|null $id Status ID. - * - * @return self - */ - public function setId($id) + public function setId(?int $id): self { - $this->container['id'] = $id; - + $this->id = $id; return $this; } - /** - * Gets groupId - * - * @return int|null - */ - public function getGroupId() + public function getGroupId(): int|null { - return $this->container['groupId']; + return $this->groupId; } - /** - * Sets groupId - * - * @param int|null $groupId Status group ID. - * - * @return self - */ - public function setGroupId($groupId) + public function setGroupId(?int $groupId): self { - $this->container['groupId'] = $groupId; - + $this->groupId = $groupId; return $this; } - /** - * Gets name - * - * @return string|null - */ - public function getName() + public function getName(): string|null { - return $this->container['name']; + return $this->name; } - /** - * Sets name - * - * @param string|null $name Status name. - * - * @return self - */ - public function setName($name) + public function setName(?string $name): self { - $this->container['name'] = $name; - + $this->name = $name; return $this; } - /** - * Gets action - * - * @return string|null - */ - public function getAction() + public function getAction(): string|null { - return $this->container['action']; + return $this->action; } - /** - * Sets action - * - * @param string|null $action Action that should be taken to fix the error. - * - * @return self - */ - public function setAction($action) + public function setAction(?string $action): self { - $this->container['action'] = $action; - + $this->action = $action; return $this; } - /** - * Gets description - * - * @return string|null - */ - public function getDescription() + public function getDescription(): string|null { - return $this->container['description']; + return $this->description; } - /** - * Sets description - * - * @param string|null $description Human-readable description of the status. - * - * @return self - */ - public function setDescription($description) + public function setDescription(?string $description): self { - $this->container['description'] = $description; - + $this->description = $description; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/MmsAdvancedMessage.php b/Infobip/Model/MmsAdvancedMessage.php new file mode 100644 index 0000000..bdd0bf1 --- /dev/null +++ b/Infobip/Model/MmsAdvancedMessage.php @@ -0,0 +1,240 @@ + null, + 'deliveryTimeWindow' => null, + 'destinations' => null, + 'from' => null, + 'intermediateReport' => null, + 'notifyContentType' => null, + 'notifyUrl' => null, + 'messageSegments' => null, + 'validityPeriod' => 'int64', + 'title' => null, + 'entityId' => null, + 'applicationId' => null + ]; + + /** + * @param \Infobip\Model\MmsDestination[] $destinations + * @param \Infobip\Model\MmsAdvancedMessageSegment[] $messageSegments + */ + public function __construct( + #[Assert\NotBlank] + + protected array $destinations, + #[Assert\NotBlank] + + protected array $messageSegments, + #[Assert\Length(max: 4000)] + #[Assert\Length(min: 0)] + + protected ?string $callbackData = null, + #[Assert\Valid] + + protected ?\Infobip\Model\MmsDeliveryTimeWindow $deliveryTimeWindow = null, + protected ?string $from = null, + protected ?bool $intermediateReport = null, + protected ?string $notifyContentType = null, + protected ?string $notifyUrl = null, + protected ?int $validityPeriod = null, + #[Assert\Length(max: 66)] + #[Assert\Length(min: 0)] + + protected ?string $title = null, + #[Assert\Length(max: 50)] + #[Assert\Length(min: 0)] + + protected ?string $entityId = null, + #[Assert\Length(max: 50)] + #[Assert\Length(min: 0)] + + protected ?string $applicationId = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getCallbackData(): string|null + { + return $this->callbackData; + } + + public function setCallbackData(?string $callbackData): self + { + $this->callbackData = $callbackData; + return $this; + } + + public function getDeliveryTimeWindow(): \Infobip\Model\MmsDeliveryTimeWindow|null + { + return $this->deliveryTimeWindow; + } + + public function setDeliveryTimeWindow(?\Infobip\Model\MmsDeliveryTimeWindow $deliveryTimeWindow): self + { + $this->deliveryTimeWindow = $deliveryTimeWindow; + return $this; + } + + /** + * @return \Infobip\Model\MmsDestination[] + */ + public function getDestinations(): array + { + return $this->destinations; + } + + /** + * @param \Infobip\Model\MmsDestination[] $destinations An array of destination objects for where messages are being sent. A valid destination is required. + */ + public function setDestinations(array $destinations): self + { + $this->destinations = $destinations; + return $this; + } + + public function getFrom(): string|null + { + return $this->from; + } + + public function setFrom(?string $from): self + { + $this->from = $from; + return $this; + } + + public function getIntermediateReport(): bool|null + { + return $this->intermediateReport; + } + + public function setIntermediateReport(?bool $intermediateReport): self + { + $this->intermediateReport = $intermediateReport; + return $this; + } + + public function getNotifyContentType(): string|null + { + return $this->notifyContentType; + } + + public function setNotifyContentType(?string $notifyContentType): self + { + $this->notifyContentType = $notifyContentType; + return $this; + } + + public function getNotifyUrl(): string|null + { + return $this->notifyUrl; + } + + public function setNotifyUrl(?string $notifyUrl): self + { + $this->notifyUrl = $notifyUrl; + return $this; + } + + /** + * @return \Infobip\Model\MmsAdvancedMessageSegment[] + */ + public function getMessageSegments(): array + { + return $this->messageSegments; + } + + /** + * @param \Infobip\Model\MmsAdvancedMessageSegment[] $messageSegments Content of the message being sent. + */ + public function setMessageSegments(array $messageSegments): self + { + $this->messageSegments = $messageSegments; + return $this; + } + + public function getValidityPeriod(): int|null + { + return $this->validityPeriod; + } + + public function setValidityPeriod(?int $validityPeriod): self + { + $this->validityPeriod = $validityPeriod; + return $this; + } + + public function getTitle(): string|null + { + return $this->title; + } + + public function setTitle(?string $title): self + { + $this->title = $title; + return $this; + } + + public function getEntityId(): string|null + { + return $this->entityId; + } + + public function setEntityId(?string $entityId): self + { + $this->entityId = $entityId; + return $this; + } + + public function getApplicationId(): string|null + { + return $this->applicationId; + } + + public function setApplicationId(?string $applicationId): self + { + $this->applicationId = $applicationId; + return $this; + } +} diff --git a/Infobip/Model/MmsAdvancedMessageSegment.php b/Infobip/Model/MmsAdvancedMessageSegment.php new file mode 100644 index 0000000..f820aa2 --- /dev/null +++ b/Infobip/Model/MmsAdvancedMessageSegment.php @@ -0,0 +1,143 @@ + null, + 'text' => null, + 'contentType' => null, + 'contentUrl' => null, + 'contentBase64' => null, + 'smil' => null, + 'uploadedContentId' => null + ]; + + /** + */ + public function __construct( + protected ?string $contentId = null, + protected ?string $text = null, + protected ?string $contentType = null, + protected ?string $contentUrl = null, + protected ?string $contentBase64 = null, + protected ?string $smil = null, + protected ?string $uploadedContentId = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getContentId(): string|null + { + return $this->contentId; + } + + public function setContentId(?string $contentId): self + { + $this->contentId = $contentId; + return $this; + } + + public function getText(): string|null + { + return $this->text; + } + + public function setText(?string $text): self + { + $this->text = $text; + return $this; + } + + public function getContentType(): string|null + { + return $this->contentType; + } + + public function setContentType(?string $contentType): self + { + $this->contentType = $contentType; + return $this; + } + + public function getContentUrl(): string|null + { + return $this->contentUrl; + } + + public function setContentUrl(?string $contentUrl): self + { + $this->contentUrl = $contentUrl; + return $this; + } + + public function getContentBase64(): string|null + { + return $this->contentBase64; + } + + public function setContentBase64(?string $contentBase64): self + { + $this->contentBase64 = $contentBase64; + return $this; + } + + public function getSmil(): string|null + { + return $this->smil; + } + + public function setSmil(?string $smil): self + { + $this->smil = $smil; + return $this; + } + + public function getUploadedContentId(): string|null + { + return $this->uploadedContentId; + } + + public function setUploadedContentId(?string $uploadedContentId): self + { + $this->uploadedContentId = $uploadedContentId; + return $this; + } +} diff --git a/Infobip/Model/MmsAdvancedRequest.php b/Infobip/Model/MmsAdvancedRequest.php new file mode 100644 index 0000000..bc28208 --- /dev/null +++ b/Infobip/Model/MmsAdvancedRequest.php @@ -0,0 +1,102 @@ + null, + 'messages' => null, + 'sendingSpeedLimit' => null + ]; + + /** + * @param \Infobip\Model\MmsAdvancedMessage[] $messages + */ + public function __construct( + #[Assert\NotBlank] + + protected array $messages, + protected ?string $bulkId = null, + #[Assert\Valid] + + protected ?\Infobip\Model\MmsSendingSpeedLimit $sendingSpeedLimit = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getBulkId(): string|null + { + return $this->bulkId; + } + + public function setBulkId(?string $bulkId): self + { + $this->bulkId = $bulkId; + return $this; + } + + /** + * @return \Infobip\Model\MmsAdvancedMessage[] + */ + public function getMessages(): array + { + return $this->messages; + } + + /** + * @param \Infobip\Model\MmsAdvancedMessage[] $messages An array of message objects of a single message or multiple messages sent under one bulk ID. + */ + public function setMessages(array $messages): self + { + $this->messages = $messages; + return $this; + } + + public function getSendingSpeedLimit(): \Infobip\Model\MmsSendingSpeedLimit|null + { + return $this->sendingSpeedLimit; + } + + public function setSendingSpeedLimit(?\Infobip\Model\MmsSendingSpeedLimit $sendingSpeedLimit): self + { + $this->sendingSpeedLimit = $sendingSpeedLimit; + return $this; + } +} diff --git a/Infobip/Model/MmsDeliveryDay.php b/Infobip/Model/MmsDeliveryDay.php new file mode 100644 index 0000000..3e69deb --- /dev/null +++ b/Infobip/Model/MmsDeliveryDay.php @@ -0,0 +1,99 @@ +value = $value; + } + + public static function MONDAY(): MmsDeliveryDay + { + return new self('MONDAY'); + } + + public static function TUESDAY(): MmsDeliveryDay + { + return new self('TUESDAY'); + } + + public static function WEDNESDAY(): MmsDeliveryDay + { + return new self('WEDNESDAY'); + } + + public static function THURSDAY(): MmsDeliveryDay + { + return new self('THURSDAY'); + } + + public static function FRIDAY(): MmsDeliveryDay + { + return new self('FRIDAY'); + } + + public static function SATURDAY(): MmsDeliveryDay + { + return new self('SATURDAY'); + } + + public static function SUNDAY(): MmsDeliveryDay + { + return new self('SUNDAY'); + } + + public function __toString(): string + { + return $this->value; + } +} diff --git a/Infobip/Model/MmsDeliveryTime.php b/Infobip/Model/MmsDeliveryTime.php new file mode 100644 index 0000000..a29e6fd --- /dev/null +++ b/Infobip/Model/MmsDeliveryTime.php @@ -0,0 +1,84 @@ + 'int32', + 'minute' => 'int32' + ]; + + /** + */ + public function __construct( + #[Assert\LessThan(23)] + #[Assert\GreaterThan(0)] + + protected ?int $hour = null, + #[Assert\LessThan(59)] + #[Assert\GreaterThan(0)] + + protected ?int $minute = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getHour(): int|null + { + return $this->hour; + } + + public function setHour(?int $hour): self + { + $this->hour = $hour; + return $this; + } + + public function getMinute(): int|null + { + return $this->minute; + } + + public function setMinute(?int $minute): self + { + $this->minute = $minute; + return $this; + } +} diff --git a/Infobip/Model/MmsDeliveryTimeWindow.php b/Infobip/Model/MmsDeliveryTimeWindow.php new file mode 100644 index 0000000..6a2f6c3 --- /dev/null +++ b/Infobip/Model/MmsDeliveryTimeWindow.php @@ -0,0 +1,104 @@ + null, + 'from' => null, + 'to' => null + ]; + + /** + * @param \Infobip\Model\MmsDeliveryDay[] $days + */ + public function __construct( + #[Assert\NotBlank] + + protected array $days, + #[Assert\Valid] + + protected ?\Infobip\Model\MmsDeliveryTime $from = null, + #[Assert\Valid] + + protected ?\Infobip\Model\MmsDeliveryTime $to = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + /** + * @return \Infobip\Model\MmsDeliveryDay[] + */ + public function getDays(): array + { + return $this->days; + } + + /** + * @param \Infobip\Model\MmsDeliveryDay[] $days Days of the week which are included in the delivery time window. At least one day must be provided. Separate multiple days with a comma. + */ + public function setDays(array $days): self + { + $this->days = $days; + return $this; + } + + public function getFrom(): \Infobip\Model\MmsDeliveryTime|null + { + return $this->from; + } + + public function setFrom(?\Infobip\Model\MmsDeliveryTime $from): self + { + $this->from = $from; + return $this; + } + + public function getTo(): \Infobip\Model\MmsDeliveryTime|null + { + return $this->to; + } + + public function setTo(?\Infobip\Model\MmsDeliveryTime $to): self + { + $this->to = $to; + return $this; + } +} diff --git a/Infobip/Model/MmsDestination.php b/Infobip/Model/MmsDestination.php new file mode 100644 index 0000000..6ef7a82 --- /dev/null +++ b/Infobip/Model/MmsDestination.php @@ -0,0 +1,82 @@ + null, + 'to' => null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 50)] + #[Assert\Length(min: 0)] + + protected string $to, + protected ?string $messageId = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getMessageId(): string|null + { + return $this->messageId; + } + + public function setMessageId(?string $messageId): self + { + $this->messageId = $messageId; + return $this; + } + + public function getTo(): string + { + return $this->to; + } + + public function setTo(string $to): self + { + $this->to = $to; + return $this; + } +} diff --git a/Infobip/Model/MmsError.php b/Infobip/Model/MmsError.php new file mode 100644 index 0000000..86d03f8 --- /dev/null +++ b/Infobip/Model/MmsError.php @@ -0,0 +1,117 @@ + 'int32', + 'groupName' => null, + 'id' => 'int32', + 'name' => null, + 'description' => null + ]; + + /** + */ + public function __construct( + protected ?int $groupId = null, + protected ?string $groupName = null, + protected ?int $id = null, + protected ?string $name = null, + protected ?string $description = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getGroupId(): int|null + { + return $this->groupId; + } + + public function setGroupId(?int $groupId): self + { + $this->groupId = $groupId; + return $this; + } + + public function getGroupName(): string|null + { + return $this->groupName; + } + + public function setGroupName(?string $groupName): self + { + $this->groupName = $groupName; + return $this; + } + + public function getId(): int|null + { + return $this->id; + } + + public function setId(?int $id): self + { + $this->id = $id; + return $this; + } + + public function getName(): string|null + { + return $this->name; + } + + public function setName(?string $name): self + { + $this->name = $name; + return $this; + } + + public function getDescription(): string|null + { + return $this->description; + } + + public function setDescription(?string $description): self + { + $this->description = $description; + return $this; + } +} diff --git a/Infobip/Model/MmsInboundReport.php b/Infobip/Model/MmsInboundReport.php new file mode 100644 index 0000000..1b76e47 --- /dev/null +++ b/Infobip/Model/MmsInboundReport.php @@ -0,0 +1,158 @@ + null, + 'to' => null, + 'from' => null, + 'message' => null, + 'receivedAt' => null, + 'mmsCount' => 'int32', + 'callbackData' => null, + 'price' => null + ]; + + /** + */ + public function __construct( + protected ?string $messageId = null, + protected ?string $to = null, + protected ?string $from = null, + protected ?string $message = null, + protected ?string $receivedAt = null, + protected ?int $mmsCount = null, + protected ?string $callbackData = null, + #[Assert\Valid] + + protected ?\Infobip\Model\MmsPrice $price = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getMessageId(): string|null + { + return $this->messageId; + } + + public function setMessageId(?string $messageId): self + { + $this->messageId = $messageId; + return $this; + } + + public function getTo(): string|null + { + return $this->to; + } + + public function setTo(?string $to): self + { + $this->to = $to; + return $this; + } + + public function getFrom(): string|null + { + return $this->from; + } + + public function setFrom(?string $from): self + { + $this->from = $from; + return $this; + } + + public function getMessage(): string|null + { + return $this->message; + } + + public function setMessage(?string $message): self + { + $this->message = $message; + return $this; + } + + public function getReceivedAt(): string|null + { + return $this->receivedAt; + } + + public function setReceivedAt(?string $receivedAt): self + { + $this->receivedAt = $receivedAt; + return $this; + } + + public function getMmsCount(): int|null + { + return $this->mmsCount; + } + + public function setMmsCount(?int $mmsCount): self + { + $this->mmsCount = $mmsCount; + return $this; + } + + public function getCallbackData(): string|null + { + return $this->callbackData; + } + + public function setCallbackData(?string $callbackData): self + { + $this->callbackData = $callbackData; + return $this; + } + + public function getPrice(): \Infobip\Model\MmsPrice|null + { + return $this->price; + } + + public function setPrice(?\Infobip\Model\MmsPrice $price): self + { + $this->price = $price; + return $this; + } +} diff --git a/Infobip/Model/MmsInboundReportResponse.php b/Infobip/Model/MmsInboundReportResponse.php new file mode 100644 index 0000000..1821d68 --- /dev/null +++ b/Infobip/Model/MmsInboundReportResponse.php @@ -0,0 +1,72 @@ + null + ]; + + /** + * @param \Infobip\Model\MmsInboundReport[] $results + */ + public function __construct( + protected ?array $results = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + /** + * @return \Infobip\Model\MmsInboundReport[]|null + */ + public function getResults(): ?array + { + return $this->results; + } + + /** + * @param \Infobip\Model\MmsInboundReport[]|null $results Results. + */ + public function setResults(?array $results): self + { + $this->results = $results; + return $this; + } +} diff --git a/Infobip/Model/MmsMessageResult.php b/Infobip/Model/MmsMessageResult.php new file mode 100644 index 0000000..50044b3 --- /dev/null +++ b/Infobip/Model/MmsMessageResult.php @@ -0,0 +1,94 @@ + null, + 'status' => null, + 'messageId' => null + ]; + + /** + */ + public function __construct( + #[Assert\Valid] + #[Assert\NotBlank] + + protected \Infobip\Model\MmsStatus $status, + protected ?string $to = null, + protected ?string $messageId = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getTo(): string|null + { + return $this->to; + } + + public function setTo(?string $to): self + { + $this->to = $to; + return $this; + } + + public function getStatus(): \Infobip\Model\MmsStatus + { + return $this->status; + } + + public function setStatus(\Infobip\Model\MmsStatus $status): self + { + $this->status = $status; + return $this; + } + + public function getMessageId(): string|null + { + return $this->messageId; + } + + public function setMessageId(?string $messageId): self + { + $this->messageId = $messageId; + return $this; + } +} diff --git a/Infobip/Model/MmsPrice.php b/Infobip/Model/MmsPrice.php new file mode 100644 index 0000000..f177d6e --- /dev/null +++ b/Infobip/Model/MmsPrice.php @@ -0,0 +1,78 @@ + null, + 'currency' => null + ]; + + /** + */ + public function __construct( + protected ?float $pricePerMessage = null, + protected ?string $currency = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getPricePerMessage(): float|null + { + return $this->pricePerMessage; + } + + public function setPricePerMessage(?float $pricePerMessage): self + { + $this->pricePerMessage = $pricePerMessage; + return $this; + } + + public function getCurrency(): string|null + { + return $this->currency; + } + + public function setCurrency(?string $currency): self + { + $this->currency = $currency; + return $this; + } +} diff --git a/Infobip/Model/MmsReport.php b/Infobip/Model/MmsReport.php new file mode 100644 index 0000000..3e80284 --- /dev/null +++ b/Infobip/Model/MmsReport.php @@ -0,0 +1,240 @@ + null, + 'messageId' => null, + 'to' => null, + 'from' => null, + 'sentAt' => null, + 'doneAt' => null, + 'mmsCount' => 'int32', + 'mccMnc' => null, + 'callbackData' => null, + 'price' => null, + 'status' => null, + 'error' => null, + 'entityId' => null, + 'applicationId' => null + ]; + + /** + */ + public function __construct( + protected ?string $bulkId = null, + protected ?string $messageId = null, + protected ?string $to = null, + protected ?string $from = null, + protected ?string $sentAt = null, + protected ?string $doneAt = null, + protected ?int $mmsCount = null, + protected ?string $mccMnc = null, + protected ?string $callbackData = null, + #[Assert\Valid] + + protected ?\Infobip\Model\MmsPrice $price = null, + #[Assert\Valid] + + protected ?\Infobip\Model\MmsStatus $status = null, + #[Assert\Valid] + + protected ?\Infobip\Model\MmsError $error = null, + protected ?string $entityId = null, + protected ?string $applicationId = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getBulkId(): string|null + { + return $this->bulkId; + } + + public function setBulkId(?string $bulkId): self + { + $this->bulkId = $bulkId; + return $this; + } + + public function getMessageId(): string|null + { + return $this->messageId; + } + + public function setMessageId(?string $messageId): self + { + $this->messageId = $messageId; + return $this; + } + + public function getTo(): string|null + { + return $this->to; + } + + public function setTo(?string $to): self + { + $this->to = $to; + return $this; + } + + public function getFrom(): string|null + { + return $this->from; + } + + public function setFrom(?string $from): self + { + $this->from = $from; + return $this; + } + + public function getSentAt(): string|null + { + return $this->sentAt; + } + + public function setSentAt(?string $sentAt): self + { + $this->sentAt = $sentAt; + return $this; + } + + public function getDoneAt(): string|null + { + return $this->doneAt; + } + + public function setDoneAt(?string $doneAt): self + { + $this->doneAt = $doneAt; + return $this; + } + + public function getMmsCount(): int|null + { + return $this->mmsCount; + } + + public function setMmsCount(?int $mmsCount): self + { + $this->mmsCount = $mmsCount; + return $this; + } + + public function getMccMnc(): string|null + { + return $this->mccMnc; + } + + public function setMccMnc(?string $mccMnc): self + { + $this->mccMnc = $mccMnc; + return $this; + } + + public function getCallbackData(): string|null + { + return $this->callbackData; + } + + public function setCallbackData(?string $callbackData): self + { + $this->callbackData = $callbackData; + return $this; + } + + public function getPrice(): \Infobip\Model\MmsPrice|null + { + return $this->price; + } + + public function setPrice(?\Infobip\Model\MmsPrice $price): self + { + $this->price = $price; + return $this; + } + + public function getStatus(): \Infobip\Model\MmsStatus|null + { + return $this->status; + } + + public function setStatus(?\Infobip\Model\MmsStatus $status): self + { + $this->status = $status; + return $this; + } + + public function getError(): \Infobip\Model\MmsError|null + { + return $this->error; + } + + public function setError(?\Infobip\Model\MmsError $error): self + { + $this->error = $error; + return $this; + } + + public function getEntityId(): string|null + { + return $this->entityId; + } + + public function setEntityId(?string $entityId): self + { + $this->entityId = $entityId; + return $this; + } + + public function getApplicationId(): string|null + { + return $this->applicationId; + } + + public function setApplicationId(?string $applicationId): self + { + $this->applicationId = $applicationId; + return $this; + } +} diff --git a/Infobip/Model/MmsReportResponse.php b/Infobip/Model/MmsReportResponse.php new file mode 100644 index 0000000..df0f9d2 --- /dev/null +++ b/Infobip/Model/MmsReportResponse.php @@ -0,0 +1,72 @@ + null + ]; + + /** + * @param \Infobip\Model\MmsReport[] $results + */ + public function __construct( + protected ?array $results = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + /** + * @return \Infobip\Model\MmsReport[]|null + */ + public function getResults(): ?array + { + return $this->results; + } + + /** + * @param \Infobip\Model\MmsReport[]|null $results results + */ + public function setResults(?array $results): self + { + $this->results = $results; + return $this; + } +} diff --git a/Infobip/Model/MmsSendResult.php b/Infobip/Model/MmsSendResult.php new file mode 100644 index 0000000..6dca91c --- /dev/null +++ b/Infobip/Model/MmsSendResult.php @@ -0,0 +1,100 @@ + null, + 'messages' => null, + 'errorMessage' => null + ]; + + /** + * @param \Infobip\Model\MmsMessageResult[] $messages + */ + public function __construct( + #[Assert\NotBlank] + + protected array $messages, + protected ?string $bulkId = null, + protected ?string $errorMessage = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getBulkId(): string|null + { + return $this->bulkId; + } + + public function setBulkId(?string $bulkId): self + { + $this->bulkId = $bulkId; + return $this; + } + + /** + * @return \Infobip\Model\MmsMessageResult[] + */ + public function getMessages(): array + { + return $this->messages; + } + + /** + * @param \Infobip\Model\MmsMessageResult[] $messages Array of sent message objects, one object per every message. + */ + public function setMessages(array $messages): self + { + $this->messages = $messages; + return $this; + } + + public function getErrorMessage(): string|null + { + return $this->errorMessage; + } + + public function setErrorMessage(?string $errorMessage): self + { + $this->errorMessage = $errorMessage; + return $this; + } +} diff --git a/Infobip/Model/MmsSendingSpeedLimit.php b/Infobip/Model/MmsSendingSpeedLimit.php new file mode 100644 index 0000000..b6f159e --- /dev/null +++ b/Infobip/Model/MmsSendingSpeedLimit.php @@ -0,0 +1,83 @@ + 'int32', + 'timeUnit' => null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + + protected int $amount, + #[Assert\NotBlank] + #[Assert\Choice(['MINUTE',])] + + protected string $timeUnit, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getAmount(): int + { + return $this->amount; + } + + public function setAmount(int $amount): self + { + $this->amount = $amount; + return $this; + } + + public function getTimeUnit(): mixed + { + return $this->timeUnit; + } + + public function setTimeUnit($timeUnit): self + { + $this->timeUnit = $timeUnit; + return $this; + } +} diff --git a/Infobip/Model/MmsSpeedLimitTimeUnit.php b/Infobip/Model/MmsSpeedLimitTimeUnit.php new file mode 100644 index 0000000..28cc9df --- /dev/null +++ b/Infobip/Model/MmsSpeedLimitTimeUnit.php @@ -0,0 +1,57 @@ +value = $value; + } + + public static function MINUTE(): MmsSpeedLimitTimeUnit + { + return new self('MINUTE'); + } + + public function __toString(): string + { + return $this->value; + } +} diff --git a/Infobip/Model/MmsStatus.php b/Infobip/Model/MmsStatus.php new file mode 100644 index 0000000..e22dc92 --- /dev/null +++ b/Infobip/Model/MmsStatus.php @@ -0,0 +1,127 @@ + 'int32', + 'groupName' => null, + 'id' => 'int32', + 'name' => null, + 'description' => null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + + protected int $groupId, + #[Assert\NotBlank] + + protected string $groupName, + #[Assert\NotBlank] + + protected int $id, + #[Assert\NotBlank] + + protected string $name, + #[Assert\NotBlank] + + protected string $description, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getGroupId(): int + { + return $this->groupId; + } + + public function setGroupId(int $groupId): self + { + $this->groupId = $groupId; + return $this; + } + + public function getGroupName(): string + { + return $this->groupName; + } + + public function setGroupName(string $groupName): self + { + $this->groupName = $groupName; + return $this; + } + + public function getId(): int + { + return $this->id; + } + + public function setId(int $id): self + { + $this->id = $id; + return $this; + } + + public function getName(): string + { + return $this->name; + } + + public function setName(string $name): self + { + $this->name = $name; + return $this; + } + + public function getDescription(): string + { + return $this->description; + } + + public function setDescription(string $description): self + { + $this->description = $description; + return $this; + } +} diff --git a/Infobip/Model/MmsUploadBinaryResult.php b/Infobip/Model/MmsUploadBinaryResult.php new file mode 100644 index 0000000..87580a1 --- /dev/null +++ b/Infobip/Model/MmsUploadBinaryResult.php @@ -0,0 +1,65 @@ + null + ]; + + /** + */ + public function __construct( + protected ?string $uploadedContentId = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getUploadedContentId(): string|null + { + return $this->uploadedContentId; + } + + public function setUploadedContentId(?string $uploadedContentId): self + { + $this->uploadedContentId = $uploadedContentId; + return $this; + } +} diff --git a/Infobip/Model/MmsWebhookInboundMessageSegment.php b/Infobip/Model/MmsWebhookInboundMessageSegment.php new file mode 100644 index 0000000..1b7c728 --- /dev/null +++ b/Infobip/Model/MmsWebhookInboundMessageSegment.php @@ -0,0 +1,91 @@ + null, + 'value' => null, + 'url' => null + ]; + + /** + */ + public function __construct( + protected ?string $contentType = null, + protected ?string $value = null, + protected ?string $url = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getContentType(): string|null + { + return $this->contentType; + } + + public function setContentType(?string $contentType): self + { + $this->contentType = $contentType; + return $this; + } + + public function getValue(): string|null + { + return $this->value; + } + + public function setValue(?string $value): self + { + $this->value = $value; + return $this; + } + + public function getUrl(): string|null + { + return $this->url; + } + + public function setUrl(?string $url): self + { + $this->url = $url; + return $this; + } +} diff --git a/Infobip/Model/MmsWebhookInboundMessageSegmentLink.php b/Infobip/Model/MmsWebhookInboundMessageSegmentLink.php new file mode 100644 index 0000000..6857224 --- /dev/null +++ b/Infobip/Model/MmsWebhookInboundMessageSegmentLink.php @@ -0,0 +1,78 @@ + null, + 'url' => null + ]; + + /** + */ + public function __construct( + protected ?string $contentType = null, + protected ?string $url = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getContentType(): string|null + { + return $this->contentType; + } + + public function setContentType(?string $contentType): self + { + $this->contentType = $contentType; + return $this; + } + + public function getUrl(): string|null + { + return $this->url; + } + + public function setUrl(?string $url): self + { + $this->url = $url; + return $this; + } +} diff --git a/Infobip/Model/MmsWebhookInboundMessageSegmentText.php b/Infobip/Model/MmsWebhookInboundMessageSegmentText.php new file mode 100644 index 0000000..8403ab2 --- /dev/null +++ b/Infobip/Model/MmsWebhookInboundMessageSegmentText.php @@ -0,0 +1,78 @@ + null, + 'value' => null + ]; + + /** + */ + public function __construct( + protected ?string $contentType = null, + protected ?string $value = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getContentType(): string|null + { + return $this->contentType; + } + + public function setContentType(?string $contentType): self + { + $this->contentType = $contentType; + return $this; + } + + public function getValue(): string|null + { + return $this->value; + } + + public function setValue(?string $value): self + { + $this->value = $value; + return $this; + } +} diff --git a/Infobip/Model/MmsWebhookInboundReport.php b/Infobip/Model/MmsWebhookInboundReport.php new file mode 100644 index 0000000..4b003ec --- /dev/null +++ b/Infobip/Model/MmsWebhookInboundReport.php @@ -0,0 +1,206 @@ + null, + 'applicationId' => null, + 'from' => null, + 'to' => null, + 'receivedAt' => 'date-time', + 'messageId' => null, + 'pairedMessageId' => null, + 'callbackData' => null, + 'userAgent' => null, + 'message' => null, + 'price' => null + ]; + + /** + * @param \Infobip\Model\MmsWebhookInboundMessageSegment[] $message + */ + public function __construct( + protected ?string $entityId = null, + protected ?string $applicationId = null, + protected ?string $from = null, + protected ?string $to = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $receivedAt = null, + protected ?string $messageId = null, + protected ?string $pairedMessageId = null, + protected ?string $callbackData = null, + protected ?string $userAgent = null, + protected ?array $message = null, + #[Assert\Valid] + + protected ?\Infobip\Model\MessagePrice $price = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getEntityId(): string|null + { + return $this->entityId; + } + + public function setEntityId(?string $entityId): self + { + $this->entityId = $entityId; + return $this; + } + + public function getApplicationId(): string|null + { + return $this->applicationId; + } + + public function setApplicationId(?string $applicationId): self + { + $this->applicationId = $applicationId; + return $this; + } + + public function getFrom(): string|null + { + return $this->from; + } + + public function setFrom(?string $from): self + { + $this->from = $from; + return $this; + } + + public function getTo(): string|null + { + return $this->to; + } + + public function setTo(?string $to): self + { + $this->to = $to; + return $this; + } + + public function getReceivedAt(): \DateTime|null + { + return $this->receivedAt; + } + + public function setReceivedAt(?\DateTime $receivedAt): self + { + $this->receivedAt = $receivedAt; + return $this; + } + + public function getMessageId(): string|null + { + return $this->messageId; + } + + public function setMessageId(?string $messageId): self + { + $this->messageId = $messageId; + return $this; + } + + public function getPairedMessageId(): string|null + { + return $this->pairedMessageId; + } + + public function setPairedMessageId(?string $pairedMessageId): self + { + $this->pairedMessageId = $pairedMessageId; + return $this; + } + + public function getCallbackData(): string|null + { + return $this->callbackData; + } + + public function setCallbackData(?string $callbackData): self + { + $this->callbackData = $callbackData; + return $this; + } + + public function getUserAgent(): string|null + { + return $this->userAgent; + } + + public function setUserAgent(?string $userAgent): self + { + $this->userAgent = $userAgent; + return $this; + } + + /** + * @return \Infobip\Model\MmsWebhookInboundMessageSegment[]|null + */ + public function getMessage(): ?array + { + return $this->message; + } + + /** + * @param \Infobip\Model\MmsWebhookInboundMessageSegment[]|null $message All parts of the received message. + */ + public function setMessage(?array $message): self + { + $this->message = $message; + return $this; + } + + public function getPrice(): \Infobip\Model\MessagePrice|null + { + return $this->price; + } + + public function setPrice(?\Infobip\Model\MessagePrice $price): self + { + $this->price = $price; + return $this; + } +} diff --git a/Infobip/Model/MmsWebhookInboundReportResponse.php b/Infobip/Model/MmsWebhookInboundReportResponse.php new file mode 100644 index 0000000..ed7e2b3 --- /dev/null +++ b/Infobip/Model/MmsWebhookInboundReportResponse.php @@ -0,0 +1,98 @@ + 'int32', + 'pendingMessageCount' => 'int32', + 'results' => null + ]; + + /** + * @param \Infobip\Model\MmsWebhookInboundReport[] $results + */ + public function __construct( + protected ?int $messageCount = null, + protected ?int $pendingMessageCount = null, + protected ?array $results = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getMessageCount(): int|null + { + return $this->messageCount; + } + + public function setMessageCount(?int $messageCount): self + { + $this->messageCount = $messageCount; + return $this; + } + + public function getPendingMessageCount(): int|null + { + return $this->pendingMessageCount; + } + + public function setPendingMessageCount(?int $pendingMessageCount): self + { + $this->pendingMessageCount = $pendingMessageCount; + return $this; + } + + /** + * @return \Infobip\Model\MmsWebhookInboundReport[]|null + */ + public function getResults(): ?array + { + return $this->results; + } + + /** + * @param \Infobip\Model\MmsWebhookInboundReport[]|null $results results + */ + public function setResults(?array $results): self + { + $this->results = $results; + return $this; + } +} diff --git a/Infobip/Model/MmsWebhookOutboundReport.php b/Infobip/Model/MmsWebhookOutboundReport.php new file mode 100644 index 0000000..072ca91 --- /dev/null +++ b/Infobip/Model/MmsWebhookOutboundReport.php @@ -0,0 +1,205 @@ + null, + 'messageId' => null, + 'to' => null, + 'sentAt' => 'date-time', + 'doneAt' => 'date-time', + 'smsCount' => 'int32', + 'mccMnc' => null, + 'callbackData' => null, + 'price' => null, + 'status' => null, + 'error' => null + ]; + + /** + */ + public function __construct( + protected ?string $bulkId = null, + protected ?string $messageId = null, + protected ?string $to = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $sentAt = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $doneAt = null, + protected ?int $smsCount = null, + protected ?string $mccMnc = null, + protected ?string $callbackData = null, + #[Assert\Valid] + + protected ?\Infobip\Model\MessagePrice $price = null, + #[Assert\Valid] + + protected ?\Infobip\Model\MessageStatus $status = null, + #[Assert\Valid] + + protected ?\Infobip\Model\MessageError $error = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getBulkId(): string|null + { + return $this->bulkId; + } + + public function setBulkId(?string $bulkId): self + { + $this->bulkId = $bulkId; + return $this; + } + + public function getMessageId(): string|null + { + return $this->messageId; + } + + public function setMessageId(?string $messageId): self + { + $this->messageId = $messageId; + return $this; + } + + public function getTo(): string|null + { + return $this->to; + } + + public function setTo(?string $to): self + { + $this->to = $to; + return $this; + } + + public function getSentAt(): \DateTime|null + { + return $this->sentAt; + } + + public function setSentAt(?\DateTime $sentAt): self + { + $this->sentAt = $sentAt; + return $this; + } + + public function getDoneAt(): \DateTime|null + { + return $this->doneAt; + } + + public function setDoneAt(?\DateTime $doneAt): self + { + $this->doneAt = $doneAt; + return $this; + } + + public function getSmsCount(): int|null + { + return $this->smsCount; + } + + public function setSmsCount(?int $smsCount): self + { + $this->smsCount = $smsCount; + return $this; + } + + public function getMccMnc(): string|null + { + return $this->mccMnc; + } + + public function setMccMnc(?string $mccMnc): self + { + $this->mccMnc = $mccMnc; + return $this; + } + + public function getCallbackData(): string|null + { + return $this->callbackData; + } + + public function setCallbackData(?string $callbackData): self + { + $this->callbackData = $callbackData; + return $this; + } + + public function getPrice(): \Infobip\Model\MessagePrice|null + { + return $this->price; + } + + public function setPrice(?\Infobip\Model\MessagePrice $price): self + { + $this->price = $price; + return $this; + } + + public function getStatus(): \Infobip\Model\MessageStatus|null + { + return $this->status; + } + + public function setStatus(?\Infobip\Model\MessageStatus $status): self + { + $this->status = $status; + return $this; + } + + public function getError(): \Infobip\Model\MessageError|null + { + return $this->error; + } + + public function setError(?\Infobip\Model\MessageError $error): self + { + $this->error = $error; + return $this; + } +} diff --git a/Infobip/Model/MmsWebhookOutboundReportResponse.php b/Infobip/Model/MmsWebhookOutboundReportResponse.php new file mode 100644 index 0000000..db17559 --- /dev/null +++ b/Infobip/Model/MmsWebhookOutboundReportResponse.php @@ -0,0 +1,72 @@ + null + ]; + + /** + * @param \Infobip\Model\MmsWebhookOutboundReport[] $results + */ + public function __construct( + protected ?array $results = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + /** + * @return \Infobip\Model\MmsWebhookOutboundReport[]|null + */ + public function getResults(): ?array + { + return $this->results; + } + + /** + * @param \Infobip\Model\MmsWebhookOutboundReport[]|null $results results + */ + public function setResults(?array $results): self + { + $this->results = $results; + return $this; + } +} diff --git a/Infobip/Model/ModelInterface.php b/Infobip/Model/ModelInterface.php index a94f1ec..0407da6 100644 --- a/Infobip/Model/ModelInterface.php +++ b/Infobip/Model/ModelInterface.php @@ -1,10 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class SmsAdvancedBinaryRequest implements ModelInterface, ArrayAccess, \JsonSerializable +class SmsAdvancedBinaryRequest implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'SmsAdvancedBinaryRequest'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'bulkId' => 'string', - 'messages' => '\Infobip\Model\SmsBinaryMessage[]', - 'sendingSpeedLimit' => '\Infobip\Model\SmsSendingSpeedLimit' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'SmsAdvancedBinaryRequest'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'bulkId' => null, 'messages' => null, 'sendingSpeedLimit' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'bulkId' => 'bulkId', - 'messages' => 'messages', - 'sendingSpeedLimit' => 'sendingSpeedLimit' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] + * @param \Infobip\Model\SmsBinaryMessage[] $messages */ - protected static $setters = [ - 'bulkId' => 'setBulkId', - 'messages' => 'setMessages', - 'sendingSpeedLimit' => 'setSendingSpeedLimit' - ]; + public function __construct( + #[Assert\NotBlank] - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'bulkId' => 'getBulkId', - 'messages' => 'getMessages', - 'sendingSpeedLimit' => 'getSendingSpeedLimit' - ]; + protected array $messages, + protected ?string $bulkId = null, + #[Assert\Valid] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; + protected ?\Infobip\Model\SmsSendingSpeedLimit $sendingSpeedLimit = null, + ) { } - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() + #[Ignore] + public function getModelName(): string { - return self::$setters; + return self::OPENAPI_MODEL_NAME; } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$getters; + return self::DISCRIMINATOR; } - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() + public function getBulkId(): string|null { - return self::$openAPIModelName; + return $this->bulkId; } - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) + public function setBulkId(?string $bulkId): self { - $this->container['bulkId'] = $data['bulkId'] ?? null; - $this->container['messages'] = $data['messages'] ?? null; - $this->container['sendingSpeedLimit'] = $data['sendingSpeedLimit'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - if ($this->container['messages'] === null) { - $invalidProperties[] = "'messages' can't be null"; - } - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets bulkId - * - * @return string|null - */ - public function getBulkId() - { - return $this->container['bulkId']; - } - - /** - * Sets bulkId - * - * @param string|null $bulkId Unique ID assigned to the request if messaging multiple recipients or sending multiple messages via a single API request. If not provided, it will be auto-generated and returned in the API response. Typically, used to fetch [delivery reports](#channels/sms/get-outbound-sms-message-delivery-reports) and [message logs](#channels/sms/get-outbound-sms-message-logs). - * - * @return self - */ - public function setBulkId($bulkId) - { - $this->container['bulkId'] = $bulkId; - + $this->bulkId = $bulkId; return $this; } /** - * Gets messages - * * @return \Infobip\Model\SmsBinaryMessage[] */ - public function getMessages() + public function getMessages(): array { - return $this->container['messages']; + return $this->messages; } /** - * Sets messages - * * @param \Infobip\Model\SmsBinaryMessage[] $messages An array of message objects of a single message or multiple messages sent under one bulk ID. - * - * @return self */ - public function setMessages($messages) + public function setMessages(array $messages): self { - $this->container['messages'] = $messages; - + $this->messages = $messages; return $this; } - /** - * Gets sendingSpeedLimit - * - * @return \Infobip\Model\SmsSendingSpeedLimit|null - */ - public function getSendingSpeedLimit() + public function getSendingSpeedLimit(): \Infobip\Model\SmsSendingSpeedLimit|null { - return $this->container['sendingSpeedLimit']; + return $this->sendingSpeedLimit; } - /** - * Sets sendingSpeedLimit - * - * @param \Infobip\Model\SmsSendingSpeedLimit|null $sendingSpeedLimit sendingSpeedLimit - * - * @return self - */ - public function setSendingSpeedLimit($sendingSpeedLimit) + public function setSendingSpeedLimit(?\Infobip\Model\SmsSendingSpeedLimit $sendingSpeedLimit): self { - $this->container['sendingSpeedLimit'] = $sendingSpeedLimit; - + $this->sendingSpeedLimit = $sendingSpeedLimit; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/SmsAdvancedTextualRequest.php b/Infobip/Model/SmsAdvancedTextualRequest.php index a37ba37..ea9441e 100644 --- a/Infobip/Model/SmsAdvancedTextualRequest.php +++ b/Infobip/Model/SmsAdvancedTextualRequest.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class SmsAdvancedTextualRequest implements ModelInterface, ArrayAccess, \JsonSerializable +class SmsAdvancedTextualRequest implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'SmsAdvancedTextualRequest'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'bulkId' => 'string', - 'messages' => '\Infobip\Model\SmsTextualMessage[]', - 'sendingSpeedLimit' => '\Infobip\Model\SmsSendingSpeedLimit', - 'tracking' => '\Infobip\Model\SmsTracking' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'SmsAdvancedTextualRequest'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'bulkId' => null, 'messages' => null, 'sendingSpeedLimit' => null, + 'urlOptions' => null, 'tracking' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array + * @param \Infobip\Model\SmsTextualMessage[] $messages */ - public static function openAPITypes() - { - return self::$openAPITypes; - } + public function __construct( + #[Assert\NotBlank] - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } + protected array $messages, + protected ?string $bulkId = null, + #[Assert\Valid] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'bulkId' => 'bulkId', - 'messages' => 'messages', - 'sendingSpeedLimit' => 'sendingSpeedLimit', - 'tracking' => 'tracking' - ]; + protected ?\Infobip\Model\SmsSendingSpeedLimit $sendingSpeedLimit = null, + #[Assert\Valid] - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'bulkId' => 'setBulkId', - 'messages' => 'setMessages', - 'sendingSpeedLimit' => 'setSendingSpeedLimit', - 'tracking' => 'setTracking' - ]; + protected ?\Infobip\Model\SmsUrlOptions $urlOptions = null, + #[Assert\Valid] - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'bulkId' => 'getBulkId', - 'messages' => 'getMessages', - 'sendingSpeedLimit' => 'getSendingSpeedLimit', - 'tracking' => 'getTracking' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; + protected ?\Infobip\Model\SmsTracking $tracking = null, + ) { } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public function getModelName(): string { - return self::$getters; + return self::OPENAPI_MODEL_NAME; } - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$openAPIModelName; + return self::DISCRIMINATOR; } - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) + public function getBulkId(): string|null { - $this->container['bulkId'] = $data['bulkId'] ?? null; - $this->container['messages'] = $data['messages'] ?? null; - $this->container['sendingSpeedLimit'] = $data['sendingSpeedLimit'] ?? null; - $this->container['tracking'] = $data['tracking'] ?? null; + return $this->bulkId; } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + public function setBulkId(?string $bulkId): self { - $invalidProperties = []; - - if ($this->container['messages'] === null) { - $invalidProperties[] = "'messages' can't be null"; - } - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets bulkId - * - * @return string|null - */ - public function getBulkId() - { - return $this->container['bulkId']; - } - - /** - * Sets bulkId - * - * @param string|null $bulkId Unique ID assigned to the request if messaging multiple recipients or sending multiple messages via a single API request. If not provided, it will be auto-generated and returned in the API response. Typically, used to fetch [delivery reports](#channels/sms/get-outbound-sms-message-delivery-reports) and [message logs](#channels/sms/get-outbound-sms-message-logs). - * - * @return self - */ - public function setBulkId($bulkId) - { - $this->container['bulkId'] = $bulkId; - + $this->bulkId = $bulkId; return $this; } /** - * Gets messages - * * @return \Infobip\Model\SmsTextualMessage[] */ - public function getMessages() + public function getMessages(): array { - return $this->container['messages']; + return $this->messages; } /** - * Sets messages - * * @param \Infobip\Model\SmsTextualMessage[] $messages An array of message objects of a single message or multiple messages sent under one bulk ID. - * - * @return self */ - public function setMessages($messages) + public function setMessages(array $messages): self { - $this->container['messages'] = $messages; - + $this->messages = $messages; return $this; } - /** - * Gets sendingSpeedLimit - * - * @return \Infobip\Model\SmsSendingSpeedLimit|null - */ - public function getSendingSpeedLimit() + public function getSendingSpeedLimit(): \Infobip\Model\SmsSendingSpeedLimit|null { - return $this->container['sendingSpeedLimit']; + return $this->sendingSpeedLimit; } - /** - * Sets sendingSpeedLimit - * - * @param \Infobip\Model\SmsSendingSpeedLimit|null $sendingSpeedLimit sendingSpeedLimit - * - * @return self - */ - public function setSendingSpeedLimit($sendingSpeedLimit) + public function setSendingSpeedLimit(?\Infobip\Model\SmsSendingSpeedLimit $sendingSpeedLimit): self { - $this->container['sendingSpeedLimit'] = $sendingSpeedLimit; - + $this->sendingSpeedLimit = $sendingSpeedLimit; return $this; } - /** - * Gets tracking - * - * @return \Infobip\Model\SmsTracking|null - */ - public function getTracking() + public function getUrlOptions(): \Infobip\Model\SmsUrlOptions|null { - return $this->container['tracking']; + return $this->urlOptions; } - /** - * Sets tracking - * - * @param \Infobip\Model\SmsTracking|null $tracking tracking - * - * @return self - */ - public function setTracking($tracking) + public function setUrlOptions(?\Infobip\Model\SmsUrlOptions $urlOptions): self { - $this->container['tracking'] = $tracking; - + $this->urlOptions = $urlOptions; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() + public function getTracking(): \Infobip\Model\SmsTracking|null { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); + return $this->tracking; } - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() + public function setTracking(?\Infobip\Model\SmsTracking $tracking): self { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + $this->tracking = $tracking; + return $this; } } diff --git a/Infobip/Model/SmsApiRequestErrorDetails.php b/Infobip/Model/SmsApiRequestErrorDetails.php index d63fce7..11bdc55 100644 --- a/Infobip/Model/SmsApiRequestErrorDetails.php +++ b/Infobip/Model/SmsApiRequestErrorDetails.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class SmsApiRequestErrorDetails implements ModelInterface, ArrayAccess, \JsonSerializable +class SmsApiRequestErrorDetails implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'SmsApiRequestErrorDetails'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'messageId' => 'string', - 'text' => 'string', - 'validationErrors' => 'array' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'SmsApiRequestErrorDetails'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'messageId' => null, 'text' => null, 'validationErrors' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array + * @param array $validationErrors */ - public static function openAPITypes() - { - return self::$openAPITypes; + public function __construct( + protected ?string $messageId = null, + protected ?string $text = null, + protected ?array $validationErrors = null, + ) { } - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() + #[Ignore] + public function getModelName(): string { - return self::$openAPIFormats; + return self::OPENAPI_MODEL_NAME; } - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'messageId' => 'messageId', - 'text' => 'text', - 'validationErrors' => 'validationErrors' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'messageId' => 'setMessageId', - 'text' => 'setText', - 'validationErrors' => 'setValidationErrors' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'messageId' => 'getMessageId', - 'text' => 'getText', - 'validationErrors' => 'getValidationErrors' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$setters; + return self::DISCRIMINATOR; } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() + public function getMessageId(): string|null { - return self::$openAPIModelName; + return $this->messageId; } - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['messageId'] = $data['messageId'] ?? null; - $this->container['text'] = $data['text'] ?? null; - $this->container['validationErrors'] = $data['validationErrors'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + public function setMessageId(?string $messageId): self { - $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() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets messageId - * - * @return string|null - */ - public function getMessageId() - { - return $this->container['messageId']; - } - - /** - * Sets messageId - * - * @param string|null $messageId Identifier of the error. - * - * @return self - */ - public function setMessageId($messageId) - { - $this->container['messageId'] = $messageId; - + $this->messageId = $messageId; return $this; } - /** - * Gets text - * - * @return string|null - */ - public function getText() + public function getText(): string|null { - return $this->container['text']; + return $this->text; } - /** - * Sets text - * - * @param string|null $text Detailed error description. - * - * @return self - */ - public function setText($text) + public function setText(?string $text): self { - $this->container['text'] = $text; - + $this->text = $text; return $this; } /** - * Gets validationErrors - * * @return array|null */ public function getValidationErrors() { - return $this->container['validationErrors']; + return $this->validationErrors; } /** - * Sets validationErrors - * - * @param array|null $validationErrors Map of validation errors. - * - * @return self + * @param array|null $validationErrors Validation errors. */ - public function setValidationErrors($validationErrors) + public function setValidationErrors(?array $validationErrors): self { - $this->container['validationErrors'] = $validationErrors; - + $this->validationErrors = $validationErrors; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/SmsBinaryContent.php b/Infobip/Model/SmsBinaryContent.php index 7f8f923..00d03a6 100644 --- a/Infobip/Model/SmsBinaryContent.php +++ b/Infobip/Model/SmsBinaryContent.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class SmsBinaryContent implements ModelInterface, ArrayAccess, \JsonSerializable +class SmsBinaryContent implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'SmsBinaryContent'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'dataCoding' => 'int', - 'esmClass' => 'int', - 'hex' => 'string' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'SmsBinaryContent'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'dataCoding' => 'int32', 'esmClass' => 'int32', 'hex' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'dataCoding' => 'dataCoding', - 'esmClass' => 'esmClass', - 'hex' => 'hex' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'dataCoding' => 'setDataCoding', - 'esmClass' => 'setEsmClass', - 'hex' => 'setHex' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'dataCoding' => 'getDataCoding', - 'esmClass' => 'getEsmClass', - 'hex' => 'getHex' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] */ - protected $container = []; + public function __construct( + #[Assert\NotBlank] - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['dataCoding'] = $data['dataCoding'] ?? null; - $this->container['esmClass'] = $data['esmClass'] ?? null; - $this->container['hex'] = $data['hex'] ?? null; + protected string $hex, + protected ?int $dataCoding = null, + protected ?int $esmClass = null, + ) { } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - if ($this->container['hex'] === null) { - $invalidProperties[] = "'hex' can't be null"; - } - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets dataCoding - * - * @return int|null - */ - public function getDataCoding() + public function getDataCoding(): int|null { - return $this->container['dataCoding']; + return $this->dataCoding; } - /** - * Sets dataCoding - * - * @param int|null $dataCoding Binary content data coding. The default value is (`0`) for GSM7. Example: (`8`) for Unicode data. - * - * @return self - */ - public function setDataCoding($dataCoding) + public function setDataCoding(?int $dataCoding): self { - $this->container['dataCoding'] = $dataCoding; - + $this->dataCoding = $dataCoding; return $this; } - /** - * Gets esmClass - * - * @return int|null - */ - public function getEsmClass() + public function getEsmClass(): int|null { - return $this->container['esmClass']; + return $this->esmClass; } - /** - * Sets esmClass - * - * @param int|null $esmClass “Esm_class” parameter. Indicate special message attributes associated with the SMS. Default value is (`0`). - * - * @return self - */ - public function setEsmClass($esmClass) + public function setEsmClass(?int $esmClass): self { - $this->container['esmClass'] = $esmClass; - + $this->esmClass = $esmClass; return $this; } - /** - * Gets hex - * - * @return string - */ - public function getHex() + public function getHex(): string { - return $this->container['hex']; + return $this->hex; } - /** - * Sets hex - * - * @param string $hex Hexadecimal string. This is the representation of your binary data. Two hex digits represent one byte. They should be separated by the space character (Example: `0f c2 4a bf 34 13 ba`). - * - * @return self - */ - public function setHex($hex) + public function setHex(string $hex): self { - $this->container['hex'] = $hex; - + $this->hex = $hex; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/SmsBinaryMessage.php b/Infobip/Model/SmsBinaryMessage.php index 2df0f3a..58f9ae0 100644 --- a/Infobip/Model/SmsBinaryMessage.php +++ b/Infobip/Model/SmsBinaryMessage.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class SmsBinaryMessage implements ModelInterface, ArrayAccess, \JsonSerializable +class SmsBinaryMessage implements ModelInterface { - public const DISCRIMINATOR = null; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'SmsBinaryMessage'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'SmsBinaryMessage'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'binary' => '\Infobip\Model\SmsBinaryContent', - 'callbackData' => 'string', - 'deliveryTimeWindow' => '\Infobip\Model\SmsDeliveryTimeWindow', - 'destinations' => '\Infobip\Model\SmsDestination[]', - 'flash' => 'bool', - 'from' => 'string', - 'intermediateReport' => 'bool', - 'notifyContentType' => 'string', - 'notifyUrl' => 'string', - 'regional' => '\Infobip\Model\SmsRegionalOptions', - 'sendAt' => '\DateTime', - 'validityPeriod' => 'int' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'binary' => null, 'callbackData' => null, 'deliveryTimeWindow' => null, @@ -88,578 +41,220 @@ class SmsBinaryMessage implements ModelInterface, ArrayAccess, \JsonSerializable 'notifyUrl' => null, 'regional' => null, 'sendAt' => 'date-time', - 'validityPeriod' => 'int64' - ]; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'binary' => 'binary', - 'callbackData' => 'callbackData', - 'deliveryTimeWindow' => 'deliveryTimeWindow', - 'destinations' => 'destinations', - 'flash' => 'flash', - 'from' => 'from', - 'intermediateReport' => 'intermediateReport', - 'notifyContentType' => 'notifyContentType', - 'notifyUrl' => 'notifyUrl', - 'regional' => 'regional', - 'sendAt' => 'sendAt', - 'validityPeriod' => 'validityPeriod' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'binary' => 'setBinary', - 'callbackData' => 'setCallbackData', - 'deliveryTimeWindow' => 'setDeliveryTimeWindow', - 'destinations' => 'setDestinations', - 'flash' => 'setFlash', - 'from' => 'setFrom', - 'intermediateReport' => 'setIntermediateReport', - 'notifyContentType' => 'setNotifyContentType', - 'notifyUrl' => 'setNotifyUrl', - 'regional' => 'setRegional', - 'sendAt' => 'setSendAt', - 'validityPeriod' => 'setValidityPeriod' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'binary' => 'getBinary', - 'callbackData' => 'getCallbackData', - 'deliveryTimeWindow' => 'getDeliveryTimeWindow', - 'destinations' => 'getDestinations', - 'flash' => 'getFlash', - 'from' => 'getFrom', - 'intermediateReport' => 'getIntermediateReport', - 'notifyContentType' => 'getNotifyContentType', - 'notifyUrl' => 'getNotifyUrl', - 'regional' => 'getRegional', - 'sendAt' => 'getSendAt', - 'validityPeriod' => 'getValidityPeriod' + 'validityPeriod' => 'int64', + 'entityId' => null, + 'applicationId' => null ]; /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array + * @param \Infobip\Model\SmsDestination[] $destinations */ - public static function attributeMap() - { - return self::$attributeMap; - } + public function __construct( + #[Assert\NotBlank] - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } + protected array $destinations, + #[Assert\Valid] - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } + protected ?\Infobip\Model\SmsBinaryContent $binary = null, + #[Assert\Length(max: 4000)] + #[Assert\Length(min: 0)] - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } + protected ?string $callbackData = null, + #[Assert\Valid] + protected ?\Infobip\Model\SmsDeliveryTimeWindow $deliveryTimeWindow = null, + protected ?bool $flash = null, + protected ?string $from = null, + protected ?bool $intermediateReport = null, + protected ?string $notifyContentType = null, + protected ?string $notifyUrl = null, + #[Assert\Valid] + protected ?\Infobip\Model\SmsRegionalOptions $regional = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + protected ?\DateTime $sendAt = null, + protected ?int $validityPeriod = null, + #[Assert\Length(max: 66)] + #[Assert\Length(min: 0)] + protected ?string $entityId = null, + #[Assert\Length(max: 66)] + #[Assert\Length(min: 0)] - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['binary'] = $data['binary'] ?? null; - $this->container['callbackData'] = $data['callbackData'] ?? null; - $this->container['deliveryTimeWindow'] = $data['deliveryTimeWindow'] ?? null; - $this->container['destinations'] = $data['destinations'] ?? null; - $this->container['flash'] = $data['flash'] ?? null; - $this->container['from'] = $data['from'] ?? null; - $this->container['intermediateReport'] = $data['intermediateReport'] ?? null; - $this->container['notifyContentType'] = $data['notifyContentType'] ?? null; - $this->container['notifyUrl'] = $data['notifyUrl'] ?? null; - $this->container['regional'] = $data['regional'] ?? null; - $this->container['sendAt'] = $data['sendAt'] ?? null; - $this->container['validityPeriod'] = $data['validityPeriod'] ?? null; + protected ?string $applicationId = null, + ) { } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - if (!is_null($this->container['callbackData']) && (mb_strlen($this->container['callbackData']) > 4000)) { - $invalidProperties[] = "invalid value for 'callbackData', the character length must be smaller than or equal to 4000."; - } - - if (!is_null($this->container['callbackData']) && (mb_strlen($this->container['callbackData']) < 0)) { - $invalidProperties[] = "invalid value for 'callbackData', the character length must be bigger than or equal to 0."; - } - - if ($this->container['destinations'] === null) { - $invalidProperties[] = "'destinations' can't be null"; - } - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets binary - * - * @return \Infobip\Model\SmsBinaryContent|null - */ - public function getBinary() + public function getBinary(): \Infobip\Model\SmsBinaryContent|null { - return $this->container['binary']; + return $this->binary; } - /** - * Sets binary - * - * @param \Infobip\Model\SmsBinaryContent|null $binary binary - * - * @return self - */ - public function setBinary($binary) + public function setBinary(?\Infobip\Model\SmsBinaryContent $binary): self { - $this->container['binary'] = $binary; - + $this->binary = $binary; return $this; } - /** - * Gets callbackData - * - * @return string|null - */ - public function getCallbackData() + public function getCallbackData(): string|null { - return $this->container['callbackData']; + return $this->callbackData; } - /** - * Sets callbackData - * - * @param string|null $callbackData Additional client data that will be sent on the notifyUrl. The maximum value is 4000 characters. - * - * @return self - */ - public function setCallbackData($callbackData) + public function setCallbackData(?string $callbackData): self { - if (!is_null($callbackData) && (mb_strlen($callbackData) > 4000)) { - throw new \InvalidArgumentException('invalid length for $callbackData when calling SmsBinaryMessage., must be smaller than or equal to 4000.'); - } - if (!is_null($callbackData) && (mb_strlen($callbackData) < 0)) { - throw new \InvalidArgumentException('invalid length for $callbackData when calling SmsBinaryMessage., must be bigger than or equal to 0.'); - } - - $this->container['callbackData'] = $callbackData; - + $this->callbackData = $callbackData; return $this; } - /** - * Gets deliveryTimeWindow - * - * @return \Infobip\Model\SmsDeliveryTimeWindow|null - */ - public function getDeliveryTimeWindow() + public function getDeliveryTimeWindow(): \Infobip\Model\SmsDeliveryTimeWindow|null { - return $this->container['deliveryTimeWindow']; + return $this->deliveryTimeWindow; } - /** - * Sets deliveryTimeWindow - * - * @param \Infobip\Model\SmsDeliveryTimeWindow|null $deliveryTimeWindow deliveryTimeWindow - * - * @return self - */ - public function setDeliveryTimeWindow($deliveryTimeWindow) + public function setDeliveryTimeWindow(?\Infobip\Model\SmsDeliveryTimeWindow $deliveryTimeWindow): self { - $this->container['deliveryTimeWindow'] = $deliveryTimeWindow; - + $this->deliveryTimeWindow = $deliveryTimeWindow; return $this; } /** - * Gets destinations - * * @return \Infobip\Model\SmsDestination[] */ - public function getDestinations() + public function getDestinations(): array { - return $this->container['destinations']; + return $this->destinations; } /** - * Sets destinations - * * @param \Infobip\Model\SmsDestination[] $destinations An array of destination objects for where messages are being sent. A valid destination is required. - * - * @return self */ - public function setDestinations($destinations) + public function setDestinations(array $destinations): self { - $this->container['destinations'] = $destinations; - + $this->destinations = $destinations; return $this; } - /** - * Gets flash - * - * @return bool|null - */ - public function getFlash() + public function getFlash(): bool|null { - return $this->container['flash']; + return $this->flash; } - /** - * Sets flash - * - * @param bool|null $flash Allows for sending a [flash SMS](https://www.infobip.com/docs/sms/message-types#flash-sms) to automatically appear on recipient devices without interaction. Set to `true` to enable flash SMS, or leave the default value, `false` to send a standard SMS. - * - * @return self - */ - public function setFlash($flash) + public function setFlash(?bool $flash): self { - $this->container['flash'] = $flash; - + $this->flash = $flash; return $this; } - /** - * Gets from - * - * @return string|null - */ - public function getFrom() + public function getFrom(): string|null { - return $this->container['from']; + return $this->from; } - /** - * Sets from - * - * @param string|null $from The sender ID which can be alphanumeric or numeric (e.g., `CompanyName`). Make sure you don't exceed [character limit](https://www.infobip.com/docs/sms/get-started#sender-names). - * - * @return self - */ - public function setFrom($from) + public function setFrom(?string $from): self { - $this->container['from'] = $from; - + $this->from = $from; return $this; } - /** - * Gets intermediateReport - * - * @return bool|null - */ - public function getIntermediateReport() + public function getIntermediateReport(): bool|null { - return $this->container['intermediateReport']; + return $this->intermediateReport; } - /** - * Sets intermediateReport - * - * @param bool|null $intermediateReport The [real-time intermediate delivery report](https://www.infobip.com/docs/api#channels/sms/receive-outbound-sms-message-report) containing GSM error codes, messages status, pricing, network and country codes, etc., which will be sent on your callback server. Defaults to `false`. - * - * @return self - */ - public function setIntermediateReport($intermediateReport) + public function setIntermediateReport(?bool $intermediateReport): self { - $this->container['intermediateReport'] = $intermediateReport; - + $this->intermediateReport = $intermediateReport; return $this; } - /** - * Gets notifyContentType - * - * @return string|null - */ - public function getNotifyContentType() + public function getNotifyContentType(): string|null { - return $this->container['notifyContentType']; + return $this->notifyContentType; } - /** - * Sets notifyContentType - * - * @param string|null $notifyContentType Preferred delivery report content type, `application/json` or `application/xml`. - * - * @return self - */ - public function setNotifyContentType($notifyContentType) + public function setNotifyContentType(?string $notifyContentType): self { - $this->container['notifyContentType'] = $notifyContentType; - + $this->notifyContentType = $notifyContentType; return $this; } - /** - * Gets notifyUrl - * - * @return string|null - */ - public function getNotifyUrl() + public function getNotifyUrl(): string|null { - return $this->container['notifyUrl']; + return $this->notifyUrl; } - /** - * Sets notifyUrl - * - * @param string|null $notifyUrl The URL on your call back server on which the Delivery report will be sent. - * - * @return self - */ - public function setNotifyUrl($notifyUrl) + public function setNotifyUrl(?string $notifyUrl): self { - $this->container['notifyUrl'] = $notifyUrl; - + $this->notifyUrl = $notifyUrl; return $this; } - /** - * Gets regional - * - * @return \Infobip\Model\SmsRegionalOptions|null - */ - public function getRegional() + public function getRegional(): \Infobip\Model\SmsRegionalOptions|null { - return $this->container['regional']; + return $this->regional; } - /** - * Sets regional - * - * @param \Infobip\Model\SmsRegionalOptions|null $regional regional - * - * @return self - */ - public function setRegional($regional) + public function setRegional(?\Infobip\Model\SmsRegionalOptions $regional): self { - $this->container['regional'] = $regional; - + $this->regional = $regional; return $this; } - /** - * Gets sendAt - * - * @return \DateTime|null - */ - public function getSendAt() + public function getSendAt(): \DateTime|null { - return $this->container['sendAt']; + return $this->sendAt; } - /** - * Sets sendAt - * - * @param \DateTime|null $sendAt Date and time when the message is to be sent. Used for [scheduled SMS](https://www.infobip.com/docs/api#channels/sms/get-scheduled-sms-messages). Has the following format: `yyyy-MM-dd'T'HH:mm:ss.SSSZ`, and can only be scheduled for no later than 180 days in advance. - * - * @return self - */ - public function setSendAt($sendAt) + public function setSendAt(?\DateTime $sendAt): self { - $this->container['sendAt'] = $sendAt; - + $this->sendAt = $sendAt; return $this; } - /** - * Gets validityPeriod - * - * @return int|null - */ - public function getValidityPeriod() + public function getValidityPeriod(): int|null { - return $this->container['validityPeriod']; + return $this->validityPeriod; } - /** - * Sets validityPeriod - * - * @param int|null $validityPeriod The message validity period in minutes. When the period expires, it will not be allowed for the message to be sent. Validity period longer than 48h is not supported (in this case, it will be automatically set to 48h). - * - * @return self - */ - public function setValidityPeriod($validityPeriod) + public function setValidityPeriod(?int $validityPeriod): self { - $this->container['validityPeriod'] = $validityPeriod; - + $this->validityPeriod = $validityPeriod; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void + public function getEntityId(): string|null { - unset($this->container[$offset]); + return $this->entityId; } - /** - * 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. - */ - public function jsonSerialize(): mixed + public function setEntityId(?string $entityId): self { - return ObjectSerializer::sanitizeForSerialization($this); + $this->entityId = $entityId; + return $this; } - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() + public function getApplicationId(): string|null { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); + return $this->applicationId; } - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() + public function setApplicationId(?string $applicationId): self { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + $this->applicationId = $applicationId; + return $this; } } diff --git a/Infobip/Model/SmsBulkRequest.php b/Infobip/Model/SmsBulkRequest.php index 2c63ac7..92fd4a6 100644 --- a/Infobip/Model/SmsBulkRequest.php +++ b/Infobip/Model/SmsBulkRequest.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class SmsBulkRequest implements ModelInterface, ArrayAccess, \JsonSerializable +class SmsBulkRequest implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'SmsBulkRequest'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'sendAt' => '\DateTime' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'SmsBulkRequest'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'sendAt' => 'date-time' ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'sendAt' => 'sendAt' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'sendAt' => 'setSendAt' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'sendAt' => 'getSendAt' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] */ - protected $container = []; + public function __construct( + #[Assert\NotBlank] + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['sendAt'] = $data['sendAt'] ?? null; + protected \DateTime $sendAt, + ) { } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - if ($this->container['sendAt'] === null) { - $invalidProperties[] = "'sendAt' can't be null"; - } - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets sendAt - * - * @return \DateTime - */ - public function getSendAt() + public function getSendAt(): \DateTime { - return $this->container['sendAt']; + return $this->sendAt; } - /** - * Sets sendAt - * - * @param \DateTime $sendAt Date and time when the message is to be sent. Used for scheduled SMS (see [Scheduled SMS endpoints](#channels/sms/get-scheduled-sms-messages) for more details). Has the following format: `yyyy-MM-dd'T'HH:mm:ss.SSSZ`, and can only be scheduled for no later than 180 days in advance. - * - * @return self - */ - public function setSendAt($sendAt) + public function setSendAt(\DateTime $sendAt): self { - $this->container['sendAt'] = $sendAt; - + $this->sendAt = $sendAt; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/SmsBulkResponse.php b/Infobip/Model/SmsBulkResponse.php index fc7a7c6..dc23ca4 100644 --- a/Infobip/Model/SmsBulkResponse.php +++ b/Infobip/Model/SmsBulkResponse.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class SmsBulkResponse implements ModelInterface, ArrayAccess, \JsonSerializable +class SmsBulkResponse implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'SmsBulkResponse'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'bulkId' => 'string', - 'sendAt' => '\DateTime' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'SmsBulkResponse'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'bulkId' => null, 'sendAt' => 'date-time' ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'bulkId' => 'bulkId', - 'sendAt' => 'sendAt' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'bulkId' => 'setBulkId', - 'sendAt' => 'setSendAt' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] */ - protected static $getters = [ - 'bulkId' => 'getBulkId', - 'sendAt' => 'getSendAt' - ]; + public function __construct( + protected ?string $bulkId = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; + protected ?\DateTime $sendAt = null, + ) { } - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() + #[Ignore] + public function getModelName(): string { - return self::$setters; + return self::OPENAPI_MODEL_NAME; } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$getters; + return self::DISCRIMINATOR; } - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() + public function getBulkId(): string|null { - return self::$openAPIModelName; + return $this->bulkId; } - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['bulkId'] = $data['bulkId'] ?? null; - $this->container['sendAt'] = $data['sendAt'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + public function setBulkId(?string $bulkId): self { - $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() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets bulkId - * - * @return string|null - */ - public function getBulkId() - { - return $this->container['bulkId']; - } - - /** - * Sets bulkId - * - * @param string|null $bulkId Unique ID assigned to the request if messaging multiple recipients or sending multiple messages via a single API request. - * - * @return self - */ - public function setBulkId($bulkId) - { - $this->container['bulkId'] = $bulkId; - + $this->bulkId = $bulkId; return $this; } - /** - * Gets sendAt - * - * @return \DateTime|null - */ - public function getSendAt() + public function getSendAt(): \DateTime|null { - return $this->container['sendAt']; + return $this->sendAt; } - /** - * Sets sendAt - * - * @param \DateTime|null $sendAt Date and time when the message is to be sent. Used for scheduled SMS (see [Scheduled SMS endpoints](#channels/sms/get-scheduled-sms-messages) for more details). Has the following format: `yyyy-MM-dd'T'HH:mm:ss.SSSZ`, and can only be scheduled for no later than 180 days in advance. - * - * @return self - */ - public function setSendAt($sendAt) + public function setSendAt(?\DateTime $sendAt): self { - $this->container['sendAt'] = $sendAt; - + $this->sendAt = $sendAt; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/SmsBulkStatus.php b/Infobip/Model/SmsBulkStatus.php index 7c0b110..c9b4a39 100644 --- a/Infobip/Model/SmsBulkStatus.php +++ b/Infobip/Model/SmsBulkStatus.php @@ -1,14 +1,8 @@ value = $value; + } + + public static function PENDING(): SmsBulkStatus + { + return new self('PENDING'); + } + + public static function PAUSED(): SmsBulkStatus + { + return new self('PAUSED'); + } + + public static function PROCESSING(): SmsBulkStatus + { + return new self('PROCESSING'); + } + + public static function CANCELED(): SmsBulkStatus + { + return new self('CANCELED'); + } + + public static function FINISHED(): SmsBulkStatus + { + return new self('FINISHED'); + } + + public static function FAILED(): SmsBulkStatus + { + return new self('FAILED'); + } + + public function __toString(): string + { + return $this->value; } } diff --git a/Infobip/Model/SmsBulkStatusResponse.php b/Infobip/Model/SmsBulkStatusResponse.php index b724d61..d79f2d7 100644 --- a/Infobip/Model/SmsBulkStatusResponse.php +++ b/Infobip/Model/SmsBulkStatusResponse.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class SmsBulkStatusResponse implements ModelInterface, ArrayAccess, \JsonSerializable +class SmsBulkStatusResponse implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'SmsBulkStatusResponse'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'bulkId' => 'string', - 'status' => '\Infobip\Model\SmsBulkStatus' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'SmsBulkStatusResponse'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'bulkId' => null, 'status' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'bulkId' => 'bulkId', - 'status' => 'status' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'bulkId' => 'setBulkId', - 'status' => 'setStatus' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] */ - protected static $getters = [ - 'bulkId' => 'getBulkId', - 'status' => 'getStatus' - ]; + public function __construct( + protected ?string $bulkId = null, + #[Assert\Choice(['PENDING','PAUSED','PROCESSING','CANCELED','FINISHED','FAILED',])] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; + protected ?string $status = null, + ) { } - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() + #[Ignore] + public function getModelName(): string { - return self::$setters; + return self::OPENAPI_MODEL_NAME; } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$getters; + return self::DISCRIMINATOR; } - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() + public function getBulkId(): string|null { - return self::$openAPIModelName; + return $this->bulkId; } - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['bulkId'] = $data['bulkId'] ?? null; - $this->container['status'] = $data['status'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + public function setBulkId(?string $bulkId): self { - $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() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets bulkId - * - * @return string|null - */ - public function getBulkId() - { - return $this->container['bulkId']; - } - - /** - * Sets bulkId - * - * @param string|null $bulkId Unique ID assigned to the request if messaging multiple recipients or sending multiple messages via a single API request. - * - * @return self - */ - public function setBulkId($bulkId) - { - $this->container['bulkId'] = $bulkId; - + $this->bulkId = $bulkId; return $this; } - /** - * Gets status - * - * @return \Infobip\Model\SmsBulkStatus|null - */ - public function getStatus() + public function getStatus(): mixed { - return $this->container['status']; + return $this->status; } - /** - * Sets status - * - * @param \Infobip\Model\SmsBulkStatus|null $status The status of the message(s). - * - * @return self - */ - public function setStatus($status) + public function setStatus($status): self { - $this->container['status'] = $status; - + $this->status = $status; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/SmsDeliveryDay.php b/Infobip/Model/SmsDeliveryDay.php index ca34517..8b90338 100644 --- a/Infobip/Model/SmsDeliveryDay.php +++ b/Infobip/Model/SmsDeliveryDay.php @@ -1,14 +1,8 @@ value = $value; + } + + public static function MONDAY(): SmsDeliveryDay + { + return new self('MONDAY'); + } + + public static function TUESDAY(): SmsDeliveryDay + { + return new self('TUESDAY'); + } + + public static function WEDNESDAY(): SmsDeliveryDay + { + return new self('WEDNESDAY'); + } + + public static function THURSDAY(): SmsDeliveryDay + { + return new self('THURSDAY'); + } + + public static function FRIDAY(): SmsDeliveryDay + { + return new self('FRIDAY'); + } + + public static function SATURDAY(): SmsDeliveryDay + { + return new self('SATURDAY'); + } + + public static function SUNDAY(): SmsDeliveryDay + { + return new self('SUNDAY'); + } + + public function __toString(): string { - return [ - self::MONDAY, - self::TUESDAY, - self::WEDNESDAY, - self::THURSDAY, - self::FRIDAY, - self::SATURDAY, - self::SUNDAY, - ]; + return $this->value; } } diff --git a/Infobip/Model/SmsDeliveryResult.php b/Infobip/Model/SmsDeliveryResult.php index 9abb58f..55f8db2 100644 --- a/Infobip/Model/SmsDeliveryResult.php +++ b/Infobip/Model/SmsDeliveryResult.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class SmsDeliveryResult implements ModelInterface, ArrayAccess, \JsonSerializable +class SmsDeliveryResult implements ModelInterface { - public const DISCRIMINATOR = null; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'SmsDeliveryResult'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'SmsDeliveryResult'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'results' => '\Infobip\Model\SmsReport[]' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'results' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'results' => 'results' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'results' => 'setResults' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] + * @param \Infobip\Model\SmsReport[] $results */ - protected static $getters = [ - 'results' => 'getResults' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; + public function __construct( + protected ?array $results = null, + ) { } - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() + #[Ignore] + public function getModelName(): string { - return self::$setters; + return self::OPENAPI_MODEL_NAME; } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$getters; + return self::DISCRIMINATOR; } /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['results'] = $data['results'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $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() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets results - * * @return \Infobip\Model\SmsReport[]|null */ - public function getResults() + public function getResults(): ?array { - return $this->container['results']; + return $this->results; } /** - * Sets results - * * @param \Infobip\Model\SmsReport[]|null $results results - * - * @return self */ - public function setResults($results) + public function setResults(?array $results): self { - $this->container['results'] = $results; - + $this->results = $results; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/SmsDeliveryTimeFrom.php b/Infobip/Model/SmsDeliveryTimeFrom.php new file mode 100644 index 0000000..5a2706e --- /dev/null +++ b/Infobip/Model/SmsDeliveryTimeFrom.php @@ -0,0 +1,86 @@ + 'int32', + 'minute' => 'int32' + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + #[Assert\LessThan(23)] + #[Assert\GreaterThan(0)] + + protected int $hour, + #[Assert\NotBlank] + #[Assert\LessThan(59)] + #[Assert\GreaterThan(0)] + + protected int $minute, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getHour(): int + { + return $this->hour; + } + + public function setHour(int $hour): self + { + $this->hour = $hour; + return $this; + } + + public function getMinute(): int + { + return $this->minute; + } + + public function setMinute(int $minute): self + { + $this->minute = $minute; + return $this; + } +} diff --git a/Infobip/Model/SmsDeliveryTimeTo.php b/Infobip/Model/SmsDeliveryTimeTo.php new file mode 100644 index 0000000..6adc543 --- /dev/null +++ b/Infobip/Model/SmsDeliveryTimeTo.php @@ -0,0 +1,86 @@ + 'int32', + 'minute' => 'int32' + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + #[Assert\LessThan(23)] + #[Assert\GreaterThan(0)] + + protected int $hour, + #[Assert\NotBlank] + #[Assert\LessThan(59)] + #[Assert\GreaterThan(0)] + + protected int $minute, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getHour(): int + { + return $this->hour; + } + + public function setHour(int $hour): self + { + $this->hour = $hour; + return $this; + } + + public function getMinute(): int + { + return $this->minute; + } + + public function setMinute(int $minute): self + { + $this->minute = $minute; + return $this; + } +} diff --git a/Infobip/Model/SmsDeliveryTimeWindow.php b/Infobip/Model/SmsDeliveryTimeWindow.php index 028e0de..67bee38 100644 --- a/Infobip/Model/SmsDeliveryTimeWindow.php +++ b/Infobip/Model/SmsDeliveryTimeWindow.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class SmsDeliveryTimeWindow implements ModelInterface, ArrayAccess, \JsonSerializable +class SmsDeliveryTimeWindow implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'SmsDeliveryTimeWindow'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'days' => '\Infobip\Model\SmsDeliveryDay[]', - 'from' => '\Infobip\Model\SmsDeliveryTime', - 'to' => '\Infobip\Model\SmsDeliveryTime' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'SmsDeliveryTimeWindow'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'days' => null, 'from' => null, 'to' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] + * @param \Infobip\Model\SmsDeliveryDay[] $days */ - protected static $attributeMap = [ - 'days' => 'days', - 'from' => 'from', - 'to' => 'to' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'days' => 'setDays', - 'from' => 'setFrom', - 'to' => 'setTo' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'days' => 'getDays', - 'from' => 'getFrom', - 'to' => 'getTo' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - + public function __construct( + #[Assert\NotBlank] + protected array $days, + #[Assert\Valid] + protected ?\Infobip\Model\SmsDeliveryTimeFrom $from = null, + #[Assert\Valid] - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['days'] = $data['days'] ?? null; - $this->container['from'] = $data['from'] ?? null; - $this->container['to'] = $data['to'] ?? null; + protected ?\Infobip\Model\SmsDeliveryTimeTo $to = null, + ) { } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - if ($this->container['days'] === null) { - $invalidProperties[] = "'days' can't be null"; - } - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - /** - * Gets days - * * @return \Infobip\Model\SmsDeliveryDay[] */ - public function getDays() + public function getDays(): array { - return $this->container['days']; + return $this->days; } /** - * Sets days - * * @param \Infobip\Model\SmsDeliveryDay[] $days Days of the week which are included in the delivery time window. At least one day must be provided. Separate multiple days with a comma. - * - * @return self */ - public function setDays($days) + public function setDays(array $days): self { - $this->container['days'] = $days; - + $this->days = $days; return $this; } - /** - * Gets from - * - * @return \Infobip\Model\SmsDeliveryTime|null - */ - public function getFrom() + public function getFrom(): \Infobip\Model\SmsDeliveryTimeFrom|null { - return $this->container['from']; + return $this->from; } - /** - * Sets from - * - * @param \Infobip\Model\SmsDeliveryTime|null $from from - * - * @return self - */ - public function setFrom($from) + public function setFrom(?\Infobip\Model\SmsDeliveryTimeFrom $from): self { - $this->container['from'] = $from; - + $this->from = $from; return $this; } - /** - * Gets to - * - * @return \Infobip\Model\SmsDeliveryTime|null - */ - public function getTo() + public function getTo(): \Infobip\Model\SmsDeliveryTimeTo|null { - return $this->container['to']; + return $this->to; } - /** - * Sets to - * - * @param \Infobip\Model\SmsDeliveryTime|null $to to - * - * @return self - */ - public function setTo($to) + public function setTo(?\Infobip\Model\SmsDeliveryTimeTo $to): self { - $this->container['to'] = $to; - + $this->to = $to; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/SmsDestination.php b/Infobip/Model/SmsDestination.php index 490ef0b..e729da1 100644 --- a/Infobip/Model/SmsDestination.php +++ b/Infobip/Model/SmsDestination.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class SmsDestination implements ModelInterface, ArrayAccess, \JsonSerializable +class SmsDestination implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'SmsDestination'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'messageId' => 'string', - 'to' => 'string' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'SmsDestination'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'messageId' => null, 'to' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'messageId' => 'messageId', - 'to' => 'to' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'messageId' => 'setMessageId', - 'to' => 'setTo' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'messageId' => 'getMessageId', - 'to' => 'getTo' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] */ - protected $container = []; + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 50)] + #[Assert\Length(min: 0)] - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['messageId'] = $data['messageId'] ?? null; - $this->container['to'] = $data['to'] ?? null; + protected string $to, + protected ?string $messageId = null, + ) { } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - if ($this->container['to'] === null) { - $invalidProperties[] = "'to' can't be null"; - } - if ((mb_strlen($this->container['to']) > 50)) { - $invalidProperties[] = "invalid value for 'to', the character length must be smaller than or equal to 50."; - } - - if ((mb_strlen($this->container['to']) < 0)) { - $invalidProperties[] = "invalid value for 'to', the character length must be bigger than or equal to 0."; - } - - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets messageId - * - * @return string|null - */ - public function getMessageId() + public function getMessageId(): string|null { - return $this->container['messageId']; + return $this->messageId; } - /** - * Sets messageId - * - * @param string|null $messageId The ID that uniquely identifies the message sent. - * - * @return self - */ - public function setMessageId($messageId) + public function setMessageId(?string $messageId): self { - $this->container['messageId'] = $messageId; - + $this->messageId = $messageId; return $this; } - /** - * Gets to - * - * @return string - */ - public function getTo() + public function getTo(): string { - return $this->container['to']; + return $this->to; } - /** - * Sets to - * - * @param string $to Message destination address. Addresses must be in international format (Example: `41793026727`). - * - * @return self - */ - public function setTo($to) + public function setTo(string $to): self { - if ((mb_strlen($to) > 50)) { - throw new \InvalidArgumentException('invalid length for $to when calling SmsDestination., must be smaller than or equal to 50.'); - } - if ((mb_strlen($to) < 0)) { - throw new \InvalidArgumentException('invalid length for $to when calling SmsDestination., must be bigger than or equal to 0.'); - } - - $this->container['to'] = $to; - + $this->to = $to; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/SmsError.php b/Infobip/Model/SmsError.php index 05a0b3f..e44e7eb 100644 --- a/Infobip/Model/SmsError.php +++ b/Infobip/Model/SmsError.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class SmsError implements ModelInterface, ArrayAccess, \JsonSerializable +class SmsError implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'SmsError'; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'SmsError'; - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'description' => 'string', - 'groupId' => 'int', - 'groupName' => 'string', - 'id' => 'int', - 'name' => 'string', - 'permanent' => 'bool' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'description' => null, + public const OPENAPI_FORMATS = [ 'groupId' => 'int32', 'groupName' => null, 'id' => 'int32', 'name' => null, + 'description' => null, 'permanent' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array */ - public static function openAPITypes() - { - return self::$openAPITypes; + public function __construct( + protected ?int $groupId = null, + protected ?string $groupName = null, + protected ?int $id = null, + protected ?string $name = null, + protected ?string $description = null, + protected ?bool $permanent = null, + ) { } - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'description' => 'description', - 'groupId' => 'groupId', - 'groupName' => 'groupName', - 'id' => 'id', - 'name' => 'name', - 'permanent' => 'permanent' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'description' => 'setDescription', - 'groupId' => 'setGroupId', - 'groupName' => 'setGroupName', - 'id' => 'setId', - 'name' => 'setName', - 'permanent' => 'setPermanent' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'description' => 'getDescription', - 'groupId' => 'getGroupId', - 'groupName' => 'getGroupName', - 'id' => 'getId', - 'name' => 'getName', - 'permanent' => 'getPermanent' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['description'] = $data['description'] ?? null; - $this->container['groupId'] = $data['groupId'] ?? null; - $this->container['groupName'] = $data['groupName'] ?? null; - $this->container['id'] = $data['id'] ?? null; - $this->container['name'] = $data['name'] ?? null; - $this->container['permanent'] = $data['permanent'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets description - * - * @return string|null - */ - public function getDescription() + public function getGroupId(): int|null { - return $this->container['description']; + return $this->groupId; } - /** - * Sets description - * - * @param string|null $description Human-readable description of the error.. - * - * @return self - */ - public function setDescription($description) + public function setGroupId(?int $groupId): self { - $this->container['description'] = $description; - + $this->groupId = $groupId; return $this; } - /** - * Gets groupId - * - * @return int|null - */ - public function getGroupId() + public function getGroupName(): string|null { - return $this->container['groupId']; + return $this->groupName; } - /** - * Sets groupId - * - * @param int|null $groupId Error group ID. - * - * @return self - */ - public function setGroupId($groupId) + public function setGroupName(?string $groupName): self { - $this->container['groupId'] = $groupId; - + $this->groupName = $groupName; return $this; } - /** - * Gets groupName - * - * @return string|null - */ - public function getGroupName() + public function getId(): int|null { - return $this->container['groupName']; + return $this->id; } - /** - * Sets groupName - * - * @param string|null $groupName Error group name. - * - * @return self - */ - public function setGroupName($groupName) + public function setId(?int $id): self { - $this->container['groupName'] = $groupName; - + $this->id = $id; return $this; } - /** - * Gets id - * - * @return int|null - */ - public function getId() + public function getName(): string|null { - return $this->container['id']; + return $this->name; } - /** - * Sets id - * - * @param int|null $id Error ID. - * - * @return self - */ - public function setId($id) + public function setName(?string $name): self { - $this->container['id'] = $id; - + $this->name = $name; return $this; } - /** - * Gets name - * - * @return string|null - */ - public function getName() + public function getDescription(): string|null { - return $this->container['name']; + return $this->description; } - /** - * Sets name - * - * @param string|null $name Error name. - * - * @return self - */ - public function setName($name) + public function setDescription(?string $description): self { - $this->container['name'] = $name; - + $this->description = $description; return $this; } - /** - * Gets permanent - * - * @return bool|null - */ - public function getPermanent() + public function getPermanent(): bool|null { - return $this->container['permanent']; + return $this->permanent; } - /** - * Sets permanent - * - * @param bool|null $permanent Tells if the error is permanent. - * - * @return self - */ - public function setPermanent($permanent) + public function setPermanent(?bool $permanent): self { - $this->container['permanent'] = $permanent; - + $this->permanent = $permanent; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/SmsInboundMessage.php b/Infobip/Model/SmsInboundMessage.php index 5913bc0..48c0fcf 100644 --- a/Infobip/Model/SmsInboundMessage.php +++ b/Infobip/Model/SmsInboundMessage.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class SmsInboundMessage implements ModelInterface, ArrayAccess, \JsonSerializable +class SmsInboundMessage implements ModelInterface { - public const DISCRIMINATOR = null; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'SmsInboundMessage'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'SmsInboundMessage'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'callbackData' => 'string', - 'cleanText' => 'string', - 'from' => 'string', - 'keyword' => 'string', - 'messageId' => 'string', - 'price' => '\Infobip\Model\SmsPrice', - 'receivedAt' => '\DateTime', - 'smsCount' => 'int', - 'text' => 'string', - 'to' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'callbackData' => null, 'cleanText' => null, 'from' => null, @@ -87,500 +43,144 @@ class SmsInboundMessage implements ModelInterface, ArrayAccess, \JsonSerializabl ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array */ - public static function openAPITypes() - { - return self::$openAPITypes; - } + public function __construct( + protected ?string $callbackData = null, + protected ?string $cleanText = null, + protected ?string $from = null, + protected ?string $keyword = null, + protected ?string $messageId = null, + #[Assert\Valid] - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'callbackData' => 'callbackData', - 'cleanText' => 'cleanText', - 'from' => 'from', - 'keyword' => 'keyword', - 'messageId' => 'messageId', - 'price' => 'price', - 'receivedAt' => 'receivedAt', - 'smsCount' => 'smsCount', - 'text' => 'text', - 'to' => 'to' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'callbackData' => 'setCallbackData', - 'cleanText' => 'setCleanText', - 'from' => 'setFrom', - 'keyword' => 'setKeyword', - 'messageId' => 'setMessageId', - 'price' => 'setPrice', - 'receivedAt' => 'setReceivedAt', - 'smsCount' => 'setSmsCount', - 'text' => 'setText', - 'to' => 'setTo' - ]; + protected ?\Infobip\Model\SmsPrice $price = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'callbackData' => 'getCallbackData', - 'cleanText' => 'getCleanText', - 'from' => 'getFrom', - 'keyword' => 'getKeyword', - 'messageId' => 'getMessageId', - 'price' => 'getPrice', - 'receivedAt' => 'getReceivedAt', - 'smsCount' => 'getSmsCount', - 'text' => 'getText', - 'to' => 'getTo' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; + protected ?\DateTime $receivedAt = null, + protected ?int $smsCount = null, + protected ?string $text = null, + protected ?string $to = null, + ) { } - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() + #[Ignore] + public function getModelName(): string { - return self::$setters; + return self::OPENAPI_MODEL_NAME; } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) + #[Ignore] + public static function getDiscriminator(): ?string { - $this->container['callbackData'] = $data['callbackData'] ?? null; - $this->container['cleanText'] = $data['cleanText'] ?? null; - $this->container['from'] = $data['from'] ?? null; - $this->container['keyword'] = $data['keyword'] ?? null; - $this->container['messageId'] = $data['messageId'] ?? null; - $this->container['price'] = $data['price'] ?? null; - $this->container['receivedAt'] = $data['receivedAt'] ?? null; - $this->container['smsCount'] = $data['smsCount'] ?? null; - $this->container['text'] = $data['text'] ?? null; - $this->container['to'] = $data['to'] ?? null; + return self::DISCRIMINATOR; } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + public function getCallbackData(): string|null { - $invalidProperties = []; - - return $invalidProperties; + return $this->callbackData; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + public function setCallbackData(?string $callbackData): self { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets callbackData - * - * @return string|null - */ - public function getCallbackData() - { - return $this->container['callbackData']; - } - - /** - * Sets callbackData - * - * @param string|null $callbackData Custom callback data sent over the notifyUrl. - * - * @return self - */ - public function setCallbackData($callbackData) - { - $this->container['callbackData'] = $callbackData; - + $this->callbackData = $callbackData; return $this; } - /** - * Gets cleanText - * - * @return string|null - */ - public function getCleanText() + public function getCleanText(): string|null { - return $this->container['cleanText']; + return $this->cleanText; } - /** - * Sets cleanText - * - * @param string|null $cleanText Content of the message without a keyword (if a keyword was sent). - * - * @return self - */ - public function setCleanText($cleanText) + public function setCleanText(?string $cleanText): self { - $this->container['cleanText'] = $cleanText; - + $this->cleanText = $cleanText; return $this; } - /** - * Gets from - * - * @return string|null - */ - public function getFrom() + public function getFrom(): string|null { - return $this->container['from']; + return $this->from; } - /** - * Sets from - * - * @param string|null $from Sender ID that can be alphanumeric or numeric. - * - * @return self - */ - public function setFrom($from) + public function setFrom(?string $from): self { - $this->container['from'] = $from; - + $this->from = $from; return $this; } - /** - * Gets keyword - * - * @return string|null - */ - public function getKeyword() + public function getKeyword(): string|null { - return $this->container['keyword']; + return $this->keyword; } - /** - * Sets keyword - * - * @param string|null $keyword Keyword extracted from the message content. - * - * @return self - */ - public function setKeyword($keyword) + public function setKeyword(?string $keyword): self { - $this->container['keyword'] = $keyword; - + $this->keyword = $keyword; return $this; } - /** - * Gets messageId - * - * @return string|null - */ - public function getMessageId() + public function getMessageId(): string|null { - return $this->container['messageId']; + return $this->messageId; } - /** - * Sets messageId - * - * @param string|null $messageId Unique message ID. - * - * @return self - */ - public function setMessageId($messageId) + public function setMessageId(?string $messageId): self { - $this->container['messageId'] = $messageId; - + $this->messageId = $messageId; return $this; } - /** - * Gets price - * - * @return \Infobip\Model\SmsPrice|null - */ - public function getPrice() + public function getPrice(): \Infobip\Model\SmsPrice|null { - return $this->container['price']; + return $this->price; } - /** - * Sets price - * - * @param \Infobip\Model\SmsPrice|null $price A price object showing currency and a price per each message. - * - * @return self - */ - public function setPrice($price) + public function setPrice(?\Infobip\Model\SmsPrice $price): self { - $this->container['price'] = $price; - + $this->price = $price; return $this; } - /** - * Gets receivedAt - * - * @return \DateTime|null - */ - public function getReceivedAt() + public function getReceivedAt(): \DateTime|null { - return $this->container['receivedAt']; + return $this->receivedAt; } - /** - * Sets receivedAt - * - * @param \DateTime|null $receivedAt Indicates when the Infobip platform received the message. Has the following format: `yyyy-MM-dd'T'HH:mm:ss.SSSZ`. - * - * @return self - */ - public function setReceivedAt($receivedAt) + public function setReceivedAt(?\DateTime $receivedAt): self { - $this->container['receivedAt'] = $receivedAt; - + $this->receivedAt = $receivedAt; return $this; } - /** - * Gets smsCount - * - * @return int|null - */ - public function getSmsCount() + public function getSmsCount(): int|null { - return $this->container['smsCount']; + return $this->smsCount; } - /** - * Sets smsCount - * - * @param int|null $smsCount The number of characters within a message - * - * @return self - */ - public function setSmsCount($smsCount) + public function setSmsCount(?int $smsCount): self { - $this->container['smsCount'] = $smsCount; - + $this->smsCount = $smsCount; return $this; } - /** - * Gets text - * - * @return string|null - */ - public function getText() + public function getText(): string|null { - return $this->container['text']; + return $this->text; } - /** - * Sets text - * - * @param string|null $text Full content of the message. - * - * @return self - */ - public function setText($text) + public function setText(?string $text): self { - $this->container['text'] = $text; - + $this->text = $text; return $this; } - /** - * Gets to - * - * @return string|null - */ - public function getTo() + public function getTo(): string|null { - return $this->container['to']; + return $this->to; } - /** - * Sets to - * - * @param string|null $to The destination address of the message. - * - * @return self - */ - public function setTo($to) + public function setTo(?string $to): self { - $this->container['to'] = $to; - + $this->to = $to; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/SmsInboundMessageResult.php b/Infobip/Model/SmsInboundMessageResult.php index ca396e3..f33543e 100644 --- a/Infobip/Model/SmsInboundMessageResult.php +++ b/Infobip/Model/SmsInboundMessageResult.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class SmsInboundMessageResult implements ModelInterface, ArrayAccess, \JsonSerializable +class SmsInboundMessageResult implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'SmsInboundMessageResult'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'messageCount' => 'int', - 'pendingMessageCount' => 'int', - 'results' => '\Infobip\Model\SmsInboundMessage[]' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'SmsInboundMessageResult'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'messageCount' => 'int32', 'pendingMessageCount' => 'int32', 'results' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array + * @param \Infobip\Model\SmsInboundMessage[] $results */ - public static function openAPITypes() - { - return self::$openAPITypes; + public function __construct( + protected ?int $messageCount = null, + protected ?int $pendingMessageCount = null, + protected ?array $results = null, + ) { } - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() + #[Ignore] + public function getModelName(): string { - return self::$openAPIFormats; + return self::OPENAPI_MODEL_NAME; } - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'messageCount' => 'messageCount', - 'pendingMessageCount' => 'pendingMessageCount', - 'results' => 'results' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'messageCount' => 'setMessageCount', - 'pendingMessageCount' => 'setPendingMessageCount', - 'results' => 'setResults' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'messageCount' => 'getMessageCount', - 'pendingMessageCount' => 'getPendingMessageCount', - 'results' => 'getResults' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$setters; + return self::DISCRIMINATOR; } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() + public function getMessageCount(): int|null { - return self::$openAPIModelName; + return $this->messageCount; } - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['messageCount'] = $data['messageCount'] ?? null; - $this->container['pendingMessageCount'] = $data['pendingMessageCount'] ?? null; - $this->container['results'] = $data['results'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + public function setMessageCount(?int $messageCount): self { - $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() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets messageCount - * - * @return int|null - */ - public function getMessageCount() - { - return $this->container['messageCount']; - } - - /** - * Sets messageCount - * - * @param int|null $messageCount The number of messages returned in the `results` array. - * - * @return self - */ - public function setMessageCount($messageCount) - { - $this->container['messageCount'] = $messageCount; - + $this->messageCount = $messageCount; return $this; } - /** - * Gets pendingMessageCount - * - * @return int|null - */ - public function getPendingMessageCount() + public function getPendingMessageCount(): int|null { - return $this->container['pendingMessageCount']; + return $this->pendingMessageCount; } - /** - * Sets pendingMessageCount - * - * @param int|null $pendingMessageCount The number of messages that have not been pulled in. - * - * @return self - */ - public function setPendingMessageCount($pendingMessageCount) + public function setPendingMessageCount(?int $pendingMessageCount): self { - $this->container['pendingMessageCount'] = $pendingMessageCount; - + $this->pendingMessageCount = $pendingMessageCount; return $this; } /** - * Gets results - * * @return \Infobip\Model\SmsInboundMessage[]|null */ - public function getResults() + public function getResults(): ?array { - return $this->container['results']; + return $this->results; } /** - * Sets results - * * @param \Infobip\Model\SmsInboundMessage[]|null $results An array of result objects. - * - * @return self */ - public function setResults($results) + public function setResults(?array $results): self { - $this->container['results'] = $results; - + $this->results = $results; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/SmsIndiaDltOptions.php b/Infobip/Model/SmsIndiaDltOptions.php index 89ee444..678d6ec 100644 --- a/Infobip/Model/SmsIndiaDltOptions.php +++ b/Infobip/Model/SmsIndiaDltOptions.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class SmsIndiaDltOptions implements ModelInterface, ArrayAccess, \JsonSerializable +class SmsIndiaDltOptions implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'SmsIndiaDltOptions'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'contentTemplateId' => 'string', - 'principalEntityId' => 'string' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'SmsIndiaDltOptions'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'contentTemplateId' => null, 'principalEntityId' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'contentTemplateId' => 'contentTemplateId', - 'principalEntityId' => 'principalEntityId' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'contentTemplateId' => 'setContentTemplateId', - 'principalEntityId' => 'setPrincipalEntityId' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] */ - protected static $getters = [ - 'contentTemplateId' => 'getContentTemplateId', - 'principalEntityId' => 'getPrincipalEntityId' - ]; + public function __construct( + #[Assert\NotBlank] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; + protected string $principalEntityId, + protected ?string $contentTemplateId = null, + ) { } - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() + #[Ignore] + public function getModelName(): string { - return self::$setters; + return self::OPENAPI_MODEL_NAME; } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$getters; + return self::DISCRIMINATOR; } - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() + public function getContentTemplateId(): string|null { - return self::$openAPIModelName; + return $this->contentTemplateId; } - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['contentTemplateId'] = $data['contentTemplateId'] ?? null; - $this->container['principalEntityId'] = $data['principalEntityId'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + public function setContentTemplateId(?string $contentTemplateId): self { - $invalidProperties = []; - - if ($this->container['principalEntityId'] === null) { - $invalidProperties[] = "'principalEntityId' can't be null"; - } - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets contentTemplateId - * - * @return string|null - */ - public function getContentTemplateId() - { - return $this->container['contentTemplateId']; - } - - /** - * Sets contentTemplateId - * - * @param string|null $contentTemplateId Registered DLT content template ID which matches message you are sending. - * - * @return self - */ - public function setContentTemplateId($contentTemplateId) - { - $this->container['contentTemplateId'] = $contentTemplateId; - + $this->contentTemplateId = $contentTemplateId; return $this; } - /** - * Gets principalEntityId - * - * @return string - */ - public function getPrincipalEntityId() + public function getPrincipalEntityId(): string { - return $this->container['principalEntityId']; + return $this->principalEntityId; } - /** - * Sets principalEntityId - * - * @param string $principalEntityId Your assigned DLT principal entity ID. - * - * @return self - */ - public function setPrincipalEntityId($principalEntityId) + public function setPrincipalEntityId(string $principalEntityId): self { - $this->container['principalEntityId'] = $principalEntityId; - + $this->principalEntityId = $principalEntityId; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/SmsLanguage.php b/Infobip/Model/SmsLanguage.php index 3c42a94..289df32 100644 --- a/Infobip/Model/SmsLanguage.php +++ b/Infobip/Model/SmsLanguage.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class SmsLanguage implements ModelInterface, ArrayAccess, \JsonSerializable +class SmsLanguage implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'SmsLanguage'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'languageCode' => 'string' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'SmsLanguage'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'languageCode' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'languageCode' => 'languageCode' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'languageCode' => 'setLanguageCode' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'languageCode' => 'getLanguageCode' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array */ - public static function attributeMap() - { - return self::$attributeMap; + public function __construct( + protected ?string $languageCode = null, + ) { } - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() + #[Ignore] + public function getModelName(): string { - return self::$setters; + return self::OPENAPI_MODEL_NAME; } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$getters; + return self::DISCRIMINATOR; } - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() + public function getLanguageCode(): string|null { - return self::$openAPIModelName; + return $this->languageCode; } - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) + public function setLanguageCode(?string $languageCode): self { - $this->container['languageCode'] = $data['languageCode'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $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() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets languageCode - * - * @return string|null - */ - public function getLanguageCode() - { - return $this->container['languageCode']; - } - - /** - * Sets languageCode - * - * @param string|null $languageCode Language code for the correct character set. Possible values: `TR` for Turkish, `ES` for Spanish, `PT` for Portuguese, or `AUTODETECT` to let platform select the character set based on message content. - * - * @return self - */ - public function setLanguageCode($languageCode) - { - $this->container['languageCode'] = $languageCode; - + $this->languageCode = $languageCode; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/SmsLanguageConfiguration.php b/Infobip/Model/SmsLanguageConfiguration.php index ca8ae3a..69fa8fb 100644 --- a/Infobip/Model/SmsLanguageConfiguration.php +++ b/Infobip/Model/SmsLanguageConfiguration.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class SmsLanguageConfiguration implements ModelInterface, ArrayAccess, \JsonSerializable +class SmsLanguageConfiguration implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'SmsLanguageConfiguration'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'language' => '\Infobip\Model\SmsLanguage', - 'transliteration' => 'string' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'SmsLanguageConfiguration'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'language' => null, 'transliteration' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'language' => 'language', - 'transliteration' => 'transliteration' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'language' => 'setLanguage', - 'transliteration' => 'setTransliteration' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] */ - protected static $getters = [ - 'language' => 'getLanguage', - 'transliteration' => 'getTransliteration' - ]; + public function __construct( + #[Assert\Valid] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; + protected ?\Infobip\Model\SmsLanguage $language = null, + protected ?string $transliteration = null, + ) { } - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() + #[Ignore] + public function getModelName(): string { - return self::$setters; + return self::OPENAPI_MODEL_NAME; } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$getters; + return self::DISCRIMINATOR; } - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() + public function getLanguage(): \Infobip\Model\SmsLanguage|null { - return self::$openAPIModelName; + return $this->language; } - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['language'] = $data['language'] ?? null; - $this->container['transliteration'] = $data['transliteration'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + public function setLanguage(?\Infobip\Model\SmsLanguage $language): self { - $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() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets language - * - * @return \Infobip\Model\SmsLanguage|null - */ - public function getLanguage() - { - return $this->container['language']; - } - - /** - * Sets language - * - * @param \Infobip\Model\SmsLanguage|null $language language - * - * @return self - */ - public function setLanguage($language) - { - $this->container['language'] = $language; - + $this->language = $language; return $this; } - /** - * Gets transliteration - * - * @return string|null - */ - public function getTransliteration() + public function getTransliteration(): string|null { - return $this->container['transliteration']; + return $this->transliteration; } - /** - * Sets transliteration - * - * @param string|null $transliteration Conversion of a message text from one script to another. Possible values: `TURKISH`, `GREEK`, `CYRILLIC`, `SERBIAN_CYRILLIC`, `CENTRAL_EUROPEAN`, `BALTIC` and `NON_UNICODE`. - * - * @return self - */ - public function setTransliteration($transliteration) + public function setTransliteration(?string $transliteration): self { - $this->container['transliteration'] = $transliteration; - + $this->transliteration = $transliteration; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/SmsLog.php b/Infobip/Model/SmsLog.php index 3917900..6b7022f 100644 --- a/Infobip/Model/SmsLog.php +++ b/Infobip/Model/SmsLog.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class SmsLog implements ModelInterface, ArrayAccess, \JsonSerializable +class SmsLog implements ModelInterface { - public const DISCRIMINATOR = null; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'SmsLog'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'SmsLog'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'bulkId' => 'string', - 'doneAt' => '\DateTime', - 'error' => '\Infobip\Model\SmsError', - 'from' => 'string', - 'mccMnc' => 'string', - 'messageId' => 'string', - 'price' => '\Infobip\Model\SmsPrice', - 'sentAt' => '\DateTime', - 'smsCount' => 'int', - 'status' => '\Infobip\Model\SmsStatus', - 'text' => 'string', - 'to' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'bulkId' => null, 'doneAt' => 'date-time', 'error' => null, @@ -91,556 +45,174 @@ class SmsLog implements ModelInterface, ArrayAccess, \JsonSerializable ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array */ - public static function openAPITypes() - { - return self::$openAPITypes; - } + public function __construct( + protected ?string $bulkId = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } + protected ?\DateTime $doneAt = null, + #[Assert\Valid] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'bulkId' => 'bulkId', - 'doneAt' => 'doneAt', - 'error' => 'error', - 'from' => 'from', - 'mccMnc' => 'mccMnc', - 'messageId' => 'messageId', - 'price' => 'price', - 'sentAt' => 'sentAt', - 'smsCount' => 'smsCount', - 'status' => 'status', - 'text' => 'text', - 'to' => 'to' - ]; + protected ?\Infobip\Model\SmsError $error = null, + protected ?string $from = null, + protected ?string $mccMnc = null, + protected ?string $messageId = null, + #[Assert\Valid] - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'bulkId' => 'setBulkId', - 'doneAt' => 'setDoneAt', - 'error' => 'setError', - 'from' => 'setFrom', - 'mccMnc' => 'setMccMnc', - 'messageId' => 'setMessageId', - 'price' => 'setPrice', - 'sentAt' => 'setSentAt', - 'smsCount' => 'setSmsCount', - 'status' => 'setStatus', - 'text' => 'setText', - 'to' => 'setTo' - ]; + protected ?\Infobip\Model\SmsPrice $price = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'bulkId' => 'getBulkId', - 'doneAt' => 'getDoneAt', - 'error' => 'getError', - 'from' => 'getFrom', - 'mccMnc' => 'getMccMnc', - 'messageId' => 'getMessageId', - 'price' => 'getPrice', - 'sentAt' => 'getSentAt', - 'smsCount' => 'getSmsCount', - 'status' => 'getStatus', - 'text' => 'getText', - 'to' => 'getTo' - ]; + protected ?\DateTime $sentAt = null, + protected ?int $smsCount = null, + #[Assert\Valid] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; + protected ?\Infobip\Model\SmsStatus $status = null, + protected ?string $text = null, + protected ?string $to = null, + ) { } - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() + #[Ignore] + public function getModelName(): string { - return self::$setters; + return self::OPENAPI_MODEL_NAME; } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$getters; + return self::DISCRIMINATOR; } - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() + public function getBulkId(): string|null { - return self::$openAPIModelName; + return $this->bulkId; } - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['bulkId'] = $data['bulkId'] ?? null; - $this->container['doneAt'] = $data['doneAt'] ?? null; - $this->container['error'] = $data['error'] ?? null; - $this->container['from'] = $data['from'] ?? null; - $this->container['mccMnc'] = $data['mccMnc'] ?? null; - $this->container['messageId'] = $data['messageId'] ?? null; - $this->container['price'] = $data['price'] ?? null; - $this->container['sentAt'] = $data['sentAt'] ?? null; - $this->container['smsCount'] = $data['smsCount'] ?? null; - $this->container['status'] = $data['status'] ?? null; - $this->container['text'] = $data['text'] ?? null; - $this->container['to'] = $data['to'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $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() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets bulkId - * - * @return string|null - */ - public function getBulkId() - { - return $this->container['bulkId']; - } - - /** - * Sets bulkId - * - * @param string|null $bulkId Unique ID assigned to the request if messaging multiple recipients or sending multiple messages via a single API request. - * - * @return self - */ - public function setBulkId($bulkId) + public function setBulkId(?string $bulkId): self { - $this->container['bulkId'] = $bulkId; - + $this->bulkId = $bulkId; return $this; } - /** - * Gets doneAt - * - * @return \DateTime|null - */ - public function getDoneAt() + public function getDoneAt(): \DateTime|null { - return $this->container['doneAt']; + return $this->doneAt; } - /** - * Sets doneAt - * - * @param \DateTime|null $doneAt Date and time when the Infobip services finished processing the message (i.e. delivered to the destination, delivered to the destination network, etc.). Has the following format: `yyyy-MM-dd'T'HH:mm:ss.SSSZ`. - * - * @return self - */ - public function setDoneAt($doneAt) + public function setDoneAt(?\DateTime $doneAt): self { - $this->container['doneAt'] = $doneAt; - + $this->doneAt = $doneAt; return $this; } - /** - * Gets error - * - * @return \Infobip\Model\SmsError|null - */ - public function getError() + public function getError(): \Infobip\Model\SmsError|null { - return $this->container['error']; + return $this->error; } - /** - * Sets error - * - * @param \Infobip\Model\SmsError|null $error error - * - * @return self - */ - public function setError($error) + public function setError(?\Infobip\Model\SmsError $error): self { - $this->container['error'] = $error; - + $this->error = $error; return $this; } - /** - * Gets from - * - * @return string|null - */ - public function getFrom() + public function getFrom(): string|null { - return $this->container['from']; + return $this->from; } - /** - * Sets from - * - * @param string|null $from Sender ID that can be alphanumeric or numeric. - * - * @return self - */ - public function setFrom($from) + public function setFrom(?string $from): self { - $this->container['from'] = $from; - + $this->from = $from; return $this; } - /** - * Gets mccMnc - * - * @return string|null - */ - public function getMccMnc() + public function getMccMnc(): string|null { - return $this->container['mccMnc']; + return $this->mccMnc; } - /** - * Sets mccMnc - * - * @param string|null $mccMnc Mobile country and network codes. - * - * @return self - */ - public function setMccMnc($mccMnc) + public function setMccMnc(?string $mccMnc): self { - $this->container['mccMnc'] = $mccMnc; - + $this->mccMnc = $mccMnc; return $this; } - /** - * Gets messageId - * - * @return string|null - */ - public function getMessageId() + public function getMessageId(): string|null { - return $this->container['messageId']; + return $this->messageId; } - /** - * Sets messageId - * - * @param string|null $messageId Unique message ID. - * - * @return self - */ - public function setMessageId($messageId) + public function setMessageId(?string $messageId): self { - $this->container['messageId'] = $messageId; - + $this->messageId = $messageId; return $this; } - /** - * Gets price - * - * @return \Infobip\Model\SmsPrice|null - */ - public function getPrice() + public function getPrice(): \Infobip\Model\SmsPrice|null { - return $this->container['price']; + return $this->price; } - /** - * Sets price - * - * @param \Infobip\Model\SmsPrice|null $price price - * - * @return self - */ - public function setPrice($price) + public function setPrice(?\Infobip\Model\SmsPrice $price): self { - $this->container['price'] = $price; - + $this->price = $price; return $this; } - /** - * Gets sentAt - * - * @return \DateTime|null - */ - public function getSentAt() + public function getSentAt(): \DateTime|null { - return $this->container['sentAt']; + return $this->sentAt; } - /** - * Sets sentAt - * - * @param \DateTime|null $sentAt Date and time when the message was [scheduled](https://www.infobip.com/docs/api#channels/sms/get-scheduled-sms-messages) to be sent. Has the following format: `yyyy-MM-dd'T'HH:mm:ss.SSSZ`. - * - * @return self - */ - public function setSentAt($sentAt) + public function setSentAt(?\DateTime $sentAt): self { - $this->container['sentAt'] = $sentAt; - + $this->sentAt = $sentAt; return $this; } - /** - * Gets smsCount - * - * @return int|null - */ - public function getSmsCount() + public function getSmsCount(): int|null { - return $this->container['smsCount']; + return $this->smsCount; } - /** - * Sets smsCount - * - * @param int|null $smsCount The number of parts the message content was split into. - * - * @return self - */ - public function setSmsCount($smsCount) + public function setSmsCount(?int $smsCount): self { - $this->container['smsCount'] = $smsCount; - + $this->smsCount = $smsCount; return $this; } - /** - * Gets status - * - * @return \Infobip\Model\SmsStatus|null - */ - public function getStatus() + public function getStatus(): \Infobip\Model\SmsStatus|null { - return $this->container['status']; + return $this->status; } - /** - * Sets status - * - * @param \Infobip\Model\SmsStatus|null $status status - * - * @return self - */ - public function setStatus($status) + public function setStatus(?\Infobip\Model\SmsStatus $status): self { - $this->container['status'] = $status; - + $this->status = $status; return $this; } - /** - * Gets text - * - * @return string|null - */ - public function getText() + public function getText(): string|null { - return $this->container['text']; + return $this->text; } - /** - * Sets text - * - * @param string|null $text Content of the message being sent. - * - * @return self - */ - public function setText($text) + public function setText(?string $text): self { - $this->container['text'] = $text; - + $this->text = $text; return $this; } - /** - * Gets to - * - * @return string|null - */ - public function getTo() + public function getTo(): string|null { - return $this->container['to']; + return $this->to; } - /** - * Sets to - * - * @param string|null $to The destination address of the message. - * - * @return self - */ - public function setTo($to) + public function setTo(?string $to): self { - $this->container['to'] = $to; - + $this->to = $to; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/SmsLogsResponse.php b/Infobip/Model/SmsLogsResponse.php index 514f1f7..b17bbce 100644 --- a/Infobip/Model/SmsLogsResponse.php +++ b/Infobip/Model/SmsLogsResponse.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class SmsLogsResponse implements ModelInterface, ArrayAccess, \JsonSerializable +class SmsLogsResponse implements ModelInterface { - public const DISCRIMINATOR = null; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'SmsLogsResponse'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'SmsLogsResponse'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'results' => '\Infobip\Model\SmsLog[]' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'results' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'results' => 'results' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'results' => 'setResults' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] + * @param \Infobip\Model\SmsLog[] $results */ - protected static $getters = [ - 'results' => 'getResults' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; + public function __construct( + protected ?array $results = null, + ) { } - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() + #[Ignore] + public function getModelName(): string { - return self::$setters; + return self::OPENAPI_MODEL_NAME; } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$getters; + return self::DISCRIMINATOR; } /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['results'] = $data['results'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $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() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets results - * * @return \Infobip\Model\SmsLog[]|null */ - public function getResults() + public function getResults(): ?array { - return $this->container['results']; + return $this->results; } /** - * Sets results - * * @param \Infobip\Model\SmsLog[]|null $results Collection of logs. - * - * @return self */ - public function setResults($results) + public function setResults(?array $results): self { - $this->container['results'] = $results; - + $this->results = $results; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/SmsPreview.php b/Infobip/Model/SmsPreview.php index 22eeb41..6c0dfc0 100644 --- a/Infobip/Model/SmsPreview.php +++ b/Infobip/Model/SmsPreview.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class SmsPreview implements ModelInterface, ArrayAccess, \JsonSerializable +class SmsPreview implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'SmsPreview'; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'SmsPreview'; - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'charactersRemaining' => 'int', - 'configuration' => '\Infobip\Model\SmsLanguageConfiguration', - 'messageCount' => 'int', - 'textPreview' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'charactersRemaining' => 'int32', - 'configuration' => null, + public const OPENAPI_FORMATS = [ + 'textPreview' => null, 'messageCount' => 'int32', - 'textPreview' => null - ]; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'charactersRemaining' => 'charactersRemaining', - 'configuration' => 'configuration', - 'messageCount' => 'messageCount', - 'textPreview' => 'textPreview' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'charactersRemaining' => 'setCharactersRemaining', - 'configuration' => 'setConfiguration', - 'messageCount' => 'setMessageCount', - 'textPreview' => 'setTextPreview' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'charactersRemaining' => 'getCharactersRemaining', - 'configuration' => 'getConfiguration', - 'messageCount' => 'getMessageCount', - 'textPreview' => 'getTextPreview' + 'charactersRemaining' => 'int32', + 'configuration' => null ]; /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array */ - public static function attributeMap() - { - return self::$attributeMap; - } + public function __construct( + protected ?string $textPreview = null, + protected ?int $messageCount = null, + protected ?int $charactersRemaining = null, + #[Assert\Valid] - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; + protected ?\Infobip\Model\SmsLanguageConfiguration $configuration = null, + ) { } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public function getModelName(): string { - return self::$getters; + return self::OPENAPI_MODEL_NAME; } - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$openAPIModelName; + return self::DISCRIMINATOR; } - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) + public function getTextPreview(): string|null { - $this->container['charactersRemaining'] = $data['charactersRemaining'] ?? null; - $this->container['configuration'] = $data['configuration'] ?? null; - $this->container['messageCount'] = $data['messageCount'] ?? null; - $this->container['textPreview'] = $data['textPreview'] ?? null; + return $this->textPreview; } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + public function setTextPreview(?string $textPreview): self { - $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() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets charactersRemaining - * - * @return int|null - */ - public function getCharactersRemaining() - { - return $this->container['charactersRemaining']; - } - - /** - * Sets charactersRemaining - * - * @param int|null $charactersRemaining Number of remaining characters in the last part of the SMS. - * - * @return self - */ - public function setCharactersRemaining($charactersRemaining) - { - $this->container['charactersRemaining'] = $charactersRemaining; - + $this->textPreview = $textPreview; return $this; } - /** - * Gets configuration - * - * @return \Infobip\Model\SmsLanguageConfiguration|null - */ - public function getConfiguration() + public function getMessageCount(): int|null { - return $this->container['configuration']; + return $this->messageCount; } - /** - * Sets configuration - * - * @param \Infobip\Model\SmsLanguageConfiguration|null $configuration Sets up additional configuration that changes the original message content you can preview with this call. - * - * @return self - */ - public function setConfiguration($configuration) + public function setMessageCount(?int $messageCount): self { - $this->container['configuration'] = $configuration; - + $this->messageCount = $messageCount; return $this; } - /** - * Gets messageCount - * - * @return int|null - */ - public function getMessageCount() + public function getCharactersRemaining(): int|null { - return $this->container['messageCount']; + return $this->charactersRemaining; } - /** - * Sets messageCount - * - * @param int|null $messageCount Number of SMS message parts required to deliver the message. - * - * @return self - */ - public function setMessageCount($messageCount) + public function setCharactersRemaining(?int $charactersRemaining): self { - $this->container['messageCount'] = $messageCount; - + $this->charactersRemaining = $charactersRemaining; return $this; } - /** - * Gets textPreview - * - * @return string|null - */ - public function getTextPreview() + public function getConfiguration(): \Infobip\Model\SmsLanguageConfiguration|null { - return $this->container['textPreview']; + return $this->configuration; } - /** - * Sets textPreview - * - * @param string|null $textPreview Preview of the message content as it should appear on the recipient’s device. - * - * @return self - */ - public function setTextPreview($textPreview) + public function setConfiguration(?\Infobip\Model\SmsLanguageConfiguration $configuration): self { - $this->container['textPreview'] = $textPreview; - + $this->configuration = $configuration; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/SmsPreviewRequest.php b/Infobip/Model/SmsPreviewRequest.php index f6e4c6b..bea8835 100644 --- a/Infobip/Model/SmsPreviewRequest.php +++ b/Infobip/Model/SmsPreviewRequest.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class SmsPreviewRequest implements ModelInterface, ArrayAccess, \JsonSerializable +class SmsPreviewRequest implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'SmsPreviewRequest'; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'SmsPreviewRequest'; - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'languageCode' => 'string', - 'text' => 'string', - 'transliteration' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'languageCode' => null, + public const OPENAPI_FORMATS = [ 'text' => null, + 'languageCode' => null, 'transliteration' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'languageCode' => 'languageCode', - 'text' => 'text', - 'transliteration' => 'transliteration' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'languageCode' => 'setLanguageCode', - 'text' => 'setText', - 'transliteration' => 'setTransliteration' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'languageCode' => 'getLanguageCode', - 'text' => 'getText', - 'transliteration' => 'getTransliteration' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array */ - public static function attributeMap() - { - return self::$attributeMap; - } + public function __construct( + #[Assert\NotBlank] - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } + protected string $text, + #[Assert\Regex('/^(TR|ES|PT|AUTODETECT)$/')] - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; + protected ?string $languageCode = null, + #[Assert\Regex('/^(TURKISH|GREEK|CYRILLIC|SERBIAN_CYRILLIC|BULGARIAN_CYRILLIC|CENTRAL_EUROPEAN|BALTIC|NON_UNICODE)$/')] - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['languageCode'] = $data['languageCode'] ?? null; - $this->container['text'] = $data['text'] ?? null; - $this->container['transliteration'] = $data['transliteration'] ?? null; + protected ?string $transliteration = null, + ) { } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - if (!is_null($this->container['languageCode']) && !preg_match("/^(TR|ES|PT|AUTODETECT)$/", $this->container['languageCode'])) { - $invalidProperties[] = "invalid value for 'languageCode', must be conform to the pattern /^(TR|ES|PT|AUTODETECT)$/."; - } - - if ($this->container['text'] === null) { - $invalidProperties[] = "'text' can't be null"; - } - if (!is_null($this->container['transliteration']) && !preg_match("/^(TURKISH|GREEK|CYRILLIC|SERBIAN_CYRILLIC|CENTRAL_EUROPEAN|BALTIC|NON_UNICODE)$/", $this->container['transliteration'])) { - $invalidProperties[] = "invalid value for 'transliteration', must be conform to the pattern /^(TURKISH|GREEK|CYRILLIC|SERBIAN_CYRILLIC|CENTRAL_EUROPEAN|BALTIC|NON_UNICODE)$/."; - } - - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets languageCode - * - * @return string|null - */ - public function getLanguageCode() + public function getText(): string { - return $this->container['languageCode']; + return $this->text; } - /** - * Sets languageCode - * - * @param string|null $languageCode Language code for the correct character set. Possible values: `TR` for Turkish, `ES` for Spanish, `PT` for Portuguese, or `AUTODETECT` to let platform select the character set based on message content. - * - * @return self - */ - public function setLanguageCode($languageCode) + public function setText(string $text): self { - if (!is_null($languageCode) && (!preg_match("/^(TR|ES|PT|AUTODETECT)$/", $languageCode))) { - throw new \InvalidArgumentException("invalid value for $languageCode when calling SmsPreviewRequest., must conform to the pattern /^(TR|ES|PT|AUTODETECT)$/."); - } - - $this->container['languageCode'] = $languageCode; - + $this->text = $text; return $this; } - /** - * Gets text - * - * @return string - */ - public function getText() + public function getLanguageCode(): string|null { - return $this->container['text']; + return $this->languageCode; } - /** - * Sets text - * - * @param string $text Content of the message being sent. - * - * @return self - */ - public function setText($text) + public function setLanguageCode(?string $languageCode): self { - $this->container['text'] = $text; - + $this->languageCode = $languageCode; return $this; } - /** - * Gets transliteration - * - * @return string|null - */ - public function getTransliteration() + public function getTransliteration(): string|null { - return $this->container['transliteration']; + return $this->transliteration; } - /** - * Sets transliteration - * - * @param string|null $transliteration The transliteration of your sent message from one script to another. Transliteration is used to replace characters which are not recognized as part of your defaulted alphabet. Possible values: `TURKISH`, `GREEK`, `CYRILLIC`, `SERBIAN_CYRILLIC`, `CENTRAL_EUROPEAN`, `BALTIC` and `NON_UNICODE`. - * - * @return self - */ - public function setTransliteration($transliteration) + public function setTransliteration(?string $transliteration): self { - if (!is_null($transliteration) && (!preg_match("/^(TURKISH|GREEK|CYRILLIC|SERBIAN_CYRILLIC|CENTRAL_EUROPEAN|BALTIC|NON_UNICODE)$/", $transliteration))) { - throw new \InvalidArgumentException("invalid value for $transliteration when calling SmsPreviewRequest., must conform to the pattern /^(TURKISH|GREEK|CYRILLIC|SERBIAN_CYRILLIC|CENTRAL_EUROPEAN|BALTIC|NON_UNICODE)$/."); - } - - $this->container['transliteration'] = $transliteration; - + $this->transliteration = $transliteration; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/SmsPreviewResponse.php b/Infobip/Model/SmsPreviewResponse.php index d2004dd..1eef2b1 100644 --- a/Infobip/Model/SmsPreviewResponse.php +++ b/Infobip/Model/SmsPreviewResponse.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class SmsPreviewResponse implements ModelInterface, ArrayAccess, \JsonSerializable +class SmsPreviewResponse implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'SmsPreviewResponse'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'originalText' => 'string', - 'previews' => '\Infobip\Model\SmsPreview[]' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'SmsPreviewResponse'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'originalText' => null, 'previews' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'originalText' => 'originalText', - 'previews' => 'previews' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'originalText' => 'setOriginalText', - 'previews' => 'setPreviews' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'originalText' => 'getOriginalText', - 'previews' => 'getPreviews' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model + * @param \Infobip\Model\SmsPreview[] $previews */ - public function __construct(array $data = null) - { - $this->container['originalText'] = $data['originalText'] ?? null; - $this->container['previews'] = $data['previews'] ?? null; + public function __construct( + protected ?string $originalText = null, + protected ?array $previews = null, + ) { } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets originalText - * - * @return string|null - */ - public function getOriginalText() + public function getOriginalText(): string|null { - return $this->container['originalText']; + return $this->originalText; } - /** - * Sets originalText - * - * @param string|null $originalText Message content supplied in the request. - * - * @return self - */ - public function setOriginalText($originalText) + public function setOriginalText(?string $originalText): self { - $this->container['originalText'] = $originalText; - + $this->originalText = $originalText; return $this; } /** - * Gets previews - * * @return \Infobip\Model\SmsPreview[]|null */ - public function getPreviews() + public function getPreviews(): ?array { - return $this->container['previews']; + return $this->previews; } /** - * Sets previews - * * @param \Infobip\Model\SmsPreview[]|null $previews Allows for previewing the original message content once additional language configuration has been applied to it. - * - * @return self */ - public function setPreviews($previews) + public function setPreviews(?array $previews): self { - $this->container['previews'] = $previews; - + $this->previews = $previews; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/SmsPrice.php b/Infobip/Model/SmsPrice.php index 3e4a079..2346262 100644 --- a/Infobip/Model/SmsPrice.php +++ b/Infobip/Model/SmsPrice.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class SmsPrice implements ModelInterface, ArrayAccess, \JsonSerializable +class SmsPrice implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'SmsPrice'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'currency' => 'string', - 'pricePerMessage' => 'double' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'currency' => null, - 'pricePerMessage' => 'double' - ]; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'currency' => 'currency', - 'pricePerMessage' => 'pricePerMessage' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'SmsPrice'; - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'currency' => 'setCurrency', - 'pricePerMessage' => 'setPricePerMessage' + public const OPENAPI_FORMATS = [ + 'pricePerMessage' => null, + 'currency' => null ]; /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'currency' => 'getCurrency', - 'pricePerMessage' => 'getPricePerMessage' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['currency'] = $data['currency'] ?? null; - $this->container['pricePerMessage'] = $data['pricePerMessage'] ?? null; + public function __construct( + protected ?float $pricePerMessage = null, + protected ?string $currency = null, + ) { } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets currency - * - * @return string|null - */ - public function getCurrency() + public function getPricePerMessage(): float|null { - return $this->container['currency']; + return $this->pricePerMessage; } - /** - * Sets currency - * - * @param string|null $currency The currency in which the price is expressed. - * - * @return self - */ - public function setCurrency($currency) + public function setPricePerMessage(?float $pricePerMessage): self { - $this->container['currency'] = $currency; - + $this->pricePerMessage = $pricePerMessage; return $this; } - /** - * Gets pricePerMessage - * - * @return double|null - */ - public function getPricePerMessage() + public function getCurrency(): string|null { - return $this->container['pricePerMessage']; + return $this->currency; } - /** - * Sets pricePerMessage - * - * @param double|null $pricePerMessage Price per one SMS. - * - * @return self - */ - public function setPricePerMessage($pricePerMessage) + public function setCurrency(?string $currency): self { - $this->container['pricePerMessage'] = $pricePerMessage; - + $this->currency = $currency; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/SmsRegionalOptions.php b/Infobip/Model/SmsRegionalOptions.php index 181730e..c572e08 100644 --- a/Infobip/Model/SmsRegionalOptions.php +++ b/Infobip/Model/SmsRegionalOptions.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class SmsRegionalOptions implements ModelInterface, ArrayAccess, \JsonSerializable +class SmsRegionalOptions implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'SmsRegionalOptions'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'indiaDlt' => '\Infobip\Model\SmsIndiaDltOptions', - 'turkeyIys' => '\Infobip\Model\SmsTurkeyIysOptions' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'SmsRegionalOptions'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'indiaDlt' => null, 'turkeyIys' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] */ - protected static $attributeMap = [ - 'indiaDlt' => 'indiaDlt', - 'turkeyIys' => 'turkeyIys' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'indiaDlt' => 'setIndiaDlt', - 'turkeyIys' => 'setTurkeyIys' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'indiaDlt' => 'getIndiaDlt', - 'turkeyIys' => 'getTurkeyIys' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - + public function __construct( + #[Assert\Valid] + protected ?\Infobip\Model\SmsIndiaDltOptions $indiaDlt = null, + #[Assert\Valid] - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['indiaDlt'] = $data['indiaDlt'] ?? null; - $this->container['turkeyIys'] = $data['turkeyIys'] ?? null; + protected ?\Infobip\Model\SmsTurkeyIysOptions $turkeyIys = null, + ) { } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets indiaDlt - * - * @return \Infobip\Model\SmsIndiaDltOptions|null - */ - public function getIndiaDlt() + public function getIndiaDlt(): \Infobip\Model\SmsIndiaDltOptions|null { - return $this->container['indiaDlt']; + return $this->indiaDlt; } - /** - * Sets indiaDlt - * - * @param \Infobip\Model\SmsIndiaDltOptions|null $indiaDlt indiaDlt - * - * @return self - */ - public function setIndiaDlt($indiaDlt) + public function setIndiaDlt(?\Infobip\Model\SmsIndiaDltOptions $indiaDlt): self { - $this->container['indiaDlt'] = $indiaDlt; - + $this->indiaDlt = $indiaDlt; return $this; } - /** - * Gets turkeyIys - * - * @return \Infobip\Model\SmsTurkeyIysOptions|null - */ - public function getTurkeyIys() + public function getTurkeyIys(): \Infobip\Model\SmsTurkeyIysOptions|null { - return $this->container['turkeyIys']; + return $this->turkeyIys; } - /** - * Sets turkeyIys - * - * @param \Infobip\Model\SmsTurkeyIysOptions|null $turkeyIys turkeyIys - * - * @return self - */ - public function setTurkeyIys($turkeyIys) + public function setTurkeyIys(?\Infobip\Model\SmsTurkeyIysOptions $turkeyIys): self { - $this->container['turkeyIys'] = $turkeyIys; - + $this->turkeyIys = $turkeyIys; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/SmsReport.php b/Infobip/Model/SmsReport.php index 6b73577..fd8479e 100644 --- a/Infobip/Model/SmsReport.php +++ b/Infobip/Model/SmsReport.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class SmsReport implements ModelInterface, ArrayAccess, \JsonSerializable +class SmsReport implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'SmsReport'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'bulkId' => 'string', - 'callbackData' => 'string', - 'doneAt' => '\DateTime', - 'error' => '\Infobip\Model\SmsError', - 'from' => 'string', - 'mccMnc' => 'string', - 'messageId' => 'string', - 'price' => '\Infobip\Model\SmsPrice', - 'sentAt' => '\DateTime', - 'smsCount' => 'int', - 'status' => '\Infobip\Model\SmsStatus', - 'to' => 'string' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'SmsReport'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'bulkId' => null, - 'callbackData' => null, - 'doneAt' => 'date-time', - 'error' => null, - 'from' => null, - 'mccMnc' => null, 'messageId' => null, - 'price' => null, + 'to' => null, + 'from' => null, 'sentAt' => 'date-time', + 'doneAt' => 'date-time', 'smsCount' => 'int32', + 'mccMnc' => null, + 'callbackData' => null, + 'price' => null, 'status' => null, - 'to' => null - ]; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'bulkId' => 'bulkId', - 'callbackData' => 'callbackData', - 'doneAt' => 'doneAt', - 'error' => 'error', - 'from' => 'from', - 'mccMnc' => 'mccMnc', - 'messageId' => 'messageId', - 'price' => 'price', - 'sentAt' => 'sentAt', - 'smsCount' => 'smsCount', - 'status' => 'status', - 'to' => 'to' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'bulkId' => 'setBulkId', - 'callbackData' => 'setCallbackData', - 'doneAt' => 'setDoneAt', - 'error' => 'setError', - 'from' => 'setFrom', - 'mccMnc' => 'setMccMnc', - 'messageId' => 'setMessageId', - 'price' => 'setPrice', - 'sentAt' => 'setSentAt', - 'smsCount' => 'setSmsCount', - 'status' => 'setStatus', - 'to' => 'setTo' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'bulkId' => 'getBulkId', - 'callbackData' => 'getCallbackData', - 'doneAt' => 'getDoneAt', - 'error' => 'getError', - 'from' => 'getFrom', - 'mccMnc' => 'getMccMnc', - 'messageId' => 'getMessageId', - 'price' => 'getPrice', - 'sentAt' => 'getSentAt', - 'smsCount' => 'getSmsCount', - 'status' => 'getStatus', - 'to' => 'getTo' + 'error' => null ]; /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } + public function __construct( + protected ?string $bulkId = null, + protected ?string $messageId = null, + protected ?string $to = null, + protected ?string $from = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + protected ?\DateTime $sentAt = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + protected ?\DateTime $doneAt = null, + protected ?int $smsCount = null, + protected ?string $mccMnc = null, + protected ?string $callbackData = null, + #[Assert\Valid] + protected ?\Infobip\Model\SmsPrice $price = null, + #[Assert\Valid] + protected ?\Infobip\Model\SmsStatus $status = null, + #[Assert\Valid] - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['bulkId'] = $data['bulkId'] ?? null; - $this->container['callbackData'] = $data['callbackData'] ?? null; - $this->container['doneAt'] = $data['doneAt'] ?? null; - $this->container['error'] = $data['error'] ?? null; - $this->container['from'] = $data['from'] ?? null; - $this->container['mccMnc'] = $data['mccMnc'] ?? null; - $this->container['messageId'] = $data['messageId'] ?? null; - $this->container['price'] = $data['price'] ?? null; - $this->container['sentAt'] = $data['sentAt'] ?? null; - $this->container['smsCount'] = $data['smsCount'] ?? null; - $this->container['status'] = $data['status'] ?? null; - $this->container['to'] = $data['to'] ?? null; + protected ?\Infobip\Model\SmsError $error = null, + ) { } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets bulkId - * - * @return string|null - */ - public function getBulkId() + public function getBulkId(): string|null { - return $this->container['bulkId']; + return $this->bulkId; } - /** - * Sets bulkId - * - * @param string|null $bulkId Unique ID assigned to the request if messaging multiple recipients or sending multiple messages via a single API request. - * - * @return self - */ - public function setBulkId($bulkId) + public function setBulkId(?string $bulkId): self { - $this->container['bulkId'] = $bulkId; - + $this->bulkId = $bulkId; return $this; } - /** - * Gets callbackData - * - * @return string|null - */ - public function getCallbackData() + public function getMessageId(): string|null { - return $this->container['callbackData']; + return $this->messageId; } - /** - * Sets callbackData - * - * @param string|null $callbackData Custom data sent over to the `notifyUrl`. - * - * @return self - */ - public function setCallbackData($callbackData) + public function setMessageId(?string $messageId): self { - $this->container['callbackData'] = $callbackData; - + $this->messageId = $messageId; return $this; } - /** - * Gets doneAt - * - * @return \DateTime|null - */ - public function getDoneAt() + public function getTo(): string|null { - return $this->container['doneAt']; + return $this->to; } - /** - * Sets doneAt - * - * @param \DateTime|null $doneAt Date and time when the Infobip services finished processing the message (i.e., delivered to the destination, delivered to the destination network, etc.). Has the following format: `yyyy-MM-dd'T'HH:mm:ss.SSSZ`. - * - * @return self - */ - public function setDoneAt($doneAt) + public function setTo(?string $to): self { - $this->container['doneAt'] = $doneAt; - + $this->to = $to; return $this; } - /** - * Gets error - * - * @return \Infobip\Model\SmsError|null - */ - public function getError() + public function getFrom(): string|null { - return $this->container['error']; + return $this->from; } - /** - * Sets error - * - * @param \Infobip\Model\SmsError|null $error Indicates whether an error occurred during the query execution. - * - * @return self - */ - public function setError($error) + public function setFrom(?string $from): self { - $this->container['error'] = $error; - + $this->from = $from; return $this; } - /** - * Gets from - * - * @return string|null - */ - public function getFrom() + public function getSentAt(): \DateTime|null { - return $this->container['from']; + return $this->sentAt; } - /** - * Sets from - * - * @param string|null $from The sender ID which can be alphanumeric or numeric (e.g., `CompanyName`). - * - * @return self - */ - public function setFrom($from) + public function setSentAt(?\DateTime $sentAt): self { - $this->container['from'] = $from; - + $this->sentAt = $sentAt; return $this; } - /** - * Gets mccMnc - * - * @return string|null - */ - public function getMccMnc() + public function getDoneAt(): \DateTime|null { - return $this->container['mccMnc']; + return $this->doneAt; } - /** - * Sets mccMnc - * - * @param string|null $mccMnc Mobile country and network codes. - * - * @return self - */ - public function setMccMnc($mccMnc) + public function setDoneAt(?\DateTime $doneAt): self { - $this->container['mccMnc'] = $mccMnc; - + $this->doneAt = $doneAt; return $this; } - /** - * Gets messageId - * - * @return string|null - */ - public function getMessageId() + public function getSmsCount(): int|null { - return $this->container['messageId']; + return $this->smsCount; } - /** - * Sets messageId - * - * @param string|null $messageId Unique message ID. - * - * @return self - */ - public function setMessageId($messageId) + public function setSmsCount(?int $smsCount): self { - $this->container['messageId'] = $messageId; - + $this->smsCount = $smsCount; return $this; } - /** - * Gets price - * - * @return \Infobip\Model\SmsPrice|null - */ - public function getPrice() + public function getMccMnc(): string|null { - return $this->container['price']; + return $this->mccMnc; } - /** - * Sets price - * - * @param \Infobip\Model\SmsPrice|null $price Sent SMS price. - * - * @return self - */ - public function setPrice($price) + public function setMccMnc(?string $mccMnc): self { - $this->container['price'] = $price; - + $this->mccMnc = $mccMnc; return $this; } - /** - * Gets sentAt - * - * @return \DateTime|null - */ - public function getSentAt() + public function getCallbackData(): string|null { - return $this->container['sentAt']; + return $this->callbackData; } - /** - * Sets sentAt - * - * @param \DateTime|null $sentAt Date and time when the message was [scheduled](#channels/sms/get-scheduled-sms-messages) to be sent. Has the following format: `yyyy-MM-dd'T'HH:mm:ss.SSSZ`. - * - * @return self - */ - public function setSentAt($sentAt) + public function setCallbackData(?string $callbackData): self { - $this->container['sentAt'] = $sentAt; - + $this->callbackData = $callbackData; return $this; } - /** - * Gets smsCount - * - * @return int|null - */ - public function getSmsCount() + public function getPrice(): \Infobip\Model\SmsPrice|null { - return $this->container['smsCount']; + return $this->price; } - /** - * Sets smsCount - * - * @param int|null $smsCount The number of parts the message content was split into. - * - * @return self - */ - public function setSmsCount($smsCount) + public function setPrice(?\Infobip\Model\SmsPrice $price): self { - $this->container['smsCount'] = $smsCount; - + $this->price = $price; return $this; } - /** - * Gets status - * - * @return \Infobip\Model\SmsStatus|null - */ - public function getStatus() + public function getStatus(): \Infobip\Model\SmsStatus|null { - return $this->container['status']; + return $this->status; } - /** - * Sets status - * - * @param \Infobip\Model\SmsStatus|null $status Indicates the [status](https://www.infobip.com/docs/essentials/response-status-and-error-codes#api-status-codes) of the message and how to recover from an error should there be any. - * - * @return self - */ - public function setStatus($status) + public function setStatus(?\Infobip\Model\SmsStatus $status): self { - $this->container['status'] = $status; - + $this->status = $status; return $this; } - /** - * Gets to - * - * @return string|null - */ - public function getTo() + public function getError(): \Infobip\Model\SmsError|null { - return $this->container['to']; + return $this->error; } - /** - * Sets to - * - * @param string|null $to Message destination address. - * - * @return self - */ - public function setTo($to) + public function setError(?\Infobip\Model\SmsError $error): self { - $this->container['to'] = $to; - + $this->error = $error; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/SmsResponse.php b/Infobip/Model/SmsResponse.php index f0ae884..9a0973f 100644 --- a/Infobip/Model/SmsResponse.php +++ b/Infobip/Model/SmsResponse.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class SmsResponse implements ModelInterface, ArrayAccess, \JsonSerializable +class SmsResponse implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'SmsResponse'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'bulkId' => 'string', - 'messages' => '\Infobip\Model\SmsResponseDetails[]' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'SmsResponse'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'bulkId' => null, 'messages' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'bulkId' => 'bulkId', - 'messages' => 'messages' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'bulkId' => 'setBulkId', - 'messages' => 'setMessages' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'bulkId' => 'getBulkId', - 'messages' => 'getMessages' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model + * @param \Infobip\Model\SmsResponseDetails[] $messages */ - public function __construct(array $data = null) - { - $this->container['bulkId'] = $data['bulkId'] ?? null; - $this->container['messages'] = $data['messages'] ?? null; + public function __construct( + protected ?string $bulkId = null, + protected ?array $messages = null, + ) { } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets bulkId - * - * @return string|null - */ - public function getBulkId() + public function getBulkId(): string|null { - return $this->container['bulkId']; + return $this->bulkId; } - /** - * Sets bulkId - * - * @param string|null $bulkId Unique ID assigned to the request if messaging multiple recipients or sending multiple messages via a single API request. Typically, used to fetch [delivery reports](#channels/sms/get-outbound-sms-message-delivery-reports) and [message logs](#channels/sms/get-outbound-sms-message-logs). - * - * @return self - */ - public function setBulkId($bulkId) + public function setBulkId(?string $bulkId): self { - $this->container['bulkId'] = $bulkId; - + $this->bulkId = $bulkId; return $this; } /** - * Gets messages - * * @return \Infobip\Model\SmsResponseDetails[]|null */ - public function getMessages() + public function getMessages(): ?array { - return $this->container['messages']; + return $this->messages; } /** - * Sets messages - * * @param \Infobip\Model\SmsResponseDetails[]|null $messages An array of message objects of a single message or multiple messages sent under one bulk ID. - * - * @return self */ - public function setMessages($messages) + public function setMessages(?array $messages): self { - $this->container['messages'] = $messages; - + $this->messages = $messages; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/SmsResponseDetails.php b/Infobip/Model/SmsResponseDetails.php index 864e6a7..b802999 100644 --- a/Infobip/Model/SmsResponseDetails.php +++ b/Infobip/Model/SmsResponseDetails.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class SmsResponseDetails implements ModelInterface, ArrayAccess, \JsonSerializable +class SmsResponseDetails implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'SmsResponseDetails'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'messageId' => 'string', - 'status' => '\Infobip\Model\SmsStatus', - 'to' => 'string' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'SmsResponseDetails'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'messageId' => null, 'status' => null, 'to' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'messageId' => 'messageId', - 'status' => 'status', - 'to' => 'to' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'messageId' => 'setMessageId', - 'status' => 'setStatus', - 'to' => 'setTo' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'messageId' => 'getMessageId', - 'status' => 'getStatus', - 'to' => 'getTo' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] */ - protected $container = []; + public function __construct( + protected ?string $messageId = null, + #[Assert\Valid] - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['messageId'] = $data['messageId'] ?? null; - $this->container['status'] = $data['status'] ?? null; - $this->container['to'] = $data['to'] ?? null; + protected ?\Infobip\Model\SmsStatus $status = null, + protected ?string $to = null, + ) { } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets messageId - * - * @return string|null - */ - public function getMessageId() + public function getMessageId(): string|null { - return $this->container['messageId']; + return $this->messageId; } - /** - * Sets messageId - * - * @param string|null $messageId Unique message ID. If not passed, it will be automatically generated and returned in a response. - * - * @return self - */ - public function setMessageId($messageId) + public function setMessageId(?string $messageId): self { - $this->container['messageId'] = $messageId; - + $this->messageId = $messageId; return $this; } - /** - * Gets status - * - * @return \Infobip\Model\SmsStatus|null - */ - public function getStatus() + public function getStatus(): \Infobip\Model\SmsStatus|null { - return $this->container['status']; + return $this->status; } - /** - * Sets status - * - * @param \Infobip\Model\SmsStatus|null $status status - * - * @return self - */ - public function setStatus($status) + public function setStatus(?\Infobip\Model\SmsStatus $status): self { - $this->container['status'] = $status; - + $this->status = $status; return $this; } - /** - * Gets to - * - * @return string|null - */ - public function getTo() + public function getTo(): string|null { - return $this->container['to']; + return $this->to; } - /** - * Sets to - * - * @param string|null $to The destination address of the message. - * - * @return self - */ - public function setTo($to) + public function setTo(?string $to): self { - $this->container['to'] = $to; - + $this->to = $to; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/SmsSendingSpeedLimit.php b/Infobip/Model/SmsSendingSpeedLimit.php index 82e9cd2..1be04fa 100644 --- a/Infobip/Model/SmsSendingSpeedLimit.php +++ b/Infobip/Model/SmsSendingSpeedLimit.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class SmsSendingSpeedLimit implements ModelInterface, ArrayAccess, \JsonSerializable +class SmsSendingSpeedLimit implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'SmsSendingSpeedLimit'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'amount' => 'int', - 'timeUnit' => '\Infobip\Model\SmsSpeedLimitTimeUnit' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'SmsSendingSpeedLimit'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'amount' => 'int32', 'timeUnit' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] */ - protected static $attributeMap = [ - 'amount' => 'amount', - 'timeUnit' => 'timeUnit' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'amount' => 'setAmount', - 'timeUnit' => 'setTimeUnit' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'amount' => 'getAmount', - 'timeUnit' => 'getTimeUnit' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - + public function __construct( + #[Assert\NotBlank] + protected int $amount, + #[Assert\Choice(['MINUTE','HOUR','DAY',])] - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['amount'] = $data['amount'] ?? null; - $this->container['timeUnit'] = $data['timeUnit'] ?? null; + protected ?string $timeUnit = null, + ) { } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - if ($this->container['amount'] === null) { - $invalidProperties[] = "'amount' can't be null"; - } - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets amount - * - * @return int - */ - public function getAmount() + public function getAmount(): int { - return $this->container['amount']; + return $this->amount; } - /** - * Sets amount - * - * @param int $amount The number of messages to be sent per timeUnit. By default, the system sends messages as fast as the infrastructure allows. Use this parameter to adapt sending capacity to your needs. The system is only able to work against its maximum capacity for ambitious message batches. - * - * @return self - */ - public function setAmount($amount) + public function setAmount(int $amount): self { - $this->container['amount'] = $amount; - + $this->amount = $amount; return $this; } - /** - * Gets timeUnit - * - * @return \Infobip\Model\SmsSpeedLimitTimeUnit|null - */ - public function getTimeUnit() + public function getTimeUnit(): mixed { - return $this->container['timeUnit']; + return $this->timeUnit; } - /** - * Sets timeUnit - * - * @param \Infobip\Model\SmsSpeedLimitTimeUnit|null $timeUnit timeUnit - * - * @return self - */ - public function setTimeUnit($timeUnit) + public function setTimeUnit($timeUnit): self { - $this->container['timeUnit'] = $timeUnit; - + $this->timeUnit = $timeUnit; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/SmsSpeedLimitTimeUnit.php b/Infobip/Model/SmsSpeedLimitTimeUnit.php index 7582f1c..35ed8ae 100644 --- a/Infobip/Model/SmsSpeedLimitTimeUnit.php +++ b/Infobip/Model/SmsSpeedLimitTimeUnit.php @@ -1,14 +1,8 @@ value = $value; + } + + public static function MINUTE(): SmsSpeedLimitTimeUnit + { + return new self('MINUTE'); + } + + public static function HOUR(): SmsSpeedLimitTimeUnit + { + return new self('HOUR'); + } + + public static function DAY(): SmsSpeedLimitTimeUnit + { + return new self('DAY'); + } + + public function __toString(): string { - return [ - self::MINUTE, - self::HOUR, - self::DAY, - ]; + return $this->value; } } diff --git a/Infobip/Model/SmsStatus.php b/Infobip/Model/SmsStatus.php index 938f8fa..317f8ae 100644 --- a/Infobip/Model/SmsStatus.php +++ b/Infobip/Model/SmsStatus.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class SmsStatus implements ModelInterface, ArrayAccess, \JsonSerializable +class SmsStatus implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'SmsStatus'; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'SmsStatus'; - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'action' => 'string', - 'description' => 'string', - 'groupId' => 'int', - 'groupName' => 'string', - 'id' => 'int', - 'name' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'action' => null, - 'description' => null, + public const OPENAPI_FORMATS = [ 'groupId' => 'int32', 'groupName' => null, 'id' => 'int32', - 'name' => null - ]; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'action' => 'action', - 'description' => 'description', - 'groupId' => 'groupId', - 'groupName' => 'groupName', - 'id' => 'id', - 'name' => 'name' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'action' => 'setAction', - 'description' => 'setDescription', - 'groupId' => 'setGroupId', - 'groupName' => 'setGroupName', - 'id' => 'setId', - 'name' => 'setName' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'action' => 'getAction', - 'description' => 'getDescription', - 'groupId' => 'getGroupId', - 'groupName' => 'getGroupName', - 'id' => 'getId', - 'name' => 'getName' + 'name' => null, + 'description' => null, + 'action' => null ]; /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string */ - public function getModelName() - { - return self::$openAPIModelName; + public function __construct( + protected ?int $groupId = null, + protected ?string $groupName = null, + protected ?int $id = null, + protected ?string $name = null, + protected ?string $description = null, + protected ?string $action = null, + ) { } - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['action'] = $data['action'] ?? null; - $this->container['description'] = $data['description'] ?? null; - $this->container['groupId'] = $data['groupId'] ?? null; - $this->container['groupName'] = $data['groupName'] ?? null; - $this->container['id'] = $data['id'] ?? null; - $this->container['name'] = $data['name'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets action - * - * @return string|null - */ - public function getAction() + public function getGroupId(): int|null { - return $this->container['action']; + return $this->groupId; } - /** - * Sets action - * - * @param string|null $action Action that should be taken to recover from the error. - * - * @return self - */ - public function setAction($action) + public function setGroupId(?int $groupId): self { - $this->container['action'] = $action; - + $this->groupId = $groupId; return $this; } - /** - * Gets description - * - * @return string|null - */ - public function getDescription() + public function getGroupName(): string|null { - return $this->container['description']; + return $this->groupName; } - /** - * Sets description - * - * @param string|null $description Human-readable description of the status. - * - * @return self - */ - public function setDescription($description) + public function setGroupName(?string $groupName): self { - $this->container['description'] = $description; - + $this->groupName = $groupName; return $this; } - /** - * Gets groupId - * - * @return int|null - */ - public function getGroupId() + public function getId(): int|null { - return $this->container['groupId']; + return $this->id; } - /** - * Sets groupId - * - * @param int|null $groupId Status group ID. - * - * @return self - */ - public function setGroupId($groupId) + public function setId(?int $id): self { - $this->container['groupId'] = $groupId; - + $this->id = $id; return $this; } - /** - * Gets groupName - * - * @return string|null - */ - public function getGroupName() + public function getName(): string|null { - return $this->container['groupName']; + return $this->name; } - /** - * Sets groupName - * - * @param string|null $groupName Status group name that describes which category the status code belongs to, e.g. PENDING, UNDELIVERABLE, DELIVERED, EXPIRED, REJECTED. - * - * @return self - */ - public function setGroupName($groupName) + public function setName(?string $name): self { - $this->container['groupName'] = $groupName; - + $this->name = $name; return $this; } - /** - * Gets id - * - * @return int|null - */ - public function getId() + public function getDescription(): string|null { - return $this->container['id']; + return $this->description; } - /** - * Sets id - * - * @param int|null $id Status ID. - * - * @return self - */ - public function setId($id) + public function setDescription(?string $description): self { - $this->container['id'] = $id; - + $this->description = $description; return $this; } - /** - * Gets name - * - * @return string|null - */ - public function getName() + public function getAction(): string|null { - return $this->container['name']; + return $this->action; } - /** - * Sets name - * - * @param string|null $name [Status name](https://www.infobip.com/docs/essentials/response-status-and-error-codes). - * - * @return self - */ - public function setName($name) + public function setAction(?string $action): self { - $this->container['name'] = $name; - + $this->action = $action; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/SmsTextualMessage.php b/Infobip/Model/SmsTextualMessage.php index 18eba2a..3fcea62 100644 --- a/Infobip/Model/SmsTextualMessage.php +++ b/Infobip/Model/SmsTextualMessage.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class SmsTextualMessage implements ModelInterface, ArrayAccess, \JsonSerializable +class SmsTextualMessage implements ModelInterface { - public const DISCRIMINATOR = null; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'SmsTextualMessage'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'SmsTextualMessage'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'callbackData' => 'string', - 'deliveryTimeWindow' => '\Infobip\Model\SmsDeliveryTimeWindow', - 'destinations' => '\Infobip\Model\SmsDestination[]', - 'flash' => 'bool', - 'from' => 'string', - 'intermediateReport' => 'bool', - 'language' => '\Infobip\Model\SmsLanguage', - 'notifyContentType' => 'string', - 'notifyUrl' => 'string', - 'regional' => '\Infobip\Model\SmsRegionalOptions', - 'sendAt' => '\DateTime', - 'text' => 'string', - 'transliteration' => 'string', - 'validityPeriod' => 'int' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'callbackData' => null, 'deliveryTimeWindow' => null, 'destinations' => null, @@ -92,634 +43,244 @@ class SmsTextualMessage implements ModelInterface, ArrayAccess, \JsonSerializabl 'sendAt' => 'date-time', 'text' => null, 'transliteration' => null, - 'validityPeriod' => 'int64' + 'validityPeriod' => 'int64', + 'entityId' => null, + 'applicationId' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'callbackData' => 'callbackData', - 'deliveryTimeWindow' => 'deliveryTimeWindow', - 'destinations' => 'destinations', - 'flash' => 'flash', - 'from' => 'from', - 'intermediateReport' => 'intermediateReport', - 'language' => 'language', - 'notifyContentType' => 'notifyContentType', - 'notifyUrl' => 'notifyUrl', - 'regional' => 'regional', - 'sendAt' => 'sendAt', - 'text' => 'text', - 'transliteration' => 'transliteration', - 'validityPeriod' => 'validityPeriod' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'callbackData' => 'setCallbackData', - 'deliveryTimeWindow' => 'setDeliveryTimeWindow', - 'destinations' => 'setDestinations', - 'flash' => 'setFlash', - 'from' => 'setFrom', - 'intermediateReport' => 'setIntermediateReport', - 'language' => 'setLanguage', - 'notifyContentType' => 'setNotifyContentType', - 'notifyUrl' => 'setNotifyUrl', - 'regional' => 'setRegional', - 'sendAt' => 'setSendAt', - 'text' => 'setText', - 'transliteration' => 'setTransliteration', - 'validityPeriod' => 'setValidityPeriod' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'callbackData' => 'getCallbackData', - 'deliveryTimeWindow' => 'getDeliveryTimeWindow', - 'destinations' => 'getDestinations', - 'flash' => 'getFlash', - 'from' => 'getFrom', - 'intermediateReport' => 'getIntermediateReport', - 'language' => 'getLanguage', - 'notifyContentType' => 'getNotifyContentType', - 'notifyUrl' => 'getNotifyUrl', - 'regional' => 'getRegional', - 'sendAt' => 'getSendAt', - 'text' => 'getText', - 'transliteration' => 'getTransliteration', - 'validityPeriod' => 'getValidityPeriod' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array + * @param \Infobip\Model\SmsDestination[] $destinations */ - public static function setters() - { - return self::$setters; - } + public function __construct( + #[Assert\NotBlank] - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } + protected array $destinations, + #[Assert\Length(max: 4000)] + #[Assert\Length(min: 0)] - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } + protected ?string $callbackData = null, + #[Assert\Valid] + protected ?\Infobip\Model\SmsDeliveryTimeWindow $deliveryTimeWindow = null, + protected ?bool $flash = false, + protected ?string $from = null, + protected ?bool $intermediateReport = null, + #[Assert\Valid] + protected ?\Infobip\Model\SmsLanguage $language = null, + protected ?string $notifyContentType = null, + protected ?string $notifyUrl = null, + #[Assert\Valid] + protected ?\Infobip\Model\SmsRegionalOptions $regional = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + protected ?\DateTime $sendAt = null, + protected ?string $text = null, + protected ?string $transliteration = null, + protected ?int $validityPeriod = null, + #[Assert\Length(max: 50)] + #[Assert\Length(min: 0)] - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; + protected ?string $entityId = null, + #[Assert\Length(max: 50)] + #[Assert\Length(min: 0)] - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['callbackData'] = $data['callbackData'] ?? null; - $this->container['deliveryTimeWindow'] = $data['deliveryTimeWindow'] ?? null; - $this->container['destinations'] = $data['destinations'] ?? null; - $this->container['flash'] = $data['flash'] ?? false; - $this->container['from'] = $data['from'] ?? null; - $this->container['intermediateReport'] = $data['intermediateReport'] ?? null; - $this->container['language'] = $data['language'] ?? null; - $this->container['notifyContentType'] = $data['notifyContentType'] ?? null; - $this->container['notifyUrl'] = $data['notifyUrl'] ?? null; - $this->container['regional'] = $data['regional'] ?? null; - $this->container['sendAt'] = $data['sendAt'] ?? null; - $this->container['text'] = $data['text'] ?? null; - $this->container['transliteration'] = $data['transliteration'] ?? null; - $this->container['validityPeriod'] = $data['validityPeriod'] ?? null; + protected ?string $applicationId = null, + ) { } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - if (!is_null($this->container['callbackData']) && (mb_strlen($this->container['callbackData']) > 4000)) { - $invalidProperties[] = "invalid value for 'callbackData', the character length must be smaller than or equal to 4000."; - } - - if (!is_null($this->container['callbackData']) && (mb_strlen($this->container['callbackData']) < 0)) { - $invalidProperties[] = "invalid value for 'callbackData', the character length must be bigger than or equal to 0."; - } - - if ($this->container['destinations'] === null) { - $invalidProperties[] = "'destinations' can't be null"; - } - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets callbackData - * - * @return string|null - */ - public function getCallbackData() + public function getCallbackData(): string|null { - return $this->container['callbackData']; + return $this->callbackData; } - /** - * Sets callbackData - * - * @param string|null $callbackData Additional data that can be used for identifying, managing, or monitoring a message. Data included here will also be automatically included in the message [Delivery Report](#channels/sms/get-outbound-sms-message-delivery-reports). The maximum value is 4000 characters and any overhead may be truncated. - * - * @return self - */ - public function setCallbackData($callbackData) + public function setCallbackData(?string $callbackData): self { - if (!is_null($callbackData) && (mb_strlen($callbackData) > 4000)) { - throw new \InvalidArgumentException('invalid length for $callbackData when calling SmsTextualMessage., must be smaller than or equal to 4000.'); - } - if (!is_null($callbackData) && (mb_strlen($callbackData) < 0)) { - throw new \InvalidArgumentException('invalid length for $callbackData when calling SmsTextualMessage., must be bigger than or equal to 0.'); - } - - $this->container['callbackData'] = $callbackData; - + $this->callbackData = $callbackData; return $this; } - /** - * Gets deliveryTimeWindow - * - * @return \Infobip\Model\SmsDeliveryTimeWindow|null - */ - public function getDeliveryTimeWindow() + public function getDeliveryTimeWindow(): \Infobip\Model\SmsDeliveryTimeWindow|null { - return $this->container['deliveryTimeWindow']; + return $this->deliveryTimeWindow; } - /** - * Sets deliveryTimeWindow - * - * @param \Infobip\Model\SmsDeliveryTimeWindow|null $deliveryTimeWindow deliveryTimeWindow - * - * @return self - */ - public function setDeliveryTimeWindow($deliveryTimeWindow) + public function setDeliveryTimeWindow(?\Infobip\Model\SmsDeliveryTimeWindow $deliveryTimeWindow): self { - $this->container['deliveryTimeWindow'] = $deliveryTimeWindow; - + $this->deliveryTimeWindow = $deliveryTimeWindow; return $this; } /** - * Gets destinations - * * @return \Infobip\Model\SmsDestination[] */ - public function getDestinations() + public function getDestinations(): array { - return $this->container['destinations']; + return $this->destinations; } /** - * Sets destinations - * * @param \Infobip\Model\SmsDestination[] $destinations An array of destination objects for where messages are being sent. A valid destination is required. - * - * @return self */ - public function setDestinations($destinations) + public function setDestinations(array $destinations): self { - $this->container['destinations'] = $destinations; - + $this->destinations = $destinations; return $this; } - /** - * Gets flash - * - * @return bool|null - */ - public function getFlash() + public function getFlash(): bool|null { - return $this->container['flash']; + return $this->flash; } - /** - * Sets flash - * - * @param bool|null $flash Allows for sending a [flash SMS](https://www.infobip.com/docs/sms/message-types#flash-sms) to automatically appear on recipient devices without interaction. Set to `true` to enable flash SMS, or leave the default value, `false` to send a standard SMS. - * - * @return self - */ - public function setFlash($flash) + public function setFlash(?bool $flash): self { - $this->container['flash'] = $flash; - + $this->flash = $flash; return $this; } - /** - * Gets from - * - * @return string|null - */ - public function getFrom() + public function getFrom(): string|null { - return $this->container['from']; + return $this->from; } - /** - * Sets from - * - * @param string|null $from The sender ID which can be alphanumeric or numeric (e.g., `CompanyName`). Make sure you don't exceed [character limit](https://www.infobip.com/docs/sms/get-started#sender-names). - * - * @return self - */ - public function setFrom($from) + public function setFrom(?string $from): self { - $this->container['from'] = $from; - + $this->from = $from; return $this; } - /** - * Gets intermediateReport - * - * @return bool|null - */ - public function getIntermediateReport() + public function getIntermediateReport(): bool|null { - return $this->container['intermediateReport']; + return $this->intermediateReport; } - /** - * Sets intermediateReport - * - * @param bool|null $intermediateReport The [real-time intermediate delivery report](#channels/sms/receive-outbound-sms-message-report) containing GSM error codes, messages status, pricing, network and country codes, etc., which will be sent on your callback server. Defaults to `false`. - * - * @return self - */ - public function setIntermediateReport($intermediateReport) + public function setIntermediateReport(?bool $intermediateReport): self { - $this->container['intermediateReport'] = $intermediateReport; - + $this->intermediateReport = $intermediateReport; return $this; } - /** - * Gets language - * - * @return \Infobip\Model\SmsLanguage|null - */ - public function getLanguage() + public function getLanguage(): \Infobip\Model\SmsLanguage|null { - return $this->container['language']; + return $this->language; } - /** - * Sets language - * - * @param \Infobip\Model\SmsLanguage|null $language language - * - * @return self - */ - public function setLanguage($language) + public function setLanguage(?\Infobip\Model\SmsLanguage $language): self { - $this->container['language'] = $language; - + $this->language = $language; return $this; } - /** - * Gets notifyContentType - * - * @return string|null - */ - public function getNotifyContentType() + public function getNotifyContentType(): string|null { - return $this->container['notifyContentType']; + return $this->notifyContentType; } - /** - * Sets notifyContentType - * - * @param string|null $notifyContentType Preferred delivery report content type, `application/json` or `application/xml`. - * - * @return self - */ - public function setNotifyContentType($notifyContentType) + public function setNotifyContentType(?string $notifyContentType): self { - $this->container['notifyContentType'] = $notifyContentType; - + $this->notifyContentType = $notifyContentType; return $this; } - /** - * Gets notifyUrl - * - * @return string|null - */ - public function getNotifyUrl() + public function getNotifyUrl(): string|null { - return $this->container['notifyUrl']; + return $this->notifyUrl; } - /** - * Sets notifyUrl - * - * @param string|null $notifyUrl The URL on your call back server on to which a delivery report will be sent. The [retry cycle](https://www.infobip.com/docs/sms/api#notify-url) for when your URL becomes unavailable uses the following formula: `1min + (1min * retryNumber * retryNumber)`. - * - * @return self - */ - public function setNotifyUrl($notifyUrl) + public function setNotifyUrl(?string $notifyUrl): self { - $this->container['notifyUrl'] = $notifyUrl; - + $this->notifyUrl = $notifyUrl; return $this; } - /** - * Gets regional - * - * @return \Infobip\Model\SmsRegionalOptions|null - */ - public function getRegional() + public function getRegional(): \Infobip\Model\SmsRegionalOptions|null { - return $this->container['regional']; + return $this->regional; } - /** - * Sets regional - * - * @param \Infobip\Model\SmsRegionalOptions|null $regional regional - * - * @return self - */ - public function setRegional($regional) + public function setRegional(?\Infobip\Model\SmsRegionalOptions $regional): self { - $this->container['regional'] = $regional; - + $this->regional = $regional; return $this; } - /** - * Gets sendAt - * - * @return \DateTime|null - */ - public function getSendAt() + public function getSendAt(): \DateTime|null { - return $this->container['sendAt']; + return $this->sendAt; } - /** - * Sets sendAt - * - * @param \DateTime|null $sendAt Date and time when the message is to be sent. Used for [scheduled SMS](#channels/sms/get-scheduled-sms-messages). Has the following format: `yyyy-MM-dd'T'HH:mm:ss.SSSZ`, and can only be scheduled for no later than 180 days in advance. - * - * @return self - */ - public function setSendAt($sendAt) + public function setSendAt(?\DateTime $sendAt): self { - $this->container['sendAt'] = $sendAt; - + $this->sendAt = $sendAt; return $this; } - /** - * Gets text - * - * @return string|null - */ - public function getText() + public function getText(): string|null { - return $this->container['text']; + return $this->text; } - /** - * Sets text - * - * @param string|null $text Content of the message being sent. - * - * @return self - */ - public function setText($text) + public function setText(?string $text): self { - $this->container['text'] = $text; - + $this->text = $text; return $this; } - /** - * Gets transliteration - * - * @return string|null - */ - public function getTransliteration() + public function getTransliteration(): string|null { - return $this->container['transliteration']; + return $this->transliteration; } - /** - * Sets transliteration - * - * @param string|null $transliteration The transliteration of your sent message from one script to another. Transliteration is used to replace characters which are not recognized as part of your defaulted alphabet. Possible values: `TURKISH`, `GREEK`, `CYRILLIC`, `SERBIAN_CYRILLIC`, `CENTRAL_EUROPEAN`, `BALTIC` and `NON_UNICODE`. - * - * @return self - */ - public function setTransliteration($transliteration) + public function setTransliteration(?string $transliteration): self { - $this->container['transliteration'] = $transliteration; - + $this->transliteration = $transliteration; return $this; } - /** - * Gets validityPeriod - * - * @return int|null - */ - public function getValidityPeriod() + public function getValidityPeriod(): int|null { - return $this->container['validityPeriod']; + return $this->validityPeriod; } - /** - * Sets validityPeriod - * - * @param int|null $validityPeriod The message validity period in minutes. When the period expires, it will not be allowed for the message to be sent. Validity period longer than 48h is not supported. Any bigger value will automatically default back to `2880`. - * - * @return self - */ - public function setValidityPeriod($validityPeriod) + public function setValidityPeriod(?int $validityPeriod): self { - $this->container['validityPeriod'] = $validityPeriod; - + $this->validityPeriod = $validityPeriod; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void + public function getEntityId(): string|null { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } + return $this->entityId; } - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void + public function setEntityId(?string $entityId): self { - 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. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); + $this->entityId = $entityId; + return $this; } - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() + public function getApplicationId(): string|null { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); + return $this->applicationId; } - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() + public function setApplicationId(?string $applicationId): self { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + $this->applicationId = $applicationId; + return $this; } } diff --git a/Infobip/Model/SmsTracking.php b/Infobip/Model/SmsTracking.php index 47eeeb4..c0104bb 100644 --- a/Infobip/Model/SmsTracking.php +++ b/Infobip/Model/SmsTracking.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class SmsTracking implements ModelInterface, ArrayAccess, \JsonSerializable +class SmsTracking implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'SmsTracking'; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'SmsTracking'; - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'baseUrl' => 'string', - 'processKey' => 'string', - 'track' => 'string', - 'type' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'baseUrl' => null, 'processKey' => null, 'track' => null, @@ -76,332 +37,68 @@ class SmsTracking implements ModelInterface, ArrayAccess, \JsonSerializable ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'baseUrl' => 'baseUrl', - 'processKey' => 'processKey', - 'track' => 'track', - 'type' => 'type' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'baseUrl' => 'setBaseUrl', - 'processKey' => 'setProcessKey', - 'track' => 'setTrack', - 'type' => 'setType' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'baseUrl' => 'getBaseUrl', - 'processKey' => 'getProcessKey', - 'track' => 'getTrack', - 'type' => 'getType' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model */ - public function __construct(array $data = null) - { - $this->container['baseUrl'] = $data['baseUrl'] ?? null; - $this->container['processKey'] = $data['processKey'] ?? null; - $this->container['track'] = $data['track'] ?? null; - $this->container['type'] = $data['type'] ?? null; + public function __construct( + protected ?string $baseUrl = null, + protected ?string $processKey = null, + protected ?string $track = null, + protected ?string $type = null, + ) { } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets baseUrl - * - * @return string|null - */ - public function getBaseUrl() + public function getBaseUrl(): string|null { - return $this->container['baseUrl']; + return $this->baseUrl; } - /** - * Sets baseUrl - * - * @param string|null $baseUrl Custom base URL for shortened links in messages when tracking URL conversions. - * - * @return self - */ - public function setBaseUrl($baseUrl) + public function setBaseUrl(?string $baseUrl): self { - $this->container['baseUrl'] = $baseUrl; - + $this->baseUrl = $baseUrl; return $this; } - /** - * Gets processKey - * - * @return string|null - */ - public function getProcessKey() + public function getProcessKey(): string|null { - return $this->container['processKey']; + return $this->processKey; } - /** - * Sets processKey - * - * @param string|null $processKey The process key which uniquely identifies conversion tracking. - * - * @return self - */ - public function setProcessKey($processKey) + public function setProcessKey(?string $processKey): self { - $this->container['processKey'] = $processKey; - + $this->processKey = $processKey; return $this; } - /** - * Gets track - * - * @return string|null - */ - public function getTrack() + public function getTrack(): string|null { - return $this->container['track']; + return $this->track; } - /** - * Sets track - * - * @param string|null $track Indicates if a message has to be tracked for conversion rates. Values are: `SMS` and `URL`. - * - * @return self - */ - public function setTrack($track) + public function setTrack(?string $track): self { - $this->container['track'] = $track; - + $this->track = $track; return $this; } - /** - * Gets type - * - * @return string|null - */ - public function getType() + public function getType(): string|null { - return $this->container['type']; + return $this->type; } - /** - * Sets type - * - * @param string|null $type Sets a custom conversion type naming convention, e.g. `ONE_TIME_PIN` or `SOCIAL_INVITES`. - * - * @return self - */ - public function setType($type) + public function setType(?string $type): self { - $this->container['type'] = $type; - + $this->type = $type; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/SmsTurkeyIysOptions.php b/Infobip/Model/SmsTurkeyIysOptions.php index 6fab3e3..df19a07 100644 --- a/Infobip/Model/SmsTurkeyIysOptions.php +++ b/Infobip/Model/SmsTurkeyIysOptions.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class SmsTurkeyIysOptions implements ModelInterface, ArrayAccess, \JsonSerializable +class SmsTurkeyIysOptions implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'SmsTurkeyIysOptions'; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'SmsTurkeyIysOptions'; - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'brandCode' => 'int', - 'recipientType' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'brandCode' => 'int32', 'recipientType' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array */ - public static function openAPITypes() - { - return self::$openAPITypes; - } + public function __construct( + #[Assert\NotBlank] + #[Assert\Choice(['BIREYSEL','TACIR',])] - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; + protected string $recipientType, + protected ?int $brandCode = null, + ) { } - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'brandCode' => 'brandCode', - 'recipientType' => 'recipientType' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'brandCode' => 'setBrandCode', - 'recipientType' => 'setRecipientType' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'brandCode' => 'getBrandCode', - 'recipientType' => 'getRecipientType' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() + #[Ignore] + public function getModelName(): string { - return self::$attributeMap; + return self::OPENAPI_MODEL_NAME; } - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$openAPIModelName; + return self::DISCRIMINATOR; } - public const RECIPIENT_TYPE_BIREYSEL = 'BIREYSEL'; - public const RECIPIENT_TYPE_TACIR = 'TACIR'; - - - - /** - * Gets allowable values of the enum - * - * @return string[] - */ - public function getRecipientTypeAllowableValues() + public function getBrandCode(): int|null { - return [ - self::RECIPIENT_TYPE_BIREYSEL, - self::RECIPIENT_TYPE_TACIR, - ]; + return $this->brandCode; } - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) + public function setBrandCode(?int $brandCode): self { - $this->container['brandCode'] = $data['brandCode'] ?? null; - $this->container['recipientType'] = $data['recipientType'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - if ($this->container['recipientType'] === null) { - $invalidProperties[] = "'recipientType' can't be null"; - } - $allowedValues = $this->getRecipientTypeAllowableValues(); - if (!is_null($this->container['recipientType']) && !in_array($this->container['recipientType'], $allowedValues, true)) { - $invalidProperties[] = sprintf( - "invalid value '%s' for 'recipientType', must be one of '%s'", - $this->container['recipientType'], - implode("', '", $allowedValues) - ); - } - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets brandCode - * - * @return int|null - */ - public function getBrandCode() - { - return $this->container['brandCode']; - } - - /** - * Sets brandCode - * - * @param int|null $brandCode Brand code is an ID of the company based on a company VAT number. If not provided in request, default value is used from your Infobip account. - * - * @return self - */ - public function setBrandCode($brandCode) - { - $this->container['brandCode'] = $brandCode; - + $this->brandCode = $brandCode; return $this; } - /** - * Gets recipientType - * - * @return string - */ - public function getRecipientType() + public function getRecipientType(): mixed { - return $this->container['recipientType']; + return $this->recipientType; } - /** - * Sets recipientType - * - * @param string $recipientType Recipient Type must be `TACIR` or `BIREYSEL`. - * - * @return self - */ - public function setRecipientType($recipientType) + public function setRecipientType($recipientType): self { - $allowedValues = $this->getRecipientTypeAllowableValues(); - if (!in_array($recipientType, $allowedValues, true)) { - throw new \InvalidArgumentException( - sprintf( - "Invalid value '%s' for 'recipientType', must be one of '%s'", - $recipientType, - implode("', '", $allowedValues) - ) - ); - } - $this->container['recipientType'] = $recipientType; - + $this->recipientType = $recipientType; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/SmsUpdateStatusRequest.php b/Infobip/Model/SmsUpdateStatusRequest.php index 1d186e1..2d489ca 100644 --- a/Infobip/Model/SmsUpdateStatusRequest.php +++ b/Infobip/Model/SmsUpdateStatusRequest.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class SmsUpdateStatusRequest implements ModelInterface, ArrayAccess, \JsonSerializable +class SmsUpdateStatusRequest implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'SmsUpdateStatusRequest'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'status' => '\Infobip\Model\SmsBulkStatus' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'SmsUpdateStatusRequest'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'status' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'status' => 'status' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'status' => 'setStatus' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'status' => 'getStatus' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] */ - protected $container = []; + public function __construct( + #[Assert\NotBlank] + #[Assert\Choice(['PENDING','PAUSED','PROCESSING','CANCELED','FINISHED','FAILED',])] - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['status'] = $data['status'] ?? null; + protected string $status, + ) { } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - if ($this->container['status'] === null) { - $invalidProperties[] = "'status' can't be null"; - } - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets status - * - * @return \Infobip\Model\SmsBulkStatus - */ - public function getStatus() + public function getStatus(): mixed { - return $this->container['status']; + return $this->status; } - /** - * Sets status - * - * @param \Infobip\Model\SmsBulkStatus $status The status of the message(s). - * - * @return self - */ - public function setStatus($status) + public function setStatus($status): self { - $this->container['status'] = $status; - + $this->status = $status; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/SmsUrlOptions.php b/Infobip/Model/SmsUrlOptions.php new file mode 100644 index 0000000..812a6b1 --- /dev/null +++ b/Infobip/Model/SmsUrlOptions.php @@ -0,0 +1,117 @@ + null, + 'trackClicks' => null, + 'trackingUrl' => null, + 'removeProtocol' => null, + 'customDomain' => null + ]; + + /** + */ + public function __construct( + protected ?bool $shortenUrl = true, + protected ?bool $trackClicks = true, + protected ?string $trackingUrl = null, + protected ?bool $removeProtocol = false, + protected ?string $customDomain = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getShortenUrl(): bool|null + { + return $this->shortenUrl; + } + + public function setShortenUrl(?bool $shortenUrl): self + { + $this->shortenUrl = $shortenUrl; + return $this; + } + + public function getTrackClicks(): bool|null + { + return $this->trackClicks; + } + + public function setTrackClicks(?bool $trackClicks): self + { + $this->trackClicks = $trackClicks; + return $this; + } + + public function getTrackingUrl(): string|null + { + return $this->trackingUrl; + } + + public function setTrackingUrl(?string $trackingUrl): self + { + $this->trackingUrl = $trackingUrl; + return $this; + } + + public function getRemoveProtocol(): bool|null + { + return $this->removeProtocol; + } + + public function setRemoveProtocol(?bool $removeProtocol): self + { + $this->removeProtocol = $removeProtocol; + return $this; + } + + public function getCustomDomain(): string|null + { + return $this->customDomain; + } + + public function setCustomDomain(?string $customDomain): self + { + $this->customDomain = $customDomain; + return $this; + } +} diff --git a/Infobip/Model/SmsWebhookInboundReport.php b/Infobip/Model/SmsWebhookInboundReport.php new file mode 100644 index 0000000..60e51c5 --- /dev/null +++ b/Infobip/Model/SmsWebhookInboundReport.php @@ -0,0 +1,186 @@ + null, + 'from' => null, + 'to' => null, + 'text' => null, + 'cleanText' => null, + 'keyword' => null, + 'receivedAt' => 'date-time', + 'smsCount' => 'int32', + 'price' => null, + 'callbackData' => null + ]; + + /** + */ + public function __construct( + protected ?string $messageId = null, + protected ?string $from = null, + protected ?string $to = null, + protected ?string $text = null, + protected ?string $cleanText = null, + protected ?string $keyword = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $receivedAt = null, + protected ?int $smsCount = null, + #[Assert\Valid] + + protected ?\Infobip\Model\MessagePrice $price = null, + protected ?string $callbackData = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getMessageId(): string|null + { + return $this->messageId; + } + + public function setMessageId(?string $messageId): self + { + $this->messageId = $messageId; + return $this; + } + + public function getFrom(): string|null + { + return $this->from; + } + + public function setFrom(?string $from): self + { + $this->from = $from; + return $this; + } + + public function getTo(): string|null + { + return $this->to; + } + + public function setTo(?string $to): self + { + $this->to = $to; + return $this; + } + + public function getText(): string|null + { + return $this->text; + } + + public function setText(?string $text): self + { + $this->text = $text; + return $this; + } + + public function getCleanText(): string|null + { + return $this->cleanText; + } + + public function setCleanText(?string $cleanText): self + { + $this->cleanText = $cleanText; + return $this; + } + + public function getKeyword(): string|null + { + return $this->keyword; + } + + public function setKeyword(?string $keyword): self + { + $this->keyword = $keyword; + return $this; + } + + public function getReceivedAt(): \DateTime|null + { + return $this->receivedAt; + } + + public function setReceivedAt(?\DateTime $receivedAt): self + { + $this->receivedAt = $receivedAt; + return $this; + } + + public function getSmsCount(): int|null + { + return $this->smsCount; + } + + public function setSmsCount(?int $smsCount): self + { + $this->smsCount = $smsCount; + return $this; + } + + public function getPrice(): \Infobip\Model\MessagePrice|null + { + return $this->price; + } + + public function setPrice(?\Infobip\Model\MessagePrice $price): self + { + $this->price = $price; + return $this; + } + + public function getCallbackData(): string|null + { + return $this->callbackData; + } + + public function setCallbackData(?string $callbackData): self + { + $this->callbackData = $callbackData; + return $this; + } +} diff --git a/Infobip/Model/SmsWebhookInboundReportResponse.php b/Infobip/Model/SmsWebhookInboundReportResponse.php new file mode 100644 index 0000000..3b66991 --- /dev/null +++ b/Infobip/Model/SmsWebhookInboundReportResponse.php @@ -0,0 +1,98 @@ + 'int32', + 'pendingMessageCount' => 'int32', + 'results' => null + ]; + + /** + * @param \Infobip\Model\SmsWebhookInboundReport[] $results + */ + public function __construct( + protected ?int $messageCount = null, + protected ?int $pendingMessageCount = null, + protected ?array $results = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getMessageCount(): int|null + { + return $this->messageCount; + } + + public function setMessageCount(?int $messageCount): self + { + $this->messageCount = $messageCount; + return $this; + } + + public function getPendingMessageCount(): int|null + { + return $this->pendingMessageCount; + } + + public function setPendingMessageCount(?int $pendingMessageCount): self + { + $this->pendingMessageCount = $pendingMessageCount; + return $this; + } + + /** + * @return \Infobip\Model\SmsWebhookInboundReport[]|null + */ + public function getResults(): ?array + { + return $this->results; + } + + /** + * @param \Infobip\Model\SmsWebhookInboundReport[]|null $results results + */ + public function setResults(?array $results): self + { + $this->results = $results; + return $this; + } +} diff --git a/Infobip/Model/SmsWebhookOutboundReport.php b/Infobip/Model/SmsWebhookOutboundReport.php new file mode 100644 index 0000000..6170f65 --- /dev/null +++ b/Infobip/Model/SmsWebhookOutboundReport.php @@ -0,0 +1,205 @@ + null, + 'messageId' => null, + 'to' => null, + 'sentAt' => 'date-time', + 'doneAt' => 'date-time', + 'smsCount' => 'int32', + 'mccMnc' => null, + 'callbackData' => null, + 'price' => null, + 'status' => null, + 'error' => null + ]; + + /** + */ + public function __construct( + protected ?string $bulkId = null, + protected ?string $messageId = null, + protected ?string $to = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $sentAt = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $doneAt = null, + protected ?int $smsCount = null, + protected ?string $mccMnc = null, + protected ?string $callbackData = null, + #[Assert\Valid] + + protected ?\Infobip\Model\MessagePrice $price = null, + #[Assert\Valid] + + protected ?\Infobip\Model\MessageStatus $status = null, + #[Assert\Valid] + + protected ?\Infobip\Model\MessageError $error = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getBulkId(): string|null + { + return $this->bulkId; + } + + public function setBulkId(?string $bulkId): self + { + $this->bulkId = $bulkId; + return $this; + } + + public function getMessageId(): string|null + { + return $this->messageId; + } + + public function setMessageId(?string $messageId): self + { + $this->messageId = $messageId; + return $this; + } + + public function getTo(): string|null + { + return $this->to; + } + + public function setTo(?string $to): self + { + $this->to = $to; + return $this; + } + + public function getSentAt(): \DateTime|null + { + return $this->sentAt; + } + + public function setSentAt(?\DateTime $sentAt): self + { + $this->sentAt = $sentAt; + return $this; + } + + public function getDoneAt(): \DateTime|null + { + return $this->doneAt; + } + + public function setDoneAt(?\DateTime $doneAt): self + { + $this->doneAt = $doneAt; + return $this; + } + + public function getSmsCount(): int|null + { + return $this->smsCount; + } + + public function setSmsCount(?int $smsCount): self + { + $this->smsCount = $smsCount; + return $this; + } + + public function getMccMnc(): string|null + { + return $this->mccMnc; + } + + public function setMccMnc(?string $mccMnc): self + { + $this->mccMnc = $mccMnc; + return $this; + } + + public function getCallbackData(): string|null + { + return $this->callbackData; + } + + public function setCallbackData(?string $callbackData): self + { + $this->callbackData = $callbackData; + return $this; + } + + public function getPrice(): \Infobip\Model\MessagePrice|null + { + return $this->price; + } + + public function setPrice(?\Infobip\Model\MessagePrice $price): self + { + $this->price = $price; + return $this; + } + + public function getStatus(): \Infobip\Model\MessageStatus|null + { + return $this->status; + } + + public function setStatus(?\Infobip\Model\MessageStatus $status): self + { + $this->status = $status; + return $this; + } + + public function getError(): \Infobip\Model\MessageError|null + { + return $this->error; + } + + public function setError(?\Infobip\Model\MessageError $error): self + { + $this->error = $error; + return $this; + } +} diff --git a/Infobip/Model/SmsWebhookOutboundReportResponse.php b/Infobip/Model/SmsWebhookOutboundReportResponse.php new file mode 100644 index 0000000..904df0f --- /dev/null +++ b/Infobip/Model/SmsWebhookOutboundReportResponse.php @@ -0,0 +1,72 @@ + null + ]; + + /** + * @param \Infobip\Model\SmsWebhookOutboundReport[] $results + */ + public function __construct( + protected ?array $results = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + /** + * @return \Infobip\Model\SmsWebhookOutboundReport[]|null + */ + public function getResults(): ?array + { + return $this->results; + } + + /** + * @param \Infobip\Model\SmsWebhookOutboundReport[]|null $results The array of objects for your sent messages. + */ + public function setResults(?array $results): self + { + $this->results = $results; + return $this; + } +} diff --git a/Infobip/Model/TfaApplicationConfiguration.php b/Infobip/Model/TfaApplicationConfiguration.php index 8d50300..9be14be 100644 --- a/Infobip/Model/TfaApplicationConfiguration.php +++ b/Infobip/Model/TfaApplicationConfiguration.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class TfaApplicationConfiguration implements ModelInterface, ArrayAccess, \JsonSerializable +class TfaApplicationConfiguration implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'TfaApplicationConfiguration'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'allowMultiplePinVerifications' => 'bool', - 'pinAttempts' => 'int', - 'pinTimeToLive' => 'string', - 'sendPinPerApplicationLimit' => 'string', - 'sendPinPerPhoneNumberLimit' => 'string', - 'verifyPinLimit' => 'string' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'TfaApplicationConfiguration'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'allowMultiplePinVerifications' => null, 'pinAttempts' => 'int32', 'pinTimeToLive' => null, @@ -79,388 +39,92 @@ class TfaApplicationConfiguration implements ModelInterface, ArrayAccess, \JsonS ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'allowMultiplePinVerifications' => 'allowMultiplePinVerifications', - 'pinAttempts' => 'pinAttempts', - 'pinTimeToLive' => 'pinTimeToLive', - 'sendPinPerApplicationLimit' => 'sendPinPerApplicationLimit', - 'sendPinPerPhoneNumberLimit' => 'sendPinPerPhoneNumberLimit', - 'verifyPinLimit' => 'verifyPinLimit' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'allowMultiplePinVerifications' => 'setAllowMultiplePinVerifications', - 'pinAttempts' => 'setPinAttempts', - 'pinTimeToLive' => 'setPinTimeToLive', - 'sendPinPerApplicationLimit' => 'setSendPinPerApplicationLimit', - 'sendPinPerPhoneNumberLimit' => 'setSendPinPerPhoneNumberLimit', - 'verifyPinLimit' => 'setVerifyPinLimit' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] */ - protected static $getters = [ - 'allowMultiplePinVerifications' => 'getAllowMultiplePinVerifications', - 'pinAttempts' => 'getPinAttempts', - 'pinTimeToLive' => 'getPinTimeToLive', - 'sendPinPerApplicationLimit' => 'getSendPinPerApplicationLimit', - 'sendPinPerPhoneNumberLimit' => 'getSendPinPerPhoneNumberLimit', - 'verifyPinLimit' => 'getVerifyPinLimit' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; + public function __construct( + protected ?bool $allowMultiplePinVerifications = true, + protected ?int $pinAttempts = 10, + protected ?string $pinTimeToLive = '15m', + protected ?string $sendPinPerApplicationLimit = '10000/1d', + protected ?string $sendPinPerPhoneNumberLimit = '3/1d', + protected ?string $verifyPinLimit = '1/3s', + ) { } - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['allowMultiplePinVerifications'] = $data['allowMultiplePinVerifications'] ?? true; - $this->container['pinAttempts'] = $data['pinAttempts'] ?? 10; - $this->container['pinTimeToLive'] = $data['pinTimeToLive'] ?? '15m'; - $this->container['sendPinPerApplicationLimit'] = $data['sendPinPerApplicationLimit'] ?? '10000/1d'; - $this->container['sendPinPerPhoneNumberLimit'] = $data['sendPinPerPhoneNumberLimit'] ?? '3/1d'; - $this->container['verifyPinLimit'] = $data['verifyPinLimit'] ?? '1/3s'; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets allowMultiplePinVerifications - * - * @return bool|null - */ - public function getAllowMultiplePinVerifications() + public function getAllowMultiplePinVerifications(): bool|null { - return $this->container['allowMultiplePinVerifications']; + return $this->allowMultiplePinVerifications; } - /** - * Sets allowMultiplePinVerifications - * - * @param bool|null $allowMultiplePinVerifications Indicates whether multiple PIN verification is allowed. - * - * @return self - */ - public function setAllowMultiplePinVerifications($allowMultiplePinVerifications) + public function setAllowMultiplePinVerifications(?bool $allowMultiplePinVerifications): self { - $this->container['allowMultiplePinVerifications'] = $allowMultiplePinVerifications; - + $this->allowMultiplePinVerifications = $allowMultiplePinVerifications; return $this; } - /** - * Gets pinAttempts - * - * @return int|null - */ - public function getPinAttempts() + public function getPinAttempts(): int|null { - return $this->container['pinAttempts']; + return $this->pinAttempts; } - /** - * Sets pinAttempts - * - * @param int|null $pinAttempts Number of possible PIN attempts. - * - * @return self - */ - public function setPinAttempts($pinAttempts) + public function setPinAttempts(?int $pinAttempts): self { - $this->container['pinAttempts'] = $pinAttempts; - + $this->pinAttempts = $pinAttempts; return $this; } - /** - * Gets pinTimeToLive - * - * @return string|null - */ - public function getPinTimeToLive() + public function getPinTimeToLive(): string|null { - return $this->container['pinTimeToLive']; + return $this->pinTimeToLive; } - /** - * Sets pinTimeToLive - * - * @param string|null $pinTimeToLive Validity period of PIN in specified time unit. Required format: `{timeLength}{timeUnit}`. `timeLength` is optional with a default value of 1. `timeUnit` can be set to: `ms`, `s`, `m`, `h` or `d` representing milliseconds, seconds, minutes, hours, and days respectively. Must not exceed one year, although much lower value is recommended. - * - * @return self - */ - public function setPinTimeToLive($pinTimeToLive) + public function setPinTimeToLive(?string $pinTimeToLive): self { - $this->container['pinTimeToLive'] = $pinTimeToLive; - + $this->pinTimeToLive = $pinTimeToLive; return $this; } - /** - * Gets sendPinPerApplicationLimit - * - * @return string|null - */ - public function getSendPinPerApplicationLimit() + public function getSendPinPerApplicationLimit(): string|null { - return $this->container['sendPinPerApplicationLimit']; + return $this->sendPinPerApplicationLimit; } - /** - * Sets sendPinPerApplicationLimit - * - * @param string|null $sendPinPerApplicationLimit Overall number of requests over a specififed time period for generating a PIN and sending an SMS using a single application. Required format: `{attempts}/{timeLength}{timeUnit}`. `attempts` is mandatory and `timeLength` is optional with a default value of 1. `timeUnit` is one of: `ms`, `s`, `m`, `h` or `d` representing milliseconds, seconds, minutes, hours, and days respectively. Must not exceed one year, although much lower value is recommended. - * - * @return self - */ - public function setSendPinPerApplicationLimit($sendPinPerApplicationLimit) + public function setSendPinPerApplicationLimit(?string $sendPinPerApplicationLimit): self { - $this->container['sendPinPerApplicationLimit'] = $sendPinPerApplicationLimit; - + $this->sendPinPerApplicationLimit = $sendPinPerApplicationLimit; return $this; } - /** - * Gets sendPinPerPhoneNumberLimit - * - * @return string|null - */ - public function getSendPinPerPhoneNumberLimit() + public function getSendPinPerPhoneNumberLimit(): string|null { - return $this->container['sendPinPerPhoneNumberLimit']; + return $this->sendPinPerPhoneNumberLimit; } - /** - * Sets sendPinPerPhoneNumberLimit - * - * @param string|null $sendPinPerPhoneNumberLimit Number of requests over a specififed time period for generating a PIN and sending an SMS to one phone number (MSISDN). Required format: `{attempts}/{timeLength}{timeUnit}`. `attempts` is mandatory and `timeLength` is optional with a default value of 1. `timeUnit` is one of: `ms`, `s`, `m`, `h` or `d` representing milliseconds, seconds, minutes, hours, and days respectively. Must not exceed one year, although much lower value is recommended. - * - * @return self - */ - public function setSendPinPerPhoneNumberLimit($sendPinPerPhoneNumberLimit) + public function setSendPinPerPhoneNumberLimit(?string $sendPinPerPhoneNumberLimit): self { - $this->container['sendPinPerPhoneNumberLimit'] = $sendPinPerPhoneNumberLimit; - + $this->sendPinPerPhoneNumberLimit = $sendPinPerPhoneNumberLimit; return $this; } - /** - * Gets verifyPinLimit - * - * @return string|null - */ - public function getVerifyPinLimit() + public function getVerifyPinLimit(): string|null { - return $this->container['verifyPinLimit']; + return $this->verifyPinLimit; } - /** - * Sets verifyPinLimit - * - * @param string|null $verifyPinLimit The number of PIN verification requests over a specififed time period from one phone number (MSISDN). Required format: `{attempts}/{timeLength}{timeUnit}`. `attempts` is mandatory and `timeLength` is optional with a default value of 1. `timeUnit` is one of: `ms`, `s`, `m`, `h` or `d` representing milliseconds, seconds, minutes, hours, and days respectively. Must not exceed one day, although much lower value is recommended. - * - * @return self - */ - public function setVerifyPinLimit($verifyPinLimit) + public function setVerifyPinLimit(?string $verifyPinLimit): self { - $this->container['verifyPinLimit'] = $verifyPinLimit; - + $this->verifyPinLimit = $verifyPinLimit; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/TfaApplicationRequest.php b/Infobip/Model/TfaApplicationRequest.php index f723fee..0866751 100644 --- a/Infobip/Model/TfaApplicationRequest.php +++ b/Infobip/Model/TfaApplicationRequest.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class TfaApplicationRequest implements ModelInterface, ArrayAccess, \JsonSerializable +class TfaApplicationRequest implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'TfaApplicationRequest'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'configuration' => '\Infobip\Model\TfaApplicationConfiguration', - 'enabled' => 'bool', - 'name' => 'string' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'TfaApplicationRequest'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'configuration' => null, 'enabled' => null, 'name' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'configuration' => 'configuration', - 'enabled' => 'enabled', - 'name' => 'name' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] */ - protected static $setters = [ - 'configuration' => 'setConfiguration', - 'enabled' => 'setEnabled', - 'name' => 'setName' - ]; + public function __construct( + #[Assert\NotBlank] - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'configuration' => 'getConfiguration', - 'enabled' => 'getEnabled', - 'name' => 'getName' - ]; + protected string $name, + #[Assert\Valid] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; + protected ?\Infobip\Model\TfaApplicationConfiguration $configuration = null, + protected ?bool $enabled = null, + ) { } - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() + #[Ignore] + public function getModelName(): string { - return self::$setters; + return self::OPENAPI_MODEL_NAME; } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$openAPIModelName; + return self::DISCRIMINATOR; } - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) + public function getConfiguration(): \Infobip\Model\TfaApplicationConfiguration|null { - $this->container['configuration'] = $data['configuration'] ?? null; - $this->container['enabled'] = $data['enabled'] ?? null; - $this->container['name'] = $data['name'] ?? null; + return $this->configuration; } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + public function setConfiguration(?\Infobip\Model\TfaApplicationConfiguration $configuration): self { - $invalidProperties = []; - - if ($this->container['name'] === null) { - $invalidProperties[] = "'name' can't be null"; - } - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets configuration - * - * @return \Infobip\Model\TfaApplicationConfiguration|null - */ - public function getConfiguration() - { - return $this->container['configuration']; - } - - /** - * Sets configuration - * - * @param \Infobip\Model\TfaApplicationConfiguration|null $configuration Created 2FA application configuration. - * - * @return self - */ - public function setConfiguration($configuration) - { - $this->container['configuration'] = $configuration; - + $this->configuration = $configuration; return $this; } - /** - * Gets enabled - * - * @return bool|null - */ - public function getEnabled() + public function getEnabled(): bool|null { - return $this->container['enabled']; + return $this->enabled; } - /** - * Sets enabled - * - * @param bool|null $enabled Indicates whether the created application is enabled. - * - * @return self - */ - public function setEnabled($enabled) + public function setEnabled(?bool $enabled): self { - $this->container['enabled'] = $enabled; - + $this->enabled = $enabled; return $this; } - /** - * Gets name - * - * @return string - */ - public function getName() + public function getName(): string { - return $this->container['name']; + return $this->name; } - /** - * Sets name - * - * @param string $name 2FA application name. - * - * @return self - */ - public function setName($name) + public function setName(string $name): self { - $this->container['name'] = $name; - + $this->name = $name; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/TfaApplicationResponse.php b/Infobip/Model/TfaApplicationResponse.php index b8e8266..e7c7929 100644 --- a/Infobip/Model/TfaApplicationResponse.php +++ b/Infobip/Model/TfaApplicationResponse.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class TfaApplicationResponse implements ModelInterface, ArrayAccess, \JsonSerializable +class TfaApplicationResponse implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'TfaApplicationResponse'; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'TfaApplicationResponse'; - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'applicationId' => 'string', - 'configuration' => '\Infobip\Model\TfaApplicationConfiguration', - 'enabled' => 'bool', - 'name' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'applicationId' => null, 'configuration' => null, 'enabled' => null, @@ -75,332 +37,70 @@ class TfaApplicationResponse implements ModelInterface, ArrayAccess, \JsonSerial ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array */ - public static function openAPITypes() - { - return self::$openAPITypes; - } + public function __construct( + protected ?string $applicationId = null, + #[Assert\Valid] - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; + protected ?\Infobip\Model\TfaApplicationConfiguration $configuration = null, + protected ?bool $enabled = null, + protected ?string $name = null, + ) { } - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'applicationId' => 'applicationId', - 'configuration' => 'configuration', - 'enabled' => 'enabled', - 'name' => 'name' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'applicationId' => 'setApplicationId', - 'configuration' => 'setConfiguration', - 'enabled' => 'setEnabled', - 'name' => 'setName' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'applicationId' => 'getApplicationId', - 'configuration' => 'getConfiguration', - 'enabled' => 'getEnabled', - 'name' => 'getName' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() + #[Ignore] + public function getModelName(): string { - return self::$attributeMap; + return self::OPENAPI_MODEL_NAME; } - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$setters; + return self::DISCRIMINATOR; } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + public function getApplicationId(): string|null { - return self::$getters; + return $this->applicationId; } - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() + public function setApplicationId(?string $applicationId): self { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['applicationId'] = $data['applicationId'] ?? null; - $this->container['configuration'] = $data['configuration'] ?? null; - $this->container['enabled'] = $data['enabled'] ?? null; - $this->container['name'] = $data['name'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $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() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets applicationId - * - * @return string|null - */ - public function getApplicationId() - { - return $this->container['applicationId']; - } - - /** - * Sets applicationId - * - * @param string|null $applicationId The ID of the application that represents your service, e.g. 2FA for login, 2FA for changing the password, etc. - * - * @return self - */ - public function setApplicationId($applicationId) - { - $this->container['applicationId'] = $applicationId; - + $this->applicationId = $applicationId; return $this; } - /** - * Gets configuration - * - * @return \Infobip\Model\TfaApplicationConfiguration|null - */ - public function getConfiguration() + public function getConfiguration(): \Infobip\Model\TfaApplicationConfiguration|null { - return $this->container['configuration']; + return $this->configuration; } - /** - * Sets configuration - * - * @param \Infobip\Model\TfaApplicationConfiguration|null $configuration Created 2FA application configuration. - * - * @return self - */ - public function setConfiguration($configuration) + public function setConfiguration(?\Infobip\Model\TfaApplicationConfiguration $configuration): self { - $this->container['configuration'] = $configuration; - + $this->configuration = $configuration; return $this; } - /** - * Gets enabled - * - * @return bool|null - */ - public function getEnabled() + public function getEnabled(): bool|null { - return $this->container['enabled']; + return $this->enabled; } - /** - * Sets enabled - * - * @param bool|null $enabled Indicates whether the created application is enabled. - * - * @return self - */ - public function setEnabled($enabled) + public function setEnabled(?bool $enabled): self { - $this->container['enabled'] = $enabled; - + $this->enabled = $enabled; return $this; } - /** - * Gets name - * - * @return string|null - */ - public function getName() + public function getName(): string|null { - return $this->container['name']; + return $this->name; } - /** - * Sets name - * - * @param string|null $name 2FA application name. - * - * @return self - */ - public function setName($name) + public function setName(?string $name): self { - $this->container['name'] = $name; - + $this->name = $name; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/TfaCreateMessageRequest.php b/Infobip/Model/TfaCreateMessageRequest.php index ab49fb3..bc2f9ad 100644 --- a/Infobip/Model/TfaCreateMessageRequest.php +++ b/Infobip/Model/TfaCreateMessageRequest.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class TfaCreateMessageRequest implements ModelInterface, ArrayAccess, \JsonSerializable +class TfaCreateMessageRequest implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'TfaCreateMessageRequest'; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'TfaCreateMessageRequest'; - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'language' => '\Infobip\Model\TfaLanguage', - 'messageText' => 'string', - 'pinLength' => 'int', - 'pinType' => '\Infobip\Model\TfaPinType', - 'regional' => '\Infobip\Model\TfaRegionalOptions', - 'repeatDTMF' => 'string', - 'senderId' => 'string', - 'speechRate' => 'double' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'language' => null, 'messageText' => null, 'pinLength' => 'int32', @@ -83,450 +41,125 @@ class TfaCreateMessageRequest implements ModelInterface, ArrayAccess, \JsonSeria ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'language' => 'language', - 'messageText' => 'messageText', - 'pinLength' => 'pinLength', - 'pinType' => 'pinType', - 'regional' => 'regional', - 'repeatDTMF' => 'repeatDTMF', - 'senderId' => 'senderId', - 'speechRate' => 'speechRate' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] */ - protected static $setters = [ - 'language' => 'setLanguage', - 'messageText' => 'setMessageText', - 'pinLength' => 'setPinLength', - 'pinType' => 'setPinType', - 'regional' => 'setRegional', - 'repeatDTMF' => 'setRepeatDTMF', - 'senderId' => 'setSenderId', - 'speechRate' => 'setSpeechRate' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'language' => 'getLanguage', - 'messageText' => 'getMessageText', - 'pinLength' => 'getPinLength', - 'pinType' => 'getPinType', - 'regional' => 'getRegional', - 'repeatDTMF' => 'getRepeatDTMF', - 'senderId' => 'getSenderId', - 'speechRate' => 'getSpeechRate' - ]; + public function __construct( + #[Assert\NotBlank] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } + protected string $messageText, + #[Assert\NotBlank] + #[Assert\Choice(['NUMERIC','ALPHA','HEX','ALPHANUMERIC',])] - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } + protected string $pinType, + #[Assert\Choice(['en','es','ca','da','nl','fr','de','it','ja','ko','no','pl','ru','sv','fi','hr','sl','ro','pt-pt','pt-br','zh-cn','zh-tw',])] - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } + protected ?string $language = null, + protected ?int $pinLength = null, + #[Assert\Valid] - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; + protected ?\Infobip\Model\TfaRegionalOptions $regional = null, + protected ?string $repeatDTMF = null, + protected ?string $senderId = null, + protected ?float $speechRate = null, + ) { } - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) + #[Ignore] + public function getModelName(): string { - $this->container['language'] = $data['language'] ?? null; - $this->container['messageText'] = $data['messageText'] ?? null; - $this->container['pinLength'] = $data['pinLength'] ?? null; - $this->container['pinType'] = $data['pinType'] ?? null; - $this->container['regional'] = $data['regional'] ?? null; - $this->container['repeatDTMF'] = $data['repeatDTMF'] ?? null; - $this->container['senderId'] = $data['senderId'] ?? null; - $this->container['speechRate'] = $data['speechRate'] ?? null; + return self::OPENAPI_MODEL_NAME; } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public static function getDiscriminator(): ?string { - $invalidProperties = []; - - if ($this->container['messageText'] === null) { - $invalidProperties[] = "'messageText' can't be null"; - } - if ($this->container['pinType'] === null) { - $invalidProperties[] = "'pinType' can't be null"; - } - return $invalidProperties; + return self::DISCRIMINATOR; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + public function getLanguage(): mixed { - return count($this->listInvalidProperties()) === 0; + return $this->language; } - - /** - * Gets language - * - * @return \Infobip\Model\TfaLanguage|null - */ - public function getLanguage() + public function setLanguage($language): self { - return $this->container['language']; - } - - /** - * Sets language - * - * @param \Infobip\Model\TfaLanguage|null $language The language code which message is written in used when sending text-to-speech messages. If not defined, it will default to English (`en`). - * - * @return self - */ - public function setLanguage($language) - { - $this->container['language'] = $language; - + $this->language = $language; return $this; } - /** - * Gets messageText - * - * @return string - */ - public function getMessageText() + public function getMessageText(): string { - return $this->container['messageText']; + return $this->messageText; } - /** - * Sets messageText - * - * @param string $messageText Content of the message being sent which contains at minimum one placeholder for a PIN code (`{{pin}}`). Placeholder format is `{{placeholderName}}`. - * - * @return self - */ - public function setMessageText($messageText) + public function setMessageText(string $messageText): self { - $this->container['messageText'] = $messageText; - + $this->messageText = $messageText; return $this; } - /** - * Gets pinLength - * - * @return int|null - */ - public function getPinLength() + public function getPinLength(): int|null { - return $this->container['pinLength']; + return $this->pinLength; } - /** - * Sets pinLength - * - * @param int|null $pinLength PIN code length. - * - * @return self - */ - public function setPinLength($pinLength) + public function setPinLength(?int $pinLength): self { - $this->container['pinLength'] = $pinLength; - + $this->pinLength = $pinLength; return $this; } - /** - * Gets pinType - * - * @return \Infobip\Model\TfaPinType - */ - public function getPinType() + public function getPinType(): mixed { - return $this->container['pinType']; + return $this->pinType; } - /** - * Sets pinType - * - * @param \Infobip\Model\TfaPinType $pinType Type of PIN code that will be generated and sent as part of 2FA message. - * - * @return self - */ - public function setPinType($pinType) + public function setPinType($pinType): self { - $this->container['pinType'] = $pinType; - + $this->pinType = $pinType; return $this; } - /** - * Gets regional - * - * @return \Infobip\Model\TfaRegionalOptions|null - */ - public function getRegional() + public function getRegional(): \Infobip\Model\TfaRegionalOptions|null { - return $this->container['regional']; + return $this->regional; } - /** - * Sets regional - * - * @param \Infobip\Model\TfaRegionalOptions|null $regional Region-specific parameters, often imposed by local laws. Use this, if country or region that you are sending a message to requires additional information. - * - * @return self - */ - public function setRegional($regional) + public function setRegional(?\Infobip\Model\TfaRegionalOptions $regional): self { - $this->container['regional'] = $regional; - + $this->regional = $regional; return $this; } - /** - * Gets repeatDTMF - * - * @return string|null - */ - public function getRepeatDTMF() + public function getRepeatDTMF(): string|null { - return $this->container['repeatDTMF']; + return $this->repeatDTMF; } - /** - * Sets repeatDTMF - * - * @param string|null $repeatDTMF If the PIN is sent as a voice message, the DTMF code allows the recipient to replay the message. - * - * @return self - */ - public function setRepeatDTMF($repeatDTMF) + public function setRepeatDTMF(?string $repeatDTMF): self { - $this->container['repeatDTMF'] = $repeatDTMF; - + $this->repeatDTMF = $repeatDTMF; return $this; } - /** - * Gets senderId - * - * @return string|null - */ - public function getSenderId() + public function getSenderId(): string|null { - return $this->container['senderId']; + return $this->senderId; } - /** - * Sets senderId - * - * @param string|null $senderId The name that will appear as the sender of the 2FA message (Example: CompanyName). - * - * @return self - */ - public function setSenderId($senderId) + public function setSenderId(?string $senderId): self { - $this->container['senderId'] = $senderId; - + $this->senderId = $senderId; return $this; } - /** - * Gets speechRate - * - * @return double|null - */ - public function getSpeechRate() + public function getSpeechRate(): float|null { - return $this->container['speechRate']; + return $this->speechRate; } - /** - * Sets speechRate - * - * @param double|null $speechRate The speed of narration for messages sent as voice. Supported range is from `0.5` to `2`. - * - * @return self - */ - public function setSpeechRate($speechRate) + public function setSpeechRate(?float $speechRate): self { - $this->container['speechRate'] = $speechRate; - + $this->speechRate = $speechRate; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/TfaIndiaDltOptions.php b/Infobip/Model/TfaIndiaDltOptions.php index 155531a..75288b7 100644 --- a/Infobip/Model/TfaIndiaDltOptions.php +++ b/Infobip/Model/TfaIndiaDltOptions.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class TfaIndiaDltOptions implements ModelInterface, ArrayAccess, \JsonSerializable +class TfaIndiaDltOptions implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'TfaIndiaDltOptions'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'contentTemplateId' => 'string', - 'principalEntityId' => 'string' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'TfaIndiaDltOptions'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'contentTemplateId' => null, 'principalEntityId' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'contentTemplateId' => 'contentTemplateId', - 'principalEntityId' => 'principalEntityId' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] */ - protected static $setters = [ - 'contentTemplateId' => 'setContentTemplateId', - 'principalEntityId' => 'setPrincipalEntityId' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'contentTemplateId' => 'getContentTemplateId', - 'principalEntityId' => 'getPrincipalEntityId' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 30)] + #[Assert\Length(min: 0)] - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; + protected string $principalEntityId, + #[Assert\Length(max: 30)] + #[Assert\Length(min: 0)] - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['contentTemplateId'] = $data['contentTemplateId'] ?? null; - $this->container['principalEntityId'] = $data['principalEntityId'] ?? null; + protected ?string $contentTemplateId = null, + ) { } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - if (!is_null($this->container['contentTemplateId']) && (mb_strlen($this->container['contentTemplateId']) > 30)) { - $invalidProperties[] = "invalid value for 'contentTemplateId', the character length must be smaller than or equal to 30."; - } - - if (!is_null($this->container['contentTemplateId']) && (mb_strlen($this->container['contentTemplateId']) < 0)) { - $invalidProperties[] = "invalid value for 'contentTemplateId', the character length must be bigger than or equal to 0."; - } - - if ($this->container['principalEntityId'] === null) { - $invalidProperties[] = "'principalEntityId' can't be null"; - } - if ((mb_strlen($this->container['principalEntityId']) > 30)) { - $invalidProperties[] = "invalid value for 'principalEntityId', the character length must be smaller than or equal to 30."; - } - - if ((mb_strlen($this->container['principalEntityId']) < 0)) { - $invalidProperties[] = "invalid value for 'principalEntityId', the character length must be bigger than or equal to 0."; - } - - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets contentTemplateId - * - * @return string|null - */ - public function getContentTemplateId() + public function getContentTemplateId(): string|null { - return $this->container['contentTemplateId']; + return $this->contentTemplateId; } - /** - * Sets contentTemplateId - * - * @param string|null $contentTemplateId Registered DLT content template ID which matches message you are sending. - * - * @return self - */ - public function setContentTemplateId($contentTemplateId) + public function setContentTemplateId(?string $contentTemplateId): self { - if (!is_null($contentTemplateId) && (mb_strlen($contentTemplateId) > 30)) { - throw new \InvalidArgumentException('invalid length for $contentTemplateId when calling TfaIndiaDltOptions., must be smaller than or equal to 30.'); - } - if (!is_null($contentTemplateId) && (mb_strlen($contentTemplateId) < 0)) { - throw new \InvalidArgumentException('invalid length for $contentTemplateId when calling TfaIndiaDltOptions., must be bigger than or equal to 0.'); - } - - $this->container['contentTemplateId'] = $contentTemplateId; - + $this->contentTemplateId = $contentTemplateId; return $this; } - /** - * Gets principalEntityId - * - * @return string - */ - public function getPrincipalEntityId() + public function getPrincipalEntityId(): string { - return $this->container['principalEntityId']; + return $this->principalEntityId; } - /** - * Sets principalEntityId - * - * @param string $principalEntityId Your assigned DLT principal entity ID. - * - * @return self - */ - public function setPrincipalEntityId($principalEntityId) + public function setPrincipalEntityId(string $principalEntityId): self { - if ((mb_strlen($principalEntityId) > 30)) { - throw new \InvalidArgumentException('invalid length for $principalEntityId when calling TfaIndiaDltOptions., must be smaller than or equal to 30.'); - } - if ((mb_strlen($principalEntityId) < 0)) { - throw new \InvalidArgumentException('invalid length for $principalEntityId when calling TfaIndiaDltOptions., must be bigger than or equal to 0.'); - } - - $this->container['principalEntityId'] = $principalEntityId; - + $this->principalEntityId = $principalEntityId; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/TfaLanguage.php b/Infobip/Model/TfaLanguage.php index 71c8870..18333b8 100644 --- a/Infobip/Model/TfaLanguage.php +++ b/Infobip/Model/TfaLanguage.php @@ -1,14 +1,8 @@ value = $value; + } + + public static function EN(): TfaLanguage + { + return new self('en'); + } + + public static function ES(): TfaLanguage + { + return new self('es'); + } + + public static function CA(): TfaLanguage + { + return new self('ca'); + } + + public static function DA(): TfaLanguage + { + return new self('da'); + } + + public static function NL(): TfaLanguage + { + return new self('nl'); + } + + public static function FR(): TfaLanguage + { + return new self('fr'); + } + + public static function DE(): TfaLanguage + { + return new self('de'); + } + + public static function IT(): TfaLanguage + { + return new self('it'); + } + + public static function JA(): TfaLanguage + { + return new self('ja'); + } + + public static function KO(): TfaLanguage + { + return new self('ko'); + } + + public static function NO(): TfaLanguage + { + return new self('no'); + } + + public static function PL(): TfaLanguage + { + return new self('pl'); + } + + public static function RU(): TfaLanguage + { + return new self('ru'); + } + + public static function SV(): TfaLanguage + { + return new self('sv'); + } + + public static function FI(): TfaLanguage + { + return new self('fi'); + } + + public static function HR(): TfaLanguage + { + return new self('hr'); + } + + public static function SL(): TfaLanguage + { + return new self('sl'); + } + + public static function RO(): TfaLanguage + { + return new self('ro'); + } + + public static function PT_PT(): TfaLanguage + { + return new self('pt-pt'); + } + + public static function PT_BR(): TfaLanguage + { + return new self('pt-br'); + } + + public static function ZH_CN(): TfaLanguage + { + return new self('zh-cn'); + } + + public static function ZH_TW(): TfaLanguage + { + return new self('zh-tw'); + } + + public function __toString(): string + { + return $this->value; } } diff --git a/Infobip/Model/TfaMessage.php b/Infobip/Model/TfaMessage.php index 1eed525..d4c9d31 100644 --- a/Infobip/Model/TfaMessage.php +++ b/Infobip/Model/TfaMessage.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class TfaMessage implements ModelInterface, ArrayAccess, \JsonSerializable +class TfaMessage implements ModelInterface { - public const DISCRIMINATOR = null; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'TfaMessage'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'TfaMessage'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'applicationId' => 'string', - 'language' => '\Infobip\Model\TfaLanguage', - 'messageId' => 'string', - 'messageText' => 'string', - 'pinLength' => 'int', - 'pinPlaceholder' => 'string', - 'pinType' => '\Infobip\Model\TfaPinType', - 'regional' => '\Infobip\Model\TfaRegionalOptions', - 'repeatDTMF' => 'string', - 'senderId' => 'string', - 'speechRate' => 'double' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'applicationId' => null, 'language' => null, 'messageId' => null, @@ -89,528 +44,158 @@ class TfaMessage implements ModelInterface, ArrayAccess, \JsonSerializable ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'applicationId' => 'applicationId', - 'language' => 'language', - 'messageId' => 'messageId', - 'messageText' => 'messageText', - 'pinLength' => 'pinLength', - 'pinPlaceholder' => 'pinPlaceholder', - 'pinType' => 'pinType', - 'regional' => 'regional', - 'repeatDTMF' => 'repeatDTMF', - 'senderId' => 'senderId', - 'speechRate' => 'speechRate' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'applicationId' => 'setApplicationId', - 'language' => 'setLanguage', - 'messageId' => 'setMessageId', - 'messageText' => 'setMessageText', - 'pinLength' => 'setPinLength', - 'pinPlaceholder' => 'setPinPlaceholder', - 'pinType' => 'setPinType', - 'regional' => 'setRegional', - 'repeatDTMF' => 'setRepeatDTMF', - 'senderId' => 'setSenderId', - 'speechRate' => 'setSpeechRate' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'applicationId' => 'getApplicationId', - 'language' => 'getLanguage', - 'messageId' => 'getMessageId', - 'messageText' => 'getMessageText', - 'pinLength' => 'getPinLength', - 'pinPlaceholder' => 'getPinPlaceholder', - 'pinType' => 'getPinType', - 'regional' => 'getRegional', - 'repeatDTMF' => 'getRepeatDTMF', - 'senderId' => 'getSenderId', - 'speechRate' => 'getSpeechRate' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string */ - public function getModelName() - { - return self::$openAPIModelName; - } - - + public function __construct( + protected ?string $applicationId = null, + #[Assert\Choice(['en','es','ca','da','nl','fr','de','it','ja','ko','no','pl','ru','sv','fi','hr','sl','ro','pt-pt','pt-br','zh-cn','zh-tw',])] + protected ?string $language = null, + protected ?string $messageId = null, + protected ?string $messageText = null, + protected ?int $pinLength = null, + protected ?string $pinPlaceholder = null, + #[Assert\Choice(['NUMERIC','ALPHA','HEX','ALPHANUMERIC',])] + protected ?string $pinType = null, + #[Assert\Valid] - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['applicationId'] = $data['applicationId'] ?? null; - $this->container['language'] = $data['language'] ?? null; - $this->container['messageId'] = $data['messageId'] ?? null; - $this->container['messageText'] = $data['messageText'] ?? null; - $this->container['pinLength'] = $data['pinLength'] ?? null; - $this->container['pinPlaceholder'] = $data['pinPlaceholder'] ?? null; - $this->container['pinType'] = $data['pinType'] ?? null; - $this->container['regional'] = $data['regional'] ?? null; - $this->container['repeatDTMF'] = $data['repeatDTMF'] ?? null; - $this->container['senderId'] = $data['senderId'] ?? null; - $this->container['speechRate'] = $data['speechRate'] ?? null; + protected ?\Infobip\Model\TfaRegionalOptions $regional = null, + protected ?string $repeatDTMF = null, + protected ?string $senderId = null, + protected ?float $speechRate = null, + ) { } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets applicationId - * - * @return string|null - */ - public function getApplicationId() + public function getApplicationId(): string|null { - return $this->container['applicationId']; + return $this->applicationId; } - /** - * Sets applicationId - * - * @param string|null $applicationId The ID of the application that represents your service (e.g. 2FA for login, 2FA for changing the password, etc.) for which the requested message has been created. - * - * @return self - */ - public function setApplicationId($applicationId) + public function setApplicationId(?string $applicationId): self { - $this->container['applicationId'] = $applicationId; - + $this->applicationId = $applicationId; return $this; } - /** - * Gets language - * - * @return \Infobip\Model\TfaLanguage|null - */ - public function getLanguage() + public function getLanguage(): mixed { - return $this->container['language']; + return $this->language; } - /** - * Sets language - * - * @param \Infobip\Model\TfaLanguage|null $language The language code which message is written in used when sending text-to-speech messages. If not defined, it will default to English (`en`). - * - * @return self - */ - public function setLanguage($language) + public function setLanguage($language): self { - $this->container['language'] = $language; - + $this->language = $language; return $this; } - /** - * Gets messageId - * - * @return string|null - */ - public function getMessageId() + public function getMessageId(): string|null { - return $this->container['messageId']; + return $this->messageId; } - /** - * Sets messageId - * - * @param string|null $messageId The ID of the message template (message body with the PIN placeholder) that is sent to the recipient. - * - * @return self - */ - public function setMessageId($messageId) + public function setMessageId(?string $messageId): self { - $this->container['messageId'] = $messageId; - + $this->messageId = $messageId; return $this; } - /** - * Gets messageText - * - * @return string|null - */ - public function getMessageText() + public function getMessageText(): string|null { - return $this->container['messageText']; + return $this->messageText; } - /** - * Sets messageText - * - * @param string|null $messageText Text of a message that will be sent. Message text must contain `pinPlaceholder`. - * - * @return self - */ - public function setMessageText($messageText) + public function setMessageText(?string $messageText): self { - $this->container['messageText'] = $messageText; - + $this->messageText = $messageText; return $this; } - /** - * Gets pinLength - * - * @return int|null - */ - public function getPinLength() + public function getPinLength(): int|null { - return $this->container['pinLength']; + return $this->pinLength; } - /** - * Sets pinLength - * - * @param int|null $pinLength PIN code length. - * - * @return self - */ - public function setPinLength($pinLength) + public function setPinLength(?int $pinLength): self { - $this->container['pinLength'] = $pinLength; - + $this->pinLength = $pinLength; return $this; } - /** - * Gets pinPlaceholder - * - * @return string|null - */ - public function getPinPlaceholder() + public function getPinPlaceholder(): string|null { - return $this->container['pinPlaceholder']; + return $this->pinPlaceholder; } - /** - * Sets pinPlaceholder - * - * @param string|null $pinPlaceholder The PIN code placeholder that will be replaced with a generated PIN code. - * - * @return self - */ - public function setPinPlaceholder($pinPlaceholder) + public function setPinPlaceholder(?string $pinPlaceholder): self { - $this->container['pinPlaceholder'] = $pinPlaceholder; - + $this->pinPlaceholder = $pinPlaceholder; return $this; } - /** - * Gets pinType - * - * @return \Infobip\Model\TfaPinType|null - */ - public function getPinType() + public function getPinType(): mixed { - return $this->container['pinType']; + return $this->pinType; } - /** - * Sets pinType - * - * @param \Infobip\Model\TfaPinType|null $pinType The type of PIN code that will be generated and sent as part of 2FA message. You can set PIN type to numeric, alpha, alphanumeric or hex. - * - * @return self - */ - public function setPinType($pinType) + public function setPinType($pinType): self { - $this->container['pinType'] = $pinType; - + $this->pinType = $pinType; return $this; } - /** - * Gets regional - * - * @return \Infobip\Model\TfaRegionalOptions|null - */ - public function getRegional() + public function getRegional(): \Infobip\Model\TfaRegionalOptions|null { - return $this->container['regional']; + return $this->regional; } - /** - * Sets regional - * - * @param \Infobip\Model\TfaRegionalOptions|null $regional Region specific parameters, often specified by local laws. Use this if country or region that you are sending SMS to requires some extra parameters. - * - * @return self - */ - public function setRegional($regional) + public function setRegional(?\Infobip\Model\TfaRegionalOptions $regional): self { - $this->container['regional'] = $regional; - + $this->regional = $regional; return $this; } - /** - * Gets repeatDTMF - * - * @return string|null - */ - public function getRepeatDTMF() + public function getRepeatDTMF(): string|null { - return $this->container['repeatDTMF']; + return $this->repeatDTMF; } - /** - * Sets repeatDTMF - * - * @param string|null $repeatDTMF In case PIN message is sent by Voice, DTMF code will enable replaying the message. - * - * @return self - */ - public function setRepeatDTMF($repeatDTMF) + public function setRepeatDTMF(?string $repeatDTMF): self { - $this->container['repeatDTMF'] = $repeatDTMF; - + $this->repeatDTMF = $repeatDTMF; return $this; } - /** - * Gets senderId - * - * @return string|null - */ - public function getSenderId() + public function getSenderId(): string|null { - return $this->container['senderId']; + return $this->senderId; } - /** - * Sets senderId - * - * @param string|null $senderId The name that will appear as the sender of the 2FA message (Example: CompanyName). - * - * @return self - */ - public function setSenderId($senderId) + public function setSenderId(?string $senderId): self { - $this->container['senderId'] = $senderId; - + $this->senderId = $senderId; return $this; } - /** - * Gets speechRate - * - * @return double|null - */ - public function getSpeechRate() + public function getSpeechRate(): float|null { - return $this->container['speechRate']; + return $this->speechRate; } - /** - * Sets speechRate - * - * @param double|null $speechRate In case PIN message is sent by Voice, the speed of speech can be set for the message. Supported range is from `0.5` to `2`. - * - * @return self - */ - public function setSpeechRate($speechRate) + public function setSpeechRate(?float $speechRate): self { - $this->container['speechRate'] = $speechRate; - + $this->speechRate = $speechRate; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/TfaPinType.php b/Infobip/Model/TfaPinType.php index 39984e9..ca2a7cc 100644 --- a/Infobip/Model/TfaPinType.php +++ b/Infobip/Model/TfaPinType.php @@ -1,14 +1,8 @@ value = $value; + } + + public static function NUMERIC(): TfaPinType + { + return new self('NUMERIC'); + } + + public static function ALPHA(): TfaPinType + { + return new self('ALPHA'); + } + + public static function HEX(): TfaPinType + { + return new self('HEX'); + } + + public static function ALPHANUMERIC(): TfaPinType + { + return new self('ALPHANUMERIC'); + } + + public function __toString(): string { - return [ - self::NUMERIC, - self::ALPHA, - self::HEX, - self::ALPHANUMERIC, - ]; + return $this->value; } } diff --git a/Infobip/Model/TfaRegionalOptions.php b/Infobip/Model/TfaRegionalOptions.php index 9a3839d..90dacc9 100644 --- a/Infobip/Model/TfaRegionalOptions.php +++ b/Infobip/Model/TfaRegionalOptions.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class TfaRegionalOptions implements ModelInterface, ArrayAccess, \JsonSerializable +class TfaRegionalOptions implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'TfaRegionalOptions'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'indiaDlt' => '\Infobip\Model\TfaIndiaDltOptions' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'TfaRegionalOptions'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'indiaDlt' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'indiaDlt' => 'indiaDlt' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'indiaDlt' => 'setIndiaDlt' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'indiaDlt' => 'getIndiaDlt' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] */ - protected $container = []; + public function __construct( + #[Assert\Valid] - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['indiaDlt'] = $data['indiaDlt'] ?? null; + protected ?\Infobip\Model\TfaIndiaDltOptions $indiaDlt = null, + ) { } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets indiaDlt - * - * @return \Infobip\Model\TfaIndiaDltOptions|null - */ - public function getIndiaDlt() + public function getIndiaDlt(): \Infobip\Model\TfaIndiaDltOptions|null { - return $this->container['indiaDlt']; + return $this->indiaDlt; } - /** - * Sets indiaDlt - * - * @param \Infobip\Model\TfaIndiaDltOptions|null $indiaDlt Distributed Ledger Technology (DLT) specific parameters required for sending SMS to phone numbers registered in India. - * - * @return self - */ - public function setIndiaDlt($indiaDlt) + public function setIndiaDlt(?\Infobip\Model\TfaIndiaDltOptions $indiaDlt): self { - $this->container['indiaDlt'] = $indiaDlt; - + $this->indiaDlt = $indiaDlt; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/TfaResendPinRequest.php b/Infobip/Model/TfaResendPinRequest.php index 504df6a..bdc0a36 100644 --- a/Infobip/Model/TfaResendPinRequest.php +++ b/Infobip/Model/TfaResendPinRequest.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class TfaResendPinRequest implements ModelInterface, ArrayAccess, \JsonSerializable +class TfaResendPinRequest implements ModelInterface { - public const DISCRIMINATOR = null; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'TfaResendPinRequest'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'TfaResendPinRequest'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'placeholders' => 'array' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'placeholders' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'placeholders' => 'placeholders' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'placeholders' => 'setPlaceholders' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] + * @param array $placeholders */ - protected static $getters = [ - 'placeholders' => 'getPlaceholders' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; + public function __construct( + protected ?array $placeholders = null, + ) { } - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() + #[Ignore] + public function getModelName(): string { - return self::$setters; + return self::OPENAPI_MODEL_NAME; } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$getters; + return self::DISCRIMINATOR; } /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['placeholders'] = $data['placeholders'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $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() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets placeholders - * * @return array|null */ public function getPlaceholders() { - return $this->container['placeholders']; + return $this->placeholders; } /** - * Sets placeholders - * * @param array|null $placeholders Key value pairs that will be replaced during message sending. Placeholder keys should NOT contain curly brackets and should NOT contain a `pin` placeholder. Valid example: `\"placeholders\":{\"firstName\":\"John\"}` - * - * @return self */ - public function setPlaceholders($placeholders) + public function setPlaceholders(?array $placeholders): self { - $this->container['placeholders'] = $placeholders; - + $this->placeholders = $placeholders; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/TfaStartAuthenticationRequest.php b/Infobip/Model/TfaStartAuthenticationRequest.php index 8765504..222804a 100644 --- a/Infobip/Model/TfaStartAuthenticationRequest.php +++ b/Infobip/Model/TfaStartAuthenticationRequest.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class TfaStartAuthenticationRequest implements ModelInterface, ArrayAccess, \JsonSerializable +class TfaStartAuthenticationRequest implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'TfaStartAuthenticationRequest'; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'TfaStartAuthenticationRequest'; - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'applicationId' => 'string', - 'from' => 'string', - 'messageId' => 'string', - 'placeholders' => 'array', - 'to' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'applicationId' => null, 'from' => null, 'messageId' => null, @@ -77,369 +38,93 @@ class TfaStartAuthenticationRequest implements ModelInterface, ArrayAccess, \Jso ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'applicationId' => 'applicationId', - 'from' => 'from', - 'messageId' => 'messageId', - 'placeholders' => 'placeholders', - 'to' => 'to' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'applicationId' => 'setApplicationId', - 'from' => 'setFrom', - 'messageId' => 'setMessageId', - 'placeholders' => 'setPlaceholders', - 'to' => 'setTo' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] + * @param array $placeholders */ - protected static $getters = [ - 'applicationId' => 'getApplicationId', - 'from' => 'getFrom', - 'messageId' => 'getMessageId', - 'placeholders' => 'getPlaceholders', - 'to' => 'getTo' - ]; + public function __construct( + #[Assert\NotBlank] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } + protected string $applicationId, + #[Assert\NotBlank] - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } + protected string $messageId, + #[Assert\NotBlank] - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['applicationId'] = $data['applicationId'] ?? null; - $this->container['from'] = $data['from'] ?? null; - $this->container['messageId'] = $data['messageId'] ?? null; - $this->container['placeholders'] = $data['placeholders'] ?? null; - $this->container['to'] = $data['to'] ?? null; + protected string $to, + protected ?string $from = null, + protected ?array $placeholders = null, + ) { } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - if ($this->container['applicationId'] === null) { - $invalidProperties[] = "'applicationId' can't be null"; - } - if ($this->container['messageId'] === null) { - $invalidProperties[] = "'messageId' can't be null"; - } - if ($this->container['to'] === null) { - $invalidProperties[] = "'to' can't be null"; - } - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets applicationId - * - * @return string - */ - public function getApplicationId() + public function getApplicationId(): string { - return $this->container['applicationId']; + return $this->applicationId; } - /** - * Sets applicationId - * - * @param string $applicationId The ID of the application that represents your service, e.g. 2FA for login, 2FA for changing the password, etc. - * - * @return self - */ - public function setApplicationId($applicationId) + public function setApplicationId(string $applicationId): self { - $this->container['applicationId'] = $applicationId; - + $this->applicationId = $applicationId; return $this; } - /** - * Gets from - * - * @return string|null - */ - public function getFrom() + public function getFrom(): string|null { - return $this->container['from']; + return $this->from; } - /** - * Sets from - * - * @param string|null $from Use this parameter if you wish to override the sender ID from the [created](#channels/sms/create-2fa-message-template) message template parameter `senderId`. - * - * @return self - */ - public function setFrom($from) + public function setFrom(?string $from): self { - $this->container['from'] = $from; - + $this->from = $from; return $this; } - /** - * Gets messageId - * - * @return string - */ - public function getMessageId() + public function getMessageId(): string { - return $this->container['messageId']; + return $this->messageId; } - /** - * Sets messageId - * - * @param string $messageId The ID of the message template (message body with the PIN placeholder) that is sent to the recipient. - * - * @return self - */ - public function setMessageId($messageId) + public function setMessageId(string $messageId): self { - $this->container['messageId'] = $messageId; - + $this->messageId = $messageId; return $this; } /** - * Gets placeholders - * * @return array|null */ public function getPlaceholders() { - return $this->container['placeholders']; + return $this->placeholders; } /** - * Sets placeholders - * * @param array|null $placeholders Key value pairs that will be replaced during message sending. Placeholder keys should NOT contain curly brackets and should NOT contain a `pin` placeholder. Valid example: `\"placeholders\":{\"firstName\":\"John\"}` - * - * @return self */ - public function setPlaceholders($placeholders) + public function setPlaceholders(?array $placeholders): self { - $this->container['placeholders'] = $placeholders; - + $this->placeholders = $placeholders; return $this; } - /** - * Gets to - * - * @return string - */ - public function getTo() + public function getTo(): string { - return $this->container['to']; + return $this->to; } - /** - * Sets to - * - * @param string $to Phone number to which the 2FA message will be sent. Example: 41793026727. - * - * @return self - */ - public function setTo($to) + public function setTo(string $to): self { - $this->container['to'] = $to; - + $this->to = $to; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/TfaStartAuthenticationResponse.php b/Infobip/Model/TfaStartAuthenticationResponse.php index 6f1e250..6dd8a66 100644 --- a/Infobip/Model/TfaStartAuthenticationResponse.php +++ b/Infobip/Model/TfaStartAuthenticationResponse.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class TfaStartAuthenticationResponse implements ModelInterface, ArrayAccess, \JsonSerializable +class TfaStartAuthenticationResponse implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'TfaStartAuthenticationResponse'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'callStatus' => 'string', - 'ncStatus' => 'string', - 'pinId' => 'string', - 'smsStatus' => 'string', - 'to' => 'string' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'TfaStartAuthenticationResponse'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'callStatus' => null, 'ncStatus' => null, 'pinId' => null, @@ -77,360 +38,80 @@ class TfaStartAuthenticationResponse implements ModelInterface, ArrayAccess, \Js ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'callStatus' => 'callStatus', - 'ncStatus' => 'ncStatus', - 'pinId' => 'pinId', - 'smsStatus' => 'smsStatus', - 'to' => 'to' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'callStatus' => 'setCallStatus', - 'ncStatus' => 'setNcStatus', - 'pinId' => 'setPinId', - 'smsStatus' => 'setSmsStatus', - 'to' => 'setTo' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'callStatus' => 'getCallStatus', - 'ncStatus' => 'getNcStatus', - 'pinId' => 'getPinId', - 'smsStatus' => 'getSmsStatus', - 'to' => 'getTo' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array */ - public static function attributeMap() - { - return self::$attributeMap; + public function __construct( + protected ?string $callStatus = null, + protected ?string $ncStatus = null, + protected ?string $pinId = null, + protected ?string $smsStatus = null, + protected ?string $to = null, + ) { } - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() + #[Ignore] + public function getModelName(): string { - return self::$setters; + return self::OPENAPI_MODEL_NAME; } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$getters; + return self::DISCRIMINATOR; } - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() + public function getCallStatus(): string|null { - return self::$openAPIModelName; + return $this->callStatus; } - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['callStatus'] = $data['callStatus'] ?? null; - $this->container['ncStatus'] = $data['ncStatus'] ?? null; - $this->container['pinId'] = $data['pinId'] ?? null; - $this->container['smsStatus'] = $data['smsStatus'] ?? null; - $this->container['to'] = $data['to'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $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() + public function setCallStatus(?string $callStatus): self { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets callStatus - * - * @return string|null - */ - public function getCallStatus() - { - return $this->container['callStatus']; - } - - /** - * Sets callStatus - * - * @param string|null $callStatus Call status, e.g. `PENDING_ACCEPTED`. - * - * @return self - */ - public function setCallStatus($callStatus) - { - $this->container['callStatus'] = $callStatus; - + $this->callStatus = $callStatus; return $this; } - /** - * Gets ncStatus - * - * @return string|null - */ - public function getNcStatus() + public function getNcStatus(): string|null { - return $this->container['ncStatus']; + return $this->ncStatus; } - /** - * Sets ncStatus - * - * @param string|null $ncStatus Status of sent [Number Lookup](https://www.infobip.com/docs/number-lookup). Number Lookup status can have one of the following values: `NC_DESTINATION_UNKNOWN`, `NC_DESTINATION_REACHABLE`, `NC_DESTINATION_NOT_REACHABLE`, `NC_NOT_CONFIGURED`. Contact your Account Manager, if you get the `NC_NOT_CONFIGURED` status. SMS will not be sent only if Number Lookup status is `NC_NOT_REACHABLE`. - * - * @return self - */ - public function setNcStatus($ncStatus) + public function setNcStatus(?string $ncStatus): self { - $this->container['ncStatus'] = $ncStatus; - + $this->ncStatus = $ncStatus; return $this; } - /** - * Gets pinId - * - * @return string|null - */ - public function getPinId() + public function getPinId(): string|null { - return $this->container['pinId']; + return $this->pinId; } - /** - * Sets pinId - * - * @param string|null $pinId Sent PIN code ID. - * - * @return self - */ - public function setPinId($pinId) + public function setPinId(?string $pinId): self { - $this->container['pinId'] = $pinId; - + $this->pinId = $pinId; return $this; } - /** - * Gets smsStatus - * - * @return string|null - */ - public function getSmsStatus() + public function getSmsStatus(): string|null { - return $this->container['smsStatus']; + return $this->smsStatus; } - /** - * Sets smsStatus - * - * @param string|null $smsStatus Sent SMS status. Can have one of the following values: `MESSAGE_SENT`, `MESSAGE_NOT_SENT`. - * - * @return self - */ - public function setSmsStatus($smsStatus) + public function setSmsStatus(?string $smsStatus): self { - $this->container['smsStatus'] = $smsStatus; - + $this->smsStatus = $smsStatus; return $this; } - /** - * Gets to - * - * @return string|null - */ - public function getTo() + public function getTo(): string|null { - return $this->container['to']; + return $this->to; } - /** - * Sets to - * - * @param string|null $to Phone number to which the 2FA message will be sent. Example: `41793026727`. - * - * @return self - */ - public function setTo($to) + public function setTo(?string $to): self { - $this->container['to'] = $to; - + $this->to = $to; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/TfaUpdateMessageRequest.php b/Infobip/Model/TfaUpdateMessageRequest.php index fe4f31a..dc5486f 100644 --- a/Infobip/Model/TfaUpdateMessageRequest.php +++ b/Infobip/Model/TfaUpdateMessageRequest.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class TfaUpdateMessageRequest implements ModelInterface, ArrayAccess, \JsonSerializable +class TfaUpdateMessageRequest implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'TfaUpdateMessageRequest'; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'TfaUpdateMessageRequest'; - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'language' => '\Infobip\Model\TfaLanguage', - 'messageText' => 'string', - 'pinLength' => 'int', - 'pinType' => '\Infobip\Model\TfaPinType', - 'regional' => '\Infobip\Model\TfaRegionalOptions', - 'repeatDTMF' => 'string', - 'senderId' => 'string', - 'speechRate' => 'double' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'language' => null, 'messageText' => null, 'pinLength' => 'int32', @@ -83,444 +41,122 @@ class TfaUpdateMessageRequest implements ModelInterface, ArrayAccess, \JsonSeria ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'language' => 'language', - 'messageText' => 'messageText', - 'pinLength' => 'pinLength', - 'pinType' => 'pinType', - 'regional' => 'regional', - 'repeatDTMF' => 'repeatDTMF', - 'senderId' => 'senderId', - 'speechRate' => 'speechRate' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'language' => 'setLanguage', - 'messageText' => 'setMessageText', - 'pinLength' => 'setPinLength', - 'pinType' => 'setPinType', - 'regional' => 'setRegional', - 'repeatDTMF' => 'setRepeatDTMF', - 'senderId' => 'setSenderId', - 'speechRate' => 'setSpeechRate' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'language' => 'getLanguage', - 'messageText' => 'getMessageText', - 'pinLength' => 'getPinLength', - 'pinType' => 'getPinType', - 'regional' => 'getRegional', - 'repeatDTMF' => 'getRepeatDTMF', - 'senderId' => 'getSenderId', - 'speechRate' => 'getSpeechRate' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string */ - public function getModelName() - { - return self::$openAPIModelName; - } - + public function __construct( + #[Assert\Choice(['en','es','ca','da','nl','fr','de','it','ja','ko','no','pl','ru','sv','fi','hr','sl','ro','pt-pt','pt-br','zh-cn','zh-tw',])] + protected ?string $language = null, + protected ?string $messageText = null, + protected ?int $pinLength = null, + #[Assert\Choice(['NUMERIC','ALPHA','HEX','ALPHANUMERIC',])] + protected ?string $pinType = null, + #[Assert\Valid] - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['language'] = $data['language'] ?? null; - $this->container['messageText'] = $data['messageText'] ?? null; - $this->container['pinLength'] = $data['pinLength'] ?? null; - $this->container['pinType'] = $data['pinType'] ?? null; - $this->container['regional'] = $data['regional'] ?? null; - $this->container['repeatDTMF'] = $data['repeatDTMF'] ?? null; - $this->container['senderId'] = $data['senderId'] ?? null; - $this->container['speechRate'] = $data['speechRate'] ?? null; + protected ?\Infobip\Model\TfaRegionalOptions $regional = null, + protected ?string $repeatDTMF = null, + protected ?string $senderId = null, + protected ?float $speechRate = null, + ) { } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets language - * - * @return \Infobip\Model\TfaLanguage|null - */ - public function getLanguage() + public function getLanguage(): mixed { - return $this->container['language']; + return $this->language; } - /** - * Sets language - * - * @param \Infobip\Model\TfaLanguage|null $language Language code which message is written in. This is used when sending text-to-speech messages. If not defined, it will default to English (`en`). - * - * @return self - */ - public function setLanguage($language) + public function setLanguage($language): self { - $this->container['language'] = $language; - + $this->language = $language; return $this; } - /** - * Gets messageText - * - * @return string|null - */ - public function getMessageText() + public function getMessageText(): string|null { - return $this->container['messageText']; + return $this->messageText; } - /** - * Sets messageText - * - * @param string|null $messageText Content of the message being sent which contains at minimum one placeholder for a PIN code (`{{pin}}`). Placeholder format is `{{placeholderName}}`. - * - * @return self - */ - public function setMessageText($messageText) + public function setMessageText(?string $messageText): self { - $this->container['messageText'] = $messageText; - + $this->messageText = $messageText; return $this; } - /** - * Gets pinLength - * - * @return int|null - */ - public function getPinLength() + public function getPinLength(): int|null { - return $this->container['pinLength']; + return $this->pinLength; } - /** - * Sets pinLength - * - * @param int|null $pinLength PIN code length. - * - * @return self - */ - public function setPinLength($pinLength) + public function setPinLength(?int $pinLength): self { - $this->container['pinLength'] = $pinLength; - + $this->pinLength = $pinLength; return $this; } - /** - * Gets pinType - * - * @return \Infobip\Model\TfaPinType|null - */ - public function getPinType() + public function getPinType(): mixed { - return $this->container['pinType']; + return $this->pinType; } - /** - * Sets pinType - * - * @param \Infobip\Model\TfaPinType|null $pinType The type of PIN code that will be generated and sent as part of a 2FA message. - * - * @return self - */ - public function setPinType($pinType) + public function setPinType($pinType): self { - $this->container['pinType'] = $pinType; - + $this->pinType = $pinType; return $this; } - /** - * Gets regional - * - * @return \Infobip\Model\TfaRegionalOptions|null - */ - public function getRegional() + public function getRegional(): \Infobip\Model\TfaRegionalOptions|null { - return $this->container['regional']; + return $this->regional; } - /** - * Sets regional - * - * @param \Infobip\Model\TfaRegionalOptions|null $regional Region-specific parameters, often imposed by local laws. Use this, if country or region that you are sending a message to requires additional information. - * - * @return self - */ - public function setRegional($regional) + public function setRegional(?\Infobip\Model\TfaRegionalOptions $regional): self { - $this->container['regional'] = $regional; - + $this->regional = $regional; return $this; } - /** - * Gets repeatDTMF - * - * @return string|null - */ - public function getRepeatDTMF() + public function getRepeatDTMF(): string|null { - return $this->container['repeatDTMF']; + return $this->repeatDTMF; } - /** - * Sets repeatDTMF - * - * @param string|null $repeatDTMF If the PIN is sent as a voice message, the DTMF code allows the recipient to replay the message. - * - * @return self - */ - public function setRepeatDTMF($repeatDTMF) + public function setRepeatDTMF(?string $repeatDTMF): self { - $this->container['repeatDTMF'] = $repeatDTMF; - + $this->repeatDTMF = $repeatDTMF; return $this; } - /** - * Gets senderId - * - * @return string|null - */ - public function getSenderId() + public function getSenderId(): string|null { - return $this->container['senderId']; + return $this->senderId; } - /** - * Sets senderId - * - * @param string|null $senderId The name that will appear as the sender of the 2FA message (e.g. CompanyName). - * - * @return self - */ - public function setSenderId($senderId) + public function setSenderId(?string $senderId): self { - $this->container['senderId'] = $senderId; - + $this->senderId = $senderId; return $this; } - /** - * Gets speechRate - * - * @return double|null - */ - public function getSpeechRate() + public function getSpeechRate(): float|null { - return $this->container['speechRate']; + return $this->speechRate; } - /** - * Sets speechRate - * - * @param double|null $speechRate The speed of narration for messages sent as voice. Supported range is from `0.5` to `2`. - * - * @return self - */ - public function setSpeechRate($speechRate) + public function setSpeechRate(?float $speechRate): self { - $this->container['speechRate'] = $speechRate; - + $this->speechRate = $speechRate; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/TfaVerification.php b/Infobip/Model/TfaVerification.php index c2e2d76..4000d6d 100644 --- a/Infobip/Model/TfaVerification.php +++ b/Infobip/Model/TfaVerification.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class TfaVerification implements ModelInterface, ArrayAccess, \JsonSerializable +class TfaVerification implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'TfaVerification'; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'TfaVerification'; - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'msisdn' => 'string', - 'sentAt' => 'int', - 'verified' => 'bool', - 'verifiedAt' => 'int' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'msisdn' => null, 'sentAt' => 'int64', 'verified' => null, @@ -75,332 +37,68 @@ class TfaVerification implements ModelInterface, ArrayAccess, \JsonSerializable ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'msisdn' => 'msisdn', - 'sentAt' => 'sentAt', - 'verified' => 'verified', - 'verifiedAt' => 'verifiedAt' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'msisdn' => 'setMsisdn', - 'sentAt' => 'setSentAt', - 'verified' => 'setVerified', - 'verifiedAt' => 'setVerifiedAt' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'msisdn' => 'getMsisdn', - 'sentAt' => 'getSentAt', - 'verified' => 'getVerified', - 'verifiedAt' => 'getVerifiedAt' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model */ - public function __construct(array $data = null) - { - $this->container['msisdn'] = $data['msisdn'] ?? null; - $this->container['sentAt'] = $data['sentAt'] ?? null; - $this->container['verified'] = $data['verified'] ?? null; - $this->container['verifiedAt'] = $data['verifiedAt'] ?? null; + public function __construct( + protected ?string $msisdn = null, + protected ?int $sentAt = null, + protected ?bool $verified = null, + protected ?int $verifiedAt = null, + ) { } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets msisdn - * - * @return string|null - */ - public function getMsisdn() + public function getMsisdn(): string|null { - return $this->container['msisdn']; + return $this->msisdn; } - /** - * Sets msisdn - * - * @param string|null $msisdn Phone number (MSISDN) for which verification status is checked. - * - * @return self - */ - public function setMsisdn($msisdn) + public function setMsisdn(?string $msisdn): self { - $this->container['msisdn'] = $msisdn; - + $this->msisdn = $msisdn; return $this; } - /** - * Gets sentAt - * - * @return int|null - */ - public function getSentAt() + public function getSentAt(): int|null { - return $this->container['sentAt']; + return $this->sentAt; } - /** - * Sets sentAt - * - * @param int|null $sentAt Sent UNIX timestamp (in millis), if the phone number (MSISDN) is verified. - * - * @return self - */ - public function setSentAt($sentAt) + public function setSentAt(?int $sentAt): self { - $this->container['sentAt'] = $sentAt; - + $this->sentAt = $sentAt; return $this; } - /** - * Gets verified - * - * @return bool|null - */ - public function getVerified() + public function getVerified(): bool|null { - return $this->container['verified']; + return $this->verified; } - /** - * Sets verified - * - * @param bool|null $verified Indicates if the phone number (MSISDN) is already verified for 2FA application with given ID. - * - * @return self - */ - public function setVerified($verified) + public function setVerified(?bool $verified): self { - $this->container['verified'] = $verified; - + $this->verified = $verified; return $this; } - /** - * Gets verifiedAt - * - * @return int|null - */ - public function getVerifiedAt() + public function getVerifiedAt(): int|null { - return $this->container['verifiedAt']; + return $this->verifiedAt; } - /** - * Sets verifiedAt - * - * @param int|null $verifiedAt Verification UNIX timestamp (in millis), if the phone number (MSISDN) is verified. - * - * @return self - */ - public function setVerifiedAt($verifiedAt) + public function setVerifiedAt(?int $verifiedAt): self { - $this->container['verifiedAt'] = $verifiedAt; - + $this->verifiedAt = $verifiedAt; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/TfaVerificationResponse.php b/Infobip/Model/TfaVerificationResponse.php index c99721a..d88a241 100644 --- a/Infobip/Model/TfaVerificationResponse.php +++ b/Infobip/Model/TfaVerificationResponse.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class TfaVerificationResponse implements ModelInterface, ArrayAccess, \JsonSerializable +class TfaVerificationResponse implements ModelInterface { - public const DISCRIMINATOR = null; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'TfaVerificationResponse'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'TfaVerificationResponse'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'verifications' => '\Infobip\Model\TfaVerification[]' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'verifications' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'verifications' => 'verifications' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'verifications' => 'setVerifications' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] + * @param \Infobip\Model\TfaVerification[] $verifications */ - protected static $getters = [ - 'verifications' => 'getVerifications' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; + public function __construct( + protected ?array $verifications = null, + ) { } - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() + #[Ignore] + public function getModelName(): string { - return self::$setters; + return self::OPENAPI_MODEL_NAME; } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$getters; + return self::DISCRIMINATOR; } /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['verifications'] = $data['verifications'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $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() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets verifications - * * @return \Infobip\Model\TfaVerification[]|null */ - public function getVerifications() + public function getVerifications(): ?array { - return $this->container['verifications']; + return $this->verifications; } /** - * Sets verifications - * * @param \Infobip\Model\TfaVerification[]|null $verifications Collection of verifications - * - * @return self */ - public function setVerifications($verifications) + public function setVerifications(?array $verifications): self { - $this->container['verifications'] = $verifications; - + $this->verifications = $verifications; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/TfaVerifyPinRequest.php b/Infobip/Model/TfaVerifyPinRequest.php index 5329cef..6e410c1 100644 --- a/Infobip/Model/TfaVerifyPinRequest.php +++ b/Infobip/Model/TfaVerifyPinRequest.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class TfaVerifyPinRequest implements ModelInterface, ArrayAccess, \JsonSerializable +class TfaVerifyPinRequest implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'TfaVerifyPinRequest'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'pin' => 'string' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'TfaVerifyPinRequest'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'pin' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'pin' => 'pin' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'pin' => 'setPin' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'pin' => 'getPin' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] */ - protected $container = []; + public function __construct( + #[Assert\NotBlank] - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['pin'] = $data['pin'] ?? null; + protected string $pin, + ) { } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - if ($this->container['pin'] === null) { - $invalidProperties[] = "'pin' can't be null"; - } - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets pin - * - * @return string - */ - public function getPin() + public function getPin(): string { - return $this->container['pin']; + return $this->pin; } - /** - * Sets pin - * - * @param string $pin The PIN code to verify. - * - * @return self - */ - public function setPin($pin) + public function setPin(string $pin): self { - $this->container['pin'] = $pin; - + $this->pin = $pin; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/TfaVerifyPinResponse.php b/Infobip/Model/TfaVerifyPinResponse.php index 8f1ac0e..d795851 100644 --- a/Infobip/Model/TfaVerifyPinResponse.php +++ b/Infobip/Model/TfaVerifyPinResponse.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class TfaVerifyPinResponse implements ModelInterface, ArrayAccess, \JsonSerializable +class TfaVerifyPinResponse implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'TfaVerifyPinResponse'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'attemptsRemaining' => 'int', - 'msisdn' => 'string', - 'pinError' => 'string', - 'pinId' => 'string', - 'verified' => 'bool' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'TfaVerifyPinResponse'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'attemptsRemaining' => 'int32', 'msisdn' => null, 'pinError' => null, @@ -77,360 +38,80 @@ class TfaVerifyPinResponse implements ModelInterface, ArrayAccess, \JsonSerializ ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'attemptsRemaining' => 'attemptsRemaining', - 'msisdn' => 'msisdn', - 'pinError' => 'pinError', - 'pinId' => 'pinId', - 'verified' => 'verified' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'attemptsRemaining' => 'setAttemptsRemaining', - 'msisdn' => 'setMsisdn', - 'pinError' => 'setPinError', - 'pinId' => 'setPinId', - 'verified' => 'setVerified' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'attemptsRemaining' => 'getAttemptsRemaining', - 'msisdn' => 'getMsisdn', - 'pinError' => 'getPinError', - 'pinId' => 'getPinId', - 'verified' => 'getVerified' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array */ - public static function attributeMap() - { - return self::$attributeMap; + public function __construct( + protected ?int $attemptsRemaining = null, + protected ?string $msisdn = null, + protected ?string $pinError = null, + protected ?string $pinId = null, + protected ?bool $verified = null, + ) { } - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() + #[Ignore] + public function getModelName(): string { - return self::$setters; + return self::OPENAPI_MODEL_NAME; } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$getters; + return self::DISCRIMINATOR; } - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() + public function getAttemptsRemaining(): int|null { - return self::$openAPIModelName; + return $this->attemptsRemaining; } - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['attemptsRemaining'] = $data['attemptsRemaining'] ?? null; - $this->container['msisdn'] = $data['msisdn'] ?? null; - $this->container['pinError'] = $data['pinError'] ?? null; - $this->container['pinId'] = $data['pinId'] ?? null; - $this->container['verified'] = $data['verified'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $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() + public function setAttemptsRemaining(?int $attemptsRemaining): self { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets attemptsRemaining - * - * @return int|null - */ - public function getAttemptsRemaining() - { - return $this->container['attemptsRemaining']; - } - - /** - * Sets attemptsRemaining - * - * @param int|null $attemptsRemaining Number of remaining PIN attempts. - * - * @return self - */ - public function setAttemptsRemaining($attemptsRemaining) - { - $this->container['attemptsRemaining'] = $attemptsRemaining; - + $this->attemptsRemaining = $attemptsRemaining; return $this; } - /** - * Gets msisdn - * - * @return string|null - */ - public function getMsisdn() + public function getMsisdn(): string|null { - return $this->container['msisdn']; + return $this->msisdn; } - /** - * Sets msisdn - * - * @param string|null $msisdn Phone number (`MSISDN`) to which the 2FA message was sent. - * - * @return self - */ - public function setMsisdn($msisdn) + public function setMsisdn(?string $msisdn): self { - $this->container['msisdn'] = $msisdn; - + $this->msisdn = $msisdn; return $this; } - /** - * Gets pinError - * - * @return string|null - */ - public function getPinError() + public function getPinError(): string|null { - return $this->container['pinError']; + return $this->pinError; } - /** - * Sets pinError - * - * @param string|null $pinError Indicates whether an error has occurred during PIN verification. - * - * @return self - */ - public function setPinError($pinError) + public function setPinError(?string $pinError): self { - $this->container['pinError'] = $pinError; - + $this->pinError = $pinError; return $this; } - /** - * Gets pinId - * - * @return string|null - */ - public function getPinId() + public function getPinId(): string|null { - return $this->container['pinId']; + return $this->pinId; } - /** - * Sets pinId - * - * @param string|null $pinId Sent PIN code ID. - * - * @return self - */ - public function setPinId($pinId) + public function setPinId(?string $pinId): self { - $this->container['pinId'] = $pinId; - + $this->pinId = $pinId; return $this; } - /** - * Gets verified - * - * @return bool|null - */ - public function getVerified() + public function getVerified(): bool|null { - return $this->container['verified']; + return $this->verified; } - /** - * Sets verified - * - * @param bool|null $verified Indicates whether the phone number (`MSISDN`) was successfully verified. - * - * @return self - */ - public function setVerified($verified) + public function setVerified(?bool $verified): self { - $this->container['verified'] = $verified; - + $this->verified = $verified; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/ViberBulkMessageInfo.php b/Infobip/Model/ViberBulkMessageInfo.php new file mode 100644 index 0000000..3434846 --- /dev/null +++ b/Infobip/Model/ViberBulkMessageInfo.php @@ -0,0 +1,85 @@ + null, + 'bulkId' => null + ]; + + /** + * @param \Infobip\Model\ViberSingleMessageInfo[] $messages + */ + public function __construct( + protected ?array $messages = null, + protected ?string $bulkId = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + /** + * @return \Infobip\Model\ViberSingleMessageInfo[]|null + */ + public function getMessages(): ?array + { + return $this->messages; + } + + /** + * @param \Infobip\Model\ViberSingleMessageInfo[]|null $messages Array of sent message objects, one object per every message. + */ + public function setMessages(?array $messages): self + { + $this->messages = $messages; + return $this; + } + + public function getBulkId(): string|null + { + return $this->bulkId; + } + + public function setBulkId(?string $bulkId): self + { + $this->bulkId = $bulkId; + return $this; + } +} diff --git a/Infobip/Model/ViberBulkTextMessage.php b/Infobip/Model/ViberBulkTextMessage.php new file mode 100644 index 0000000..803bf1e --- /dev/null +++ b/Infobip/Model/ViberBulkTextMessage.php @@ -0,0 +1,90 @@ + null, + 'bulkId' => null + ]; + + /** + * @param \Infobip\Model\ViberTextMessage[] $messages + */ + public function __construct( + #[Assert\NotBlank] + + protected array $messages, + #[Assert\Length(max: 100)] + #[Assert\Length(min: 0)] + + protected ?string $bulkId = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + /** + * @return \Infobip\Model\ViberTextMessage[] + */ + public function getMessages(): array + { + return $this->messages; + } + + /** + * @param \Infobip\Model\ViberTextMessage[] $messages An array of messages being sent. + */ + public function setMessages(array $messages): self + { + $this->messages = $messages; + return $this; + } + + public function getBulkId(): string|null + { + return $this->bulkId; + } + + public function setBulkId(?string $bulkId): self + { + $this->bulkId = $bulkId; + return $this; + } +} diff --git a/Infobip/Model/ViberButton.php b/Infobip/Model/ViberButton.php new file mode 100644 index 0000000..b9a0b45 --- /dev/null +++ b/Infobip/Model/ViberButton.php @@ -0,0 +1,86 @@ + null, + 'action' => null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 30)] + #[Assert\Length(min: 1)] + + protected string $title, + #[Assert\NotBlank] + #[Assert\Length(max: 1000)] + #[Assert\Length(min: 0)] + + protected string $action, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getTitle(): string + { + return $this->title; + } + + public function setTitle(string $title): self + { + $this->title = $title; + return $this; + } + + public function getAction(): string + { + return $this->action; + } + + public function setAction(string $action): self + { + $this->action = $action; + return $this; + } +} diff --git a/Infobip/Model/ViberFileContent.php b/Infobip/Model/ViberFileContent.php new file mode 100644 index 0000000..757f4d4 --- /dev/null +++ b/Infobip/Model/ViberFileContent.php @@ -0,0 +1,85 @@ + null, + 'mediaUrl' => null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 25)] + #[Assert\Length(min: 0)] + #[Assert\Regex('/.*\\.(docx?|dotx?|xlsx?|f?ods|f?odt|rtf|odf|txt|info|pdf|xps|pdax|eps|csv|xlsm|xltx)$/')] + + protected string $filename, + #[Assert\NotBlank] + + protected string $mediaUrl, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getFilename(): string + { + return $this->filename; + } + + public function setFilename(string $filename): self + { + $this->filename = $filename; + return $this; + } + + public function getMediaUrl(): string + { + return $this->mediaUrl; + } + + public function setMediaUrl(string $mediaUrl): self + { + $this->mediaUrl = $mediaUrl; + return $this; + } +} diff --git a/Infobip/Model/ViberFileMessage.php b/Infobip/Model/ViberFileMessage.php new file mode 100644 index 0000000..c54f0cc --- /dev/null +++ b/Infobip/Model/ViberFileMessage.php @@ -0,0 +1,223 @@ + null, + 'to' => null, + 'messageId' => null, + 'content' => null, + 'callbackData' => null, + 'trackingData' => null, + 'applySessionRate' => null, + 'label' => null, + 'smsFailover' => null, + 'notifyUrl' => null, + 'urlOptions' => null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 20)] + #[Assert\Length(min: 2)] + + protected string $from, + #[Assert\NotBlank] + #[Assert\Regex('/^[0-9]{1,15}$/')] + + protected string $to, + #[Assert\Valid] + #[Assert\NotBlank] + + protected \Infobip\Model\ViberFileContent $content, + #[Assert\Length(max: 50)] + #[Assert\Length(min: 1)] + + protected ?string $messageId = null, + #[Assert\Length(max: 4000)] + #[Assert\Length(min: 1)] + + protected ?string $callbackData = null, + #[Assert\Length(max: 100)] + #[Assert\Length(min: 1)] + + protected ?string $trackingData = null, + protected ?bool $applySessionRate = null, + #[Assert\Choice(['PROMOTIONAL','TRANSACTIONAL',])] + + protected ?string $label = null, + #[Assert\Valid] + + protected ?\Infobip\Model\ViberSmsFailover $smsFailover = null, + #[Assert\Length(max: 2048)] + #[Assert\Length(min: 0)] + + protected ?string $notifyUrl = null, + #[Assert\Valid] + + protected ?\Infobip\Model\ViberUrlOptions $urlOptions = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getFrom(): string + { + return $this->from; + } + + public function setFrom(string $from): self + { + $this->from = $from; + return $this; + } + + public function getTo(): string + { + return $this->to; + } + + public function setTo(string $to): self + { + $this->to = $to; + return $this; + } + + public function getMessageId(): string|null + { + return $this->messageId; + } + + public function setMessageId(?string $messageId): self + { + $this->messageId = $messageId; + return $this; + } + + public function getContent(): \Infobip\Model\ViberFileContent + { + return $this->content; + } + + public function setContent(\Infobip\Model\ViberFileContent $content): self + { + $this->content = $content; + return $this; + } + + public function getCallbackData(): string|null + { + return $this->callbackData; + } + + public function setCallbackData(?string $callbackData): self + { + $this->callbackData = $callbackData; + return $this; + } + + public function getTrackingData(): string|null + { + return $this->trackingData; + } + + public function setTrackingData(?string $trackingData): self + { + $this->trackingData = $trackingData; + return $this; + } + + public function getApplySessionRate(): bool|null + { + return $this->applySessionRate; + } + + public function setApplySessionRate(?bool $applySessionRate): self + { + $this->applySessionRate = $applySessionRate; + return $this; + } + + public function getLabel(): mixed + { + return $this->label; + } + + public function setLabel($label): self + { + $this->label = $label; + return $this; + } + + public function getSmsFailover(): \Infobip\Model\ViberSmsFailover|null + { + return $this->smsFailover; + } + + public function setSmsFailover(?\Infobip\Model\ViberSmsFailover $smsFailover): self + { + $this->smsFailover = $smsFailover; + return $this; + } + + public function getNotifyUrl(): string|null + { + return $this->notifyUrl; + } + + public function setNotifyUrl(?string $notifyUrl): self + { + $this->notifyUrl = $notifyUrl; + return $this; + } + + public function getUrlOptions(): \Infobip\Model\ViberUrlOptions|null + { + return $this->urlOptions; + } + + public function setUrlOptions(?\Infobip\Model\ViberUrlOptions $urlOptions): self + { + $this->urlOptions = $urlOptions; + return $this; + } +} diff --git a/Infobip/Model/ViberImageContent.php b/Infobip/Model/ViberImageContent.php new file mode 100644 index 0000000..cb102fa --- /dev/null +++ b/Infobip/Model/ViberImageContent.php @@ -0,0 +1,98 @@ + null, + 'mediaUrl' => null, + 'button' => null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + + protected string $mediaUrl, + #[Assert\Length(max: 1000)] + #[Assert\Length(min: 1)] + + protected ?string $text = null, + #[Assert\Valid] + + protected ?\Infobip\Model\ViberButton $button = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getText(): string|null + { + return $this->text; + } + + public function setText(?string $text): self + { + $this->text = $text; + return $this; + } + + public function getMediaUrl(): string + { + return $this->mediaUrl; + } + + public function setMediaUrl(string $mediaUrl): self + { + $this->mediaUrl = $mediaUrl; + return $this; + } + + public function getButton(): \Infobip\Model\ViberButton|null + { + return $this->button; + } + + public function setButton(?\Infobip\Model\ViberButton $button): self + { + $this->button = $button; + return $this; + } +} diff --git a/Infobip/Model/ViberImageMessage.php b/Infobip/Model/ViberImageMessage.php new file mode 100644 index 0000000..65df5e2 --- /dev/null +++ b/Infobip/Model/ViberImageMessage.php @@ -0,0 +1,223 @@ + null, + 'to' => null, + 'messageId' => null, + 'content' => null, + 'callbackData' => null, + 'trackingData' => null, + 'applySessionRate' => null, + 'label' => null, + 'smsFailover' => null, + 'notifyUrl' => null, + 'urlOptions' => null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 20)] + #[Assert\Length(min: 2)] + + protected string $from, + #[Assert\NotBlank] + #[Assert\Regex('/^[0-9]{1,15}$/')] + + protected string $to, + #[Assert\Valid] + #[Assert\NotBlank] + + protected \Infobip\Model\ViberImageContent $content, + #[Assert\Length(max: 50)] + #[Assert\Length(min: 1)] + + protected ?string $messageId = null, + #[Assert\Length(max: 4000)] + #[Assert\Length(min: 1)] + + protected ?string $callbackData = null, + #[Assert\Length(max: 100)] + #[Assert\Length(min: 1)] + + protected ?string $trackingData = null, + protected ?bool $applySessionRate = null, + #[Assert\Choice(['PROMOTIONAL','TRANSACTIONAL',])] + + protected ?string $label = null, + #[Assert\Valid] + + protected ?\Infobip\Model\ViberSmsFailover $smsFailover = null, + #[Assert\Length(max: 2048)] + #[Assert\Length(min: 0)] + + protected ?string $notifyUrl = null, + #[Assert\Valid] + + protected ?\Infobip\Model\ViberUrlOptions $urlOptions = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getFrom(): string + { + return $this->from; + } + + public function setFrom(string $from): self + { + $this->from = $from; + return $this; + } + + public function getTo(): string + { + return $this->to; + } + + public function setTo(string $to): self + { + $this->to = $to; + return $this; + } + + public function getMessageId(): string|null + { + return $this->messageId; + } + + public function setMessageId(?string $messageId): self + { + $this->messageId = $messageId; + return $this; + } + + public function getContent(): \Infobip\Model\ViberImageContent + { + return $this->content; + } + + public function setContent(\Infobip\Model\ViberImageContent $content): self + { + $this->content = $content; + return $this; + } + + public function getCallbackData(): string|null + { + return $this->callbackData; + } + + public function setCallbackData(?string $callbackData): self + { + $this->callbackData = $callbackData; + return $this; + } + + public function getTrackingData(): string|null + { + return $this->trackingData; + } + + public function setTrackingData(?string $trackingData): self + { + $this->trackingData = $trackingData; + return $this; + } + + public function getApplySessionRate(): bool|null + { + return $this->applySessionRate; + } + + public function setApplySessionRate(?bool $applySessionRate): self + { + $this->applySessionRate = $applySessionRate; + return $this; + } + + public function getLabel(): mixed + { + return $this->label; + } + + public function setLabel($label): self + { + $this->label = $label; + return $this; + } + + public function getSmsFailover(): \Infobip\Model\ViberSmsFailover|null + { + return $this->smsFailover; + } + + public function setSmsFailover(?\Infobip\Model\ViberSmsFailover $smsFailover): self + { + $this->smsFailover = $smsFailover; + return $this; + } + + public function getNotifyUrl(): string|null + { + return $this->notifyUrl; + } + + public function setNotifyUrl(?string $notifyUrl): self + { + $this->notifyUrl = $notifyUrl; + return $this; + } + + public function getUrlOptions(): \Infobip\Model\ViberUrlOptions|null + { + return $this->urlOptions; + } + + public function setUrlOptions(?\Infobip\Model\ViberUrlOptions $urlOptions): self + { + $this->urlOptions = $urlOptions; + return $this; + } +} diff --git a/Infobip/Model/ViberLabel.php b/Infobip/Model/ViberLabel.php new file mode 100644 index 0000000..1038d87 --- /dev/null +++ b/Infobip/Model/ViberLabel.php @@ -0,0 +1,64 @@ +value = $value; + } + + public static function PROMOTIONAL(): ViberLabel + { + return new self('PROMOTIONAL'); + } + + public static function TRANSACTIONAL(): ViberLabel + { + return new self('TRANSACTIONAL'); + } + + public function __toString(): string + { + return $this->value; + } +} diff --git a/Infobip/Model/ViberSingleMessageInfo.php b/Infobip/Model/ViberSingleMessageInfo.php new file mode 100644 index 0000000..6bcb5cf --- /dev/null +++ b/Infobip/Model/ViberSingleMessageInfo.php @@ -0,0 +1,106 @@ + null, + 'messageCount' => 'int32', + 'messageId' => null, + 'status' => null + ]; + + /** + */ + public function __construct( + protected ?string $to = null, + protected ?int $messageCount = null, + protected ?string $messageId = null, + #[Assert\Valid] + + protected ?\Infobip\Model\ViberSingleMessageStatus $status = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getTo(): string|null + { + return $this->to; + } + + public function setTo(?string $to): self + { + $this->to = $to; + return $this; + } + + public function getMessageCount(): int|null + { + return $this->messageCount; + } + + public function setMessageCount(?int $messageCount): self + { + $this->messageCount = $messageCount; + return $this; + } + + public function getMessageId(): string|null + { + return $this->messageId; + } + + public function setMessageId(?string $messageId): self + { + $this->messageId = $messageId; + return $this; + } + + public function getStatus(): \Infobip\Model\ViberSingleMessageStatus|null + { + return $this->status; + } + + public function setStatus(?\Infobip\Model\ViberSingleMessageStatus $status): self + { + $this->status = $status; + return $this; + } +} diff --git a/Infobip/Model/ViberSingleMessageStatus.php b/Infobip/Model/ViberSingleMessageStatus.php new file mode 100644 index 0000000..c635072 --- /dev/null +++ b/Infobip/Model/ViberSingleMessageStatus.php @@ -0,0 +1,130 @@ + 'int32', + 'groupName' => null, + 'id' => 'int32', + 'name' => null, + 'description' => null, + 'action' => null + ]; + + /** + */ + public function __construct( + protected ?int $groupId = null, + protected ?string $groupName = null, + protected ?int $id = null, + protected ?string $name = null, + protected ?string $description = null, + protected ?string $action = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getGroupId(): int|null + { + return $this->groupId; + } + + public function setGroupId(?int $groupId): self + { + $this->groupId = $groupId; + return $this; + } + + public function getGroupName(): string|null + { + return $this->groupName; + } + + public function setGroupName(?string $groupName): self + { + $this->groupName = $groupName; + return $this; + } + + public function getId(): int|null + { + return $this->id; + } + + public function setId(?int $id): self + { + $this->id = $id; + return $this; + } + + public function getName(): string|null + { + return $this->name; + } + + public function setName(?string $name): self + { + $this->name = $name; + return $this; + } + + public function getDescription(): string|null + { + return $this->description; + } + + public function setDescription(?string $description): self + { + $this->description = $description; + return $this; + } + + public function getAction(): string|null + { + return $this->action; + } + + public function setAction(?string $action): self + { + $this->action = $action; + return $this; + } +} diff --git a/Infobip/Model/ViberSmsFailover.php b/Infobip/Model/ViberSmsFailover.php new file mode 100644 index 0000000..bf7d1ed --- /dev/null +++ b/Infobip/Model/ViberSmsFailover.php @@ -0,0 +1,110 @@ + null, + 'text' => null, + 'validityPeriod' => 'int32', + 'validityPeriodTimeUnit' => null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + + protected string $from, + #[Assert\NotBlank] + + protected string $text, + protected ?int $validityPeriod = null, + #[Assert\Choice(['SECONDS','MINUTES','HOURS','DAYS',])] + + protected ?string $validityPeriodTimeUnit = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getFrom(): string + { + return $this->from; + } + + public function setFrom(string $from): self + { + $this->from = $from; + return $this; + } + + public function getText(): string + { + return $this->text; + } + + public function setText(string $text): self + { + $this->text = $text; + return $this; + } + + public function getValidityPeriod(): int|null + { + return $this->validityPeriod; + } + + public function setValidityPeriod(?int $validityPeriod): self + { + $this->validityPeriod = $validityPeriod; + return $this; + } + + public function getValidityPeriodTimeUnit(): mixed + { + return $this->validityPeriodTimeUnit; + } + + public function setValidityPeriodTimeUnit($validityPeriodTimeUnit): self + { + $this->validityPeriodTimeUnit = $validityPeriodTimeUnit; + return $this; + } +} diff --git a/Infobip/Model/ViberTextContent.php b/Infobip/Model/ViberTextContent.php new file mode 100644 index 0000000..1b6801b --- /dev/null +++ b/Infobip/Model/ViberTextContent.php @@ -0,0 +1,84 @@ + null, + 'button' => null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 1000)] + #[Assert\Length(min: 1)] + + protected string $text, + #[Assert\Valid] + + protected ?\Infobip\Model\ViberButton $button = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getText(): string + { + return $this->text; + } + + public function setText(string $text): self + { + $this->text = $text; + return $this; + } + + public function getButton(): \Infobip\Model\ViberButton|null + { + return $this->button; + } + + public function setButton(?\Infobip\Model\ViberButton $button): self + { + $this->button = $button; + return $this; + } +} diff --git a/Infobip/Model/ViberTextMessage.php b/Infobip/Model/ViberTextMessage.php new file mode 100644 index 0000000..94f90a7 --- /dev/null +++ b/Infobip/Model/ViberTextMessage.php @@ -0,0 +1,236 @@ + null, + 'to' => null, + 'messageId' => null, + 'content' => null, + 'callbackData' => null, + 'trackingData' => null, + 'applySessionRate' => null, + 'toPrimaryDeviceOnly' => null, + 'label' => null, + 'smsFailover' => null, + 'notifyUrl' => null, + 'urlOptions' => null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 20)] + #[Assert\Length(min: 2)] + + protected string $from, + #[Assert\NotBlank] + #[Assert\Regex('/^[0-9]{1,15}$/')] + + protected string $to, + #[Assert\Valid] + #[Assert\NotBlank] + + protected \Infobip\Model\ViberTextContent $content, + #[Assert\Length(max: 50)] + #[Assert\Length(min: 1)] + + protected ?string $messageId = null, + #[Assert\Length(max: 4000)] + #[Assert\Length(min: 1)] + + protected ?string $callbackData = null, + #[Assert\Length(max: 100)] + #[Assert\Length(min: 1)] + + protected ?string $trackingData = null, + protected ?bool $applySessionRate = null, + protected ?bool $toPrimaryDeviceOnly = null, + #[Assert\Choice(['PROMOTIONAL','TRANSACTIONAL',])] + + protected ?string $label = null, + #[Assert\Valid] + + protected ?\Infobip\Model\ViberSmsFailover $smsFailover = null, + #[Assert\Length(max: 2048)] + #[Assert\Length(min: 0)] + + protected ?string $notifyUrl = null, + #[Assert\Valid] + + protected ?\Infobip\Model\ViberUrlOptions $urlOptions = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getFrom(): string + { + return $this->from; + } + + public function setFrom(string $from): self + { + $this->from = $from; + return $this; + } + + public function getTo(): string + { + return $this->to; + } + + public function setTo(string $to): self + { + $this->to = $to; + return $this; + } + + public function getMessageId(): string|null + { + return $this->messageId; + } + + public function setMessageId(?string $messageId): self + { + $this->messageId = $messageId; + return $this; + } + + public function getContent(): \Infobip\Model\ViberTextContent + { + return $this->content; + } + + public function setContent(\Infobip\Model\ViberTextContent $content): self + { + $this->content = $content; + return $this; + } + + public function getCallbackData(): string|null + { + return $this->callbackData; + } + + public function setCallbackData(?string $callbackData): self + { + $this->callbackData = $callbackData; + return $this; + } + + public function getTrackingData(): string|null + { + return $this->trackingData; + } + + public function setTrackingData(?string $trackingData): self + { + $this->trackingData = $trackingData; + return $this; + } + + public function getApplySessionRate(): bool|null + { + return $this->applySessionRate; + } + + public function setApplySessionRate(?bool $applySessionRate): self + { + $this->applySessionRate = $applySessionRate; + return $this; + } + + public function getToPrimaryDeviceOnly(): bool|null + { + return $this->toPrimaryDeviceOnly; + } + + public function setToPrimaryDeviceOnly(?bool $toPrimaryDeviceOnly): self + { + $this->toPrimaryDeviceOnly = $toPrimaryDeviceOnly; + return $this; + } + + public function getLabel(): mixed + { + return $this->label; + } + + public function setLabel($label): self + { + $this->label = $label; + return $this; + } + + public function getSmsFailover(): \Infobip\Model\ViberSmsFailover|null + { + return $this->smsFailover; + } + + public function setSmsFailover(?\Infobip\Model\ViberSmsFailover $smsFailover): self + { + $this->smsFailover = $smsFailover; + return $this; + } + + public function getNotifyUrl(): string|null + { + return $this->notifyUrl; + } + + public function setNotifyUrl(?string $notifyUrl): self + { + $this->notifyUrl = $notifyUrl; + return $this; + } + + public function getUrlOptions(): \Infobip\Model\ViberUrlOptions|null + { + return $this->urlOptions; + } + + public function setUrlOptions(?\Infobip\Model\ViberUrlOptions $urlOptions): self + { + $this->urlOptions = $urlOptions; + return $this; + } +} diff --git a/Infobip/Model/ViberUrlOptions.php b/Infobip/Model/ViberUrlOptions.php new file mode 100644 index 0000000..624824b --- /dev/null +++ b/Infobip/Model/ViberUrlOptions.php @@ -0,0 +1,117 @@ + null, + 'trackClicks' => null, + 'trackingUrl' => null, + 'removeProtocol' => null, + 'customDomain' => null + ]; + + /** + */ + public function __construct( + protected ?bool $shortenUrl = true, + protected ?bool $trackClicks = true, + protected ?string $trackingUrl = null, + protected ?bool $removeProtocol = false, + protected ?string $customDomain = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getShortenUrl(): bool|null + { + return $this->shortenUrl; + } + + public function setShortenUrl(?bool $shortenUrl): self + { + $this->shortenUrl = $shortenUrl; + return $this; + } + + public function getTrackClicks(): bool|null + { + return $this->trackClicks; + } + + public function setTrackClicks(?bool $trackClicks): self + { + $this->trackClicks = $trackClicks; + return $this; + } + + public function getTrackingUrl(): string|null + { + return $this->trackingUrl; + } + + public function setTrackingUrl(?string $trackingUrl): self + { + $this->trackingUrl = $trackingUrl; + return $this; + } + + public function getRemoveProtocol(): bool|null + { + return $this->removeProtocol; + } + + public function setRemoveProtocol(?bool $removeProtocol): self + { + $this->removeProtocol = $removeProtocol; + return $this; + } + + public function getCustomDomain(): string|null + { + return $this->customDomain; + } + + public function setCustomDomain(?string $customDomain): self + { + $this->customDomain = $customDomain; + return $this; + } +} diff --git a/Infobip/Model/ViberValidityPeriodTimeUnit.php b/Infobip/Model/ViberValidityPeriodTimeUnit.php new file mode 100644 index 0000000..86c4448 --- /dev/null +++ b/Infobip/Model/ViberValidityPeriodTimeUnit.php @@ -0,0 +1,78 @@ +value = $value; + } + + public static function SECONDS(): ViberValidityPeriodTimeUnit + { + return new self('SECONDS'); + } + + public static function MINUTES(): ViberValidityPeriodTimeUnit + { + return new self('MINUTES'); + } + + public static function HOURS(): ViberValidityPeriodTimeUnit + { + return new self('HOURS'); + } + + public static function DAYS(): ViberValidityPeriodTimeUnit + { + return new self('DAYS'); + } + + public function __toString(): string + { + return $this->value; + } +} diff --git a/Infobip/Model/ViberVideoContent.php b/Infobip/Model/ViberVideoContent.php new file mode 100644 index 0000000..bd3ec01 --- /dev/null +++ b/Infobip/Model/ViberVideoContent.php @@ -0,0 +1,133 @@ + null, + 'mediaUrl' => null, + 'thumbnailUrl' => null, + 'mediaDuration' => 'int32', + 'buttonTitle' => null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 1000)] + #[Assert\Length(min: 0)] + + protected string $mediaUrl, + #[Assert\NotBlank] + + protected string $thumbnailUrl, + #[Assert\NotBlank] + #[Assert\LessThan(600)] + #[Assert\GreaterThan(1)] + + protected int $mediaDuration, + #[Assert\Length(max: 1000)] + #[Assert\Length(min: 1)] + + protected ?string $text = null, + #[Assert\Length(max: 30)] + #[Assert\Length(min: 1)] + + protected ?string $buttonTitle = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getText(): string|null + { + return $this->text; + } + + public function setText(?string $text): self + { + $this->text = $text; + return $this; + } + + public function getMediaUrl(): string + { + return $this->mediaUrl; + } + + public function setMediaUrl(string $mediaUrl): self + { + $this->mediaUrl = $mediaUrl; + return $this; + } + + public function getThumbnailUrl(): string + { + return $this->thumbnailUrl; + } + + public function setThumbnailUrl(string $thumbnailUrl): self + { + $this->thumbnailUrl = $thumbnailUrl; + return $this; + } + + public function getMediaDuration(): int + { + return $this->mediaDuration; + } + + public function setMediaDuration(int $mediaDuration): self + { + $this->mediaDuration = $mediaDuration; + return $this; + } + + public function getButtonTitle(): string|null + { + return $this->buttonTitle; + } + + public function setButtonTitle(?string $buttonTitle): self + { + $this->buttonTitle = $buttonTitle; + return $this; + } +} diff --git a/Infobip/Model/ViberVideoMessage.php b/Infobip/Model/ViberVideoMessage.php new file mode 100644 index 0000000..069efc6 --- /dev/null +++ b/Infobip/Model/ViberVideoMessage.php @@ -0,0 +1,195 @@ + null, + 'to' => null, + 'messageId' => null, + 'content' => null, + 'callbackData' => null, + 'trackingData' => null, + 'smsFailover' => null, + 'notifyUrl' => null, + 'urlOptions' => null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 20)] + #[Assert\Length(min: 2)] + + protected string $from, + #[Assert\NotBlank] + #[Assert\Regex('/^[0-9]{1,15}$/')] + + protected string $to, + #[Assert\Valid] + #[Assert\NotBlank] + + protected \Infobip\Model\ViberVideoContent $content, + #[Assert\Length(max: 50)] + #[Assert\Length(min: 1)] + + protected ?string $messageId = null, + #[Assert\Length(max: 4000)] + #[Assert\Length(min: 1)] + + protected ?string $callbackData = null, + #[Assert\Length(max: 100)] + #[Assert\Length(min: 1)] + + protected ?string $trackingData = null, + #[Assert\Valid] + + protected ?\Infobip\Model\ViberSmsFailover $smsFailover = null, + #[Assert\Length(max: 2048)] + #[Assert\Length(min: 0)] + + protected ?string $notifyUrl = null, + #[Assert\Valid] + + protected ?\Infobip\Model\ViberUrlOptions $urlOptions = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getFrom(): string + { + return $this->from; + } + + public function setFrom(string $from): self + { + $this->from = $from; + return $this; + } + + public function getTo(): string + { + return $this->to; + } + + public function setTo(string $to): self + { + $this->to = $to; + return $this; + } + + public function getMessageId(): string|null + { + return $this->messageId; + } + + public function setMessageId(?string $messageId): self + { + $this->messageId = $messageId; + return $this; + } + + public function getContent(): \Infobip\Model\ViberVideoContent + { + return $this->content; + } + + public function setContent(\Infobip\Model\ViberVideoContent $content): self + { + $this->content = $content; + return $this; + } + + public function getCallbackData(): string|null + { + return $this->callbackData; + } + + public function setCallbackData(?string $callbackData): self + { + $this->callbackData = $callbackData; + return $this; + } + + public function getTrackingData(): string|null + { + return $this->trackingData; + } + + public function setTrackingData(?string $trackingData): self + { + $this->trackingData = $trackingData; + return $this; + } + + public function getSmsFailover(): \Infobip\Model\ViberSmsFailover|null + { + return $this->smsFailover; + } + + public function setSmsFailover(?\Infobip\Model\ViberSmsFailover $smsFailover): self + { + $this->smsFailover = $smsFailover; + return $this; + } + + public function getNotifyUrl(): string|null + { + return $this->notifyUrl; + } + + public function setNotifyUrl(?string $notifyUrl): self + { + $this->notifyUrl = $notifyUrl; + return $this; + } + + public function getUrlOptions(): \Infobip\Model\ViberUrlOptions|null + { + return $this->urlOptions; + } + + public function setUrlOptions(?\Infobip\Model\ViberUrlOptions $urlOptions): self + { + $this->urlOptions = $urlOptions; + return $this; + } +} diff --git a/Infobip/Model/ViberWebhookReport.php b/Infobip/Model/ViberWebhookReport.php new file mode 100644 index 0000000..4e6ceb7 --- /dev/null +++ b/Infobip/Model/ViberWebhookReport.php @@ -0,0 +1,194 @@ + null, + 'price' => null, + 'status' => null, + 'error' => null, + 'messageId' => null, + 'doneAt' => 'date-time', + 'messageCount' => 'int32', + 'sentAt' => 'date-time', + 'to' => null, + 'channel' => null + ]; + + /** + */ + public function __construct( + protected ?string $bulkId = null, + #[Assert\Valid] + + protected ?\Infobip\Model\MessagePrice $price = null, + #[Assert\Valid] + + protected ?\Infobip\Model\MessageStatus $status = null, + #[Assert\Valid] + + protected ?\Infobip\Model\MessageError $error = null, + protected ?string $messageId = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $doneAt = null, + protected ?int $messageCount = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $sentAt = null, + protected ?string $to = null, + #[Assert\Valid] + + protected ?\Infobip\Model\WebhookOmniChannel $channel = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getBulkId(): string|null + { + return $this->bulkId; + } + + public function setBulkId(?string $bulkId): self + { + $this->bulkId = $bulkId; + return $this; + } + + public function getPrice(): \Infobip\Model\MessagePrice|null + { + return $this->price; + } + + public function setPrice(?\Infobip\Model\MessagePrice $price): self + { + $this->price = $price; + return $this; + } + + public function getStatus(): \Infobip\Model\MessageStatus|null + { + return $this->status; + } + + public function setStatus(?\Infobip\Model\MessageStatus $status): self + { + $this->status = $status; + return $this; + } + + public function getError(): \Infobip\Model\MessageError|null + { + return $this->error; + } + + public function setError(?\Infobip\Model\MessageError $error): self + { + $this->error = $error; + return $this; + } + + public function getMessageId(): string|null + { + return $this->messageId; + } + + public function setMessageId(?string $messageId): self + { + $this->messageId = $messageId; + return $this; + } + + public function getDoneAt(): \DateTime|null + { + return $this->doneAt; + } + + public function setDoneAt(?\DateTime $doneAt): self + { + $this->doneAt = $doneAt; + return $this; + } + + public function getMessageCount(): int|null + { + return $this->messageCount; + } + + public function setMessageCount(?int $messageCount): self + { + $this->messageCount = $messageCount; + return $this; + } + + public function getSentAt(): \DateTime|null + { + return $this->sentAt; + } + + public function setSentAt(?\DateTime $sentAt): self + { + $this->sentAt = $sentAt; + return $this; + } + + public function getTo(): string|null + { + return $this->to; + } + + public function setTo(?string $to): self + { + $this->to = $to; + return $this; + } + + public function getChannel(): \Infobip\Model\WebhookOmniChannel|null + { + return $this->channel; + } + + public function setChannel(?\Infobip\Model\WebhookOmniChannel $channel): self + { + $this->channel = $channel; + return $this; + } +} diff --git a/Infobip/Model/ViberWebhookReportsResponse.php b/Infobip/Model/ViberWebhookReportsResponse.php new file mode 100644 index 0000000..f461811 --- /dev/null +++ b/Infobip/Model/ViberWebhookReportsResponse.php @@ -0,0 +1,72 @@ + null + ]; + + /** + * @param \Infobip\Model\ViberWebhookReport[] $results + */ + public function __construct( + protected ?array $results = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + /** + * @return \Infobip\Model\ViberWebhookReport[]|null + */ + public function getResults(): ?array + { + return $this->results; + } + + /** + * @param \Infobip\Model\ViberWebhookReport[]|null $results Collection of reports, one per every message. + */ + public function setResults(?array $results): self + { + $this->results = $results; + return $this; + } +} diff --git a/Infobip/Model/WebRtcAndroidPushNotificationConfig.php b/Infobip/Model/WebRtcAndroidPushNotificationConfig.php new file mode 100644 index 0000000..b0bcf3e --- /dev/null +++ b/Infobip/Model/WebRtcAndroidPushNotificationConfig.php @@ -0,0 +1,67 @@ + null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + + protected string $fcmServerKey, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getFcmServerKey(): string + { + return $this->fcmServerKey; + } + + public function setFcmServerKey(string $fcmServerKey): self + { + $this->fcmServerKey = $fcmServerKey; + return $this; + } +} diff --git a/Infobip/Model/WebRtcCapabilities.php b/Infobip/Model/WebRtcCapabilities.php new file mode 100644 index 0000000..52d5001 --- /dev/null +++ b/Infobip/Model/WebRtcCapabilities.php @@ -0,0 +1,67 @@ + null + ]; + + /** + */ + public function __construct( + #[Assert\Choice(['ALWAYS','ON_DEMAND','DISABLED',])] + + protected ?string $recording = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getRecording(): mixed + { + return $this->recording; + } + + public function setRecording($recording): self + { + $this->recording = $recording; + return $this; + } +} diff --git a/Infobip/Model/WebRtcIosPushNotificationConfig.php b/Infobip/Model/WebRtcIosPushNotificationConfig.php new file mode 100644 index 0000000..65e1ede --- /dev/null +++ b/Infobip/Model/WebRtcIosPushNotificationConfig.php @@ -0,0 +1,95 @@ + null, + 'apnsCertificateFileContent' => null, + 'apnsCertificatePassword' => null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + + protected string $apnsCertificateFileName, + #[Assert\NotBlank] + + protected string $apnsCertificateFileContent, + protected ?string $apnsCertificatePassword = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getApnsCertificateFileName(): string + { + return $this->apnsCertificateFileName; + } + + public function setApnsCertificateFileName(string $apnsCertificateFileName): self + { + $this->apnsCertificateFileName = $apnsCertificateFileName; + return $this; + } + + public function getApnsCertificateFileContent(): string + { + return $this->apnsCertificateFileContent; + } + + public function setApnsCertificateFileContent(string $apnsCertificateFileContent): self + { + $this->apnsCertificateFileContent = $apnsCertificateFileContent; + return $this; + } + + public function getApnsCertificatePassword(): string|null + { + return $this->apnsCertificatePassword; + } + + public function setApnsCertificatePassword(?string $apnsCertificatePassword): self + { + $this->apnsCertificatePassword = $apnsCertificatePassword; + return $this; + } +} diff --git a/Infobip/Model/WebRtcPageInfo.php b/Infobip/Model/WebRtcPageInfo.php new file mode 100644 index 0000000..0f717c3 --- /dev/null +++ b/Infobip/Model/WebRtcPageInfo.php @@ -0,0 +1,116 @@ + 'int32', + 'size' => 'int32', + 'totalPages' => 'int32', + 'totalResults' => 'int64' + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + #[Assert\GreaterThan(0)] + + protected int $page, + #[Assert\NotBlank] + #[Assert\GreaterThan(1)] + + protected int $size, + #[Assert\NotBlank] + #[Assert\GreaterThan(0)] + + protected int $totalPages, + #[Assert\NotBlank] + #[Assert\GreaterThan(0)] + + protected int $totalResults, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getPage(): int + { + return $this->page; + } + + public function setPage(int $page): self + { + $this->page = $page; + return $this; + } + + public function getSize(): int + { + return $this->size; + } + + public function setSize(int $size): self + { + $this->size = $size; + return $this; + } + + public function getTotalPages(): int + { + return $this->totalPages; + } + + public function setTotalPages(int $totalPages): self + { + $this->totalPages = $totalPages; + return $this; + } + + public function getTotalResults(): int + { + return $this->totalResults; + } + + public function setTotalResults(int $totalResults): self + { + $this->totalResults = $totalResults; + return $this; + } +} diff --git a/Infobip/Model/WebRtcPushConfigurationPageResponse.php b/Infobip/Model/WebRtcPushConfigurationPageResponse.php new file mode 100644 index 0000000..32b92e3 --- /dev/null +++ b/Infobip/Model/WebRtcPushConfigurationPageResponse.php @@ -0,0 +1,87 @@ + null, + 'pageInfo' => null + ]; + + /** + * @param \Infobip\Model\WebRtcPushConfigurationResponse[] $results + */ + public function __construct( + protected ?array $results = null, + #[Assert\Valid] + + protected ?\Infobip\Model\WebRtcPageInfo $pageInfo = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + /** + * @return \Infobip\Model\WebRtcPushConfigurationResponse[]|null + */ + public function getResults(): ?array + { + return $this->results; + } + + /** + * @param \Infobip\Model\WebRtcPushConfigurationResponse[]|null $results List of results for this page. + */ + public function setResults(?array $results): self + { + $this->results = $results; + return $this; + } + + public function getPageInfo(): \Infobip\Model\WebRtcPageInfo|null + { + return $this->pageInfo; + } + + public function setPageInfo(?\Infobip\Model\WebRtcPageInfo $pageInfo): self + { + $this->pageInfo = $pageInfo; + return $this; + } +} diff --git a/Infobip/Model/WebRtcPushConfigurationRequest.php b/Infobip/Model/WebRtcPushConfigurationRequest.php new file mode 100644 index 0000000..0732601 --- /dev/null +++ b/Infobip/Model/WebRtcPushConfigurationRequest.php @@ -0,0 +1,97 @@ + null, + 'ios' => null, + 'android' => null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + + protected string $applicationId, + #[Assert\Valid] + + protected ?\Infobip\Model\WebRtcIosPushNotificationConfig $ios = null, + #[Assert\Valid] + + protected ?\Infobip\Model\WebRtcAndroidPushNotificationConfig $android = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getApplicationId(): string + { + return $this->applicationId; + } + + public function setApplicationId(string $applicationId): self + { + $this->applicationId = $applicationId; + return $this; + } + + public function getIos(): \Infobip\Model\WebRtcIosPushNotificationConfig|null + { + return $this->ios; + } + + public function setIos(?\Infobip\Model\WebRtcIosPushNotificationConfig $ios): self + { + $this->ios = $ios; + return $this; + } + + public function getAndroid(): \Infobip\Model\WebRtcAndroidPushNotificationConfig|null + { + return $this->android; + } + + public function setAndroid(?\Infobip\Model\WebRtcAndroidPushNotificationConfig $android): self + { + $this->android = $android; + return $this; + } +} diff --git a/Infobip/Model/WebRtcPushConfigurationResponse.php b/Infobip/Model/WebRtcPushConfigurationResponse.php new file mode 100644 index 0000000..be3956f --- /dev/null +++ b/Infobip/Model/WebRtcPushConfigurationResponse.php @@ -0,0 +1,112 @@ + null, + 'applicationId' => null, + 'ios' => null, + 'android' => null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + + protected string $id, + #[Assert\NotBlank] + + protected string $applicationId, + #[Assert\Valid] + + protected ?\Infobip\Model\WebRtcIosPushNotificationConfig $ios = null, + #[Assert\Valid] + + protected ?\Infobip\Model\WebRtcAndroidPushNotificationConfig $android = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getId(): string + { + return $this->id; + } + + public function setId(string $id): self + { + $this->id = $id; + return $this; + } + + public function getApplicationId(): string + { + return $this->applicationId; + } + + public function setApplicationId(string $applicationId): self + { + $this->applicationId = $applicationId; + return $this; + } + + public function getIos(): \Infobip\Model\WebRtcIosPushNotificationConfig|null + { + return $this->ios; + } + + public function setIos(?\Infobip\Model\WebRtcIosPushNotificationConfig $ios): self + { + $this->ios = $ios; + return $this; + } + + public function getAndroid(): \Infobip\Model\WebRtcAndroidPushNotificationConfig|null + { + return $this->android; + } + + public function setAndroid(?\Infobip\Model\WebRtcAndroidPushNotificationConfig $android): self + { + $this->android = $android; + return $this; + } +} diff --git a/Infobip/Model/WebRtcRecording.php b/Infobip/Model/WebRtcRecording.php new file mode 100644 index 0000000..c0e45eb --- /dev/null +++ b/Infobip/Model/WebRtcRecording.php @@ -0,0 +1,71 @@ +value = $value; + } + + public static function ALWAYS(): WebRtcRecording + { + return new self('ALWAYS'); + } + + public static function ON_DEMAND(): WebRtcRecording + { + return new self('ON_DEMAND'); + } + + public static function DISABLED(): WebRtcRecording + { + return new self('DISABLED'); + } + + public function __toString(): string + { + return $this->value; + } +} diff --git a/Infobip/Model/WebRtcTokenRequestModel.php b/Infobip/Model/WebRtcTokenRequestModel.php new file mode 100644 index 0000000..cdd9748 --- /dev/null +++ b/Infobip/Model/WebRtcTokenRequestModel.php @@ -0,0 +1,122 @@ + null, + 'applicationId' => null, + 'displayName' => null, + 'capabilities' => null, + 'timeToLive' => 'int64' + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + #[Assert\Regex('/^[\\p{L}\\p{N}\\-_+=\/.]{3,64}$/')] + + protected string $identity, + protected ?string $applicationId = null, + protected ?string $displayName = null, + #[Assert\Valid] + + protected ?\Infobip\Model\WebRtcCapabilities $capabilities = null, + protected ?int $timeToLive = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getIdentity(): string + { + return $this->identity; + } + + public function setIdentity(string $identity): self + { + $this->identity = $identity; + return $this; + } + + public function getApplicationId(): string|null + { + return $this->applicationId; + } + + public function setApplicationId(?string $applicationId): self + { + $this->applicationId = $applicationId; + return $this; + } + + public function getDisplayName(): string|null + { + return $this->displayName; + } + + public function setDisplayName(?string $displayName): self + { + $this->displayName = $displayName; + return $this; + } + + public function getCapabilities(): \Infobip\Model\WebRtcCapabilities|null + { + return $this->capabilities; + } + + public function setCapabilities(?\Infobip\Model\WebRtcCapabilities $capabilities): self + { + $this->capabilities = $capabilities; + return $this; + } + + public function getTimeToLive(): int|null + { + return $this->timeToLive; + } + + public function setTimeToLive(?int $timeToLive): self + { + $this->timeToLive = $timeToLive; + return $this; + } +} diff --git a/Infobip/Model/WebRtcTokenResponseModel.php b/Infobip/Model/WebRtcTokenResponseModel.php new file mode 100644 index 0000000..d6d8398 --- /dev/null +++ b/Infobip/Model/WebRtcTokenResponseModel.php @@ -0,0 +1,78 @@ + null, + 'expirationTime' => null + ]; + + /** + */ + public function __construct( + protected ?string $token = null, + protected ?string $expirationTime = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getToken(): string|null + { + return $this->token; + } + + public function setToken(?string $token): self + { + $this->token = $token; + return $this; + } + + public function getExpirationTime(): string|null + { + return $this->expirationTime; + } + + public function setExpirationTime(?string $expirationTime): self + { + $this->expirationTime = $expirationTime; + return $this; + } +} diff --git a/Infobip/Model/WebhookMessageCount.php b/Infobip/Model/WebhookMessageCount.php new file mode 100644 index 0000000..f87fcbd --- /dev/null +++ b/Infobip/Model/WebhookMessageCount.php @@ -0,0 +1,78 @@ + 'int32', + 'pendingMessageCount' => 'int32' + ]; + + /** + */ + public function __construct( + protected ?int $messageCount = null, + protected ?int $pendingMessageCount = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getMessageCount(): int|null + { + return $this->messageCount; + } + + public function setMessageCount(?int $messageCount): self + { + $this->messageCount = $messageCount; + return $this; + } + + public function getPendingMessageCount(): int|null + { + return $this->pendingMessageCount; + } + + public function setPendingMessageCount(?int $pendingMessageCount): self + { + $this->pendingMessageCount = $pendingMessageCount; + return $this; + } +} diff --git a/Infobip/Model/WebhookOmniChannel.php b/Infobip/Model/WebhookOmniChannel.php new file mode 100644 index 0000000..d5b0a85 --- /dev/null +++ b/Infobip/Model/WebhookOmniChannel.php @@ -0,0 +1,85 @@ +value = $value; + } + + public static function WHATSAPP(): WebhookOmniChannel + { + return new self('WHATSAPP'); + } + + public static function VIBER(): WebhookOmniChannel + { + return new self('VIBER'); + } + + public static function FACEBOOK(): WebhookOmniChannel + { + return new self('FACEBOOK'); + } + + public static function LINE(): WebhookOmniChannel + { + return new self('LINE'); + } + + public static function VK(): WebhookOmniChannel + { + return new self('VK'); + } + + public function __toString(): string + { + return $this->value; + } +} diff --git a/Infobip/Model/WebhookReport.php b/Infobip/Model/WebhookReport.php new file mode 100644 index 0000000..415ef98 --- /dev/null +++ b/Infobip/Model/WebhookReport.php @@ -0,0 +1,179 @@ + null, + 'price' => null, + 'status' => null, + 'error' => null, + 'messageId' => null, + 'doneAt' => 'date-time', + 'messageCount' => 'int32', + 'sentAt' => 'date-time', + 'to' => null + ]; + + /** + */ + public function __construct( + protected ?string $bulkId = null, + #[Assert\Valid] + + protected ?\Infobip\Model\MessagePrice $price = null, + #[Assert\Valid] + + protected ?\Infobip\Model\MessageStatus $status = null, + #[Assert\Valid] + + protected ?\Infobip\Model\MessageError $error = null, + protected ?string $messageId = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $doneAt = null, + protected ?int $messageCount = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $sentAt = null, + protected ?string $to = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getBulkId(): string|null + { + return $this->bulkId; + } + + public function setBulkId(?string $bulkId): self + { + $this->bulkId = $bulkId; + return $this; + } + + public function getPrice(): \Infobip\Model\MessagePrice|null + { + return $this->price; + } + + public function setPrice(?\Infobip\Model\MessagePrice $price): self + { + $this->price = $price; + return $this; + } + + public function getStatus(): \Infobip\Model\MessageStatus|null + { + return $this->status; + } + + public function setStatus(?\Infobip\Model\MessageStatus $status): self + { + $this->status = $status; + return $this; + } + + public function getError(): \Infobip\Model\MessageError|null + { + return $this->error; + } + + public function setError(?\Infobip\Model\MessageError $error): self + { + $this->error = $error; + return $this; + } + + public function getMessageId(): string|null + { + return $this->messageId; + } + + public function setMessageId(?string $messageId): self + { + $this->messageId = $messageId; + return $this; + } + + public function getDoneAt(): \DateTime|null + { + return $this->doneAt; + } + + public function setDoneAt(?\DateTime $doneAt): self + { + $this->doneAt = $doneAt; + return $this; + } + + public function getMessageCount(): int|null + { + return $this->messageCount; + } + + public function setMessageCount(?int $messageCount): self + { + $this->messageCount = $messageCount; + return $this; + } + + public function getSentAt(): \DateTime|null + { + return $this->sentAt; + } + + public function setSentAt(?\DateTime $sentAt): self + { + $this->sentAt = $sentAt; + return $this; + } + + public function getTo(): string|null + { + return $this->to; + } + + public function setTo(?string $to): self + { + $this->to = $to; + return $this; + } +} diff --git a/Infobip/Model/WhatsAppAddressContent.php b/Infobip/Model/WhatsAppAddressContent.php index d8a832c..91dfe6d 100644 --- a/Infobip/Model/WhatsAppAddressContent.php +++ b/Infobip/Model/WhatsAppAddressContent.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppAddressContent implements ModelInterface, ArrayAccess, \JsonSerializable +class WhatsAppAddressContent implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppAddressContent'; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'WhatsAppAddressContent'; - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'street' => 'string', - 'city' => 'string', - 'state' => 'string', - 'zip' => 'string', - 'country' => 'string', - 'countryCode' => 'string', - 'type' => '\Infobip\Model\WhatsAppAddressType' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'street' => null, 'city' => null, 'state' => null, @@ -82,416 +40,106 @@ class WhatsAppAddressContent implements ModelInterface, ArrayAccess, \JsonSerial ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'street' => 'street', - 'city' => 'city', - 'state' => 'state', - 'zip' => 'zip', - 'country' => 'country', - 'countryCode' => 'countryCode', - 'type' => 'type' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'street' => 'setStreet', - 'city' => 'setCity', - 'state' => 'setState', - 'zip' => 'setZip', - 'country' => 'setCountry', - 'countryCode' => 'setCountryCode', - 'type' => 'setType' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'street' => 'getStreet', - 'city' => 'getCity', - 'state' => 'getState', - 'zip' => 'getZip', - 'country' => 'getCountry', - 'countryCode' => 'getCountryCode', - 'type' => 'getType' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } + public function __construct( + protected ?string $street = null, + protected ?string $city = null, + protected ?string $state = null, + protected ?string $zip = null, + protected ?string $country = null, + protected ?string $countryCode = null, + #[Assert\Choice(['HOME','WORK',])] - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; + protected ?string $type = null, + ) { } - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() + #[Ignore] + public function getModelName(): string { - return self::$openAPIModelName; + return self::OPENAPI_MODEL_NAME; } - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['street'] = $data['street'] ?? null; - $this->container['city'] = $data['city'] ?? null; - $this->container['state'] = $data['state'] ?? null; - $this->container['zip'] = $data['zip'] ?? null; - $this->container['country'] = $data['country'] ?? null; - $this->container['countryCode'] = $data['countryCode'] ?? null; - $this->container['type'] = $data['type'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $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() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets street - * - * @return string|null - */ - public function getStreet() + public function getStreet(): string|null { - return $this->container['street']; + return $this->street; } - /** - * Sets street - * - * @param string|null $street Street name. - * - * @return self - */ - public function setStreet($street) + public function setStreet(?string $street): self { - $this->container['street'] = $street; - + $this->street = $street; return $this; } - /** - * Gets city - * - * @return string|null - */ - public function getCity() + public function getCity(): string|null { - return $this->container['city']; + return $this->city; } - /** - * Sets city - * - * @param string|null $city City name. - * - * @return self - */ - public function setCity($city) + public function setCity(?string $city): self { - $this->container['city'] = $city; - + $this->city = $city; return $this; } - /** - * Gets state - * - * @return string|null - */ - public function getState() + public function getState(): string|null { - return $this->container['state']; + return $this->state; } - /** - * Sets state - * - * @param string|null $state State name. - * - * @return self - */ - public function setState($state) + public function setState(?string $state): self { - $this->container['state'] = $state; - + $this->state = $state; return $this; } - /** - * Gets zip - * - * @return string|null - */ - public function getZip() + public function getZip(): string|null { - return $this->container['zip']; + return $this->zip; } - /** - * Sets zip - * - * @param string|null $zip Zip code value. - * - * @return self - */ - public function setZip($zip) + public function setZip(?string $zip): self { - $this->container['zip'] = $zip; - + $this->zip = $zip; return $this; } - /** - * Gets country - * - * @return string|null - */ - public function getCountry() + public function getCountry(): string|null { - return $this->container['country']; + return $this->country; } - /** - * Sets country - * - * @param string|null $country Country name. - * - * @return self - */ - public function setCountry($country) + public function setCountry(?string $country): self { - $this->container['country'] = $country; - + $this->country = $country; return $this; } - /** - * Gets countryCode - * - * @return string|null - */ - public function getCountryCode() + public function getCountryCode(): string|null { - return $this->container['countryCode']; + return $this->countryCode; } - /** - * Sets countryCode - * - * @param string|null $countryCode Country code value. - * - * @return self - */ - public function setCountryCode($countryCode) + public function setCountryCode(?string $countryCode): self { - $this->container['countryCode'] = $countryCode; - + $this->countryCode = $countryCode; return $this; } - /** - * Gets type - * - * @return \Infobip\Model\WhatsAppAddressType|null - */ - public function getType() + public function getType(): mixed { - return $this->container['type']; + return $this->type; } - /** - * Sets type - * - * @param \Infobip\Model\WhatsAppAddressType|null $type type - * - * @return self - */ - public function setType($type) + public function setType($type): self { - $this->container['type'] = $type; - + $this->type = $type; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppAddressType.php b/Infobip/Model/WhatsAppAddressType.php index dc5962a..50d1eb5 100644 --- a/Infobip/Model/WhatsAppAddressType.php +++ b/Infobip/Model/WhatsAppAddressType.php @@ -1,14 +1,8 @@ value = $value; + } + + public static function HOME(): WhatsAppAddressType + { + return new self('HOME'); + } + + public static function WORK(): WhatsAppAddressType + { + return new self('WORK'); + } + + public function __toString(): string { - return [ - self::HOME, - self::WORK, - ]; + return $this->value; } } diff --git a/Infobip/Model/WhatsAppAudioContent.php b/Infobip/Model/WhatsAppAudioContent.php index bcbebaf..8fcebd0 100644 --- a/Infobip/Model/WhatsAppAudioContent.php +++ b/Infobip/Model/WhatsAppAudioContent.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppAudioContent implements ModelInterface, ArrayAccess, \JsonSerializable +class WhatsAppAudioContent implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppAudioContent'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'mediaUrl' => 'string' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'WhatsAppAudioContent'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'mediaUrl' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array */ - public static function openAPITypes() - { - return self::$openAPITypes; - } + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 2048)] + #[Assert\Length(min: 1)] - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; + protected string $mediaUrl, + ) { } - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'mediaUrl' => 'mediaUrl' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'mediaUrl' => 'setMediaUrl' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'mediaUrl' => 'getMediaUrl' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() + #[Ignore] + public function getModelName(): string { - return self::$setters; + return self::OPENAPI_MODEL_NAME; } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$getters; + return self::DISCRIMINATOR; } - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() + public function getMediaUrl(): string { - return self::$openAPIModelName; + return $this->mediaUrl; } - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) + public function setMediaUrl(string $mediaUrl): self { - $this->container['mediaUrl'] = $data['mediaUrl'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - if ($this->container['mediaUrl'] === null) { - $invalidProperties[] = "'mediaUrl' can't be null"; - } - if ((mb_strlen($this->container['mediaUrl']) > 2048)) { - $invalidProperties[] = "invalid value for 'mediaUrl', the character length must be smaller than or equal to 2048."; - } - - if ((mb_strlen($this->container['mediaUrl']) < 1)) { - $invalidProperties[] = "invalid value for 'mediaUrl', the character length must be bigger than or equal to 1."; - } - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets mediaUrl - * - * @return string - */ - public function getMediaUrl() - { - return $this->container['mediaUrl']; - } - - /** - * Sets mediaUrl - * - * @param string $mediaUrl URL of an audio sent in a WhatsApp message. Must be a valid URL starting with `https://` or `http://`. Supported audio types are `AAC`, `AMR`, `MP3`, `MP4`, `OPUS`. Maximum audio size is 16MB. - * - * @return self - */ - public function setMediaUrl($mediaUrl) - { - if ((mb_strlen($mediaUrl) > 2048)) { - throw new \InvalidArgumentException('invalid length for $mediaUrl when calling WhatsAppAudioContent., must be smaller than or equal to 2048.'); - } - if ((mb_strlen($mediaUrl) < 1)) { - throw new \InvalidArgumentException('invalid length for $mediaUrl when calling WhatsAppAudioContent., must be bigger than or equal to 1.'); - } - - $this->container['mediaUrl'] = $mediaUrl; - + $this->mediaUrl = $mediaUrl; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppAudioMessage.php b/Infobip/Model/WhatsAppAudioMessage.php index f8850b5..262ea98 100644 --- a/Infobip/Model/WhatsAppAudioMessage.php +++ b/Infobip/Model/WhatsAppAudioMessage.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppAudioMessage implements ModelInterface, ArrayAccess, \JsonSerializable +class WhatsAppAudioMessage implements ModelInterface { - public const DISCRIMINATOR = null; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'WhatsAppAudioMessage'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppAudioMessage'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'from' => 'string', - 'to' => 'string', - 'messageId' => 'string', - 'content' => '\Infobip\Model\WhatsAppAudioContent', - 'callbackData' => 'string', - 'notifyUrl' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'from' => null, 'to' => null, 'messageId' => null, @@ -79,472 +39,112 @@ class WhatsAppAudioMessage implements ModelInterface, ArrayAccess, \JsonSerializ ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array */ - public static function openAPITypes() - { - return self::$openAPITypes; - } + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 24)] + #[Assert\Length(min: 1)] - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } + protected string $from, + #[Assert\NotBlank] + #[Assert\Length(max: 24)] + #[Assert\Length(min: 1)] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'from' => 'from', - 'to' => 'to', - 'messageId' => 'messageId', - 'content' => 'content', - 'callbackData' => 'callbackData', - 'notifyUrl' => 'notifyUrl' - ]; + protected string $to, + #[Assert\Valid] + #[Assert\NotBlank] - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'from' => 'setFrom', - 'to' => 'setTo', - 'messageId' => 'setMessageId', - 'content' => 'setContent', - 'callbackData' => 'setCallbackData', - 'notifyUrl' => 'setNotifyUrl' - ]; + protected \Infobip\Model\WhatsAppAudioContent $content, + #[Assert\Length(max: 100)] + #[Assert\Length(min: 0)] - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'from' => 'getFrom', - 'to' => 'getTo', - 'messageId' => 'getMessageId', - 'content' => 'getContent', - 'callbackData' => 'getCallbackData', - 'notifyUrl' => 'getNotifyUrl' - ]; + protected ?string $messageId = null, + #[Assert\Length(max: 4000)] + #[Assert\Length(min: 0)] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } + protected ?string $callbackData = null, + #[Assert\Length(max: 2048)] + #[Assert\Length(min: 0)] - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; + protected ?string $notifyUrl = null, + ) { } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public function getModelName(): string { - return self::$getters; + return self::OPENAPI_MODEL_NAME; } - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) + #[Ignore] + public static function getDiscriminator(): ?string { - $this->container['from'] = $data['from'] ?? null; - $this->container['to'] = $data['to'] ?? null; - $this->container['messageId'] = $data['messageId'] ?? null; - $this->container['content'] = $data['content'] ?? null; - $this->container['callbackData'] = $data['callbackData'] ?? null; - $this->container['notifyUrl'] = $data['notifyUrl'] ?? null; + return self::DISCRIMINATOR; } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + public function getFrom(): string { - $invalidProperties = []; - - if ($this->container['from'] === null) { - $invalidProperties[] = "'from' can't be null"; - } - if ((mb_strlen($this->container['from']) > 24)) { - $invalidProperties[] = "invalid value for 'from', the character length must be smaller than or equal to 24."; - } - - if ((mb_strlen($this->container['from']) < 1)) { - $invalidProperties[] = "invalid value for 'from', the character length must be bigger than or equal to 1."; - } - - if ($this->container['to'] === null) { - $invalidProperties[] = "'to' can't be null"; - } - if ((mb_strlen($this->container['to']) > 24)) { - $invalidProperties[] = "invalid value for 'to', the character length must be smaller than or equal to 24."; - } - - if ((mb_strlen($this->container['to']) < 1)) { - $invalidProperties[] = "invalid value for 'to', the character length must be bigger than or equal to 1."; - } - - if (!is_null($this->container['messageId']) && (mb_strlen($this->container['messageId']) > 50)) { - $invalidProperties[] = "invalid value for 'messageId', the character length must be smaller than or equal to 50."; - } - - if (!is_null($this->container['messageId']) && (mb_strlen($this->container['messageId']) < 0)) { - $invalidProperties[] = "invalid value for 'messageId', the character length must be bigger than or equal to 0."; - } - - if ($this->container['content'] === null) { - $invalidProperties[] = "'content' can't be null"; - } - if (!is_null($this->container['callbackData']) && (mb_strlen($this->container['callbackData']) > 4000)) { - $invalidProperties[] = "invalid value for 'callbackData', the character length must be smaller than or equal to 4000."; - } - - if (!is_null($this->container['callbackData']) && (mb_strlen($this->container['callbackData']) < 0)) { - $invalidProperties[] = "invalid value for 'callbackData', the character length must be bigger than or equal to 0."; - } - - if (!is_null($this->container['notifyUrl']) && (mb_strlen($this->container['notifyUrl']) > 2048)) { - $invalidProperties[] = "invalid value for 'notifyUrl', the character length must be smaller than or equal to 2048."; - } - - if (!is_null($this->container['notifyUrl']) && (mb_strlen($this->container['notifyUrl']) < 0)) { - $invalidProperties[] = "invalid value for 'notifyUrl', the character length must be bigger than or equal to 0."; - } - - return $invalidProperties; + return $this->from; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + public function setFrom(string $from): self { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets from - * - * @return string - */ - public function getFrom() - { - return $this->container['from']; - } - - /** - * Sets from - * - * @param string $from Registered WhatsApp sender number. Must be in international format and comply with [WhatsApp's requirements](https://www.infobip.com/docs/whatsapp/get-started#phone-number-what-you-need-to-know). - * - * @return self - */ - public function setFrom($from) - { - if ((mb_strlen($from) > 24)) { - throw new \InvalidArgumentException('invalid length for $from when calling WhatsAppAudioMessage., must be smaller than or equal to 24.'); - } - if ((mb_strlen($from) < 1)) { - throw new \InvalidArgumentException('invalid length for $from when calling WhatsAppAudioMessage., must be bigger than or equal to 1.'); - } - - $this->container['from'] = $from; - + $this->from = $from; return $this; } - /** - * Gets to - * - * @return string - */ - public function getTo() + public function getTo(): string { - return $this->container['to']; + return $this->to; } - /** - * Sets to - * - * @param string $to Message recipient number. Must be in international format. - * - * @return self - */ - public function setTo($to) + public function setTo(string $to): self { - if ((mb_strlen($to) > 24)) { - throw new \InvalidArgumentException('invalid length for $to when calling WhatsAppAudioMessage., must be smaller than or equal to 24.'); - } - if ((mb_strlen($to) < 1)) { - throw new \InvalidArgumentException('invalid length for $to when calling WhatsAppAudioMessage., must be bigger than or equal to 1.'); - } - - $this->container['to'] = $to; - + $this->to = $to; return $this; } - /** - * Gets messageId - * - * @return string|null - */ - public function getMessageId() + public function getMessageId(): string|null { - return $this->container['messageId']; + return $this->messageId; } - /** - * Sets messageId - * - * @param string|null $messageId The ID that uniquely identifies the message sent. - * - * @return self - */ - public function setMessageId($messageId) + public function setMessageId(?string $messageId): self { - if (!is_null($messageId) && (mb_strlen($messageId) > 50)) { - throw new \InvalidArgumentException('invalid length for $messageId when calling WhatsAppAudioMessage., must be smaller than or equal to 50.'); - } - if (!is_null($messageId) && (mb_strlen($messageId) < 0)) { - throw new \InvalidArgumentException('invalid length for $messageId when calling WhatsAppAudioMessage., must be bigger than or equal to 0.'); - } - - $this->container['messageId'] = $messageId; - + $this->messageId = $messageId; return $this; } - /** - * Gets content - * - * @return \Infobip\Model\WhatsAppAudioContent - */ - public function getContent() + public function getContent(): \Infobip\Model\WhatsAppAudioContent { - return $this->container['content']; + return $this->content; } - /** - * Sets content - * - * @param \Infobip\Model\WhatsAppAudioContent $content content - * - * @return self - */ - public function setContent($content) + public function setContent(\Infobip\Model\WhatsAppAudioContent $content): self { - $this->container['content'] = $content; - + $this->content = $content; return $this; } - /** - * Gets callbackData - * - * @return string|null - */ - public function getCallbackData() + public function getCallbackData(): string|null { - return $this->container['callbackData']; + return $this->callbackData; } - /** - * Sets callbackData - * - * @param string|null $callbackData Custom client data that will be included in a [Delivery Report](#channels/whatsapp/receive-whatsapp-delivery-reports). - * - * @return self - */ - public function setCallbackData($callbackData) + public function setCallbackData(?string $callbackData): self { - if (!is_null($callbackData) && (mb_strlen($callbackData) > 4000)) { - throw new \InvalidArgumentException('invalid length for $callbackData when calling WhatsAppAudioMessage., must be smaller than or equal to 4000.'); - } - if (!is_null($callbackData) && (mb_strlen($callbackData) < 0)) { - throw new \InvalidArgumentException('invalid length for $callbackData when calling WhatsAppAudioMessage., must be bigger than or equal to 0.'); - } - - $this->container['callbackData'] = $callbackData; - + $this->callbackData = $callbackData; return $this; } - /** - * Gets notifyUrl - * - * @return string|null - */ - public function getNotifyUrl() + public function getNotifyUrl(): string|null { - return $this->container['notifyUrl']; + return $this->notifyUrl; } - /** - * Sets notifyUrl - * - * @param string|null $notifyUrl The URL on your callback server to which delivery and seen reports will be sent. [Delivery report format](#channels/whatsapp/receive-whatsapp-delivery-reports), [Seen report format](#channels/whatsapp/receive-whatsapp-seen-reports). - * - * @return self - */ - public function setNotifyUrl($notifyUrl) + public function setNotifyUrl(?string $notifyUrl): self { - if (!is_null($notifyUrl) && (mb_strlen($notifyUrl) > 2048)) { - throw new \InvalidArgumentException('invalid length for $notifyUrl when calling WhatsAppAudioMessage., must be smaller than or equal to 2048.'); - } - if (!is_null($notifyUrl) && (mb_strlen($notifyUrl) < 0)) { - throw new \InvalidArgumentException('invalid length for $notifyUrl when calling WhatsAppAudioMessage., must be bigger than or equal to 0.'); - } - - $this->container['notifyUrl'] = $notifyUrl; - + $this->notifyUrl = $notifyUrl; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppBodyApiData.php b/Infobip/Model/WhatsAppBodyApiData.php index b5f7fe1..36280c3 100644 --- a/Infobip/Model/WhatsAppBodyApiData.php +++ b/Infobip/Model/WhatsAppBodyApiData.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppBodyApiData implements ModelInterface, ArrayAccess, \JsonSerializable +class WhatsAppBodyApiData implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppBodyApiData'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'text' => 'string', - 'examples' => 'string[]' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'WhatsAppBodyApiData'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'text' => null, 'examples' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'text' => 'text', - 'examples' => 'examples' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] + * @param string[] $examples */ - protected static $setters = [ - 'text' => 'setText', - 'examples' => 'setExamples' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'text' => 'getText', - 'examples' => 'getExamples' - ]; + public function __construct( + #[Assert\NotBlank] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; + protected string $text, + protected ?array $examples = null, + ) { } - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() + #[Ignore] + public function getModelName(): string { - return self::$setters; + return self::OPENAPI_MODEL_NAME; } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$getters; + return self::DISCRIMINATOR; } - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() + public function getText(): string { - return self::$openAPIModelName; + return $this->text; } - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) + public function setText(string $text): self { - $this->container['text'] = $data['text'] ?? null; - $this->container['examples'] = $data['examples'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - if ($this->container['text'] === null) { - $invalidProperties[] = "'text' can't be null"; - } - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets text - * - * @return string - */ - public function getText() - { - return $this->container['text']; - } - - /** - * Sets text - * - * @param string $text Plain text or text with placeholders. Placeholders have to be correctly formatted and in the correct order, regardless of other sections. Example: {{1}}, {{2}}, {{3}}... - * - * @return self - */ - public function setText($text) - { - $this->container['text'] = $text; - + $this->text = $text; return $this; } /** - * Gets examples - * * @return string[]|null */ - public function getExamples() + public function getExamples(): ?array { - return $this->container['examples']; + return $this->examples; } /** - * Sets examples - * * @param string[]|null $examples Placeholders examples. The number of examples has to be the same as the number of placeholders. Examples cannot contain placeholders. - * - * @return self */ - public function setExamples($examples) + public function setExamples(?array $examples): self { - $this->container['examples'] = $examples; - + $this->examples = $examples; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppBulkMessage.php b/Infobip/Model/WhatsAppBulkMessage.php index fefffa4..3dfd2dd 100644 --- a/Infobip/Model/WhatsAppBulkMessage.php +++ b/Infobip/Model/WhatsAppBulkMessage.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppBulkMessage implements ModelInterface, ArrayAccess, \JsonSerializable +class WhatsAppBulkMessage implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppBulkMessage'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'messages' => '\Infobip\Model\WhatsAppMessage[]', - 'bulkId' => 'string' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'WhatsAppBulkMessage'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'messages' => null, 'bulkId' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array + * @param \Infobip\Model\WhatsAppMessage[] $messages */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } + public function __construct( + #[Assert\NotBlank] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'messages' => 'messages', - 'bulkId' => 'bulkId' - ]; + protected array $messages, + #[Assert\Length(max: 100)] + #[Assert\Length(min: 0)] - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'messages' => 'setMessages', - 'bulkId' => 'setBulkId' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'messages' => 'getMessages', - 'bulkId' => 'getBulkId' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; + protected ?string $bulkId = null, + ) { } - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public function getModelName(): string { - return self::$getters; + return self::OPENAPI_MODEL_NAME; } - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$openAPIModelName; + return self::DISCRIMINATOR; } - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['messages'] = $data['messages'] ?? null; - $this->container['bulkId'] = $data['bulkId'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - if ($this->container['messages'] === null) { - $invalidProperties[] = "'messages' can't be null"; - } - if (!is_null($this->container['bulkId']) && (mb_strlen($this->container['bulkId']) > 100)) { - $invalidProperties[] = "invalid value for 'bulkId', the character length must be smaller than or equal to 100."; - } - - if (!is_null($this->container['bulkId']) && (mb_strlen($this->container['bulkId']) < 0)) { - $invalidProperties[] = "invalid value for 'bulkId', the character length must be bigger than or equal to 0."; - } - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets messages - * * @return \Infobip\Model\WhatsAppMessage[] */ - public function getMessages() + public function getMessages(): array { - return $this->container['messages']; + return $this->messages; } /** - * Sets messages - * * @param \Infobip\Model\WhatsAppMessage[] $messages An array of messages being sent. - * - * @return self */ - public function setMessages($messages) + public function setMessages(array $messages): self { - $this->container['messages'] = $messages; - + $this->messages = $messages; return $this; } - /** - * Gets bulkId - * - * @return string|null - */ - public function getBulkId() + public function getBulkId(): string|null { - return $this->container['bulkId']; + return $this->bulkId; } - /** - * Sets bulkId - * - * @param string|null $bulkId The ID that uniquely identifies the request. Bulk ID will be received only when you send a message to more than one destination address. - * - * @return self - */ - public function setBulkId($bulkId) + public function setBulkId(?string $bulkId): self { - if (!is_null($bulkId) && (mb_strlen($bulkId) > 100)) { - throw new \InvalidArgumentException('invalid length for $bulkId when calling WhatsAppBulkMessage., must be smaller than or equal to 100.'); - } - if (!is_null($bulkId) && (mb_strlen($bulkId) < 0)) { - throw new \InvalidArgumentException('invalid length for $bulkId when calling WhatsAppBulkMessage., must be bigger than or equal to 0.'); - } - - $this->container['bulkId'] = $bulkId; - + $this->bulkId = $bulkId; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppBulkMessageInfo.php b/Infobip/Model/WhatsAppBulkMessageInfo.php index 0a3ccba..56c9a81 100644 --- a/Infobip/Model/WhatsAppBulkMessageInfo.php +++ b/Infobip/Model/WhatsAppBulkMessageInfo.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppBulkMessageInfo implements ModelInterface, ArrayAccess, \JsonSerializable +class WhatsAppBulkMessageInfo implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppBulkMessageInfo'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'messages' => '\Infobip\Model\WhatsAppSingleMessageInfo[]', - 'bulkId' => 'string' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'WhatsAppBulkMessageInfo'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'messages' => null, 'bulkId' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'messages' => 'messages', - 'bulkId' => 'bulkId' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'messages' => 'setMessages', - 'bulkId' => 'setBulkId' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'messages' => 'getMessages', - 'bulkId' => 'getBulkId' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model + * @param \Infobip\Model\WhatsAppSingleMessageInfo[] $messages */ - public function __construct(array $data = null) - { - $this->container['messages'] = $data['messages'] ?? null; - $this->container['bulkId'] = $data['bulkId'] ?? null; + public function __construct( + protected ?array $messages = null, + protected ?string $bulkId = null, + ) { } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - /** - * Gets messages - * * @return \Infobip\Model\WhatsAppSingleMessageInfo[]|null */ - public function getMessages() + public function getMessages(): ?array { - return $this->container['messages']; + return $this->messages; } /** - * Sets messages - * * @param \Infobip\Model\WhatsAppSingleMessageInfo[]|null $messages Array of sent message objects, one object per every message. - * - * @return self */ - public function setMessages($messages) + public function setMessages(?array $messages): self { - $this->container['messages'] = $messages; - + $this->messages = $messages; return $this; } - /** - * Gets bulkId - * - * @return string|null - */ - public function getBulkId() + public function getBulkId(): string|null { - return $this->container['bulkId']; + return $this->bulkId; } - /** - * Sets bulkId - * - * @param string|null $bulkId The ID that uniquely identifies the request. Bulk ID will be received only when you send a message to more than one destination address. - * - * @return self - */ - public function setBulkId($bulkId) + public function setBulkId(?string $bulkId): self { - $this->container['bulkId'] = $bulkId; - + $this->bulkId = $bulkId; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppButtonApiData.php b/Infobip/Model/WhatsAppButtonApiData.php index d6b80dc..13caad5 100644 --- a/Infobip/Model/WhatsAppButtonApiData.php +++ b/Infobip/Model/WhatsAppButtonApiData.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppButtonApiData implements ModelInterface, ArrayAccess, \JsonSerializable +use Symfony\Component\Validator\Constraints as Assert; +use Symfony\Component\Serializer\Annotation as Serializer; +use Symfony\Component\Serializer\Annotation\Ignore; +use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer; +use Symfony\Component\Serializer\Annotation\DiscriminatorMap; + +#[DiscriminatorMap(typeProperty: "type", mapping: [ + "PHONE_NUMBER" => "\Infobip\Model\WhatsAppPhoneNumberButtonApiData", + "QUICK_REPLY" => "\Infobip\Model\WhatsAppQuickReplyButtonApiData", + "URL" => "\Infobip\Model\WhatsAppUrlButtonApiData", + "WhatsAppPhoneNumberButtonApiData" => "\Infobip\Model\WhatsAppPhoneNumberButtonApiData", + "WhatsAppQuickReplyButtonApiData" => "\Infobip\Model\WhatsAppQuickReplyButtonApiData", + "WhatsAppUrlButtonApiData" => "\Infobip\Model\WhatsAppUrlButtonApiData", +])] +class WhatsAppButtonApiData implements ModelInterface { public const DISCRIMINATOR = 'type'; + public const OPENAPI_MODEL_NAME = 'WhatsAppButtonApiData'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppButtonApiData'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'type' => 'string', - 'text' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'type' => null, 'text' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'type' => 'type', - 'text' => 'text' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'type' => 'setType', - 'text' => 'setText' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'type' => 'getType', - 'text' => 'getText' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - public const TYPE_PHONE_NUMBER = 'PHONE_NUMBER'; - public const TYPE_URL = 'URL'; - public const TYPE_QUICK_REPLY = 'QUICK_REPLY'; - - - - /** - * Gets allowable values of the enum - * - * @return string[] */ - public function getTypeAllowableValues() - { - return [ - self::TYPE_PHONE_NUMBER, - self::TYPE_URL, - self::TYPE_QUICK_REPLY, - ]; - } + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 200)] + #[Assert\Length(min: 0)] + protected string $text, + #[Assert\Choice(['PHONE_NUMBER','URL','QUICK_REPLY',])] - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['type'] = $data['type'] ?? null; - $this->container['text'] = $data['text'] ?? null; + protected ?string $type = null, + ) { } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - $allowedValues = $this->getTypeAllowableValues(); - if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { - $invalidProperties[] = sprintf( - "invalid value '%s' for 'type', must be one of '%s'", - $this->container['type'], - implode("', '", $allowedValues) - ); - } - - if ($this->container['text'] === null) { - $invalidProperties[] = "'text' can't be null"; - } - if ((mb_strlen($this->container['text']) > 200)) { - $invalidProperties[] = "invalid value for 'text', the character length must be smaller than or equal to 200."; - } - - if ((mb_strlen($this->container['text']) < 0)) { - $invalidProperties[] = "invalid value for 'text', the character length must be bigger than or equal to 0."; - } - - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets type - * - * @return string|null - */ - public function getType() + public function getType(): mixed { - return $this->container['type']; + return $this->type; } - /** - * Sets type - * - * @param string|null $type type - * - * @return self - */ - public function setType($type) + public function setType($type): self { - $allowedValues = $this->getTypeAllowableValues(); - if (!is_null($type) && !in_array($type, $allowedValues, true)) { - throw new \InvalidArgumentException( - sprintf( - "Invalid value '%s' for 'type', must be one of '%s'", - $type, - implode("', '", $allowedValues) - ) - ); - } - $this->container['type'] = $type; - + $this->type = $type; return $this; } - /** - * Gets text - * - * @return string - */ - public function getText() + public function getText(): string { - return $this->container['text']; + return $this->text; } - /** - * Sets text - * - * @param string $text Button text. - * - * @return self - */ - public function setText($text) + public function setText(string $text): self { - if ((mb_strlen($text) > 200)) { - throw new \InvalidArgumentException('invalid length for $text when calling WhatsAppButtonApiData., must be smaller than or equal to 200.'); - } - if ((mb_strlen($text) < 0)) { - throw new \InvalidArgumentException('invalid length for $text when calling WhatsAppButtonApiData., must be bigger than or equal to 0.'); - } - - $this->container['text'] = $text; - + $this->text = $text; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppCategory.php b/Infobip/Model/WhatsAppCategory.php index 0dcd556..c6c9031 100644 --- a/Infobip/Model/WhatsAppCategory.php +++ b/Infobip/Model/WhatsAppCategory.php @@ -1,14 +1,8 @@ value = $value; + } + + public static function ACCOUNT_UPDATE(): WhatsAppCategory + { + return new self('ACCOUNT_UPDATE'); + } + + public static function PAYMENT_UPDATE(): WhatsAppCategory + { + return new self('PAYMENT_UPDATE'); + } + + public static function PERSONAL_FINANCE_UPDATE(): WhatsAppCategory + { + return new self('PERSONAL_FINANCE_UPDATE'); + } + + public static function SHIPPING_UPDATE(): WhatsAppCategory + { + return new self('SHIPPING_UPDATE'); + } + + public static function RESERVATION_UPDATE(): WhatsAppCategory + { + return new self('RESERVATION_UPDATE'); + } + + public static function ISSUE_RESOLUTION(): WhatsAppCategory + { + return new self('ISSUE_RESOLUTION'); + } + + public static function APPOINTMENT_UPDATE(): WhatsAppCategory + { + return new self('APPOINTMENT_UPDATE'); + } + + public static function TRANSPORTATION_UPDATE(): WhatsAppCategory + { + return new self('TRANSPORTATION_UPDATE'); + } + + public static function TICKET_UPDATE(): WhatsAppCategory + { + return new self('TICKET_UPDATE'); + } + + public static function ALERT_UPDATE(): WhatsAppCategory + { + return new self('ALERT_UPDATE'); + } + + public static function AUTO_REPLY(): WhatsAppCategory + { + return new self('AUTO_REPLY'); + } + + public static function MARKETING(): WhatsAppCategory + { + return new self('MARKETING'); + } + + public static function TRANSACTIONAL(): WhatsAppCategory + { + return new self('TRANSACTIONAL'); + } + + public static function OTP(): WhatsAppCategory + { + return new self('OTP'); + } + + public function __toString(): string + { + return $this->value; } } diff --git a/Infobip/Model/WhatsAppContactContent.php b/Infobip/Model/WhatsAppContactContent.php index 2a405b7..3c3dc88 100644 --- a/Infobip/Model/WhatsAppContactContent.php +++ b/Infobip/Model/WhatsAppContactContent.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppContactContent implements ModelInterface, ArrayAccess, \JsonSerializable +class WhatsAppContactContent implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppContactContent'; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'WhatsAppContactContent'; - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'addresses' => '\Infobip\Model\WhatsAppAddressContent[]', - 'birthday' => 'string', - 'emails' => '\Infobip\Model\WhatsAppEmailContent[]', - 'name' => '\Infobip\Model\WhatsAppNameContent', - 'org' => '\Infobip\Model\WhatsAppOrganizationContent', - 'phones' => '\Infobip\Model\WhatsAppPhoneContent[]', - 'urls' => '\Infobip\Model\WhatsAppUrlContent[]' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'addresses' => null, 'birthday' => null, 'emails' => null, @@ -82,419 +40,137 @@ class WhatsAppContactContent implements ModelInterface, ArrayAccess, \JsonSerial ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'addresses' => 'addresses', - 'birthday' => 'birthday', - 'emails' => 'emails', - 'name' => 'name', - 'org' => 'org', - 'phones' => 'phones', - 'urls' => 'urls' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'addresses' => 'setAddresses', - 'birthday' => 'setBirthday', - 'emails' => 'setEmails', - 'name' => 'setName', - 'org' => 'setOrg', - 'phones' => 'setPhones', - 'urls' => 'setUrls' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] + * @param \Infobip\Model\WhatsAppAddressContent[] $addresses + * @param \Infobip\Model\WhatsAppEmailContent[] $emails + * @param \Infobip\Model\WhatsAppPhoneContent[] $phones + * @param \Infobip\Model\WhatsAppUrlContent[] $urls */ - protected static $getters = [ - 'addresses' => 'getAddresses', - 'birthday' => 'getBirthday', - 'emails' => 'getEmails', - 'name' => 'getName', - 'org' => 'getOrg', - 'phones' => 'getPhones', - 'urls' => 'getUrls' - ]; + public function __construct( + #[Assert\Valid] + #[Assert\NotBlank] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } + protected \Infobip\Model\WhatsAppNameContent $name, + protected ?array $addresses = null, + protected ?string $birthday = null, + protected ?array $emails = null, + #[Assert\Valid] - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; + protected ?\Infobip\Model\WhatsAppOrganizationContent $org = null, + protected ?array $phones = null, + protected ?array $urls = null, + ) { } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public function getModelName(): string { - return self::$getters; + return self::OPENAPI_MODEL_NAME; } - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$openAPIModelName; + return self::DISCRIMINATOR; } - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['addresses'] = $data['addresses'] ?? null; - $this->container['birthday'] = $data['birthday'] ?? null; - $this->container['emails'] = $data['emails'] ?? null; - $this->container['name'] = $data['name'] ?? null; - $this->container['org'] = $data['org'] ?? null; - $this->container['phones'] = $data['phones'] ?? null; - $this->container['urls'] = $data['urls'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - if ($this->container['name'] === null) { - $invalidProperties[] = "'name' can't be null"; - } - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets addresses - * * @return \Infobip\Model\WhatsAppAddressContent[]|null */ - public function getAddresses() + public function getAddresses(): ?array { - return $this->container['addresses']; + return $this->addresses; } /** - * Sets addresses - * * @param \Infobip\Model\WhatsAppAddressContent[]|null $addresses Array of addresses information. - * - * @return self */ - public function setAddresses($addresses) + public function setAddresses(?array $addresses): self { - $this->container['addresses'] = $addresses; - + $this->addresses = $addresses; return $this; } - /** - * Gets birthday - * - * @return string|null - */ - public function getBirthday() + public function getBirthday(): string|null { - return $this->container['birthday']; + return $this->birthday; } - /** - * Sets birthday - * - * @param string|null $birthday Date of birth in `YYYY-MM-DD` format. - * - * @return self - */ - public function setBirthday($birthday) + public function setBirthday(?string $birthday): self { - $this->container['birthday'] = $birthday; - + $this->birthday = $birthday; return $this; } /** - * Gets emails - * * @return \Infobip\Model\WhatsAppEmailContent[]|null */ - public function getEmails() + public function getEmails(): ?array { - return $this->container['emails']; + return $this->emails; } /** - * Sets emails - * * @param \Infobip\Model\WhatsAppEmailContent[]|null $emails Array of emails information. - * - * @return self */ - public function setEmails($emails) + public function setEmails(?array $emails): self { - $this->container['emails'] = $emails; - + $this->emails = $emails; return $this; } - /** - * Gets name - * - * @return \Infobip\Model\WhatsAppNameContent - */ - public function getName() + public function getName(): \Infobip\Model\WhatsAppNameContent { - return $this->container['name']; + return $this->name; } - /** - * Sets name - * - * @param \Infobip\Model\WhatsAppNameContent $name name - * - * @return self - */ - public function setName($name) + public function setName(\Infobip\Model\WhatsAppNameContent $name): self { - $this->container['name'] = $name; - + $this->name = $name; return $this; } - /** - * Gets org - * - * @return \Infobip\Model\WhatsAppOrganizationContent|null - */ - public function getOrg() + public function getOrg(): \Infobip\Model\WhatsAppOrganizationContent|null { - return $this->container['org']; + return $this->org; } - /** - * Sets org - * - * @param \Infobip\Model\WhatsAppOrganizationContent|null $org org - * - * @return self - */ - public function setOrg($org) + public function setOrg(?\Infobip\Model\WhatsAppOrganizationContent $org): self { - $this->container['org'] = $org; - + $this->org = $org; return $this; } /** - * Gets phones - * * @return \Infobip\Model\WhatsAppPhoneContent[]|null */ - public function getPhones() + public function getPhones(): ?array { - return $this->container['phones']; + return $this->phones; } /** - * Sets phones - * * @param \Infobip\Model\WhatsAppPhoneContent[]|null $phones Array of phones information. - * - * @return self */ - public function setPhones($phones) + public function setPhones(?array $phones): self { - $this->container['phones'] = $phones; - + $this->phones = $phones; return $this; } /** - * Gets urls - * * @return \Infobip\Model\WhatsAppUrlContent[]|null */ - public function getUrls() + public function getUrls(): ?array { - return $this->container['urls']; + return $this->urls; } /** - * Sets urls - * * @param \Infobip\Model\WhatsAppUrlContent[]|null $urls Array of urls information. - * - * @return self */ - public function setUrls($urls) + public function setUrls(?array $urls): self { - $this->container['urls'] = $urls; - + $this->urls = $urls; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppContactsContent.php b/Infobip/Model/WhatsAppContactsContent.php index 85d0684..a0ef1e0 100644 --- a/Infobip/Model/WhatsAppContactsContent.php +++ b/Infobip/Model/WhatsAppContactsContent.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppContactsContent implements ModelInterface, ArrayAccess, \JsonSerializable +class WhatsAppContactsContent implements ModelInterface { - public const DISCRIMINATOR = null; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'WhatsAppContactsContent'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppContactsContent'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'contacts' => '\Infobip\Model\WhatsAppContactContent[]' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'contacts' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'contacts' => 'contacts' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'contacts' => 'setContacts' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'contacts' => 'getContacts' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string + * @param \Infobip\Model\WhatsAppContactContent[] $contacts */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; + public function __construct( + #[Assert\NotBlank] - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['contacts'] = $data['contacts'] ?? null; + protected array $contacts, + ) { } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - if ($this->container['contacts'] === null) { - $invalidProperties[] = "'contacts' can't be null"; - } - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - /** - * Gets contacts - * * @return \Infobip\Model\WhatsAppContactContent[] */ - public function getContacts() + public function getContacts(): array { - return $this->container['contacts']; + return $this->contacts; } /** - * Sets contacts - * * @param \Infobip\Model\WhatsAppContactContent[] $contacts An array of contacts sent in a WhatsApp message. - * - * @return self */ - public function setContacts($contacts) + public function setContacts(array $contacts): self { - $this->container['contacts'] = $contacts; - + $this->contacts = $contacts; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppContactsMessage.php b/Infobip/Model/WhatsAppContactsMessage.php index 283128f..69af5fd 100644 --- a/Infobip/Model/WhatsAppContactsMessage.php +++ b/Infobip/Model/WhatsAppContactsMessage.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppContactsMessage implements ModelInterface, ArrayAccess, \JsonSerializable +class WhatsAppContactsMessage implements ModelInterface { - public const DISCRIMINATOR = null; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'WhatsAppContactsMessage'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppContactsMessage'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'from' => 'string', - 'to' => 'string', - 'messageId' => 'string', - 'content' => '\Infobip\Model\WhatsAppContactsContent', - 'callbackData' => 'string', - 'notifyUrl' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'from' => null, 'to' => null, 'messageId' => null, @@ -79,472 +39,112 @@ class WhatsAppContactsMessage implements ModelInterface, ArrayAccess, \JsonSeria ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array */ - public static function openAPITypes() - { - return self::$openAPITypes; - } + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 24)] + #[Assert\Length(min: 1)] - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } + protected string $from, + #[Assert\NotBlank] + #[Assert\Length(max: 24)] + #[Assert\Length(min: 1)] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'from' => 'from', - 'to' => 'to', - 'messageId' => 'messageId', - 'content' => 'content', - 'callbackData' => 'callbackData', - 'notifyUrl' => 'notifyUrl' - ]; + protected string $to, + #[Assert\Valid] + #[Assert\NotBlank] - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'from' => 'setFrom', - 'to' => 'setTo', - 'messageId' => 'setMessageId', - 'content' => 'setContent', - 'callbackData' => 'setCallbackData', - 'notifyUrl' => 'setNotifyUrl' - ]; + protected \Infobip\Model\WhatsAppContactsContent $content, + #[Assert\Length(max: 100)] + #[Assert\Length(min: 0)] - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'from' => 'getFrom', - 'to' => 'getTo', - 'messageId' => 'getMessageId', - 'content' => 'getContent', - 'callbackData' => 'getCallbackData', - 'notifyUrl' => 'getNotifyUrl' - ]; + protected ?string $messageId = null, + #[Assert\Length(max: 4000)] + #[Assert\Length(min: 0)] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } + protected ?string $callbackData = null, + #[Assert\Length(max: 2048)] + #[Assert\Length(min: 0)] - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; + protected ?string $notifyUrl = null, + ) { } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public function getModelName(): string { - return self::$getters; + return self::OPENAPI_MODEL_NAME; } - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) + #[Ignore] + public static function getDiscriminator(): ?string { - $this->container['from'] = $data['from'] ?? null; - $this->container['to'] = $data['to'] ?? null; - $this->container['messageId'] = $data['messageId'] ?? null; - $this->container['content'] = $data['content'] ?? null; - $this->container['callbackData'] = $data['callbackData'] ?? null; - $this->container['notifyUrl'] = $data['notifyUrl'] ?? null; + return self::DISCRIMINATOR; } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + public function getFrom(): string { - $invalidProperties = []; - - if ($this->container['from'] === null) { - $invalidProperties[] = "'from' can't be null"; - } - if ((mb_strlen($this->container['from']) > 24)) { - $invalidProperties[] = "invalid value for 'from', the character length must be smaller than or equal to 24."; - } - - if ((mb_strlen($this->container['from']) < 1)) { - $invalidProperties[] = "invalid value for 'from', the character length must be bigger than or equal to 1."; - } - - if ($this->container['to'] === null) { - $invalidProperties[] = "'to' can't be null"; - } - if ((mb_strlen($this->container['to']) > 24)) { - $invalidProperties[] = "invalid value for 'to', the character length must be smaller than or equal to 24."; - } - - if ((mb_strlen($this->container['to']) < 1)) { - $invalidProperties[] = "invalid value for 'to', the character length must be bigger than or equal to 1."; - } - - if (!is_null($this->container['messageId']) && (mb_strlen($this->container['messageId']) > 50)) { - $invalidProperties[] = "invalid value for 'messageId', the character length must be smaller than or equal to 50."; - } - - if (!is_null($this->container['messageId']) && (mb_strlen($this->container['messageId']) < 0)) { - $invalidProperties[] = "invalid value for 'messageId', the character length must be bigger than or equal to 0."; - } - - if ($this->container['content'] === null) { - $invalidProperties[] = "'content' can't be null"; - } - if (!is_null($this->container['callbackData']) && (mb_strlen($this->container['callbackData']) > 4000)) { - $invalidProperties[] = "invalid value for 'callbackData', the character length must be smaller than or equal to 4000."; - } - - if (!is_null($this->container['callbackData']) && (mb_strlen($this->container['callbackData']) < 0)) { - $invalidProperties[] = "invalid value for 'callbackData', the character length must be bigger than or equal to 0."; - } - - if (!is_null($this->container['notifyUrl']) && (mb_strlen($this->container['notifyUrl']) > 2048)) { - $invalidProperties[] = "invalid value for 'notifyUrl', the character length must be smaller than or equal to 2048."; - } - - if (!is_null($this->container['notifyUrl']) && (mb_strlen($this->container['notifyUrl']) < 0)) { - $invalidProperties[] = "invalid value for 'notifyUrl', the character length must be bigger than or equal to 0."; - } - - return $invalidProperties; + return $this->from; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + public function setFrom(string $from): self { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets from - * - * @return string - */ - public function getFrom() - { - return $this->container['from']; - } - - /** - * Sets from - * - * @param string $from Registered WhatsApp sender number. Must be in international format and comply with [WhatsApp's requirements](https://www.infobip.com/docs/whatsapp/get-started#phone-number-what-you-need-to-know). - * - * @return self - */ - public function setFrom($from) - { - if ((mb_strlen($from) > 24)) { - throw new \InvalidArgumentException('invalid length for $from when calling WhatsAppContactsMessage., must be smaller than or equal to 24.'); - } - if ((mb_strlen($from) < 1)) { - throw new \InvalidArgumentException('invalid length for $from when calling WhatsAppContactsMessage., must be bigger than or equal to 1.'); - } - - $this->container['from'] = $from; - + $this->from = $from; return $this; } - /** - * Gets to - * - * @return string - */ - public function getTo() + public function getTo(): string { - return $this->container['to']; + return $this->to; } - /** - * Sets to - * - * @param string $to Message recipient number. Must be in international format. - * - * @return self - */ - public function setTo($to) + public function setTo(string $to): self { - if ((mb_strlen($to) > 24)) { - throw new \InvalidArgumentException('invalid length for $to when calling WhatsAppContactsMessage., must be smaller than or equal to 24.'); - } - if ((mb_strlen($to) < 1)) { - throw new \InvalidArgumentException('invalid length for $to when calling WhatsAppContactsMessage., must be bigger than or equal to 1.'); - } - - $this->container['to'] = $to; - + $this->to = $to; return $this; } - /** - * Gets messageId - * - * @return string|null - */ - public function getMessageId() + public function getMessageId(): string|null { - return $this->container['messageId']; + return $this->messageId; } - /** - * Sets messageId - * - * @param string|null $messageId The ID that uniquely identifies the message sent. - * - * @return self - */ - public function setMessageId($messageId) + public function setMessageId(?string $messageId): self { - if (!is_null($messageId) && (mb_strlen($messageId) > 50)) { - throw new \InvalidArgumentException('invalid length for $messageId when calling WhatsAppContactsMessage., must be smaller than or equal to 50.'); - } - if (!is_null($messageId) && (mb_strlen($messageId) < 0)) { - throw new \InvalidArgumentException('invalid length for $messageId when calling WhatsAppContactsMessage., must be bigger than or equal to 0.'); - } - - $this->container['messageId'] = $messageId; - + $this->messageId = $messageId; return $this; } - /** - * Gets content - * - * @return \Infobip\Model\WhatsAppContactsContent - */ - public function getContent() + public function getContent(): \Infobip\Model\WhatsAppContactsContent { - return $this->container['content']; + return $this->content; } - /** - * Sets content - * - * @param \Infobip\Model\WhatsAppContactsContent $content content - * - * @return self - */ - public function setContent($content) + public function setContent(\Infobip\Model\WhatsAppContactsContent $content): self { - $this->container['content'] = $content; - + $this->content = $content; return $this; } - /** - * Gets callbackData - * - * @return string|null - */ - public function getCallbackData() + public function getCallbackData(): string|null { - return $this->container['callbackData']; + return $this->callbackData; } - /** - * Sets callbackData - * - * @param string|null $callbackData Custom client data that will be included in a [Delivery Report](#channels/whatsapp/receive-whatsapp-delivery-reports). - * - * @return self - */ - public function setCallbackData($callbackData) + public function setCallbackData(?string $callbackData): self { - if (!is_null($callbackData) && (mb_strlen($callbackData) > 4000)) { - throw new \InvalidArgumentException('invalid length for $callbackData when calling WhatsAppContactsMessage., must be smaller than or equal to 4000.'); - } - if (!is_null($callbackData) && (mb_strlen($callbackData) < 0)) { - throw new \InvalidArgumentException('invalid length for $callbackData when calling WhatsAppContactsMessage., must be bigger than or equal to 0.'); - } - - $this->container['callbackData'] = $callbackData; - + $this->callbackData = $callbackData; return $this; } - /** - * Gets notifyUrl - * - * @return string|null - */ - public function getNotifyUrl() + public function getNotifyUrl(): string|null { - return $this->container['notifyUrl']; + return $this->notifyUrl; } - /** - * Sets notifyUrl - * - * @param string|null $notifyUrl The URL on your callback server to which delivery and seen reports will be sent. [Delivery report format](#channels/whatsapp/receive-whatsapp-delivery-reports), [Seen report format](#channels/whatsapp/receive-whatsapp-seen-reports). - * - * @return self - */ - public function setNotifyUrl($notifyUrl) + public function setNotifyUrl(?string $notifyUrl): self { - if (!is_null($notifyUrl) && (mb_strlen($notifyUrl) > 2048)) { - throw new \InvalidArgumentException('invalid length for $notifyUrl when calling WhatsAppContactsMessage., must be smaller than or equal to 2048.'); - } - if (!is_null($notifyUrl) && (mb_strlen($notifyUrl) < 0)) { - throw new \InvalidArgumentException('invalid length for $notifyUrl when calling WhatsAppContactsMessage., must be bigger than or equal to 0.'); - } - - $this->container['notifyUrl'] = $notifyUrl; - + $this->notifyUrl = $notifyUrl; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppDocumentContent.php b/Infobip/Model/WhatsAppDocumentContent.php index 37b1355..47d2080 100644 --- a/Infobip/Model/WhatsAppDocumentContent.php +++ b/Infobip/Model/WhatsAppDocumentContent.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppDocumentContent implements ModelInterface, ArrayAccess, \JsonSerializable +class WhatsAppDocumentContent implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppDocumentContent'; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'WhatsAppDocumentContent'; - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'mediaUrl' => 'string', - 'caption' => 'string', - 'filename' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'mediaUrl' => null, 'caption' => null, 'filename' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'mediaUrl' => 'mediaUrl', - 'caption' => 'caption', - 'filename' => 'filename' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'mediaUrl' => 'setMediaUrl', - 'caption' => 'setCaption', - 'filename' => 'setFilename' - ]; + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 2048)] + #[Assert\Length(min: 1)] - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'mediaUrl' => 'getMediaUrl', - 'caption' => 'getCaption', - 'filename' => 'getFilename' - ]; + protected string $mediaUrl, + #[Assert\Length(max: 3000)] + #[Assert\Length(min: 0)] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } + protected ?string $caption = null, + #[Assert\Length(max: 240)] + #[Assert\Length(min: 0)] - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; + protected ?string $filename = null, + ) { } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public function getModelName(): string { - return self::$getters; + return self::OPENAPI_MODEL_NAME; } - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$openAPIModelName; + return self::DISCRIMINATOR; } - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) + public function getMediaUrl(): string { - $this->container['mediaUrl'] = $data['mediaUrl'] ?? null; - $this->container['caption'] = $data['caption'] ?? null; - $this->container['filename'] = $data['filename'] ?? null; + return $this->mediaUrl; } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + public function setMediaUrl(string $mediaUrl): self { - $invalidProperties = []; - - if ($this->container['mediaUrl'] === null) { - $invalidProperties[] = "'mediaUrl' can't be null"; - } - if ((mb_strlen($this->container['mediaUrl']) > 2048)) { - $invalidProperties[] = "invalid value for 'mediaUrl', the character length must be smaller than or equal to 2048."; - } - - if ((mb_strlen($this->container['mediaUrl']) < 1)) { - $invalidProperties[] = "invalid value for 'mediaUrl', the character length must be bigger than or equal to 1."; - } - - if (!is_null($this->container['caption']) && (mb_strlen($this->container['caption']) > 3000)) { - $invalidProperties[] = "invalid value for 'caption', the character length must be smaller than or equal to 3000."; - } - - if (!is_null($this->container['caption']) && (mb_strlen($this->container['caption']) < 0)) { - $invalidProperties[] = "invalid value for 'caption', the character length must be bigger than or equal to 0."; - } - - if (!is_null($this->container['filename']) && (mb_strlen($this->container['filename']) > 240)) { - $invalidProperties[] = "invalid value for 'filename', the character length must be smaller than or equal to 240."; - } - - if (!is_null($this->container['filename']) && (mb_strlen($this->container['filename']) < 0)) { - $invalidProperties[] = "invalid value for 'filename', the character length must be bigger than or equal to 0."; - } - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets mediaUrl - * - * @return string - */ - public function getMediaUrl() - { - return $this->container['mediaUrl']; - } - - /** - * Sets mediaUrl - * - * @param string $mediaUrl URL of a document sent in a WhatsApp message. Must be a valid URL starting with `https://` or `http://`. Maximum document size is 100MB. - * - * @return self - */ - public function setMediaUrl($mediaUrl) - { - if ((mb_strlen($mediaUrl) > 2048)) { - throw new \InvalidArgumentException('invalid length for $mediaUrl when calling WhatsAppDocumentContent., must be smaller than or equal to 2048.'); - } - if ((mb_strlen($mediaUrl) < 1)) { - throw new \InvalidArgumentException('invalid length for $mediaUrl when calling WhatsAppDocumentContent., must be bigger than or equal to 1.'); - } - - $this->container['mediaUrl'] = $mediaUrl; - + $this->mediaUrl = $mediaUrl; return $this; } - /** - * Gets caption - * - * @return string|null - */ - public function getCaption() + public function getCaption(): string|null { - return $this->container['caption']; + return $this->caption; } - /** - * Sets caption - * - * @param string|null $caption Caption of the document. - * - * @return self - */ - public function setCaption($caption) + public function setCaption(?string $caption): self { - if (!is_null($caption) && (mb_strlen($caption) > 3000)) { - throw new \InvalidArgumentException('invalid length for $caption when calling WhatsAppDocumentContent., must be smaller than or equal to 3000.'); - } - if (!is_null($caption) && (mb_strlen($caption) < 0)) { - throw new \InvalidArgumentException('invalid length for $caption when calling WhatsAppDocumentContent., must be bigger than or equal to 0.'); - } - - $this->container['caption'] = $caption; - + $this->caption = $caption; return $this; } - /** - * Gets filename - * - * @return string|null - */ - public function getFilename() + public function getFilename(): string|null { - return $this->container['filename']; + return $this->filename; } - /** - * Sets filename - * - * @param string|null $filename File name of the document. - * - * @return self - */ - public function setFilename($filename) + public function setFilename(?string $filename): self { - if (!is_null($filename) && (mb_strlen($filename) > 240)) { - throw new \InvalidArgumentException('invalid length for $filename when calling WhatsAppDocumentContent., must be smaller than or equal to 240.'); - } - if (!is_null($filename) && (mb_strlen($filename) < 0)) { - throw new \InvalidArgumentException('invalid length for $filename when calling WhatsAppDocumentContent., must be bigger than or equal to 0.'); - } - - $this->container['filename'] = $filename; - + $this->filename = $filename; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppDocumentHeaderApiData.php b/Infobip/Model/WhatsAppDocumentHeaderApiData.php index 7b7014e..7f8c7ed 100644 --- a/Infobip/Model/WhatsAppDocumentHeaderApiData.php +++ b/Infobip/Model/WhatsAppDocumentHeaderApiData.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ class WhatsAppDocumentHeaderApiData extends WhatsAppHeaderApiData { public const DISCRIMINATOR = 'format'; + public const OPENAPI_MODEL_NAME = 'WhatsAppDocumentHeaderApiData'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppDocumentHeaderApiData'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'example' => 'string' - ]; + public const FORMAT = 'DOCUMENT'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'example' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes + parent::openAPITypes(); - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats + parent::openAPIFormats(); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'example' => 'example' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'example' => 'setExample' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'example' => 'getExample' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return parent::attributeMap() + self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array */ - public static function setters() - { - return parent::setters() + self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return parent::getters() + self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - + public function __construct( + protected ?string $example = null, + ) { + $modelDiscriminatorValue = 'DOCUMENT'; - - - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - parent::__construct($data); - - $this->container['example'] = $data['example'] ?? null; - - $this->container['format'] = 'DOCUMENT'; + parent::__construct( + format: $modelDiscriminatorValue, + ); } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = parent::listInvalidProperties(); - - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets example - * - * @return string|null - */ - public function getExample() + public function getExample(): string|null { - return $this->container['example']; + return $this->example; } - /** - * Sets example - * - * @param string|null $example An example of a template header document a user could create. Should be a valid URL that starts with `http` or `https`. Supported document type is `PDF`. Maximum document size is 16MB. Cannot contain placeholders. - * - * @return self - */ - public function setExample($example) + public function setExample(?string $example): self { - $this->container['example'] = $example; - + $this->example = $example; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppDocumentMessage.php b/Infobip/Model/WhatsAppDocumentMessage.php index b1c14fb..c269a8b 100644 --- a/Infobip/Model/WhatsAppDocumentMessage.php +++ b/Infobip/Model/WhatsAppDocumentMessage.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppDocumentMessage implements ModelInterface, ArrayAccess, \JsonSerializable +class WhatsAppDocumentMessage implements ModelInterface { - public const DISCRIMINATOR = null; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'WhatsAppDocumentMessage'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppDocumentMessage'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'from' => 'string', - 'to' => 'string', - 'messageId' => 'string', - 'content' => '\Infobip\Model\WhatsAppDocumentContent', - 'callbackData' => 'string', - 'notifyUrl' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'from' => null, 'to' => null, 'messageId' => null, @@ -79,472 +39,112 @@ class WhatsAppDocumentMessage implements ModelInterface, ArrayAccess, \JsonSeria ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array */ - public static function openAPITypes() - { - return self::$openAPITypes; - } + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 24)] + #[Assert\Length(min: 1)] - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } + protected string $from, + #[Assert\NotBlank] + #[Assert\Length(max: 24)] + #[Assert\Length(min: 1)] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'from' => 'from', - 'to' => 'to', - 'messageId' => 'messageId', - 'content' => 'content', - 'callbackData' => 'callbackData', - 'notifyUrl' => 'notifyUrl' - ]; + protected string $to, + #[Assert\Valid] + #[Assert\NotBlank] - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'from' => 'setFrom', - 'to' => 'setTo', - 'messageId' => 'setMessageId', - 'content' => 'setContent', - 'callbackData' => 'setCallbackData', - 'notifyUrl' => 'setNotifyUrl' - ]; + protected \Infobip\Model\WhatsAppDocumentContent $content, + #[Assert\Length(max: 100)] + #[Assert\Length(min: 0)] - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'from' => 'getFrom', - 'to' => 'getTo', - 'messageId' => 'getMessageId', - 'content' => 'getContent', - 'callbackData' => 'getCallbackData', - 'notifyUrl' => 'getNotifyUrl' - ]; + protected ?string $messageId = null, + #[Assert\Length(max: 4000)] + #[Assert\Length(min: 0)] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } + protected ?string $callbackData = null, + #[Assert\Length(max: 2048)] + #[Assert\Length(min: 0)] - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; + protected ?string $notifyUrl = null, + ) { } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public function getModelName(): string { - return self::$getters; + return self::OPENAPI_MODEL_NAME; } - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) + #[Ignore] + public static function getDiscriminator(): ?string { - $this->container['from'] = $data['from'] ?? null; - $this->container['to'] = $data['to'] ?? null; - $this->container['messageId'] = $data['messageId'] ?? null; - $this->container['content'] = $data['content'] ?? null; - $this->container['callbackData'] = $data['callbackData'] ?? null; - $this->container['notifyUrl'] = $data['notifyUrl'] ?? null; + return self::DISCRIMINATOR; } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + public function getFrom(): string { - $invalidProperties = []; - - if ($this->container['from'] === null) { - $invalidProperties[] = "'from' can't be null"; - } - if ((mb_strlen($this->container['from']) > 24)) { - $invalidProperties[] = "invalid value for 'from', the character length must be smaller than or equal to 24."; - } - - if ((mb_strlen($this->container['from']) < 1)) { - $invalidProperties[] = "invalid value for 'from', the character length must be bigger than or equal to 1."; - } - - if ($this->container['to'] === null) { - $invalidProperties[] = "'to' can't be null"; - } - if ((mb_strlen($this->container['to']) > 24)) { - $invalidProperties[] = "invalid value for 'to', the character length must be smaller than or equal to 24."; - } - - if ((mb_strlen($this->container['to']) < 1)) { - $invalidProperties[] = "invalid value for 'to', the character length must be bigger than or equal to 1."; - } - - if (!is_null($this->container['messageId']) && (mb_strlen($this->container['messageId']) > 50)) { - $invalidProperties[] = "invalid value for 'messageId', the character length must be smaller than or equal to 50."; - } - - if (!is_null($this->container['messageId']) && (mb_strlen($this->container['messageId']) < 0)) { - $invalidProperties[] = "invalid value for 'messageId', the character length must be bigger than or equal to 0."; - } - - if ($this->container['content'] === null) { - $invalidProperties[] = "'content' can't be null"; - } - if (!is_null($this->container['callbackData']) && (mb_strlen($this->container['callbackData']) > 4000)) { - $invalidProperties[] = "invalid value for 'callbackData', the character length must be smaller than or equal to 4000."; - } - - if (!is_null($this->container['callbackData']) && (mb_strlen($this->container['callbackData']) < 0)) { - $invalidProperties[] = "invalid value for 'callbackData', the character length must be bigger than or equal to 0."; - } - - if (!is_null($this->container['notifyUrl']) && (mb_strlen($this->container['notifyUrl']) > 2048)) { - $invalidProperties[] = "invalid value for 'notifyUrl', the character length must be smaller than or equal to 2048."; - } - - if (!is_null($this->container['notifyUrl']) && (mb_strlen($this->container['notifyUrl']) < 0)) { - $invalidProperties[] = "invalid value for 'notifyUrl', the character length must be bigger than or equal to 0."; - } - - return $invalidProperties; + return $this->from; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + public function setFrom(string $from): self { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets from - * - * @return string - */ - public function getFrom() - { - return $this->container['from']; - } - - /** - * Sets from - * - * @param string $from Registered WhatsApp sender number. Must be in international format and comply with [WhatsApp's requirements](https://www.infobip.com/docs/whatsapp/get-started#phone-number-what-you-need-to-know). - * - * @return self - */ - public function setFrom($from) - { - if ((mb_strlen($from) > 24)) { - throw new \InvalidArgumentException('invalid length for $from when calling WhatsAppDocumentMessage., must be smaller than or equal to 24.'); - } - if ((mb_strlen($from) < 1)) { - throw new \InvalidArgumentException('invalid length for $from when calling WhatsAppDocumentMessage., must be bigger than or equal to 1.'); - } - - $this->container['from'] = $from; - + $this->from = $from; return $this; } - /** - * Gets to - * - * @return string - */ - public function getTo() + public function getTo(): string { - return $this->container['to']; + return $this->to; } - /** - * Sets to - * - * @param string $to Message recipient number. Must be in international format. - * - * @return self - */ - public function setTo($to) + public function setTo(string $to): self { - if ((mb_strlen($to) > 24)) { - throw new \InvalidArgumentException('invalid length for $to when calling WhatsAppDocumentMessage., must be smaller than or equal to 24.'); - } - if ((mb_strlen($to) < 1)) { - throw new \InvalidArgumentException('invalid length for $to when calling WhatsAppDocumentMessage., must be bigger than or equal to 1.'); - } - - $this->container['to'] = $to; - + $this->to = $to; return $this; } - /** - * Gets messageId - * - * @return string|null - */ - public function getMessageId() + public function getMessageId(): string|null { - return $this->container['messageId']; + return $this->messageId; } - /** - * Sets messageId - * - * @param string|null $messageId The ID that uniquely identifies the message sent. - * - * @return self - */ - public function setMessageId($messageId) + public function setMessageId(?string $messageId): self { - if (!is_null($messageId) && (mb_strlen($messageId) > 50)) { - throw new \InvalidArgumentException('invalid length for $messageId when calling WhatsAppDocumentMessage., must be smaller than or equal to 50.'); - } - if (!is_null($messageId) && (mb_strlen($messageId) < 0)) { - throw new \InvalidArgumentException('invalid length for $messageId when calling WhatsAppDocumentMessage., must be bigger than or equal to 0.'); - } - - $this->container['messageId'] = $messageId; - + $this->messageId = $messageId; return $this; } - /** - * Gets content - * - * @return \Infobip\Model\WhatsAppDocumentContent - */ - public function getContent() + public function getContent(): \Infobip\Model\WhatsAppDocumentContent { - return $this->container['content']; + return $this->content; } - /** - * Sets content - * - * @param \Infobip\Model\WhatsAppDocumentContent $content content - * - * @return self - */ - public function setContent($content) + public function setContent(\Infobip\Model\WhatsAppDocumentContent $content): self { - $this->container['content'] = $content; - + $this->content = $content; return $this; } - /** - * Gets callbackData - * - * @return string|null - */ - public function getCallbackData() + public function getCallbackData(): string|null { - return $this->container['callbackData']; + return $this->callbackData; } - /** - * Sets callbackData - * - * @param string|null $callbackData Custom client data that will be included in a [Delivery Report](#channels/whatsapp/receive-whatsapp-delivery-reports). - * - * @return self - */ - public function setCallbackData($callbackData) + public function setCallbackData(?string $callbackData): self { - if (!is_null($callbackData) && (mb_strlen($callbackData) > 4000)) { - throw new \InvalidArgumentException('invalid length for $callbackData when calling WhatsAppDocumentMessage., must be smaller than or equal to 4000.'); - } - if (!is_null($callbackData) && (mb_strlen($callbackData) < 0)) { - throw new \InvalidArgumentException('invalid length for $callbackData when calling WhatsAppDocumentMessage., must be bigger than or equal to 0.'); - } - - $this->container['callbackData'] = $callbackData; - + $this->callbackData = $callbackData; return $this; } - /** - * Gets notifyUrl - * - * @return string|null - */ - public function getNotifyUrl() + public function getNotifyUrl(): string|null { - return $this->container['notifyUrl']; + return $this->notifyUrl; } - /** - * Sets notifyUrl - * - * @param string|null $notifyUrl The URL on your callback server to which delivery and seen reports will be sent. [Delivery report format](#channels/whatsapp/receive-whatsapp-delivery-reports), [Seen report format](#channels/whatsapp/receive-whatsapp-seen-reports). - * - * @return self - */ - public function setNotifyUrl($notifyUrl) + public function setNotifyUrl(?string $notifyUrl): self { - if (!is_null($notifyUrl) && (mb_strlen($notifyUrl) > 2048)) { - throw new \InvalidArgumentException('invalid length for $notifyUrl when calling WhatsAppDocumentMessage., must be smaller than or equal to 2048.'); - } - if (!is_null($notifyUrl) && (mb_strlen($notifyUrl) < 0)) { - throw new \InvalidArgumentException('invalid length for $notifyUrl when calling WhatsAppDocumentMessage., must be bigger than or equal to 0.'); - } - - $this->container['notifyUrl'] = $notifyUrl; - + $this->notifyUrl = $notifyUrl; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppEmailContent.php b/Infobip/Model/WhatsAppEmailContent.php index fbfc96e..511d879 100644 --- a/Infobip/Model/WhatsAppEmailContent.php +++ b/Infobip/Model/WhatsAppEmailContent.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppEmailContent implements ModelInterface, ArrayAccess, \JsonSerializable +class WhatsAppEmailContent implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppEmailContent'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'email' => 'string', - 'type' => '\Infobip\Model\WhatsAppEmailType' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'WhatsAppEmailContent'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'email' => null, 'type' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'email' => 'email', - 'type' => 'type' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'email' => 'setEmail', - 'type' => 'setType' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] */ - protected static $getters = [ - 'email' => 'getEmail', - 'type' => 'getType' - ]; + public function __construct( + protected ?string $email = null, + #[Assert\Choice(['HOME','WORK',])] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; + protected ?string $type = null, + ) { } - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() + #[Ignore] + public function getModelName(): string { - return self::$setters; + return self::OPENAPI_MODEL_NAME; } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$getters; + return self::DISCRIMINATOR; } - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() + public function getEmail(): string|null { - return self::$openAPIModelName; + return $this->email; } - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['email'] = $data['email'] ?? null; - $this->container['type'] = $data['type'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + public function setEmail(?string $email): self { - $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() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets email - * - * @return string|null - */ - public function getEmail() - { - return $this->container['email']; - } - - /** - * Sets email - * - * @param string|null $email Contact's email. - * - * @return self - */ - public function setEmail($email) - { - $this->container['email'] = $email; - + $this->email = $email; return $this; } - /** - * Gets type - * - * @return \Infobip\Model\WhatsAppEmailType|null - */ - public function getType() + public function getType(): mixed { - return $this->container['type']; + return $this->type; } - /** - * Sets type - * - * @param \Infobip\Model\WhatsAppEmailType|null $type type - * - * @return self - */ - public function setType($type) + public function setType($type): self { - $this->container['type'] = $type; - + $this->type = $type; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppEmailType.php b/Infobip/Model/WhatsAppEmailType.php index f3207ee..3f05c10 100644 --- a/Infobip/Model/WhatsAppEmailType.php +++ b/Infobip/Model/WhatsAppEmailType.php @@ -1,14 +1,8 @@ value = $value; + } + + public static function HOME(): WhatsAppEmailType + { + return new self('HOME'); + } + + public static function WORK(): WhatsAppEmailType + { + return new self('WORK'); + } + + public function __toString(): string { - return [ - self::HOME, - self::WORK, - ]; + return $this->value; } } diff --git a/Infobip/Model/WhatsAppFailover.php b/Infobip/Model/WhatsAppFailover.php index ea8458e..57c67c0 100644 --- a/Infobip/Model/WhatsAppFailover.php +++ b/Infobip/Model/WhatsAppFailover.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppFailover implements ModelInterface, ArrayAccess, \JsonSerializable +class WhatsAppFailover implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppFailover'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'from' => 'string', - 'text' => 'string' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'WhatsAppFailover'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'from' => null, 'text' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'from' => 'from', - 'text' => 'text' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] */ - protected static $setters = [ - 'from' => 'setFrom', - 'text' => 'setText' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'from' => 'getFrom', - 'text' => 'getText' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 24)] + #[Assert\Length(min: 1)] - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; + protected string $from, + #[Assert\NotBlank] + #[Assert\Length(max: 4096)] + #[Assert\Length(min: 1)] - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['from'] = $data['from'] ?? null; - $this->container['text'] = $data['text'] ?? null; + protected string $text, + ) { } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - if ($this->container['from'] === null) { - $invalidProperties[] = "'from' can't be null"; - } - if ((mb_strlen($this->container['from']) > 24)) { - $invalidProperties[] = "invalid value for 'from', the character length must be smaller than or equal to 24."; - } - - if ((mb_strlen($this->container['from']) < 1)) { - $invalidProperties[] = "invalid value for 'from', the character length must be bigger than or equal to 1."; - } - - if ($this->container['text'] === null) { - $invalidProperties[] = "'text' can't be null"; - } - if ((mb_strlen($this->container['text']) > 4096)) { - $invalidProperties[] = "invalid value for 'text', the character length must be smaller than or equal to 4096."; - } - - if ((mb_strlen($this->container['text']) < 1)) { - $invalidProperties[] = "invalid value for 'text', the character length must be bigger than or equal to 1."; - } - - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets from - * - * @return string - */ - public function getFrom() + public function getFrom(): string { - return $this->container['from']; + return $this->from; } - /** - * Sets from - * - * @param string $from SMS sender number. Must be in international format. - * - * @return self - */ - public function setFrom($from) + public function setFrom(string $from): self { - if ((mb_strlen($from) > 24)) { - throw new \InvalidArgumentException('invalid length for $from when calling WhatsAppFailover., must be smaller than or equal to 24.'); - } - if ((mb_strlen($from) < 1)) { - throw new \InvalidArgumentException('invalid length for $from when calling WhatsAppFailover., must be bigger than or equal to 1.'); - } - - $this->container['from'] = $from; - + $this->from = $from; return $this; } - /** - * Gets text - * - * @return string - */ - public function getText() + public function getText(): string { - return $this->container['text']; + return $this->text; } - /** - * Sets text - * - * @param string $text Content of the SMS that will be sent. - * - * @return self - */ - public function setText($text) + public function setText(string $text): self { - if ((mb_strlen($text) > 4096)) { - throw new \InvalidArgumentException('invalid length for $text when calling WhatsAppFailover., must be smaller than or equal to 4096.'); - } - if ((mb_strlen($text) < 1)) { - throw new \InvalidArgumentException('invalid length for $text when calling WhatsAppFailover., must be bigger than or equal to 1.'); - } - - $this->container['text'] = $text; - + $this->text = $text; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppFooterApiData.php b/Infobip/Model/WhatsAppFooterApiData.php index 17376b7..ac40ec5 100644 --- a/Infobip/Model/WhatsAppFooterApiData.php +++ b/Infobip/Model/WhatsAppFooterApiData.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppFooterApiData implements ModelInterface, ArrayAccess, \JsonSerializable +class WhatsAppFooterApiData implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppFooterApiData'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'text' => 'string' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'WhatsAppFooterApiData'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'text' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array */ - public static function openAPITypes() - { - return self::$openAPITypes; - } + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 60)] + #[Assert\Length(min: 0)] - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; + protected string $text, + ) { } - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'text' => 'text' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'text' => 'setText' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'text' => 'getText' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() + #[Ignore] + public function getModelName(): string { - return self::$setters; + return self::OPENAPI_MODEL_NAME; } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$getters; + return self::DISCRIMINATOR; } - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() + public function getText(): string { - return self::$openAPIModelName; + return $this->text; } - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) + public function setText(string $text): self { - $this->container['text'] = $data['text'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - if ($this->container['text'] === null) { - $invalidProperties[] = "'text' can't be null"; - } - if ((mb_strlen($this->container['text']) > 60)) { - $invalidProperties[] = "invalid value for 'text', the character length must be smaller than or equal to 60."; - } - - if ((mb_strlen($this->container['text']) < 0)) { - $invalidProperties[] = "invalid value for 'text', the character length must be bigger than or equal to 0."; - } - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets text - * - * @return string - */ - public function getText() - { - return $this->container['text']; - } - - /** - * Sets text - * - * @param string $text Plain text, up to 60 characters. - * - * @return self - */ - public function setText($text) - { - if ((mb_strlen($text) > 60)) { - throw new \InvalidArgumentException('invalid length for $text when calling WhatsAppFooterApiData., must be smaller than or equal to 60.'); - } - if ((mb_strlen($text) < 0)) { - throw new \InvalidArgumentException('invalid length for $text when calling WhatsAppFooterApiData., must be bigger than or equal to 0.'); - } - - $this->container['text'] = $text; - + $this->text = $text; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppHeaderApiData.php b/Infobip/Model/WhatsAppHeaderApiData.php index 2967711..c21f7dc 100644 --- a/Infobip/Model/WhatsAppHeaderApiData.php +++ b/Infobip/Model/WhatsAppHeaderApiData.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppHeaderApiData implements ModelInterface, ArrayAccess, \JsonSerializable +use Symfony\Component\Validator\Constraints as Assert; +use Symfony\Component\Serializer\Annotation as Serializer; +use Symfony\Component\Serializer\Annotation\Ignore; +use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer; +use Symfony\Component\Serializer\Annotation\DiscriminatorMap; + +#[DiscriminatorMap(typeProperty: "format", mapping: [ + "DOCUMENT" => "\Infobip\Model\WhatsAppDocumentHeaderApiData", + "IMAGE" => "\Infobip\Model\WhatsAppImageHeaderApiData", + "LOCATION" => "\Infobip\Model\WhatsAppLocationHeaderApiData", + "TEXT" => "\Infobip\Model\WhatsAppTextHeaderApiData", + "VIDEO" => "\Infobip\Model\WhatsAppVideoHeaderApiData", + "WhatsAppDocumentHeaderApiData" => "\Infobip\Model\WhatsAppDocumentHeaderApiData", + "WhatsAppImageHeaderApiData" => "\Infobip\Model\WhatsAppImageHeaderApiData", + "WhatsAppLocationHeaderApiData" => "\Infobip\Model\WhatsAppLocationHeaderApiData", + "WhatsAppTextHeaderApiData" => "\Infobip\Model\WhatsAppTextHeaderApiData", + "WhatsAppVideoHeaderApiData" => "\Infobip\Model\WhatsAppVideoHeaderApiData", +])] +class WhatsAppHeaderApiData implements ModelInterface { public const DISCRIMINATOR = 'format'; + public const OPENAPI_MODEL_NAME = 'WhatsAppHeaderApiData'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppHeaderApiData'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'format' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'format' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array */ - public static function openAPITypes() - { - return self::$openAPITypes; - } + public function __construct( + #[Assert\Choice(['TEXT','IMAGE','VIDEO','DOCUMENT','LOCATION',])] - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; + protected ?string $format = null, + ) { } - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'format' => 'format' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'format' => 'setFormat' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'format' => 'getFormat' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() + #[Ignore] + public function getModelName(): string { - return self::$attributeMap; + return self::OPENAPI_MODEL_NAME; } - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$setters; + return self::DISCRIMINATOR; } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() + public function getFormat(): mixed { - return self::$openAPIModelName; + return $this->format; } - public const FORMAT_TEXT = 'TEXT'; - public const FORMAT_IMAGE = 'IMAGE'; - public const FORMAT_VIDEO = 'VIDEO'; - public const FORMAT_DOCUMENT = 'DOCUMENT'; - public const FORMAT_LOCATION = 'LOCATION'; - - - - /** - * Gets allowable values of the enum - * - * @return string[] - */ - public function getFormatAllowableValues() - { - return [ - self::FORMAT_TEXT, - self::FORMAT_IMAGE, - self::FORMAT_VIDEO, - self::FORMAT_DOCUMENT, - self::FORMAT_LOCATION, - ]; - } - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) + public function setFormat($format): self { - $this->container['format'] = $data['format'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - $allowedValues = $this->getFormatAllowableValues(); - if (!is_null($this->container['format']) && !in_array($this->container['format'], $allowedValues, true)) { - $invalidProperties[] = sprintf( - "invalid value '%s' for 'format', must be one of '%s'", - $this->container['format'], - implode("', '", $allowedValues) - ); - } - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets format - * - * @return string|null - */ - public function getFormat() - { - return $this->container['format']; - } - - /** - * Sets format - * - * @param string|null $format format - * - * @return self - */ - public function setFormat($format) - { - $allowedValues = $this->getFormatAllowableValues(); - if (!is_null($format) && !in_array($format, $allowedValues, true)) { - throw new \InvalidArgumentException( - sprintf( - "Invalid value '%s' for 'format', must be one of '%s'", - $format, - implode("', '", $allowedValues) - ) - ); - } - $this->container['format'] = $format; - + $this->format = $format; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppIdentityConfirmation.php b/Infobip/Model/WhatsAppIdentityConfirmation.php index a548c72..cd1a722 100644 --- a/Infobip/Model/WhatsAppIdentityConfirmation.php +++ b/Infobip/Model/WhatsAppIdentityConfirmation.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppIdentityConfirmation implements ModelInterface, ArrayAccess, \JsonSerializable +class WhatsAppIdentityConfirmation implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppIdentityConfirmation'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'hash' => 'string' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'WhatsAppIdentityConfirmation'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'hash' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'hash' => 'hash' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'hash' => 'setHash' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'hash' => 'getHash' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] */ - protected $container = []; + public function __construct( + #[Assert\NotBlank] - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['hash'] = $data['hash'] ?? null; + protected string $hash, + ) { } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - if ($this->container['hash'] === null) { - $invalidProperties[] = "'hash' can't be null"; - } - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets hash - * - * @return string - */ - public function getHash() + public function getHash(): string { - return $this->container['hash']; + return $this->hash; } - /** - * Sets hash - * - * @param string $hash Identity hash - * - * @return self - */ - public function setHash($hash) + public function setHash(string $hash): self { - $this->container['hash'] = $hash; - + $this->hash = $hash; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppIdentityInfo.php b/Infobip/Model/WhatsAppIdentityInfo.php index b2bd9c0..3109a2c 100644 --- a/Infobip/Model/WhatsAppIdentityInfo.php +++ b/Infobip/Model/WhatsAppIdentityInfo.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppIdentityInfo implements ModelInterface, ArrayAccess, \JsonSerializable +class WhatsAppIdentityInfo implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppIdentityInfo'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'acknowledged' => 'bool', - 'hash' => 'string', - 'createdAt' => '\DateTime' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'WhatsAppIdentityInfo'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'acknowledged' => null, 'hash' => null, 'createdAt' => 'date-time' ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } + public function __construct( + #[Assert\NotBlank] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'acknowledged' => 'acknowledged', - 'hash' => 'hash', - 'createdAt' => 'createdAt' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'acknowledged' => 'setAcknowledged', - 'hash' => 'setHash', - 'createdAt' => 'setCreatedAt' - ]; + protected bool $acknowledged, + #[Assert\NotBlank] - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'acknowledged' => 'getAcknowledged', - 'hash' => 'getHash', - 'createdAt' => 'getCreatedAt' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; + protected string $hash, + #[Assert\NotBlank] + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['acknowledged'] = $data['acknowledged'] ?? null; - $this->container['hash'] = $data['hash'] ?? null; - $this->container['createdAt'] = $data['createdAt'] ?? null; + protected \DateTime $createdAt, + ) { } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - if ($this->container['acknowledged'] === null) { - $invalidProperties[] = "'acknowledged' can't be null"; - } - if ($this->container['hash'] === null) { - $invalidProperties[] = "'hash' can't be null"; - } - if ($this->container['createdAt'] === null) { - $invalidProperties[] = "'createdAt' can't be null"; - } - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets acknowledged - * - * @return bool - */ - public function getAcknowledged() + public function getAcknowledged(): bool { - return $this->container['acknowledged']; + return $this->acknowledged; } - /** - * Sets acknowledged - * - * @param bool $acknowledged Identity acknowledge status - * - * @return self - */ - public function setAcknowledged($acknowledged) + public function setAcknowledged(bool $acknowledged): self { - $this->container['acknowledged'] = $acknowledged; - + $this->acknowledged = $acknowledged; return $this; } - /** - * Gets hash - * - * @return string - */ - public function getHash() + public function getHash(): string { - return $this->container['hash']; + return $this->hash; } - /** - * Sets hash - * - * @param string $hash Identity hash - * - * @return self - */ - public function setHash($hash) + public function setHash(string $hash): self { - $this->container['hash'] = $hash; - + $this->hash = $hash; return $this; } - /** - * Gets createdAt - * - * @return \DateTime - */ - public function getCreatedAt() + public function getCreatedAt(): \DateTime { - return $this->container['createdAt']; + return $this->createdAt; } - /** - * Sets createdAt - * - * @param \DateTime $createdAt Identity event creation date - * - * @return self - */ - public function setCreatedAt($createdAt) + public function setCreatedAt(\DateTime $createdAt): self { - $this->container['createdAt'] = $createdAt; - + $this->createdAt = $createdAt; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppImageContent.php b/Infobip/Model/WhatsAppImageContent.php index c87ac20..2456e79 100644 --- a/Infobip/Model/WhatsAppImageContent.php +++ b/Infobip/Model/WhatsAppImageContent.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppImageContent implements ModelInterface, ArrayAccess, \JsonSerializable +class WhatsAppImageContent implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppImageContent'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'mediaUrl' => 'string', - 'caption' => 'string' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'WhatsAppImageContent'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'mediaUrl' => null, 'caption' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'mediaUrl' => 'mediaUrl', - 'caption' => 'caption' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] */ - protected static $setters = [ - 'mediaUrl' => 'setMediaUrl', - 'caption' => 'setCaption' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'mediaUrl' => 'getMediaUrl', - 'caption' => 'getCaption' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 2048)] + #[Assert\Length(min: 1)] - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; + protected string $mediaUrl, + #[Assert\Length(max: 3000)] + #[Assert\Length(min: 0)] - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['mediaUrl'] = $data['mediaUrl'] ?? null; - $this->container['caption'] = $data['caption'] ?? null; + protected ?string $caption = null, + ) { } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - if ($this->container['mediaUrl'] === null) { - $invalidProperties[] = "'mediaUrl' can't be null"; - } - if ((mb_strlen($this->container['mediaUrl']) > 2048)) { - $invalidProperties[] = "invalid value for 'mediaUrl', the character length must be smaller than or equal to 2048."; - } - - if ((mb_strlen($this->container['mediaUrl']) < 1)) { - $invalidProperties[] = "invalid value for 'mediaUrl', the character length must be bigger than or equal to 1."; - } - - if (!is_null($this->container['caption']) && (mb_strlen($this->container['caption']) > 3000)) { - $invalidProperties[] = "invalid value for 'caption', the character length must be smaller than or equal to 3000."; - } - - if (!is_null($this->container['caption']) && (mb_strlen($this->container['caption']) < 0)) { - $invalidProperties[] = "invalid value for 'caption', the character length must be bigger than or equal to 0."; - } - - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets mediaUrl - * - * @return string - */ - public function getMediaUrl() + public function getMediaUrl(): string { - return $this->container['mediaUrl']; + return $this->mediaUrl; } - /** - * Sets mediaUrl - * - * @param string $mediaUrl URL of an image sent in a WhatsApp message. Must be a valid URL starting with `https://` or `http://`. Supported image types are `JPG`, `JPEG`, `PNG`. Maximum image size is 5MB. - * - * @return self - */ - public function setMediaUrl($mediaUrl) + public function setMediaUrl(string $mediaUrl): self { - if ((mb_strlen($mediaUrl) > 2048)) { - throw new \InvalidArgumentException('invalid length for $mediaUrl when calling WhatsAppImageContent., must be smaller than or equal to 2048.'); - } - if ((mb_strlen($mediaUrl) < 1)) { - throw new \InvalidArgumentException('invalid length for $mediaUrl when calling WhatsAppImageContent., must be bigger than or equal to 1.'); - } - - $this->container['mediaUrl'] = $mediaUrl; - + $this->mediaUrl = $mediaUrl; return $this; } - /** - * Gets caption - * - * @return string|null - */ - public function getCaption() + public function getCaption(): string|null { - return $this->container['caption']; + return $this->caption; } - /** - * Sets caption - * - * @param string|null $caption Caption of the image. - * - * @return self - */ - public function setCaption($caption) + public function setCaption(?string $caption): self { - if (!is_null($caption) && (mb_strlen($caption) > 3000)) { - throw new \InvalidArgumentException('invalid length for $caption when calling WhatsAppImageContent., must be smaller than or equal to 3000.'); - } - if (!is_null($caption) && (mb_strlen($caption) < 0)) { - throw new \InvalidArgumentException('invalid length for $caption when calling WhatsAppImageContent., must be bigger than or equal to 0.'); - } - - $this->container['caption'] = $caption; - + $this->caption = $caption; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppImageHeaderApiData.php b/Infobip/Model/WhatsAppImageHeaderApiData.php index 9c72d52..2ae28e9 100644 --- a/Infobip/Model/WhatsAppImageHeaderApiData.php +++ b/Infobip/Model/WhatsAppImageHeaderApiData.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ class WhatsAppImageHeaderApiData extends WhatsAppHeaderApiData { public const DISCRIMINATOR = 'format'; + public const OPENAPI_MODEL_NAME = 'WhatsAppImageHeaderApiData'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppImageHeaderApiData'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'example' => 'string' - ]; + public const FORMAT = 'IMAGE'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'example' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes + parent::openAPITypes(); - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats + parent::openAPIFormats(); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'example' => 'example' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'example' => 'setExample' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'example' => 'getExample' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return parent::attributeMap() + self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array */ - public static function setters() - { - return parent::setters() + self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return parent::getters() + self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - + public function __construct( + protected ?string $example = null, + ) { + $modelDiscriminatorValue = 'IMAGE'; - - - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - parent::__construct($data); - - $this->container['example'] = $data['example'] ?? null; - - $this->container['format'] = 'IMAGE'; + parent::__construct( + format: $modelDiscriminatorValue, + ); } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = parent::listInvalidProperties(); - - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets example - * - * @return string|null - */ - public function getExample() + public function getExample(): string|null { - return $this->container['example']; + return $this->example; } - /** - * Sets example - * - * @param string|null $example An example of a template header image a user could create. Should be a valid URL that starts with `http` or `https`. Supported image types are `JPG`, `JPEG`, `PNG`. Maximum image size is 16MB. Cannot contain placeholders. - * - * @return self - */ - public function setExample($example) + public function setExample(?string $example): self { - $this->container['example'] = $example; - + $this->example = $example; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppImageMessage.php b/Infobip/Model/WhatsAppImageMessage.php index 9b525f5..657bf5d 100644 --- a/Infobip/Model/WhatsAppImageMessage.php +++ b/Infobip/Model/WhatsAppImageMessage.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppImageMessage implements ModelInterface, ArrayAccess, \JsonSerializable +class WhatsAppImageMessage implements ModelInterface { - public const DISCRIMINATOR = null; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'WhatsAppImageMessage'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppImageMessage'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'from' => 'string', - 'to' => 'string', - 'messageId' => 'string', - 'content' => '\Infobip\Model\WhatsAppImageContent', - 'callbackData' => 'string', - 'notifyUrl' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'from' => null, 'to' => null, 'messageId' => null, @@ -79,472 +39,112 @@ class WhatsAppImageMessage implements ModelInterface, ArrayAccess, \JsonSerializ ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array */ - public static function openAPITypes() - { - return self::$openAPITypes; - } + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 24)] + #[Assert\Length(min: 1)] - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } + protected string $from, + #[Assert\NotBlank] + #[Assert\Length(max: 24)] + #[Assert\Length(min: 1)] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'from' => 'from', - 'to' => 'to', - 'messageId' => 'messageId', - 'content' => 'content', - 'callbackData' => 'callbackData', - 'notifyUrl' => 'notifyUrl' - ]; + protected string $to, + #[Assert\Valid] + #[Assert\NotBlank] - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'from' => 'setFrom', - 'to' => 'setTo', - 'messageId' => 'setMessageId', - 'content' => 'setContent', - 'callbackData' => 'setCallbackData', - 'notifyUrl' => 'setNotifyUrl' - ]; + protected \Infobip\Model\WhatsAppImageContent $content, + #[Assert\Length(max: 100)] + #[Assert\Length(min: 0)] - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'from' => 'getFrom', - 'to' => 'getTo', - 'messageId' => 'getMessageId', - 'content' => 'getContent', - 'callbackData' => 'getCallbackData', - 'notifyUrl' => 'getNotifyUrl' - ]; + protected ?string $messageId = null, + #[Assert\Length(max: 4000)] + #[Assert\Length(min: 0)] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } + protected ?string $callbackData = null, + #[Assert\Length(max: 2048)] + #[Assert\Length(min: 0)] - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; + protected ?string $notifyUrl = null, + ) { } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public function getModelName(): string { - return self::$getters; + return self::OPENAPI_MODEL_NAME; } - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) + #[Ignore] + public static function getDiscriminator(): ?string { - $this->container['from'] = $data['from'] ?? null; - $this->container['to'] = $data['to'] ?? null; - $this->container['messageId'] = $data['messageId'] ?? null; - $this->container['content'] = $data['content'] ?? null; - $this->container['callbackData'] = $data['callbackData'] ?? null; - $this->container['notifyUrl'] = $data['notifyUrl'] ?? null; + return self::DISCRIMINATOR; } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + public function getFrom(): string { - $invalidProperties = []; - - if ($this->container['from'] === null) { - $invalidProperties[] = "'from' can't be null"; - } - if ((mb_strlen($this->container['from']) > 24)) { - $invalidProperties[] = "invalid value for 'from', the character length must be smaller than or equal to 24."; - } - - if ((mb_strlen($this->container['from']) < 1)) { - $invalidProperties[] = "invalid value for 'from', the character length must be bigger than or equal to 1."; - } - - if ($this->container['to'] === null) { - $invalidProperties[] = "'to' can't be null"; - } - if ((mb_strlen($this->container['to']) > 24)) { - $invalidProperties[] = "invalid value for 'to', the character length must be smaller than or equal to 24."; - } - - if ((mb_strlen($this->container['to']) < 1)) { - $invalidProperties[] = "invalid value for 'to', the character length must be bigger than or equal to 1."; - } - - if (!is_null($this->container['messageId']) && (mb_strlen($this->container['messageId']) > 50)) { - $invalidProperties[] = "invalid value for 'messageId', the character length must be smaller than or equal to 50."; - } - - if (!is_null($this->container['messageId']) && (mb_strlen($this->container['messageId']) < 0)) { - $invalidProperties[] = "invalid value for 'messageId', the character length must be bigger than or equal to 0."; - } - - if ($this->container['content'] === null) { - $invalidProperties[] = "'content' can't be null"; - } - if (!is_null($this->container['callbackData']) && (mb_strlen($this->container['callbackData']) > 4000)) { - $invalidProperties[] = "invalid value for 'callbackData', the character length must be smaller than or equal to 4000."; - } - - if (!is_null($this->container['callbackData']) && (mb_strlen($this->container['callbackData']) < 0)) { - $invalidProperties[] = "invalid value for 'callbackData', the character length must be bigger than or equal to 0."; - } - - if (!is_null($this->container['notifyUrl']) && (mb_strlen($this->container['notifyUrl']) > 2048)) { - $invalidProperties[] = "invalid value for 'notifyUrl', the character length must be smaller than or equal to 2048."; - } - - if (!is_null($this->container['notifyUrl']) && (mb_strlen($this->container['notifyUrl']) < 0)) { - $invalidProperties[] = "invalid value for 'notifyUrl', the character length must be bigger than or equal to 0."; - } - - return $invalidProperties; + return $this->from; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + public function setFrom(string $from): self { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets from - * - * @return string - */ - public function getFrom() - { - return $this->container['from']; - } - - /** - * Sets from - * - * @param string $from Registered WhatsApp sender number. Must be in international format and comply with [WhatsApp's requirements](https://www.infobip.com/docs/whatsapp/get-started#phone-number-what-you-need-to-know). - * - * @return self - */ - public function setFrom($from) - { - if ((mb_strlen($from) > 24)) { - throw new \InvalidArgumentException('invalid length for $from when calling WhatsAppImageMessage., must be smaller than or equal to 24.'); - } - if ((mb_strlen($from) < 1)) { - throw new \InvalidArgumentException('invalid length for $from when calling WhatsAppImageMessage., must be bigger than or equal to 1.'); - } - - $this->container['from'] = $from; - + $this->from = $from; return $this; } - /** - * Gets to - * - * @return string - */ - public function getTo() + public function getTo(): string { - return $this->container['to']; + return $this->to; } - /** - * Sets to - * - * @param string $to Message recipient number. Must be in international format. - * - * @return self - */ - public function setTo($to) + public function setTo(string $to): self { - if ((mb_strlen($to) > 24)) { - throw new \InvalidArgumentException('invalid length for $to when calling WhatsAppImageMessage., must be smaller than or equal to 24.'); - } - if ((mb_strlen($to) < 1)) { - throw new \InvalidArgumentException('invalid length for $to when calling WhatsAppImageMessage., must be bigger than or equal to 1.'); - } - - $this->container['to'] = $to; - + $this->to = $to; return $this; } - /** - * Gets messageId - * - * @return string|null - */ - public function getMessageId() + public function getMessageId(): string|null { - return $this->container['messageId']; + return $this->messageId; } - /** - * Sets messageId - * - * @param string|null $messageId The ID that uniquely identifies the message sent. - * - * @return self - */ - public function setMessageId($messageId) + public function setMessageId(?string $messageId): self { - if (!is_null($messageId) && (mb_strlen($messageId) > 50)) { - throw new \InvalidArgumentException('invalid length for $messageId when calling WhatsAppImageMessage., must be smaller than or equal to 50.'); - } - if (!is_null($messageId) && (mb_strlen($messageId) < 0)) { - throw new \InvalidArgumentException('invalid length for $messageId when calling WhatsAppImageMessage., must be bigger than or equal to 0.'); - } - - $this->container['messageId'] = $messageId; - + $this->messageId = $messageId; return $this; } - /** - * Gets content - * - * @return \Infobip\Model\WhatsAppImageContent - */ - public function getContent() + public function getContent(): \Infobip\Model\WhatsAppImageContent { - return $this->container['content']; + return $this->content; } - /** - * Sets content - * - * @param \Infobip\Model\WhatsAppImageContent $content content - * - * @return self - */ - public function setContent($content) + public function setContent(\Infobip\Model\WhatsAppImageContent $content): self { - $this->container['content'] = $content; - + $this->content = $content; return $this; } - /** - * Gets callbackData - * - * @return string|null - */ - public function getCallbackData() + public function getCallbackData(): string|null { - return $this->container['callbackData']; + return $this->callbackData; } - /** - * Sets callbackData - * - * @param string|null $callbackData Custom client data that will be included in a [Delivery Report](#channels/whatsapp/receive-whatsapp-delivery-reports). - * - * @return self - */ - public function setCallbackData($callbackData) + public function setCallbackData(?string $callbackData): self { - if (!is_null($callbackData) && (mb_strlen($callbackData) > 4000)) { - throw new \InvalidArgumentException('invalid length for $callbackData when calling WhatsAppImageMessage., must be smaller than or equal to 4000.'); - } - if (!is_null($callbackData) && (mb_strlen($callbackData) < 0)) { - throw new \InvalidArgumentException('invalid length for $callbackData when calling WhatsAppImageMessage., must be bigger than or equal to 0.'); - } - - $this->container['callbackData'] = $callbackData; - + $this->callbackData = $callbackData; return $this; } - /** - * Gets notifyUrl - * - * @return string|null - */ - public function getNotifyUrl() + public function getNotifyUrl(): string|null { - return $this->container['notifyUrl']; + return $this->notifyUrl; } - /** - * Sets notifyUrl - * - * @param string|null $notifyUrl The URL on your callback server to which delivery and seen reports will be sent. [Delivery report format](#channels/whatsapp/receive-whatsapp-delivery-reports), [Seen report format](#channels/whatsapp/receive-whatsapp-seen-reports). - * - * @return self - */ - public function setNotifyUrl($notifyUrl) + public function setNotifyUrl(?string $notifyUrl): self { - if (!is_null($notifyUrl) && (mb_strlen($notifyUrl) > 2048)) { - throw new \InvalidArgumentException('invalid length for $notifyUrl when calling WhatsAppImageMessage., must be smaller than or equal to 2048.'); - } - if (!is_null($notifyUrl) && (mb_strlen($notifyUrl) < 0)) { - throw new \InvalidArgumentException('invalid length for $notifyUrl when calling WhatsAppImageMessage., must be bigger than or equal to 0.'); - } - - $this->container['notifyUrl'] = $notifyUrl; - + $this->notifyUrl = $notifyUrl; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppInteractiveBodyContent.php b/Infobip/Model/WhatsAppInteractiveBodyContent.php index 0f07be0..1ea0f33 100644 --- a/Infobip/Model/WhatsAppInteractiveBodyContent.php +++ b/Infobip/Model/WhatsAppInteractiveBodyContent.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppInteractiveBodyContent implements ModelInterface, ArrayAccess, \JsonSerializable +class WhatsAppInteractiveBodyContent implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppInteractiveBodyContent'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'text' => 'string' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'WhatsAppInteractiveBodyContent'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'text' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array */ - public static function openAPITypes() - { - return self::$openAPITypes; - } + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 1024)] + #[Assert\Length(min: 1)] - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; + protected string $text, + ) { } - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'text' => 'text' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'text' => 'setText' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'text' => 'getText' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() + #[Ignore] + public function getModelName(): string { - return self::$setters; + return self::OPENAPI_MODEL_NAME; } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$getters; + return self::DISCRIMINATOR; } - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() + public function getText(): string { - return self::$openAPIModelName; + return $this->text; } - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) + public function setText(string $text): self { - $this->container['text'] = $data['text'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - if ($this->container['text'] === null) { - $invalidProperties[] = "'text' can't be null"; - } - if ((mb_strlen($this->container['text']) > 1024)) { - $invalidProperties[] = "invalid value for 'text', the character length must be smaller than or equal to 1024."; - } - - if ((mb_strlen($this->container['text']) < 1)) { - $invalidProperties[] = "invalid value for 'text', the character length must be bigger than or equal to 1."; - } - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets text - * - * @return string - */ - public function getText() - { - return $this->container['text']; - } - - /** - * Sets text - * - * @param string $text Content of the message body. - * - * @return self - */ - public function setText($text) - { - if ((mb_strlen($text) > 1024)) { - throw new \InvalidArgumentException('invalid length for $text when calling WhatsAppInteractiveBodyContent., must be smaller than or equal to 1024.'); - } - if ((mb_strlen($text) < 1)) { - throw new \InvalidArgumentException('invalid length for $text when calling WhatsAppInteractiveBodyContent., must be bigger than or equal to 1.'); - } - - $this->container['text'] = $text; - + $this->text = $text; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppInteractiveButtonContent.php b/Infobip/Model/WhatsAppInteractiveButtonContent.php index bb63df7..3ab3795 100644 --- a/Infobip/Model/WhatsAppInteractiveButtonContent.php +++ b/Infobip/Model/WhatsAppInteractiveButtonContent.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppInteractiveButtonContent implements ModelInterface, ArrayAccess, \JsonSerializable +use Symfony\Component\Validator\Constraints as Assert; +use Symfony\Component\Serializer\Annotation as Serializer; +use Symfony\Component\Serializer\Annotation\Ignore; +use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer; +use Symfony\Component\Serializer\Annotation\DiscriminatorMap; + +#[DiscriminatorMap(typeProperty: "type", mapping: [ + "REPLY" => "\Infobip\Model\WhatsAppInteractiveReplyButtonContent", + "WhatsAppInteractiveReplyButtonContent" => "\Infobip\Model\WhatsAppInteractiveReplyButtonContent", +])] +class WhatsAppInteractiveButtonContent implements ModelInterface { public const DISCRIMINATOR = 'type'; + public const OPENAPI_MODEL_NAME = 'WhatsAppInteractiveButtonContent'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppInteractiveButtonContent'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'type' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'type' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'type' => 'type' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'type' => 'setType' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] */ - protected static $getters = [ - 'type' => 'getType' - ]; + public function __construct( + #[Assert\NotBlank] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; + protected string $type, + ) { } - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() + #[Ignore] + public function getModelName(): string { - return self::$setters; + return self::OPENAPI_MODEL_NAME; } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$getters; + return self::DISCRIMINATOR; } - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() + public function getType(): string { - return self::$openAPIModelName; + return $this->type; } - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) + public function setType(string $type): self { - $this->container['type'] = $data['type'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - if ($this->container['type'] === null) { - $invalidProperties[] = "'type' can't be null"; - } - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets type - * - * @return string - */ - public function getType() - { - return $this->container['type']; - } - - /** - * Sets type - * - * @param string $type type - * - * @return self - */ - public function setType($type) - { - $this->container['type'] = $type; - + $this->type = $type; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppInteractiveButtonsActionContent.php b/Infobip/Model/WhatsAppInteractiveButtonsActionContent.php index 7246a4b..e47d102 100644 --- a/Infobip/Model/WhatsAppInteractiveButtonsActionContent.php +++ b/Infobip/Model/WhatsAppInteractiveButtonsActionContent.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppInteractiveButtonsActionContent implements ModelInterface, ArrayAccess, \JsonSerializable +class WhatsAppInteractiveButtonsActionContent implements ModelInterface { - public const DISCRIMINATOR = null; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'WhatsAppInteractiveButtonsActionContent'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppInteractiveButtonsActionContent'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'buttons' => '\Infobip\Model\WhatsAppInteractiveButtonContent[]' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'buttons' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'buttons' => 'buttons' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'buttons' => 'setButtons' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'buttons' => 'getButtons' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] + * @param \Infobip\Model\WhatsAppInteractiveButtonContent[] $buttons */ - protected $container = []; + public function __construct( + #[Assert\NotBlank] + #[Assert\Count(max: 3)] + #[Assert\Count(min: 1)] - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['buttons'] = $data['buttons'] ?? null; + protected array $buttons, + ) { } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - if ($this->container['buttons'] === null) { - $invalidProperties[] = "'buttons' can't be null"; - } - if ((count($this->container['buttons']) > 3)) { - $invalidProperties[] = "invalid value for 'buttons', number of items must be less than or equal to 3."; - } - - if ((count($this->container['buttons']) < 1)) { - $invalidProperties[] = "invalid value for 'buttons', number of items must be greater than or equal to 1."; - } - - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - /** - * Gets buttons - * * @return \Infobip\Model\WhatsAppInteractiveButtonContent[] */ - public function getButtons() + public function getButtons(): array { - return $this->container['buttons']; + return $this->buttons; } /** - * Sets buttons - * * @param \Infobip\Model\WhatsAppInteractiveButtonContent[] $buttons An array of buttons sent in a message. It can have up to three buttons. - * - * @return self */ - public function setButtons($buttons) + public function setButtons(array $buttons): self { - if ((count($buttons) > 3)) { - throw new \InvalidArgumentException('invalid value for $buttons when calling WhatsAppInteractiveButtonsActionContent., number of items must be less than or equal to 3.'); - } - if ((count($buttons) < 1)) { - throw new \InvalidArgumentException('invalid length for $buttons when calling WhatsAppInteractiveButtonsActionContent., number of items must be greater than or equal to 1.'); - } - $this->container['buttons'] = $buttons; - + $this->buttons = $buttons; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppInteractiveButtonsContent.php b/Infobip/Model/WhatsAppInteractiveButtonsContent.php index a5fd91b..c775689 100644 --- a/Infobip/Model/WhatsAppInteractiveButtonsContent.php +++ b/Infobip/Model/WhatsAppInteractiveButtonsContent.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppInteractiveButtonsContent implements ModelInterface, ArrayAccess, \JsonSerializable +class WhatsAppInteractiveButtonsContent implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppInteractiveButtonsContent'; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'WhatsAppInteractiveButtonsContent'; - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'body' => '\Infobip\Model\WhatsAppInteractiveBodyContent', - 'action' => '\Infobip\Model\WhatsAppInteractiveButtonsActionContent', - 'header' => '\Infobip\Model\WhatsAppInteractiveButtonsHeaderContent', - 'footer' => '\Infobip\Model\WhatsAppInteractiveFooterContent' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'body' => null, 'action' => null, 'header' => null, @@ -76,338 +37,78 @@ class WhatsAppInteractiveButtonsContent implements ModelInterface, ArrayAccess, ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array */ - public static function openAPITypes() - { - return self::$openAPITypes; - } + public function __construct( + #[Assert\Valid] + #[Assert\NotBlank] - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } + protected \Infobip\Model\WhatsAppInteractiveBodyContent $body, + #[Assert\Valid] + #[Assert\NotBlank] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'body' => 'body', - 'action' => 'action', - 'header' => 'header', - 'footer' => 'footer' - ]; + protected \Infobip\Model\WhatsAppInteractiveButtonsActionContent $action, + #[Assert\Valid] - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'body' => 'setBody', - 'action' => 'setAction', - 'header' => 'setHeader', - 'footer' => 'setFooter' - ]; + protected ?\Infobip\Model\WhatsAppInteractiveButtonsHeaderContent $header = null, + #[Assert\Valid] - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'body' => 'getBody', - 'action' => 'getAction', - 'header' => 'getHeader', - 'footer' => 'getFooter' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['body'] = $data['body'] ?? null; - $this->container['action'] = $data['action'] ?? null; - $this->container['header'] = $data['header'] ?? null; - $this->container['footer'] = $data['footer'] ?? null; + protected ?\Infobip\Model\WhatsAppInteractiveFooterContent $footer = null, + ) { } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - if ($this->container['body'] === null) { - $invalidProperties[] = "'body' can't be null"; - } - if ($this->container['action'] === null) { - $invalidProperties[] = "'action' can't be null"; - } - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets body - * - * @return \Infobip\Model\WhatsAppInteractiveBodyContent - */ - public function getBody() + public function getBody(): \Infobip\Model\WhatsAppInteractiveBodyContent { - return $this->container['body']; + return $this->body; } - /** - * Sets body - * - * @param \Infobip\Model\WhatsAppInteractiveBodyContent $body body - * - * @return self - */ - public function setBody($body) + public function setBody(\Infobip\Model\WhatsAppInteractiveBodyContent $body): self { - $this->container['body'] = $body; - + $this->body = $body; return $this; } - /** - * Gets action - * - * @return \Infobip\Model\WhatsAppInteractiveButtonsActionContent - */ - public function getAction() + public function getAction(): \Infobip\Model\WhatsAppInteractiveButtonsActionContent { - return $this->container['action']; + return $this->action; } - /** - * Sets action - * - * @param \Infobip\Model\WhatsAppInteractiveButtonsActionContent $action action - * - * @return self - */ - public function setAction($action) + public function setAction(\Infobip\Model\WhatsAppInteractiveButtonsActionContent $action): self { - $this->container['action'] = $action; - + $this->action = $action; return $this; } - /** - * Gets header - * - * @return \Infobip\Model\WhatsAppInteractiveButtonsHeaderContent|null - */ - public function getHeader() + public function getHeader(): \Infobip\Model\WhatsAppInteractiveButtonsHeaderContent|null { - return $this->container['header']; + return $this->header; } - /** - * Sets header - * - * @param \Infobip\Model\WhatsAppInteractiveButtonsHeaderContent|null $header header - * - * @return self - */ - public function setHeader($header) + public function setHeader(?\Infobip\Model\WhatsAppInteractiveButtonsHeaderContent $header): self { - $this->container['header'] = $header; - + $this->header = $header; return $this; } - /** - * Gets footer - * - * @return \Infobip\Model\WhatsAppInteractiveFooterContent|null - */ - public function getFooter() + public function getFooter(): \Infobip\Model\WhatsAppInteractiveFooterContent|null { - return $this->container['footer']; + return $this->footer; } - /** - * Sets footer - * - * @param \Infobip\Model\WhatsAppInteractiveFooterContent|null $footer footer - * - * @return self - */ - public function setFooter($footer) + public function setFooter(?\Infobip\Model\WhatsAppInteractiveFooterContent $footer): self { - $this->container['footer'] = $footer; - + $this->footer = $footer; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppInteractiveButtonsDocumentHeaderContent.php b/Infobip/Model/WhatsAppInteractiveButtonsDocumentHeaderContent.php index 04f31f7..6830e99 100644 --- a/Infobip/Model/WhatsAppInteractiveButtonsDocumentHeaderContent.php +++ b/Infobip/Model/WhatsAppInteractiveButtonsDocumentHeaderContent.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ class WhatsAppInteractiveButtonsDocumentHeaderContent extends WhatsAppInteractiveButtonsHeaderContent { public const DISCRIMINATOR = 'type'; + public const OPENAPI_MODEL_NAME = 'WhatsAppInteractiveButtonsDocumentHeaderContent'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppInteractiveButtonsDocumentHeaderContent'; + public const TYPE = 'DOCUMENT'; - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'mediaUrl' => 'string', - 'filename' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'mediaUrl' => null, 'filename' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes + parent::openAPITypes(); - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats + parent::openAPIFormats(); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'mediaUrl' => 'mediaUrl', - 'filename' => 'filename' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'mediaUrl' => 'setMediaUrl', - 'filename' => 'setFilename' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'mediaUrl' => 'getMediaUrl', - 'filename' => 'getFilename' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return parent::attributeMap() + self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return parent::setters() + self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array */ - public static function getters() - { - return parent::getters() + self::$getters; - } + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 2048)] + #[Assert\Length(min: 1)] - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - parent::__construct($data); + protected string $mediaUrl, + #[Assert\Length(max: 240)] + #[Assert\Length(min: 0)] - $this->container['mediaUrl'] = $data['mediaUrl'] ?? null; - $this->container['filename'] = $data['filename'] ?? null; + protected ?string $filename = null, + ) { + $modelDiscriminatorValue = 'DOCUMENT'; - $this->container['type'] = 'DOCUMENT'; + parent::__construct( + type: $modelDiscriminatorValue, + ); } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = parent::listInvalidProperties(); - - if ($this->container['mediaUrl'] === null) { - $invalidProperties[] = "'mediaUrl' can't be null"; - } - if ((mb_strlen($this->container['mediaUrl']) > 2048)) { - $invalidProperties[] = "invalid value for 'mediaUrl', the character length must be smaller than or equal to 2048."; - } - - if ((mb_strlen($this->container['mediaUrl']) < 1)) { - $invalidProperties[] = "invalid value for 'mediaUrl', the character length must be bigger than or equal to 1."; - } - - if (!is_null($this->container['filename']) && (mb_strlen($this->container['filename']) > 240)) { - $invalidProperties[] = "invalid value for 'filename', the character length must be smaller than or equal to 240."; - } - - if (!is_null($this->container['filename']) && (mb_strlen($this->container['filename']) < 0)) { - $invalidProperties[] = "invalid value for 'filename', the character length must be bigger than or equal to 0."; - } - - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets mediaUrl - * - * @return string - */ - public function getMediaUrl() + public function getMediaUrl(): string { - return $this->container['mediaUrl']; + return $this->mediaUrl; } - /** - * Sets mediaUrl - * - * @param string $mediaUrl URL of a document sent in the header of a message containing one or more [interactive buttons](https://www.infobip.com/docs/whatsapp/message-types#interactive-buttons-free-form-messages). Must be a valid URL starting with `https://` or `http://`. Supported document type is `PDF`. Maximum document size is 100MB. - * - * @return self - */ - public function setMediaUrl($mediaUrl) + public function setMediaUrl(string $mediaUrl): self { - if ((mb_strlen($mediaUrl) > 2048)) { - throw new \InvalidArgumentException('invalid length for $mediaUrl when calling WhatsAppInteractiveButtonsDocumentHeaderContent., must be smaller than or equal to 2048.'); - } - if ((mb_strlen($mediaUrl) < 1)) { - throw new \InvalidArgumentException('invalid length for $mediaUrl when calling WhatsAppInteractiveButtonsDocumentHeaderContent., must be bigger than or equal to 1.'); - } - - $this->container['mediaUrl'] = $mediaUrl; - + $this->mediaUrl = $mediaUrl; return $this; } - /** - * Gets filename - * - * @return string|null - */ - public function getFilename() + public function getFilename(): string|null { - return $this->container['filename']; + return $this->filename; } - /** - * Sets filename - * - * @param string|null $filename Filename of the document. - * - * @return self - */ - public function setFilename($filename) + public function setFilename(?string $filename): self { - if (!is_null($filename) && (mb_strlen($filename) > 240)) { - throw new \InvalidArgumentException('invalid length for $filename when calling WhatsAppInteractiveButtonsDocumentHeaderContent., must be smaller than or equal to 240.'); - } - if (!is_null($filename) && (mb_strlen($filename) < 0)) { - throw new \InvalidArgumentException('invalid length for $filename when calling WhatsAppInteractiveButtonsDocumentHeaderContent., must be bigger than or equal to 0.'); - } - - $this->container['filename'] = $filename; - + $this->filename = $filename; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppInteractiveButtonsHeaderContent.php b/Infobip/Model/WhatsAppInteractiveButtonsHeaderContent.php index 9bec0e9..d4cf72f 100644 --- a/Infobip/Model/WhatsAppInteractiveButtonsHeaderContent.php +++ b/Infobip/Model/WhatsAppInteractiveButtonsHeaderContent.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppInteractiveButtonsHeaderContent implements ModelInterface, ArrayAccess, \JsonSerializable +use Symfony\Component\Validator\Constraints as Assert; +use Symfony\Component\Serializer\Annotation as Serializer; +use Symfony\Component\Serializer\Annotation\Ignore; +use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer; +use Symfony\Component\Serializer\Annotation\DiscriminatorMap; + +#[DiscriminatorMap(typeProperty: "type", mapping: [ + "DOCUMENT" => "\Infobip\Model\WhatsAppInteractiveButtonsDocumentHeaderContent", + "IMAGE" => "\Infobip\Model\WhatsAppInteractiveButtonsImageHeaderContent", + "TEXT" => "\Infobip\Model\WhatsAppInteractiveButtonsTextHeaderContent", + "VIDEO" => "\Infobip\Model\WhatsAppInteractiveButtonsVideoHeaderContent", + "WhatsAppInteractiveButtonsDocumentHeaderContent" => "\Infobip\Model\WhatsAppInteractiveButtonsDocumentHeaderContent", + "WhatsAppInteractiveButtonsImageHeaderContent" => "\Infobip\Model\WhatsAppInteractiveButtonsImageHeaderContent", + "WhatsAppInteractiveButtonsTextHeaderContent" => "\Infobip\Model\WhatsAppInteractiveButtonsTextHeaderContent", + "WhatsAppInteractiveButtonsVideoHeaderContent" => "\Infobip\Model\WhatsAppInteractiveButtonsVideoHeaderContent", +])] +class WhatsAppInteractiveButtonsHeaderContent implements ModelInterface { public const DISCRIMINATOR = 'type'; + public const OPENAPI_MODEL_NAME = 'WhatsAppInteractiveButtonsHeaderContent'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppInteractiveButtonsHeaderContent'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'type' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'type' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'type' => 'type' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'type' => 'setType' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] */ - protected static $getters = [ - 'type' => 'getType' - ]; + public function __construct( + #[Assert\NotBlank] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; + protected string $type, + ) { } - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() + #[Ignore] + public function getModelName(): string { - return self::$setters; + return self::OPENAPI_MODEL_NAME; } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$getters; + return self::DISCRIMINATOR; } - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() + public function getType(): string { - return self::$openAPIModelName; + return $this->type; } - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) + public function setType(string $type): self { - $this->container['type'] = $data['type'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - if ($this->container['type'] === null) { - $invalidProperties[] = "'type' can't be null"; - } - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets type - * - * @return string - */ - public function getType() - { - return $this->container['type']; - } - - /** - * Sets type - * - * @param string $type Type of the header content. Select the type from the dropdown to view its parameters. - * - * @return self - */ - public function setType($type) - { - $this->container['type'] = $type; - + $this->type = $type; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppInteractiveButtonsImageHeaderContent.php b/Infobip/Model/WhatsAppInteractiveButtonsImageHeaderContent.php index 9c42fe3..5c14dd7 100644 --- a/Infobip/Model/WhatsAppInteractiveButtonsImageHeaderContent.php +++ b/Infobip/Model/WhatsAppInteractiveButtonsImageHeaderContent.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ class WhatsAppInteractiveButtonsImageHeaderContent extends WhatsAppInteractiveButtonsHeaderContent { public const DISCRIMINATOR = 'type'; + public const OPENAPI_MODEL_NAME = 'WhatsAppInteractiveButtonsImageHeaderContent'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppInteractiveButtonsImageHeaderContent'; + public const TYPE = 'IMAGE'; - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'mediaUrl' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'mediaUrl' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes + parent::openAPITypes(); - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats + parent::openAPIFormats(); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'mediaUrl' => 'mediaUrl' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] */ - protected static $setters = [ - 'mediaUrl' => 'setMediaUrl' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'mediaUrl' => 'getMediaUrl' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return parent::attributeMap() + self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return parent::setters() + self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return parent::getters() + self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 2048)] + #[Assert\Length(min: 1)] + protected string $mediaUrl, + ) { + $modelDiscriminatorValue = 'IMAGE'; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - parent::__construct($data); - - $this->container['mediaUrl'] = $data['mediaUrl'] ?? null; - - $this->container['type'] = 'IMAGE'; + parent::__construct( + type: $modelDiscriminatorValue, + ); } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = parent::listInvalidProperties(); - - if ($this->container['mediaUrl'] === null) { - $invalidProperties[] = "'mediaUrl' can't be null"; - } - if ((mb_strlen($this->container['mediaUrl']) > 2048)) { - $invalidProperties[] = "invalid value for 'mediaUrl', the character length must be smaller than or equal to 2048."; - } - - if ((mb_strlen($this->container['mediaUrl']) < 1)) { - $invalidProperties[] = "invalid value for 'mediaUrl', the character length must be bigger than or equal to 1."; - } - - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets mediaUrl - * - * @return string - */ - public function getMediaUrl() + public function getMediaUrl(): string { - return $this->container['mediaUrl']; + return $this->mediaUrl; } - /** - * Sets mediaUrl - * - * @param string $mediaUrl URL of an image sent in the header of a message containing one or more [interactive buttons](https://www.infobip.com/docs/whatsapp/message-types#interactive-buttons-free-form-messages). Must be a valid URL starting with `https://` or `http://`. Supported image types are `JPG`, `JPEG`, `PNG`. Maximum image size is 5MB. - * - * @return self - */ - public function setMediaUrl($mediaUrl) + public function setMediaUrl(string $mediaUrl): self { - if ((mb_strlen($mediaUrl) > 2048)) { - throw new \InvalidArgumentException('invalid length for $mediaUrl when calling WhatsAppInteractiveButtonsImageHeaderContent., must be smaller than or equal to 2048.'); - } - if ((mb_strlen($mediaUrl) < 1)) { - throw new \InvalidArgumentException('invalid length for $mediaUrl when calling WhatsAppInteractiveButtonsImageHeaderContent., must be bigger than or equal to 1.'); - } - - $this->container['mediaUrl'] = $mediaUrl; - + $this->mediaUrl = $mediaUrl; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppInteractiveButtonsMessage.php b/Infobip/Model/WhatsAppInteractiveButtonsMessage.php index 85b4b97..574d70f 100644 --- a/Infobip/Model/WhatsAppInteractiveButtonsMessage.php +++ b/Infobip/Model/WhatsAppInteractiveButtonsMessage.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppInteractiveButtonsMessage implements ModelInterface, ArrayAccess, \JsonSerializable +class WhatsAppInteractiveButtonsMessage implements ModelInterface { - public const DISCRIMINATOR = null; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'WhatsAppInteractiveButtonsMessage'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppInteractiveButtonsMessage'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'from' => 'string', - 'to' => 'string', - 'messageId' => 'string', - 'content' => '\Infobip\Model\WhatsAppInteractiveButtonsContent', - 'callbackData' => 'string', - 'notifyUrl' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'from' => null, 'to' => null, 'messageId' => null, @@ -79,472 +39,112 @@ class WhatsAppInteractiveButtonsMessage implements ModelInterface, ArrayAccess, ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array */ - public static function openAPITypes() - { - return self::$openAPITypes; - } + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 24)] + #[Assert\Length(min: 1)] - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } + protected string $from, + #[Assert\NotBlank] + #[Assert\Length(max: 24)] + #[Assert\Length(min: 1)] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'from' => 'from', - 'to' => 'to', - 'messageId' => 'messageId', - 'content' => 'content', - 'callbackData' => 'callbackData', - 'notifyUrl' => 'notifyUrl' - ]; + protected string $to, + #[Assert\Valid] + #[Assert\NotBlank] - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'from' => 'setFrom', - 'to' => 'setTo', - 'messageId' => 'setMessageId', - 'content' => 'setContent', - 'callbackData' => 'setCallbackData', - 'notifyUrl' => 'setNotifyUrl' - ]; + protected \Infobip\Model\WhatsAppInteractiveButtonsContent $content, + #[Assert\Length(max: 100)] + #[Assert\Length(min: 0)] - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'from' => 'getFrom', - 'to' => 'getTo', - 'messageId' => 'getMessageId', - 'content' => 'getContent', - 'callbackData' => 'getCallbackData', - 'notifyUrl' => 'getNotifyUrl' - ]; + protected ?string $messageId = null, + #[Assert\Length(max: 4000)] + #[Assert\Length(min: 0)] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } + protected ?string $callbackData = null, + #[Assert\Length(max: 2048)] + #[Assert\Length(min: 0)] - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; + protected ?string $notifyUrl = null, + ) { } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public function getModelName(): string { - return self::$getters; + return self::OPENAPI_MODEL_NAME; } - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) + #[Ignore] + public static function getDiscriminator(): ?string { - $this->container['from'] = $data['from'] ?? null; - $this->container['to'] = $data['to'] ?? null; - $this->container['messageId'] = $data['messageId'] ?? null; - $this->container['content'] = $data['content'] ?? null; - $this->container['callbackData'] = $data['callbackData'] ?? null; - $this->container['notifyUrl'] = $data['notifyUrl'] ?? null; + return self::DISCRIMINATOR; } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + public function getFrom(): string { - $invalidProperties = []; - - if ($this->container['from'] === null) { - $invalidProperties[] = "'from' can't be null"; - } - if ((mb_strlen($this->container['from']) > 24)) { - $invalidProperties[] = "invalid value for 'from', the character length must be smaller than or equal to 24."; - } - - if ((mb_strlen($this->container['from']) < 1)) { - $invalidProperties[] = "invalid value for 'from', the character length must be bigger than or equal to 1."; - } - - if ($this->container['to'] === null) { - $invalidProperties[] = "'to' can't be null"; - } - if ((mb_strlen($this->container['to']) > 24)) { - $invalidProperties[] = "invalid value for 'to', the character length must be smaller than or equal to 24."; - } - - if ((mb_strlen($this->container['to']) < 1)) { - $invalidProperties[] = "invalid value for 'to', the character length must be bigger than or equal to 1."; - } - - if (!is_null($this->container['messageId']) && (mb_strlen($this->container['messageId']) > 50)) { - $invalidProperties[] = "invalid value for 'messageId', the character length must be smaller than or equal to 50."; - } - - if (!is_null($this->container['messageId']) && (mb_strlen($this->container['messageId']) < 0)) { - $invalidProperties[] = "invalid value for 'messageId', the character length must be bigger than or equal to 0."; - } - - if ($this->container['content'] === null) { - $invalidProperties[] = "'content' can't be null"; - } - if (!is_null($this->container['callbackData']) && (mb_strlen($this->container['callbackData']) > 4000)) { - $invalidProperties[] = "invalid value for 'callbackData', the character length must be smaller than or equal to 4000."; - } - - if (!is_null($this->container['callbackData']) && (mb_strlen($this->container['callbackData']) < 0)) { - $invalidProperties[] = "invalid value for 'callbackData', the character length must be bigger than or equal to 0."; - } - - if (!is_null($this->container['notifyUrl']) && (mb_strlen($this->container['notifyUrl']) > 2048)) { - $invalidProperties[] = "invalid value for 'notifyUrl', the character length must be smaller than or equal to 2048."; - } - - if (!is_null($this->container['notifyUrl']) && (mb_strlen($this->container['notifyUrl']) < 0)) { - $invalidProperties[] = "invalid value for 'notifyUrl', the character length must be bigger than or equal to 0."; - } - - return $invalidProperties; + return $this->from; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + public function setFrom(string $from): self { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets from - * - * @return string - */ - public function getFrom() - { - return $this->container['from']; - } - - /** - * Sets from - * - * @param string $from Registered WhatsApp sender number. Must be in international format and comply with [WhatsApp's requirements](https://www.infobip.com/docs/whatsapp/get-started#phone-number-what-you-need-to-know). - * - * @return self - */ - public function setFrom($from) - { - if ((mb_strlen($from) > 24)) { - throw new \InvalidArgumentException('invalid length for $from when calling WhatsAppInteractiveButtonsMessage., must be smaller than or equal to 24.'); - } - if ((mb_strlen($from) < 1)) { - throw new \InvalidArgumentException('invalid length for $from when calling WhatsAppInteractiveButtonsMessage., must be bigger than or equal to 1.'); - } - - $this->container['from'] = $from; - + $this->from = $from; return $this; } - /** - * Gets to - * - * @return string - */ - public function getTo() + public function getTo(): string { - return $this->container['to']; + return $this->to; } - /** - * Sets to - * - * @param string $to Message recipient number. Must be in international format. - * - * @return self - */ - public function setTo($to) + public function setTo(string $to): self { - if ((mb_strlen($to) > 24)) { - throw new \InvalidArgumentException('invalid length for $to when calling WhatsAppInteractiveButtonsMessage., must be smaller than or equal to 24.'); - } - if ((mb_strlen($to) < 1)) { - throw new \InvalidArgumentException('invalid length for $to when calling WhatsAppInteractiveButtonsMessage., must be bigger than or equal to 1.'); - } - - $this->container['to'] = $to; - + $this->to = $to; return $this; } - /** - * Gets messageId - * - * @return string|null - */ - public function getMessageId() + public function getMessageId(): string|null { - return $this->container['messageId']; + return $this->messageId; } - /** - * Sets messageId - * - * @param string|null $messageId The ID that uniquely identifies the message sent. - * - * @return self - */ - public function setMessageId($messageId) + public function setMessageId(?string $messageId): self { - if (!is_null($messageId) && (mb_strlen($messageId) > 50)) { - throw new \InvalidArgumentException('invalid length for $messageId when calling WhatsAppInteractiveButtonsMessage., must be smaller than or equal to 50.'); - } - if (!is_null($messageId) && (mb_strlen($messageId) < 0)) { - throw new \InvalidArgumentException('invalid length for $messageId when calling WhatsAppInteractiveButtonsMessage., must be bigger than or equal to 0.'); - } - - $this->container['messageId'] = $messageId; - + $this->messageId = $messageId; return $this; } - /** - * Gets content - * - * @return \Infobip\Model\WhatsAppInteractiveButtonsContent - */ - public function getContent() + public function getContent(): \Infobip\Model\WhatsAppInteractiveButtonsContent { - return $this->container['content']; + return $this->content; } - /** - * Sets content - * - * @param \Infobip\Model\WhatsAppInteractiveButtonsContent $content content - * - * @return self - */ - public function setContent($content) + public function setContent(\Infobip\Model\WhatsAppInteractiveButtonsContent $content): self { - $this->container['content'] = $content; - + $this->content = $content; return $this; } - /** - * Gets callbackData - * - * @return string|null - */ - public function getCallbackData() + public function getCallbackData(): string|null { - return $this->container['callbackData']; + return $this->callbackData; } - /** - * Sets callbackData - * - * @param string|null $callbackData Custom client data that will be included in a [Delivery Report](#channels/whatsapp/receive-whatsapp-delivery-reports). - * - * @return self - */ - public function setCallbackData($callbackData) + public function setCallbackData(?string $callbackData): self { - if (!is_null($callbackData) && (mb_strlen($callbackData) > 4000)) { - throw new \InvalidArgumentException('invalid length for $callbackData when calling WhatsAppInteractiveButtonsMessage., must be smaller than or equal to 4000.'); - } - if (!is_null($callbackData) && (mb_strlen($callbackData) < 0)) { - throw new \InvalidArgumentException('invalid length for $callbackData when calling WhatsAppInteractiveButtonsMessage., must be bigger than or equal to 0.'); - } - - $this->container['callbackData'] = $callbackData; - + $this->callbackData = $callbackData; return $this; } - /** - * Gets notifyUrl - * - * @return string|null - */ - public function getNotifyUrl() + public function getNotifyUrl(): string|null { - return $this->container['notifyUrl']; + return $this->notifyUrl; } - /** - * Sets notifyUrl - * - * @param string|null $notifyUrl The URL on your callback server to which delivery and seen reports will be sent. [Delivery report format](#channels/whatsapp/receive-whatsapp-delivery-reports), [Seen report format](#channels/whatsapp/receive-whatsapp-seen-reports). - * - * @return self - */ - public function setNotifyUrl($notifyUrl) + public function setNotifyUrl(?string $notifyUrl): self { - if (!is_null($notifyUrl) && (mb_strlen($notifyUrl) > 2048)) { - throw new \InvalidArgumentException('invalid length for $notifyUrl when calling WhatsAppInteractiveButtonsMessage., must be smaller than or equal to 2048.'); - } - if (!is_null($notifyUrl) && (mb_strlen($notifyUrl) < 0)) { - throw new \InvalidArgumentException('invalid length for $notifyUrl when calling WhatsAppInteractiveButtonsMessage., must be bigger than or equal to 0.'); - } - - $this->container['notifyUrl'] = $notifyUrl; - + $this->notifyUrl = $notifyUrl; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppInteractiveButtonsTextHeaderContent.php b/Infobip/Model/WhatsAppInteractiveButtonsTextHeaderContent.php index c00b48e..d6c0415 100644 --- a/Infobip/Model/WhatsAppInteractiveButtonsTextHeaderContent.php +++ b/Infobip/Model/WhatsAppInteractiveButtonsTextHeaderContent.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ class WhatsAppInteractiveButtonsTextHeaderContent extends WhatsAppInteractiveButtonsHeaderContent { public const DISCRIMINATOR = 'type'; + public const OPENAPI_MODEL_NAME = 'WhatsAppInteractiveButtonsTextHeaderContent'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppInteractiveButtonsTextHeaderContent'; + public const TYPE = 'TEXT'; - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'text' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'text' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes + parent::openAPITypes(); - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats + parent::openAPIFormats(); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'text' => 'text' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] */ - protected static $setters = [ - 'text' => 'setText' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'text' => 'getText' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return parent::attributeMap() + self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return parent::setters() + self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return parent::getters() + self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 60)] + #[Assert\Length(min: 1)] + protected string $text, + ) { + $modelDiscriminatorValue = 'TEXT'; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - parent::__construct($data); - - $this->container['text'] = $data['text'] ?? null; - - $this->container['type'] = 'TEXT'; + parent::__construct( + type: $modelDiscriminatorValue, + ); } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = parent::listInvalidProperties(); - - if ($this->container['text'] === null) { - $invalidProperties[] = "'text' can't be null"; - } - if ((mb_strlen($this->container['text']) > 60)) { - $invalidProperties[] = "invalid value for 'text', the character length must be smaller than or equal to 60."; - } - - if ((mb_strlen($this->container['text']) < 1)) { - $invalidProperties[] = "invalid value for 'text', the character length must be bigger than or equal to 1."; - } - - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets text - * - * @return string - */ - public function getText() + public function getText(): string { - return $this->container['text']; + return $this->text; } - /** - * Sets text - * - * @param string $text Content of the header used when creating [interactive buttons](https://www.infobip.com/docs/whatsapp/message-types#interactive-buttons-free-form-messages). - * - * @return self - */ - public function setText($text) + public function setText(string $text): self { - if ((mb_strlen($text) > 60)) { - throw new \InvalidArgumentException('invalid length for $text when calling WhatsAppInteractiveButtonsTextHeaderContent., must be smaller than or equal to 60.'); - } - if ((mb_strlen($text) < 1)) { - throw new \InvalidArgumentException('invalid length for $text when calling WhatsAppInteractiveButtonsTextHeaderContent., must be bigger than or equal to 1.'); - } - - $this->container['text'] = $text; - + $this->text = $text; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppInteractiveButtonsVideoHeaderContent.php b/Infobip/Model/WhatsAppInteractiveButtonsVideoHeaderContent.php index d8570f6..9220c3d 100644 --- a/Infobip/Model/WhatsAppInteractiveButtonsVideoHeaderContent.php +++ b/Infobip/Model/WhatsAppInteractiveButtonsVideoHeaderContent.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ class WhatsAppInteractiveButtonsVideoHeaderContent extends WhatsAppInteractiveButtonsHeaderContent { public const DISCRIMINATOR = 'type'; + public const OPENAPI_MODEL_NAME = 'WhatsAppInteractiveButtonsVideoHeaderContent'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppInteractiveButtonsVideoHeaderContent'; + public const TYPE = 'VIDEO'; - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'mediaUrl' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'mediaUrl' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes + parent::openAPITypes(); - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats + parent::openAPIFormats(); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'mediaUrl' => 'mediaUrl' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] */ - protected static $setters = [ - 'mediaUrl' => 'setMediaUrl' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'mediaUrl' => 'getMediaUrl' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return parent::attributeMap() + self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return parent::setters() + self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return parent::getters() + self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 2048)] + #[Assert\Length(min: 1)] + protected string $mediaUrl, + ) { + $modelDiscriminatorValue = 'VIDEO'; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - parent::__construct($data); - - $this->container['mediaUrl'] = $data['mediaUrl'] ?? null; - - $this->container['type'] = 'VIDEO'; + parent::__construct( + type: $modelDiscriminatorValue, + ); } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = parent::listInvalidProperties(); - - if ($this->container['mediaUrl'] === null) { - $invalidProperties[] = "'mediaUrl' can't be null"; - } - if ((mb_strlen($this->container['mediaUrl']) > 2048)) { - $invalidProperties[] = "invalid value for 'mediaUrl', the character length must be smaller than or equal to 2048."; - } - - if ((mb_strlen($this->container['mediaUrl']) < 1)) { - $invalidProperties[] = "invalid value for 'mediaUrl', the character length must be bigger than or equal to 1."; - } - - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets mediaUrl - * - * @return string - */ - public function getMediaUrl() + public function getMediaUrl(): string { - return $this->container['mediaUrl']; + return $this->mediaUrl; } - /** - * Sets mediaUrl - * - * @param string $mediaUrl URL of a video sent in the header of a message containing one or more [interactive buttons](https://www.infobip.com/docs/whatsapp/message-types#interactive-buttons-free-form-messages). Must be a valid URL starting with `https://` or `http://`. Supported video types are `MP4`, `3GPP`. Maximum video size is 16MB. - * - * @return self - */ - public function setMediaUrl($mediaUrl) + public function setMediaUrl(string $mediaUrl): self { - if ((mb_strlen($mediaUrl) > 2048)) { - throw new \InvalidArgumentException('invalid length for $mediaUrl when calling WhatsAppInteractiveButtonsVideoHeaderContent., must be smaller than or equal to 2048.'); - } - if ((mb_strlen($mediaUrl) < 1)) { - throw new \InvalidArgumentException('invalid length for $mediaUrl when calling WhatsAppInteractiveButtonsVideoHeaderContent., must be bigger than or equal to 1.'); - } - - $this->container['mediaUrl'] = $mediaUrl; - + $this->mediaUrl = $mediaUrl; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppInteractiveFooterContent.php b/Infobip/Model/WhatsAppInteractiveFooterContent.php index 6949c80..daa2b44 100644 --- a/Infobip/Model/WhatsAppInteractiveFooterContent.php +++ b/Infobip/Model/WhatsAppInteractiveFooterContent.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppInteractiveFooterContent implements ModelInterface, ArrayAccess, \JsonSerializable +class WhatsAppInteractiveFooterContent implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppInteractiveFooterContent'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'text' => 'string' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'WhatsAppInteractiveFooterContent'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'text' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array */ - public static function openAPITypes() - { - return self::$openAPITypes; - } + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 60)] + #[Assert\Length(min: 1)] - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; + protected string $text, + ) { } - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'text' => 'text' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'text' => 'setText' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'text' => 'getText' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() + #[Ignore] + public function getModelName(): string { - return self::$setters; + return self::OPENAPI_MODEL_NAME; } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$getters; + return self::DISCRIMINATOR; } - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() + public function getText(): string { - return self::$openAPIModelName; + return $this->text; } - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) + public function setText(string $text): self { - $this->container['text'] = $data['text'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - if ($this->container['text'] === null) { - $invalidProperties[] = "'text' can't be null"; - } - if ((mb_strlen($this->container['text']) > 60)) { - $invalidProperties[] = "invalid value for 'text', the character length must be smaller than or equal to 60."; - } - - if ((mb_strlen($this->container['text']) < 1)) { - $invalidProperties[] = "invalid value for 'text', the character length must be bigger than or equal to 1."; - } - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets text - * - * @return string - */ - public function getText() - { - return $this->container['text']; - } - - /** - * Sets text - * - * @param string $text Content of the message footer. - * - * @return self - */ - public function setText($text) - { - if ((mb_strlen($text) > 60)) { - throw new \InvalidArgumentException('invalid length for $text when calling WhatsAppInteractiveFooterContent., must be smaller than or equal to 60.'); - } - if ((mb_strlen($text) < 1)) { - throw new \InvalidArgumentException('invalid length for $text when calling WhatsAppInteractiveFooterContent., must be bigger than or equal to 1.'); - } - - $this->container['text'] = $text; - + $this->text = $text; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppInteractiveListActionContent.php b/Infobip/Model/WhatsAppInteractiveListActionContent.php index 9850162..ab439aa 100644 --- a/Infobip/Model/WhatsAppInteractiveListActionContent.php +++ b/Infobip/Model/WhatsAppInteractiveListActionContent.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppInteractiveListActionContent implements ModelInterface, ArrayAccess, \JsonSerializable +class WhatsAppInteractiveListActionContent implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppInteractiveListActionContent'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'title' => 'string', - 'sections' => '\Infobip\Model\WhatsAppInteractiveListSectionContent[]' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'WhatsAppInteractiveListActionContent'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'title' => null, 'sections' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'title' => 'title', - 'sections' => 'sections' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] + * @param \Infobip\Model\WhatsAppInteractiveListSectionContent[] $sections */ - protected static $setters = [ - 'title' => 'setTitle', - 'sections' => 'setSections' - ]; + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 20)] + #[Assert\Length(min: 1)] - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'title' => 'getTitle', - 'sections' => 'getSections' - ]; + protected string $title, + #[Assert\NotBlank] + #[Assert\Count(max: 10)] + #[Assert\Count(min: 1)] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; + protected array $sections, + ) { } - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() + #[Ignore] + public function getModelName(): string { - return self::$setters; + return self::OPENAPI_MODEL_NAME; } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$getters; + return self::DISCRIMINATOR; } - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() + public function getTitle(): string { - return self::$openAPIModelName; + return $this->title; } - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) + public function setTitle(string $title): self { - $this->container['title'] = $data['title'] ?? null; - $this->container['sections'] = $data['sections'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - if ($this->container['title'] === null) { - $invalidProperties[] = "'title' can't be null"; - } - if ((mb_strlen($this->container['title']) > 20)) { - $invalidProperties[] = "invalid value for 'title', the character length must be smaller than or equal to 20."; - } - - if ((mb_strlen($this->container['title']) < 1)) { - $invalidProperties[] = "invalid value for 'title', the character length must be bigger than or equal to 1."; - } - - if ($this->container['sections'] === null) { - $invalidProperties[] = "'sections' can't be null"; - } - if ((count($this->container['sections']) > 10)) { - $invalidProperties[] = "invalid value for 'sections', number of items must be less than or equal to 10."; - } - - if ((count($this->container['sections']) < 1)) { - $invalidProperties[] = "invalid value for 'sections', number of items must be greater than or equal to 1."; - } - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets title - * - * @return string - */ - public function getTitle() - { - return $this->container['title']; - } - - /** - * Sets title - * - * @param string $title Title of the list. Does not allow emojis or markdown. - * - * @return self - */ - public function setTitle($title) - { - if ((mb_strlen($title) > 20)) { - throw new \InvalidArgumentException('invalid length for $title when calling WhatsAppInteractiveListActionContent., must be smaller than or equal to 20.'); - } - if ((mb_strlen($title) < 1)) { - throw new \InvalidArgumentException('invalid length for $title when calling WhatsAppInteractiveListActionContent., must be bigger than or equal to 1.'); - } - - $this->container['title'] = $title; - + $this->title = $title; return $this; } /** - * Gets sections - * * @return \Infobip\Model\WhatsAppInteractiveListSectionContent[] */ - public function getSections() + public function getSections(): array { - return $this->container['sections']; + return $this->sections; } /** - * Sets sections - * * @param \Infobip\Model\WhatsAppInteractiveListSectionContent[] $sections Array of sections in the list. - * - * @return self */ - public function setSections($sections) + public function setSections(array $sections): self { - if ((count($sections) > 10)) { - throw new \InvalidArgumentException('invalid value for $sections when calling WhatsAppInteractiveListActionContent., number of items must be less than or equal to 10.'); - } - if ((count($sections) < 1)) { - throw new \InvalidArgumentException('invalid length for $sections when calling WhatsAppInteractiveListActionContent., number of items must be greater than or equal to 1.'); - } - $this->container['sections'] = $sections; - + $this->sections = $sections; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppInteractiveListContent.php b/Infobip/Model/WhatsAppInteractiveListContent.php index 1611e5b..a92e977 100644 --- a/Infobip/Model/WhatsAppInteractiveListContent.php +++ b/Infobip/Model/WhatsAppInteractiveListContent.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppInteractiveListContent implements ModelInterface, ArrayAccess, \JsonSerializable +class WhatsAppInteractiveListContent implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppInteractiveListContent'; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'WhatsAppInteractiveListContent'; - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'body' => '\Infobip\Model\WhatsAppInteractiveBodyContent', - 'action' => '\Infobip\Model\WhatsAppInteractiveListActionContent', - 'header' => '\Infobip\Model\WhatsAppInteractiveListHeaderContent', - 'footer' => '\Infobip\Model\WhatsAppInteractiveFooterContent' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'body' => null, 'action' => null, 'header' => null, @@ -76,338 +37,78 @@ class WhatsAppInteractiveListContent implements ModelInterface, ArrayAccess, \Js ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array */ - public static function openAPITypes() - { - return self::$openAPITypes; - } + public function __construct( + #[Assert\Valid] + #[Assert\NotBlank] - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } + protected \Infobip\Model\WhatsAppInteractiveBodyContent $body, + #[Assert\Valid] + #[Assert\NotBlank] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'body' => 'body', - 'action' => 'action', - 'header' => 'header', - 'footer' => 'footer' - ]; + protected \Infobip\Model\WhatsAppInteractiveListActionContent $action, + #[Assert\Valid] - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'body' => 'setBody', - 'action' => 'setAction', - 'header' => 'setHeader', - 'footer' => 'setFooter' - ]; + protected ?\Infobip\Model\WhatsAppInteractiveListHeaderContent $header = null, + #[Assert\Valid] - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'body' => 'getBody', - 'action' => 'getAction', - 'header' => 'getHeader', - 'footer' => 'getFooter' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['body'] = $data['body'] ?? null; - $this->container['action'] = $data['action'] ?? null; - $this->container['header'] = $data['header'] ?? null; - $this->container['footer'] = $data['footer'] ?? null; + protected ?\Infobip\Model\WhatsAppInteractiveFooterContent $footer = null, + ) { } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - if ($this->container['body'] === null) { - $invalidProperties[] = "'body' can't be null"; - } - if ($this->container['action'] === null) { - $invalidProperties[] = "'action' can't be null"; - } - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets body - * - * @return \Infobip\Model\WhatsAppInteractiveBodyContent - */ - public function getBody() + public function getBody(): \Infobip\Model\WhatsAppInteractiveBodyContent { - return $this->container['body']; + return $this->body; } - /** - * Sets body - * - * @param \Infobip\Model\WhatsAppInteractiveBodyContent $body body - * - * @return self - */ - public function setBody($body) + public function setBody(\Infobip\Model\WhatsAppInteractiveBodyContent $body): self { - $this->container['body'] = $body; - + $this->body = $body; return $this; } - /** - * Gets action - * - * @return \Infobip\Model\WhatsAppInteractiveListActionContent - */ - public function getAction() + public function getAction(): \Infobip\Model\WhatsAppInteractiveListActionContent { - return $this->container['action']; + return $this->action; } - /** - * Sets action - * - * @param \Infobip\Model\WhatsAppInteractiveListActionContent $action action - * - * @return self - */ - public function setAction($action) + public function setAction(\Infobip\Model\WhatsAppInteractiveListActionContent $action): self { - $this->container['action'] = $action; - + $this->action = $action; return $this; } - /** - * Gets header - * - * @return \Infobip\Model\WhatsAppInteractiveListHeaderContent|null - */ - public function getHeader() + public function getHeader(): \Infobip\Model\WhatsAppInteractiveListHeaderContent|null { - return $this->container['header']; + return $this->header; } - /** - * Sets header - * - * @param \Infobip\Model\WhatsAppInteractiveListHeaderContent|null $header header - * - * @return self - */ - public function setHeader($header) + public function setHeader(?\Infobip\Model\WhatsAppInteractiveListHeaderContent $header): self { - $this->container['header'] = $header; - + $this->header = $header; return $this; } - /** - * Gets footer - * - * @return \Infobip\Model\WhatsAppInteractiveFooterContent|null - */ - public function getFooter() + public function getFooter(): \Infobip\Model\WhatsAppInteractiveFooterContent|null { - return $this->container['footer']; + return $this->footer; } - /** - * Sets footer - * - * @param \Infobip\Model\WhatsAppInteractiveFooterContent|null $footer footer - * - * @return self - */ - public function setFooter($footer) + public function setFooter(?\Infobip\Model\WhatsAppInteractiveFooterContent $footer): self { - $this->container['footer'] = $footer; - + $this->footer = $footer; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppInteractiveListHeaderContent.php b/Infobip/Model/WhatsAppInteractiveListHeaderContent.php index 1b15a12..bec53da 100644 --- a/Infobip/Model/WhatsAppInteractiveListHeaderContent.php +++ b/Infobip/Model/WhatsAppInteractiveListHeaderContent.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppInteractiveListHeaderContent implements ModelInterface, ArrayAccess, \JsonSerializable +use Symfony\Component\Validator\Constraints as Assert; +use Symfony\Component\Serializer\Annotation as Serializer; +use Symfony\Component\Serializer\Annotation\Ignore; +use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer; +use Symfony\Component\Serializer\Annotation\DiscriminatorMap; + +#[DiscriminatorMap(typeProperty: "type", mapping: [ + "TEXT" => "\Infobip\Model\WhatsAppInteractiveListTextHeaderContent", + "WhatsAppInteractiveListTextHeaderContent" => "\Infobip\Model\WhatsAppInteractiveListTextHeaderContent", +])] +class WhatsAppInteractiveListHeaderContent implements ModelInterface { public const DISCRIMINATOR = 'type'; + public const OPENAPI_MODEL_NAME = 'WhatsAppInteractiveListHeaderContent'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppInteractiveListHeaderContent'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'type' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'type' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'type' => 'type' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'type' => 'setType' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] */ - protected static $getters = [ - 'type' => 'getType' - ]; + public function __construct( + #[Assert\NotBlank] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; + protected string $type, + ) { } - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() + #[Ignore] + public function getModelName(): string { - return self::$setters; + return self::OPENAPI_MODEL_NAME; } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$getters; + return self::DISCRIMINATOR; } - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() + public function getType(): string { - return self::$openAPIModelName; + return $this->type; } - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) + public function setType(string $type): self { - $this->container['type'] = $data['type'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - if ($this->container['type'] === null) { - $invalidProperties[] = "'type' can't be null"; - } - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets type - * - * @return string - */ - public function getType() - { - return $this->container['type']; - } - - /** - * Sets type - * - * @param string $type Type of the header content. Select the type from the dropdown to view its parameters. - * - * @return self - */ - public function setType($type) - { - $this->container['type'] = $type; - + $this->type = $type; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppInteractiveListMessage.php b/Infobip/Model/WhatsAppInteractiveListMessage.php index ac5a94f..fae2d49 100644 --- a/Infobip/Model/WhatsAppInteractiveListMessage.php +++ b/Infobip/Model/WhatsAppInteractiveListMessage.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppInteractiveListMessage implements ModelInterface, ArrayAccess, \JsonSerializable +class WhatsAppInteractiveListMessage implements ModelInterface { - public const DISCRIMINATOR = null; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'WhatsAppInteractiveListMessage'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppInteractiveListMessage'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'from' => 'string', - 'to' => 'string', - 'messageId' => 'string', - 'content' => '\Infobip\Model\WhatsAppInteractiveListContent', - 'callbackData' => 'string', - 'notifyUrl' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'from' => null, 'to' => null, 'messageId' => null, @@ -79,472 +39,112 @@ class WhatsAppInteractiveListMessage implements ModelInterface, ArrayAccess, \Js ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array */ - public static function openAPITypes() - { - return self::$openAPITypes; - } + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 24)] + #[Assert\Length(min: 1)] - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } + protected string $from, + #[Assert\NotBlank] + #[Assert\Length(max: 24)] + #[Assert\Length(min: 1)] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'from' => 'from', - 'to' => 'to', - 'messageId' => 'messageId', - 'content' => 'content', - 'callbackData' => 'callbackData', - 'notifyUrl' => 'notifyUrl' - ]; + protected string $to, + #[Assert\Valid] + #[Assert\NotBlank] - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'from' => 'setFrom', - 'to' => 'setTo', - 'messageId' => 'setMessageId', - 'content' => 'setContent', - 'callbackData' => 'setCallbackData', - 'notifyUrl' => 'setNotifyUrl' - ]; + protected \Infobip\Model\WhatsAppInteractiveListContent $content, + #[Assert\Length(max: 100)] + #[Assert\Length(min: 0)] - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'from' => 'getFrom', - 'to' => 'getTo', - 'messageId' => 'getMessageId', - 'content' => 'getContent', - 'callbackData' => 'getCallbackData', - 'notifyUrl' => 'getNotifyUrl' - ]; + protected ?string $messageId = null, + #[Assert\Length(max: 4000)] + #[Assert\Length(min: 0)] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } + protected ?string $callbackData = null, + #[Assert\Length(max: 2048)] + #[Assert\Length(min: 0)] - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; + protected ?string $notifyUrl = null, + ) { } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public function getModelName(): string { - return self::$getters; + return self::OPENAPI_MODEL_NAME; } - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) + #[Ignore] + public static function getDiscriminator(): ?string { - $this->container['from'] = $data['from'] ?? null; - $this->container['to'] = $data['to'] ?? null; - $this->container['messageId'] = $data['messageId'] ?? null; - $this->container['content'] = $data['content'] ?? null; - $this->container['callbackData'] = $data['callbackData'] ?? null; - $this->container['notifyUrl'] = $data['notifyUrl'] ?? null; + return self::DISCRIMINATOR; } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + public function getFrom(): string { - $invalidProperties = []; - - if ($this->container['from'] === null) { - $invalidProperties[] = "'from' can't be null"; - } - if ((mb_strlen($this->container['from']) > 24)) { - $invalidProperties[] = "invalid value for 'from', the character length must be smaller than or equal to 24."; - } - - if ((mb_strlen($this->container['from']) < 1)) { - $invalidProperties[] = "invalid value for 'from', the character length must be bigger than or equal to 1."; - } - - if ($this->container['to'] === null) { - $invalidProperties[] = "'to' can't be null"; - } - if ((mb_strlen($this->container['to']) > 24)) { - $invalidProperties[] = "invalid value for 'to', the character length must be smaller than or equal to 24."; - } - - if ((mb_strlen($this->container['to']) < 1)) { - $invalidProperties[] = "invalid value for 'to', the character length must be bigger than or equal to 1."; - } - - if (!is_null($this->container['messageId']) && (mb_strlen($this->container['messageId']) > 50)) { - $invalidProperties[] = "invalid value for 'messageId', the character length must be smaller than or equal to 50."; - } - - if (!is_null($this->container['messageId']) && (mb_strlen($this->container['messageId']) < 0)) { - $invalidProperties[] = "invalid value for 'messageId', the character length must be bigger than or equal to 0."; - } - - if ($this->container['content'] === null) { - $invalidProperties[] = "'content' can't be null"; - } - if (!is_null($this->container['callbackData']) && (mb_strlen($this->container['callbackData']) > 4000)) { - $invalidProperties[] = "invalid value for 'callbackData', the character length must be smaller than or equal to 4000."; - } - - if (!is_null($this->container['callbackData']) && (mb_strlen($this->container['callbackData']) < 0)) { - $invalidProperties[] = "invalid value for 'callbackData', the character length must be bigger than or equal to 0."; - } - - if (!is_null($this->container['notifyUrl']) && (mb_strlen($this->container['notifyUrl']) > 2048)) { - $invalidProperties[] = "invalid value for 'notifyUrl', the character length must be smaller than or equal to 2048."; - } - - if (!is_null($this->container['notifyUrl']) && (mb_strlen($this->container['notifyUrl']) < 0)) { - $invalidProperties[] = "invalid value for 'notifyUrl', the character length must be bigger than or equal to 0."; - } - - return $invalidProperties; + return $this->from; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + public function setFrom(string $from): self { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets from - * - * @return string - */ - public function getFrom() - { - return $this->container['from']; - } - - /** - * Sets from - * - * @param string $from Registered WhatsApp sender number. Must be in international format and comply with [WhatsApp's requirements](https://www.infobip.com/docs/whatsapp/get-started#phone-number-what-you-need-to-know). - * - * @return self - */ - public function setFrom($from) - { - if ((mb_strlen($from) > 24)) { - throw new \InvalidArgumentException('invalid length for $from when calling WhatsAppInteractiveListMessage., must be smaller than or equal to 24.'); - } - if ((mb_strlen($from) < 1)) { - throw new \InvalidArgumentException('invalid length for $from when calling WhatsAppInteractiveListMessage., must be bigger than or equal to 1.'); - } - - $this->container['from'] = $from; - + $this->from = $from; return $this; } - /** - * Gets to - * - * @return string - */ - public function getTo() + public function getTo(): string { - return $this->container['to']; + return $this->to; } - /** - * Sets to - * - * @param string $to Message recipient number. Must be in international format. - * - * @return self - */ - public function setTo($to) + public function setTo(string $to): self { - if ((mb_strlen($to) > 24)) { - throw new \InvalidArgumentException('invalid length for $to when calling WhatsAppInteractiveListMessage., must be smaller than or equal to 24.'); - } - if ((mb_strlen($to) < 1)) { - throw new \InvalidArgumentException('invalid length for $to when calling WhatsAppInteractiveListMessage., must be bigger than or equal to 1.'); - } - - $this->container['to'] = $to; - + $this->to = $to; return $this; } - /** - * Gets messageId - * - * @return string|null - */ - public function getMessageId() + public function getMessageId(): string|null { - return $this->container['messageId']; + return $this->messageId; } - /** - * Sets messageId - * - * @param string|null $messageId The ID that uniquely identifies the message sent. - * - * @return self - */ - public function setMessageId($messageId) + public function setMessageId(?string $messageId): self { - if (!is_null($messageId) && (mb_strlen($messageId) > 50)) { - throw new \InvalidArgumentException('invalid length for $messageId when calling WhatsAppInteractiveListMessage., must be smaller than or equal to 50.'); - } - if (!is_null($messageId) && (mb_strlen($messageId) < 0)) { - throw new \InvalidArgumentException('invalid length for $messageId when calling WhatsAppInteractiveListMessage., must be bigger than or equal to 0.'); - } - - $this->container['messageId'] = $messageId; - + $this->messageId = $messageId; return $this; } - /** - * Gets content - * - * @return \Infobip\Model\WhatsAppInteractiveListContent - */ - public function getContent() + public function getContent(): \Infobip\Model\WhatsAppInteractiveListContent { - return $this->container['content']; + return $this->content; } - /** - * Sets content - * - * @param \Infobip\Model\WhatsAppInteractiveListContent $content content - * - * @return self - */ - public function setContent($content) + public function setContent(\Infobip\Model\WhatsAppInteractiveListContent $content): self { - $this->container['content'] = $content; - + $this->content = $content; return $this; } - /** - * Gets callbackData - * - * @return string|null - */ - public function getCallbackData() + public function getCallbackData(): string|null { - return $this->container['callbackData']; + return $this->callbackData; } - /** - * Sets callbackData - * - * @param string|null $callbackData Custom client data that will be included in a [Delivery Report](#channels/whatsapp/receive-whatsapp-delivery-reports). - * - * @return self - */ - public function setCallbackData($callbackData) + public function setCallbackData(?string $callbackData): self { - if (!is_null($callbackData) && (mb_strlen($callbackData) > 4000)) { - throw new \InvalidArgumentException('invalid length for $callbackData when calling WhatsAppInteractiveListMessage., must be smaller than or equal to 4000.'); - } - if (!is_null($callbackData) && (mb_strlen($callbackData) < 0)) { - throw new \InvalidArgumentException('invalid length for $callbackData when calling WhatsAppInteractiveListMessage., must be bigger than or equal to 0.'); - } - - $this->container['callbackData'] = $callbackData; - + $this->callbackData = $callbackData; return $this; } - /** - * Gets notifyUrl - * - * @return string|null - */ - public function getNotifyUrl() + public function getNotifyUrl(): string|null { - return $this->container['notifyUrl']; + return $this->notifyUrl; } - /** - * Sets notifyUrl - * - * @param string|null $notifyUrl The URL on your callback server to which delivery and seen reports will be sent. [Delivery report format](#channels/whatsapp/receive-whatsapp-delivery-reports), [Seen report format](#channels/whatsapp/receive-whatsapp-seen-reports). - * - * @return self - */ - public function setNotifyUrl($notifyUrl) + public function setNotifyUrl(?string $notifyUrl): self { - if (!is_null($notifyUrl) && (mb_strlen($notifyUrl) > 2048)) { - throw new \InvalidArgumentException('invalid length for $notifyUrl when calling WhatsAppInteractiveListMessage., must be smaller than or equal to 2048.'); - } - if (!is_null($notifyUrl) && (mb_strlen($notifyUrl) < 0)) { - throw new \InvalidArgumentException('invalid length for $notifyUrl when calling WhatsAppInteractiveListMessage., must be bigger than or equal to 0.'); - } - - $this->container['notifyUrl'] = $notifyUrl; - + $this->notifyUrl = $notifyUrl; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppInteractiveListSectionContent.php b/Infobip/Model/WhatsAppInteractiveListSectionContent.php index 3b6a844..88980df 100644 --- a/Infobip/Model/WhatsAppInteractiveListSectionContent.php +++ b/Infobip/Model/WhatsAppInteractiveListSectionContent.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppInteractiveListSectionContent implements ModelInterface, ArrayAccess, \JsonSerializable +class WhatsAppInteractiveListSectionContent implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppInteractiveListSectionContent'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'title' => 'string', - 'rows' => '\Infobip\Model\WhatsAppInteractiveRowContent[]' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'WhatsAppInteractiveListSectionContent'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'title' => null, 'rows' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array + * @param \Infobip\Model\WhatsAppInteractiveRowContent[] $rows */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } + public function __construct( + #[Assert\NotBlank] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'title' => 'title', - 'rows' => 'rows' - ]; + protected array $rows, + #[Assert\Length(max: 24)] + #[Assert\Length(min: 0)] - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'title' => 'setTitle', - 'rows' => 'setRows' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'title' => 'getTitle', - 'rows' => 'getRows' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; + protected ?string $title = null, + ) { } - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public function getModelName(): string { - return self::$getters; + return self::OPENAPI_MODEL_NAME; } - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$openAPIModelName; + return self::DISCRIMINATOR; } - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) + public function getTitle(): string|null { - $this->container['title'] = $data['title'] ?? null; - $this->container['rows'] = $data['rows'] ?? null; + return $this->title; } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + public function setTitle(?string $title): self { - $invalidProperties = []; - - if (!is_null($this->container['title']) && (mb_strlen($this->container['title']) > 24)) { - $invalidProperties[] = "invalid value for 'title', the character length must be smaller than or equal to 24."; - } - - if (!is_null($this->container['title']) && (mb_strlen($this->container['title']) < 0)) { - $invalidProperties[] = "invalid value for 'title', the character length must be bigger than or equal to 0."; - } - - if ($this->container['rows'] === null) { - $invalidProperties[] = "'rows' can't be null"; - } - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets title - * - * @return string|null - */ - public function getTitle() - { - return $this->container['title']; - } - - /** - * Sets title - * - * @param string|null $title Title of the section. Required, if the message has more than one section. - * - * @return self - */ - public function setTitle($title) - { - if (!is_null($title) && (mb_strlen($title) > 24)) { - throw new \InvalidArgumentException('invalid length for $title when calling WhatsAppInteractiveListSectionContent., must be smaller than or equal to 24.'); - } - if (!is_null($title) && (mb_strlen($title) < 0)) { - throw new \InvalidArgumentException('invalid length for $title when calling WhatsAppInteractiveListSectionContent., must be bigger than or equal to 0.'); - } - - $this->container['title'] = $title; - + $this->title = $title; return $this; } /** - * Gets rows - * * @return \Infobip\Model\WhatsAppInteractiveRowContent[] */ - public function getRows() + public function getRows(): array { - return $this->container['rows']; + return $this->rows; } /** - * Sets rows - * * @param \Infobip\Model\WhatsAppInteractiveRowContent[] $rows An array of rows sent within a section. Section must contain at least one row. Message can have up to ten rows. - * - * @return self */ - public function setRows($rows) + public function setRows(array $rows): self { - $this->container['rows'] = $rows; - + $this->rows = $rows; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppInteractiveListTextHeaderContent.php b/Infobip/Model/WhatsAppInteractiveListTextHeaderContent.php index 11aa08c..0879b78 100644 --- a/Infobip/Model/WhatsAppInteractiveListTextHeaderContent.php +++ b/Infobip/Model/WhatsAppInteractiveListTextHeaderContent.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ class WhatsAppInteractiveListTextHeaderContent extends WhatsAppInteractiveListHeaderContent { public const DISCRIMINATOR = 'type'; + public const OPENAPI_MODEL_NAME = 'WhatsAppInteractiveListTextHeaderContent'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppInteractiveListTextHeaderContent'; + public const TYPE = 'TEXT'; - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'text' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'text' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes + parent::openAPITypes(); - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats + parent::openAPIFormats(); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'text' => 'text' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] */ - protected static $setters = [ - 'text' => 'setText' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'text' => 'getText' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return parent::attributeMap() + self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return parent::setters() + self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return parent::getters() + self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 60)] + #[Assert\Length(min: 1)] + protected string $text, + ) { + $modelDiscriminatorValue = 'TEXT'; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - parent::__construct($data); - - $this->container['text'] = $data['text'] ?? null; - - $this->container['type'] = 'TEXT'; + parent::__construct( + type: $modelDiscriminatorValue, + ); } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = parent::listInvalidProperties(); - - if ($this->container['text'] === null) { - $invalidProperties[] = "'text' can't be null"; - } - if ((mb_strlen($this->container['text']) > 60)) { - $invalidProperties[] = "invalid value for 'text', the character length must be smaller than or equal to 60."; - } - - if ((mb_strlen($this->container['text']) < 1)) { - $invalidProperties[] = "invalid value for 'text', the character length must be bigger than or equal to 1."; - } - - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets text - * - * @return string - */ - public function getText() + public function getText(): string { - return $this->container['text']; + return $this->text; } - /** - * Sets text - * - * @param string $text Content of the header used when creating an [interactive list](https://www.infobip.com/docs/whatsapp/message-types#interactive-lists-free-form-messages). - * - * @return self - */ - public function setText($text) + public function setText(string $text): self { - if ((mb_strlen($text) > 60)) { - throw new \InvalidArgumentException('invalid length for $text when calling WhatsAppInteractiveListTextHeaderContent., must be smaller than or equal to 60.'); - } - if ((mb_strlen($text) < 1)) { - throw new \InvalidArgumentException('invalid length for $text when calling WhatsAppInteractiveListTextHeaderContent., must be bigger than or equal to 1.'); - } - - $this->container['text'] = $text; - + $this->text = $text; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppInteractiveMultiProductActionContent.php b/Infobip/Model/WhatsAppInteractiveMultiProductActionContent.php new file mode 100644 index 0000000..5a650e8 --- /dev/null +++ b/Infobip/Model/WhatsAppInteractiveMultiProductActionContent.php @@ -0,0 +1,91 @@ + null, + 'sections' => null + ]; + + /** + * @param \Infobip\Model\WhatsAppInteractiveMultiProductSectionContent[] $sections + */ + public function __construct( + #[Assert\NotBlank] + + protected string $catalogId, + #[Assert\NotBlank] + #[Assert\Count(max: 10)] + #[Assert\Count(min: 1)] + + protected array $sections, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getCatalogId(): string + { + return $this->catalogId; + } + + public function setCatalogId(string $catalogId): self + { + $this->catalogId = $catalogId; + return $this; + } + + /** + * @return \Infobip\Model\WhatsAppInteractiveMultiProductSectionContent[] + */ + public function getSections(): array + { + return $this->sections; + } + + /** + * @param \Infobip\Model\WhatsAppInteractiveMultiProductSectionContent[] $sections An array of multi product sections. + */ + public function setSections(array $sections): self + { + $this->sections = $sections; + return $this; + } +} diff --git a/Infobip/Model/WhatsAppInteractiveMultiProductContent.php b/Infobip/Model/WhatsAppInteractiveMultiProductContent.php new file mode 100644 index 0000000..0ed9d47 --- /dev/null +++ b/Infobip/Model/WhatsAppInteractiveMultiProductContent.php @@ -0,0 +1,115 @@ + null, + 'body' => null, + 'action' => null, + 'footer' => null + ]; + + /** + */ + public function __construct( + #[Assert\Valid] + #[Assert\NotBlank] + + protected \Infobip\Model\WhatsAppInteractiveMultiProductHeaderContent $header, + #[Assert\Valid] + #[Assert\NotBlank] + + protected \Infobip\Model\WhatsAppInteractiveBodyContent $body, + #[Assert\Valid] + #[Assert\NotBlank] + + protected \Infobip\Model\WhatsAppInteractiveMultiProductActionContent $action, + #[Assert\Valid] + + protected ?\Infobip\Model\WhatsAppInteractiveFooterContent $footer = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getHeader(): \Infobip\Model\WhatsAppInteractiveMultiProductHeaderContent + { + return $this->header; + } + + public function setHeader(\Infobip\Model\WhatsAppInteractiveMultiProductHeaderContent $header): self + { + $this->header = $header; + return $this; + } + + public function getBody(): \Infobip\Model\WhatsAppInteractiveBodyContent + { + return $this->body; + } + + public function setBody(\Infobip\Model\WhatsAppInteractiveBodyContent $body): self + { + $this->body = $body; + return $this; + } + + public function getAction(): \Infobip\Model\WhatsAppInteractiveMultiProductActionContent + { + return $this->action; + } + + public function setAction(\Infobip\Model\WhatsAppInteractiveMultiProductActionContent $action): self + { + $this->action = $action; + return $this; + } + + public function getFooter(): \Infobip\Model\WhatsAppInteractiveFooterContent|null + { + return $this->footer; + } + + public function setFooter(?\Infobip\Model\WhatsAppInteractiveFooterContent $footer): self + { + $this->footer = $footer; + return $this; + } +} diff --git a/Infobip/Model/WhatsAppInteractiveMultiProductHeaderContent.php b/Infobip/Model/WhatsAppInteractiveMultiProductHeaderContent.php new file mode 100644 index 0000000..8ce3e59 --- /dev/null +++ b/Infobip/Model/WhatsAppInteractiveMultiProductHeaderContent.php @@ -0,0 +1,71 @@ + "\Infobip\Model\WhatsAppInteractiveMultiProductTextHeaderContent", + "WhatsAppInteractiveMultiProductTextHeaderContent" => "\Infobip\Model\WhatsAppInteractiveMultiProductTextHeaderContent", +])] +class WhatsAppInteractiveMultiProductHeaderContent implements ModelInterface +{ + public const DISCRIMINATOR = 'type'; + public const OPENAPI_MODEL_NAME = 'WhatsAppInteractiveMultiProductHeaderContent'; + + public const OPENAPI_FORMATS = [ + 'type' => null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + + protected string $type, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getType(): string + { + return $this->type; + } + + public function setType(string $type): self + { + $this->type = $type; + return $this; + } +} diff --git a/Infobip/Model/WhatsAppInteractiveMultiProductMessage.php b/Infobip/Model/WhatsAppInteractiveMultiProductMessage.php new file mode 100644 index 0000000..ba03927 --- /dev/null +++ b/Infobip/Model/WhatsAppInteractiveMultiProductMessage.php @@ -0,0 +1,150 @@ + null, + 'to' => null, + 'messageId' => null, + 'content' => null, + 'callbackData' => null, + 'notifyUrl' => null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 24)] + #[Assert\Length(min: 1)] + + protected string $from, + #[Assert\NotBlank] + #[Assert\Length(max: 24)] + #[Assert\Length(min: 1)] + + protected string $to, + #[Assert\Valid] + #[Assert\NotBlank] + + protected \Infobip\Model\WhatsAppInteractiveMultiProductContent $content, + #[Assert\Length(max: 100)] + #[Assert\Length(min: 0)] + + protected ?string $messageId = null, + #[Assert\Length(max: 4000)] + #[Assert\Length(min: 0)] + + protected ?string $callbackData = null, + #[Assert\Length(max: 2048)] + #[Assert\Length(min: 0)] + + protected ?string $notifyUrl = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getFrom(): string + { + return $this->from; + } + + public function setFrom(string $from): self + { + $this->from = $from; + return $this; + } + + public function getTo(): string + { + return $this->to; + } + + public function setTo(string $to): self + { + $this->to = $to; + return $this; + } + + public function getMessageId(): string|null + { + return $this->messageId; + } + + public function setMessageId(?string $messageId): self + { + $this->messageId = $messageId; + return $this; + } + + public function getContent(): \Infobip\Model\WhatsAppInteractiveMultiProductContent + { + return $this->content; + } + + public function setContent(\Infobip\Model\WhatsAppInteractiveMultiProductContent $content): self + { + $this->content = $content; + return $this; + } + + public function getCallbackData(): string|null + { + return $this->callbackData; + } + + public function setCallbackData(?string $callbackData): self + { + $this->callbackData = $callbackData; + return $this; + } + + public function getNotifyUrl(): string|null + { + return $this->notifyUrl; + } + + public function setNotifyUrl(?string $notifyUrl): self + { + $this->notifyUrl = $notifyUrl; + return $this; + } +} diff --git a/Infobip/Model/WhatsAppInteractiveMultiProductSectionContent.php b/Infobip/Model/WhatsAppInteractiveMultiProductSectionContent.php new file mode 100644 index 0000000..d5321a2 --- /dev/null +++ b/Infobip/Model/WhatsAppInteractiveMultiProductSectionContent.php @@ -0,0 +1,90 @@ + null, + 'productRetailerIds' => null + ]; + + /** + * @param string[] $productRetailerIds + */ + public function __construct( + #[Assert\NotBlank] + + protected array $productRetailerIds, + #[Assert\Length(max: 24)] + #[Assert\Length(min: 0)] + + protected ?string $title = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getTitle(): string|null + { + return $this->title; + } + + public function setTitle(?string $title): self + { + $this->title = $title; + return $this; + } + + /** + * @return string[] + */ + public function getProductRetailerIds(): array + { + return $this->productRetailerIds; + } + + /** + * @param string[] $productRetailerIds An array of product-unique identifiers as defined in the [catalog](https://www.infobip.com/docs/whatsapp/manage-connection#manage-catalog). If product retailer ID doesn't exist in your catalog, the product won't be displayed. + */ + public function setProductRetailerIds(array $productRetailerIds): self + { + $this->productRetailerIds = $productRetailerIds; + return $this; + } +} diff --git a/Infobip/Model/WhatsAppInteractiveMultiProductTextHeaderContent.php b/Infobip/Model/WhatsAppInteractiveMultiProductTextHeaderContent.php new file mode 100644 index 0000000..930ded5 --- /dev/null +++ b/Infobip/Model/WhatsAppInteractiveMultiProductTextHeaderContent.php @@ -0,0 +1,75 @@ + null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 60)] + #[Assert\Length(min: 1)] + + protected string $text, + ) { + $modelDiscriminatorValue = 'TEXT'; + + parent::__construct( + type: $modelDiscriminatorValue, + ); + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getText(): string + { + return $this->text; + } + + public function setText(string $text): self + { + $this->text = $text; + return $this; + } +} diff --git a/Infobip/Model/WhatsAppInteractiveProductActionContent.php b/Infobip/Model/WhatsAppInteractiveProductActionContent.php new file mode 100644 index 0000000..3e6013e --- /dev/null +++ b/Infobip/Model/WhatsAppInteractiveProductActionContent.php @@ -0,0 +1,82 @@ + null, + 'productRetailerId' => null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + + protected string $catalogId, + #[Assert\NotBlank] + + protected string $productRetailerId, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getCatalogId(): string + { + return $this->catalogId; + } + + public function setCatalogId(string $catalogId): self + { + $this->catalogId = $catalogId; + return $this; + } + + public function getProductRetailerId(): string + { + return $this->productRetailerId; + } + + public function setProductRetailerId(string $productRetailerId): self + { + $this->productRetailerId = $productRetailerId; + return $this; + } +} diff --git a/Infobip/Model/WhatsAppInteractiveProductContent.php b/Infobip/Model/WhatsAppInteractiveProductContent.php new file mode 100644 index 0000000..27d8ae8 --- /dev/null +++ b/Infobip/Model/WhatsAppInteractiveProductContent.php @@ -0,0 +1,98 @@ + null, + 'body' => null, + 'footer' => null + ]; + + /** + */ + public function __construct( + #[Assert\Valid] + #[Assert\NotBlank] + + protected \Infobip\Model\WhatsAppInteractiveProductActionContent $action, + #[Assert\Valid] + + protected ?\Infobip\Model\WhatsAppInteractiveBodyContent $body = null, + #[Assert\Valid] + + protected ?\Infobip\Model\WhatsAppInteractiveFooterContent $footer = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getAction(): \Infobip\Model\WhatsAppInteractiveProductActionContent + { + return $this->action; + } + + public function setAction(\Infobip\Model\WhatsAppInteractiveProductActionContent $action): self + { + $this->action = $action; + return $this; + } + + public function getBody(): \Infobip\Model\WhatsAppInteractiveBodyContent|null + { + return $this->body; + } + + public function setBody(?\Infobip\Model\WhatsAppInteractiveBodyContent $body): self + { + $this->body = $body; + return $this; + } + + public function getFooter(): \Infobip\Model\WhatsAppInteractiveFooterContent|null + { + return $this->footer; + } + + public function setFooter(?\Infobip\Model\WhatsAppInteractiveFooterContent $footer): self + { + $this->footer = $footer; + return $this; + } +} diff --git a/Infobip/Model/WhatsAppInteractiveProductMessage.php b/Infobip/Model/WhatsAppInteractiveProductMessage.php new file mode 100644 index 0000000..f1a31fc --- /dev/null +++ b/Infobip/Model/WhatsAppInteractiveProductMessage.php @@ -0,0 +1,150 @@ + null, + 'to' => null, + 'messageId' => null, + 'content' => null, + 'callbackData' => null, + 'notifyUrl' => null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 24)] + #[Assert\Length(min: 1)] + + protected string $from, + #[Assert\NotBlank] + #[Assert\Length(max: 24)] + #[Assert\Length(min: 1)] + + protected string $to, + #[Assert\Valid] + #[Assert\NotBlank] + + protected \Infobip\Model\WhatsAppInteractiveProductContent $content, + #[Assert\Length(max: 100)] + #[Assert\Length(min: 0)] + + protected ?string $messageId = null, + #[Assert\Length(max: 4000)] + #[Assert\Length(min: 0)] + + protected ?string $callbackData = null, + #[Assert\Length(max: 2048)] + #[Assert\Length(min: 0)] + + protected ?string $notifyUrl = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getFrom(): string + { + return $this->from; + } + + public function setFrom(string $from): self + { + $this->from = $from; + return $this; + } + + public function getTo(): string + { + return $this->to; + } + + public function setTo(string $to): self + { + $this->to = $to; + return $this; + } + + public function getMessageId(): string|null + { + return $this->messageId; + } + + public function setMessageId(?string $messageId): self + { + $this->messageId = $messageId; + return $this; + } + + public function getContent(): \Infobip\Model\WhatsAppInteractiveProductContent + { + return $this->content; + } + + public function setContent(\Infobip\Model\WhatsAppInteractiveProductContent $content): self + { + $this->content = $content; + return $this; + } + + public function getCallbackData(): string|null + { + return $this->callbackData; + } + + public function setCallbackData(?string $callbackData): self + { + $this->callbackData = $callbackData; + return $this; + } + + public function getNotifyUrl(): string|null + { + return $this->notifyUrl; + } + + public function setNotifyUrl(?string $notifyUrl): self + { + $this->notifyUrl = $notifyUrl; + return $this; + } +} diff --git a/Infobip/Model/WhatsAppInteractiveReplyButtonContent.php b/Infobip/Model/WhatsAppInteractiveReplyButtonContent.php index 9b5b40e..39773ea 100644 --- a/Infobip/Model/WhatsAppInteractiveReplyButtonContent.php +++ b/Infobip/Model/WhatsAppInteractiveReplyButtonContent.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ class WhatsAppInteractiveReplyButtonContent extends WhatsAppInteractiveButtonContent { public const DISCRIMINATOR = 'type'; + public const OPENAPI_MODEL_NAME = 'WhatsAppInteractiveReplyButtonContent'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppInteractiveReplyButtonContent'; + public const TYPE = 'REPLY'; - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'id' => 'string', - 'title' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'id' => null, 'title' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes + parent::openAPITypes(); - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats + parent::openAPIFormats(); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'id' => 'id', - 'title' => 'title' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'id' => 'setId', - 'title' => 'setTitle' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'id' => 'getId', - 'title' => 'getTitle' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return parent::attributeMap() + self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return parent::setters() + self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array */ - public static function getters() - { - return parent::getters() + self::$getters; - } + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 256)] + #[Assert\Length(min: 1)] - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - parent::__construct($data); + protected string $id, + #[Assert\NotBlank] + #[Assert\Length(max: 20)] + #[Assert\Length(min: 1)] - $this->container['id'] = $data['id'] ?? null; - $this->container['title'] = $data['title'] ?? null; + protected string $title, + ) { + $modelDiscriminatorValue = 'REPLY'; - $this->container['type'] = 'REPLY'; + parent::__construct( + type: $modelDiscriminatorValue, + ); } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = parent::listInvalidProperties(); - - if ($this->container['id'] === null) { - $invalidProperties[] = "'id' can't be null"; - } - if ((mb_strlen($this->container['id']) > 256)) { - $invalidProperties[] = "invalid value for 'id', the character length must be smaller than or equal to 256."; - } - - if ((mb_strlen($this->container['id']) < 1)) { - $invalidProperties[] = "invalid value for 'id', the character length must be bigger than or equal to 1."; - } - - if ($this->container['title'] === null) { - $invalidProperties[] = "'title' can't be null"; - } - if ((mb_strlen($this->container['title']) > 20)) { - $invalidProperties[] = "invalid value for 'title', the character length must be smaller than or equal to 20."; - } - - if ((mb_strlen($this->container['title']) < 1)) { - $invalidProperties[] = "invalid value for 'title', the character length must be bigger than or equal to 1."; - } - - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets id - * - * @return string - */ - public function getId() + public function getId(): string { - return $this->container['id']; + return $this->id; } - /** - * Sets id - * - * @param string $id Unique identifier of the button containing no leading nor trailing whitespaces. - * - * @return self - */ - public function setId($id) + public function setId(string $id): self { - if ((mb_strlen($id) > 256)) { - throw new \InvalidArgumentException('invalid length for $id when calling WhatsAppInteractiveReplyButtonContent., must be smaller than or equal to 256.'); - } - if ((mb_strlen($id) < 1)) { - throw new \InvalidArgumentException('invalid length for $id when calling WhatsAppInteractiveReplyButtonContent., must be bigger than or equal to 1.'); - } - - $this->container['id'] = $id; - + $this->id = $id; return $this; } - /** - * Gets title - * - * @return string - */ - public function getTitle() + public function getTitle(): string { - return $this->container['title']; + return $this->title; } - /** - * Sets title - * - * @param string $title Unique title of the button. Doesn't allow emojis or markdown. - * - * @return self - */ - public function setTitle($title) + public function setTitle(string $title): self { - if ((mb_strlen($title) > 20)) { - throw new \InvalidArgumentException('invalid length for $title when calling WhatsAppInteractiveReplyButtonContent., must be smaller than or equal to 20.'); - } - if ((mb_strlen($title) < 1)) { - throw new \InvalidArgumentException('invalid length for $title when calling WhatsAppInteractiveReplyButtonContent., must be bigger than or equal to 1.'); - } - - $this->container['title'] = $title; - + $this->title = $title; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppInteractiveRowContent.php b/Infobip/Model/WhatsAppInteractiveRowContent.php index 87756f4..7d465af 100644 --- a/Infobip/Model/WhatsAppInteractiveRowContent.php +++ b/Infobip/Model/WhatsAppInteractiveRowContent.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppInteractiveRowContent implements ModelInterface, ArrayAccess, \JsonSerializable +class WhatsAppInteractiveRowContent implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppInteractiveRowContent'; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'WhatsAppInteractiveRowContent'; - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'id' => 'string', - 'title' => 'string', - 'description' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'id' => null, 'title' => null, 'description' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'id' => 'id', - 'title' => 'title', - 'description' => 'description' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'id' => 'setId', - 'title' => 'setTitle', - 'description' => 'setDescription' - ]; + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 200)] + #[Assert\Length(min: 1)] - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'id' => 'getId', - 'title' => 'getTitle', - 'description' => 'getDescription' - ]; + protected string $id, + #[Assert\NotBlank] + #[Assert\Length(max: 24)] + #[Assert\Length(min: 1)] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } + protected string $title, + #[Assert\Length(max: 72)] + #[Assert\Length(min: 0)] - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; + protected ?string $description = null, + ) { } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public function getModelName(): string { - return self::$getters; + return self::OPENAPI_MODEL_NAME; } - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$openAPIModelName; + return self::DISCRIMINATOR; } - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) + public function getId(): string { - $this->container['id'] = $data['id'] ?? null; - $this->container['title'] = $data['title'] ?? null; - $this->container['description'] = $data['description'] ?? null; + return $this->id; } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + public function setId(string $id): self { - $invalidProperties = []; - - if ($this->container['id'] === null) { - $invalidProperties[] = "'id' can't be null"; - } - if ((mb_strlen($this->container['id']) > 200)) { - $invalidProperties[] = "invalid value for 'id', the character length must be smaller than or equal to 200."; - } - - if ((mb_strlen($this->container['id']) < 1)) { - $invalidProperties[] = "invalid value for 'id', the character length must be bigger than or equal to 1."; - } - - if ($this->container['title'] === null) { - $invalidProperties[] = "'title' can't be null"; - } - if ((mb_strlen($this->container['title']) > 24)) { - $invalidProperties[] = "invalid value for 'title', the character length must be smaller than or equal to 24."; - } - - if ((mb_strlen($this->container['title']) < 1)) { - $invalidProperties[] = "invalid value for 'title', the character length must be bigger than or equal to 1."; - } - - if (!is_null($this->container['description']) && (mb_strlen($this->container['description']) > 72)) { - $invalidProperties[] = "invalid value for 'description', the character length must be smaller than or equal to 72."; - } - - if (!is_null($this->container['description']) && (mb_strlen($this->container['description']) < 0)) { - $invalidProperties[] = "invalid value for 'description', the character length must be bigger than or equal to 0."; - } - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets id - * - * @return string - */ - public function getId() - { - return $this->container['id']; - } - - /** - * Sets id - * - * @param string $id Identifier of the row. It must be unique across all sections. - * - * @return self - */ - public function setId($id) - { - if ((mb_strlen($id) > 200)) { - throw new \InvalidArgumentException('invalid length for $id when calling WhatsAppInteractiveRowContent., must be smaller than or equal to 200.'); - } - if ((mb_strlen($id) < 1)) { - throw new \InvalidArgumentException('invalid length for $id when calling WhatsAppInteractiveRowContent., must be bigger than or equal to 1.'); - } - - $this->container['id'] = $id; - + $this->id = $id; return $this; } - /** - * Gets title - * - * @return string - */ - public function getTitle() + public function getTitle(): string { - return $this->container['title']; + return $this->title; } - /** - * Sets title - * - * @param string $title Title of the row. - * - * @return self - */ - public function setTitle($title) + public function setTitle(string $title): self { - if ((mb_strlen($title) > 24)) { - throw new \InvalidArgumentException('invalid length for $title when calling WhatsAppInteractiveRowContent., must be smaller than or equal to 24.'); - } - if ((mb_strlen($title) < 1)) { - throw new \InvalidArgumentException('invalid length for $title when calling WhatsAppInteractiveRowContent., must be bigger than or equal to 1.'); - } - - $this->container['title'] = $title; - + $this->title = $title; return $this; } - /** - * Gets description - * - * @return string|null - */ - public function getDescription() + public function getDescription(): string|null { - return $this->container['description']; + return $this->description; } - /** - * Sets description - * - * @param string|null $description Description of the row. - * - * @return self - */ - public function setDescription($description) + public function setDescription(?string $description): self { - if (!is_null($description) && (mb_strlen($description) > 72)) { - throw new \InvalidArgumentException('invalid length for $description when calling WhatsAppInteractiveRowContent., must be smaller than or equal to 72.'); - } - if (!is_null($description) && (mb_strlen($description) < 0)) { - throw new \InvalidArgumentException('invalid length for $description when calling WhatsAppInteractiveRowContent., must be bigger than or equal to 0.'); - } - - $this->container['description'] = $description; - + $this->description = $description; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppLanguage.php b/Infobip/Model/WhatsAppLanguage.php index f853113..33115d2 100644 --- a/Infobip/Model/WhatsAppLanguage.php +++ b/Infobip/Model/WhatsAppLanguage.php @@ -1,14 +1,8 @@ value = $value; + } + + public static function AF(): WhatsAppLanguage + { + return new self('af'); + } + + public static function SQ(): WhatsAppLanguage + { + return new self('sq'); + } + + public static function AR(): WhatsAppLanguage + { + return new self('ar'); + } + + public static function AZ(): WhatsAppLanguage + { + return new self('az'); + } + + public static function BN(): WhatsAppLanguage + { + return new self('bn'); + } + + public static function BG(): WhatsAppLanguage + { + return new self('bg'); + } + + public static function CA(): WhatsAppLanguage + { + return new self('ca'); + } + + public static function ZH_CN(): WhatsAppLanguage + { + return new self('zh_CN'); + } + + public static function ZH_HK(): WhatsAppLanguage + { + return new self('zh_HK'); + } + + public static function ZH_TW(): WhatsAppLanguage + { + return new self('zh_TW'); + } + + public static function HR(): WhatsAppLanguage + { + return new self('hr'); + } + + public static function CS(): WhatsAppLanguage + { + return new self('cs'); + } + + public static function DA(): WhatsAppLanguage + { + return new self('da'); + } + + public static function NL(): WhatsAppLanguage + { + return new self('nl'); + } + + public static function EN(): WhatsAppLanguage + { + return new self('en'); + } + + public static function EN_GB(): WhatsAppLanguage + { + return new self('en_GB'); + } + + public static function EN_US(): WhatsAppLanguage + { + return new self('en_US'); + } + + public static function ET(): WhatsAppLanguage + { + return new self('et'); + } + + public static function FIL(): WhatsAppLanguage + { + return new self('fil'); + } + + public static function FI(): WhatsAppLanguage + { + return new self('fi'); + } + + public static function FR(): WhatsAppLanguage + { + return new self('fr'); + } + + public static function KA(): WhatsAppLanguage + { + return new self('ka'); + } + + public static function DE(): WhatsAppLanguage + { + return new self('de'); + } + + public static function EL(): WhatsAppLanguage + { + return new self('el'); + } + + public static function GU(): WhatsAppLanguage + { + return new self('gu'); + } + + public static function HA(): WhatsAppLanguage + { + return new self('ha'); + } + + public static function HE(): WhatsAppLanguage + { + return new self('he'); + } + + public static function HI(): WhatsAppLanguage + { + return new self('hi'); + } + + public static function HU(): WhatsAppLanguage + { + return new self('hu'); + } + + public static function ID(): WhatsAppLanguage + { + return new self('id'); + } + + public static function GA(): WhatsAppLanguage + { + return new self('ga'); + } + + public static function IT(): WhatsAppLanguage + { + return new self('it'); + } + + public static function JA(): WhatsAppLanguage + { + return new self('ja'); + } + + public static function KN(): WhatsAppLanguage + { + return new self('kn'); + } + + public static function KK(): WhatsAppLanguage + { + return new self('kk'); + } + + public static function RW_RW(): WhatsAppLanguage + { + return new self('rw_RW'); + } + + public static function KO(): WhatsAppLanguage + { + return new self('ko'); + } + + public static function KY_KG(): WhatsAppLanguage + { + return new self('ky_KG'); + } + + public static function LO(): WhatsAppLanguage + { + return new self('lo'); + } + + public static function LV(): WhatsAppLanguage + { + return new self('lv'); + } + + public static function LT(): WhatsAppLanguage + { + return new self('lt'); + } + + public static function MK(): WhatsAppLanguage + { + return new self('mk'); + } + + public static function MS(): WhatsAppLanguage + { + return new self('ms'); + } + + public static function ML(): WhatsAppLanguage + { + return new self('ml'); + } + + public static function MR(): WhatsAppLanguage + { + return new self('mr'); + } + + public static function NB(): WhatsAppLanguage + { + return new self('nb'); + } + + public static function FA(): WhatsAppLanguage + { + return new self('fa'); + } + + public static function PL(): WhatsAppLanguage + { + return new self('pl'); + } + + public static function PT_BR(): WhatsAppLanguage + { + return new self('pt_BR'); + } + + public static function PT_PT(): WhatsAppLanguage + { + return new self('pt_PT'); + } + + public static function PA(): WhatsAppLanguage + { + return new self('pa'); + } + + public static function RO(): WhatsAppLanguage + { + return new self('ro'); + } + + public static function RU(): WhatsAppLanguage + { + return new self('ru'); + } + + public static function SR(): WhatsAppLanguage + { + return new self('sr'); + } + + public static function SK(): WhatsAppLanguage + { + return new self('sk'); + } + + public static function SL(): WhatsAppLanguage + { + return new self('sl'); + } + + public static function ES(): WhatsAppLanguage + { + return new self('es'); + } + + public static function ES_AR(): WhatsAppLanguage + { + return new self('es_AR'); + } + + public static function ES_ES(): WhatsAppLanguage + { + return new self('es_ES'); + } + + public static function ES_MX(): WhatsAppLanguage + { + return new self('es_MX'); + } + + public static function SW(): WhatsAppLanguage + { + return new self('sw'); + } + + public static function SV(): WhatsAppLanguage + { + return new self('sv'); + } + + public static function TA(): WhatsAppLanguage + { + return new self('ta'); + } + + public static function TE(): WhatsAppLanguage + { + return new self('te'); + } + + public static function TH(): WhatsAppLanguage + { + return new self('th'); + } + + public static function TR(): WhatsAppLanguage + { + return new self('tr'); + } + + public static function UK(): WhatsAppLanguage + { + return new self('uk'); + } + + public static function UR(): WhatsAppLanguage + { + return new self('ur'); + } + + public static function UZ(): WhatsAppLanguage + { + return new self('uz'); + } + + public static function VI(): WhatsAppLanguage + { + return new self('vi'); + } + + public static function ZU(): WhatsAppLanguage + { + return new self('zu'); + } + + public static function UNKNOWN(): WhatsAppLanguage + { + return new self('unknown'); + } + + public function __toString(): string + { + return $this->value; } } diff --git a/Infobip/Model/WhatsAppLocationContent.php b/Infobip/Model/WhatsAppLocationContent.php index b9cd9f2..cac2579 100644 --- a/Infobip/Model/WhatsAppLocationContent.php +++ b/Infobip/Model/WhatsAppLocationContent.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppLocationContent implements ModelInterface, ArrayAccess, \JsonSerializable +class WhatsAppLocationContent implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppLocationContent'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'latitude' => 'double', - 'longitude' => 'double', - 'name' => 'string', - 'address' => 'string' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'WhatsAppLocationContent'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'latitude' => 'double', 'longitude' => 'double', 'name' => null, @@ -76,398 +37,82 @@ class WhatsAppLocationContent implements ModelInterface, ArrayAccess, \JsonSeria ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'latitude' => 'latitude', - 'longitude' => 'longitude', - 'name' => 'name', - 'address' => 'address' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'latitude' => 'setLatitude', - 'longitude' => 'setLongitude', - 'name' => 'setName', - 'address' => 'setAddress' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'latitude' => 'getLatitude', - 'longitude' => 'getLongitude', - 'name' => 'getName', - 'address' => 'getAddress' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string */ - public function getModelName() - { - return self::$openAPIModelName; - } - + public function __construct( + #[Assert\NotBlank] + #[Assert\LessThan(90)] + #[Assert\GreaterThan(-90)] + protected float $latitude, + #[Assert\NotBlank] + #[Assert\LessThan(180)] + #[Assert\GreaterThan(-180)] + protected float $longitude, + #[Assert\Length(max: 1000)] + #[Assert\Length(min: 0)] + protected ?string $name = null, + #[Assert\Length(max: 1000)] + #[Assert\Length(min: 0)] - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['latitude'] = $data['latitude'] ?? null; - $this->container['longitude'] = $data['longitude'] ?? null; - $this->container['name'] = $data['name'] ?? null; - $this->container['address'] = $data['address'] ?? null; + protected ?string $address = null, + ) { } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - if ($this->container['latitude'] === null) { - $invalidProperties[] = "'latitude' can't be null"; - } - if (($this->container['latitude'] > 90)) { - $invalidProperties[] = "invalid value for 'latitude', must be smaller than or equal to 90."; - } - - if (($this->container['latitude'] < -90)) { - $invalidProperties[] = "invalid value for 'latitude', must be bigger than or equal to -90."; - } - - if ($this->container['longitude'] === null) { - $invalidProperties[] = "'longitude' can't be null"; - } - if (($this->container['longitude'] > 180)) { - $invalidProperties[] = "invalid value for 'longitude', must be smaller than or equal to 180."; - } - - if (($this->container['longitude'] < -180)) { - $invalidProperties[] = "invalid value for 'longitude', must be bigger than or equal to -180."; - } - - if (!is_null($this->container['name']) && (mb_strlen($this->container['name']) > 1000)) { - $invalidProperties[] = "invalid value for 'name', the character length must be smaller than or equal to 1000."; - } - - if (!is_null($this->container['name']) && (mb_strlen($this->container['name']) < 0)) { - $invalidProperties[] = "invalid value for 'name', the character length must be bigger than or equal to 0."; - } - - if (!is_null($this->container['address']) && (mb_strlen($this->container['address']) > 1000)) { - $invalidProperties[] = "invalid value for 'address', the character length must be smaller than or equal to 1000."; - } - - if (!is_null($this->container['address']) && (mb_strlen($this->container['address']) < 0)) { - $invalidProperties[] = "invalid value for 'address', the character length must be bigger than or equal to 0."; - } - - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets latitude - * - * @return double - */ - public function getLatitude() + public function getLatitude(): float { - return $this->container['latitude']; + return $this->latitude; } - /** - * Sets latitude - * - * @param double $latitude Latitude of a location sent in the WhatsApp message. - * - * @return self - */ - public function setLatitude($latitude) + public function setLatitude(float $latitude): self { - if (($latitude > 90)) { - throw new \InvalidArgumentException('invalid value for $latitude when calling WhatsAppLocationContent., must be smaller than or equal to 90.'); - } - if (($latitude < -90)) { - throw new \InvalidArgumentException('invalid value for $latitude when calling WhatsAppLocationContent., must be bigger than or equal to -90.'); - } - - $this->container['latitude'] = $latitude; - + $this->latitude = $latitude; return $this; } - /** - * Gets longitude - * - * @return double - */ - public function getLongitude() + public function getLongitude(): float { - return $this->container['longitude']; + return $this->longitude; } - /** - * Sets longitude - * - * @param double $longitude Longitude of a location sent in the WhatsApp message. - * - * @return self - */ - public function setLongitude($longitude) + public function setLongitude(float $longitude): self { - if (($longitude > 180)) { - throw new \InvalidArgumentException('invalid value for $longitude when calling WhatsAppLocationContent., must be smaller than or equal to 180.'); - } - if (($longitude < -180)) { - throw new \InvalidArgumentException('invalid value for $longitude when calling WhatsAppLocationContent., must be bigger than or equal to -180.'); - } - - $this->container['longitude'] = $longitude; - + $this->longitude = $longitude; return $this; } - /** - * Gets name - * - * @return string|null - */ - public function getName() + public function getName(): string|null { - return $this->container['name']; + return $this->name; } - /** - * Sets name - * - * @param string|null $name Location name. - * - * @return self - */ - public function setName($name) + public function setName(?string $name): self { - if (!is_null($name) && (mb_strlen($name) > 1000)) { - throw new \InvalidArgumentException('invalid length for $name when calling WhatsAppLocationContent., must be smaller than or equal to 1000.'); - } - if (!is_null($name) && (mb_strlen($name) < 0)) { - throw new \InvalidArgumentException('invalid length for $name when calling WhatsAppLocationContent., must be bigger than or equal to 0.'); - } - - $this->container['name'] = $name; - + $this->name = $name; return $this; } - /** - * Gets address - * - * @return string|null - */ - public function getAddress() + public function getAddress(): string|null { - return $this->container['address']; + return $this->address; } - /** - * Sets address - * - * @param string|null $address Location address. - * - * @return self - */ - public function setAddress($address) + public function setAddress(?string $address): self { - if (!is_null($address) && (mb_strlen($address) > 1000)) { - throw new \InvalidArgumentException('invalid length for $address when calling WhatsAppLocationContent., must be smaller than or equal to 1000.'); - } - if (!is_null($address) && (mb_strlen($address) < 0)) { - throw new \InvalidArgumentException('invalid length for $address when calling WhatsAppLocationContent., must be bigger than or equal to 0.'); - } - - $this->container['address'] = $address; - + $this->address = $address; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppLocationHeaderApiData.php b/Infobip/Model/WhatsAppLocationHeaderApiData.php index bd7e215..3b9a1e1 100644 --- a/Infobip/Model/WhatsAppLocationHeaderApiData.php +++ b/Infobip/Model/WhatsAppLocationHeaderApiData.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ class WhatsAppLocationHeaderApiData extends WhatsAppHeaderApiData { public const DISCRIMINATOR = 'format'; + public const OPENAPI_MODEL_NAME = 'WhatsAppLocationHeaderApiData'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppLocationHeaderApiData'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - - ]; + public const FORMAT = 'LOCATION'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes + parent::openAPITypes(); - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array */ - public static function openAPIFormats() - { - return self::$openAPIFormats + parent::openAPIFormats(); - } + public function __construct( - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ + ) { + $modelDiscriminatorValue = 'LOCATION'; - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return parent::attributeMap() + self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return parent::setters() + self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return parent::getters() + self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - parent::__construct($data); - - - $this->container['format'] = 'LOCATION'; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = parent::listInvalidProperties(); - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); + parent::__construct( + format: $modelDiscriminatorValue, + ); } - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() + #[Ignore] + public function getModelName(): string { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); + return self::OPENAPI_MODEL_NAME; } - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() + #[Ignore] + public static function getDiscriminator(): ?string { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + return self::DISCRIMINATOR; } } diff --git a/Infobip/Model/WhatsAppLocationMessage.php b/Infobip/Model/WhatsAppLocationMessage.php index 30230b5..e91e795 100644 --- a/Infobip/Model/WhatsAppLocationMessage.php +++ b/Infobip/Model/WhatsAppLocationMessage.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppLocationMessage implements ModelInterface, ArrayAccess, \JsonSerializable +class WhatsAppLocationMessage implements ModelInterface { - public const DISCRIMINATOR = null; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'WhatsAppLocationMessage'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppLocationMessage'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'from' => 'string', - 'to' => 'string', - 'messageId' => 'string', - 'content' => '\Infobip\Model\WhatsAppLocationContent', - 'callbackData' => 'string', - 'notifyUrl' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'from' => null, 'to' => null, 'messageId' => null, @@ -79,472 +39,112 @@ class WhatsAppLocationMessage implements ModelInterface, ArrayAccess, \JsonSeria ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array */ - public static function openAPITypes() - { - return self::$openAPITypes; - } + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 24)] + #[Assert\Length(min: 1)] - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } + protected string $from, + #[Assert\NotBlank] + #[Assert\Length(max: 24)] + #[Assert\Length(min: 1)] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'from' => 'from', - 'to' => 'to', - 'messageId' => 'messageId', - 'content' => 'content', - 'callbackData' => 'callbackData', - 'notifyUrl' => 'notifyUrl' - ]; + protected string $to, + #[Assert\Valid] + #[Assert\NotBlank] - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'from' => 'setFrom', - 'to' => 'setTo', - 'messageId' => 'setMessageId', - 'content' => 'setContent', - 'callbackData' => 'setCallbackData', - 'notifyUrl' => 'setNotifyUrl' - ]; + protected \Infobip\Model\WhatsAppLocationContent $content, + #[Assert\Length(max: 100)] + #[Assert\Length(min: 0)] - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'from' => 'getFrom', - 'to' => 'getTo', - 'messageId' => 'getMessageId', - 'content' => 'getContent', - 'callbackData' => 'getCallbackData', - 'notifyUrl' => 'getNotifyUrl' - ]; + protected ?string $messageId = null, + #[Assert\Length(max: 4000)] + #[Assert\Length(min: 0)] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } + protected ?string $callbackData = null, + #[Assert\Length(max: 2048)] + #[Assert\Length(min: 0)] - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; + protected ?string $notifyUrl = null, + ) { } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public function getModelName(): string { - return self::$getters; + return self::OPENAPI_MODEL_NAME; } - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) + #[Ignore] + public static function getDiscriminator(): ?string { - $this->container['from'] = $data['from'] ?? null; - $this->container['to'] = $data['to'] ?? null; - $this->container['messageId'] = $data['messageId'] ?? null; - $this->container['content'] = $data['content'] ?? null; - $this->container['callbackData'] = $data['callbackData'] ?? null; - $this->container['notifyUrl'] = $data['notifyUrl'] ?? null; + return self::DISCRIMINATOR; } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + public function getFrom(): string { - $invalidProperties = []; - - if ($this->container['from'] === null) { - $invalidProperties[] = "'from' can't be null"; - } - if ((mb_strlen($this->container['from']) > 24)) { - $invalidProperties[] = "invalid value for 'from', the character length must be smaller than or equal to 24."; - } - - if ((mb_strlen($this->container['from']) < 1)) { - $invalidProperties[] = "invalid value for 'from', the character length must be bigger than or equal to 1."; - } - - if ($this->container['to'] === null) { - $invalidProperties[] = "'to' can't be null"; - } - if ((mb_strlen($this->container['to']) > 24)) { - $invalidProperties[] = "invalid value for 'to', the character length must be smaller than or equal to 24."; - } - - if ((mb_strlen($this->container['to']) < 1)) { - $invalidProperties[] = "invalid value for 'to', the character length must be bigger than or equal to 1."; - } - - if (!is_null($this->container['messageId']) && (mb_strlen($this->container['messageId']) > 50)) { - $invalidProperties[] = "invalid value for 'messageId', the character length must be smaller than or equal to 50."; - } - - if (!is_null($this->container['messageId']) && (mb_strlen($this->container['messageId']) < 0)) { - $invalidProperties[] = "invalid value for 'messageId', the character length must be bigger than or equal to 0."; - } - - if ($this->container['content'] === null) { - $invalidProperties[] = "'content' can't be null"; - } - if (!is_null($this->container['callbackData']) && (mb_strlen($this->container['callbackData']) > 4000)) { - $invalidProperties[] = "invalid value for 'callbackData', the character length must be smaller than or equal to 4000."; - } - - if (!is_null($this->container['callbackData']) && (mb_strlen($this->container['callbackData']) < 0)) { - $invalidProperties[] = "invalid value for 'callbackData', the character length must be bigger than or equal to 0."; - } - - if (!is_null($this->container['notifyUrl']) && (mb_strlen($this->container['notifyUrl']) > 2048)) { - $invalidProperties[] = "invalid value for 'notifyUrl', the character length must be smaller than or equal to 2048."; - } - - if (!is_null($this->container['notifyUrl']) && (mb_strlen($this->container['notifyUrl']) < 0)) { - $invalidProperties[] = "invalid value for 'notifyUrl', the character length must be bigger than or equal to 0."; - } - - return $invalidProperties; + return $this->from; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + public function setFrom(string $from): self { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets from - * - * @return string - */ - public function getFrom() - { - return $this->container['from']; - } - - /** - * Sets from - * - * @param string $from Registered WhatsApp sender number. Must be in international format and comply with [WhatsApp's requirements](https://www.infobip.com/docs/whatsapp/get-started#phone-number-what-you-need-to-know). - * - * @return self - */ - public function setFrom($from) - { - if ((mb_strlen($from) > 24)) { - throw new \InvalidArgumentException('invalid length for $from when calling WhatsAppLocationMessage., must be smaller than or equal to 24.'); - } - if ((mb_strlen($from) < 1)) { - throw new \InvalidArgumentException('invalid length for $from when calling WhatsAppLocationMessage., must be bigger than or equal to 1.'); - } - - $this->container['from'] = $from; - + $this->from = $from; return $this; } - /** - * Gets to - * - * @return string - */ - public function getTo() + public function getTo(): string { - return $this->container['to']; + return $this->to; } - /** - * Sets to - * - * @param string $to Message recipient number. Must be in international format. - * - * @return self - */ - public function setTo($to) + public function setTo(string $to): self { - if ((mb_strlen($to) > 24)) { - throw new \InvalidArgumentException('invalid length for $to when calling WhatsAppLocationMessage., must be smaller than or equal to 24.'); - } - if ((mb_strlen($to) < 1)) { - throw new \InvalidArgumentException('invalid length for $to when calling WhatsAppLocationMessage., must be bigger than or equal to 1.'); - } - - $this->container['to'] = $to; - + $this->to = $to; return $this; } - /** - * Gets messageId - * - * @return string|null - */ - public function getMessageId() + public function getMessageId(): string|null { - return $this->container['messageId']; + return $this->messageId; } - /** - * Sets messageId - * - * @param string|null $messageId The ID that uniquely identifies the message sent. - * - * @return self - */ - public function setMessageId($messageId) + public function setMessageId(?string $messageId): self { - if (!is_null($messageId) && (mb_strlen($messageId) > 50)) { - throw new \InvalidArgumentException('invalid length for $messageId when calling WhatsAppLocationMessage., must be smaller than or equal to 50.'); - } - if (!is_null($messageId) && (mb_strlen($messageId) < 0)) { - throw new \InvalidArgumentException('invalid length for $messageId when calling WhatsAppLocationMessage., must be bigger than or equal to 0.'); - } - - $this->container['messageId'] = $messageId; - + $this->messageId = $messageId; return $this; } - /** - * Gets content - * - * @return \Infobip\Model\WhatsAppLocationContent - */ - public function getContent() + public function getContent(): \Infobip\Model\WhatsAppLocationContent { - return $this->container['content']; + return $this->content; } - /** - * Sets content - * - * @param \Infobip\Model\WhatsAppLocationContent $content content - * - * @return self - */ - public function setContent($content) + public function setContent(\Infobip\Model\WhatsAppLocationContent $content): self { - $this->container['content'] = $content; - + $this->content = $content; return $this; } - /** - * Gets callbackData - * - * @return string|null - */ - public function getCallbackData() + public function getCallbackData(): string|null { - return $this->container['callbackData']; + return $this->callbackData; } - /** - * Sets callbackData - * - * @param string|null $callbackData Custom client data that will be included in a [Delivery Report](#channels/whatsapp/receive-whatsapp-delivery-reports). - * - * @return self - */ - public function setCallbackData($callbackData) + public function setCallbackData(?string $callbackData): self { - if (!is_null($callbackData) && (mb_strlen($callbackData) > 4000)) { - throw new \InvalidArgumentException('invalid length for $callbackData when calling WhatsAppLocationMessage., must be smaller than or equal to 4000.'); - } - if (!is_null($callbackData) && (mb_strlen($callbackData) < 0)) { - throw new \InvalidArgumentException('invalid length for $callbackData when calling WhatsAppLocationMessage., must be bigger than or equal to 0.'); - } - - $this->container['callbackData'] = $callbackData; - + $this->callbackData = $callbackData; return $this; } - /** - * Gets notifyUrl - * - * @return string|null - */ - public function getNotifyUrl() + public function getNotifyUrl(): string|null { - return $this->container['notifyUrl']; + return $this->notifyUrl; } - /** - * Sets notifyUrl - * - * @param string|null $notifyUrl The URL on your callback server to which delivery and seen reports will be sent. [Delivery report format](#channels/whatsapp/receive-whatsapp-delivery-reports), [Seen report format](#channels/whatsapp/receive-whatsapp-seen-reports). - * - * @return self - */ - public function setNotifyUrl($notifyUrl) + public function setNotifyUrl(?string $notifyUrl): self { - if (!is_null($notifyUrl) && (mb_strlen($notifyUrl) > 2048)) { - throw new \InvalidArgumentException('invalid length for $notifyUrl when calling WhatsAppLocationMessage., must be smaller than or equal to 2048.'); - } - if (!is_null($notifyUrl) && (mb_strlen($notifyUrl) < 0)) { - throw new \InvalidArgumentException('invalid length for $notifyUrl when calling WhatsAppLocationMessage., must be bigger than or equal to 0.'); - } - - $this->container['notifyUrl'] = $notifyUrl; - + $this->notifyUrl = $notifyUrl; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppMarkAsReadErrorResponse.php b/Infobip/Model/WhatsAppMarkAsReadErrorResponse.php index 57d4204..d024c3f 100644 --- a/Infobip/Model/WhatsAppMarkAsReadErrorResponse.php +++ b/Infobip/Model/WhatsAppMarkAsReadErrorResponse.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppMarkAsReadErrorResponse implements ModelInterface, ArrayAccess, \JsonSerializable +class WhatsAppMarkAsReadErrorResponse implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppMarkAsReadErrorResponse'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'error' => 'string' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'WhatsAppMarkAsReadErrorResponse'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'error' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'error' => 'error' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'error' => 'setError' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'error' => 'getError' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array */ - public static function attributeMap() - { - return self::$attributeMap; + public function __construct( + protected ?string $error = null, + ) { } - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() + #[Ignore] + public function getModelName(): string { - return self::$setters; + return self::OPENAPI_MODEL_NAME; } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$getters; + return self::DISCRIMINATOR; } - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() + public function getError(): string|null { - return self::$openAPIModelName; + return $this->error; } - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) + public function setError(?string $error): self { - $this->container['error'] = $data['error'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $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() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets error - * - * @return string|null - */ - public function getError() - { - return $this->container['error']; - } - - /** - * Sets error - * - * @param string|null $error Error details - * - * @return self - */ - public function setError($error) - { - $this->container['error'] = $error; - + $this->error = $error; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppMessage.php b/Infobip/Model/WhatsAppMessage.php index f92b0bf..ebb186d 100644 --- a/Infobip/Model/WhatsAppMessage.php +++ b/Infobip/Model/WhatsAppMessage.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppMessage implements ModelInterface, ArrayAccess, \JsonSerializable +class WhatsAppMessage implements ModelInterface { - public const DISCRIMINATOR = null; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'WhatsAppMessage'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppMessage'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'from' => 'string', - 'to' => 'string', - 'messageId' => 'string', - 'content' => '\Infobip\Model\WhatsAppTemplateContent', - 'callbackData' => 'string', - 'notifyUrl' => 'string', - 'smsFailover' => '\Infobip\Model\WhatsAppFailover' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'from' => null, 'to' => null, 'messageId' => null, @@ -82,500 +40,126 @@ class WhatsAppMessage implements ModelInterface, ArrayAccess, \JsonSerializable ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array */ - public static function openAPITypes() - { - return self::$openAPITypes; - } + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 24)] + #[Assert\Length(min: 1)] - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } + protected string $from, + #[Assert\NotBlank] + #[Assert\Length(max: 24)] + #[Assert\Length(min: 1)] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'from' => 'from', - 'to' => 'to', - 'messageId' => 'messageId', - 'content' => 'content', - 'callbackData' => 'callbackData', - 'notifyUrl' => 'notifyUrl', - 'smsFailover' => 'smsFailover' - ]; + protected string $to, + #[Assert\Valid] + #[Assert\NotBlank] - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'from' => 'setFrom', - 'to' => 'setTo', - 'messageId' => 'setMessageId', - 'content' => 'setContent', - 'callbackData' => 'setCallbackData', - 'notifyUrl' => 'setNotifyUrl', - 'smsFailover' => 'setSmsFailover' - ]; + protected \Infobip\Model\WhatsAppTemplateContent $content, + #[Assert\Length(max: 100)] + #[Assert\Length(min: 0)] - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'from' => 'getFrom', - 'to' => 'getTo', - 'messageId' => 'getMessageId', - 'content' => 'getContent', - 'callbackData' => 'getCallbackData', - 'notifyUrl' => 'getNotifyUrl', - 'smsFailover' => 'getSmsFailover' - ]; + protected ?string $messageId = null, + #[Assert\Length(max: 4000)] + #[Assert\Length(min: 0)] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } + protected ?string $callbackData = null, + #[Assert\Length(max: 2048)] + #[Assert\Length(min: 0)] - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } + protected ?string $notifyUrl = null, + #[Assert\Valid] - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; + protected ?\Infobip\Model\WhatsAppFailover $smsFailover = null, + ) { } - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() + #[Ignore] + public function getModelName(): string { - return self::$openAPIModelName; + return self::OPENAPI_MODEL_NAME; } - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) + #[Ignore] + public static function getDiscriminator(): ?string { - $this->container['from'] = $data['from'] ?? null; - $this->container['to'] = $data['to'] ?? null; - $this->container['messageId'] = $data['messageId'] ?? null; - $this->container['content'] = $data['content'] ?? null; - $this->container['callbackData'] = $data['callbackData'] ?? null; - $this->container['notifyUrl'] = $data['notifyUrl'] ?? null; - $this->container['smsFailover'] = $data['smsFailover'] ?? null; + return self::DISCRIMINATOR; } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + public function getFrom(): string { - $invalidProperties = []; - - if ($this->container['from'] === null) { - $invalidProperties[] = "'from' can't be null"; - } - if ((mb_strlen($this->container['from']) > 24)) { - $invalidProperties[] = "invalid value for 'from', the character length must be smaller than or equal to 24."; - } - - if ((mb_strlen($this->container['from']) < 1)) { - $invalidProperties[] = "invalid value for 'from', the character length must be bigger than or equal to 1."; - } - - if ($this->container['to'] === null) { - $invalidProperties[] = "'to' can't be null"; - } - if ((mb_strlen($this->container['to']) > 24)) { - $invalidProperties[] = "invalid value for 'to', the character length must be smaller than or equal to 24."; - } - - if ((mb_strlen($this->container['to']) < 1)) { - $invalidProperties[] = "invalid value for 'to', the character length must be bigger than or equal to 1."; - } - - if (!is_null($this->container['messageId']) && (mb_strlen($this->container['messageId']) > 50)) { - $invalidProperties[] = "invalid value for 'messageId', the character length must be smaller than or equal to 50."; - } - - if (!is_null($this->container['messageId']) && (mb_strlen($this->container['messageId']) < 0)) { - $invalidProperties[] = "invalid value for 'messageId', the character length must be bigger than or equal to 0."; - } - - if ($this->container['content'] === null) { - $invalidProperties[] = "'content' can't be null"; - } - if (!is_null($this->container['callbackData']) && (mb_strlen($this->container['callbackData']) > 4000)) { - $invalidProperties[] = "invalid value for 'callbackData', the character length must be smaller than or equal to 4000."; - } - - if (!is_null($this->container['callbackData']) && (mb_strlen($this->container['callbackData']) < 0)) { - $invalidProperties[] = "invalid value for 'callbackData', the character length must be bigger than or equal to 0."; - } - - if (!is_null($this->container['notifyUrl']) && (mb_strlen($this->container['notifyUrl']) > 2048)) { - $invalidProperties[] = "invalid value for 'notifyUrl', the character length must be smaller than or equal to 2048."; - } - - if (!is_null($this->container['notifyUrl']) && (mb_strlen($this->container['notifyUrl']) < 0)) { - $invalidProperties[] = "invalid value for 'notifyUrl', the character length must be bigger than or equal to 0."; - } - - return $invalidProperties; + return $this->from; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + public function setFrom(string $from): self { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets from - * - * @return string - */ - public function getFrom() - { - return $this->container['from']; - } - - /** - * Sets from - * - * @param string $from Registered WhatsApp sender number. Must be in international format and comply with [WhatsApp's requirements](https://www.infobip.com/docs/whatsapp/get-started#phone-number-what-you-need-to-know). - * - * @return self - */ - public function setFrom($from) - { - if ((mb_strlen($from) > 24)) { - throw new \InvalidArgumentException('invalid length for $from when calling WhatsAppMessage., must be smaller than or equal to 24.'); - } - if ((mb_strlen($from) < 1)) { - throw new \InvalidArgumentException('invalid length for $from when calling WhatsAppMessage., must be bigger than or equal to 1.'); - } - - $this->container['from'] = $from; - + $this->from = $from; return $this; } - /** - * Gets to - * - * @return string - */ - public function getTo() + public function getTo(): string { - return $this->container['to']; + return $this->to; } - /** - * Sets to - * - * @param string $to Message recipient number. Must be in international format. - * - * @return self - */ - public function setTo($to) + public function setTo(string $to): self { - if ((mb_strlen($to) > 24)) { - throw new \InvalidArgumentException('invalid length for $to when calling WhatsAppMessage., must be smaller than or equal to 24.'); - } - if ((mb_strlen($to) < 1)) { - throw new \InvalidArgumentException('invalid length for $to when calling WhatsAppMessage., must be bigger than or equal to 1.'); - } - - $this->container['to'] = $to; - + $this->to = $to; return $this; } - /** - * Gets messageId - * - * @return string|null - */ - public function getMessageId() + public function getMessageId(): string|null { - return $this->container['messageId']; + return $this->messageId; } - /** - * Sets messageId - * - * @param string|null $messageId The ID that uniquely identifies the message sent. - * - * @return self - */ - public function setMessageId($messageId) + public function setMessageId(?string $messageId): self { - if (!is_null($messageId) && (mb_strlen($messageId) > 50)) { - throw new \InvalidArgumentException('invalid length for $messageId when calling WhatsAppMessage., must be smaller than or equal to 50.'); - } - if (!is_null($messageId) && (mb_strlen($messageId) < 0)) { - throw new \InvalidArgumentException('invalid length for $messageId when calling WhatsAppMessage., must be bigger than or equal to 0.'); - } - - $this->container['messageId'] = $messageId; - + $this->messageId = $messageId; return $this; } - /** - * Gets content - * - * @return \Infobip\Model\WhatsAppTemplateContent - */ - public function getContent() + public function getContent(): \Infobip\Model\WhatsAppTemplateContent { - return $this->container['content']; + return $this->content; } - /** - * Sets content - * - * @param \Infobip\Model\WhatsAppTemplateContent $content content - * - * @return self - */ - public function setContent($content) + public function setContent(\Infobip\Model\WhatsAppTemplateContent $content): self { - $this->container['content'] = $content; - + $this->content = $content; return $this; } - /** - * Gets callbackData - * - * @return string|null - */ - public function getCallbackData() + public function getCallbackData(): string|null { - return $this->container['callbackData']; + return $this->callbackData; } - /** - * Sets callbackData - * - * @param string|null $callbackData Custom client data that will be included in a [Delivery Report](#channels/whatsapp/receive-whatsapp-delivery-reports). - * - * @return self - */ - public function setCallbackData($callbackData) + public function setCallbackData(?string $callbackData): self { - if (!is_null($callbackData) && (mb_strlen($callbackData) > 4000)) { - throw new \InvalidArgumentException('invalid length for $callbackData when calling WhatsAppMessage., must be smaller than or equal to 4000.'); - } - if (!is_null($callbackData) && (mb_strlen($callbackData) < 0)) { - throw new \InvalidArgumentException('invalid length for $callbackData when calling WhatsAppMessage., must be bigger than or equal to 0.'); - } - - $this->container['callbackData'] = $callbackData; - + $this->callbackData = $callbackData; return $this; } - /** - * Gets notifyUrl - * - * @return string|null - */ - public function getNotifyUrl() + public function getNotifyUrl(): string|null { - return $this->container['notifyUrl']; + return $this->notifyUrl; } - /** - * Sets notifyUrl - * - * @param string|null $notifyUrl The URL on your callback server to which delivery and seen reports will be sent. [Delivery report format](#channels/whatsapp/receive-whatsapp-delivery-reports), [Seen report format](#channels/whatsapp/receive-whatsapp-seen-reports). - * - * @return self - */ - public function setNotifyUrl($notifyUrl) + public function setNotifyUrl(?string $notifyUrl): self { - if (!is_null($notifyUrl) && (mb_strlen($notifyUrl) > 2048)) { - throw new \InvalidArgumentException('invalid length for $notifyUrl when calling WhatsAppMessage., must be smaller than or equal to 2048.'); - } - if (!is_null($notifyUrl) && (mb_strlen($notifyUrl) < 0)) { - throw new \InvalidArgumentException('invalid length for $notifyUrl when calling WhatsAppMessage., must be bigger than or equal to 0.'); - } - - $this->container['notifyUrl'] = $notifyUrl; - + $this->notifyUrl = $notifyUrl; return $this; } - /** - * Gets smsFailover - * - * @return \Infobip\Model\WhatsAppFailover|null - */ - public function getSmsFailover() + public function getSmsFailover(): \Infobip\Model\WhatsAppFailover|null { - return $this->container['smsFailover']; + return $this->smsFailover; } - /** - * Sets smsFailover - * - * @param \Infobip\Model\WhatsAppFailover|null $smsFailover smsFailover - * - * @return self - */ - public function setSmsFailover($smsFailover) + public function setSmsFailover(?\Infobip\Model\WhatsAppFailover $smsFailover): self { - $this->container['smsFailover'] = $smsFailover; - + $this->smsFailover = $smsFailover; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppNameContent.php b/Infobip/Model/WhatsAppNameContent.php index 5424136..979ff53 100644 --- a/Infobip/Model/WhatsAppNameContent.php +++ b/Infobip/Model/WhatsAppNameContent.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppNameContent implements ModelInterface, ArrayAccess, \JsonSerializable +class WhatsAppNameContent implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppNameContent'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'firstName' => 'string', - 'lastName' => 'string', - 'middleName' => 'string', - 'nameSuffix' => 'string', - 'namePrefix' => 'string', - 'formattedName' => 'string' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'WhatsAppNameContent'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'firstName' => null, 'lastName' => null, 'middleName' => null, @@ -80,394 +39,96 @@ class WhatsAppNameContent implements ModelInterface, ArrayAccess, \JsonSerializa ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'firstName' => 'firstName', - 'lastName' => 'lastName', - 'middleName' => 'middleName', - 'nameSuffix' => 'nameSuffix', - 'namePrefix' => 'namePrefix', - 'formattedName' => 'formattedName' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] */ - protected static $setters = [ - 'firstName' => 'setFirstName', - 'lastName' => 'setLastName', - 'middleName' => 'setMiddleName', - 'nameSuffix' => 'setNameSuffix', - 'namePrefix' => 'setNamePrefix', - 'formattedName' => 'setFormattedName' - ]; + public function __construct( + #[Assert\NotBlank] - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'firstName' => 'getFirstName', - 'lastName' => 'getLastName', - 'middleName' => 'getMiddleName', - 'nameSuffix' => 'getNameSuffix', - 'namePrefix' => 'getNamePrefix', - 'formattedName' => 'getFormattedName' - ]; + protected string $firstName, + #[Assert\NotBlank] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; + protected string $formattedName, + protected ?string $lastName = null, + protected ?string $middleName = null, + protected ?string $nameSuffix = null, + protected ?string $namePrefix = null, + ) { } - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() + #[Ignore] + public function getModelName(): string { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['firstName'] = $data['firstName'] ?? null; - $this->container['lastName'] = $data['lastName'] ?? null; - $this->container['middleName'] = $data['middleName'] ?? null; - $this->container['nameSuffix'] = $data['nameSuffix'] ?? null; - $this->container['namePrefix'] = $data['namePrefix'] ?? null; - $this->container['formattedName'] = $data['formattedName'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - if ($this->container['firstName'] === null) { - $invalidProperties[] = "'firstName' can't be null"; - } - if ($this->container['formattedName'] === null) { - $invalidProperties[] = "'formattedName' can't be null"; - } - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets firstName - * - * @return string - */ - public function getFirstName() + public function getFirstName(): string { - return $this->container['firstName']; + return $this->firstName; } - /** - * Sets firstName - * - * @param string $firstName Contact's first name. - * - * @return self - */ - public function setFirstName($firstName) + public function setFirstName(string $firstName): self { - $this->container['firstName'] = $firstName; - + $this->firstName = $firstName; return $this; } - /** - * Gets lastName - * - * @return string|null - */ - public function getLastName() + public function getLastName(): string|null { - return $this->container['lastName']; + return $this->lastName; } - /** - * Sets lastName - * - * @param string|null $lastName Contact's last name. - * - * @return self - */ - public function setLastName($lastName) + public function setLastName(?string $lastName): self { - $this->container['lastName'] = $lastName; - + $this->lastName = $lastName; return $this; } - /** - * Gets middleName - * - * @return string|null - */ - public function getMiddleName() + public function getMiddleName(): string|null { - return $this->container['middleName']; + return $this->middleName; } - /** - * Sets middleName - * - * @param string|null $middleName Contact's middle name. - * - * @return self - */ - public function setMiddleName($middleName) + public function setMiddleName(?string $middleName): self { - $this->container['middleName'] = $middleName; - + $this->middleName = $middleName; return $this; } - /** - * Gets nameSuffix - * - * @return string|null - */ - public function getNameSuffix() + public function getNameSuffix(): string|null { - return $this->container['nameSuffix']; + return $this->nameSuffix; } - /** - * Sets nameSuffix - * - * @param string|null $nameSuffix Contact's name suffix. - * - * @return self - */ - public function setNameSuffix($nameSuffix) + public function setNameSuffix(?string $nameSuffix): self { - $this->container['nameSuffix'] = $nameSuffix; - + $this->nameSuffix = $nameSuffix; return $this; } - /** - * Gets namePrefix - * - * @return string|null - */ - public function getNamePrefix() + public function getNamePrefix(): string|null { - return $this->container['namePrefix']; + return $this->namePrefix; } - /** - * Sets namePrefix - * - * @param string|null $namePrefix Contact's name prefix. - * - * @return self - */ - public function setNamePrefix($namePrefix) + public function setNamePrefix(?string $namePrefix): self { - $this->container['namePrefix'] = $namePrefix; - + $this->namePrefix = $namePrefix; return $this; } - /** - * Gets formattedName - * - * @return string - */ - public function getFormattedName() + public function getFormattedName(): string { - return $this->container['formattedName']; + return $this->formattedName; } - /** - * Sets formattedName - * - * @param string $formattedName Contact's full name as it normally appears. - * - * @return self - */ - public function setFormattedName($formattedName) + public function setFormattedName(string $formattedName): self { - $this->container['formattedName'] = $formattedName; - + $this->formattedName = $formattedName; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppOrganizationContent.php b/Infobip/Model/WhatsAppOrganizationContent.php index cfc640e..3edd7f7 100644 --- a/Infobip/Model/WhatsAppOrganizationContent.php +++ b/Infobip/Model/WhatsAppOrganizationContent.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppOrganizationContent implements ModelInterface, ArrayAccess, \JsonSerializable +class WhatsAppOrganizationContent implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppOrganizationContent'; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'WhatsAppOrganizationContent'; - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'company' => 'string', - 'department' => 'string', - 'title' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'company' => null, 'department' => null, 'title' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array */ - public static function openAPITypes() - { - return self::$openAPITypes; + public function __construct( + protected ?string $company = null, + protected ?string $department = null, + protected ?string $title = null, + ) { } - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() + #[Ignore] + public function getModelName(): string { - return self::$openAPIFormats; + return self::OPENAPI_MODEL_NAME; } - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'company' => 'company', - 'department' => 'department', - 'title' => 'title' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'company' => 'setCompany', - 'department' => 'setDepartment', - 'title' => 'setTitle' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'company' => 'getCompany', - 'department' => 'getDepartment', - 'title' => 'getTitle' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$openAPIModelName; + return self::DISCRIMINATOR; } - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) + public function getCompany(): string|null { - $this->container['company'] = $data['company'] ?? null; - $this->container['department'] = $data['department'] ?? null; - $this->container['title'] = $data['title'] ?? null; + return $this->company; } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + public function setCompany(?string $company): self { - $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() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets company - * - * @return string|null - */ - public function getCompany() - { - return $this->container['company']; - } - - /** - * Sets company - * - * @param string|null $company Company name. - * - * @return self - */ - public function setCompany($company) - { - $this->container['company'] = $company; - + $this->company = $company; return $this; } - /** - * Gets department - * - * @return string|null - */ - public function getDepartment() + public function getDepartment(): string|null { - return $this->container['department']; + return $this->department; } - /** - * Sets department - * - * @param string|null $department Department name. - * - * @return self - */ - public function setDepartment($department) + public function setDepartment(?string $department): self { - $this->container['department'] = $department; - + $this->department = $department; return $this; } - /** - * Gets title - * - * @return string|null - */ - public function getTitle() + public function getTitle(): string|null { - return $this->container['title']; + return $this->title; } - /** - * Sets title - * - * @param string|null $title Title value. - * - * @return self - */ - public function setTitle($title) + public function setTitle(?string $title): self { - $this->container['title'] = $title; - + $this->title = $title; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppPhoneContent.php b/Infobip/Model/WhatsAppPhoneContent.php index 98a63b6..c9aa485 100644 --- a/Infobip/Model/WhatsAppPhoneContent.php +++ b/Infobip/Model/WhatsAppPhoneContent.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppPhoneContent implements ModelInterface, ArrayAccess, \JsonSerializable +class WhatsAppPhoneContent implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppPhoneContent'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'phone' => 'string', - 'type' => '\Infobip\Model\WhatsAppPhoneType', - 'waId' => 'string' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'WhatsAppPhoneContent'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'phone' => null, 'type' => null, 'waId' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'phone' => 'phone', - 'type' => 'type', - 'waId' => 'waId' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'phone' => 'setPhone', - 'type' => 'setType', - 'waId' => 'setWaId' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'phone' => 'getPhone', - 'type' => 'getType', - 'waId' => 'getWaId' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] */ - protected $container = []; + public function __construct( + protected ?string $phone = null, + #[Assert\Choice(['CELL','MAIN','IPHONE','HOME','WORK',])] - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['phone'] = $data['phone'] ?? null; - $this->container['type'] = $data['type'] ?? null; - $this->container['waId'] = $data['waId'] ?? null; + protected ?string $type = null, + protected ?string $waId = null, + ) { } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets phone - * - * @return string|null - */ - public function getPhone() + public function getPhone(): string|null { - return $this->container['phone']; + return $this->phone; } - /** - * Sets phone - * - * @param string|null $phone Contact's phone number. - * - * @return self - */ - public function setPhone($phone) + public function setPhone(?string $phone): self { - $this->container['phone'] = $phone; - + $this->phone = $phone; return $this; } - /** - * Gets type - * - * @return \Infobip\Model\WhatsAppPhoneType|null - */ - public function getType() + public function getType(): mixed { - return $this->container['type']; + return $this->type; } - /** - * Sets type - * - * @param \Infobip\Model\WhatsAppPhoneType|null $type type - * - * @return self - */ - public function setType($type) + public function setType($type): self { - $this->container['type'] = $type; - + $this->type = $type; return $this; } - /** - * Gets waId - * - * @return string|null - */ - public function getWaId() + public function getWaId(): string|null { - return $this->container['waId']; + return $this->waId; } - /** - * Sets waId - * - * @param string|null $waId Contact's WhatsApp ID. - * - * @return self - */ - public function setWaId($waId) + public function setWaId(?string $waId): self { - $this->container['waId'] = $waId; - + $this->waId = $waId; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppPhoneNumberButtonApiData.php b/Infobip/Model/WhatsAppPhoneNumberButtonApiData.php index de24beb..828d85a 100644 --- a/Infobip/Model/WhatsAppPhoneNumberButtonApiData.php +++ b/Infobip/Model/WhatsAppPhoneNumberButtonApiData.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ class WhatsAppPhoneNumberButtonApiData extends WhatsAppButtonApiData { public const DISCRIMINATOR = 'type'; + public const OPENAPI_MODEL_NAME = 'WhatsAppPhoneNumberButtonApiData'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppPhoneNumberButtonApiData'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'phoneNumber' => 'string' - ]; + public const TYPE = 'PHONE_NUMBER'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'phoneNumber' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes + parent::openAPITypes(); - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats + parent::openAPIFormats(); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] */ - protected static $attributeMap = [ - 'phoneNumber' => 'phoneNumber' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'phoneNumber' => 'setPhoneNumber' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'phoneNumber' => 'getPhoneNumber' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return parent::attributeMap() + self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return parent::setters() + self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return parent::getters() + self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 200)] + #[Assert\Length(min: 0)] + protected string $text, + #[Assert\NotBlank] + protected string $phoneNumber, + ) { + $modelDiscriminatorValue = 'PHONE_NUMBER'; - - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - parent::__construct($data); - - $this->container['phoneNumber'] = $data['phoneNumber'] ?? null; - - $this->container['type'] = 'PHONE_NUMBER'; + parent::__construct( + type: $modelDiscriminatorValue, + text: $text, + ); } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = parent::listInvalidProperties(); - - if ($this->container['phoneNumber'] === null) { - $invalidProperties[] = "'phoneNumber' can't be null"; - } - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets phoneNumber - * - * @return string - */ - public function getPhoneNumber() + public function getPhoneNumber(): string { - return $this->container['phoneNumber']; + return $this->phoneNumber; } - /** - * Sets phoneNumber - * - * @param string $phoneNumber Phone number to which a phone call would be placed by end-user when hitting the button. - * - * @return self - */ - public function setPhoneNumber($phoneNumber) + public function setPhoneNumber(string $phoneNumber): self { - $this->container['phoneNumber'] = $phoneNumber; - + $this->phoneNumber = $phoneNumber; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppPhoneType.php b/Infobip/Model/WhatsAppPhoneType.php index 436ad1c..4f44a7c 100644 --- a/Infobip/Model/WhatsAppPhoneType.php +++ b/Infobip/Model/WhatsAppPhoneType.php @@ -1,14 +1,8 @@ value = $value; + } + + public static function CELL(): WhatsAppPhoneType + { + return new self('CELL'); + } + + public static function MAIN(): WhatsAppPhoneType + { + return new self('MAIN'); + } + + public static function IPHONE(): WhatsAppPhoneType + { + return new self('IPHONE'); + } + + public static function HOME(): WhatsAppPhoneType + { + return new self('HOME'); + } + + public static function WORK(): WhatsAppPhoneType + { + return new self('WORK'); + } + + public function __toString(): string { - return [ - self::CELL, - self::MAIN, - self::IPHONE, - self::HOME, - self::WORK, - ]; + return $this->value; } } diff --git a/Infobip/Model/WhatsAppQuickReplyButtonApiData.php b/Infobip/Model/WhatsAppQuickReplyButtonApiData.php index ee6a65f..ac73917 100644 --- a/Infobip/Model/WhatsAppQuickReplyButtonApiData.php +++ b/Infobip/Model/WhatsAppQuickReplyButtonApiData.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ class WhatsAppQuickReplyButtonApiData extends WhatsAppButtonApiData { public const DISCRIMINATOR = 'type'; + public const OPENAPI_MODEL_NAME = 'WhatsAppQuickReplyButtonApiData'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppQuickReplyButtonApiData'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - - ]; + public const TYPE = 'QUICK_REPLY'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes + parent::openAPITypes(); - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array */ - public static function openAPIFormats() - { - return self::$openAPIFormats + parent::openAPIFormats(); - } + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 200)] + #[Assert\Length(min: 0)] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ + protected string $text, + ) { + $modelDiscriminatorValue = 'QUICK_REPLY'; - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return parent::attributeMap() + self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return parent::setters() + self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return parent::getters() + self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - parent::__construct($data); - - - $this->container['type'] = 'QUICK_REPLY'; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = parent::listInvalidProperties(); - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); + parent::__construct( + type: $modelDiscriminatorValue, + text: $text, + ); } - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() + #[Ignore] + public function getModelName(): string { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); + return self::OPENAPI_MODEL_NAME; } - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() + #[Ignore] + public static function getDiscriminator(): ?string { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + return self::DISCRIMINATOR; } } diff --git a/Infobip/Model/WhatsAppSingleMessageInfo.php b/Infobip/Model/WhatsAppSingleMessageInfo.php index ad2d64d..d82ea7d 100644 --- a/Infobip/Model/WhatsAppSingleMessageInfo.php +++ b/Infobip/Model/WhatsAppSingleMessageInfo.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppSingleMessageInfo implements ModelInterface, ArrayAccess, \JsonSerializable +class WhatsAppSingleMessageInfo implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppSingleMessageInfo'; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'WhatsAppSingleMessageInfo'; - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'to' => 'string', - 'messageCount' => 'int', - 'messageId' => 'string', - 'status' => '\Infobip\Model\WhatsAppSingleMessageStatus' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'to' => null, 'messageCount' => 'int32', 'messageId' => null, @@ -75,332 +37,70 @@ class WhatsAppSingleMessageInfo implements ModelInterface, ArrayAccess, \JsonSer ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array */ - public static function openAPITypes() - { - return self::$openAPITypes; - } + public function __construct( + protected ?string $to = null, + protected ?int $messageCount = null, + protected ?string $messageId = null, + #[Assert\Valid] - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; + protected ?\Infobip\Model\WhatsAppSingleMessageStatus $status = null, + ) { } - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'to' => 'to', - 'messageCount' => 'messageCount', - 'messageId' => 'messageId', - 'status' => 'status' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'to' => 'setTo', - 'messageCount' => 'setMessageCount', - 'messageId' => 'setMessageId', - 'status' => 'setStatus' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'to' => 'getTo', - 'messageCount' => 'getMessageCount', - 'messageId' => 'getMessageId', - 'status' => 'getStatus' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() + #[Ignore] + public function getModelName(): string { - return self::$attributeMap; + return self::OPENAPI_MODEL_NAME; } - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$setters; + return self::DISCRIMINATOR; } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + public function getTo(): string|null { - return self::$getters; + return $this->to; } - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() + public function setTo(?string $to): self { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['to'] = $data['to'] ?? null; - $this->container['messageCount'] = $data['messageCount'] ?? null; - $this->container['messageId'] = $data['messageId'] ?? null; - $this->container['status'] = $data['status'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $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() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets to - * - * @return string|null - */ - public function getTo() - { - return $this->container['to']; - } - - /** - * Sets to - * - * @param string|null $to The destination address of the message. - * - * @return self - */ - public function setTo($to) - { - $this->container['to'] = $to; - + $this->to = $to; return $this; } - /** - * Gets messageCount - * - * @return int|null - */ - public function getMessageCount() + public function getMessageCount(): int|null { - return $this->container['messageCount']; + return $this->messageCount; } - /** - * Sets messageCount - * - * @param int|null $messageCount Number of messages required to deliver. - * - * @return self - */ - public function setMessageCount($messageCount) + public function setMessageCount(?int $messageCount): self { - $this->container['messageCount'] = $messageCount; - + $this->messageCount = $messageCount; return $this; } - /** - * Gets messageId - * - * @return string|null - */ - public function getMessageId() + public function getMessageId(): string|null { - return $this->container['messageId']; + return $this->messageId; } - /** - * Sets messageId - * - * @param string|null $messageId The ID that uniquely identifies the message sent. If not passed, it will be automatically generated and returned in a response. - * - * @return self - */ - public function setMessageId($messageId) + public function setMessageId(?string $messageId): self { - $this->container['messageId'] = $messageId; - + $this->messageId = $messageId; return $this; } - /** - * Gets status - * - * @return \Infobip\Model\WhatsAppSingleMessageStatus|null - */ - public function getStatus() + public function getStatus(): \Infobip\Model\WhatsAppSingleMessageStatus|null { - return $this->container['status']; + return $this->status; } - /** - * Sets status - * - * @param \Infobip\Model\WhatsAppSingleMessageStatus|null $status status - * - * @return self - */ - public function setStatus($status) + public function setStatus(?\Infobip\Model\WhatsAppSingleMessageStatus $status): self { - $this->container['status'] = $status; - + $this->status = $status; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppSingleMessageStatus.php b/Infobip/Model/WhatsAppSingleMessageStatus.php index 63b3073..f2a3a44 100644 --- a/Infobip/Model/WhatsAppSingleMessageStatus.php +++ b/Infobip/Model/WhatsAppSingleMessageStatus.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppSingleMessageStatus implements ModelInterface, ArrayAccess, \JsonSerializable +class WhatsAppSingleMessageStatus implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppSingleMessageStatus'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'groupId' => 'int', - 'groupName' => 'string', - 'id' => 'int', - 'name' => 'string', - 'description' => 'string', - 'action' => 'string' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'WhatsAppSingleMessageStatus'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'groupId' => 'int32', 'groupName' => null, 'id' => 'int32', @@ -80,388 +39,92 @@ class WhatsAppSingleMessageStatus implements ModelInterface, ArrayAccess, \JsonS ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'groupId' => 'groupId', - 'groupName' => 'groupName', - 'id' => 'id', - 'name' => 'name', - 'description' => 'description', - 'action' => 'action' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'groupId' => 'setGroupId', - 'groupName' => 'setGroupName', - 'id' => 'setId', - 'name' => 'setName', - 'description' => 'setDescription', - 'action' => 'setAction' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] */ - protected static $getters = [ - 'groupId' => 'getGroupId', - 'groupName' => 'getGroupName', - 'id' => 'getId', - 'name' => 'getName', - 'description' => 'getDescription', - 'action' => 'getAction' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; + public function __construct( + protected ?int $groupId = null, + protected ?string $groupName = null, + protected ?int $id = null, + protected ?string $name = null, + protected ?string $description = null, + protected ?string $action = null, + ) { } - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['groupId'] = $data['groupId'] ?? null; - $this->container['groupName'] = $data['groupName'] ?? null; - $this->container['id'] = $data['id'] ?? null; - $this->container['name'] = $data['name'] ?? null; - $this->container['description'] = $data['description'] ?? null; - $this->container['action'] = $data['action'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets groupId - * - * @return int|null - */ - public function getGroupId() + public function getGroupId(): int|null { - return $this->container['groupId']; + return $this->groupId; } - /** - * Sets groupId - * - * @param int|null $groupId Status group ID. - * - * @return self - */ - public function setGroupId($groupId) + public function setGroupId(?int $groupId): self { - $this->container['groupId'] = $groupId; - + $this->groupId = $groupId; return $this; } - /** - * Gets groupName - * - * @return string|null - */ - public function getGroupName() + public function getGroupName(): string|null { - return $this->container['groupName']; + return $this->groupName; } - /** - * Sets groupName - * - * @param string|null $groupName Status group name. - * - * @return self - */ - public function setGroupName($groupName) + public function setGroupName(?string $groupName): self { - $this->container['groupName'] = $groupName; - + $this->groupName = $groupName; return $this; } - /** - * Gets id - * - * @return int|null - */ - public function getId() + public function getId(): int|null { - return $this->container['id']; + return $this->id; } - /** - * Sets id - * - * @param int|null $id Status ID. - * - * @return self - */ - public function setId($id) + public function setId(?int $id): self { - $this->container['id'] = $id; - + $this->id = $id; return $this; } - /** - * Gets name - * - * @return string|null - */ - public function getName() + public function getName(): string|null { - return $this->container['name']; + return $this->name; } - /** - * Sets name - * - * @param string|null $name Status name. - * - * @return self - */ - public function setName($name) + public function setName(?string $name): self { - $this->container['name'] = $name; - + $this->name = $name; return $this; } - /** - * Gets description - * - * @return string|null - */ - public function getDescription() + public function getDescription(): string|null { - return $this->container['description']; + return $this->description; } - /** - * Sets description - * - * @param string|null $description Human-readable description of the status. - * - * @return self - */ - public function setDescription($description) + public function setDescription(?string $description): self { - $this->container['description'] = $description; - + $this->description = $description; return $this; } - /** - * Gets action - * - * @return string|null - */ - public function getAction() + public function getAction(): string|null { - return $this->container['action']; + return $this->action; } - /** - * Sets action - * - * @param string|null $action Action that should be taken to eliminate the error. - * - * @return self - */ - public function setAction($action) + public function setAction(?string $action): self { - $this->container['action'] = $action; - + $this->action = $action; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppStatus.php b/Infobip/Model/WhatsAppStatus.php index 4e0973c..300d96f 100644 --- a/Infobip/Model/WhatsAppStatus.php +++ b/Infobip/Model/WhatsAppStatus.php @@ -1,14 +1,8 @@ value = $value; + } + + public static function APPROVED(): WhatsAppStatus + { + return new self('APPROVED'); + } + + public static function IN_APPEAL(): WhatsAppStatus + { + return new self('IN_APPEAL'); + } + + public static function PENDING(): WhatsAppStatus + { + return new self('PENDING'); + } + + public static function REJECTED(): WhatsAppStatus + { + return new self('REJECTED'); + } + + public static function PENDING_DELETION(): WhatsAppStatus + { + return new self('PENDING_DELETION'); + } + + public static function DELETED(): WhatsAppStatus + { + return new self('DELETED'); + } + + public static function REINSTATED(): WhatsAppStatus + { + return new self('REINSTATED'); + } + + public static function FLAGGED(): WhatsAppStatus + { + return new self('FLAGGED'); + } + + public static function FIRST_PAUSED(): WhatsAppStatus + { + return new self('FIRST_PAUSED'); + } + + public static function SECOND_PAUSED(): WhatsAppStatus + { + return new self('SECOND_PAUSED'); + } + + public static function DISABLED(): WhatsAppStatus + { + return new self('DISABLED'); + } + + public function __toString(): string { - return [ - self::APPROVED, - self::IN_APPEAL, - self::PENDING, - self::REJECTED, - self::PENDING_DELETION, - self::DELETED, - self::REINSTATED, - self::FLAGGED, - self::FIRST_PAUSED, - self::SECOND_PAUSED, - self::DISABLED, - ]; + return $this->value; } } diff --git a/Infobip/Model/WhatsAppStickerContent.php b/Infobip/Model/WhatsAppStickerContent.php index e9ace07..c536dba 100644 --- a/Infobip/Model/WhatsAppStickerContent.php +++ b/Infobip/Model/WhatsAppStickerContent.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppStickerContent implements ModelInterface, ArrayAccess, \JsonSerializable +class WhatsAppStickerContent implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppStickerContent'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'mediaUrl' => 'string' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'WhatsAppStickerContent'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'mediaUrl' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array */ - public static function openAPITypes() - { - return self::$openAPITypes; - } + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 2048)] + #[Assert\Length(min: 1)] - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; + protected string $mediaUrl, + ) { } - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'mediaUrl' => 'mediaUrl' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'mediaUrl' => 'setMediaUrl' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'mediaUrl' => 'getMediaUrl' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() + #[Ignore] + public function getModelName(): string { - return self::$setters; + return self::OPENAPI_MODEL_NAME; } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$getters; + return self::DISCRIMINATOR; } - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() + public function getMediaUrl(): string { - return self::$openAPIModelName; + return $this->mediaUrl; } - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) + public function setMediaUrl(string $mediaUrl): self { - $this->container['mediaUrl'] = $data['mediaUrl'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - if ($this->container['mediaUrl'] === null) { - $invalidProperties[] = "'mediaUrl' can't be null"; - } - if ((mb_strlen($this->container['mediaUrl']) > 2048)) { - $invalidProperties[] = "invalid value for 'mediaUrl', the character length must be smaller than or equal to 2048."; - } - - if ((mb_strlen($this->container['mediaUrl']) < 1)) { - $invalidProperties[] = "invalid value for 'mediaUrl', the character length must be bigger than or equal to 1."; - } - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets mediaUrl - * - * @return string - */ - public function getMediaUrl() - { - return $this->container['mediaUrl']; - } - - /** - * Sets mediaUrl - * - * @param string $mediaUrl URL of a sticker sent in a WhatsApp message. Must be a valid URL starting with `https://` or `http://`. Supported sticker type is `WebP`. Sticker file should be 512x512 pixels. Maximum sticker size is 100KB. - * - * @return self - */ - public function setMediaUrl($mediaUrl) - { - if ((mb_strlen($mediaUrl) > 2048)) { - throw new \InvalidArgumentException('invalid length for $mediaUrl when calling WhatsAppStickerContent., must be smaller than or equal to 2048.'); - } - if ((mb_strlen($mediaUrl) < 1)) { - throw new \InvalidArgumentException('invalid length for $mediaUrl when calling WhatsAppStickerContent., must be bigger than or equal to 1.'); - } - - $this->container['mediaUrl'] = $mediaUrl; - + $this->mediaUrl = $mediaUrl; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppStickerMessage.php b/Infobip/Model/WhatsAppStickerMessage.php index 49248b1..70f337f 100644 --- a/Infobip/Model/WhatsAppStickerMessage.php +++ b/Infobip/Model/WhatsAppStickerMessage.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppStickerMessage implements ModelInterface, ArrayAccess, \JsonSerializable +class WhatsAppStickerMessage implements ModelInterface { - public const DISCRIMINATOR = null; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'WhatsAppStickerMessage'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppStickerMessage'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'from' => 'string', - 'to' => 'string', - 'messageId' => 'string', - 'content' => '\Infobip\Model\WhatsAppStickerContent', - 'callbackData' => 'string', - 'notifyUrl' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'from' => null, 'to' => null, 'messageId' => null, @@ -79,472 +39,112 @@ class WhatsAppStickerMessage implements ModelInterface, ArrayAccess, \JsonSerial ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array */ - public static function openAPITypes() - { - return self::$openAPITypes; - } + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 24)] + #[Assert\Length(min: 1)] - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } + protected string $from, + #[Assert\NotBlank] + #[Assert\Length(max: 24)] + #[Assert\Length(min: 1)] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'from' => 'from', - 'to' => 'to', - 'messageId' => 'messageId', - 'content' => 'content', - 'callbackData' => 'callbackData', - 'notifyUrl' => 'notifyUrl' - ]; + protected string $to, + #[Assert\Valid] + #[Assert\NotBlank] - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'from' => 'setFrom', - 'to' => 'setTo', - 'messageId' => 'setMessageId', - 'content' => 'setContent', - 'callbackData' => 'setCallbackData', - 'notifyUrl' => 'setNotifyUrl' - ]; + protected \Infobip\Model\WhatsAppStickerContent $content, + #[Assert\Length(max: 100)] + #[Assert\Length(min: 0)] - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'from' => 'getFrom', - 'to' => 'getTo', - 'messageId' => 'getMessageId', - 'content' => 'getContent', - 'callbackData' => 'getCallbackData', - 'notifyUrl' => 'getNotifyUrl' - ]; + protected ?string $messageId = null, + #[Assert\Length(max: 4000)] + #[Assert\Length(min: 0)] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } + protected ?string $callbackData = null, + #[Assert\Length(max: 2048)] + #[Assert\Length(min: 0)] - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; + protected ?string $notifyUrl = null, + ) { } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public function getModelName(): string { - return self::$getters; + return self::OPENAPI_MODEL_NAME; } - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) + #[Ignore] + public static function getDiscriminator(): ?string { - $this->container['from'] = $data['from'] ?? null; - $this->container['to'] = $data['to'] ?? null; - $this->container['messageId'] = $data['messageId'] ?? null; - $this->container['content'] = $data['content'] ?? null; - $this->container['callbackData'] = $data['callbackData'] ?? null; - $this->container['notifyUrl'] = $data['notifyUrl'] ?? null; + return self::DISCRIMINATOR; } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + public function getFrom(): string { - $invalidProperties = []; - - if ($this->container['from'] === null) { - $invalidProperties[] = "'from' can't be null"; - } - if ((mb_strlen($this->container['from']) > 24)) { - $invalidProperties[] = "invalid value for 'from', the character length must be smaller than or equal to 24."; - } - - if ((mb_strlen($this->container['from']) < 1)) { - $invalidProperties[] = "invalid value for 'from', the character length must be bigger than or equal to 1."; - } - - if ($this->container['to'] === null) { - $invalidProperties[] = "'to' can't be null"; - } - if ((mb_strlen($this->container['to']) > 24)) { - $invalidProperties[] = "invalid value for 'to', the character length must be smaller than or equal to 24."; - } - - if ((mb_strlen($this->container['to']) < 1)) { - $invalidProperties[] = "invalid value for 'to', the character length must be bigger than or equal to 1."; - } - - if (!is_null($this->container['messageId']) && (mb_strlen($this->container['messageId']) > 50)) { - $invalidProperties[] = "invalid value for 'messageId', the character length must be smaller than or equal to 50."; - } - - if (!is_null($this->container['messageId']) && (mb_strlen($this->container['messageId']) < 0)) { - $invalidProperties[] = "invalid value for 'messageId', the character length must be bigger than or equal to 0."; - } - - if ($this->container['content'] === null) { - $invalidProperties[] = "'content' can't be null"; - } - if (!is_null($this->container['callbackData']) && (mb_strlen($this->container['callbackData']) > 4000)) { - $invalidProperties[] = "invalid value for 'callbackData', the character length must be smaller than or equal to 4000."; - } - - if (!is_null($this->container['callbackData']) && (mb_strlen($this->container['callbackData']) < 0)) { - $invalidProperties[] = "invalid value for 'callbackData', the character length must be bigger than or equal to 0."; - } - - if (!is_null($this->container['notifyUrl']) && (mb_strlen($this->container['notifyUrl']) > 2048)) { - $invalidProperties[] = "invalid value for 'notifyUrl', the character length must be smaller than or equal to 2048."; - } - - if (!is_null($this->container['notifyUrl']) && (mb_strlen($this->container['notifyUrl']) < 0)) { - $invalidProperties[] = "invalid value for 'notifyUrl', the character length must be bigger than or equal to 0."; - } - - return $invalidProperties; + return $this->from; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + public function setFrom(string $from): self { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets from - * - * @return string - */ - public function getFrom() - { - return $this->container['from']; - } - - /** - * Sets from - * - * @param string $from Registered WhatsApp sender number. Must be in international format and comply with [WhatsApp's requirements](https://www.infobip.com/docs/whatsapp/get-started#phone-number-what-you-need-to-know). - * - * @return self - */ - public function setFrom($from) - { - if ((mb_strlen($from) > 24)) { - throw new \InvalidArgumentException('invalid length for $from when calling WhatsAppStickerMessage., must be smaller than or equal to 24.'); - } - if ((mb_strlen($from) < 1)) { - throw new \InvalidArgumentException('invalid length for $from when calling WhatsAppStickerMessage., must be bigger than or equal to 1.'); - } - - $this->container['from'] = $from; - + $this->from = $from; return $this; } - /** - * Gets to - * - * @return string - */ - public function getTo() + public function getTo(): string { - return $this->container['to']; + return $this->to; } - /** - * Sets to - * - * @param string $to Message recipient number. Must be in international format. - * - * @return self - */ - public function setTo($to) + public function setTo(string $to): self { - if ((mb_strlen($to) > 24)) { - throw new \InvalidArgumentException('invalid length for $to when calling WhatsAppStickerMessage., must be smaller than or equal to 24.'); - } - if ((mb_strlen($to) < 1)) { - throw new \InvalidArgumentException('invalid length for $to when calling WhatsAppStickerMessage., must be bigger than or equal to 1.'); - } - - $this->container['to'] = $to; - + $this->to = $to; return $this; } - /** - * Gets messageId - * - * @return string|null - */ - public function getMessageId() + public function getMessageId(): string|null { - return $this->container['messageId']; + return $this->messageId; } - /** - * Sets messageId - * - * @param string|null $messageId The ID that uniquely identifies the message sent. - * - * @return self - */ - public function setMessageId($messageId) + public function setMessageId(?string $messageId): self { - if (!is_null($messageId) && (mb_strlen($messageId) > 50)) { - throw new \InvalidArgumentException('invalid length for $messageId when calling WhatsAppStickerMessage., must be smaller than or equal to 50.'); - } - if (!is_null($messageId) && (mb_strlen($messageId) < 0)) { - throw new \InvalidArgumentException('invalid length for $messageId when calling WhatsAppStickerMessage., must be bigger than or equal to 0.'); - } - - $this->container['messageId'] = $messageId; - + $this->messageId = $messageId; return $this; } - /** - * Gets content - * - * @return \Infobip\Model\WhatsAppStickerContent - */ - public function getContent() + public function getContent(): \Infobip\Model\WhatsAppStickerContent { - return $this->container['content']; + return $this->content; } - /** - * Sets content - * - * @param \Infobip\Model\WhatsAppStickerContent $content content - * - * @return self - */ - public function setContent($content) + public function setContent(\Infobip\Model\WhatsAppStickerContent $content): self { - $this->container['content'] = $content; - + $this->content = $content; return $this; } - /** - * Gets callbackData - * - * @return string|null - */ - public function getCallbackData() + public function getCallbackData(): string|null { - return $this->container['callbackData']; + return $this->callbackData; } - /** - * Sets callbackData - * - * @param string|null $callbackData Custom client data that will be included in a [Delivery Report](#channels/whatsapp/receive-whatsapp-delivery-reports). - * - * @return self - */ - public function setCallbackData($callbackData) + public function setCallbackData(?string $callbackData): self { - if (!is_null($callbackData) && (mb_strlen($callbackData) > 4000)) { - throw new \InvalidArgumentException('invalid length for $callbackData when calling WhatsAppStickerMessage., must be smaller than or equal to 4000.'); - } - if (!is_null($callbackData) && (mb_strlen($callbackData) < 0)) { - throw new \InvalidArgumentException('invalid length for $callbackData when calling WhatsAppStickerMessage., must be bigger than or equal to 0.'); - } - - $this->container['callbackData'] = $callbackData; - + $this->callbackData = $callbackData; return $this; } - /** - * Gets notifyUrl - * - * @return string|null - */ - public function getNotifyUrl() + public function getNotifyUrl(): string|null { - return $this->container['notifyUrl']; + return $this->notifyUrl; } - /** - * Sets notifyUrl - * - * @param string|null $notifyUrl The URL on your callback server to which delivery and seen reports will be sent. [Delivery report format](#channels/whatsapp/receive-whatsapp-delivery-reports), [Seen report format](#channels/whatsapp/receive-whatsapp-seen-reports). - * - * @return self - */ - public function setNotifyUrl($notifyUrl) + public function setNotifyUrl(?string $notifyUrl): self { - if (!is_null($notifyUrl) && (mb_strlen($notifyUrl) > 2048)) { - throw new \InvalidArgumentException('invalid length for $notifyUrl when calling WhatsAppStickerMessage., must be smaller than or equal to 2048.'); - } - if (!is_null($notifyUrl) && (mb_strlen($notifyUrl) < 0)) { - throw new \InvalidArgumentException('invalid length for $notifyUrl when calling WhatsAppStickerMessage., must be bigger than or equal to 0.'); - } - - $this->container['notifyUrl'] = $notifyUrl; - + $this->notifyUrl = $notifyUrl; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppTemplateApiResponse.php b/Infobip/Model/WhatsAppTemplateApiResponse.php index 8e674f6..21f6b70 100644 --- a/Infobip/Model/WhatsAppTemplateApiResponse.php +++ b/Infobip/Model/WhatsAppTemplateApiResponse.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppTemplateApiResponse implements ModelInterface, ArrayAccess, \JsonSerializable +class WhatsAppTemplateApiResponse implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppTemplateApiResponse'; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'WhatsAppTemplateApiResponse'; - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'id' => 'string', - 'businessAccountId' => 'int', - 'name' => 'string', - 'language' => '\Infobip\Model\WhatsAppLanguage', - 'status' => '\Infobip\Model\WhatsAppStatus', - 'category' => '\Infobip\Model\WhatsAppCategory', - 'structure' => '\Infobip\Model\WhatsAppTemplateStructureApiData' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'id' => null, 'businessAccountId' => 'int64', 'name' => null, @@ -82,416 +40,112 @@ class WhatsAppTemplateApiResponse implements ModelInterface, ArrayAccess, \JsonS ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array */ - public static function openAPITypes() - { - return self::$openAPITypes; - } + public function __construct( + protected ?string $id = null, + protected ?int $businessAccountId = null, + protected ?string $name = null, + #[Assert\Choice(['af','sq','ar','az','bn','bg','ca','zh_CN','zh_HK','zh_TW','hr','cs','da','nl','en','en_GB','en_US','et','fil','fi','fr','ka','de','el','gu','ha','he','hi','hu','id','ga','it','ja','kn','kk','rw_RW','ko','ky_KG','lo','lv','lt','mk','ms','ml','mr','nb','fa','pl','pt_BR','pt_PT','pa','ro','ru','sr','sk','sl','es','es_AR','es_ES','es_MX','sw','sv','ta','te','th','tr','uk','ur','uz','vi','zu','unknown',])] - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } + protected ?string $language = null, + #[Assert\Choice(['APPROVED','IN_APPEAL','PENDING','REJECTED','PENDING_DELETION','DELETED','REINSTATED','FLAGGED','FIRST_PAUSED','SECOND_PAUSED','DISABLED',])] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'id' => 'id', - 'businessAccountId' => 'businessAccountId', - 'name' => 'name', - 'language' => 'language', - 'status' => 'status', - 'category' => 'category', - 'structure' => 'structure' - ]; + protected ?string $status = null, + #[Assert\Choice(['ACCOUNT_UPDATE','PAYMENT_UPDATE','PERSONAL_FINANCE_UPDATE','SHIPPING_UPDATE','RESERVATION_UPDATE','ISSUE_RESOLUTION','APPOINTMENT_UPDATE','TRANSPORTATION_UPDATE','TICKET_UPDATE','ALERT_UPDATE','AUTO_REPLY','MARKETING','TRANSACTIONAL','OTP',])] - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'id' => 'setId', - 'businessAccountId' => 'setBusinessAccountId', - 'name' => 'setName', - 'language' => 'setLanguage', - 'status' => 'setStatus', - 'category' => 'setCategory', - 'structure' => 'setStructure' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'id' => 'getId', - 'businessAccountId' => 'getBusinessAccountId', - 'name' => 'getName', - 'language' => 'getLanguage', - 'status' => 'getStatus', - 'category' => 'getCategory', - 'structure' => 'getStructure' - ]; + protected ?string $category = null, + #[Assert\Valid] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; + protected ?\Infobip\Model\WhatsAppTemplateStructureApiData $structure = null, + ) { } - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) + #[Ignore] + public function getModelName(): string { - $this->container['id'] = $data['id'] ?? null; - $this->container['businessAccountId'] = $data['businessAccountId'] ?? null; - $this->container['name'] = $data['name'] ?? null; - $this->container['language'] = $data['language'] ?? null; - $this->container['status'] = $data['status'] ?? null; - $this->container['category'] = $data['category'] ?? null; - $this->container['structure'] = $data['structure'] ?? null; + return self::OPENAPI_MODEL_NAME; } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public static function getDiscriminator(): ?string { - $invalidProperties = []; - - return $invalidProperties; + return self::DISCRIMINATOR; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + public function getId(): string|null { - return count($this->listInvalidProperties()) === 0; + return $this->id; } - - /** - * Gets id - * - * @return string|null - */ - public function getId() + public function setId(?string $id): self { - return $this->container['id']; - } - - /** - * Sets id - * - * @param string|null $id Template ID. - * - * @return self - */ - public function setId($id) - { - $this->container['id'] = $id; - + $this->id = $id; return $this; } - /** - * Gets businessAccountId - * - * @return int|null - */ - public function getBusinessAccountId() + public function getBusinessAccountId(): int|null { - return $this->container['businessAccountId']; + return $this->businessAccountId; } - /** - * Sets businessAccountId - * - * @param int|null $businessAccountId Business account ID to which template belongs. - * - * @return self - */ - public function setBusinessAccountId($businessAccountId) + public function setBusinessAccountId(?int $businessAccountId): self { - $this->container['businessAccountId'] = $businessAccountId; - + $this->businessAccountId = $businessAccountId; return $this; } - /** - * Gets name - * - * @return string|null - */ - public function getName() + public function getName(): string|null { - return $this->container['name']; + return $this->name; } - /** - * Sets name - * - * @param string|null $name Name of the template. - * - * @return self - */ - public function setName($name) + public function setName(?string $name): self { - $this->container['name'] = $name; - + $this->name = $name; return $this; } - /** - * Gets language - * - * @return \Infobip\Model\WhatsAppLanguage|null - */ - public function getLanguage() + public function getLanguage(): mixed { - return $this->container['language']; + return $this->language; } - /** - * Sets language - * - * @param \Infobip\Model\WhatsAppLanguage|null $language language - * - * @return self - */ - public function setLanguage($language) + public function setLanguage($language): self { - $this->container['language'] = $language; - + $this->language = $language; return $this; } - /** - * Gets status - * - * @return \Infobip\Model\WhatsAppStatus|null - */ - public function getStatus() + public function getStatus(): mixed { - return $this->container['status']; + return $this->status; } - /** - * Sets status - * - * @param \Infobip\Model\WhatsAppStatus|null $status status - * - * @return self - */ - public function setStatus($status) + public function setStatus($status): self { - $this->container['status'] = $status; - + $this->status = $status; return $this; } - /** - * Gets category - * - * @return \Infobip\Model\WhatsAppCategory|null - */ - public function getCategory() + public function getCategory(): mixed { - return $this->container['category']; + return $this->category; } - /** - * Sets category - * - * @param \Infobip\Model\WhatsAppCategory|null $category category - * - * @return self - */ - public function setCategory($category) + public function setCategory($category): self { - $this->container['category'] = $category; - + $this->category = $category; return $this; } - /** - * Gets structure - * - * @return \Infobip\Model\WhatsAppTemplateStructureApiData|null - */ - public function getStructure() + public function getStructure(): \Infobip\Model\WhatsAppTemplateStructureApiData|null { - return $this->container['structure']; + return $this->structure; } - /** - * Sets structure - * - * @param \Infobip\Model\WhatsAppTemplateStructureApiData|null $structure structure - * - * @return self - */ - public function setStructure($structure) + public function setStructure(?\Infobip\Model\WhatsAppTemplateStructureApiData $structure): self { - $this->container['structure'] = $structure; - + $this->structure = $structure; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppTemplateBodyContent.php b/Infobip/Model/WhatsAppTemplateBodyContent.php index 5cd72f9..ac77c9d 100644 --- a/Infobip/Model/WhatsAppTemplateBodyContent.php +++ b/Infobip/Model/WhatsAppTemplateBodyContent.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppTemplateBodyContent implements ModelInterface, ArrayAccess, \JsonSerializable +class WhatsAppTemplateBodyContent implements ModelInterface { - public const DISCRIMINATOR = null; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'WhatsAppTemplateBodyContent'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppTemplateBodyContent'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'placeholders' => 'string[]' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'placeholders' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'placeholders' => 'placeholders' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'placeholders' => 'setPlaceholders' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'placeholders' => 'getPlaceholders' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string + * @param string[] $placeholders */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; + public function __construct( + #[Assert\NotBlank] - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['placeholders'] = $data['placeholders'] ?? null; + protected array $placeholders, + ) { } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - if ($this->container['placeholders'] === null) { - $invalidProperties[] = "'placeholders' can't be null"; - } - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - /** - * Gets placeholders - * * @return string[] */ - public function getPlaceholders() + public function getPlaceholders(): array { - return $this->container['placeholders']; + return $this->placeholders; } /** - * Sets placeholders - * * @param string[] $placeholders Template's parameter values submitted in the same order as in the registered template. The value must not be null, but it can be an empty array, if the template was registered without placeholders. Values within the array must not be null or empty. - * - * @return self */ - public function setPlaceholders($placeholders) + public function setPlaceholders(array $placeholders): self { - $this->container['placeholders'] = $placeholders; - + $this->placeholders = $placeholders; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppTemplateButtonContent.php b/Infobip/Model/WhatsAppTemplateButtonContent.php index 3e88fc2..7494334 100644 --- a/Infobip/Model/WhatsAppTemplateButtonContent.php +++ b/Infobip/Model/WhatsAppTemplateButtonContent.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppTemplateButtonContent implements ModelInterface, ArrayAccess, \JsonSerializable +use Symfony\Component\Validator\Constraints as Assert; +use Symfony\Component\Serializer\Annotation as Serializer; +use Symfony\Component\Serializer\Annotation\Ignore; +use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer; +use Symfony\Component\Serializer\Annotation\DiscriminatorMap; + +#[DiscriminatorMap(typeProperty: "type", mapping: [ + "QUICK_REPLY" => "\Infobip\Model\WhatsAppTemplateQuickReplyButtonContent", + "URL" => "\Infobip\Model\WhatsAppTemplateUrlButtonContent", + "WhatsAppTemplateQuickReplyButtonContent" => "\Infobip\Model\WhatsAppTemplateQuickReplyButtonContent", + "WhatsAppTemplateUrlButtonContent" => "\Infobip\Model\WhatsAppTemplateUrlButtonContent", +])] +class WhatsAppTemplateButtonContent implements ModelInterface { public const DISCRIMINATOR = 'type'; + public const OPENAPI_MODEL_NAME = 'WhatsAppTemplateButtonContent'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppTemplateButtonContent'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'type' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'type' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'type' => 'type' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'type' => 'setType' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] */ - protected static $getters = [ - 'type' => 'getType' - ]; + public function __construct( + #[Assert\NotBlank] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; + protected string $type, + ) { } - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() + #[Ignore] + public function getModelName(): string { - return self::$setters; + return self::OPENAPI_MODEL_NAME; } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$getters; + return self::DISCRIMINATOR; } - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() + public function getType(): string { - return self::$openAPIModelName; + return $this->type; } - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) + public function setType(string $type): self { - $this->container['type'] = $data['type'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - if ($this->container['type'] === null) { - $invalidProperties[] = "'type' can't be null"; - } - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets type - * - * @return string - */ - public function getType() - { - return $this->container['type']; - } - - /** - * Sets type - * - * @param string $type type - * - * @return self - */ - public function setType($type) - { - $this->container['type'] = $type; - + $this->type = $type; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppTemplateContent.php b/Infobip/Model/WhatsAppTemplateContent.php index d92600f..e4b8810 100644 --- a/Infobip/Model/WhatsAppTemplateContent.php +++ b/Infobip/Model/WhatsAppTemplateContent.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppTemplateContent implements ModelInterface, ArrayAccess, \JsonSerializable +class WhatsAppTemplateContent implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppTemplateContent'; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'WhatsAppTemplateContent'; - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'templateName' => 'string', - 'templateData' => '\Infobip\Model\WhatsAppTemplateDataContent', - 'language' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'templateName' => null, 'templateData' => null, 'language' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array */ - public static function openAPITypes() - { - return self::$openAPITypes; - } + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 512)] + #[Assert\Length(min: 1)] - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } + protected string $templateName, + #[Assert\Valid] + #[Assert\NotBlank] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'templateName' => 'templateName', - 'templateData' => 'templateData', - 'language' => 'language' - ]; + protected \Infobip\Model\WhatsAppTemplateDataContent $templateData, + #[Assert\NotBlank] - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'templateName' => 'setTemplateName', - 'templateData' => 'setTemplateData', - 'language' => 'setLanguage' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'templateName' => 'getTemplateName', - 'templateData' => 'getTemplateData', - 'language' => 'getLanguage' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; + protected string $language, + ) { } - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() + #[Ignore] + public function getModelName(): string { - return self::$setters; + return self::OPENAPI_MODEL_NAME; } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$getters; + return self::DISCRIMINATOR; } - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) + public function getTemplateName(): string { - $this->container['templateName'] = $data['templateName'] ?? null; - $this->container['templateData'] = $data['templateData'] ?? null; - $this->container['language'] = $data['language'] ?? null; + return $this->templateName; } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + public function setTemplateName(string $templateName): self { - $invalidProperties = []; - - if ($this->container['templateName'] === null) { - $invalidProperties[] = "'templateName' can't be null"; - } - if ((mb_strlen($this->container['templateName']) > 512)) { - $invalidProperties[] = "invalid value for 'templateName', the character length must be smaller than or equal to 512."; - } - - if ((mb_strlen($this->container['templateName']) < 1)) { - $invalidProperties[] = "invalid value for 'templateName', the character length must be bigger than or equal to 1."; - } - - if ($this->container['templateData'] === null) { - $invalidProperties[] = "'templateData' can't be null"; - } - if ($this->container['language'] === null) { - $invalidProperties[] = "'language' can't be null"; - } - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets templateName - * - * @return string - */ - public function getTemplateName() - { - return $this->container['templateName']; - } - - /** - * Sets templateName - * - * @param string $templateName Template name. Should only contain lowercase alphanumeric characters and underscores. - * - * @return self - */ - public function setTemplateName($templateName) - { - if ((mb_strlen($templateName) > 512)) { - throw new \InvalidArgumentException('invalid length for $templateName when calling WhatsAppTemplateContent., must be smaller than or equal to 512.'); - } - if ((mb_strlen($templateName) < 1)) { - throw new \InvalidArgumentException('invalid length for $templateName when calling WhatsAppTemplateContent., must be bigger than or equal to 1.'); - } - - $this->container['templateName'] = $templateName; - + $this->templateName = $templateName; return $this; } - /** - * Gets templateData - * - * @return \Infobip\Model\WhatsAppTemplateDataContent - */ - public function getTemplateData() + public function getTemplateData(): \Infobip\Model\WhatsAppTemplateDataContent { - return $this->container['templateData']; + return $this->templateData; } - /** - * Sets templateData - * - * @param \Infobip\Model\WhatsAppTemplateDataContent $templateData templateData - * - * @return self - */ - public function setTemplateData($templateData) + public function setTemplateData(\Infobip\Model\WhatsAppTemplateDataContent $templateData): self { - $this->container['templateData'] = $templateData; - + $this->templateData = $templateData; return $this; } - /** - * Gets language - * - * @return string - */ - public function getLanguage() + public function getLanguage(): string { - return $this->container['language']; + return $this->language; } - /** - * Sets language - * - * @param string $language The code of language or locale to use. Must be the same code used when registering the template. - * - * @return self - */ - public function setLanguage($language) + public function setLanguage(string $language): self { - $this->container['language'] = $language; - + $this->language = $language; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppTemplateDataContent.php b/Infobip/Model/WhatsAppTemplateDataContent.php index 860dc8d..5dad7fd 100644 --- a/Infobip/Model/WhatsAppTemplateDataContent.php +++ b/Infobip/Model/WhatsAppTemplateDataContent.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppTemplateDataContent implements ModelInterface, ArrayAccess, \JsonSerializable +class WhatsAppTemplateDataContent implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppTemplateDataContent'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'body' => '\Infobip\Model\WhatsAppTemplateBodyContent', - 'header' => '\Infobip\Model\WhatsAppTemplateHeaderContent', - 'buttons' => '\Infobip\Model\WhatsAppTemplateButtonContent[]' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'WhatsAppTemplateDataContent'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'body' => null, 'header' => null, 'buttons' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'body' => 'body', - 'header' => 'header', - 'buttons' => 'buttons' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] + * @param \Infobip\Model\WhatsAppTemplateButtonContent[] $buttons */ - protected static $setters = [ - 'body' => 'setBody', - 'header' => 'setHeader', - 'buttons' => 'setButtons' - ]; + public function __construct( + #[Assert\Valid] + #[Assert\NotBlank] - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'body' => 'getBody', - 'header' => 'getHeader', - 'buttons' => 'getButtons' - ]; + protected \Infobip\Model\WhatsAppTemplateBodyContent $body, + #[Assert\Valid] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; + protected ?\Infobip\Model\WhatsAppTemplateHeaderContent $header = null, + protected ?array $buttons = null, + ) { } - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() + #[Ignore] + public function getModelName(): string { - return self::$setters; + return self::OPENAPI_MODEL_NAME; } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$getters; + return self::DISCRIMINATOR; } - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() + public function getBody(): \Infobip\Model\WhatsAppTemplateBodyContent { - return self::$openAPIModelName; + return $this->body; } - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) + public function setBody(\Infobip\Model\WhatsAppTemplateBodyContent $body): self { - $this->container['body'] = $data['body'] ?? null; - $this->container['header'] = $data['header'] ?? null; - $this->container['buttons'] = $data['buttons'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - if ($this->container['body'] === null) { - $invalidProperties[] = "'body' can't be null"; - } - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets body - * - * @return \Infobip\Model\WhatsAppTemplateBodyContent - */ - public function getBody() - { - return $this->container['body']; - } - - /** - * Sets body - * - * @param \Infobip\Model\WhatsAppTemplateBodyContent $body body - * - * @return self - */ - public function setBody($body) - { - $this->container['body'] = $body; - + $this->body = $body; return $this; } - /** - * Gets header - * - * @return \Infobip\Model\WhatsAppTemplateHeaderContent|null - */ - public function getHeader() + public function getHeader(): \Infobip\Model\WhatsAppTemplateHeaderContent|null { - return $this->container['header']; + return $this->header; } - /** - * Sets header - * - * @param \Infobip\Model\WhatsAppTemplateHeaderContent|null $header header - * - * @return self - */ - public function setHeader($header) + public function setHeader(?\Infobip\Model\WhatsAppTemplateHeaderContent $header): self { - $this->container['header'] = $header; - + $this->header = $header; return $this; } /** - * Gets buttons - * * @return \Infobip\Model\WhatsAppTemplateButtonContent[]|null */ - public function getButtons() + public function getButtons(): ?array { - return $this->container['buttons']; + return $this->buttons; } /** - * Sets buttons - * * @param \Infobip\Model\WhatsAppTemplateButtonContent[]|null $buttons Template buttons. Should be defined in correct order, only if `quick reply` or `dynamic URL` buttons have been registered. It can have up to three `quick reply` buttons or only one `dynamic URL` button. - * - * @return self */ - public function setButtons($buttons) + public function setButtons(?array $buttons): self { - $this->container['buttons'] = $buttons; - + $this->buttons = $buttons; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppTemplateDocumentHeaderContent.php b/Infobip/Model/WhatsAppTemplateDocumentHeaderContent.php index 0c6176f..aae07da 100644 --- a/Infobip/Model/WhatsAppTemplateDocumentHeaderContent.php +++ b/Infobip/Model/WhatsAppTemplateDocumentHeaderContent.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ class WhatsAppTemplateDocumentHeaderContent extends WhatsAppTemplateHeaderContent { public const DISCRIMINATOR = 'type'; + public const OPENAPI_MODEL_NAME = 'WhatsAppTemplateDocumentHeaderContent'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppTemplateDocumentHeaderContent'; + public const TYPE = 'DOCUMENT'; - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'mediaUrl' => 'string', - 'filename' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'mediaUrl' => null, 'filename' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes + parent::openAPITypes(); - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats + parent::openAPIFormats(); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'mediaUrl' => 'mediaUrl', - 'filename' => 'filename' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'mediaUrl' => 'setMediaUrl', - 'filename' => 'setFilename' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'mediaUrl' => 'getMediaUrl', - 'filename' => 'getFilename' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return parent::attributeMap() + self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return parent::setters() + self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array */ - public static function getters() - { - return parent::getters() + self::$getters; - } + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 2048)] + #[Assert\Length(min: 1)] - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - parent::__construct($data); + protected string $mediaUrl, + #[Assert\NotBlank] + #[Assert\Length(max: 240)] + #[Assert\Length(min: 1)] - $this->container['mediaUrl'] = $data['mediaUrl'] ?? null; - $this->container['filename'] = $data['filename'] ?? null; + protected string $filename, + ) { + $modelDiscriminatorValue = 'DOCUMENT'; - $this->container['type'] = 'DOCUMENT'; + parent::__construct( + type: $modelDiscriminatorValue, + ); } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = parent::listInvalidProperties(); - - if ($this->container['mediaUrl'] === null) { - $invalidProperties[] = "'mediaUrl' can't be null"; - } - if ((mb_strlen($this->container['mediaUrl']) > 2048)) { - $invalidProperties[] = "invalid value for 'mediaUrl', the character length must be smaller than or equal to 2048."; - } - - if ((mb_strlen($this->container['mediaUrl']) < 1)) { - $invalidProperties[] = "invalid value for 'mediaUrl', the character length must be bigger than or equal to 1."; - } - - if ($this->container['filename'] === null) { - $invalidProperties[] = "'filename' can't be null"; - } - if ((mb_strlen($this->container['filename']) > 240)) { - $invalidProperties[] = "invalid value for 'filename', the character length must be smaller than or equal to 240."; - } - - if ((mb_strlen($this->container['filename']) < 1)) { - $invalidProperties[] = "invalid value for 'filename', the character length must be bigger than or equal to 1."; - } - - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets mediaUrl - * - * @return string - */ - public function getMediaUrl() + public function getMediaUrl(): string { - return $this->container['mediaUrl']; + return $this->mediaUrl; } - /** - * Sets mediaUrl - * - * @param string $mediaUrl URL of a document sent in the header. It is expected to be a valid URL starting with `https://` or `http://`. Supported document type is `PDF`. Maximum document size is 100MB. - * - * @return self - */ - public function setMediaUrl($mediaUrl) + public function setMediaUrl(string $mediaUrl): self { - if ((mb_strlen($mediaUrl) > 2048)) { - throw new \InvalidArgumentException('invalid length for $mediaUrl when calling WhatsAppTemplateDocumentHeaderContent., must be smaller than or equal to 2048.'); - } - if ((mb_strlen($mediaUrl) < 1)) { - throw new \InvalidArgumentException('invalid length for $mediaUrl when calling WhatsAppTemplateDocumentHeaderContent., must be bigger than or equal to 1.'); - } - - $this->container['mediaUrl'] = $mediaUrl; - + $this->mediaUrl = $mediaUrl; return $this; } - /** - * Gets filename - * - * @return string - */ - public function getFilename() + public function getFilename(): string { - return $this->container['filename']; + return $this->filename; } - /** - * Sets filename - * - * @param string $filename Filename of the document. - * - * @return self - */ - public function setFilename($filename) + public function setFilename(string $filename): self { - if ((mb_strlen($filename) > 240)) { - throw new \InvalidArgumentException('invalid length for $filename when calling WhatsAppTemplateDocumentHeaderContent., must be smaller than or equal to 240.'); - } - if ((mb_strlen($filename) < 1)) { - throw new \InvalidArgumentException('invalid length for $filename when calling WhatsAppTemplateDocumentHeaderContent., must be bigger than or equal to 1.'); - } - - $this->container['filename'] = $filename; - + $this->filename = $filename; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppTemplateHeaderContent.php b/Infobip/Model/WhatsAppTemplateHeaderContent.php index df7fbbc..7fb5214 100644 --- a/Infobip/Model/WhatsAppTemplateHeaderContent.php +++ b/Infobip/Model/WhatsAppTemplateHeaderContent.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppTemplateHeaderContent implements ModelInterface, ArrayAccess, \JsonSerializable +use Symfony\Component\Validator\Constraints as Assert; +use Symfony\Component\Serializer\Annotation as Serializer; +use Symfony\Component\Serializer\Annotation\Ignore; +use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer; +use Symfony\Component\Serializer\Annotation\DiscriminatorMap; + +#[DiscriminatorMap(typeProperty: "type", mapping: [ + "DOCUMENT" => "\Infobip\Model\WhatsAppTemplateDocumentHeaderContent", + "IMAGE" => "\Infobip\Model\WhatsAppTemplateImageHeaderContent", + "LOCATION" => "\Infobip\Model\WhatsAppTemplateLocationHeaderContent", + "TEXT" => "\Infobip\Model\WhatsAppTemplateTextHeaderContent", + "VIDEO" => "\Infobip\Model\WhatsAppTemplateVideoHeaderContent", + "WhatsAppTemplateDocumentHeaderContent" => "\Infobip\Model\WhatsAppTemplateDocumentHeaderContent", + "WhatsAppTemplateImageHeaderContent" => "\Infobip\Model\WhatsAppTemplateImageHeaderContent", + "WhatsAppTemplateLocationHeaderContent" => "\Infobip\Model\WhatsAppTemplateLocationHeaderContent", + "WhatsAppTemplateTextHeaderContent" => "\Infobip\Model\WhatsAppTemplateTextHeaderContent", + "WhatsAppTemplateVideoHeaderContent" => "\Infobip\Model\WhatsAppTemplateVideoHeaderContent", +])] +class WhatsAppTemplateHeaderContent implements ModelInterface { public const DISCRIMINATOR = 'type'; + public const OPENAPI_MODEL_NAME = 'WhatsAppTemplateHeaderContent'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppTemplateHeaderContent'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'type' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'type' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'type' => 'type' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'type' => 'setType' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] */ - protected static $getters = [ - 'type' => 'getType' - ]; + public function __construct( + #[Assert\NotBlank] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; + protected string $type, + ) { } - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() + #[Ignore] + public function getModelName(): string { - return self::$setters; + return self::OPENAPI_MODEL_NAME; } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$getters; + return self::DISCRIMINATOR; } - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() + public function getType(): string { - return self::$openAPIModelName; + return $this->type; } - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) + public function setType(string $type): self { - $this->container['type'] = $data['type'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - if ($this->container['type'] === null) { - $invalidProperties[] = "'type' can't be null"; - } - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets type - * - * @return string - */ - public function getType() - { - return $this->container['type']; - } - - /** - * Sets type - * - * @param string $type type - * - * @return self - */ - public function setType($type) - { - $this->container['type'] = $type; - + $this->type = $type; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppTemplateImageHeaderContent.php b/Infobip/Model/WhatsAppTemplateImageHeaderContent.php index d24ac3f..4477010 100644 --- a/Infobip/Model/WhatsAppTemplateImageHeaderContent.php +++ b/Infobip/Model/WhatsAppTemplateImageHeaderContent.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ class WhatsAppTemplateImageHeaderContent extends WhatsAppTemplateHeaderContent { public const DISCRIMINATOR = 'type'; + public const OPENAPI_MODEL_NAME = 'WhatsAppTemplateImageHeaderContent'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppTemplateImageHeaderContent'; + public const TYPE = 'IMAGE'; - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'mediaUrl' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'mediaUrl' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes + parent::openAPITypes(); - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats + parent::openAPIFormats(); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'mediaUrl' => 'mediaUrl' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] */ - protected static $setters = [ - 'mediaUrl' => 'setMediaUrl' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'mediaUrl' => 'getMediaUrl' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return parent::attributeMap() + self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return parent::setters() + self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return parent::getters() + self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 2048)] + #[Assert\Length(min: 1)] + protected string $mediaUrl, + ) { + $modelDiscriminatorValue = 'IMAGE'; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - parent::__construct($data); - - $this->container['mediaUrl'] = $data['mediaUrl'] ?? null; - - $this->container['type'] = 'IMAGE'; + parent::__construct( + type: $modelDiscriminatorValue, + ); } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = parent::listInvalidProperties(); - - if ($this->container['mediaUrl'] === null) { - $invalidProperties[] = "'mediaUrl' can't be null"; - } - if ((mb_strlen($this->container['mediaUrl']) > 2048)) { - $invalidProperties[] = "invalid value for 'mediaUrl', the character length must be smaller than or equal to 2048."; - } - - if ((mb_strlen($this->container['mediaUrl']) < 1)) { - $invalidProperties[] = "invalid value for 'mediaUrl', the character length must be bigger than or equal to 1."; - } - - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets mediaUrl - * - * @return string - */ - public function getMediaUrl() + public function getMediaUrl(): string { - return $this->container['mediaUrl']; + return $this->mediaUrl; } - /** - * Sets mediaUrl - * - * @param string $mediaUrl URL of an image sent in the header. It is expected to be a valid URL starting with `https://` or `http://`. Supported image types are `JPG`, `JPEG`, `PNG`. Maximum image size is 5MB. - * - * @return self - */ - public function setMediaUrl($mediaUrl) + public function setMediaUrl(string $mediaUrl): self { - if ((mb_strlen($mediaUrl) > 2048)) { - throw new \InvalidArgumentException('invalid length for $mediaUrl when calling WhatsAppTemplateImageHeaderContent., must be smaller than or equal to 2048.'); - } - if ((mb_strlen($mediaUrl) < 1)) { - throw new \InvalidArgumentException('invalid length for $mediaUrl when calling WhatsAppTemplateImageHeaderContent., must be bigger than or equal to 1.'); - } - - $this->container['mediaUrl'] = $mediaUrl; - + $this->mediaUrl = $mediaUrl; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppTemplateLocationHeaderContent.php b/Infobip/Model/WhatsAppTemplateLocationHeaderContent.php index bfe3587..7abbd4d 100644 --- a/Infobip/Model/WhatsAppTemplateLocationHeaderContent.php +++ b/Infobip/Model/WhatsAppTemplateLocationHeaderContent.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ class WhatsAppTemplateLocationHeaderContent extends WhatsAppTemplateHeaderContent { public const DISCRIMINATOR = 'type'; + public const OPENAPI_MODEL_NAME = 'WhatsAppTemplateLocationHeaderContent'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppTemplateLocationHeaderContent'; + public const TYPE = 'LOCATION'; - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ + public const OPENAPI_FORMATS = [ 'latitude' => 'double', 'longitude' => 'double' ]; /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'latitude' => 'double', - 'longitude' => 'double' - ]; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes + parent::openAPITypes(); - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats + parent::openAPIFormats(); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'latitude' => 'latitude', - 'longitude' => 'longitude' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] */ - protected static $setters = [ - 'latitude' => 'setLatitude', - 'longitude' => 'setLongitude' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'latitude' => 'getLatitude', - 'longitude' => 'getLongitude' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return parent::attributeMap() + self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return parent::setters() + self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return parent::getters() + self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - + public function __construct( + #[Assert\NotBlank] + #[Assert\LessThan(90)] + #[Assert\GreaterThan(-90)] - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - parent::__construct($data); + protected float $latitude, + #[Assert\NotBlank] + #[Assert\LessThan(180)] + #[Assert\GreaterThan(-180)] - $this->container['latitude'] = $data['latitude'] ?? null; - $this->container['longitude'] = $data['longitude'] ?? null; + protected float $longitude, + ) { + $modelDiscriminatorValue = 'LOCATION'; - $this->container['type'] = 'LOCATION'; + parent::__construct( + type: $modelDiscriminatorValue, + ); } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = parent::listInvalidProperties(); - - if ($this->container['latitude'] === null) { - $invalidProperties[] = "'latitude' can't be null"; - } - if (($this->container['latitude'] > 90)) { - $invalidProperties[] = "invalid value for 'latitude', must be smaller than or equal to 90."; - } - - if (($this->container['latitude'] < -90)) { - $invalidProperties[] = "invalid value for 'latitude', must be bigger than or equal to -90."; - } - - if ($this->container['longitude'] === null) { - $invalidProperties[] = "'longitude' can't be null"; - } - if (($this->container['longitude'] > 180)) { - $invalidProperties[] = "invalid value for 'longitude', must be smaller than or equal to 180."; - } - - if (($this->container['longitude'] < -180)) { - $invalidProperties[] = "invalid value for 'longitude', must be bigger than or equal to -180."; - } - - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets latitude - * - * @return double - */ - public function getLatitude() + public function getLatitude(): float { - return $this->container['latitude']; + return $this->latitude; } - /** - * Sets latitude - * - * @param double $latitude Latitude of a location sent in the header. - * - * @return self - */ - public function setLatitude($latitude) + public function setLatitude(float $latitude): self { - if (($latitude > 90)) { - throw new \InvalidArgumentException('invalid value for $latitude when calling WhatsAppTemplateLocationHeaderContent., must be smaller than or equal to 90.'); - } - if (($latitude < -90)) { - throw new \InvalidArgumentException('invalid value for $latitude when calling WhatsAppTemplateLocationHeaderContent., must be bigger than or equal to -90.'); - } - - $this->container['latitude'] = $latitude; - + $this->latitude = $latitude; return $this; } - /** - * Gets longitude - * - * @return double - */ - public function getLongitude() + public function getLongitude(): float { - return $this->container['longitude']; + return $this->longitude; } - /** - * Sets longitude - * - * @param double $longitude Longitude of a location sent in the header. - * - * @return self - */ - public function setLongitude($longitude) + public function setLongitude(float $longitude): self { - if (($longitude > 180)) { - throw new \InvalidArgumentException('invalid value for $longitude when calling WhatsAppTemplateLocationHeaderContent., must be smaller than or equal to 180.'); - } - if (($longitude < -180)) { - throw new \InvalidArgumentException('invalid value for $longitude when calling WhatsAppTemplateLocationHeaderContent., must be bigger than or equal to -180.'); - } - - $this->container['longitude'] = $longitude; - + $this->longitude = $longitude; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppTemplatePublicApiRequest.php b/Infobip/Model/WhatsAppTemplatePublicApiRequest.php index b7b0206..4befb7f 100644 --- a/Infobip/Model/WhatsAppTemplatePublicApiRequest.php +++ b/Infobip/Model/WhatsAppTemplatePublicApiRequest.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppTemplatePublicApiRequest implements ModelInterface, ArrayAccess, \JsonSerializable +class WhatsAppTemplatePublicApiRequest implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppTemplatePublicApiRequest'; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'WhatsAppTemplatePublicApiRequest'; - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'name' => 'string', - 'language' => '\Infobip\Model\WhatsAppLanguage', - 'category' => 'string', - 'structure' => '\Infobip\Model\WhatsAppTemplateStructureApiData' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'name' => null, 'language' => null, 'category' => null, @@ -75,380 +37,79 @@ class WhatsAppTemplatePublicApiRequest implements ModelInterface, ArrayAccess, \ ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'name' => 'name', - 'language' => 'language', - 'category' => 'category', - 'structure' => 'structure' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'name' => 'setName', - 'language' => 'setLanguage', - 'category' => 'setCategory', - 'structure' => 'setStructure' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'name' => 'getName', - 'language' => 'getLanguage', - 'category' => 'getCategory', - 'structure' => 'getStructure' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - public const CATEGORY_MARKETING = 'MARKETING'; - public const CATEGORY_TRANSACTIONAL = 'TRANSACTIONAL'; - public const CATEGORY_OTP = 'OTP'; + public function __construct( + #[Assert\NotBlank] + protected string $name, + #[Assert\NotBlank] + #[Assert\Choice(['af','sq','ar','az','bn','bg','ca','zh_CN','zh_HK','zh_TW','hr','cs','da','nl','en','en_GB','en_US','et','fil','fi','fr','ka','de','el','gu','ha','he','hi','hu','id','ga','it','ja','kn','kk','rw_RW','ko','ky_KG','lo','lv','lt','mk','ms','ml','mr','nb','fa','pl','pt_BR','pt_PT','pa','ro','ru','sr','sk','sl','es','es_AR','es_ES','es_MX','sw','sv','ta','te','th','tr','uk','ur','uz','vi','zu','unknown',])] + protected string $language, + #[Assert\NotBlank] + #[Assert\Choice(['MARKETING','TRANSACTIONAL','OTP',])] - /** - * Gets allowable values of the enum - * - * @return string[] - */ - public function getCategoryAllowableValues() - { - return [ - self::CATEGORY_MARKETING, - self::CATEGORY_TRANSACTIONAL, - self::CATEGORY_OTP, - ]; - } - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; + protected string $category, + #[Assert\Valid] + #[Assert\NotBlank] - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['name'] = $data['name'] ?? null; - $this->container['language'] = $data['language'] ?? null; - $this->container['category'] = $data['category'] ?? null; - $this->container['structure'] = $data['structure'] ?? null; + protected \Infobip\Model\WhatsAppTemplateStructureApiData $structure, + ) { } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - if ($this->container['name'] === null) { - $invalidProperties[] = "'name' can't be null"; - } - if ($this->container['language'] === null) { - $invalidProperties[] = "'language' can't be null"; - } - if ($this->container['category'] === null) { - $invalidProperties[] = "'category' can't be null"; - } - $allowedValues = $this->getCategoryAllowableValues(); - if (!is_null($this->container['category']) && !in_array($this->container['category'], $allowedValues, true)) { - $invalidProperties[] = sprintf( - "invalid value '%s' for 'category', must be one of '%s'", - $this->container['category'], - implode("', '", $allowedValues) - ); - } - - if ($this->container['structure'] === null) { - $invalidProperties[] = "'structure' can't be null"; - } - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets name - * - * @return string - */ - public function getName() + public function getName(): string { - return $this->container['name']; + return $this->name; } - /** - * Sets name - * - * @param string $name Template name. Must only contain lowercase alphanumeric characters and underscores. - * - * @return self - */ - public function setName($name) + public function setName(string $name): self { - $this->container['name'] = $name; - + $this->name = $name; return $this; } - /** - * Gets language - * - * @return \Infobip\Model\WhatsAppLanguage - */ - public function getLanguage() + public function getLanguage(): mixed { - return $this->container['language']; + return $this->language; } - /** - * Sets language - * - * @param \Infobip\Model\WhatsAppLanguage $language language - * - * @return self - */ - public function setLanguage($language) + public function setLanguage($language): self { - $this->container['language'] = $language; - + $this->language = $language; return $this; } - /** - * Gets category - * - * @return string - */ - public function getCategory() + public function getCategory(): mixed { - return $this->container['category']; + return $this->category; } - /** - * Sets category - * - * @param string $category Category of the template. - * - * @return self - */ - public function setCategory($category) + public function setCategory($category): self { - $allowedValues = $this->getCategoryAllowableValues(); - if (!in_array($category, $allowedValues, true)) { - throw new \InvalidArgumentException( - sprintf( - "Invalid value '%s' for 'category', must be one of '%s'", - $category, - implode("', '", $allowedValues) - ) - ); - } - $this->container['category'] = $category; - + $this->category = $category; return $this; } - /** - * Gets structure - * - * @return \Infobip\Model\WhatsAppTemplateStructureApiData - */ - public function getStructure() + public function getStructure(): \Infobip\Model\WhatsAppTemplateStructureApiData { - return $this->container['structure']; + return $this->structure; } - /** - * Sets structure - * - * @param \Infobip\Model\WhatsAppTemplateStructureApiData $structure structure - * - * @return self - */ - public function setStructure($structure) + public function setStructure(\Infobip\Model\WhatsAppTemplateStructureApiData $structure): self { - $this->container['structure'] = $structure; - + $this->structure = $structure; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppTemplateQuickReplyButtonContent.php b/Infobip/Model/WhatsAppTemplateQuickReplyButtonContent.php index 5a68cc8..d5e92c5 100644 --- a/Infobip/Model/WhatsAppTemplateQuickReplyButtonContent.php +++ b/Infobip/Model/WhatsAppTemplateQuickReplyButtonContent.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ class WhatsAppTemplateQuickReplyButtonContent extends WhatsAppTemplateButtonContent { public const DISCRIMINATOR = 'type'; + public const OPENAPI_MODEL_NAME = 'WhatsAppTemplateQuickReplyButtonContent'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppTemplateQuickReplyButtonContent'; + public const TYPE = 'QUICK_REPLY'; - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'parameter' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'parameter' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes + parent::openAPITypes(); - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats + parent::openAPIFormats(); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'parameter' => 'parameter' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] */ - protected static $setters = [ - 'parameter' => 'setParameter' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'parameter' => 'getParameter' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return parent::attributeMap() + self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return parent::setters() + self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return parent::getters() + self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 128)] + #[Assert\Length(min: 1)] + protected string $parameter, + ) { + $modelDiscriminatorValue = 'QUICK_REPLY'; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - parent::__construct($data); - - $this->container['parameter'] = $data['parameter'] ?? null; - - $this->container['type'] = 'QUICK_REPLY'; + parent::__construct( + type: $modelDiscriminatorValue, + ); } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = parent::listInvalidProperties(); - - if ($this->container['parameter'] === null) { - $invalidProperties[] = "'parameter' can't be null"; - } - if ((mb_strlen($this->container['parameter']) > 128)) { - $invalidProperties[] = "invalid value for 'parameter', the character length must be smaller than or equal to 128."; - } - - if ((mb_strlen($this->container['parameter']) < 1)) { - $invalidProperties[] = "invalid value for 'parameter', the character length must be bigger than or equal to 1."; - } - - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets parameter - * - * @return string - */ - public function getParameter() + public function getParameter(): string { - return $this->container['parameter']; + return $this->parameter; } - /** - * Sets parameter - * - * @param string $parameter Payload of a `quick reply` button. - * - * @return self - */ - public function setParameter($parameter) + public function setParameter(string $parameter): self { - if ((mb_strlen($parameter) > 128)) { - throw new \InvalidArgumentException('invalid length for $parameter when calling WhatsAppTemplateQuickReplyButtonContent., must be smaller than or equal to 128.'); - } - if ((mb_strlen($parameter) < 1)) { - throw new \InvalidArgumentException('invalid length for $parameter when calling WhatsAppTemplateQuickReplyButtonContent., must be bigger than or equal to 1.'); - } - - $this->container['parameter'] = $parameter; - + $this->parameter = $parameter; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppTemplateStructureApiData.php b/Infobip/Model/WhatsAppTemplateStructureApiData.php index 79777df..694b9c1 100644 --- a/Infobip/Model/WhatsAppTemplateStructureApiData.php +++ b/Infobip/Model/WhatsAppTemplateStructureApiData.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppTemplateStructureApiData implements ModelInterface, ArrayAccess, \JsonSerializable +class WhatsAppTemplateStructureApiData implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppTemplateStructureApiData'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'header' => '\Infobip\Model\WhatsAppHeaderApiData', - 'body' => '\Infobip\Model\WhatsAppBodyApiData', - 'footer' => '\Infobip\Model\WhatsAppFooterApiData', - 'buttons' => '\Infobip\Model\WhatsAppButtonApiData[]', - 'type' => 'string' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'WhatsAppTemplateStructureApiData'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'header' => null, 'body' => null, 'footer' => null, @@ -78,413 +38,99 @@ class WhatsAppTemplateStructureApiData implements ModelInterface, ArrayAccess, \ ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array + * @param \Infobip\Model\WhatsAppButtonApiData[] $buttons */ - public static function openAPITypes() - { - return self::$openAPITypes; - } + public function __construct( + #[Assert\Valid] + #[Assert\NotBlank] - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } + protected \Infobip\Model\WhatsAppBodyApiData $body, + #[Assert\Valid] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'header' => 'header', - 'body' => 'body', - 'footer' => 'footer', - 'buttons' => 'buttons', - 'type' => 'type' - ]; + protected ?\Infobip\Model\WhatsAppHeaderApiData $header = null, + #[Assert\Valid] - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'header' => 'setHeader', - 'body' => 'setBody', - 'footer' => 'setFooter', - 'buttons' => 'setButtons', - 'type' => 'setType' - ]; + protected ?\Infobip\Model\WhatsAppFooterApiData $footer = null, + #[Assert\Count(max: 3)] + #[Assert\Count(min: 1)] - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'header' => 'getHeader', - 'body' => 'getBody', - 'footer' => 'getFooter', - 'buttons' => 'getButtons', - 'type' => 'getType' - ]; + protected ?array $buttons = null, + #[Assert\Choice(['TEXT','MEDIA','UNSUPPORTED',])] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - public const TYPE_TEXT = 'TEXT'; - public const TYPE_MEDIA = 'MEDIA'; - public const TYPE_UNSUPPORTED = 'UNSUPPORTED'; - - - - /** - * Gets allowable values of the enum - * - * @return string[] - */ - public function getTypeAllowableValues() - { - return [ - self::TYPE_TEXT, - self::TYPE_MEDIA, - self::TYPE_UNSUPPORTED, - ]; - } - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['header'] = $data['header'] ?? null; - $this->container['body'] = $data['body'] ?? null; - $this->container['footer'] = $data['footer'] ?? null; - $this->container['buttons'] = $data['buttons'] ?? null; - $this->container['type'] = $data['type'] ?? null; + protected ?string $type = null, + ) { } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - if ($this->container['body'] === null) { - $invalidProperties[] = "'body' can't be null"; - } - if (!is_null($this->container['buttons']) && (count($this->container['buttons']) > 3)) { - $invalidProperties[] = "invalid value for 'buttons', number of items must be less than or equal to 3."; - } - - if (!is_null($this->container['buttons']) && (count($this->container['buttons']) < 1)) { - $invalidProperties[] = "invalid value for 'buttons', number of items must be greater than or equal to 1."; - } - - $allowedValues = $this->getTypeAllowableValues(); - if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { - $invalidProperties[] = sprintf( - "invalid value '%s' for 'type', must be one of '%s'", - $this->container['type'], - implode("', '", $allowedValues) - ); - } - - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets header - * - * @return \Infobip\Model\WhatsAppHeaderApiData|null - */ - public function getHeader() + public function getHeader(): \Infobip\Model\WhatsAppHeaderApiData|null { - return $this->container['header']; + return $this->header; } - /** - * Sets header - * - * @param \Infobip\Model\WhatsAppHeaderApiData|null $header header - * - * @return self - */ - public function setHeader($header) + public function setHeader(?\Infobip\Model\WhatsAppHeaderApiData $header): self { - $this->container['header'] = $header; - + $this->header = $header; return $this; } - /** - * Gets body - * - * @return \Infobip\Model\WhatsAppBodyApiData - */ - public function getBody() + public function getBody(): \Infobip\Model\WhatsAppBodyApiData { - return $this->container['body']; + return $this->body; } - /** - * Sets body - * - * @param \Infobip\Model\WhatsAppBodyApiData $body body - * - * @return self - */ - public function setBody($body) + public function setBody(\Infobip\Model\WhatsAppBodyApiData $body): self { - $this->container['body'] = $body; - + $this->body = $body; return $this; } - /** - * Gets footer - * - * @return \Infobip\Model\WhatsAppFooterApiData|null - */ - public function getFooter() + public function getFooter(): \Infobip\Model\WhatsAppFooterApiData|null { - return $this->container['footer']; + return $this->footer; } - /** - * Sets footer - * - * @param \Infobip\Model\WhatsAppFooterApiData|null $footer footer - * - * @return self - */ - public function setFooter($footer) + public function setFooter(?\Infobip\Model\WhatsAppFooterApiData $footer): self { - $this->container['footer'] = $footer; - + $this->footer = $footer; return $this; } /** - * Gets buttons - * * @return \Infobip\Model\WhatsAppButtonApiData[]|null */ - public function getButtons() + public function getButtons(): ?array { - return $this->container['buttons']; + return $this->buttons; } /** - * Sets buttons - * * @param \Infobip\Model\WhatsAppButtonApiData[]|null $buttons Template buttons. Can be either up to 3 `quick reply` buttons or up to 2 `call to action` buttons. Call to action buttons must be unique in type. - * - * @return self */ - public function setButtons($buttons) + public function setButtons(?array $buttons): self { - if (!is_null($buttons) && (count($buttons) > 3)) { - throw new \InvalidArgumentException('invalid value for $buttons when calling WhatsAppTemplateStructureApiData., number of items must be less than or equal to 3.'); - } - if (!is_null($buttons) && (count($buttons) < 1)) { - throw new \InvalidArgumentException('invalid length for $buttons when calling WhatsAppTemplateStructureApiData., number of items must be greater than or equal to 1.'); - } - $this->container['buttons'] = $buttons; - + $this->buttons = $buttons; return $this; } - /** - * Gets type - * - * @return string|null - */ - public function getType() + public function getType(): mixed { - return $this->container['type']; + return $this->type; } - /** - * Sets type - * - * @param string|null $type type - * - * @return self - */ - public function setType($type) + public function setType($type): self { - $allowedValues = $this->getTypeAllowableValues(); - if (!is_null($type) && !in_array($type, $allowedValues, true)) { - throw new \InvalidArgumentException( - sprintf( - "Invalid value '%s' for 'type', must be one of '%s'", - $type, - implode("', '", $allowedValues) - ) - ); - } - $this->container['type'] = $type; - + $this->type = $type; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppTemplateTextHeaderContent.php b/Infobip/Model/WhatsAppTemplateTextHeaderContent.php index 319228d..58af8d2 100644 --- a/Infobip/Model/WhatsAppTemplateTextHeaderContent.php +++ b/Infobip/Model/WhatsAppTemplateTextHeaderContent.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ class WhatsAppTemplateTextHeaderContent extends WhatsAppTemplateHeaderContent { public const DISCRIMINATOR = 'type'; + public const OPENAPI_MODEL_NAME = 'WhatsAppTemplateTextHeaderContent'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppTemplateTextHeaderContent'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'placeholder' => 'string' - ]; + public const TYPE = 'TEXT'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'placeholder' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes + parent::openAPITypes(); - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats + parent::openAPIFormats(); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'placeholder' => 'placeholder' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'placeholder' => 'setPlaceholder' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'placeholder' => 'getPlaceholder' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return parent::attributeMap() + self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return parent::setters() + self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return parent::getters() + self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model */ - public function __construct(array $data = null) - { - parent::__construct($data); + public function __construct( + #[Assert\NotBlank] - $this->container['placeholder'] = $data['placeholder'] ?? null; + protected string $placeholder, + ) { + $modelDiscriminatorValue = 'TEXT'; - $this->container['type'] = 'TEXT'; + parent::__construct( + type: $modelDiscriminatorValue, + ); } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = parent::listInvalidProperties(); - - if ($this->container['placeholder'] === null) { - $invalidProperties[] = "'placeholder' can't be null"; - } - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets placeholder - * - * @return string - */ - public function getPlaceholder() + public function getPlaceholder(): string { - return $this->container['placeholder']; + return $this->placeholder; } - /** - * Sets placeholder - * - * @param string $placeholder Value of a placeholder in the text header. - * - * @return self - */ - public function setPlaceholder($placeholder) + public function setPlaceholder(string $placeholder): self { - $this->container['placeholder'] = $placeholder; - + $this->placeholder = $placeholder; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppTemplateUrlButtonContent.php b/Infobip/Model/WhatsAppTemplateUrlButtonContent.php index b38f129..0704731 100644 --- a/Infobip/Model/WhatsAppTemplateUrlButtonContent.php +++ b/Infobip/Model/WhatsAppTemplateUrlButtonContent.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ class WhatsAppTemplateUrlButtonContent extends WhatsAppTemplateButtonContent { public const DISCRIMINATOR = 'type'; + public const OPENAPI_MODEL_NAME = 'WhatsAppTemplateUrlButtonContent'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppTemplateUrlButtonContent'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'parameter' => 'string' - ]; + public const TYPE = 'URL'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'parameter' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes + parent::openAPITypes(); - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats + parent::openAPIFormats(); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'parameter' => 'parameter' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'parameter' => 'setParameter' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'parameter' => 'getParameter' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return parent::attributeMap() + self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return parent::setters() + self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return parent::getters() + self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model */ - public function __construct(array $data = null) - { - parent::__construct($data); + public function __construct( + #[Assert\NotBlank] - $this->container['parameter'] = $data['parameter'] ?? null; + protected string $parameter, + ) { + $modelDiscriminatorValue = 'URL'; - $this->container['type'] = 'URL'; + parent::__construct( + type: $modelDiscriminatorValue, + ); } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = parent::listInvalidProperties(); - - if ($this->container['parameter'] === null) { - $invalidProperties[] = "'parameter' can't be null"; - } - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets parameter - * - * @return string - */ - public function getParameter() + public function getParameter(): string { - return $this->container['parameter']; + return $this->parameter; } - /** - * Sets parameter - * - * @param string $parameter URL extension of a `dynamic URL` defined in the registered template. - * - * @return self - */ - public function setParameter($parameter) + public function setParameter(string $parameter): self { - $this->container['parameter'] = $parameter; - + $this->parameter = $parameter; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppTemplateVideoHeaderContent.php b/Infobip/Model/WhatsAppTemplateVideoHeaderContent.php index f7608ee..13ddfe6 100644 --- a/Infobip/Model/WhatsAppTemplateVideoHeaderContent.php +++ b/Infobip/Model/WhatsAppTemplateVideoHeaderContent.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ class WhatsAppTemplateVideoHeaderContent extends WhatsAppTemplateHeaderContent { public const DISCRIMINATOR = 'type'; + public const OPENAPI_MODEL_NAME = 'WhatsAppTemplateVideoHeaderContent'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppTemplateVideoHeaderContent'; + public const TYPE = 'VIDEO'; - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'mediaUrl' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'mediaUrl' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes + parent::openAPITypes(); - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats + parent::openAPIFormats(); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'mediaUrl' => 'mediaUrl' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] */ - protected static $setters = [ - 'mediaUrl' => 'setMediaUrl' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'mediaUrl' => 'getMediaUrl' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return parent::attributeMap() + self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return parent::setters() + self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return parent::getters() + self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 2048)] + #[Assert\Length(min: 1)] + protected string $mediaUrl, + ) { + $modelDiscriminatorValue = 'VIDEO'; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - parent::__construct($data); - - $this->container['mediaUrl'] = $data['mediaUrl'] ?? null; - - $this->container['type'] = 'VIDEO'; + parent::__construct( + type: $modelDiscriminatorValue, + ); } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = parent::listInvalidProperties(); - - if ($this->container['mediaUrl'] === null) { - $invalidProperties[] = "'mediaUrl' can't be null"; - } - if ((mb_strlen($this->container['mediaUrl']) > 2048)) { - $invalidProperties[] = "invalid value for 'mediaUrl', the character length must be smaller than or equal to 2048."; - } - - if ((mb_strlen($this->container['mediaUrl']) < 1)) { - $invalidProperties[] = "invalid value for 'mediaUrl', the character length must be bigger than or equal to 1."; - } - - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets mediaUrl - * - * @return string - */ - public function getMediaUrl() + public function getMediaUrl(): string { - return $this->container['mediaUrl']; + return $this->mediaUrl; } - /** - * Sets mediaUrl - * - * @param string $mediaUrl URL of a video sent in the header. It is expected to be a valid URL starting with `https://` or `http://`. Supported video types are `MP4`, `3GPP`. Maximum video size is 16MB. - * - * @return self - */ - public function setMediaUrl($mediaUrl) + public function setMediaUrl(string $mediaUrl): self { - if ((mb_strlen($mediaUrl) > 2048)) { - throw new \InvalidArgumentException('invalid length for $mediaUrl when calling WhatsAppTemplateVideoHeaderContent., must be smaller than or equal to 2048.'); - } - if ((mb_strlen($mediaUrl) < 1)) { - throw new \InvalidArgumentException('invalid length for $mediaUrl when calling WhatsAppTemplateVideoHeaderContent., must be bigger than or equal to 1.'); - } - - $this->container['mediaUrl'] = $mediaUrl; - + $this->mediaUrl = $mediaUrl; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppTemplatesApiResponse.php b/Infobip/Model/WhatsAppTemplatesApiResponse.php index 8d26d98..b4774b2 100644 --- a/Infobip/Model/WhatsAppTemplatesApiResponse.php +++ b/Infobip/Model/WhatsAppTemplatesApiResponse.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppTemplatesApiResponse implements ModelInterface, ArrayAccess, \JsonSerializable +class WhatsAppTemplatesApiResponse implements ModelInterface { - public const DISCRIMINATOR = null; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'WhatsAppTemplatesApiResponse'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppTemplatesApiResponse'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'templates' => '\Infobip\Model\WhatsAppTemplateApiResponse[]' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'templates' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'templates' => 'templates' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'templates' => 'setTemplates' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] + * @param \Infobip\Model\WhatsAppTemplateApiResponse[] $templates */ - protected static $getters = [ - 'templates' => 'getTemplates' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; + public function __construct( + protected ?array $templates = null, + ) { } - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() + #[Ignore] + public function getModelName(): string { - return self::$setters; + return self::OPENAPI_MODEL_NAME; } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$getters; + return self::DISCRIMINATOR; } /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['templates'] = $data['templates'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $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() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets templates - * * @return \Infobip\Model\WhatsAppTemplateApiResponse[]|null */ - public function getTemplates() + public function getTemplates(): ?array { - return $this->container['templates']; + return $this->templates; } /** - * Sets templates - * * @param \Infobip\Model\WhatsAppTemplateApiResponse[]|null $templates List of all templates for given sender. - * - * @return self */ - public function setTemplates($templates) + public function setTemplates(?array $templates): self { - $this->container['templates'] = $templates; - + $this->templates = $templates; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppTextContent.php b/Infobip/Model/WhatsAppTextContent.php index 3734825..317457b 100644 --- a/Infobip/Model/WhatsAppTextContent.php +++ b/Infobip/Model/WhatsAppTextContent.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppTextContent implements ModelInterface, ArrayAccess, \JsonSerializable +class WhatsAppTextContent implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppTextContent'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'text' => 'string', - 'previewUrl' => 'bool' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'WhatsAppTextContent'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'text' => null, 'previewUrl' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'text' => 'text', - 'previewUrl' => 'previewUrl' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'text' => 'setText', - 'previewUrl' => 'setPreviewUrl' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'text' => 'getText', - 'previewUrl' => 'getPreviewUrl' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] */ - protected $container = []; + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 4096)] + #[Assert\Length(min: 1)] - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['text'] = $data['text'] ?? null; - $this->container['previewUrl'] = $data['previewUrl'] ?? null; + protected string $text, + protected ?bool $previewUrl = null, + ) { } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - if ($this->container['text'] === null) { - $invalidProperties[] = "'text' can't be null"; - } - if ((mb_strlen($this->container['text']) > 4096)) { - $invalidProperties[] = "invalid value for 'text', the character length must be smaller than or equal to 4096."; - } - - if ((mb_strlen($this->container['text']) < 1)) { - $invalidProperties[] = "invalid value for 'text', the character length must be bigger than or equal to 1."; - } - - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets text - * - * @return string - */ - public function getText() + public function getText(): string { - return $this->container['text']; + return $this->text; } - /** - * Sets text - * - * @param string $text Content of the message being sent. - * - * @return self - */ - public function setText($text) + public function setText(string $text): self { - if ((mb_strlen($text) > 4096)) { - throw new \InvalidArgumentException('invalid length for $text when calling WhatsAppTextContent., must be smaller than or equal to 4096.'); - } - if ((mb_strlen($text) < 1)) { - throw new \InvalidArgumentException('invalid length for $text when calling WhatsAppTextContent., must be bigger than or equal to 1.'); - } - - $this->container['text'] = $text; - + $this->text = $text; return $this; } - /** - * Gets previewUrl - * - * @return bool|null - */ - public function getPreviewUrl() + public function getPreviewUrl(): bool|null { - return $this->container['previewUrl']; + return $this->previewUrl; } - /** - * Sets previewUrl - * - * @param bool|null $previewUrl Allows for URL preview from within the message. If set to `true`, the message content must contain a URL starting with `https://` or `http://`. Defaults to `false`. - * - * @return self - */ - public function setPreviewUrl($previewUrl) + public function setPreviewUrl(?bool $previewUrl): self { - $this->container['previewUrl'] = $previewUrl; - + $this->previewUrl = $previewUrl; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppTextHeaderApiData.php b/Infobip/Model/WhatsAppTextHeaderApiData.php index bb63159..e3b185e 100644 --- a/Infobip/Model/WhatsAppTextHeaderApiData.php +++ b/Infobip/Model/WhatsAppTextHeaderApiData.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ class WhatsAppTextHeaderApiData extends WhatsAppHeaderApiData { public const DISCRIMINATOR = 'format'; + public const OPENAPI_MODEL_NAME = 'WhatsAppTextHeaderApiData'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppTextHeaderApiData'; + public const FORMAT = 'TEXT'; - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'text' => 'string', - 'example' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'text' => null, 'example' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes + parent::openAPITypes(); - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats + parent::openAPIFormats(); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'text' => 'text', - 'example' => 'example' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] */ - protected static $setters = [ - 'text' => 'setText', - 'example' => 'setExample' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'text' => 'getText', - 'example' => 'getExample' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return parent::attributeMap() + self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return parent::setters() + self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return parent::getters() + self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - + public function __construct( + #[Assert\NotBlank] + protected string $text, + protected ?string $example = null, + ) { + $modelDiscriminatorValue = 'TEXT'; - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - parent::__construct($data); - - $this->container['text'] = $data['text'] ?? null; - $this->container['example'] = $data['example'] ?? null; - - $this->container['format'] = 'TEXT'; + parent::__construct( + format: $modelDiscriminatorValue, + ); } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = parent::listInvalidProperties(); - - if ($this->container['text'] === null) { - $invalidProperties[] = "'text' can't be null"; - } - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets text - * - * @return string - */ - public function getText() + public function getText(): string { - return $this->container['text']; + return $this->text; } - /** - * Sets text - * - * @param string $text Template header text. Can contain up to 60 characters, with one placeholder {{1}}. - * - * @return self - */ - public function setText($text) + public function setText(string $text): self { - $this->container['text'] = $text; - + $this->text = $text; return $this; } - /** - * Gets example - * - * @return string|null - */ - public function getExample() + public function getExample(): string|null { - return $this->container['example']; + return $this->example; } - /** - * Sets example - * - * @param string|null $example An example of the content for the template header a user could use. Cannot contain placeholders. - * - * @return self - */ - public function setExample($example) + public function setExample(?string $example): self { - $this->container['example'] = $example; - + $this->example = $example; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppTextMessage.php b/Infobip/Model/WhatsAppTextMessage.php index d51b9a8..97ebbf4 100644 --- a/Infobip/Model/WhatsAppTextMessage.php +++ b/Infobip/Model/WhatsAppTextMessage.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppTextMessage implements ModelInterface, ArrayAccess, \JsonSerializable +class WhatsAppTextMessage implements ModelInterface { - public const DISCRIMINATOR = null; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'WhatsAppTextMessage'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppTextMessage'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'from' => 'string', - 'to' => 'string', - 'messageId' => 'string', - 'content' => '\Infobip\Model\WhatsAppTextContent', - 'callbackData' => 'string', - 'notifyUrl' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'from' => null, 'to' => null, 'messageId' => null, @@ -79,472 +39,112 @@ class WhatsAppTextMessage implements ModelInterface, ArrayAccess, \JsonSerializa ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array */ - public static function openAPITypes() - { - return self::$openAPITypes; - } + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 24)] + #[Assert\Length(min: 1)] - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } + protected string $from, + #[Assert\NotBlank] + #[Assert\Length(max: 24)] + #[Assert\Length(min: 1)] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'from' => 'from', - 'to' => 'to', - 'messageId' => 'messageId', - 'content' => 'content', - 'callbackData' => 'callbackData', - 'notifyUrl' => 'notifyUrl' - ]; + protected string $to, + #[Assert\Valid] + #[Assert\NotBlank] - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'from' => 'setFrom', - 'to' => 'setTo', - 'messageId' => 'setMessageId', - 'content' => 'setContent', - 'callbackData' => 'setCallbackData', - 'notifyUrl' => 'setNotifyUrl' - ]; + protected \Infobip\Model\WhatsAppTextContent $content, + #[Assert\Length(max: 100)] + #[Assert\Length(min: 0)] - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'from' => 'getFrom', - 'to' => 'getTo', - 'messageId' => 'getMessageId', - 'content' => 'getContent', - 'callbackData' => 'getCallbackData', - 'notifyUrl' => 'getNotifyUrl' - ]; + protected ?string $messageId = null, + #[Assert\Length(max: 4000)] + #[Assert\Length(min: 0)] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } + protected ?string $callbackData = null, + #[Assert\Length(max: 2048)] + #[Assert\Length(min: 0)] - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; + protected ?string $notifyUrl = null, + ) { } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public function getModelName(): string { - return self::$getters; + return self::OPENAPI_MODEL_NAME; } - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) + #[Ignore] + public static function getDiscriminator(): ?string { - $this->container['from'] = $data['from'] ?? null; - $this->container['to'] = $data['to'] ?? null; - $this->container['messageId'] = $data['messageId'] ?? null; - $this->container['content'] = $data['content'] ?? null; - $this->container['callbackData'] = $data['callbackData'] ?? null; - $this->container['notifyUrl'] = $data['notifyUrl'] ?? null; + return self::DISCRIMINATOR; } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + public function getFrom(): string { - $invalidProperties = []; - - if ($this->container['from'] === null) { - $invalidProperties[] = "'from' can't be null"; - } - if ((mb_strlen($this->container['from']) > 24)) { - $invalidProperties[] = "invalid value for 'from', the character length must be smaller than or equal to 24."; - } - - if ((mb_strlen($this->container['from']) < 1)) { - $invalidProperties[] = "invalid value for 'from', the character length must be bigger than or equal to 1."; - } - - if ($this->container['to'] === null) { - $invalidProperties[] = "'to' can't be null"; - } - if ((mb_strlen($this->container['to']) > 24)) { - $invalidProperties[] = "invalid value for 'to', the character length must be smaller than or equal to 24."; - } - - if ((mb_strlen($this->container['to']) < 1)) { - $invalidProperties[] = "invalid value for 'to', the character length must be bigger than or equal to 1."; - } - - if (!is_null($this->container['messageId']) && (mb_strlen($this->container['messageId']) > 50)) { - $invalidProperties[] = "invalid value for 'messageId', the character length must be smaller than or equal to 50."; - } - - if (!is_null($this->container['messageId']) && (mb_strlen($this->container['messageId']) < 0)) { - $invalidProperties[] = "invalid value for 'messageId', the character length must be bigger than or equal to 0."; - } - - if ($this->container['content'] === null) { - $invalidProperties[] = "'content' can't be null"; - } - if (!is_null($this->container['callbackData']) && (mb_strlen($this->container['callbackData']) > 4000)) { - $invalidProperties[] = "invalid value for 'callbackData', the character length must be smaller than or equal to 4000."; - } - - if (!is_null($this->container['callbackData']) && (mb_strlen($this->container['callbackData']) < 0)) { - $invalidProperties[] = "invalid value for 'callbackData', the character length must be bigger than or equal to 0."; - } - - if (!is_null($this->container['notifyUrl']) && (mb_strlen($this->container['notifyUrl']) > 2048)) { - $invalidProperties[] = "invalid value for 'notifyUrl', the character length must be smaller than or equal to 2048."; - } - - if (!is_null($this->container['notifyUrl']) && (mb_strlen($this->container['notifyUrl']) < 0)) { - $invalidProperties[] = "invalid value for 'notifyUrl', the character length must be bigger than or equal to 0."; - } - - return $invalidProperties; + return $this->from; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + public function setFrom(string $from): self { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets from - * - * @return string - */ - public function getFrom() - { - return $this->container['from']; - } - - /** - * Sets from - * - * @param string $from Registered WhatsApp sender number. Must be in international format and comply with [WhatsApp's requirements](https://www.infobip.com/docs/whatsapp/get-started#phone-number-what-you-need-to-know). - * - * @return self - */ - public function setFrom($from) - { - if ((mb_strlen($from) > 24)) { - throw new \InvalidArgumentException('invalid length for $from when calling WhatsAppTextMessage., must be smaller than or equal to 24.'); - } - if ((mb_strlen($from) < 1)) { - throw new \InvalidArgumentException('invalid length for $from when calling WhatsAppTextMessage., must be bigger than or equal to 1.'); - } - - $this->container['from'] = $from; - + $this->from = $from; return $this; } - /** - * Gets to - * - * @return string - */ - public function getTo() + public function getTo(): string { - return $this->container['to']; + return $this->to; } - /** - * Sets to - * - * @param string $to Message recipient number. Must be in international format. - * - * @return self - */ - public function setTo($to) + public function setTo(string $to): self { - if ((mb_strlen($to) > 24)) { - throw new \InvalidArgumentException('invalid length for $to when calling WhatsAppTextMessage., must be smaller than or equal to 24.'); - } - if ((mb_strlen($to) < 1)) { - throw new \InvalidArgumentException('invalid length for $to when calling WhatsAppTextMessage., must be bigger than or equal to 1.'); - } - - $this->container['to'] = $to; - + $this->to = $to; return $this; } - /** - * Gets messageId - * - * @return string|null - */ - public function getMessageId() + public function getMessageId(): string|null { - return $this->container['messageId']; + return $this->messageId; } - /** - * Sets messageId - * - * @param string|null $messageId The ID that uniquely identifies the message sent. - * - * @return self - */ - public function setMessageId($messageId) + public function setMessageId(?string $messageId): self { - if (!is_null($messageId) && (mb_strlen($messageId) > 50)) { - throw new \InvalidArgumentException('invalid length for $messageId when calling WhatsAppTextMessage., must be smaller than or equal to 50.'); - } - if (!is_null($messageId) && (mb_strlen($messageId) < 0)) { - throw new \InvalidArgumentException('invalid length for $messageId when calling WhatsAppTextMessage., must be bigger than or equal to 0.'); - } - - $this->container['messageId'] = $messageId; - + $this->messageId = $messageId; return $this; } - /** - * Gets content - * - * @return \Infobip\Model\WhatsAppTextContent - */ - public function getContent() + public function getContent(): \Infobip\Model\WhatsAppTextContent { - return $this->container['content']; + return $this->content; } - /** - * Sets content - * - * @param \Infobip\Model\WhatsAppTextContent $content content - * - * @return self - */ - public function setContent($content) + public function setContent(\Infobip\Model\WhatsAppTextContent $content): self { - $this->container['content'] = $content; - + $this->content = $content; return $this; } - /** - * Gets callbackData - * - * @return string|null - */ - public function getCallbackData() + public function getCallbackData(): string|null { - return $this->container['callbackData']; + return $this->callbackData; } - /** - * Sets callbackData - * - * @param string|null $callbackData Custom client data that will be included in a [Delivery Report](#channels/whatsapp/receive-whatsapp-delivery-reports). - * - * @return self - */ - public function setCallbackData($callbackData) + public function setCallbackData(?string $callbackData): self { - if (!is_null($callbackData) && (mb_strlen($callbackData) > 4000)) { - throw new \InvalidArgumentException('invalid length for $callbackData when calling WhatsAppTextMessage., must be smaller than or equal to 4000.'); - } - if (!is_null($callbackData) && (mb_strlen($callbackData) < 0)) { - throw new \InvalidArgumentException('invalid length for $callbackData when calling WhatsAppTextMessage., must be bigger than or equal to 0.'); - } - - $this->container['callbackData'] = $callbackData; - + $this->callbackData = $callbackData; return $this; } - /** - * Gets notifyUrl - * - * @return string|null - */ - public function getNotifyUrl() + public function getNotifyUrl(): string|null { - return $this->container['notifyUrl']; + return $this->notifyUrl; } - /** - * Sets notifyUrl - * - * @param string|null $notifyUrl The URL on your callback server to which delivery and seen reports will be sent. [Delivery report format](#channels/whatsapp/receive-whatsapp-delivery-reports), [Seen report format](#channels/whatsapp/receive-whatsapp-seen-reports). - * - * @return self - */ - public function setNotifyUrl($notifyUrl) + public function setNotifyUrl(?string $notifyUrl): self { - if (!is_null($notifyUrl) && (mb_strlen($notifyUrl) > 2048)) { - throw new \InvalidArgumentException('invalid length for $notifyUrl when calling WhatsAppTextMessage., must be smaller than or equal to 2048.'); - } - if (!is_null($notifyUrl) && (mb_strlen($notifyUrl) < 0)) { - throw new \InvalidArgumentException('invalid length for $notifyUrl when calling WhatsAppTextMessage., must be bigger than or equal to 0.'); - } - - $this->container['notifyUrl'] = $notifyUrl; - + $this->notifyUrl = $notifyUrl; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppUrlButtonApiData.php b/Infobip/Model/WhatsAppUrlButtonApiData.php index e413992..4137a63 100644 --- a/Infobip/Model/WhatsAppUrlButtonApiData.php +++ b/Infobip/Model/WhatsAppUrlButtonApiData.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ class WhatsAppUrlButtonApiData extends WhatsAppButtonApiData { public const DISCRIMINATOR = 'type'; + public const OPENAPI_MODEL_NAME = 'WhatsAppUrlButtonApiData'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppUrlButtonApiData'; + public const TYPE = 'URL'; - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'url' => 'string', - 'example' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'url' => null, 'example' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes + parent::openAPITypes(); - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats + parent::openAPIFormats(); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'url' => 'url', - 'example' => 'example' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] */ - protected static $setters = [ - 'url' => 'setUrl', - 'example' => 'setExample' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'url' => 'getUrl', - 'example' => 'getExample' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return parent::attributeMap() + self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return parent::setters() + self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return parent::getters() + self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 200)] + #[Assert\Length(min: 0)] + protected string $text, + #[Assert\NotBlank] + protected string $url, + protected ?string $example = null, + ) { + $modelDiscriminatorValue = 'URL'; - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - parent::__construct($data); - - $this->container['url'] = $data['url'] ?? null; - $this->container['example'] = $data['example'] ?? null; - - $this->container['type'] = 'URL'; + parent::__construct( + type: $modelDiscriminatorValue, + text: $text, + ); } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = parent::listInvalidProperties(); - - if ($this->container['url'] === null) { - $invalidProperties[] = "'url' can't be null"; - } - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets url - * - * @return string - */ - public function getUrl() + public function getUrl(): string { - return $this->container['url']; + return $this->url; } - /** - * Sets url - * - * @param string $url URL to which the end-user will be directed when hitting the button. URL is expected to start with `https://` or `http://`. Can be static or dynamic. For dynamic URL registration, add a placeholder {{1}} at the end of the link. Example: `https://www.infobip.com/{{1}}`. - * - * @return self - */ - public function setUrl($url) + public function setUrl(string $url): self { - $this->container['url'] = $url; - + $this->url = $url; return $this; } - /** - * Gets example - * - * @return string|null - */ - public function getExample() + public function getExample(): string|null { - return $this->container['example']; + return $this->example; } - /** - * Sets example - * - * @param string|null $example An example of a URL a user could use. Should be a valid URL that starts with `https://` or `http://`. Cannot contain placeholders. - * - * @return self - */ - public function setExample($example) + public function setExample(?string $example): self { - $this->container['example'] = $example; - + $this->example = $example; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppUrlContent.php b/Infobip/Model/WhatsAppUrlContent.php index 247802a..d67acf3 100644 --- a/Infobip/Model/WhatsAppUrlContent.php +++ b/Infobip/Model/WhatsAppUrlContent.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppUrlContent implements ModelInterface, ArrayAccess, \JsonSerializable +class WhatsAppUrlContent implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppUrlContent'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'url' => 'string', - 'type' => '\Infobip\Model\WhatsAppUrlType' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'WhatsAppUrlContent'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'url' => null, 'type' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'url' => 'url', - 'type' => 'type' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'url' => 'setUrl', - 'type' => 'setType' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] */ - protected static $getters = [ - 'url' => 'getUrl', - 'type' => 'getType' - ]; + public function __construct( + protected ?string $url = null, + #[Assert\Choice(['HOME','WORK',])] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; + protected ?string $type = null, + ) { } - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() + #[Ignore] + public function getModelName(): string { - return self::$setters; + return self::OPENAPI_MODEL_NAME; } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public static function getDiscriminator(): ?string { - return self::$getters; + return self::DISCRIMINATOR; } - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() + public function getUrl(): string|null { - return self::$openAPIModelName; + return $this->url; } - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['url'] = $data['url'] ?? null; - $this->container['type'] = $data['type'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + public function setUrl(?string $url): self { - $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() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets url - * - * @return string|null - */ - public function getUrl() - { - return $this->container['url']; - } - - /** - * Sets url - * - * @param string|null $url Contact's url. - * - * @return self - */ - public function setUrl($url) - { - $this->container['url'] = $url; - + $this->url = $url; return $this; } - /** - * Gets type - * - * @return \Infobip\Model\WhatsAppUrlType|null - */ - public function getType() + public function getType(): mixed { - return $this->container['type']; + return $this->type; } - /** - * Sets type - * - * @param \Infobip\Model\WhatsAppUrlType|null $type type - * - * @return self - */ - public function setType($type) + public function setType($type): self { - $this->container['type'] = $type; - + $this->type = $type; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppUrlDeletionRequest.php b/Infobip/Model/WhatsAppUrlDeletionRequest.php index 1f2c6f4..63bf929 100644 --- a/Infobip/Model/WhatsAppUrlDeletionRequest.php +++ b/Infobip/Model/WhatsAppUrlDeletionRequest.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppUrlDeletionRequest implements ModelInterface, ArrayAccess, \JsonSerializable +class WhatsAppUrlDeletionRequest implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppUrlDeletionRequest'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'url' => 'string' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'WhatsAppUrlDeletionRequest'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'url' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'url' => 'url' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'url' => 'setUrl' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'url' => 'getUrl' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] */ - protected $container = []; + public function __construct( + #[Assert\NotBlank] - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['url'] = $data['url'] ?? null; + protected string $url, + ) { } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - if ($this->container['url'] === null) { - $invalidProperties[] = "'url' can't be null"; - } - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets url - * - * @return string - */ - public function getUrl() + public function getUrl(): string { - return $this->container['url']; + return $this->url; } - /** - * Sets url - * - * @param string $url URL of the WhatsApp media to be deleted. - * - * @return self - */ - public function setUrl($url) + public function setUrl(string $url): self { - $this->container['url'] = $url; - + $this->url = $url; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppUrlType.php b/Infobip/Model/WhatsAppUrlType.php index f5f5374..795c280 100644 --- a/Infobip/Model/WhatsAppUrlType.php +++ b/Infobip/Model/WhatsAppUrlType.php @@ -1,14 +1,8 @@ value = $value; + } + + public static function HOME(): WhatsAppUrlType + { + return new self('HOME'); + } + + public static function WORK(): WhatsAppUrlType + { + return new self('WORK'); + } + + public function __toString(): string { - return [ - self::HOME, - self::WORK, - ]; + return $this->value; } } diff --git a/Infobip/Model/WhatsAppVideoContent.php b/Infobip/Model/WhatsAppVideoContent.php index 38af26e..4ba619e 100644 --- a/Infobip/Model/WhatsAppVideoContent.php +++ b/Infobip/Model/WhatsAppVideoContent.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppVideoContent implements ModelInterface, ArrayAccess, \JsonSerializable +class WhatsAppVideoContent implements ModelInterface { - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppVideoContent'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'mediaUrl' => 'string', - 'caption' => 'string' - ]; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'WhatsAppVideoContent'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'mediaUrl' => null, 'caption' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'mediaUrl' => 'mediaUrl', - 'caption' => 'caption' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] */ - protected static $setters = [ - 'mediaUrl' => 'setMediaUrl', - 'caption' => 'setCaption' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'mediaUrl' => 'getMediaUrl', - 'caption' => 'getCaption' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 2048)] + #[Assert\Length(min: 1)] - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; + protected string $mediaUrl, + #[Assert\Length(max: 3000)] + #[Assert\Length(min: 0)] - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['mediaUrl'] = $data['mediaUrl'] ?? null; - $this->container['caption'] = $data['caption'] ?? null; + protected ?string $caption = null, + ) { } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = []; - - if ($this->container['mediaUrl'] === null) { - $invalidProperties[] = "'mediaUrl' can't be null"; - } - if ((mb_strlen($this->container['mediaUrl']) > 2048)) { - $invalidProperties[] = "invalid value for 'mediaUrl', the character length must be smaller than or equal to 2048."; - } - - if ((mb_strlen($this->container['mediaUrl']) < 1)) { - $invalidProperties[] = "invalid value for 'mediaUrl', the character length must be bigger than or equal to 1."; - } - - if (!is_null($this->container['caption']) && (mb_strlen($this->container['caption']) > 3000)) { - $invalidProperties[] = "invalid value for 'caption', the character length must be smaller than or equal to 3000."; - } - - if (!is_null($this->container['caption']) && (mb_strlen($this->container['caption']) < 0)) { - $invalidProperties[] = "invalid value for 'caption', the character length must be bigger than or equal to 0."; - } - - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets mediaUrl - * - * @return string - */ - public function getMediaUrl() + public function getMediaUrl(): string { - return $this->container['mediaUrl']; + return $this->mediaUrl; } - /** - * Sets mediaUrl - * - * @param string $mediaUrl URL of a video sent in a WhatsApp message. Must be a valid URL starting with `https://` or `http://`. Supported video types are `MP4`, `3GPP`. Maximum video size is 16MB. - * - * @return self - */ - public function setMediaUrl($mediaUrl) + public function setMediaUrl(string $mediaUrl): self { - if ((mb_strlen($mediaUrl) > 2048)) { - throw new \InvalidArgumentException('invalid length for $mediaUrl when calling WhatsAppVideoContent., must be smaller than or equal to 2048.'); - } - if ((mb_strlen($mediaUrl) < 1)) { - throw new \InvalidArgumentException('invalid length for $mediaUrl when calling WhatsAppVideoContent., must be bigger than or equal to 1.'); - } - - $this->container['mediaUrl'] = $mediaUrl; - + $this->mediaUrl = $mediaUrl; return $this; } - /** - * Gets caption - * - * @return string|null - */ - public function getCaption() + public function getCaption(): string|null { - return $this->container['caption']; + return $this->caption; } - /** - * Sets caption - * - * @param string|null $caption Caption of the video. - * - * @return self - */ - public function setCaption($caption) + public function setCaption(?string $caption): self { - if (!is_null($caption) && (mb_strlen($caption) > 3000)) { - throw new \InvalidArgumentException('invalid length for $caption when calling WhatsAppVideoContent., must be smaller than or equal to 3000.'); - } - if (!is_null($caption) && (mb_strlen($caption) < 0)) { - throw new \InvalidArgumentException('invalid length for $caption when calling WhatsAppVideoContent., must be bigger than or equal to 0.'); - } - - $this->container['caption'] = $caption; - + $this->caption = $caption; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppVideoHeaderApiData.php b/Infobip/Model/WhatsAppVideoHeaderApiData.php index 44099e4..dbb67c3 100644 --- a/Infobip/Model/WhatsAppVideoHeaderApiData.php +++ b/Infobip/Model/WhatsAppVideoHeaderApiData.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ class WhatsAppVideoHeaderApiData extends WhatsAppHeaderApiData { public const DISCRIMINATOR = 'format'; + public const OPENAPI_MODEL_NAME = 'WhatsAppVideoHeaderApiData'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppVideoHeaderApiData'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'example' => 'string' - ]; + public const FORMAT = 'VIDEO'; - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'example' => null ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes + parent::openAPITypes(); - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats + parent::openAPIFormats(); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'example' => 'example' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'example' => 'setExample' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'example' => 'getExample' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return parent::attributeMap() + self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array */ - public static function setters() - { - return parent::setters() + self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return parent::getters() + self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - + public function __construct( + protected ?string $example = null, + ) { + $modelDiscriminatorValue = 'VIDEO'; - - - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - parent::__construct($data); - - $this->container['example'] = $data['example'] ?? null; - - $this->container['format'] = 'VIDEO'; + parent::__construct( + format: $modelDiscriminatorValue, + ); } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + #[Ignore] + public function getModelName(): string { - $invalidProperties = parent::listInvalidProperties(); - - return $invalidProperties; + return self::OPENAPI_MODEL_NAME; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + #[Ignore] + public static function getDiscriminator(): ?string { - return count($this->listInvalidProperties()) === 0; + return self::DISCRIMINATOR; } - - /** - * Gets example - * - * @return string|null - */ - public function getExample() + public function getExample(): string|null { - return $this->container['example']; + return $this->example; } - /** - * Sets example - * - * @param string|null $example An example of a template header video a user could use. Should be a valid URL that starts with `http` or `https`. Supported video type is `MP4`. Maximum video size is 16MB. Cannot contain placeholders. - * - * @return self - */ - public function setExample($example) + public function setExample(?string $example): self { - $this->container['example'] = $example; - + $this->example = $example; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppVideoMessage.php b/Infobip/Model/WhatsAppVideoMessage.php index 2e16e5d..e1f1fc4 100644 --- a/Infobip/Model/WhatsAppVideoMessage.php +++ b/Infobip/Model/WhatsAppVideoMessage.php @@ -1,14 +1,8 @@ - * @template TKey int|null - * @template TValue mixed|null - */ -class WhatsAppVideoMessage implements ModelInterface, ArrayAccess, \JsonSerializable +class WhatsAppVideoMessage implements ModelInterface { - public const DISCRIMINATOR = null; + public const DISCRIMINATOR = ''; + public const OPENAPI_MODEL_NAME = 'WhatsAppVideoMessage'; - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'WhatsAppVideoMessage'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'from' => 'string', - 'to' => 'string', - 'messageId' => 'string', - 'content' => '\Infobip\Model\WhatsAppVideoContent', - 'callbackData' => 'string', - 'notifyUrl' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ + public const OPENAPI_FORMATS = [ 'from' => null, 'to' => null, 'messageId' => null, @@ -79,472 +39,112 @@ class WhatsAppVideoMessage implements ModelInterface, ArrayAccess, \JsonSerializ ]; /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array */ - public static function openAPITypes() - { - return self::$openAPITypes; - } + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 24)] + #[Assert\Length(min: 1)] - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } + protected string $from, + #[Assert\NotBlank] + #[Assert\Length(max: 24)] + #[Assert\Length(min: 1)] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'from' => 'from', - 'to' => 'to', - 'messageId' => 'messageId', - 'content' => 'content', - 'callbackData' => 'callbackData', - 'notifyUrl' => 'notifyUrl' - ]; + protected string $to, + #[Assert\Valid] + #[Assert\NotBlank] - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'from' => 'setFrom', - 'to' => 'setTo', - 'messageId' => 'setMessageId', - 'content' => 'setContent', - 'callbackData' => 'setCallbackData', - 'notifyUrl' => 'setNotifyUrl' - ]; + protected \Infobip\Model\WhatsAppVideoContent $content, + #[Assert\Length(max: 100)] + #[Assert\Length(min: 0)] - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'from' => 'getFrom', - 'to' => 'getTo', - 'messageId' => 'getMessageId', - 'content' => 'getContent', - 'callbackData' => 'getCallbackData', - 'notifyUrl' => 'getNotifyUrl' - ]; + protected ?string $messageId = null, + #[Assert\Length(max: 4000)] + #[Assert\Length(min: 0)] - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } + protected ?string $callbackData = null, + #[Assert\Length(max: 2048)] + #[Assert\Length(min: 0)] - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; + protected ?string $notifyUrl = null, + ) { } - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() + #[Ignore] + public function getModelName(): string { - return self::$getters; + return self::OPENAPI_MODEL_NAME; } - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) + #[Ignore] + public static function getDiscriminator(): ?string { - $this->container['from'] = $data['from'] ?? null; - $this->container['to'] = $data['to'] ?? null; - $this->container['messageId'] = $data['messageId'] ?? null; - $this->container['content'] = $data['content'] ?? null; - $this->container['callbackData'] = $data['callbackData'] ?? null; - $this->container['notifyUrl'] = $data['notifyUrl'] ?? null; + return self::DISCRIMINATOR; } - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() + public function getFrom(): string { - $invalidProperties = []; - - if ($this->container['from'] === null) { - $invalidProperties[] = "'from' can't be null"; - } - if ((mb_strlen($this->container['from']) > 24)) { - $invalidProperties[] = "invalid value for 'from', the character length must be smaller than or equal to 24."; - } - - if ((mb_strlen($this->container['from']) < 1)) { - $invalidProperties[] = "invalid value for 'from', the character length must be bigger than or equal to 1."; - } - - if ($this->container['to'] === null) { - $invalidProperties[] = "'to' can't be null"; - } - if ((mb_strlen($this->container['to']) > 24)) { - $invalidProperties[] = "invalid value for 'to', the character length must be smaller than or equal to 24."; - } - - if ((mb_strlen($this->container['to']) < 1)) { - $invalidProperties[] = "invalid value for 'to', the character length must be bigger than or equal to 1."; - } - - if (!is_null($this->container['messageId']) && (mb_strlen($this->container['messageId']) > 50)) { - $invalidProperties[] = "invalid value for 'messageId', the character length must be smaller than or equal to 50."; - } - - if (!is_null($this->container['messageId']) && (mb_strlen($this->container['messageId']) < 0)) { - $invalidProperties[] = "invalid value for 'messageId', the character length must be bigger than or equal to 0."; - } - - if ($this->container['content'] === null) { - $invalidProperties[] = "'content' can't be null"; - } - if (!is_null($this->container['callbackData']) && (mb_strlen($this->container['callbackData']) > 4000)) { - $invalidProperties[] = "invalid value for 'callbackData', the character length must be smaller than or equal to 4000."; - } - - if (!is_null($this->container['callbackData']) && (mb_strlen($this->container['callbackData']) < 0)) { - $invalidProperties[] = "invalid value for 'callbackData', the character length must be bigger than or equal to 0."; - } - - if (!is_null($this->container['notifyUrl']) && (mb_strlen($this->container['notifyUrl']) > 2048)) { - $invalidProperties[] = "invalid value for 'notifyUrl', the character length must be smaller than or equal to 2048."; - } - - if (!is_null($this->container['notifyUrl']) && (mb_strlen($this->container['notifyUrl']) < 0)) { - $invalidProperties[] = "invalid value for 'notifyUrl', the character length must be bigger than or equal to 0."; - } - - return $invalidProperties; + return $this->from; } - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() + public function setFrom(string $from): self { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets from - * - * @return string - */ - public function getFrom() - { - return $this->container['from']; - } - - /** - * Sets from - * - * @param string $from Registered WhatsApp sender number. Must be in international format and comply with [WhatsApp's requirements](https://www.infobip.com/docs/whatsapp/get-started#phone-number-what-you-need-to-know). - * - * @return self - */ - public function setFrom($from) - { - if ((mb_strlen($from) > 24)) { - throw new \InvalidArgumentException('invalid length for $from when calling WhatsAppVideoMessage., must be smaller than or equal to 24.'); - } - if ((mb_strlen($from) < 1)) { - throw new \InvalidArgumentException('invalid length for $from when calling WhatsAppVideoMessage., must be bigger than or equal to 1.'); - } - - $this->container['from'] = $from; - + $this->from = $from; return $this; } - /** - * Gets to - * - * @return string - */ - public function getTo() + public function getTo(): string { - return $this->container['to']; + return $this->to; } - /** - * Sets to - * - * @param string $to Message recipient number. Must be in international format. - * - * @return self - */ - public function setTo($to) + public function setTo(string $to): self { - if ((mb_strlen($to) > 24)) { - throw new \InvalidArgumentException('invalid length for $to when calling WhatsAppVideoMessage., must be smaller than or equal to 24.'); - } - if ((mb_strlen($to) < 1)) { - throw new \InvalidArgumentException('invalid length for $to when calling WhatsAppVideoMessage., must be bigger than or equal to 1.'); - } - - $this->container['to'] = $to; - + $this->to = $to; return $this; } - /** - * Gets messageId - * - * @return string|null - */ - public function getMessageId() + public function getMessageId(): string|null { - return $this->container['messageId']; + return $this->messageId; } - /** - * Sets messageId - * - * @param string|null $messageId The ID that uniquely identifies the message sent. - * - * @return self - */ - public function setMessageId($messageId) + public function setMessageId(?string $messageId): self { - if (!is_null($messageId) && (mb_strlen($messageId) > 50)) { - throw new \InvalidArgumentException('invalid length for $messageId when calling WhatsAppVideoMessage., must be smaller than or equal to 50.'); - } - if (!is_null($messageId) && (mb_strlen($messageId) < 0)) { - throw new \InvalidArgumentException('invalid length for $messageId when calling WhatsAppVideoMessage., must be bigger than or equal to 0.'); - } - - $this->container['messageId'] = $messageId; - + $this->messageId = $messageId; return $this; } - /** - * Gets content - * - * @return \Infobip\Model\WhatsAppVideoContent - */ - public function getContent() + public function getContent(): \Infobip\Model\WhatsAppVideoContent { - return $this->container['content']; + return $this->content; } - /** - * Sets content - * - * @param \Infobip\Model\WhatsAppVideoContent $content content - * - * @return self - */ - public function setContent($content) + public function setContent(\Infobip\Model\WhatsAppVideoContent $content): self { - $this->container['content'] = $content; - + $this->content = $content; return $this; } - /** - * Gets callbackData - * - * @return string|null - */ - public function getCallbackData() + public function getCallbackData(): string|null { - return $this->container['callbackData']; + return $this->callbackData; } - /** - * Sets callbackData - * - * @param string|null $callbackData Custom client data that will be included in a [Delivery Report](#channels/whatsapp/receive-whatsapp-delivery-reports). - * - * @return self - */ - public function setCallbackData($callbackData) + public function setCallbackData(?string $callbackData): self { - if (!is_null($callbackData) && (mb_strlen($callbackData) > 4000)) { - throw new \InvalidArgumentException('invalid length for $callbackData when calling WhatsAppVideoMessage., must be smaller than or equal to 4000.'); - } - if (!is_null($callbackData) && (mb_strlen($callbackData) < 0)) { - throw new \InvalidArgumentException('invalid length for $callbackData when calling WhatsAppVideoMessage., must be bigger than or equal to 0.'); - } - - $this->container['callbackData'] = $callbackData; - + $this->callbackData = $callbackData; return $this; } - /** - * Gets notifyUrl - * - * @return string|null - */ - public function getNotifyUrl() + public function getNotifyUrl(): string|null { - return $this->container['notifyUrl']; + return $this->notifyUrl; } - /** - * Sets notifyUrl - * - * @param string|null $notifyUrl The URL on your callback server to which delivery and seen reports will be sent. [Delivery report format](#channels/whatsapp/receive-whatsapp-delivery-reports), [Seen report format](#channels/whatsapp/receive-whatsapp-seen-reports). - * - * @return self - */ - public function setNotifyUrl($notifyUrl) + public function setNotifyUrl(?string $notifyUrl): self { - if (!is_null($notifyUrl) && (mb_strlen($notifyUrl) > 2048)) { - throw new \InvalidArgumentException('invalid length for $notifyUrl when calling WhatsAppVideoMessage., must be smaller than or equal to 2048.'); - } - if (!is_null($notifyUrl) && (mb_strlen($notifyUrl) < 0)) { - throw new \InvalidArgumentException('invalid length for $notifyUrl when calling WhatsAppVideoMessage., must be bigger than or equal to 0.'); - } - - $this->container['notifyUrl'] = $notifyUrl; - + $this->notifyUrl = $notifyUrl; return $this; } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - public function offsetGet($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($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize(): mixed - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } } diff --git a/Infobip/Model/WhatsAppWebhookAddress.php b/Infobip/Model/WhatsAppWebhookAddress.php new file mode 100644 index 0000000..00e9101 --- /dev/null +++ b/Infobip/Model/WhatsAppWebhookAddress.php @@ -0,0 +1,145 @@ + null, + 'city' => null, + 'state' => null, + 'zip' => null, + 'country' => null, + 'countryCode' => null, + 'type' => null + ]; + + /** + */ + public function __construct( + protected ?string $street = null, + protected ?string $city = null, + protected ?string $state = null, + protected ?string $zip = null, + protected ?string $country = null, + protected ?string $countryCode = null, + #[Assert\Choice(['HOME','WORK',])] + + protected ?string $type = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getStreet(): string|null + { + return $this->street; + } + + public function setStreet(?string $street): self + { + $this->street = $street; + return $this; + } + + public function getCity(): string|null + { + return $this->city; + } + + public function setCity(?string $city): self + { + $this->city = $city; + return $this; + } + + public function getState(): string|null + { + return $this->state; + } + + public function setState(?string $state): self + { + $this->state = $state; + return $this; + } + + public function getZip(): string|null + { + return $this->zip; + } + + public function setZip(?string $zip): self + { + $this->zip = $zip; + return $this; + } + + public function getCountry(): string|null + { + return $this->country; + } + + public function setCountry(?string $country): self + { + $this->country = $country; + return $this; + } + + public function getCountryCode(): string|null + { + return $this->countryCode; + } + + public function setCountryCode(?string $countryCode): self + { + $this->countryCode = $countryCode; + return $this; + } + + public function getType(): mixed + { + return $this->type; + } + + public function setType($type): self + { + $this->type = $type; + return $this; + } +} diff --git a/Infobip/Model/WhatsAppWebhookButtonReplyContent.php b/Infobip/Model/WhatsAppWebhookButtonReplyContent.php new file mode 100644 index 0000000..23f513c --- /dev/null +++ b/Infobip/Model/WhatsAppWebhookButtonReplyContent.php @@ -0,0 +1,104 @@ + null, + 'title' => null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 256)] + #[Assert\Length(min: 0)] + + protected string $id, + #[Assert\NotBlank] + #[Assert\Length(max: 20)] + #[Assert\Length(min: 0)] + + protected string $title, + #[Assert\Valid] + + protected ?\Infobip\Model\WhatsAppWebhookContext $context = null, + #[Assert\Valid] + + protected ?\Infobip\Model\WhatsAppWebhookIdentity $identity = null, + #[Assert\Valid] + + protected ?\Infobip\Model\WhatsAppWebhookReferral $referral = null, + ) { + $modelDiscriminatorValue = 'INTERACTIVE_BUTTON_REPLY'; + + parent::__construct( + type: $modelDiscriminatorValue, + context: $context, + identity: $identity, + referral: $referral, + ); + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getId(): string + { + return $this->id; + } + + public function setId(string $id): self + { + $this->id = $id; + return $this; + } + + public function getTitle(): string + { + return $this->title; + } + + public function setTitle(string $title): self + { + $this->title = $title; + return $this; + } +} diff --git a/Infobip/Model/WhatsAppWebhookContact.php b/Infobip/Model/WhatsAppWebhookContact.php new file mode 100644 index 0000000..fa7402d --- /dev/null +++ b/Infobip/Model/WhatsAppWebhookContact.php @@ -0,0 +1,177 @@ + null, + 'birthday' => 'date-time', + 'emails' => null, + 'name' => null, + 'org' => null, + 'phones' => null, + 'urls' => null + ]; + + /** + * @param \Infobip\Model\WhatsAppWebhookAddress[] $addresses + * @param \Infobip\Model\WhatsAppWebhookEmail[] $emails + * @param \Infobip\Model\WhatsAppWebhookPhone[] $phones + * @param \Infobip\Model\WhatsAppWebhookUrl[] $urls + */ + public function __construct( + protected ?array $addresses = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $birthday = null, + protected ?array $emails = null, + #[Assert\Valid] + + protected ?\Infobip\Model\WhatsAppWebhookName $name = null, + #[Assert\Valid] + + protected ?\Infobip\Model\WhatsAppWebhookOrganization $org = null, + protected ?array $phones = null, + protected ?array $urls = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + /** + * @return \Infobip\Model\WhatsAppWebhookAddress[]|null + */ + public function getAddresses(): ?array + { + return $this->addresses; + } + + /** + * @param \Infobip\Model\WhatsAppWebhookAddress[]|null $addresses Address information. + */ + public function setAddresses(?array $addresses): self + { + $this->addresses = $addresses; + return $this; + } + + public function getBirthday(): \DateTime|null + { + return $this->birthday; + } + + public function setBirthday(?\DateTime $birthday): self + { + $this->birthday = $birthday; + return $this; + } + + /** + * @return \Infobip\Model\WhatsAppWebhookEmail[]|null + */ + public function getEmails(): ?array + { + return $this->emails; + } + + /** + * @param \Infobip\Model\WhatsAppWebhookEmail[]|null $emails Email information. + */ + public function setEmails(?array $emails): self + { + $this->emails = $emails; + return $this; + } + + public function getName(): \Infobip\Model\WhatsAppWebhookName|null + { + return $this->name; + } + + public function setName(?\Infobip\Model\WhatsAppWebhookName $name): self + { + $this->name = $name; + return $this; + } + + public function getOrg(): \Infobip\Model\WhatsAppWebhookOrganization|null + { + return $this->org; + } + + public function setOrg(?\Infobip\Model\WhatsAppWebhookOrganization $org): self + { + $this->org = $org; + return $this; + } + + /** + * @return \Infobip\Model\WhatsAppWebhookPhone[]|null + */ + public function getPhones(): ?array + { + return $this->phones; + } + + /** + * @param \Infobip\Model\WhatsAppWebhookPhone[]|null $phones Phone information. + */ + public function setPhones(?array $phones): self + { + $this->phones = $phones; + return $this; + } + + /** + * @return \Infobip\Model\WhatsAppWebhookUrl[]|null + */ + public function getUrls(): ?array + { + return $this->urls; + } + + /** + * @param \Infobip\Model\WhatsAppWebhookUrl[]|null $urls URL information. + */ + public function setUrls(?array $urls): self + { + $this->urls = $urls; + return $this; + } +} diff --git a/Infobip/Model/WhatsAppWebhookContactName.php b/Infobip/Model/WhatsAppWebhookContactName.php new file mode 100644 index 0000000..f1833c2 --- /dev/null +++ b/Infobip/Model/WhatsAppWebhookContactName.php @@ -0,0 +1,65 @@ + null + ]; + + /** + */ + public function __construct( + protected ?string $name = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getName(): string|null + { + return $this->name; + } + + public function setName(?string $name): self + { + $this->name = $name; + return $this; + } +} diff --git a/Infobip/Model/WhatsAppWebhookContext.php b/Infobip/Model/WhatsAppWebhookContext.php new file mode 100644 index 0000000..8bcff0c --- /dev/null +++ b/Infobip/Model/WhatsAppWebhookContext.php @@ -0,0 +1,93 @@ + null, + 'from' => null, + 'referredProduct' => null + ]; + + /** + */ + public function __construct( + protected ?string $id = null, + protected ?string $from = null, + #[Assert\Valid] + + protected ?\Infobip\Model\WhatsAppWebhookReferredProduct $referredProduct = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getId(): string|null + { + return $this->id; + } + + public function setId(?string $id): self + { + $this->id = $id; + return $this; + } + + public function getFrom(): string|null + { + return $this->from; + } + + public function setFrom(?string $from): self + { + $this->from = $from; + return $this; + } + + public function getReferredProduct(): \Infobip\Model\WhatsAppWebhookReferredProduct|null + { + return $this->referredProduct; + } + + public function setReferredProduct(?\Infobip\Model\WhatsAppWebhookReferredProduct $referredProduct): self + { + $this->referredProduct = $referredProduct; + return $this; + } +} diff --git a/Infobip/Model/WhatsAppWebhookDeletedReport.php b/Infobip/Model/WhatsAppWebhookDeletedReport.php new file mode 100644 index 0000000..1e1cc81 --- /dev/null +++ b/Infobip/Model/WhatsAppWebhookDeletedReport.php @@ -0,0 +1,121 @@ + null, + 'from' => null, + 'to' => null, + 'sentAt' => 'date-time', + 'deletedAt' => 'date-time' + ]; + + /** + */ + public function __construct( + protected ?string $messageId = null, + protected ?string $from = null, + protected ?string $to = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $sentAt = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $deletedAt = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getMessageId(): string|null + { + return $this->messageId; + } + + public function setMessageId(?string $messageId): self + { + $this->messageId = $messageId; + return $this; + } + + public function getFrom(): string|null + { + return $this->from; + } + + public function setFrom(?string $from): self + { + $this->from = $from; + return $this; + } + + public function getTo(): string|null + { + return $this->to; + } + + public function setTo(?string $to): self + { + $this->to = $to; + return $this; + } + + public function getSentAt(): \DateTime|null + { + return $this->sentAt; + } + + public function setSentAt(?\DateTime $sentAt): self + { + $this->sentAt = $sentAt; + return $this; + } + + public function getDeletedAt(): \DateTime|null + { + return $this->deletedAt; + } + + public function setDeletedAt(?\DateTime $deletedAt): self + { + $this->deletedAt = $deletedAt; + return $this; + } +} diff --git a/Infobip/Model/WhatsAppWebhookDeletedReportResult.php b/Infobip/Model/WhatsAppWebhookDeletedReportResult.php new file mode 100644 index 0000000..06f8c8e --- /dev/null +++ b/Infobip/Model/WhatsAppWebhookDeletedReportResult.php @@ -0,0 +1,72 @@ + null + ]; + + /** + * @param \Infobip\Model\WhatsAppWebhookDeletedReport[] $results + */ + public function __construct( + protected ?array $results = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + /** + * @return \Infobip\Model\WhatsAppWebhookDeletedReport[]|null + */ + public function getResults(): ?array + { + return $this->results; + } + + /** + * @param \Infobip\Model\WhatsAppWebhookDeletedReport[]|null $results Collection of reports, one per every received message. + */ + public function setResults(?array $results): self + { + $this->results = $results; + return $this; + } +} diff --git a/Infobip/Model/WhatsAppWebhookDeliveryReport.php b/Infobip/Model/WhatsAppWebhookDeliveryReport.php new file mode 100644 index 0000000..4ea3df8 --- /dev/null +++ b/Infobip/Model/WhatsAppWebhookDeliveryReport.php @@ -0,0 +1,179 @@ + null, + 'price' => null, + 'status' => null, + 'error' => null, + 'messageId' => null, + 'doneAt' => 'date-time', + 'messageCount' => 'int32', + 'sentAt' => 'date-time', + 'to' => null + ]; + + /** + */ + public function __construct( + protected ?string $bulkId = null, + #[Assert\Valid] + + protected ?\Infobip\Model\MessagePrice $price = null, + #[Assert\Valid] + + protected ?\Infobip\Model\MessageStatus $status = null, + #[Assert\Valid] + + protected ?\Infobip\Model\MessageError $error = null, + protected ?string $messageId = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $doneAt = null, + protected ?int $messageCount = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $sentAt = null, + protected ?string $to = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getBulkId(): string|null + { + return $this->bulkId; + } + + public function setBulkId(?string $bulkId): self + { + $this->bulkId = $bulkId; + return $this; + } + + public function getPrice(): \Infobip\Model\MessagePrice|null + { + return $this->price; + } + + public function setPrice(?\Infobip\Model\MessagePrice $price): self + { + $this->price = $price; + return $this; + } + + public function getStatus(): \Infobip\Model\MessageStatus|null + { + return $this->status; + } + + public function setStatus(?\Infobip\Model\MessageStatus $status): self + { + $this->status = $status; + return $this; + } + + public function getError(): \Infobip\Model\MessageError|null + { + return $this->error; + } + + public function setError(?\Infobip\Model\MessageError $error): self + { + $this->error = $error; + return $this; + } + + public function getMessageId(): string|null + { + return $this->messageId; + } + + public function setMessageId(?string $messageId): self + { + $this->messageId = $messageId; + return $this; + } + + public function getDoneAt(): \DateTime|null + { + return $this->doneAt; + } + + public function setDoneAt(?\DateTime $doneAt): self + { + $this->doneAt = $doneAt; + return $this; + } + + public function getMessageCount(): int|null + { + return $this->messageCount; + } + + public function setMessageCount(?int $messageCount): self + { + $this->messageCount = $messageCount; + return $this; + } + + public function getSentAt(): \DateTime|null + { + return $this->sentAt; + } + + public function setSentAt(?\DateTime $sentAt): self + { + $this->sentAt = $sentAt; + return $this; + } + + public function getTo(): string|null + { + return $this->to; + } + + public function setTo(?string $to): self + { + $this->to = $to; + return $this; + } +} diff --git a/Infobip/Model/WhatsAppWebhookDeliveryResult.php b/Infobip/Model/WhatsAppWebhookDeliveryResult.php new file mode 100644 index 0000000..3bab15c --- /dev/null +++ b/Infobip/Model/WhatsAppWebhookDeliveryResult.php @@ -0,0 +1,72 @@ + null + ]; + + /** + * @param \Infobip\Model\WhatsAppWebhookDeliveryReport[] $results + */ + public function __construct( + protected ?array $results = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + /** + * @return \Infobip\Model\WhatsAppWebhookDeliveryReport[]|null + */ + public function getResults(): ?array + { + return $this->results; + } + + /** + * @param \Infobip\Model\WhatsAppWebhookDeliveryReport[]|null $results Collection of reports, one per every message. + */ + public function setResults(?array $results): self + { + $this->results = $results; + return $this; + } +} diff --git a/Infobip/Model/WhatsAppWebhookEmail.php b/Infobip/Model/WhatsAppWebhookEmail.php new file mode 100644 index 0000000..c2a9d43 --- /dev/null +++ b/Infobip/Model/WhatsAppWebhookEmail.php @@ -0,0 +1,80 @@ + null, + 'type' => null + ]; + + /** + */ + public function __construct( + protected ?string $email = null, + #[Assert\Choice(['HOME','WORK',])] + + protected ?string $type = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getEmail(): string|null + { + return $this->email; + } + + public function setEmail(?string $email): self + { + $this->email = $email; + return $this; + } + + public function getType(): mixed + { + return $this->type; + } + + public function setType($type): self + { + $this->type = $type; + return $this; + } +} diff --git a/Infobip/Model/WhatsAppWebhookIdentity.php b/Infobip/Model/WhatsAppWebhookIdentity.php new file mode 100644 index 0000000..7d11766 --- /dev/null +++ b/Infobip/Model/WhatsAppWebhookIdentity.php @@ -0,0 +1,93 @@ + null, + 'hash' => null, + 'createdAt' => 'date-time' + ]; + + /** + */ + public function __construct( + protected ?bool $acknowledged = null, + protected ?string $hash = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $createdAt = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getAcknowledged(): bool|null + { + return $this->acknowledged; + } + + public function setAcknowledged(?bool $acknowledged): self + { + $this->acknowledged = $acknowledged; + return $this; + } + + public function getHash(): string|null + { + return $this->hash; + } + + public function setHash(?string $hash): self + { + $this->hash = $hash; + return $this; + } + + public function getCreatedAt(): \DateTime|null + { + return $this->createdAt; + } + + public function setCreatedAt(?\DateTime $createdAt): self + { + $this->createdAt = $createdAt; + return $this; + } +} diff --git a/Infobip/Model/WhatsAppWebhookInboundAudioMessage.php b/Infobip/Model/WhatsAppWebhookInboundAudioMessage.php new file mode 100644 index 0000000..92aeaf0 --- /dev/null +++ b/Infobip/Model/WhatsAppWebhookInboundAudioMessage.php @@ -0,0 +1,96 @@ + null, + 'url' => null + ]; + + /** + */ + public function __construct( + #[Assert\Valid] + + protected ?\Infobip\Model\WhatsAppWebhookContext $context = null, + #[Assert\Valid] + + protected ?\Infobip\Model\WhatsAppWebhookIdentity $identity = null, + #[Assert\Valid] + + protected ?\Infobip\Model\WhatsAppWebhookReferral $referral = null, + protected ?string $caption = null, + protected ?string $url = null, + ) { + $modelDiscriminatorValue = 'AUDIO'; + + parent::__construct( + type: $modelDiscriminatorValue, + context: $context, + identity: $identity, + referral: $referral, + ); + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getCaption(): string|null + { + return $this->caption; + } + + public function setCaption(?string $caption): self + { + $this->caption = $caption; + return $this; + } + + public function getUrl(): string|null + { + return $this->url; + } + + public function setUrl(?string $url): self + { + $this->url = $url; + return $this; + } +} diff --git a/Infobip/Model/WhatsAppWebhookInboundContactMessage.php b/Infobip/Model/WhatsAppWebhookInboundContactMessage.php new file mode 100644 index 0000000..a186980 --- /dev/null +++ b/Infobip/Model/WhatsAppWebhookInboundContactMessage.php @@ -0,0 +1,90 @@ + null + ]; + + /** + * @param \Infobip\Model\WhatsAppWebhookContact[] $contacts + */ + public function __construct( + #[Assert\Valid] + + protected ?\Infobip\Model\WhatsAppWebhookContext $context = null, + #[Assert\Valid] + + protected ?\Infobip\Model\WhatsAppWebhookIdentity $identity = null, + #[Assert\Valid] + + protected ?\Infobip\Model\WhatsAppWebhookReferral $referral = null, + protected ?array $contacts = null, + ) { + $modelDiscriminatorValue = 'CONTACT'; + + parent::__construct( + type: $modelDiscriminatorValue, + context: $context, + identity: $identity, + referral: $referral, + ); + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + /** + * @return \Infobip\Model\WhatsAppWebhookContact[]|null + */ + public function getContacts(): ?array + { + return $this->contacts; + } + + /** + * @param \Infobip\Model\WhatsAppWebhookContact[]|null $contacts contacts + */ + public function setContacts(?array $contacts): self + { + $this->contacts = $contacts; + return $this; + } +} diff --git a/Infobip/Model/WhatsAppWebhookInboundDocumentMessage.php b/Infobip/Model/WhatsAppWebhookInboundDocumentMessage.php new file mode 100644 index 0000000..75edc4c --- /dev/null +++ b/Infobip/Model/WhatsAppWebhookInboundDocumentMessage.php @@ -0,0 +1,96 @@ + null, + 'url' => null + ]; + + /** + */ + public function __construct( + #[Assert\Valid] + + protected ?\Infobip\Model\WhatsAppWebhookContext $context = null, + #[Assert\Valid] + + protected ?\Infobip\Model\WhatsAppWebhookIdentity $identity = null, + #[Assert\Valid] + + protected ?\Infobip\Model\WhatsAppWebhookReferral $referral = null, + protected ?string $caption = null, + protected ?string $url = null, + ) { + $modelDiscriminatorValue = 'DOCUMENT'; + + parent::__construct( + type: $modelDiscriminatorValue, + context: $context, + identity: $identity, + referral: $referral, + ); + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getCaption(): string|null + { + return $this->caption; + } + + public function setCaption(?string $caption): self + { + $this->caption = $caption; + return $this; + } + + public function getUrl(): string|null + { + return $this->url; + } + + public function setUrl(?string $url): self + { + $this->url = $url; + return $this; + } +} diff --git a/Infobip/Model/WhatsAppWebhookInboundImageMessage.php b/Infobip/Model/WhatsAppWebhookInboundImageMessage.php new file mode 100644 index 0000000..dac9972 --- /dev/null +++ b/Infobip/Model/WhatsAppWebhookInboundImageMessage.php @@ -0,0 +1,96 @@ + null, + 'url' => null + ]; + + /** + */ + public function __construct( + #[Assert\Valid] + + protected ?\Infobip\Model\WhatsAppWebhookContext $context = null, + #[Assert\Valid] + + protected ?\Infobip\Model\WhatsAppWebhookIdentity $identity = null, + #[Assert\Valid] + + protected ?\Infobip\Model\WhatsAppWebhookReferral $referral = null, + protected ?string $caption = null, + protected ?string $url = null, + ) { + $modelDiscriminatorValue = 'IMAGE'; + + parent::__construct( + type: $modelDiscriminatorValue, + context: $context, + identity: $identity, + referral: $referral, + ); + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getCaption(): string|null + { + return $this->caption; + } + + public function setCaption(?string $caption): self + { + $this->caption = $caption; + return $this; + } + + public function getUrl(): string|null + { + return $this->url; + } + + public function setUrl(?string $url): self + { + $this->url = $url; + return $this; + } +} diff --git a/Infobip/Model/WhatsAppWebhookInboundLocationMessage.php b/Infobip/Model/WhatsAppWebhookInboundLocationMessage.php new file mode 100644 index 0000000..0c8d22e --- /dev/null +++ b/Infobip/Model/WhatsAppWebhookInboundLocationMessage.php @@ -0,0 +1,139 @@ + 'double', + 'latitude' => 'double', + 'name' => null, + 'address' => null, + 'url' => null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + + protected float $longitude, + #[Assert\NotBlank] + + protected float $latitude, + #[Assert\Valid] + + protected ?\Infobip\Model\WhatsAppWebhookContext $context = null, + #[Assert\Valid] + + protected ?\Infobip\Model\WhatsAppWebhookIdentity $identity = null, + #[Assert\Valid] + + protected ?\Infobip\Model\WhatsAppWebhookReferral $referral = null, + protected ?string $name = null, + protected ?string $address = null, + protected ?string $url = null, + ) { + $modelDiscriminatorValue = 'LOCATION'; + + parent::__construct( + type: $modelDiscriminatorValue, + context: $context, + identity: $identity, + referral: $referral, + ); + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getLongitude(): float + { + return $this->longitude; + } + + public function setLongitude(float $longitude): self + { + $this->longitude = $longitude; + return $this; + } + + public function getLatitude(): float + { + return $this->latitude; + } + + public function setLatitude(float $latitude): self + { + $this->latitude = $latitude; + return $this; + } + + public function getName(): string|null + { + return $this->name; + } + + public function setName(?string $name): self + { + $this->name = $name; + return $this; + } + + public function getAddress(): string|null + { + return $this->address; + } + + public function setAddress(?string $address): self + { + $this->address = $address; + return $this; + } + + public function getUrl(): string|null + { + return $this->url; + } + + public function setUrl(?string $url): self + { + $this->url = $url; + return $this; + } +} diff --git a/Infobip/Model/WhatsAppWebhookInboundMessage.php b/Infobip/Model/WhatsAppWebhookInboundMessage.php new file mode 100644 index 0000000..694f8e2 --- /dev/null +++ b/Infobip/Model/WhatsAppWebhookInboundMessage.php @@ -0,0 +1,140 @@ + "\Infobip\Model\WhatsAppWebhookInboundAudioMessage", + "BUTTON" => "\Infobip\Model\WhatsAppWebhookQuickReplyContent", + "CONTACT" => "\Infobip\Model\WhatsAppWebhookInboundContactMessage", + "DOCUMENT" => "\Infobip\Model\WhatsAppWebhookInboundDocumentMessage", + "IMAGE" => "\Infobip\Model\WhatsAppWebhookInboundImageMessage", + "INTERACTIVE_BUTTON_REPLY" => "\Infobip\Model\WhatsAppWebhookButtonReplyContent", + "INTERACTIVE_LIST_REPLY" => "\Infobip\Model\WhatsAppWebhookListReplyContent", + "LOCATION" => "\Infobip\Model\WhatsAppWebhookInboundLocationMessage", + "ORDER" => "\Infobip\Model\WhatsAppWebhookOrderContent", + "STICKER" => "\Infobip\Model\WhatsAppWebhookInboundStickerMessage", + "TEXT" => "\Infobip\Model\WhatsAppWebhookInboundTextMessage", + "VIDEO" => "\Infobip\Model\WhatsAppWebhookInboundVideoMessage", + "VOICE" => "\Infobip\Model\WhatsAppWebhookInboundVoiceMessage", + "WhatsAppWebhookButtonReplyContent" => "\Infobip\Model\WhatsAppWebhookButtonReplyContent", + "WhatsAppWebhookInboundAudioMessage" => "\Infobip\Model\WhatsAppWebhookInboundAudioMessage", + "WhatsAppWebhookInboundContactMessage" => "\Infobip\Model\WhatsAppWebhookInboundContactMessage", + "WhatsAppWebhookInboundDocumentMessage" => "\Infobip\Model\WhatsAppWebhookInboundDocumentMessage", + "WhatsAppWebhookInboundImageMessage" => "\Infobip\Model\WhatsAppWebhookInboundImageMessage", + "WhatsAppWebhookInboundLocationMessage" => "\Infobip\Model\WhatsAppWebhookInboundLocationMessage", + "WhatsAppWebhookInboundStickerMessage" => "\Infobip\Model\WhatsAppWebhookInboundStickerMessage", + "WhatsAppWebhookInboundTextMessage" => "\Infobip\Model\WhatsAppWebhookInboundTextMessage", + "WhatsAppWebhookInboundVideoMessage" => "\Infobip\Model\WhatsAppWebhookInboundVideoMessage", + "WhatsAppWebhookInboundVoiceMessage" => "\Infobip\Model\WhatsAppWebhookInboundVoiceMessage", + "WhatsAppWebhookListReplyContent" => "\Infobip\Model\WhatsAppWebhookListReplyContent", + "WhatsAppWebhookOrderContent" => "\Infobip\Model\WhatsAppWebhookOrderContent", + "WhatsAppWebhookQuickReplyContent" => "\Infobip\Model\WhatsAppWebhookQuickReplyContent", +])] +class WhatsAppWebhookInboundMessage implements ModelInterface +{ + public const DISCRIMINATOR = 'type'; + public const OPENAPI_MODEL_NAME = 'WhatsAppWebhookInboundMessage'; + + public const OPENAPI_FORMATS = [ + 'type' => null, + 'context' => null, + 'identity' => null, + 'referral' => null + ]; + + /** + */ + public function __construct( + #[Assert\Choice(['TEXT','IMAGE','DOCUMENT','STICKER','LOCATION','CONTACT','VIDEO','VOICE','AUDIO','BUTTON','INTERACTIVE_BUTTON_REPLY','INTERACTIVE_LIST_REPLY','ORDER','UNSUPPORTED',])] + + protected ?string $type = null, + #[Assert\Valid] + + protected ?\Infobip\Model\WhatsAppWebhookContext $context = null, + #[Assert\Valid] + + protected ?\Infobip\Model\WhatsAppWebhookIdentity $identity = null, + #[Assert\Valid] + + protected ?\Infobip\Model\WhatsAppWebhookReferral $referral = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getType(): mixed + { + return $this->type; + } + + public function setType($type): self + { + $this->type = $type; + return $this; + } + + public function getContext(): \Infobip\Model\WhatsAppWebhookContext|null + { + return $this->context; + } + + public function setContext(?\Infobip\Model\WhatsAppWebhookContext $context): self + { + $this->context = $context; + return $this; + } + + public function getIdentity(): \Infobip\Model\WhatsAppWebhookIdentity|null + { + return $this->identity; + } + + public function setIdentity(?\Infobip\Model\WhatsAppWebhookIdentity $identity): self + { + $this->identity = $identity; + return $this; + } + + public function getReferral(): \Infobip\Model\WhatsAppWebhookReferral|null + { + return $this->referral; + } + + public function setReferral(?\Infobip\Model\WhatsAppWebhookReferral $referral): self + { + $this->referral = $referral; + return $this; + } +} diff --git a/Infobip/Model/WhatsAppWebhookInboundMessageBase.php b/Infobip/Model/WhatsAppWebhookInboundMessageBase.php new file mode 100644 index 0000000..8752c42 --- /dev/null +++ b/Infobip/Model/WhatsAppWebhookInboundMessageBase.php @@ -0,0 +1,121 @@ + null, + 'to' => null, + 'receivedAt' => 'date-time', + 'messageId' => null, + 'price' => null + ]; + + /** + */ + public function __construct( + protected ?string $from = null, + protected ?string $to = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $receivedAt = null, + protected ?string $messageId = null, + #[Assert\Valid] + + protected ?\Infobip\Model\MessagePrice $price = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getFrom(): string|null + { + return $this->from; + } + + public function setFrom(?string $from): self + { + $this->from = $from; + return $this; + } + + public function getTo(): string|null + { + return $this->to; + } + + public function setTo(?string $to): self + { + $this->to = $to; + return $this; + } + + public function getReceivedAt(): \DateTime|null + { + return $this->receivedAt; + } + + public function setReceivedAt(?\DateTime $receivedAt): self + { + $this->receivedAt = $receivedAt; + return $this; + } + + public function getMessageId(): string|null + { + return $this->messageId; + } + + public function setMessageId(?string $messageId): self + { + $this->messageId = $messageId; + return $this; + } + + public function getPrice(): \Infobip\Model\MessagePrice|null + { + return $this->price; + } + + public function setPrice(?\Infobip\Model\MessagePrice $price): self + { + $this->price = $price; + return $this; + } +} diff --git a/Infobip/Model/WhatsAppWebhookInboundMessageData.php b/Infobip/Model/WhatsAppWebhookInboundMessageData.php new file mode 100644 index 0000000..251bddc --- /dev/null +++ b/Infobip/Model/WhatsAppWebhookInboundMessageData.php @@ -0,0 +1,151 @@ + null, + 'to' => null, + 'receivedAt' => 'date-time', + 'messageId' => null, + 'price' => null, + 'message' => null, + 'contact' => null + ]; + + /** + */ + public function __construct( + protected ?string $from = null, + protected ?string $to = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $receivedAt = null, + protected ?string $messageId = null, + #[Assert\Valid] + + protected ?\Infobip\Model\MessagePrice $price = null, + #[Assert\Valid] + + protected ?\Infobip\Model\WhatsAppWebhookInboundMessage $message = null, + #[Assert\Valid] + + protected ?\Infobip\Model\WhatsAppWebhookContactName $contact = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getFrom(): string|null + { + return $this->from; + } + + public function setFrom(?string $from): self + { + $this->from = $from; + return $this; + } + + public function getTo(): string|null + { + return $this->to; + } + + public function setTo(?string $to): self + { + $this->to = $to; + return $this; + } + + public function getReceivedAt(): \DateTime|null + { + return $this->receivedAt; + } + + public function setReceivedAt(?\DateTime $receivedAt): self + { + $this->receivedAt = $receivedAt; + return $this; + } + + public function getMessageId(): string|null + { + return $this->messageId; + } + + public function setMessageId(?string $messageId): self + { + $this->messageId = $messageId; + return $this; + } + + public function getPrice(): \Infobip\Model\MessagePrice|null + { + return $this->price; + } + + public function setPrice(?\Infobip\Model\MessagePrice $price): self + { + $this->price = $price; + return $this; + } + + public function getMessage(): \Infobip\Model\WhatsAppWebhookInboundMessage|null + { + return $this->message; + } + + public function setMessage(?\Infobip\Model\WhatsAppWebhookInboundMessage $message): self + { + $this->message = $message; + return $this; + } + + public function getContact(): \Infobip\Model\WhatsAppWebhookContactName|null + { + return $this->contact; + } + + public function setContact(?\Infobip\Model\WhatsAppWebhookContactName $contact): self + { + $this->contact = $contact; + return $this; + } +} diff --git a/Infobip/Model/WhatsAppWebhookInboundMessageResult.php b/Infobip/Model/WhatsAppWebhookInboundMessageResult.php new file mode 100644 index 0000000..24032f5 --- /dev/null +++ b/Infobip/Model/WhatsAppWebhookInboundMessageResult.php @@ -0,0 +1,98 @@ + 'int32', + 'pendingMessageCount' => 'int32', + 'results' => null + ]; + + /** + * @param \Infobip\Model\WhatsAppWebhookInboundMessageData[] $results + */ + public function __construct( + protected ?int $messageCount = null, + protected ?int $pendingMessageCount = null, + protected ?array $results = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getMessageCount(): int|null + { + return $this->messageCount; + } + + public function setMessageCount(?int $messageCount): self + { + $this->messageCount = $messageCount; + return $this; + } + + public function getPendingMessageCount(): int|null + { + return $this->pendingMessageCount; + } + + public function setPendingMessageCount(?int $pendingMessageCount): self + { + $this->pendingMessageCount = $pendingMessageCount; + return $this; + } + + /** + * @return \Infobip\Model\WhatsAppWebhookInboundMessageData[]|null + */ + public function getResults(): ?array + { + return $this->results; + } + + /** + * @param \Infobip\Model\WhatsAppWebhookInboundMessageData[]|null $results Collection of reports, one per every received message. + */ + public function setResults(?array $results): self + { + $this->results = $results; + return $this; + } +} diff --git a/Infobip/Model/WhatsAppWebhookInboundStickerMessage.php b/Infobip/Model/WhatsAppWebhookInboundStickerMessage.php new file mode 100644 index 0000000..88504c6 --- /dev/null +++ b/Infobip/Model/WhatsAppWebhookInboundStickerMessage.php @@ -0,0 +1,83 @@ + null + ]; + + /** + */ + public function __construct( + #[Assert\Valid] + + protected ?\Infobip\Model\WhatsAppWebhookContext $context = null, + #[Assert\Valid] + + protected ?\Infobip\Model\WhatsAppWebhookIdentity $identity = null, + #[Assert\Valid] + + protected ?\Infobip\Model\WhatsAppWebhookReferral $referral = null, + protected ?string $url = null, + ) { + $modelDiscriminatorValue = 'STICKER'; + + parent::__construct( + type: $modelDiscriminatorValue, + context: $context, + identity: $identity, + referral: $referral, + ); + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getUrl(): string|null + { + return $this->url; + } + + public function setUrl(?string $url): self + { + $this->url = $url; + return $this; + } +} diff --git a/Infobip/Model/WhatsAppWebhookInboundTextMessage.php b/Infobip/Model/WhatsAppWebhookInboundTextMessage.php new file mode 100644 index 0000000..581392a --- /dev/null +++ b/Infobip/Model/WhatsAppWebhookInboundTextMessage.php @@ -0,0 +1,83 @@ + null + ]; + + /** + */ + public function __construct( + #[Assert\Valid] + + protected ?\Infobip\Model\WhatsAppWebhookContext $context = null, + #[Assert\Valid] + + protected ?\Infobip\Model\WhatsAppWebhookIdentity $identity = null, + #[Assert\Valid] + + protected ?\Infobip\Model\WhatsAppWebhookReferral $referral = null, + protected ?string $text = null, + ) { + $modelDiscriminatorValue = 'TEXT'; + + parent::__construct( + type: $modelDiscriminatorValue, + context: $context, + identity: $identity, + referral: $referral, + ); + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getText(): string|null + { + return $this->text; + } + + public function setText(?string $text): self + { + $this->text = $text; + return $this; + } +} diff --git a/Infobip/Model/WhatsAppWebhookInboundVideoMessage.php b/Infobip/Model/WhatsAppWebhookInboundVideoMessage.php new file mode 100644 index 0000000..89cb7a8 --- /dev/null +++ b/Infobip/Model/WhatsAppWebhookInboundVideoMessage.php @@ -0,0 +1,96 @@ + null, + 'url' => null + ]; + + /** + */ + public function __construct( + #[Assert\Valid] + + protected ?\Infobip\Model\WhatsAppWebhookContext $context = null, + #[Assert\Valid] + + protected ?\Infobip\Model\WhatsAppWebhookIdentity $identity = null, + #[Assert\Valid] + + protected ?\Infobip\Model\WhatsAppWebhookReferral $referral = null, + protected ?string $caption = null, + protected ?string $url = null, + ) { + $modelDiscriminatorValue = 'VIDEO'; + + parent::__construct( + type: $modelDiscriminatorValue, + context: $context, + identity: $identity, + referral: $referral, + ); + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getCaption(): string|null + { + return $this->caption; + } + + public function setCaption(?string $caption): self + { + $this->caption = $caption; + return $this; + } + + public function getUrl(): string|null + { + return $this->url; + } + + public function setUrl(?string $url): self + { + $this->url = $url; + return $this; + } +} diff --git a/Infobip/Model/WhatsAppWebhookInboundVoiceMessage.php b/Infobip/Model/WhatsAppWebhookInboundVoiceMessage.php new file mode 100644 index 0000000..576e0ae --- /dev/null +++ b/Infobip/Model/WhatsAppWebhookInboundVoiceMessage.php @@ -0,0 +1,96 @@ + null, + 'url' => null + ]; + + /** + */ + public function __construct( + #[Assert\Valid] + + protected ?\Infobip\Model\WhatsAppWebhookContext $context = null, + #[Assert\Valid] + + protected ?\Infobip\Model\WhatsAppWebhookIdentity $identity = null, + #[Assert\Valid] + + protected ?\Infobip\Model\WhatsAppWebhookReferral $referral = null, + protected ?string $caption = null, + protected ?string $url = null, + ) { + $modelDiscriminatorValue = 'VOICE'; + + parent::__construct( + type: $modelDiscriminatorValue, + context: $context, + identity: $identity, + referral: $referral, + ); + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getCaption(): string|null + { + return $this->caption; + } + + public function setCaption(?string $caption): self + { + $this->caption = $caption; + return $this; + } + + public function getUrl(): string|null + { + return $this->url; + } + + public function setUrl(?string $url): self + { + $this->url = $url; + return $this; + } +} diff --git a/Infobip/Model/WhatsAppWebhookListReplyContent.php b/Infobip/Model/WhatsAppWebhookListReplyContent.php new file mode 100644 index 0000000..c429455 --- /dev/null +++ b/Infobip/Model/WhatsAppWebhookListReplyContent.php @@ -0,0 +1,120 @@ + null, + 'title' => null, + 'description' => null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 200)] + #[Assert\Length(min: 0)] + + protected string $id, + #[Assert\NotBlank] + #[Assert\Length(max: 24)] + #[Assert\Length(min: 0)] + + protected string $title, + #[Assert\Valid] + + protected ?\Infobip\Model\WhatsAppWebhookContext $context = null, + #[Assert\Valid] + + protected ?\Infobip\Model\WhatsAppWebhookIdentity $identity = null, + #[Assert\Valid] + + protected ?\Infobip\Model\WhatsAppWebhookReferral $referral = null, + #[Assert\Length(max: 72)] + #[Assert\Length(min: 0)] + + protected ?string $description = null, + ) { + $modelDiscriminatorValue = 'INTERACTIVE_LIST_REPLY'; + + parent::__construct( + type: $modelDiscriminatorValue, + context: $context, + identity: $identity, + referral: $referral, + ); + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getId(): string + { + return $this->id; + } + + public function setId(string $id): self + { + $this->id = $id; + return $this; + } + + public function getTitle(): string + { + return $this->title; + } + + public function setTitle(string $title): self + { + $this->title = $title; + return $this; + } + + public function getDescription(): string|null + { + return $this->description; + } + + public function setDescription(?string $description): self + { + $this->description = $description; + return $this; + } +} diff --git a/Infobip/Model/WhatsAppWebhookMedia.php b/Infobip/Model/WhatsAppWebhookMedia.php new file mode 100644 index 0000000..be63e49 --- /dev/null +++ b/Infobip/Model/WhatsAppWebhookMedia.php @@ -0,0 +1,78 @@ + null, + 'url' => null + ]; + + /** + */ + public function __construct( + protected ?string $caption = null, + protected ?string $url = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getCaption(): string|null + { + return $this->caption; + } + + public function setCaption(?string $caption): self + { + $this->caption = $caption; + return $this; + } + + public function getUrl(): string|null + { + return $this->url; + } + + public function setUrl(?string $url): self + { + $this->url = $url; + return $this; + } +} diff --git a/Infobip/Model/WhatsAppWebhookName.php b/Infobip/Model/WhatsAppWebhookName.php new file mode 100644 index 0000000..91ca894 --- /dev/null +++ b/Infobip/Model/WhatsAppWebhookName.php @@ -0,0 +1,130 @@ + null, + 'formattedName' => null, + 'lastName' => null, + 'middleName' => null, + 'nameSuffix' => null, + 'namePrefix' => null + ]; + + /** + */ + public function __construct( + protected ?string $firstName = null, + protected ?string $formattedName = null, + protected ?string $lastName = null, + protected ?string $middleName = null, + protected ?string $nameSuffix = null, + protected ?string $namePrefix = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getFirstName(): string|null + { + return $this->firstName; + } + + public function setFirstName(?string $firstName): self + { + $this->firstName = $firstName; + return $this; + } + + public function getFormattedName(): string|null + { + return $this->formattedName; + } + + public function setFormattedName(?string $formattedName): self + { + $this->formattedName = $formattedName; + return $this; + } + + public function getLastName(): string|null + { + return $this->lastName; + } + + public function setLastName(?string $lastName): self + { + $this->lastName = $lastName; + return $this; + } + + public function getMiddleName(): string|null + { + return $this->middleName; + } + + public function setMiddleName(?string $middleName): self + { + $this->middleName = $middleName; + return $this; + } + + public function getNameSuffix(): string|null + { + return $this->nameSuffix; + } + + public function setNameSuffix(?string $nameSuffix): self + { + $this->nameSuffix = $nameSuffix; + return $this; + } + + public function getNamePrefix(): string|null + { + return $this->namePrefix; + } + + public function setNamePrefix(?string $namePrefix): self + { + $this->namePrefix = $namePrefix; + return $this; + } +} diff --git a/Infobip/Model/WhatsAppWebhookOrderContent.php b/Infobip/Model/WhatsAppWebhookOrderContent.php new file mode 100644 index 0000000..74e0a6a --- /dev/null +++ b/Infobip/Model/WhatsAppWebhookOrderContent.php @@ -0,0 +1,122 @@ + null, + 'text' => null, + 'productItems' => null + ]; + + /** + * @param \Infobip\Model\WhatsAppWebhookProductItem[] $productItems + */ + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(min: 0)] + + protected string $catalogId, + #[Assert\NotBlank] + #[Assert\Count(min: 1)] + + protected array $productItems, + #[Assert\Valid] + + protected ?\Infobip\Model\WhatsAppWebhookContext $context = null, + #[Assert\Valid] + + protected ?\Infobip\Model\WhatsAppWebhookIdentity $identity = null, + #[Assert\Valid] + + protected ?\Infobip\Model\WhatsAppWebhookReferral $referral = null, + protected ?string $text = null, + ) { + $modelDiscriminatorValue = 'ORDER'; + + parent::__construct( + type: $modelDiscriminatorValue, + context: $context, + identity: $identity, + referral: $referral, + ); + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getCatalogId(): string + { + return $this->catalogId; + } + + public function setCatalogId(string $catalogId): self + { + $this->catalogId = $catalogId; + return $this; + } + + public function getText(): string|null + { + return $this->text; + } + + public function setText(?string $text): self + { + $this->text = $text; + return $this; + } + + /** + * @return \Infobip\Model\WhatsAppWebhookProductItem[] + */ + public function getProductItems(): array + { + return $this->productItems; + } + + /** + * @param \Infobip\Model\WhatsAppWebhookProductItem[] $productItems An array of selected products. + */ + public function setProductItems(array $productItems): self + { + $this->productItems = $productItems; + return $this; + } +} diff --git a/Infobip/Model/WhatsAppWebhookOrganization.php b/Infobip/Model/WhatsAppWebhookOrganization.php new file mode 100644 index 0000000..936a33f --- /dev/null +++ b/Infobip/Model/WhatsAppWebhookOrganization.php @@ -0,0 +1,91 @@ + null, + 'department' => null, + 'title' => null + ]; + + /** + */ + public function __construct( + protected ?string $company = null, + protected ?string $department = null, + protected ?string $title = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getCompany(): string|null + { + return $this->company; + } + + public function setCompany(?string $company): self + { + $this->company = $company; + return $this; + } + + public function getDepartment(): string|null + { + return $this->department; + } + + public function setDepartment(?string $department): self + { + $this->department = $department; + return $this; + } + + public function getTitle(): string|null + { + return $this->title; + } + + public function setTitle(?string $title): self + { + $this->title = $title; + return $this; + } +} diff --git a/Infobip/Model/WhatsAppWebhookPhone.php b/Infobip/Model/WhatsAppWebhookPhone.php new file mode 100644 index 0000000..f46b20e --- /dev/null +++ b/Infobip/Model/WhatsAppWebhookPhone.php @@ -0,0 +1,93 @@ + null, + 'waId' => null, + 'type' => null + ]; + + /** + */ + public function __construct( + protected ?string $phone = null, + protected ?string $waId = null, + #[Assert\Choice(['CELL','MAIN','IPHONE','HOME','WORK',])] + + protected ?string $type = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getPhone(): string|null + { + return $this->phone; + } + + public function setPhone(?string $phone): self + { + $this->phone = $phone; + return $this; + } + + public function getWaId(): string|null + { + return $this->waId; + } + + public function setWaId(?string $waId): self + { + $this->waId = $waId; + return $this; + } + + public function getType(): mixed + { + return $this->type; + } + + public function setType($type): self + { + $this->type = $type; + return $this; + } +} diff --git a/Infobip/Model/WhatsAppWebhookProductItem.php b/Infobip/Model/WhatsAppWebhookProductItem.php new file mode 100644 index 0000000..6164325 --- /dev/null +++ b/Infobip/Model/WhatsAppWebhookProductItem.php @@ -0,0 +1,115 @@ + null, + 'itemPrice' => null, + 'productRetailerId' => null, + 'quantity' => null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(min: 0)] + + protected string $currency, + #[Assert\NotBlank] + + protected float $itemPrice, + #[Assert\NotBlank] + #[Assert\Length(min: 0)] + + protected string $productRetailerId, + #[Assert\NotBlank] + #[Assert\GreaterThan(1)] + + protected int $quantity, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getCurrency(): string + { + return $this->currency; + } + + public function setCurrency(string $currency): self + { + $this->currency = $currency; + return $this; + } + + public function getItemPrice(): float + { + return $this->itemPrice; + } + + public function setItemPrice(float $itemPrice): self + { + $this->itemPrice = $itemPrice; + return $this; + } + + public function getProductRetailerId(): string + { + return $this->productRetailerId; + } + + public function setProductRetailerId(string $productRetailerId): self + { + $this->productRetailerId = $productRetailerId; + return $this; + } + + public function getQuantity(): int + { + return $this->quantity; + } + + public function setQuantity(int $quantity): self + { + $this->quantity = $quantity; + return $this; + } +} diff --git a/Infobip/Model/WhatsAppWebhookQuickReplyContent.php b/Infobip/Model/WhatsAppWebhookQuickReplyContent.php new file mode 100644 index 0000000..cc2be90 --- /dev/null +++ b/Infobip/Model/WhatsAppWebhookQuickReplyContent.php @@ -0,0 +1,104 @@ + null, + 'payload' => null + ]; + + /** + */ + public function __construct( + #[Assert\NotBlank] + #[Assert\Length(max: 20)] + #[Assert\Length(min: 0)] + + protected string $text, + #[Assert\NotBlank] + #[Assert\Length(max: 128)] + #[Assert\Length(min: 0)] + + protected string $payload, + #[Assert\Valid] + + protected ?\Infobip\Model\WhatsAppWebhookContext $context = null, + #[Assert\Valid] + + protected ?\Infobip\Model\WhatsAppWebhookIdentity $identity = null, + #[Assert\Valid] + + protected ?\Infobip\Model\WhatsAppWebhookReferral $referral = null, + ) { + $modelDiscriminatorValue = 'BUTTON'; + + parent::__construct( + type: $modelDiscriminatorValue, + context: $context, + identity: $identity, + referral: $referral, + ); + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getText(): string + { + return $this->text; + } + + public function setText(string $text): self + { + $this->text = $text; + return $this; + } + + public function getPayload(): string + { + return $this->payload; + } + + public function setPayload(string $payload): self + { + $this->payload = $payload; + return $this; + } +} diff --git a/Infobip/Model/WhatsAppWebhookReferral.php b/Infobip/Model/WhatsAppWebhookReferral.php new file mode 100644 index 0000000..36cfe0d --- /dev/null +++ b/Infobip/Model/WhatsAppWebhookReferral.php @@ -0,0 +1,93 @@ + null, + 'sourceId' => null, + 'sourceUrl' => null + ]; + + /** + */ + public function __construct( + #[Assert\Choice(['AD','POST','UNKNOWN',])] + + protected ?string $sourceType = null, + protected ?string $sourceId = null, + protected ?string $sourceUrl = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getSourceType(): mixed + { + return $this->sourceType; + } + + public function setSourceType($sourceType): self + { + $this->sourceType = $sourceType; + return $this; + } + + public function getSourceId(): string|null + { + return $this->sourceId; + } + + public function setSourceId(?string $sourceId): self + { + $this->sourceId = $sourceId; + return $this; + } + + public function getSourceUrl(): string|null + { + return $this->sourceUrl; + } + + public function setSourceUrl(?string $sourceUrl): self + { + $this->sourceUrl = $sourceUrl; + return $this; + } +} diff --git a/Infobip/Model/WhatsAppWebhookReferredProduct.php b/Infobip/Model/WhatsAppWebhookReferredProduct.php new file mode 100644 index 0000000..45788d2 --- /dev/null +++ b/Infobip/Model/WhatsAppWebhookReferredProduct.php @@ -0,0 +1,82 @@ + null, + 'productRetailerId' => null + ]; + + /** + */ + public function __construct( + #[Assert\Length(min: 0)] + + protected ?string $catalogId = null, + #[Assert\Length(min: 0)] + + protected ?string $productRetailerId = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getCatalogId(): string|null + { + return $this->catalogId; + } + + public function setCatalogId(?string $catalogId): self + { + $this->catalogId = $catalogId; + return $this; + } + + public function getProductRetailerId(): string|null + { + return $this->productRetailerId; + } + + public function setProductRetailerId(?string $productRetailerId): self + { + $this->productRetailerId = $productRetailerId; + return $this; + } +} diff --git a/Infobip/Model/WhatsAppWebhookSeenDeletedBase.php b/Infobip/Model/WhatsAppWebhookSeenDeletedBase.php new file mode 100644 index 0000000..b5f7f8e --- /dev/null +++ b/Infobip/Model/WhatsAppWebhookSeenDeletedBase.php @@ -0,0 +1,106 @@ + null, + 'from' => null, + 'to' => null, + 'sentAt' => 'date-time' + ]; + + /** + */ + public function __construct( + protected ?string $messageId = null, + protected ?string $from = null, + protected ?string $to = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $sentAt = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getMessageId(): string|null + { + return $this->messageId; + } + + public function setMessageId(?string $messageId): self + { + $this->messageId = $messageId; + return $this; + } + + public function getFrom(): string|null + { + return $this->from; + } + + public function setFrom(?string $from): self + { + $this->from = $from; + return $this; + } + + public function getTo(): string|null + { + return $this->to; + } + + public function setTo(?string $to): self + { + $this->to = $to; + return $this; + } + + public function getSentAt(): \DateTime|null + { + return $this->sentAt; + } + + public function setSentAt(?\DateTime $sentAt): self + { + $this->sentAt = $sentAt; + return $this; + } +} diff --git a/Infobip/Model/WhatsAppWebhookSeenReport.php b/Infobip/Model/WhatsAppWebhookSeenReport.php new file mode 100644 index 0000000..3fe930b --- /dev/null +++ b/Infobip/Model/WhatsAppWebhookSeenReport.php @@ -0,0 +1,121 @@ + null, + 'from' => null, + 'to' => null, + 'sentAt' => 'date-time', + 'seenAt' => 'date-time' + ]; + + /** + */ + public function __construct( + protected ?string $messageId = null, + protected ?string $from = null, + protected ?string $to = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $sentAt = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $seenAt = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getMessageId(): string|null + { + return $this->messageId; + } + + public function setMessageId(?string $messageId): self + { + $this->messageId = $messageId; + return $this; + } + + public function getFrom(): string|null + { + return $this->from; + } + + public function setFrom(?string $from): self + { + $this->from = $from; + return $this; + } + + public function getTo(): string|null + { + return $this->to; + } + + public function setTo(?string $to): self + { + $this->to = $to; + return $this; + } + + public function getSentAt(): \DateTime|null + { + return $this->sentAt; + } + + public function setSentAt(?\DateTime $sentAt): self + { + $this->sentAt = $sentAt; + return $this; + } + + public function getSeenAt(): \DateTime|null + { + return $this->seenAt; + } + + public function setSeenAt(?\DateTime $seenAt): self + { + $this->seenAt = $seenAt; + return $this; + } +} diff --git a/Infobip/Model/WhatsAppWebhookSeenResult.php b/Infobip/Model/WhatsAppWebhookSeenResult.php new file mode 100644 index 0000000..af2feb2 --- /dev/null +++ b/Infobip/Model/WhatsAppWebhookSeenResult.php @@ -0,0 +1,72 @@ + null + ]; + + /** + * @param \Infobip\Model\WhatsAppWebhookSeenReport[] $results + */ + public function __construct( + protected ?array $results = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + /** + * @return \Infobip\Model\WhatsAppWebhookSeenReport[]|null + */ + public function getResults(): ?array + { + return $this->results; + } + + /** + * @param \Infobip\Model\WhatsAppWebhookSeenReport[]|null $results Collection of reports, one per every message. + */ + public function setResults(?array $results): self + { + $this->results = $results; + return $this; + } +} diff --git a/Infobip/Model/WhatsAppWebhookSystemEvent.php b/Infobip/Model/WhatsAppWebhookSystemEvent.php new file mode 100644 index 0000000..59ad716 --- /dev/null +++ b/Infobip/Model/WhatsAppWebhookSystemEvent.php @@ -0,0 +1,106 @@ + null, + 'hash' => null, + 'type' => null, + 'userNumber' => null + ]; + + /** + */ + public function __construct( + protected ?string $description = null, + protected ?string $hash = null, + #[Assert\Choice(['user_identity_changed',])] + + protected ?string $type = null, + protected ?string $userNumber = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getDescription(): string|null + { + return $this->description; + } + + public function setDescription(?string $description): self + { + $this->description = $description; + return $this; + } + + public function getHash(): string|null + { + return $this->hash; + } + + public function setHash(?string $hash): self + { + $this->hash = $hash; + return $this; + } + + public function getType(): mixed + { + return $this->type; + } + + public function setType($type): self + { + $this->type = $type; + return $this; + } + + public function getUserNumber(): string|null + { + return $this->userNumber; + } + + public function setUserNumber(?string $userNumber): self + { + $this->userNumber = $userNumber; + return $this; + } +} diff --git a/Infobip/Model/WhatsAppWebhookSystemEventResponse.php b/Infobip/Model/WhatsAppWebhookSystemEventResponse.php new file mode 100644 index 0000000..1263d7e --- /dev/null +++ b/Infobip/Model/WhatsAppWebhookSystemEventResponse.php @@ -0,0 +1,95 @@ + null, + 'content' => null, + 'createdAt' => 'date-time' + ]; + + /** + */ + public function __construct( + protected ?string $from = null, + #[Assert\Valid] + + protected ?\Infobip\Model\WhatsAppWebhookSystemEvent $content = null, + #[Serializer\Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d\TH:i:s.vP'])] + + protected ?\DateTime $createdAt = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getFrom(): string|null + { + return $this->from; + } + + public function setFrom(?string $from): self + { + $this->from = $from; + return $this; + } + + public function getContent(): \Infobip\Model\WhatsAppWebhookSystemEvent|null + { + return $this->content; + } + + public function setContent(?\Infobip\Model\WhatsAppWebhookSystemEvent $content): self + { + $this->content = $content; + return $this; + } + + public function getCreatedAt(): \DateTime|null + { + return $this->createdAt; + } + + public function setCreatedAt(?\DateTime $createdAt): self + { + $this->createdAt = $createdAt; + return $this; + } +} diff --git a/Infobip/Model/WhatsAppWebhookType.php b/Infobip/Model/WhatsAppWebhookType.php new file mode 100644 index 0000000..bef3432 --- /dev/null +++ b/Infobip/Model/WhatsAppWebhookType.php @@ -0,0 +1,148 @@ +value = $value; + } + + public static function TEXT(): WhatsAppWebhookType + { + return new self('TEXT'); + } + + public static function IMAGE(): WhatsAppWebhookType + { + return new self('IMAGE'); + } + + public static function DOCUMENT(): WhatsAppWebhookType + { + return new self('DOCUMENT'); + } + + public static function STICKER(): WhatsAppWebhookType + { + return new self('STICKER'); + } + + public static function LOCATION(): WhatsAppWebhookType + { + return new self('LOCATION'); + } + + public static function CONTACT(): WhatsAppWebhookType + { + return new self('CONTACT'); + } + + public static function VIDEO(): WhatsAppWebhookType + { + return new self('VIDEO'); + } + + public static function VOICE(): WhatsAppWebhookType + { + return new self('VOICE'); + } + + public static function AUDIO(): WhatsAppWebhookType + { + return new self('AUDIO'); + } + + public static function BUTTON(): WhatsAppWebhookType + { + return new self('BUTTON'); + } + + public static function INTERACTIVE_BUTTON_REPLY(): WhatsAppWebhookType + { + return new self('INTERACTIVE_BUTTON_REPLY'); + } + + public static function INTERACTIVE_LIST_REPLY(): WhatsAppWebhookType + { + return new self('INTERACTIVE_LIST_REPLY'); + } + + public static function ORDER(): WhatsAppWebhookType + { + return new self('ORDER'); + } + + public static function UNSUPPORTED(): WhatsAppWebhookType + { + return new self('UNSUPPORTED'); + } + + public function __toString(): string + { + return $this->value; + } +} diff --git a/Infobip/Model/WhatsAppWebhookUrl.php b/Infobip/Model/WhatsAppWebhookUrl.php new file mode 100644 index 0000000..7cafef0 --- /dev/null +++ b/Infobip/Model/WhatsAppWebhookUrl.php @@ -0,0 +1,80 @@ + null, + 'type' => null + ]; + + /** + */ + public function __construct( + protected ?string $url = null, + #[Assert\Choice(['HOME','WORK',])] + + protected ?string $type = null, + ) { + } + + #[Ignore] + public function getModelName(): string + { + return self::OPENAPI_MODEL_NAME; + } + + #[Ignore] + public static function getDiscriminator(): ?string + { + return self::DISCRIMINATOR; + } + + public function getUrl(): string|null + { + return $this->url; + } + + public function setUrl(?string $url): self + { + $this->url = $url; + return $this; + } + + public function getType(): mixed + { + return $this->type; + } + + public function setType($type): self + { + $this->type = $type; + return $this; + } +} diff --git a/Infobip/ObjectSerializer.php b/Infobip/ObjectSerializer.php index 922f712..1cb4f29 100644 --- a/Infobip/ObjectSerializer.php +++ b/Infobip/ObjectSerializer.php @@ -2,7 +2,7 @@ /** * ObjectSerializer * - * PHP version 7.2 + * PHP version 8.0 * * @category Class * @package Infobip @@ -17,680 +17,243 @@ * * Contact: support@infobip.com * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * Do not edit the class manually. + * This class is auto generated from the Infobip OpenAPI specification through the OpenAPI Specification Client API libraries (Re)Generator (OSCAR), powered by the OpenAPI Generator (https://openapi-generator.tech). + * + * Do not edit manually. To learn how to raise an issue, see the CONTRIBUTING guide or contact us @ support@infobip.com. */ namespace Infobip; +use DateTimeInterface; +use Doctrine\Common\Annotations\AnnotationReader; use Infobip\Model\ModelInterface; - -/** - * ObjectSerializer Class Doc Comment - * - * @category Class - * @package Infobip - * @author Infobip Support - * @link https://www.infobip.com - */ -class ObjectSerializer +use InvalidArgumentException; +use SplFileObject; +use Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor; +use Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor; +use Symfony\Component\PropertyInfo\PropertyInfoExtractor; +use Symfony\Component\Serializer\Encoder\JsonEncoder; +use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory; +use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader; +use Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer; +use Symfony\Component\Serializer\Normalizer\ArrayDenormalizer; +use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer; +use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; +use Symfony\Component\Serializer\Serializer; +use Symfony\Component\Serializer\SerializerInterface; +use Symfony\Component\Validator\Constraint; +use Symfony\Component\Validator\ConstraintViolationInterface; +use Symfony\Component\Validator\Validation; +use Symfony\Component\Validator\Validator\ValidatorInterface; + +final class ObjectSerializer { - /** @var string */ - private static $dateTimeFormat = "Y-m-d\TH:i:s.vP"; - - private const DISCRIMINATOR_MAPPINGS = [ - "PHONE_NUMBER"=>"WhatsAppPhoneNumberButtonApiData", - "QUICK_REPLY"=>"WhatsAppQuickReplyButtonApiData", - "URL"=>"WhatsAppUrlButtonApiData", - "WhatsAppPhoneNumberButtonApiData"=>"WhatsAppPhoneNumberButtonApiData", - "WhatsAppQuickReplyButtonApiData"=>"WhatsAppQuickReplyButtonApiData", - "WhatsAppUrlButtonApiData"=>"WhatsAppUrlButtonApiData", - "AUDIO"=>"WhatsAppInboundAudioMessage", - "BUTTON"=>"WhatsAppQuickReplyContent", - "CONTACT"=>"WhatsAppInboundContactMessage", - "DOCUMENT"=>"WhatsAppInboundDocumentMessage", - "IMAGE"=>"WhatsAppInboundImageMessage", - "INTERACTIVE_BUTTON_REPLY"=>"WhatsAppButtonReplyContent", - "INTERACTIVE_LIST_REPLY"=>"WhatsAppListReplyContent", - "LOCATION"=>"WhatsAppInboundLocationMessage", - "ORDER"=>"WhatsAppOrderContent", - "STICKER"=>"WhatsAppInboundStickerMessage", - "TEXT"=>"WhatsAppInboundTextMessage", - "VIDEO"=>"WhatsAppInboundVideoMessage", - "VOICE"=>"WhatsAppInboundVoiceMessage", - "DOCUMENT"=>"WhatsAppDocumentHeaderApiData", - "IMAGE"=>"WhatsAppImageHeaderApiData", - "LOCATION"=>"WhatsAppLocationHeaderApiData", - "TEXT"=>"WhatsAppTextHeaderApiData", - "VIDEO"=>"WhatsAppVideoHeaderApiData", - "DOCUMENT"=>"WhatsAppDocumentHeaderApiData", - "IMAGE"=>"WhatsAppImageHeaderApiData", - "LOCATION"=>"WhatsAppLocationHeaderApiData", - "TEXT"=>"WhatsAppTextHeaderApiData", - "VIDEO"=>"WhatsAppVideoHeaderApiData", - "WhatsAppDocumentHeaderApiData"=>"WhatsAppDocumentHeaderApiData", - "WhatsAppImageHeaderApiData"=>"WhatsAppImageHeaderApiData", - "WhatsAppLocationHeaderApiData"=>"WhatsAppLocationHeaderApiData", - "WhatsAppTextHeaderApiData"=>"WhatsAppTextHeaderApiData", - "WhatsAppVideoHeaderApiData"=>"WhatsAppVideoHeaderApiData", - "DOCUMENT"=>"WhatsAppDocumentHeaderApiData", - "IMAGE"=>"WhatsAppImageHeaderApiData", - "LOCATION"=>"WhatsAppLocationHeaderApiData", - "TEXT"=>"WhatsAppTextHeaderApiData", - "VIDEO"=>"WhatsAppVideoHeaderApiData", - "AUDIO"=>"WhatsAppInboundAudioMessage", - "BUTTON"=>"WhatsAppQuickReplyContent", - "CONTACT"=>"WhatsAppInboundContactMessage", - "DOCUMENT"=>"WhatsAppInboundDocumentMessage", - "IMAGE"=>"WhatsAppInboundImageMessage", - "INTERACTIVE_BUTTON_REPLY"=>"WhatsAppButtonReplyContent", - "INTERACTIVE_LIST_REPLY"=>"WhatsAppListReplyContent", - "LOCATION"=>"WhatsAppInboundLocationMessage", - "ORDER"=>"WhatsAppOrderContent", - "STICKER"=>"WhatsAppInboundStickerMessage", - "TEXT"=>"WhatsAppInboundTextMessage", - "VIDEO"=>"WhatsAppInboundVideoMessage", - "VOICE"=>"WhatsAppInboundVoiceMessage", - "AUDIO"=>"WhatsAppInboundAudioMessage", - "BUTTON"=>"WhatsAppQuickReplyContent", - "CONTACT"=>"WhatsAppInboundContactMessage", - "DOCUMENT"=>"WhatsAppInboundDocumentMessage", - "IMAGE"=>"WhatsAppInboundImageMessage", - "INTERACTIVE_BUTTON_REPLY"=>"WhatsAppButtonReplyContent", - "INTERACTIVE_LIST_REPLY"=>"WhatsAppListReplyContent", - "LOCATION"=>"WhatsAppInboundLocationMessage", - "ORDER"=>"WhatsAppOrderContent", - "STICKER"=>"WhatsAppInboundStickerMessage", - "TEXT"=>"WhatsAppInboundTextMessage", - "VIDEO"=>"WhatsAppInboundVideoMessage", - "VOICE"=>"WhatsAppInboundVoiceMessage", - "AUDIO"=>"WhatsAppInboundAudioMessage", - "BUTTON"=>"WhatsAppQuickReplyContent", - "CONTACT"=>"WhatsAppInboundContactMessage", - "DOCUMENT"=>"WhatsAppInboundDocumentMessage", - "IMAGE"=>"WhatsAppInboundImageMessage", - "INTERACTIVE_BUTTON_REPLY"=>"WhatsAppButtonReplyContent", - "INTERACTIVE_LIST_REPLY"=>"WhatsAppListReplyContent", - "LOCATION"=>"WhatsAppInboundLocationMessage", - "ORDER"=>"WhatsAppOrderContent", - "STICKER"=>"WhatsAppInboundStickerMessage", - "TEXT"=>"WhatsAppInboundTextMessage", - "VIDEO"=>"WhatsAppInboundVideoMessage", - "VOICE"=>"WhatsAppInboundVoiceMessage", - "AUDIO"=>"WhatsAppInboundAudioMessage", - "BUTTON"=>"WhatsAppQuickReplyContent", - "CONTACT"=>"WhatsAppInboundContactMessage", - "DOCUMENT"=>"WhatsAppInboundDocumentMessage", - "IMAGE"=>"WhatsAppInboundImageMessage", - "INTERACTIVE_BUTTON_REPLY"=>"WhatsAppButtonReplyContent", - "INTERACTIVE_LIST_REPLY"=>"WhatsAppListReplyContent", - "LOCATION"=>"WhatsAppInboundLocationMessage", - "ORDER"=>"WhatsAppOrderContent", - "STICKER"=>"WhatsAppInboundStickerMessage", - "TEXT"=>"WhatsAppInboundTextMessage", - "VIDEO"=>"WhatsAppInboundVideoMessage", - "VOICE"=>"WhatsAppInboundVoiceMessage", - "AUDIO"=>"WhatsAppInboundAudioMessage", - "BUTTON"=>"WhatsAppQuickReplyContent", - "CONTACT"=>"WhatsAppInboundContactMessage", - "DOCUMENT"=>"WhatsAppInboundDocumentMessage", - "IMAGE"=>"WhatsAppInboundImageMessage", - "INTERACTIVE_BUTTON_REPLY"=>"WhatsAppButtonReplyContent", - "INTERACTIVE_LIST_REPLY"=>"WhatsAppListReplyContent", - "LOCATION"=>"WhatsAppInboundLocationMessage", - "ORDER"=>"WhatsAppOrderContent", - "STICKER"=>"WhatsAppInboundStickerMessage", - "TEXT"=>"WhatsAppInboundTextMessage", - "VIDEO"=>"WhatsAppInboundVideoMessage", - "VOICE"=>"WhatsAppInboundVoiceMessage", - "AUDIO"=>"WhatsAppInboundAudioMessage", - "BUTTON"=>"WhatsAppQuickReplyContent", - "CONTACT"=>"WhatsAppInboundContactMessage", - "DOCUMENT"=>"WhatsAppInboundDocumentMessage", - "IMAGE"=>"WhatsAppInboundImageMessage", - "INTERACTIVE_BUTTON_REPLY"=>"WhatsAppButtonReplyContent", - "INTERACTIVE_LIST_REPLY"=>"WhatsAppListReplyContent", - "LOCATION"=>"WhatsAppInboundLocationMessage", - "ORDER"=>"WhatsAppOrderContent", - "STICKER"=>"WhatsAppInboundStickerMessage", - "TEXT"=>"WhatsAppInboundTextMessage", - "VIDEO"=>"WhatsAppInboundVideoMessage", - "VOICE"=>"WhatsAppInboundVoiceMessage", - "WhatsAppButtonReplyContent"=>"WhatsAppButtonReplyContent", - "WhatsAppInboundAudioMessage"=>"WhatsAppInboundAudioMessage", - "WhatsAppInboundContactMessage"=>"WhatsAppInboundContactMessage", - "WhatsAppInboundDocumentMessage"=>"WhatsAppInboundDocumentMessage", - "WhatsAppInboundImageMessage"=>"WhatsAppInboundImageMessage", - "WhatsAppInboundLocationMessage"=>"WhatsAppInboundLocationMessage", - "WhatsAppInboundStickerMessage"=>"WhatsAppInboundStickerMessage", - "WhatsAppInboundTextMessage"=>"WhatsAppInboundTextMessage", - "WhatsAppInboundVideoMessage"=>"WhatsAppInboundVideoMessage", - "WhatsAppInboundVoiceMessage"=>"WhatsAppInboundVoiceMessage", - "WhatsAppListReplyContent"=>"WhatsAppListReplyContent", - "WhatsAppOrderContent"=>"WhatsAppOrderContent", - "WhatsAppQuickReplyContent"=>"WhatsAppQuickReplyContent", - "AUDIO"=>"WhatsAppInboundAudioMessage", - "BUTTON"=>"WhatsAppQuickReplyContent", - "CONTACT"=>"WhatsAppInboundContactMessage", - "DOCUMENT"=>"WhatsAppInboundDocumentMessage", - "IMAGE"=>"WhatsAppInboundImageMessage", - "INTERACTIVE_BUTTON_REPLY"=>"WhatsAppButtonReplyContent", - "INTERACTIVE_LIST_REPLY"=>"WhatsAppListReplyContent", - "LOCATION"=>"WhatsAppInboundLocationMessage", - "ORDER"=>"WhatsAppOrderContent", - "STICKER"=>"WhatsAppInboundStickerMessage", - "TEXT"=>"WhatsAppInboundTextMessage", - "VIDEO"=>"WhatsAppInboundVideoMessage", - "VOICE"=>"WhatsAppInboundVoiceMessage", - "AUDIO"=>"WhatsAppInboundAudioMessage", - "BUTTON"=>"WhatsAppQuickReplyContent", - "CONTACT"=>"WhatsAppInboundContactMessage", - "DOCUMENT"=>"WhatsAppInboundDocumentMessage", - "IMAGE"=>"WhatsAppInboundImageMessage", - "INTERACTIVE_BUTTON_REPLY"=>"WhatsAppButtonReplyContent", - "INTERACTIVE_LIST_REPLY"=>"WhatsAppListReplyContent", - "LOCATION"=>"WhatsAppInboundLocationMessage", - "ORDER"=>"WhatsAppOrderContent", - "STICKER"=>"WhatsAppInboundStickerMessage", - "TEXT"=>"WhatsAppInboundTextMessage", - "VIDEO"=>"WhatsAppInboundVideoMessage", - "VOICE"=>"WhatsAppInboundVoiceMessage", - "AUDIO"=>"WhatsAppInboundAudioMessage", - "BUTTON"=>"WhatsAppQuickReplyContent", - "CONTACT"=>"WhatsAppInboundContactMessage", - "DOCUMENT"=>"WhatsAppInboundDocumentMessage", - "IMAGE"=>"WhatsAppInboundImageMessage", - "INTERACTIVE_BUTTON_REPLY"=>"WhatsAppButtonReplyContent", - "INTERACTIVE_LIST_REPLY"=>"WhatsAppListReplyContent", - "LOCATION"=>"WhatsAppInboundLocationMessage", - "ORDER"=>"WhatsAppOrderContent", - "STICKER"=>"WhatsAppInboundStickerMessage", - "TEXT"=>"WhatsAppInboundTextMessage", - "VIDEO"=>"WhatsAppInboundVideoMessage", - "VOICE"=>"WhatsAppInboundVoiceMessage", - "AUDIO"=>"WhatsAppInboundAudioMessage", - "BUTTON"=>"WhatsAppQuickReplyContent", - "CONTACT"=>"WhatsAppInboundContactMessage", - "DOCUMENT"=>"WhatsAppInboundDocumentMessage", - "IMAGE"=>"WhatsAppInboundImageMessage", - "INTERACTIVE_BUTTON_REPLY"=>"WhatsAppButtonReplyContent", - "INTERACTIVE_LIST_REPLY"=>"WhatsAppListReplyContent", - "LOCATION"=>"WhatsAppInboundLocationMessage", - "ORDER"=>"WhatsAppOrderContent", - "STICKER"=>"WhatsAppInboundStickerMessage", - "TEXT"=>"WhatsAppInboundTextMessage", - "VIDEO"=>"WhatsAppInboundVideoMessage", - "VOICE"=>"WhatsAppInboundVoiceMessage", - "REPLY"=>"WhatsAppInteractiveReplyButtonContent", - "WhatsAppInteractiveReplyButtonContent"=>"WhatsAppInteractiveReplyButtonContent", - "DOCUMENT"=>"WhatsAppInteractiveButtonsDocumentHeaderContent", - "IMAGE"=>"WhatsAppInteractiveButtonsImageHeaderContent", - "TEXT"=>"WhatsAppInteractiveButtonsTextHeaderContent", - "VIDEO"=>"WhatsAppInteractiveButtonsVideoHeaderContent", - "DOCUMENT"=>"WhatsAppInteractiveButtonsDocumentHeaderContent", - "IMAGE"=>"WhatsAppInteractiveButtonsImageHeaderContent", - "TEXT"=>"WhatsAppInteractiveButtonsTextHeaderContent", - "VIDEO"=>"WhatsAppInteractiveButtonsVideoHeaderContent", - "WhatsAppInteractiveButtonsDocumentHeaderContent"=>"WhatsAppInteractiveButtonsDocumentHeaderContent", - "WhatsAppInteractiveButtonsImageHeaderContent"=>"WhatsAppInteractiveButtonsImageHeaderContent", - "WhatsAppInteractiveButtonsTextHeaderContent"=>"WhatsAppInteractiveButtonsTextHeaderContent", - "WhatsAppInteractiveButtonsVideoHeaderContent"=>"WhatsAppInteractiveButtonsVideoHeaderContent", - "DOCUMENT"=>"WhatsAppInteractiveButtonsDocumentHeaderContent", - "IMAGE"=>"WhatsAppInteractiveButtonsImageHeaderContent", - "TEXT"=>"WhatsAppInteractiveButtonsTextHeaderContent", - "VIDEO"=>"WhatsAppInteractiveButtonsVideoHeaderContent", - "DOCUMENT"=>"WhatsAppInteractiveButtonsDocumentHeaderContent", - "IMAGE"=>"WhatsAppInteractiveButtonsImageHeaderContent", - "TEXT"=>"WhatsAppInteractiveButtonsTextHeaderContent", - "VIDEO"=>"WhatsAppInteractiveButtonsVideoHeaderContent", - "DOCUMENT"=>"WhatsAppInteractiveButtonsDocumentHeaderContent", - "IMAGE"=>"WhatsAppInteractiveButtonsImageHeaderContent", - "TEXT"=>"WhatsAppInteractiveButtonsTextHeaderContent", - "VIDEO"=>"WhatsAppInteractiveButtonsVideoHeaderContent", - "TEXT"=>"WhatsAppInteractiveListTextHeaderContent", - "WhatsAppInteractiveListTextHeaderContent"=>"WhatsAppInteractiveListTextHeaderContent", - "TEXT"=>"WhatsAppInteractiveListTextHeaderContent", - "REPLY"=>"WhatsAppInteractiveReplyButtonContent", - "AUDIO"=>"WhatsAppInboundAudioMessage", - "BUTTON"=>"WhatsAppQuickReplyContent", - "CONTACT"=>"WhatsAppInboundContactMessage", - "DOCUMENT"=>"WhatsAppInboundDocumentMessage", - "IMAGE"=>"WhatsAppInboundImageMessage", - "INTERACTIVE_BUTTON_REPLY"=>"WhatsAppButtonReplyContent", - "INTERACTIVE_LIST_REPLY"=>"WhatsAppListReplyContent", - "LOCATION"=>"WhatsAppInboundLocationMessage", - "ORDER"=>"WhatsAppOrderContent", - "STICKER"=>"WhatsAppInboundStickerMessage", - "TEXT"=>"WhatsAppInboundTextMessage", - "VIDEO"=>"WhatsAppInboundVideoMessage", - "VOICE"=>"WhatsAppInboundVoiceMessage", - "DOCUMENT"=>"WhatsAppDocumentHeaderApiData", - "IMAGE"=>"WhatsAppImageHeaderApiData", - "LOCATION"=>"WhatsAppLocationHeaderApiData", - "TEXT"=>"WhatsAppTextHeaderApiData", - "VIDEO"=>"WhatsAppVideoHeaderApiData", - "AUDIO"=>"WhatsAppInboundAudioMessage", - "BUTTON"=>"WhatsAppQuickReplyContent", - "CONTACT"=>"WhatsAppInboundContactMessage", - "DOCUMENT"=>"WhatsAppInboundDocumentMessage", - "IMAGE"=>"WhatsAppInboundImageMessage", - "INTERACTIVE_BUTTON_REPLY"=>"WhatsAppButtonReplyContent", - "INTERACTIVE_LIST_REPLY"=>"WhatsAppListReplyContent", - "LOCATION"=>"WhatsAppInboundLocationMessage", - "ORDER"=>"WhatsAppOrderContent", - "STICKER"=>"WhatsAppInboundStickerMessage", - "TEXT"=>"WhatsAppInboundTextMessage", - "VIDEO"=>"WhatsAppInboundVideoMessage", - "VOICE"=>"WhatsAppInboundVoiceMessage", - "PHONE_NUMBER"=>"WhatsAppPhoneNumberButtonApiData", - "QUICK_REPLY"=>"WhatsAppQuickReplyButtonApiData", - "URL"=>"WhatsAppUrlButtonApiData", - "PHONE_NUMBER"=>"WhatsAppPhoneNumberButtonApiData", - "QUICK_REPLY"=>"WhatsAppQuickReplyButtonApiData", - "URL"=>"WhatsAppUrlButtonApiData", - "AUDIO"=>"WhatsAppInboundAudioMessage", - "BUTTON"=>"WhatsAppQuickReplyContent", - "CONTACT"=>"WhatsAppInboundContactMessage", - "DOCUMENT"=>"WhatsAppInboundDocumentMessage", - "IMAGE"=>"WhatsAppInboundImageMessage", - "INTERACTIVE_BUTTON_REPLY"=>"WhatsAppButtonReplyContent", - "INTERACTIVE_LIST_REPLY"=>"WhatsAppListReplyContent", - "LOCATION"=>"WhatsAppInboundLocationMessage", - "ORDER"=>"WhatsAppOrderContent", - "STICKER"=>"WhatsAppInboundStickerMessage", - "TEXT"=>"WhatsAppInboundTextMessage", - "VIDEO"=>"WhatsAppInboundVideoMessage", - "VOICE"=>"WhatsAppInboundVoiceMessage", - "QUICK_REPLY"=>"WhatsAppTemplateQuickReplyButtonContent", - "URL"=>"WhatsAppTemplateUrlButtonContent", - "WhatsAppTemplateQuickReplyButtonContent"=>"WhatsAppTemplateQuickReplyButtonContent", - "WhatsAppTemplateUrlButtonContent"=>"WhatsAppTemplateUrlButtonContent", - "DOCUMENT"=>"WhatsAppTemplateDocumentHeaderContent", - "IMAGE"=>"WhatsAppTemplateImageHeaderContent", - "LOCATION"=>"WhatsAppTemplateLocationHeaderContent", - "TEXT"=>"WhatsAppTemplateTextHeaderContent", - "VIDEO"=>"WhatsAppTemplateVideoHeaderContent", - "DOCUMENT"=>"WhatsAppTemplateDocumentHeaderContent", - "IMAGE"=>"WhatsAppTemplateImageHeaderContent", - "LOCATION"=>"WhatsAppTemplateLocationHeaderContent", - "TEXT"=>"WhatsAppTemplateTextHeaderContent", - "VIDEO"=>"WhatsAppTemplateVideoHeaderContent", - "WhatsAppTemplateDocumentHeaderContent"=>"WhatsAppTemplateDocumentHeaderContent", - "WhatsAppTemplateImageHeaderContent"=>"WhatsAppTemplateImageHeaderContent", - "WhatsAppTemplateLocationHeaderContent"=>"WhatsAppTemplateLocationHeaderContent", - "WhatsAppTemplateTextHeaderContent"=>"WhatsAppTemplateTextHeaderContent", - "WhatsAppTemplateVideoHeaderContent"=>"WhatsAppTemplateVideoHeaderContent", - "DOCUMENT"=>"WhatsAppTemplateDocumentHeaderContent", - "IMAGE"=>"WhatsAppTemplateImageHeaderContent", - "LOCATION"=>"WhatsAppTemplateLocationHeaderContent", - "TEXT"=>"WhatsAppTemplateTextHeaderContent", - "VIDEO"=>"WhatsAppTemplateVideoHeaderContent", - "DOCUMENT"=>"WhatsAppTemplateDocumentHeaderContent", - "IMAGE"=>"WhatsAppTemplateImageHeaderContent", - "LOCATION"=>"WhatsAppTemplateLocationHeaderContent", - "TEXT"=>"WhatsAppTemplateTextHeaderContent", - "VIDEO"=>"WhatsAppTemplateVideoHeaderContent", - "QUICK_REPLY"=>"WhatsAppTemplateQuickReplyButtonContent", - "URL"=>"WhatsAppTemplateUrlButtonContent", - "DOCUMENT"=>"WhatsAppTemplateDocumentHeaderContent", - "IMAGE"=>"WhatsAppTemplateImageHeaderContent", - "LOCATION"=>"WhatsAppTemplateLocationHeaderContent", - "TEXT"=>"WhatsAppTemplateTextHeaderContent", - "VIDEO"=>"WhatsAppTemplateVideoHeaderContent", - "QUICK_REPLY"=>"WhatsAppTemplateQuickReplyButtonContent", - "URL"=>"WhatsAppTemplateUrlButtonContent", - "DOCUMENT"=>"WhatsAppTemplateDocumentHeaderContent", - "IMAGE"=>"WhatsAppTemplateImageHeaderContent", - "LOCATION"=>"WhatsAppTemplateLocationHeaderContent", - "TEXT"=>"WhatsAppTemplateTextHeaderContent", - "VIDEO"=>"WhatsAppTemplateVideoHeaderContent", - "DOCUMENT"=>"WhatsAppDocumentHeaderApiData", - "IMAGE"=>"WhatsAppImageHeaderApiData", - "LOCATION"=>"WhatsAppLocationHeaderApiData", - "TEXT"=>"WhatsAppTextHeaderApiData", - "VIDEO"=>"WhatsAppVideoHeaderApiData", - "PHONE_NUMBER"=>"WhatsAppPhoneNumberButtonApiData", - "QUICK_REPLY"=>"WhatsAppQuickReplyButtonApiData", - "URL"=>"WhatsAppUrlButtonApiData", - "DOCUMENT"=>"WhatsAppDocumentHeaderApiData", - "IMAGE"=>"WhatsAppImageHeaderApiData", - "LOCATION"=>"WhatsAppLocationHeaderApiData", - "TEXT"=>"WhatsAppTextHeaderApiData", - "VIDEO"=>"WhatsAppVideoHeaderApiData", - ]; + public const DEFAULT_DATE_TIME_FORMAT = "Y-m-d\TH:i:s.vP"; - /** - * Serialize data - * - * @param mixed $data the data to serialize - * @param string $type the OpenAPIToolsType of the data - * @param string $format the format of the OpenAPITools type of the data - * - * @return scalar|object|array|null serialized form of $data - */ - public static function sanitizeForSerialization($data, $type = null, $format = null) + private SerializerInterface $serializer; + private ValidatorInterface $validator; + + public function __construct(?SerializerInterface $serializer = null) { - if (is_scalar($data) || null === $data) { - return $data; + if ($serializer === null) { + $classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader())); + $extractor = new PropertyInfoExtractor([], [new PhpDocExtractor(), new ReflectionExtractor()]); + + $serializer = new Serializer( + [ + new EnumNormalizer(), + new SplFileObjectNormalizer(), + new ArrayDenormalizer(), + new DateTimeNormalizer( + [DateTimeNormalizer::FORMAT_KEY => self::DEFAULT_DATE_TIME_FORMAT] + ), + new ObjectNormalizer( + $classMetadataFactory, + null, + null, + $extractor, + null, + null, + [AbstractObjectNormalizer::SKIP_NULL_VALUES => true] + ) + ], + [new JsonEncoder()] + ); } - if ($data instanceof \DateTime) { - return ($format === 'date') ? $data->format('Y-m-d') : $data->format(self::$dateTimeFormat); + $this->serializer = $serializer; + + $this->validator = Validation::createValidatorBuilder() + ->enableAnnotationMapping() + ->addDefaultDoctrineAnnotationReader() + ->getValidator(); + } + + public function serialize(mixed $data, string $format = JsonEncoder::FORMAT): string + { + if ($data instanceof ModelInterface) { + $this->validate($data); } - if (is_array($data)) { - foreach ($data as $property => $value) { - $data[$property] = self::sanitizeForSerialization($value); - } - return $data; + return $this->serializer->serialize($data, $format); + } + + public function deserialize( + mixed $data, + string $class, + array $headers = [], + string $format = JsonEncoder::FORMAT, + array $context = [] + ) { + if ($data === null) { + return null; } - if (is_object($data)) { - $values = []; - if ($data instanceof ModelInterface) { - $formats = $data::openAPIFormats(); - foreach ($data::openAPITypes() as $property => $openAPIType) { - $getter = $data::getters()[$property]; - $value = $data->$getter(); - if ($value !== null && !in_array($openAPIType, ['DateTime', 'bool', 'boolean', 'byte', 'double', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true)) { - $callable = [$openAPIType, 'getAllowableEnumValues']; - if (is_callable($callable)) { - /** array $callable */ - $allowedEnumTypes = $callable(); - if (!in_array($value, $allowedEnumTypes, true)) { - $imploded = implode("', '", $allowedEnumTypes); - throw new \InvalidArgumentException("Invalid value for enum '$openAPIType', must be one of: '$imploded'"); - } - } - } - if ($value !== null) { - $values[$data::attributeMap()[$property]] = self::sanitizeForSerialization($value, $openAPIType, $formats[$property]); - } - } - } else { - foreach ($data as $property => $value) { - $values[$property] = self::sanitizeForSerialization($value); - } - } - return (object)$values; - } else { - return (string)$data; + if ($class === '\DateTime') { + $class = \DateTime::class; } + + $context[SplFileObjectNormalizer::HEADERS_KEY] = $headers; + + return $this->serializer->deserialize($data, $class, $format, $context); } /** - * Sanitize filename by removing path. - * e.g. ../../sun.gif becomes sun.gif - * - * @param string $filename filename to be sanitized - * - * @return string the sanitized filename + * @internal */ - public static function sanitizeFilename($filename) + public function normalize(mixed $data, array $context = []): mixed { - if (preg_match("/.*[\/\\\\](.*)$/", $filename, $match)) { - return $match[1]; - } else { - return $filename; + return $this->serializer->normalize($data, null, $context); + } + + /** + * @internal + */ + public function denormalize(mixed $data, string $type, array $context = []): mixed + { + if ($type === '\DateTime') { + $type = \DateTime::class; } + + return $this->serializer->denormalize($data, $type, null, $context); } /** + * @internal * Take value and turn it into a string suitable for inclusion in * the path, by url-encoding. - * - * @param string $value a string which will be part of the path - * - * @return string the serialized object */ - public static function toPathValue($value) + public function toPathValue(string $value): string { - return rawurlencode(self::toString($value)); + return \rawurlencode($this->toString($value)); } /** + * @internal * Take value and turn it into a string suitable for inclusion in * the query, by imploding comma-separated if it's an object. * If it's a string, pass through unchanged. It will be url-encoded * later. - * - * @param string[]|string|\DateTime $object an object to be serialized to a string - * - * @return string the serialized object */ - public static function toQueryValue($object) + public function toQueryValue(mixed $object): string { - if (is_array($object)) { + if (\is_array($object)) { return implode(',', $object); - } else { - return self::toString($object); } + + return $this->toString($object); } /** + * @internal * Take value and turn it into a string suitable for inclusion in * the header. If it's a string, pass through unchanged * If it's a datetime object, format it using the predefined format. - * - * @param string $value a string which will be part of the header - * - * @return string the header string */ - public static function toHeaderValue($value) + public function toHeaderValue(mixed $value): string { $callable = [$value, 'toHeaderValue']; - if (is_callable($callable)) { + + if (\is_callable($callable)) { return $callable(); } - return self::toString($value); + return $this->toString($value); } /** - * Take value and turn it into a string suitable for inclusion in - * the http body (form parameter). If it's a string, pass through unchanged - * If it's a datetime object, format it using the predefined format. - * - * @param string|\SplFileObject $value the value of the form parameter - * - * @return string the form string + * @internal */ - public static function toFormValue($value) + public function toFormValue(mixed $value): string { - if ($value instanceof \SplFileObject) { - return $value->getRealPath(); - } else { - return self::toString($value); + if (\is_array($value)) { + return $this->serializeCollection($value); } + + return $this->toString($value); } /** - * Take value and turn it into a string suitable for inclusion in - * the parameter. If it's a string, pass through unchanged - * If it's a datetime object, format it using the predefined format. - * If it's a boolean, convert it to "true" or "false". - * - * @param string|bool|\DateTime $value the value of the parameter - * - * @return string the header string + * @internal */ - public static function toString($value) + public function toString(mixed $value): string { - if ($value instanceof \DateTime) { - return $value->format(self::$dateTimeFormat); - } elseif (is_bool($value)) { - return $value ? 'true' : 'false'; - } else { - return $value; + if ($value instanceof SplFileObject || $value instanceof DateTimeInterface) { + return $this->serializer->normalize($value); + } elseif (\is_bool($value)) { + return \var_export($value, true); } + + return (string)$value; } /** + * @internal * Serialize an array to a string. - * - * @param array $collection collection to serialize to a string - * @param string $style the format use for serialization (csv, - * ssv, tsv, pipes, multi) - * @param bool $allowCollectionFormatMulti allow collection format to be a multidimensional array - * - * @return string + * @param string|null $style - the format use for serialization (csv, ssv, tsv, pipes, multi) + * @param bool $allowCollectionFormatMulti - allow collection format to be a multidimensional array */ - public static function serializeCollection(array $collection, $style, $allowCollectionFormatMulti = false) - { + public function serializeCollection( + array $collection, + ?string $style = null, + bool $allowCollectionFormatMulti = false + ): string { if ($allowCollectionFormatMulti && ('multi' === $style)) { - // http_build_query() almost does the job for us. We just - // need to fix the result of multidimensional arrays. - return preg_replace('/%5B[0-9]+%5D=/', '=', http_build_query($collection, '', '&')); - } - switch ($style) { - case 'pipeDelimited': - case 'pipes': - return implode('|', $collection); - - case 'tsv': - return implode("\t", $collection); - - case 'spaceDelimited': - case 'ssv': - return implode(' ', $collection); - - case 'simple': - case 'csv': - // Deliberate fall through. CSV is default format. - default: - return implode(',', $collection); + return preg_replace('/%5B[0-9]+%5D=/', '=', \http_build_query($collection, '', '&')); } + + return match ($style) { + 'pipeDelimited', 'pipes' => implode('|', $collection), + 'tsv' => implode("\t", $collection), + 'spaceDelimited', 'ssv' => implode(' ', $collection), + default => implode(',', $collection) + }; } /** - * Deserialize a JSON string into an object - * - * @param mixed $data object or primitive to be deserialized - * @param string $class class name is passed as a string - * @param string[] $httpHeaders HTTP headers - * @param string $discriminator discriminator if polymorphism is used - * - * @return object|array|null a single or an array of $class instances + * @internal + * @param Constraint[] $constraints + * @throws InvalidArgumentException */ - public static function deserialize($data, $class, $httpHeaders = null) + public function validate(mixed $data, ?array $constraints = null) { - if (null === $data) { - return null; - } - - if (strcasecmp(substr($class, -2), '[]') === 0) { - $data = is_string($data) ? json_decode($data) : $data; - - if (!is_array($data)) { - throw new \InvalidArgumentException("Invalid array '$class'"); - } - - $subClass = substr($class, 0, -2); - $values = []; - foreach ($data as $key => $value) { - $values[] = self::deserialize($value, $subClass, null); + $result = $this->validator->validate($data, $constraints); + + if ($result->count()) { + $messages = []; + + /** + * @var ConstraintViolationInterface $item + */ + foreach ($result as $item) { + $messages[] = sprintf( + 'Property path \'%s\' validation failed with message: %s', + $item->getPropertyPath(), + $item->getMessage() + ); } - return $values; - } - - if (preg_match('/^(array<|map\[)/', $class)) { // for associative array e.g. array - $data = is_string($data) ? json_decode($data) : $data; - settype($data, 'array'); - $inner = substr($class, 4, -1); - $deserialized = []; - if (strrpos($inner, ",") !== false) { - $subClass_array = explode(',', $inner, 2); - $subClass = $subClass_array[1]; - foreach ($data as $key => $value) { - $deserialized[$key] = self::deserialize($value, $subClass, null); - } - } - return $deserialized; - } - - if ($class === 'object') { - settype($data, 'array'); - return $data; - } - if ($class === '\DateTime') { - // Some API's return an invalid, empty string as a - // date-time property. DateTime::__construct() will return - // the current time for empty input which is probably not - // what is meant. The invalid empty string is probably to - // be interpreted as a missing field/value. Let's handle - // this graceful. - if (!empty($data)) { - try { - return new \DateTime($data); - } catch (\Exception $exception) { - // Some API's return a date-time with too high nanosecond - // precision for php's DateTime to handle. This conversion - // (string -> unix timestamp -> DateTime) is a workaround - // for the problem. - return (new \DateTime())->setTimestamp(strtotime($data)); - } - } else { - return null; - } - } - - /** @psalm-suppress ParadoxicalCondition */ - if (in_array($class, ['DateTime', 'bool', 'boolean', 'byte', 'double', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true)) { - settype($data, $class); - return $data; - } - - if ($class === '\SplFileObject') { - /** @var \Psr\Http\Message\StreamInterface $data */ - - // determine file name - if (array_key_exists('Content-Disposition', $httpHeaders) && - preg_match('/inline; filename=[\'"]?([^\'"\s]+)[\'"]?$/i', $httpHeaders['Content-Disposition'], $match)) { - $filename = Configuration::getDefaultConfiguration()->getTempFolderPath() . DIRECTORY_SEPARATOR . self::sanitizeFilename($match[1]); - } else { - $filename = tempnam(Configuration::getDefaultConfiguration()->getTempFolderPath(), ''); - } - - $file = fopen($filename, 'w'); - while ($chunk = $data->read(200)) { - fwrite($file, $chunk); - } - fclose($file); - - return new \SplFileObject($filename, 'r'); - } elseif (method_exists($class, 'getAllowableEnumValues')) { - if (!in_array($data, $class::getAllowableEnumValues(), true)) { - $imploded = implode("', '", $class::getAllowableEnumValues()); - throw new \InvalidArgumentException("Invalid value for enum '$class', must be one of: '$imploded'"); - } - return $data; - } else { - $data = is_string($data) ? json_decode($data) : $data; - // If a discriminator is defined and points to a valid subclass, use it. - $discriminator = $class::DISCRIMINATOR; - if (!empty($discriminator) && isset($data->{$discriminator}) && is_string($data->{$discriminator})) { - $subclass = '\Infobip\Model\\' . self::DISCRIMINATOR_MAPPINGS[$data->{$discriminator}]; - if (is_subclass_of($subclass, $class)) { - $class = $subclass; - } - } - - /** @var ModelInterface $instance */ - $instance = new $class(); - foreach ($instance::openAPITypes() as $property => $type) { - $propertySetter = $instance::setters()[$property]; - - if (!isset($propertySetter) || !isset($data->{$instance::attributeMap()[$property]})) { - continue; - } - - if (isset($data->{$instance::attributeMap()[$property]})) { - $propertyValue = $data->{$instance::attributeMap()[$property]}; - $instance->$propertySetter(self::deserialize($propertyValue, $type, null)); - } - } - return $instance; + throw new InvalidArgumentException(implode(',', $messages)); } } } diff --git a/Infobip/SplFileObjectNormalizer.php b/Infobip/SplFileObjectNormalizer.php new file mode 100644 index 0000000..9c3d191 --- /dev/null +++ b/Infobip/SplFileObjectNormalizer.php @@ -0,0 +1,141 @@ + null, + ]; + + private const SUPPORTED_TYPES = [ + SplFileObject::class => true, + '\SplFileObject' => true, + ]; + + public function __construct(array $defaultContext = []) + { + $this->setDefaultContext($defaultContext); + } + + public function setDefaultContext(array $defaultContext): void + { + $this->defaultContext = array_merge($this->defaultContext, $defaultContext); + } + + /** + * @inheritdoc + * @throws InvalidArgumentException + */ + public function normalize(mixed $object, string $format = null, array $context = []): string + { + if (!$object instanceof SplFileObject) { + throw new InvalidArgumentException('The object must be an instance of SplFileObject'); + } + + return $object->getRealPath(); + } + + /** + * @inheritdoc + */ + public function supportsNormalization(mixed $data, string $format = null): bool + { + return $data instanceof SplFileObject; + } + + /** + * @inheritdoc + * @param StreamInterface $data + * @throws NotNormalizableValueException + */ + public function denormalize(mixed $data, string $type, string $format = null, array $context = []): SplFileObject + { + if (!$data instanceof StreamInterface) { + throw NotNormalizableValueException::createForUnexpectedDataType( + 'The data is not of StreamInterface type', + $data, + [Type::BUILTIN_TYPE_STRING], + $context['deserialization_path'] ?? null, + true + ); + } + + $configuration = $this->defaultContext[self::CONFIGURATION_KEY] ?? new Configuration('', ''); + + $headers = $context[self::HEADERS_KEY] ?? []; + $contentDisposition = $headers['Content-Disposition'] ?? null; + + $fileName = ( + $contentDisposition !== null && + preg_match('/inline; filename=[\'"]?([^\'"\s]+)[\'"]?$/i', $contentDisposition, $match) + ) + ? $configuration->getTempFolderPath() + . DIRECTORY_SEPARATOR + . $this->sanitizeFilename($match[1]) + : \tempnam($configuration->getTempFolderPath(), ''); + + $file = \fopen($fileName, 'w'); + + while ($chunk = $data->read(200)) { + \fwrite($file, $chunk); + } + + \fclose($file); + + return new SplFileObject($fileName, 'r'); + } + + /** + * @inheritdoc + */ + public function supportsDenormalization(mixed $data, string $type, string $format = null): bool + { + return \in_array($type, self::SUPPORTED_TYPES) && $data instanceof StreamInterface; + } + + private function sanitizeFilename(string $filename): string + { + if (preg_match("/.*[\/\\\\](.*)$/", $filename, $match)) { + return $match[1]; + } + + return $filename; + } +} diff --git a/README.md b/README.md index 1545872..4570259 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,13 @@ # Infobip API PHP Client -[![Packegist](https://badgen.net/packagist/v/infobip/infobip-api-php-client)](https://packagist.org/packages/infobip/infobip-api-php-client) +[![Packagist](https://badgen.net/packagist/v/infobip/infobip-api-php-client)](https://packagist.org/packages/infobip/infobip-api-php-client) +[![Snyk](https://snyk.io/test/github/infobip/infobip-api-php-client/badge.svg)](https://snyk.io/test/github/infobip/infobip-api-php-client) [![MIT License](https://badgen.net/github/license/infobip/infobip-api-php-client)](https://opensource.org/licenses/MIT) This is a PHP Client for Infobip API and you can use it as a dependency to add [Infobip APIs][apidocs] to your application. To use this, you'll need an Infobip account. If not already having one, you can create a [free trial][freetrial] account [here][signup]. -Built on top of [OpenAPI Specification](https://swagger.io/specification/), powered by [OpenAPI Generator](https://openapi-generator.tech/). +`infobip-api-php-client` is built on top of [OpenAPI Specification](https://spec.openapis.org/oas/latest.html), generated by [Infobip OSCAR](https://www.youtube.com/watch?v=XC8oVn_efTw) service powered by [OpenAPI Generator](https://openapi-generator.tech/). Infobip @@ -19,15 +20,22 @@ Built on top of [OpenAPI Specification](https://swagger.io/specification/), powe ## Documentation -Infobip API Documentation can be found [here][apidocs]. +Detailed documentation about Infobip API can be found [here][apidocs]. +The current version of this library includes this subset of Infobip products: +* [SMS](https://www.infobip.com/docs/api/channels/sms) +* [MMS](https://www.infobip.com/docs/api/channels/mms) +* [Voice](https://www.infobip.com/docs/api/channels/voice) +* [WebRTC](https://www.infobip.com/docs/api/channels/webrtc) +* [Email](https://www.infobip.com/docs/api/channels/email) +* [WhatsApp](https://www.infobip.com/docs/api/channels/whatsapp) +* [Viber](https://www.infobip.com/docs/api/channels/viber) ## General Info For `infobip-api-php-client` versioning we use [Semantic Versioning][semver] scheme. Published under [MIT License][license]. -## PHP versions -8.0 and above +The library requires PHP version >= 8.0. ## Installation @@ -35,7 +43,7 @@ Published under [MIT License][license]. To start using the library add it as dependecy in your `composer.json` file like shown below. ```json "require": { - "infobip/infobip-api-php-client": "4.0.0" + "infobip/infobip-api-php-client": "5.0.0" } ``` And simply run `composer install` to download dependencies. @@ -47,39 +55,44 @@ One of them is `php-download` online tool. You can use it to find pre-composed [ ## Quickstart #### Initialize the Configuration & HTTP client +The library supports the [API Key Header](https://www.infobip.com/docs/essentials/api-authentication#api-key-header) authentication method. +Once you have an [Infobip account](https://www.infobip.com/signup), you can manage your API keys through the Infobip [API key management](https://portal.infobip.com/settings/accounts/api-keys) page. -We support multiple authentication methods, e.g. you can use [API Key Header](https://www.infobip.com/docs/essentials/api-authentication#api-key-header), in this case, `API_KEY_PREFIX` will be "App". - -The `API_KEY` can be created via the [web interface](https://portal.infobip.com/settings/accounts/api-keys). - -To see your `URL_BASE_PATH`, log in to the [Infobip API documentation][apidocs] hub with your Infobip credentials. +To see your base URL, log in to the [Infobip API Resource][apidocs] hub with your Infobip credentials or visit your [Infobip account](https://portal.infobip.com/homepage/). ```php - $configuration = (new Configuration()) - ->setHost(URL_BASE_PATH) - ->setApiKeyPrefix('Authorization', API_KEY_PREFIX) - ->setApiKey('Authorization', API_KEY); + use Infobip\Configuration; - $client = new GuzzleHttp\Client(); + $configuration = new Configuration( + host: 'your-base-url', + apiKey: 'your-api-key' + ); ``` #### Send an SMS -Simple example for sending an SMS message. +See below, a simple example of sending a single SMS message to a single recipient. ```php - $sendSmsApi = new SendSMSApi($client, $configuration); - $destination = (new SmsDestination())->setTo('41793026727'); - $message = (new SmsTextualMessage()) - ->setFrom('InfoSMS') - ->setText('This is a dummy SMS message sent using infobip-api-php-client') - ->setDestinations([$destination]); - $request = (new SmsAdvancedTextualRequest()) - ->setMessages([$message]); -``` -```php + use Infobip\ApiException; + use Infobip\Model\SmsAdvancedTextualRequest; + use Infobip\Model\SmsDestination; + use Infobip\Model\SmsTextualMessage; + + $sendSmsApi = new SmsApi(config: $configuration); + + $message = new SmsTextualMessage( + destinations: [ + new SmsDestination(to: '41793026727') + ], + from: 'InfoSMS', + text: 'This is a dummy SMS message sent using infobip-api-php-client' + ); + + $request = new SmsAdvancedTextualRequest(messages: [$message]); + try { $smsResponse = $sendSmsApi->sendSmsMessage($request); - } catch (Throwable $apiException) { + } catch (ApiException $apiException) { // HANDLE THE EXCEPTION } ``` @@ -94,42 +107,54 @@ Also, you can get the deserialized response body using `getResponseObject` metho $apiException->getResponseObject(); ``` -Additionally, you can pull out the `bulkId` and `messageId`(s) from `SmsResponse` object and use them to fetch a delivery report for given message or bulk. +Additionally, you can retrieve a `bulkId` and a `messageId` from the `SmsResponse` object to use for troubleshooting or fetching a delivery report for a given message or a bulk. Bulk ID will be received only when you send a message to more than one destination address or multiple messages in a single request. ```php $bulkId = $smsResponse->getBulkId(); - $messageId = $smsResponse->getMessages()[0]->getMessageId(); + $messages = $smsResponse->getMessages(); + $messageId = (!empty($messages)) ? current($messages)->getMessageId() : null; ``` #### Receive SMS message delivery report -For each SMS that you send out, we can send you a message delivery report in real time. All you need to do is specify your endpoint, e.g. `https://{yourDomain}/delivery-reports`, when sending SMS in `notifyUrl` field of `SmsTextualMessage`, or subscribe for reports by contacting our support team. +For each SMS that you send out, we can send you a message delivery report in real time. All you need to do is specify your endpoint when sending SMS in the `notifyUrl` field within `SmsTextualMessage`, or subscribe for reports by contacting our support team at support@infobip.com. -You can use data models from the library and the pre-configured `\Infobip\ObjectSerializer` serializer. +You can use data models from the library and the pre-configured `Infobip\ObjectSerializer` serializer. Example of webhook implementation: ```php - use \Infobip\ObjectSerializer; + use Infobip\Model\SmsReportResponse; + use Infobip\ObjectSerializer; + + $objectSerializer = new ObjectSerializer(); - $data = file_get_contents("php://input"); - $type = '\Infobip\Model\SmsDeliveryResult'; - $deliveryReports = ObjectSerializer::deserialize($data, $type); + $data = \file_get_contents('php://input'); - foreach ($deliveryReports->getResults() as $report) { + /** + * @var SmsReportResponse $deliveryResult + */ + $deliveryResult = $objectSerializer->deserialize($data, SmsReportResponse::class); + + foreach ($deliveryResult->getResults() ?? [] as $report) { echo $report->getMessageId() . " - " . $report->getStatus()->getName() . "\n"; } ``` If you prefer to use your own serializer, please pay attention to the supported [date format](https://www.infobip.com/docs/essentials/integration-best-practices#date-formats). #### Fetching delivery reports -If you are for any reason unable to receive real time delivery reports on your endpoint, you can use `messageId` or `bulkId` to fetch them. -Each request will return a batch of delivery reports - only once. +If you are for any reason unable to receive real-time delivery reports on your endpoint, you can use `messageId` or `bulkId` to fetch them. +Each request will return a batch of delivery reports - only once. See [documentation](https://www.infobip.com/docs/api/channels/sms/sms-messaging/logs-and-status-reports/get-outbound-sms-message-delivery-reports) for more details. ```php - $numberOfReportsLimit = 10; - $deliveryReports = $sendSmsApi->getOutboundSmsMessageDeliveryReports($bulkId, $messageId, $numberOfReportsLimit); - foreach ($deliveryReports->getResults() as $report) { + $deliveryReports = $sendSmsApi + ->getOutboundSmsMessageDeliveryReports( + bulkId: 'some-bulk-id', + messageId: 'some-message-id', + limit: 10 + ); + + foreach ($deliveryReports->getResults() ?? [] as $report) { echo $report->getMessageId() . " - " . $report->getStatus()->getName() . "\n"; } ``` @@ -138,24 +163,43 @@ Each request will return a batch of delivery reports - only once. Infobip API supports Unicode characters and automatically detects encoding. Unicode and non-standard GSM characters use additional space, avoid unpleasant surprises and check how different message configurations will affect your message text, number of characters and message parts. ```php - $previewResponse = $sendSmsApi->previewSmsMessage((new SmsPreviewRequest()) - ->setText("Let's see how many characters will remain unused in this message.")); - echo $previewResponse; + use Infobip\Model\SmsPreviewRequest; + + $previewResponse = $sendSmsApi + ->previewSmsMessage( + new SmsPreviewRequest( + text: 'Let\'s see how many characters will remain unused in this message.' + ) + ); + + foreach ($previewResponse->getPreviews() ?? [] as $preview) { + echo sprintf( + 'Characters remaining: %s, text preview: %s', + $preview->getCharactersRemaining(), + $preview->getTextPreview() + ) . PHP_EOL; + } ``` #### Receive incoming SMS -If you want to receive SMS messages from your subscribers we can have them delivered to you in real time. When you buy and configure a number capable of receiving SMS, specify your endpoint as explained [here](https://www.infobip.com/docs/api#channels/sms/receive-inbound-sms-messages), +If you want to receive SMS messages from your subscribers we can have them delivered to you in real time. When you buy and configure a number capable of receiving SMS, specify your endpoint, as explained in [documentation](https://www.infobip.com/docs/api#channels/sms/receive-inbound-sms-messages). e.g. `https://{yourDomain}/incoming-sms`. Example of webhook implementation: ```php - use \Infobip\ObjectSerializer; + use Infobip\ObjectSerializer; + use Infobip\Model\SmsInboundMessageResult; - $data = file_get_contents("php://input"); - $type = '\Infobip\Model\SmsInboundMessageResult'; - $messages = ObjectSerializer::deserialize($data, $type); + $objectSerializer = new ObjectSerializer(); - foreach ($messages->getResults() as $message) { + $data = \file_get_contents('php://input'); + + /** + * @var SmsInboundMessageResult $messages + */ + $messages = $objectSerializer->deserialize($data, SmsInboundMessageResult::class); + + foreach ($messages->getResults() ?? [] as $message) { echo $message-> getFrom() . " - " . $message-> getCleanText() . "\n"; } ``` @@ -173,10 +217,12 @@ For WhatsApp quick start guide, view [these examples](whatsapp.md). Feel free to open issues on the repository for any issue or feature request. As per pull requests, for details check the `CONTRIBUTING` [file][contributing] related to it - in short, we will not merge any pull requests, this code is auto-generated. -If it is, however, something that requires our imminent attention feel free to contact us @ [support@infobip.com](mailto:support@infobip.com). +This code is auto generated, and we are unable to merge any pull request from here, but we will review and implement changes directly within our pipeline, as described in the `CONTRIBUTING` [file][contributing]. + +For anything that requires our imminent attention, contact us @ [support@infobip.com](mailto:support@infobip.com). [apidocs]: https://www.infobip.com/docs/api -[freetrial]: https://www.infobip.com/docs/freetrial +[freetrial]: https://www.infobip.com/docs/essentials/free-trial [signup]: https://www.infobip.com/signup [semver]: https://semver.org [license]: LICENSE diff --git a/composer.json b/composer.json index 0cd81ce..2258c62 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "infobip/infobip-api-php-client", "description": "PHP library for consuming Infobip's API", - "version": "4.0.0", + "version": "5.0.0", "keywords": [ "infobip", "sms", @@ -28,9 +28,21 @@ "ext-curl": "*", "ext-json": "*", "ext-mbstring": "*", - "guzzlehttp/guzzle": "^7.3" + "guzzlehttp/guzzle": "~7.0", + "symfony/validator": "^5.0|^6.0", + "symfony/serializer": "^5.0|^6.0", + "symfony/property-access": "^5.0|^6.0", + "symfony/cache": "^5.0|^6.0", + "doctrine/annotations": "~1.0", + "phpdocumentor/reflection-docblock": "^5.0|^6.0" + }, + "require-dev": { + "phpunit/phpunit": "~9.0" }, "autoload": { "psr-4": { "Infobip\\" : "Infobip/" } + }, + "autoload-dev": { + "psr-4": { "Infobip\\Test\\" : "Infobip/test/" } } } diff --git a/test/DeprecationCheckerTest.php b/test/DeprecationCheckerTest.php new file mode 100644 index 0000000..c6f216b --- /dev/null +++ b/test/DeprecationCheckerTest.php @@ -0,0 +1,137 @@ +logger = $this->createMock(LoggerInterface::class); + $this->subject = new DeprecationChecker($this->logger); + } + + public function testShouldLogSunsetMessage(): void + { + // given + $givenMethod = 'GET'; + $givenPath = '/some-path'; + $givenRequest = new Request($givenMethod, $givenPath); + + $givenSunsetHeader = 'Mon, 02 Jan 2023 23:59:59 GMT'; + $givenDeprecationHeader = 'Mon, 1 Jan 2035 00:00:00 GMT'; + + $givenResponse = new Response( + 200, + [ + 'Sunset' => $givenSunsetHeader, + 'Deprecation' => $givenDeprecationHeader, + ] + ); + + $expectedLogDate = '2023-01-02'; + + $this + ->logger + ->expects($this->once()) + ->method('warning') + ->with( + sprintf( + "As of %s UTC, the endpoint %s %s has been discontinued. " + . "To avoid disruption, kindly update the library or reach out to %s.", + $expectedLogDate, + $givenMethod, + $givenPath, + self::SUPPORT_EMAIL + ) + ); + + // when, then + $this->subject->check($givenRequest, $givenResponse); + } + + public function testShouldLogDeprecationMessageWithSunsetHeader(): void + { + // given + $givenMethod = 'GET'; + $givenPath = '/some-path'; + $givenRequest = new Request($givenMethod, $givenPath); + + $givenSunsetHeader = 'Mon, 1 Jan 2035 00:00:00 GMT'; + $givenDeprecationHeader = 'Tue, 2 Jan 2035 00:00:00 GMT'; + + $givenResponse = new Response( + 200, + [ + 'Sunset' => $givenSunsetHeader, + 'Deprecation' => $givenDeprecationHeader, + ] + ); + + $expectedLogDate = '2035-01-01'; + + $this + ->logger + ->expects($this->once()) + ->method('warning') + ->with( + sprintf( + "As of %s UTC, the endpoint %s %s will no longer be available. " + . "To avoid disruption, kindly update the library or reach out to %s.", + $expectedLogDate, + $givenMethod, + $givenPath, + self::SUPPORT_EMAIL + ) + ); + + // when, then + $this->subject->check($givenRequest, $givenResponse); + } + + public function testShouldLogDeprecationMessage(): void + { + // given + $givenMethod = 'GET'; + $givenPath = '/some-path'; + $givenRequest = new Request($givenMethod, $givenPath); + + $givenDeprecationHeader = 'Mon, 02 Jan 2023 23:59:59 GMT'; + + $givenResponse = new Response( + 200, + [ + 'Deprecation' => $givenDeprecationHeader, + ] + ); + + $this + ->logger + ->expects($this->once()) + ->method('warning') + ->with( + sprintf( + "The endpoint %s %s is deprecated. " + . "Please consider updating the library or reaching out to %s for assistance.", + $givenMethod, + $givenPath, + self::SUPPORT_EMAIL + ) + ); + + // when, then + $this->subject->check($givenRequest, $givenResponse); + } +} diff --git a/test/ObjectSerializerTest.php b/test/ObjectSerializerTest.php new file mode 100644 index 0000000..f2e09ce --- /dev/null +++ b/test/ObjectSerializerTest.php @@ -0,0 +1,188 @@ +subject = new ObjectSerializer(); + } + + public function testSimpleSerialization() + { + // given + $givenNestedModel = new SimpleModel(propertyA: 'nested-property-a', propertyB: 'nested-property-b'); + $givenModel = new SimpleModel(propertyA: 'property-a', propertyB: 'property-b', nestedModel: $givenNestedModel); + + $expectedResult = <<subject->serialize($givenModel); + + // then + $this->assertJsonStringEqualsJsonString($expectedResult, $actualResult); + } + + public function testSimpleDeserialization() + { + // given + $givenInput = <<subject->deserialize($givenInput, SimpleModel::class); + + // then + $this->assertJsonStringEqualsJsonString($givenInput, $this->subject->serialize($result)); + } + + public function testValidation() + { + // given + $givenNestedModel = new SimpleModelWithValidations( + propertyA: 'correct-a', + propertyB: 'correct-b' + ); + + $givenModel = new SimpleModelWithValidations( + propertyA: 'correct-a', + propertyB: 'correct-b', + nestedModel: $givenNestedModel + ); + + $expectedResult = <<subject->serialize($givenModel); + + // then + $this->assertJsonStringEqualsJsonString($expectedResult, $actualResult); + } + + /** + * @dataProvider dateFormatsSource + * @param string $givenDateString + */ + public function testSupportedSpecifiedDateTimeFormat(string $givenDateString) + { + // given + $objectSerializer = $this->subject; + + $dateTimeJson = <<denormalize($deserializedDateTimeJson->date, '\DateTime'); + + // then + self::assertEquals(self::EXPECTED_DATE, date_format($dateTime, self::EXPECTED_DATE_FORMAT)); + self::assertEquals(self::EXPECTED_TIMESTAMP, $dateTime->getTimestamp()); + } + + public static function dateFormatsSource(): array + { + return [ + ['2035-08-18T12:08:42.777+00:00'], + ['2035-08-18T13:08:42.777+01:00'], + ['2035-08-18T11:08:42.777-01:00'], + ['2035-08-18T17:08:42.777+05:00'], + ['2035-08-18T07:08:42.777-05:00'], + ['2035-08-18T13:38:42.777+01:30'], + ['2035-08-18T10:38:42.777-01:30'], + ['2035-08-18T17:38:42.777+05:30'], + ['2035-08-18T06:38:42.777-05:30'], + ['2035-08-18T06:38:42.777-0530'], + ]; + } + + /** + * @dataProvider jsonDateSerializationSource + */ + public function testDateFormatInJsonDateSerialization(DateTime $givenDate, string $expectedDateString) + { + // given + $objectSerializer = $this->subject; + + // when + $serializedDateTime = $objectSerializer->serialize([ + 'date' => $givenDate, + ]); + + $unserializedDateTime = \json_decode($serializedDateTime); + + // then + self::assertEquals($expectedDateString, $unserializedDateTime->date); + } + + public static function jsonDateSerializationSource(): array + { + return [ + [new DateTime("2020-04-26T17:24:10.000+00:00"), "2020-04-26T17:24:10.000+00:00"], + [new DateTime("2020-04-26T17:24:10.000+01:00"), "2020-04-26T17:24:10.000+01:00"], + ]; + } + + public function testSupportedDateTimeFormats() + { + // given + $objectSerializer = new ObjectSerializer(); + $givenDate1 = new DateTime("2020-04-26T17:24:10.000+0530"); + $givenDate2 = new DateTime("2020-04-26T17:24:10.000+05:30"); + + // when + $serializedDateTime1 = $objectSerializer->serialize(['date' => $givenDate1]); + $serializedDateTime2 = $objectSerializer->serialize(['date' => $givenDate2]); + + $unserializedDateTime1 = \json_decode($serializedDateTime1)->date; + $unserializedDateTime2 = \json_decode($serializedDateTime2)->date; + + // then + self::assertEquals($unserializedDateTime1, $unserializedDateTime2); + self::assertEquals($givenDate1, $givenDate2); + self::assertEquals($givenDate1->getTimestamp(), $givenDate2->getTimestamp()); + } +} diff --git a/test/SimpleModel.php b/test/SimpleModel.php new file mode 100644 index 0000000..511e924 --- /dev/null +++ b/test/SimpleModel.php @@ -0,0 +1,45 @@ +propertyA; + } + + public function getPropertyB(): string + { + return $this->propertyB; + } + + public function getNestedModel(): ?SimpleModel + { + return $this->nestedModel; + } +} diff --git a/test/SimpleModelWithValidations.php b/test/SimpleModelWithValidations.php new file mode 100644 index 0000000..8bfd877 --- /dev/null +++ b/test/SimpleModelWithValidations.php @@ -0,0 +1,48 @@ +propertyA; + } + + public function getPropertyB(): string + { + return $this->propertyB; + } + + public function getNestedModel(): ?SimpleModelWithValidations + { + return $this->nestedModel; + } +} diff --git a/two-factor-authentication.md b/two-factor-authentication.md index 31ceedd..66751ad 100644 --- a/two-factor-authentication.md +++ b/two-factor-authentication.md @@ -1,13 +1,15 @@ ## Two-Factor Authentication (2FA) Initialize 2FA API client: ```php - $configuration = (new Configuration()) - ->setHost(URL_BASE_PATH) - ->setApiKeyPrefix('Authorization', API_KEY_PREFIX) - ->setApiKey('Authorization', API_KEY); - $client = new GuzzleHttp\Client(); + use Infobip\Api\TfaApi; + use Infobip\Configuration; + + $configuration = new Configuration( + host: 'your-base-url', + apiKey: 'your-api-key' + ); - $tfaApi = new TfaApi($client, $configuration); + $tfaApi = new TfaApi(config: $configuration); ``` Before sending one-time PIN codes you need to set up application and message template. @@ -15,7 +17,8 @@ Before sending one-time PIN codes you need to set up application and message tem The application represents your service. It’s good practice to have separate applications for separate services. ```php $tfaApplication = $tfaApi->createTfaApplication( - (new TfaApplicationRequest())->setName("2FA application")); + new TfaApplicationRequest(name: '2FA application') + ); $appId = $tfaApplication->getApplicationId(); ``` @@ -23,11 +26,15 @@ The application represents your service. It’s good practice to have separate a #### Message template setup Message template is the message body with the PIN placeholder that is sent to end users. ```php - $tfaMessageTemplate = $tfaApi->createTfaMessageTemplate($appId, - (new TfaCreateMessageRequest()) - ->setMessageText("Your pin is {{pin}}") - ->setPinType(TfaPinType::NUMERIC) - ->setPinLength(4)); + $tfaMessageTemplate = $tfaApi + ->createTfaMessageTemplate( + $appId, + new TfaCreateMessageRequest( + messageText: 'Your pin is {{pin}}', + pinType: TfaPinType::NUMERIC, + pinLength: 4 + ) + ); $messageId = $tfaMessageTemplate->getMessageId(); ``` @@ -35,12 +42,15 @@ Message template is the message body with the PIN placeholder that is sent to en #### Send 2FA code via SMS After setting up the application and message template, you can start generating and sending PIN codes via SMS to the provided destination address. ```php - $sendCodeResponse = $tfaApi->sendTfaPinCodeOverSms(true, - (new TfaStartAuthenticationRequest()) - ->setApplicationId($appId) - ->setMessageId($messageId) - ->setFrom("InfoSMS") - ->setTo("41793026727")); + $sendCodeResponse = $tfaApi + ->sendTfaPinCodeOverSms( + new TfaStartAuthenticationRequest( + applicationId: $appId, + messageId: $messageId, + from: 'InfoSMS', + to: '41793026727' + ) + ); $isSuccessful = $sendCodeResponse->getSmsStatus() == "MESSAGE_SENT"; $pinId = $sendCodeResponse->getPinId(); @@ -49,6 +59,6 @@ After setting up the application and message template, you can start generating #### Verify phone number Verify a phone number to confirm successful 2FA authentication. ```php - $verifyResponse = $tfaApi->verifyTfaPhoneNumber($pinId, (new TfaVerifyPinRequest())->setPin("1598")); + $verifyResponse = $tfaApi->verifyTfaPhoneNumber($pinId, new TfaVerifyPinRequest(pin: '1598')); $verified = $verifyResponse->getVerified(); ``` diff --git a/whatsapp.md b/whatsapp.md index 518ebc9..c13b5e1 100644 --- a/whatsapp.md +++ b/whatsapp.md @@ -5,21 +5,18 @@ This quick guide aims to help you get started with Infobip WhatsApp API. After r The first step is to create a `Configuration` instance with your API credentials. ```php - use GuzzleHttp\Client; - use Infobip\Api\SendWhatsAppApi; + use Infobip\Api\WhatsAppApi; use Infobip\Configuration; - $client = new Client(); - - $configuration = (new Configuration()) - ->setHost('Your API host which can be found in Infobip Portal') - ->setApiKeyPrefix('Authorization', 'App') - ->setApiKey('Authorization', 'Your API key which can be found in Infobip Portal'); + $configuration = new Configuration( + host: 'your-base-url', + apiKey: 'your-api-key' + ); ``` -Now, you can create an instance of `SendWhatsAppApi` that allows you to send WhatsApp messages. +Now, you can create an instance of `WhatsAppApi` that allows you to send WhatsApp messages. ```php - $whatsAppApi = new SendWhatsAppApi($client, $configuration); + $whatsAppApi = new WhatsAppApi(config: $configuration); ``` ### Activate your test sender @@ -44,25 +41,22 @@ Infobip test sender has a lot of predefined templates that you can fetch by usin The example below shows how to use a template named `welcome_multiple_languages` with only one placeholder. First, create an instance of `WhatsAppMessage` and provide the required data like recipient number as `to` parameter. We'll use `en` as the language parameter, but you can change it to a few others that are predefined in the template. ```php - $message = (new WhatsAppMessage()) - ->setFrom('447860099299') - ->setTo('') - ->setContent( - (new WhatsAppTemplateContent()) - ->setLanguage('en') - ->setTemplateName('welcome_multiple_languages') - ->setTemplateData( - (new WhatsAppTemplateDataContent()) - ->setBody( - (new WhatsAppTemplateBodyContent()) - ->setPlaceholders(['']) - ) - ) - ); + $message = new WhatsAppMessage( + from: '447860099299', + to: '', + content: new WhatsAppTemplateContent( + templateName: 'welcome_multiple_languages', + templateData: new WhatsAppTemplateDataContent( + body: new WhatsAppTemplateBodyContent( + placeholders: [''] + ) + ), + language: 'en' + )); ``` Next step is to create a `WhatsAppBulkMessage` instance that serves as a container for multiple messages, like the one we created above. ```php - $bulkMessage = (new WhatsAppBulkMessage())->setMessages([$message]); + $bulkMessage = new WhatsAppBulkMessage(messages: [$message]); ``` Use the instance of `SendWhatsAppApi` which we created at the beginning to send a message. @@ -83,52 +77,43 @@ For sending another message we'll choose a more complex template example called This time, we'll start by creating an instance of `WhatsAppTemplateContent`. ```php - $templateContent = (new WhatsAppTemplateContent()) - ->setLanguage('en') - ->setTemplateName('registration_success') - ->setTemplateData( - (new WhatsAppTemplateDataContent()) - ->setHeader( - (new WhatsAppTemplateImageHeaderContent()) - ->setMediaUrl('https://api.infobip.com/ott/1/media/infobipLogo') - ) - ->setBody( - (new WhatsAppTemplateBodyContent()) - ->setPlaceholders( - [ - '', - 'WhatsApp message', - 'delivered', - 'exploring Infobip API', - ] - ) - ) - ->setButtons( - [ - (new WhatsAppTemplateQuickReplyButtonContent()) - ->setParameter('Yes'), - (new WhatsAppTemplateQuickReplyButtonContent()) - ->setParameter('No'), - (new WhatsAppTemplateQuickReplyButtonContent()) - ->setParameter('Later'), - ] - ) - ); + $templateContent = new WhatsAppTemplateContent( + templateName: 'registration_success', + templateData: new WhatsAppTemplateDataContent( + body: new WhatsAppTemplateBodyContent( + placeholders: [ + '', + 'WhatsApp message', + 'delivered', + 'exploring Infobip API', + ] + ), + header: new WhatsAppTemplateImageHeaderContent( + mediaUrl: 'https://api.infobip.com/ott/1/media/infobipLogo' + ), + buttons: [ + new WhatsAppTemplateQuickReplyButtonContent(parameter: 'Yes'), + new WhatsAppTemplateQuickReplyButtonContent(parameter: 'No'), + new WhatsAppTemplateQuickReplyButtonContent(parameter: 'Later') + ] + ), + language: 'en' + ); ``` Once the object is created, we can create an instance of `WhatsAppBulkMessage` and use the object as its `content` field. The rest is the same as in the previous example. We are again using the `$whatsAppApi` instance to send the message. ```php - $bulkMessage = (new WhatsAppBulkMessage()) - ->setMessages( - [ - (new WhatsAppMessage()) - ->setFrom('447860099299') - ->setTo('') - ->setContent($templateContent) - ] - ); - - $whatsAppApi = new SendWhatsAppApi($client, $configuration); + $bulkMessage = new WhatsAppBulkMessage( + messages: [ + new WhatsAppMessage( + from: '447860099299', + to: '', + content: $templateContent + ) + ] + ); + + $whatsAppApi = new WhatsAppApi(config: $configuration); $messageInfo = $whatsAppApi->sendWhatsAppTemplateMessage($bulkMessage); @@ -143,15 +128,15 @@ You may respond to user messages with any type of message within 24 hours of rec And so, to send a freestyle message, you have to initiate a WhatsApp conversation from your registered number. ```php - $textMessage = (new WhatsAppTextMessage()) - ->setFrom('447860099299') - ->setTo('') - ->setContent( - (new WhatsAppTextContent()) - ->setText('This is my first WhatsApp message sent using Infobip API client library') - ); - - $whatsAppApi = new SendWhatsAppApi($client, $configuration); + $textMessage = new WhatsAppTextMessage( + from: '447860099299', + to: '', + content: new WhatsAppTextContent( + text: 'This is my first WhatsApp message sent using Infobip API client library' + ) + ); + + $whatsAppApi = new WhatsAppApi(config: $configuration); $messageInfo = $whatsAppApi->sendWhatsAppTextMessage($textMessage); @@ -172,43 +157,48 @@ You can find more details about the structure of the message you can expect on y ```php namespace App\Controller\Webhook; +use Infobip\Model\WhatsAppWebhookInboundContactMessage; +use Infobip\Model\WhatsAppWebhookInboundDocumentMessage; +use Infobip\Model\WhatsAppWebhookInboundImageMessage; +use Infobip\Model\WhatsAppWebhookInboundLocationMessage; +use Infobip\Model\WhatsAppWebhookInboundMessageResult; +use Infobip\Model\WhatsAppWebhookInboundTextMessage; use Infobip\ObjectSerializer; -use Infobip\Model\WhatsAppInboundMessageResult; -use Infobip\Model\WhatsAppInboundTextMessage; -use Infobip\Model\WhatsAppInboundImageMessage; -use Infobip\Model\WhatsAppInboundDocumentMessage; -use Infobip\Model\WhatsAppInboundLocationMessage; -use Infobip\Model\WhatsAppInboundContactMessage; -use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpKernel\Attribute\AsController; use Symfony\Component\Routing\Annotation\Route; -class WhatsAppController extends AbstractController +#[AsController] +class WhatsAppController { + public function __construct(private ObjectSerializer $objectSerializer) + { + } + #[Route('/whatsapp', name: 'webhook_whatsapp', methods: ['POST'])] public function receiveAction(Request $request) { /** - * @var WhatsAppInboundMessageResult $messageData + * @var WhatsAppWebhookInboundMessageResult $messageData */ - $messageDataResult = ObjectSerializer::deserialize( + $messageDataResult = $this->objectSerializer->deserialize( $request->getContent(), - WhatsAppInboundMessageResult::class + WhatsAppWebhookInboundMessageResult::class ); foreach ($messageDataResult as $messageData) { foreach ($messageData->getResults() as $result) { $message = $result->getMessage(); - if ($message instanceof WhatsAppInboundTextMessage) { + if ($message instanceof WhatsAppWebhookInboundTextMessage) { $text = $message->getText(); - } elseif ($message instanceof WhatsAppInboundImageMessage) { + } elseif ($message instanceof WhatsAppWebhookInboundImageMessage) { $text = $message->getCaption(); - } elseif ($message instanceof WhatsAppInboundDocumentMessage) { + } elseif ($message instanceof WhatsAppWebhookInboundDocumentMessage) { $text = $message->getCaption(); - } elseif ($message instanceof WhatsAppInboundLocationMessage) { + } elseif ($message instanceof WhatsAppWebhookInboundLocationMessage) { $text = $message->getAddress(); - } elseif ($message instanceof WhatsAppInboundContactMessage) { + } elseif ($message instanceof WhatsAppWebhookInboundContactMessage) { $names = array_map( function ($contact) { $nameModel = $contact->getName();