From c41af1de561e929ee9be0dddaeb460ed06c3e657 Mon Sep 17 00:00:00 2001 From: vinaykumar-plivo <136321153+vinaykumar-plivo@users.noreply.github.com> Date: Wed, 13 Mar 2024 16:26:07 +0530 Subject: [PATCH] SDK changes for Import Campaign API (#338) * SDK changes for Import Campaign API * changelog, minor fix and updated version * patch version * review comments changes * making import_campaign method name standard * updating change log date --------- Co-authored-by: Thumpala Vinay Kumar Co-authored-by: Sajal Singhal Co-authored-by: Sajal Singhal --- CHANGELOG.md | 4 ++++ .../Resources/Campaign/CampaignInterface.php | 24 +++++++++++++++++++ src/Plivo/Version.php | 4 ++-- tests/Mocks/campaignImportResponse.json | 5 ++++ tests/Resources/CampaignTest.php | 21 ++++++++++++++++ 5 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 tests/Mocks/campaignImportResponse.json diff --git a/CHANGELOG.md b/CHANGELOG.md index 7cd5a136..f5909c9a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## [4.60.0](https://github.com/plivo/plivo-php/tree/v4.60.0) (2024-03-13) +**Feature - Import Campaign API** +- Added import campaign API + ## [4.59.2](https://github.com/plivo/plivo-php/tree/v4.59.2) (2024-01-29) **Feature - Log Redaction Enhancement** - Added log attribute in GET and List MDR response diff --git a/src/Plivo/Resources/Campaign/CampaignInterface.php b/src/Plivo/Resources/Campaign/CampaignInterface.php index 9917d3b5..df4264eb 100644 --- a/src/Plivo/Resources/Campaign/CampaignInterface.php +++ b/src/Plivo/Resources/Campaign/CampaignInterface.php @@ -132,6 +132,30 @@ public function create($brand_id,$campaign_alias,$vertical,$usecase,array $sub_u return $response->getContent(); } + /** + * Import Campaign + * + * @param {string} campaignId + * @param {string} campaign_alias + * @param array $optionalArgs + * @return CampaignImport + */ + public function import_campaign($campaignId, $campaign_alias, $optionalArgs = []) + { + $mandatoryArgs = [ + 'campaign_id' => $campaignId, + 'campaign_alias' => $campaign_alias + ]; + + $response = $this->client->update( + $this->uri . '10dlc/Campaign/Import/', + $mandatoryArgs, + $optionalArgs + ); + + return $response->getContent(); + } + /** * Update Campaign diff --git a/src/Plivo/Version.php b/src/Plivo/Version.php index e2638ea8..06f0230e 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 = 59; + const MINOR = 60; /** * @const int PHP helper library patch number */ - const PATCH = 2; + const PATCH = 0; /** * @return string */ diff --git a/tests/Mocks/campaignImportResponse.json b/tests/Mocks/campaignImportResponse.json new file mode 100644 index 00000000..a1e522f4 --- /dev/null +++ b/tests/Mocks/campaignImportResponse.json @@ -0,0 +1,5 @@ +{ + "api_id": "2c6c5e16-090a-11ed-bb48-0242ac110004", + "campaign_id": "CNTQ0OD", + "message": "Request to import campaign was received and is being processed." +} \ No newline at end of file diff --git a/tests/Resources/CampaignTest.php b/tests/Resources/CampaignTest.php index e9916b56..dd971b10 100644 --- a/tests/Resources/CampaignTest.php +++ b/tests/Resources/CampaignTest.php @@ -76,6 +76,27 @@ public function testGetCampaign() } + public function testCampaignImport() + { + $request = new PlivoRequest( + 'POST', + 'Account/MAXXXXXXXXXXXXXXXXXX/10dlc/Campaign/Import/', + [ + 'campaign_id' => "CNTQ0OD", + 'campaign_alias' => "New Contact by vinay for ct", + + ]); + $body = file_get_contents(__DIR__ . '/../Mocks/campaignImportResponse.json'); + + $this->mock(new PlivoResponse($request,200, $body)); + + $actual = $this->client->campaign->import_campaign("CNTQ0OD","New Contact by vinay for ct"); + + $this->assertRequest($request); + + self::assertNotNull($actual); + } + public function testCampaignUpdate() { $campaignID = "CMPT4EP";