From 55e91f5df61ac66c0f08b42842b6fc9fa971770d Mon Sep 17 00:00:00 2001 From: NirmitiJain Date: Mon, 21 Nov 2022 15:10:15 +0530 Subject: [PATCH 1/4] Delete Campaign - Brand Request - PHP SDK --- src/Plivo/Resources/Brand/BrandInterface.php | 23 +++++++++++++++++++ .../Resources/Campaign/CampaignInterface.php | 23 +++++++++++++++++++ tests/Mocks/brandDeleteResponse.json | 4 ++++ tests/Mocks/campaignDeleteResponse.json | 4 ++++ tests/Resources/BrandTest.php | 17 ++++++++++++++ tests/Resources/CampaignTest.php | 19 ++++++++++++++- 6 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 tests/Mocks/brandDeleteResponse.json create mode 100644 tests/Mocks/campaignDeleteResponse.json diff --git a/src/Plivo/Resources/Brand/BrandInterface.php b/src/Plivo/Resources/Brand/BrandInterface.php index 2c489d40..74dfe7dd 100644 --- a/src/Plivo/Resources/Brand/BrandInterface.php +++ b/src/Plivo/Resources/Brand/BrandInterface.php @@ -127,4 +127,27 @@ public function get_brand_usecases($brandId) $this->pathParams['authId'], $this->uri); } + /** + * @param $uuid + * @return Brand + * @throws PlivoValidationException + */ + public function delete($brandId) + { + if (ArrayOperations::checkNull([$brandId])) { + throw + new PlivoValidationException( + 'brand id is mandatory'); + } + + $response = $this->client->delete( + $this->uri . '10dlc/Brand/'. $brandId .'/', + [] + ); + $responseContents = $response->getContent(); + return new Brand( + $this->client, $responseContents, + $this->pathParams['authId'], $this->uri); + } + } \ No newline at end of file diff --git a/src/Plivo/Resources/Campaign/CampaignInterface.php b/src/Plivo/Resources/Campaign/CampaignInterface.php index 75caef15..2fb920b3 100644 --- a/src/Plivo/Resources/Campaign/CampaignInterface.php +++ b/src/Plivo/Resources/Campaign/CampaignInterface.php @@ -168,4 +168,27 @@ public function deleteNumber($campaignId, $number, $optionalArgs = []) ); return $response->getContent(); } + + /** + * @param $uuid + * @return Campaign + * @throws PlivoValidationException + */ + public function delete($campaignId) + { + if (ArrayOperations::checkNull([$campaignId])) { + throw + new PlivoValidationException( + 'campaign id is mandatory'); + } + + $response = $this->client->delete( + $this->uri . '10dlc/Campaign/'. $campaignId .'/', + [] + ); + $responseContents = $response->getContent(); + return new Campaign( + $this->client, $responseContents, + $this->pathParams['authId'], $this->uri); + } } \ No newline at end of file diff --git a/tests/Mocks/brandDeleteResponse.json b/tests/Mocks/brandDeleteResponse.json new file mode 100644 index 00000000..f4987bc3 --- /dev/null +++ b/tests/Mocks/brandDeleteResponse.json @@ -0,0 +1,4 @@ +{ + "message": "Brand Deactivated", + "brand_id": "BRPXS6E" +} \ No newline at end of file diff --git a/tests/Mocks/campaignDeleteResponse.json b/tests/Mocks/campaignDeleteResponse.json new file mode 100644 index 00000000..dfb2caee --- /dev/null +++ b/tests/Mocks/campaignDeleteResponse.json @@ -0,0 +1,4 @@ +{ + "message": "Campaign Deactivated", + "campaign_id": "CMPT4EP" +} \ No newline at end of file diff --git a/tests/Resources/BrandTest.php b/tests/Resources/BrandTest.php index 4af1ef1a..2a54cfd8 100644 --- a/tests/Resources/BrandTest.php +++ b/tests/Resources/BrandTest.php @@ -88,4 +88,21 @@ public function testGetBrandUsecase() } + public function testDeleteBrandUsecase() + { + $brandID = "BRPXS6E"; + $request = new PlivoRequest( + 'DELETE', + 'Account/MAXXXXXXXXXXXXXXXXXX/10dlc/Brand/'.$brandID.'/', + []); + $body = file_get_contents(__DIR__ . '/../Mocks/brandDeleteResponse.json'); + + $this->mock(new PlivoResponse($request,200, $body)); + + $actual = $this->client->brand->delete($brandID); + self::assertNotNull($actual); + $this->assertRequest($request); + + } + } \ No newline at end of file diff --git a/tests/Resources/CampaignTest.php b/tests/Resources/CampaignTest.php index 84a95534..9ec6dad6 100644 --- a/tests/Resources/CampaignTest.php +++ b/tests/Resources/CampaignTest.php @@ -131,5 +131,22 @@ function testCampaignListNumber() } + public function testDeleteCampaign() + { + $campaignID = "CMPT4EP"; + $request = new PlivoRequest( + 'GET', + 'Account/MAXXXXXXXXXXXXXXXXXX/10dlc/Campaign/'.$campaignID.'/', + []); + $body = file_get_contents(__DIR__ . '/../Mocks/campaignDeleteResponse.json'); + + $this->mock(new PlivoResponse($request,200, $body)); + + $actual = $this->client->campaign->delete($campaignID); + self::assertNotNull($actual); + $this->assertRequest($request); + + } + -} \ No newline at end of file +} From 9a7bfdd1bb079604aec780957471100b86bb8691 Mon Sep 17 00:00:00 2001 From: NirmitiJain Date: Mon, 21 Nov 2022 15:18:32 +0530 Subject: [PATCH 2/4] delete response --- src/Plivo/Resources/Brand/BrandInterface.php | 6 ++---- src/Plivo/Resources/Campaign/CampaignInterface.php | 5 +---- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/Plivo/Resources/Brand/BrandInterface.php b/src/Plivo/Resources/Brand/BrandInterface.php index 74dfe7dd..5acedd18 100644 --- a/src/Plivo/Resources/Brand/BrandInterface.php +++ b/src/Plivo/Resources/Brand/BrandInterface.php @@ -144,10 +144,8 @@ public function delete($brandId) $this->uri . '10dlc/Brand/'. $brandId .'/', [] ); - $responseContents = $response->getContent(); - return new Brand( - $this->client, $responseContents, - $this->pathParams['authId'], $this->uri); + + return $response->getContent(); } } \ No newline at end of file diff --git a/src/Plivo/Resources/Campaign/CampaignInterface.php b/src/Plivo/Resources/Campaign/CampaignInterface.php index 2fb920b3..247c5549 100644 --- a/src/Plivo/Resources/Campaign/CampaignInterface.php +++ b/src/Plivo/Resources/Campaign/CampaignInterface.php @@ -186,9 +186,6 @@ public function delete($campaignId) $this->uri . '10dlc/Campaign/'. $campaignId .'/', [] ); - $responseContents = $response->getContent(); - return new Campaign( - $this->client, $responseContents, - $this->pathParams['authId'], $this->uri); + return $response->getContent(); } } \ No newline at end of file From b6f6a49215a0f029795d933cd756cb8a37bffab2 Mon Sep 17 00:00:00 2001 From: NirmitiJain Date: Mon, 21 Nov 2022 15:34:50 +0530 Subject: [PATCH 3/4] UT --- src/Plivo/Resources/Brand/BrandInterface.php | 4 ++-- src/Plivo/Resources/Campaign/CampaignInterface.php | 4 ++-- tests/Mocks/brandDeleteResponse.json | 3 ++- tests/Mocks/campaignDeleteResponse.json | 3 ++- tests/Resources/CampaignTest.php | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Plivo/Resources/Brand/BrandInterface.php b/src/Plivo/Resources/Brand/BrandInterface.php index 5acedd18..e20fe145 100644 --- a/src/Plivo/Resources/Brand/BrandInterface.php +++ b/src/Plivo/Resources/Brand/BrandInterface.php @@ -128,8 +128,8 @@ public function get_brand_usecases($brandId) } /** - * @param $uuid - * @return Brand + * @param $brand_id + * @return Message * @throws PlivoValidationException */ public function delete($brandId) diff --git a/src/Plivo/Resources/Campaign/CampaignInterface.php b/src/Plivo/Resources/Campaign/CampaignInterface.php index 247c5549..d3d8a3da 100644 --- a/src/Plivo/Resources/Campaign/CampaignInterface.php +++ b/src/Plivo/Resources/Campaign/CampaignInterface.php @@ -170,8 +170,8 @@ public function deleteNumber($campaignId, $number, $optionalArgs = []) } /** - * @param $uuid - * @return Campaign + * @param $campaign_id + * @return Message * @throws PlivoValidationException */ public function delete($campaignId) diff --git a/tests/Mocks/brandDeleteResponse.json b/tests/Mocks/brandDeleteResponse.json index f4987bc3..fbbe9848 100644 --- a/tests/Mocks/brandDeleteResponse.json +++ b/tests/Mocks/brandDeleteResponse.json @@ -1,4 +1,5 @@ { "message": "Brand Deactivated", - "brand_id": "BRPXS6E" + "brand_id": "BRPXS6E", + "api_id": "4bac497c-b963-11ec-b7ca-0242ac110002" } \ No newline at end of file diff --git a/tests/Mocks/campaignDeleteResponse.json b/tests/Mocks/campaignDeleteResponse.json index dfb2caee..d6b5eef6 100644 --- a/tests/Mocks/campaignDeleteResponse.json +++ b/tests/Mocks/campaignDeleteResponse.json @@ -1,4 +1,5 @@ { "message": "Campaign Deactivated", - "campaign_id": "CMPT4EP" + "campaign_id": "CMPT4EP", + "api_id": "4bac497c-b963-11ec-b7ca-0242ac110002" } \ No newline at end of file diff --git a/tests/Resources/CampaignTest.php b/tests/Resources/CampaignTest.php index 9ec6dad6..698a4ee2 100644 --- a/tests/Resources/CampaignTest.php +++ b/tests/Resources/CampaignTest.php @@ -135,7 +135,7 @@ public function testDeleteCampaign() { $campaignID = "CMPT4EP"; $request = new PlivoRequest( - 'GET', + 'DELETE', 'Account/MAXXXXXXXXXXXXXXXXXX/10dlc/Campaign/'.$campaignID.'/', []); $body = file_get_contents(__DIR__ . '/../Mocks/campaignDeleteResponse.json'); From e63f7f49b4f4f5c0612c82755e1681c305513d6d Mon Sep 17 00:00:00 2001 From: NirmitiJain Date: Tue, 6 Dec 2022 14:54:41 +0530 Subject: [PATCH 4/4] version update --- CHANGELOG.md | 3 +++ src/Plivo/Version.php | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 99195c71..7558a64b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,7 @@ # Change Log +## [v4.38.0](https://github.com/plivo/plivo-php/tree/v4.38.0) (2022-12-06) +- Added Delete campaign and brand API + ## [v4.37.1](https://github.com/plivo/plivo-php/tree/v4.37.1) (2022-11-15) - Support for PHP 8.1 version diff --git a/src/Plivo/Version.php b/src/Plivo/Version.php index 2a4e5f00..fd65a8cf 100644 --- a/src/Plivo/Version.php +++ b/src/Plivo/Version.php @@ -20,12 +20,12 @@ class Version /** * @const int PHP helper library minor version number */ - const MINOR = 37; + const MINOR = 38; /** * @const int PHP helper library patch number */ - const PATCH = 1; + const PATCH = 0; /** * @return string */