Skip to content

Commit e37bb61

Browse files
author
infobip-ci
committed
Major version update
1 parent 076be72 commit e37bb61

File tree

225 files changed

+3944
-1597
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

225 files changed

+3944
-1597
lines changed

CHANGELOG.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,22 @@
22

33
All notable changes to the library will be documented in this file.
44

5-
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 [README.md][readme] file.
5+
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.
6+
7+
## [ [4.0.0](https://github.com/infobip/infobip-api-php-client/releases/tag/4.0.0) ] - 2022-10-21
8+
9+
⚠️ **IMPORTANT NOTE:** This release contains breaking changes!
10+
11+
### Changed
12+
- The minimum supported PHP version has been changed to 8.0
13+
- Get WhatsApp template / Create WhatsApp template have breaking changes as they're using the new v2 API endpoints. The body and footer are no longer strings but objects.
14+
- **getEmailLogs**' input parameters **sentSince** and **sentUntil** now correctly defined as `DateTime` type
15+
16+
### Added
17+
- Delete WhatsApp template
18+
19+
### Fixed
20+
- [PHP 8 deprecation issues](https://github.com/infobip/infobip-api-php-client/issues/47)
621

722
## [ [3.2.0](https://github.com/infobip/infobip-api-php-client/releases/tag/3.2.0) ] - 2022-03-29
823

Infobip/Api/ManageWhatsAppApi.php

Lines changed: 312 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ protected function createWhatsAppTemplateRequest($sender, $whatsAppTemplatePubli
214214
);
215215
}
216216

217-
$resourcePath = '/whatsapp/1/senders/{sender}/templates';
217+
$resourcePath = '/whatsapp/2/senders/{sender}/templates';
218218
$formParams = [];
219219
$queryParams = [];
220220
$headerParams = [];
@@ -703,6 +703,316 @@ protected function deleteWhatsAppMediaApiException($apiException)
703703
return $apiException;
704704
}
705705

706+
/**
707+
* Operation deleteWhatsAppTemplate
708+
*
709+
* Delete WhatsApp Template
710+
*
711+
* @param string $sender Registered WhatsApp sender number. Must be in international format. (required)
712+
* @param string $templateName Template name. Must only contain lowercase alphanumeric characters and underscores. (required)
713+
*
714+
* @throws \Infobip\ApiException on non-2xx response
715+
* @throws \InvalidArgumentException
716+
* @return void
717+
*/
718+
public function deleteWhatsAppTemplate($sender, $templateName)
719+
{
720+
$this->deleteWhatsAppTemplateWithHttpInfo($sender, $templateName);
721+
}
722+
723+
/**
724+
* Operation deleteWhatsAppTemplateWithHttpInfo
725+
*
726+
* Delete WhatsApp Template
727+
*
728+
* @param string $sender Registered WhatsApp sender number. Must be in international format. (required)
729+
* @param string $templateName Template name. Must only contain lowercase alphanumeric characters and underscores. (required)
730+
*
731+
* @throws \Infobip\ApiException on non-2xx response
732+
* @throws \InvalidArgumentException
733+
* @return array of null, HTTP status code, HTTP response headers (array of strings)
734+
*/
735+
public function deleteWhatsAppTemplateWithHttpInfo($sender, $templateName)
736+
{
737+
$request = $this->deleteWhatsAppTemplateRequest($sender, $templateName);
738+
739+
try {
740+
$options = $this->createHttpClientOption();
741+
try {
742+
$response = $this->client->send($request, $options);
743+
return $this->deleteWhatsAppTemplateResponse($response, $request->getUri());
744+
} catch (RequestException $e) {
745+
throw new ApiException(
746+
"[{$e->getCode()}] {$e->getMessage()}",
747+
$e->getCode(),
748+
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
749+
$e->getResponse() ? (string) $e->getResponse()->getBody() : null
750+
);
751+
}
752+
} catch (ApiException $e) {
753+
throw $this->deleteWhatsAppTemplateApiException($e);
754+
}
755+
}
756+
757+
/**
758+
* Operation deleteWhatsAppTemplateAsync
759+
*
760+
* Delete WhatsApp Template
761+
*
762+
* @param string $sender Registered WhatsApp sender number. Must be in international format. (required)
763+
* @param string $templateName Template name. Must only contain lowercase alphanumeric characters and underscores. (required)
764+
*
765+
* @throws \InvalidArgumentException
766+
* @return \GuzzleHttp\Promise\PromiseInterface
767+
*/
768+
public function deleteWhatsAppTemplateAsync($sender, $templateName)
769+
{
770+
return $this->deleteWhatsAppTemplateAsyncWithHttpInfo($sender, $templateName)
771+
->then(
772+
function ($response) {
773+
return $response[0];
774+
}
775+
);
776+
}
777+
778+
/**
779+
* Operation deleteWhatsAppTemplateAsyncWithHttpInfo
780+
*
781+
* Delete WhatsApp Template
782+
*
783+
* @param string $sender Registered WhatsApp sender number. Must be in international format. (required)
784+
* @param string $templateName Template name. Must only contain lowercase alphanumeric characters and underscores. (required)
785+
*
786+
* @throws \InvalidArgumentException
787+
* @return \GuzzleHttp\Promise\PromiseInterface
788+
*/
789+
public function deleteWhatsAppTemplateAsyncWithHttpInfo($sender, $templateName)
790+
{
791+
$request = $this->deleteWhatsAppTemplateRequest($sender, $templateName);
792+
793+
return $this->client
794+
->sendAsync($request, $this->createHttpClientOption())
795+
->then(
796+
function ($response) use ($request) {
797+
return $this->deleteWhatsAppTemplateResponse($response, $request->getUri());
798+
},
799+
function ($exception) {
800+
$statusCode = $exception->getCode();
801+
$response = $exception->getResponse();
802+
$e = new ApiException(
803+
"[{$statusCode}] {$exception->getMessage()}",
804+
$statusCode,
805+
$response ? $response->getHeaders() : null,
806+
$response ? (string) $response->getBody() : null
807+
);
808+
throw $this->deleteWhatsAppTemplateApiException($e);
809+
}
810+
);
811+
}
812+
813+
/**
814+
* Create request for operation 'deleteWhatsAppTemplate'
815+
*
816+
* @param string $sender Registered WhatsApp sender number. Must be in international format. (required)
817+
* @param string $templateName Template name. Must only contain lowercase alphanumeric characters and underscores. (required)
818+
*
819+
* @throws \InvalidArgumentException
820+
* @return \GuzzleHttp\Psr7\Request
821+
*/
822+
protected function deleteWhatsAppTemplateRequest($sender, $templateName)
823+
{
824+
// verify the required parameter 'sender' is set
825+
if ($sender === null || (is_array($sender) && count($sender) === 0)) {
826+
throw new \InvalidArgumentException(
827+
'Missing the required parameter $sender when calling deleteWhatsAppTemplate'
828+
);
829+
}
830+
// verify the required parameter 'templateName' is set
831+
if ($templateName === null || (is_array($templateName) && count($templateName) === 0)) {
832+
throw new \InvalidArgumentException(
833+
'Missing the required parameter $templateName when calling deleteWhatsAppTemplate'
834+
);
835+
}
836+
837+
$resourcePath = '/whatsapp/2/senders/{sender}/templates/{templateName}';
838+
$formParams = [];
839+
$queryParams = [];
840+
$headerParams = [];
841+
$httpBody = '';
842+
843+
844+
845+
// path params
846+
if ($sender !== null) {
847+
$resourcePath = str_replace(
848+
'{' . 'sender' . '}',
849+
ObjectSerializer::toPathValue($sender),
850+
$resourcePath
851+
);
852+
}
853+
// path params
854+
if ($templateName !== null) {
855+
$resourcePath = str_replace(
856+
'{' . 'templateName' . '}',
857+
ObjectSerializer::toPathValue($templateName),
858+
$resourcePath
859+
);
860+
}
861+
862+
863+
$headers = $this->headerSelector->selectHeaders(
864+
['application/json'],
865+
[]
866+
);
867+
868+
// for model (json/xml)
869+
if (count($formParams) > 0) {
870+
if ($headers['Content-Type'] === 'multipart/form-data') {
871+
$boundary = '----'.hash('sha256', uniqid('', true));
872+
$headers['Content-Type'] .= '; boundary=' . $boundary;
873+
$multipartContents = [];
874+
foreach ($formParams as $formParamName => $formParamValue) {
875+
$formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
876+
foreach ($formParamValueItems as $formParamValueItem) {
877+
$multipartContents[] = [
878+
'name' => $formParamName,
879+
'contents' => $formParamValueItem
880+
];
881+
}
882+
}
883+
// for HTTP post (form)
884+
$httpBody = new MultipartStream($multipartContents, $boundary);
885+
} elseif ($headers['Content-Type'] === 'application/json') {
886+
$httpBody = \GuzzleHttp\json_encode($formParams);
887+
} else {
888+
// for HTTP post (form)
889+
$httpBody = \GuzzleHttp\Psr7\Query::build($formParams);
890+
}
891+
}
892+
893+
// this endpoint requires API key authentication
894+
$apiKey = $this->config->getApiKeyWithPrefix('Authorization');
895+
if ($apiKey !== null) {
896+
$headers['Authorization'] = $apiKey;
897+
}
898+
// this endpoint requires HTTP basic authentication
899+
if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) {
900+
$headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword());
901+
}
902+
// this endpoint requires API key authentication
903+
$apiKey = $this->config->getApiKeyWithPrefix('Authorization');
904+
if ($apiKey !== null) {
905+
$headers['Authorization'] = $apiKey;
906+
}
907+
// this endpoint requires OAuth (access token)
908+
if (!empty($this->config->getAccessToken())) {
909+
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
910+
}
911+
912+
$defaultHeaders = [];
913+
if ($this->config->getUserAgent()) {
914+
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
915+
}
916+
917+
$headers = array_merge(
918+
$defaultHeaders,
919+
$headerParams,
920+
$headers
921+
);
922+
923+
$query = \GuzzleHttp\Psr7\Query::build($queryParams);
924+
return new Request(
925+
'DELETE',
926+
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
927+
$headers,
928+
$httpBody
929+
);
930+
}
931+
932+
/**
933+
* Create response for operation 'deleteWhatsAppTemplate'
934+
*
935+
* @param \GuzzleHttp\Psr7\Response $response
936+
* @param string $requestUri
937+
*
938+
* @throws \Infobip\ApiException on non-2xx response
939+
* @return array of , HTTP status code, HTTP response headers (array of strings)
940+
*/
941+
protected function deleteWhatsAppTemplateResponse($response, $requestUri)
942+
{
943+
$statusCode = $response->getStatusCode();
944+
$responseBody = $response->getBody();
945+
$responseHeaders = $response->getHeaders();
946+
947+
if ($statusCode < 200 || $statusCode > 299) {
948+
throw new ApiException(
949+
sprintf('[%d] Error connecting to the API (%s)', $statusCode, $requestUri),
950+
$statusCode,
951+
$responseHeaders,
952+
$responseBody
953+
);
954+
}
955+
956+
$responseObject = null;
957+
958+
959+
return [
960+
$responseObject,
961+
$statusCode,
962+
$responseHeaders
963+
];
964+
}
965+
966+
/**
967+
* Adapt given \Infobip\ApiException for operation 'deleteWhatsAppTemplate'
968+
*
969+
* @param \Infobip\ApiException $apiException
970+
*
971+
* @return \Infobip\ApiException
972+
*/
973+
protected function deleteWhatsAppTemplateApiException($apiException)
974+
{
975+
$statusCode = $apiException->getCode();
976+
977+
if ($statusCode === 400) {
978+
$data = ObjectSerializer::deserialize(
979+
$apiException->getResponseBody(),
980+
'\Infobip\Model\WhatsAppApiException',
981+
$apiException->getResponseHeaders()
982+
);
983+
$apiException->setResponseObject($data);
984+
return $apiException;
985+
}
986+
if ($statusCode === 401) {
987+
$data = ObjectSerializer::deserialize(
988+
$apiException->getResponseBody(),
989+
'\Infobip\Model\WhatsAppApiException',
990+
$apiException->getResponseHeaders()
991+
);
992+
$apiException->setResponseObject($data);
993+
return $apiException;
994+
}
995+
if ($statusCode === 403) {
996+
$data = ObjectSerializer::deserialize(
997+
$apiException->getResponseBody(),
998+
'\Infobip\Model\WhatsAppApiException',
999+
$apiException->getResponseHeaders()
1000+
);
1001+
$apiException->setResponseObject($data);
1002+
return $apiException;
1003+
}
1004+
if ($statusCode === 429) {
1005+
$data = ObjectSerializer::deserialize(
1006+
$apiException->getResponseBody(),
1007+
'\Infobip\Model\WhatsAppApiException',
1008+
$apiException->getResponseHeaders()
1009+
);
1010+
$apiException->setResponseObject($data);
1011+
return $apiException;
1012+
}
1013+
return $apiException;
1014+
}
1015+
7061016
/**
7071017
* Operation getWhatsAppTemplates
7081018
*
@@ -824,7 +1134,7 @@ protected function getWhatsAppTemplatesRequest($sender)
8241134
);
8251135
}
8261136

827-
$resourcePath = '/whatsapp/1/senders/{sender}/templates';
1137+
$resourcePath = '/whatsapp/2/senders/{sender}/templates';
8281138
$formParams = [];
8291139
$queryParams = [];
8301140
$headerParams = [];

0 commit comments

Comments
 (0)