From 325b3a656cc95b59fec2681f924cf7357e07fe3c Mon Sep 17 00:00:00 2001 From: NirmitiJain Date: Fri, 16 Dec 2022 16:14:25 +0530 Subject: [PATCH 1/2] update campaign php sdk --- .../Resources/Campaign/CampaignInterface.php | 43 +++++++++++++++++++ tests/Mocks/campaignUpdateResponse.json | 40 +++++++++++++++++ tests/Resources/CampaignTest.php | 32 ++++++++++++++ 3 files changed, 115 insertions(+) create mode 100644 tests/Mocks/campaignUpdateResponse.json diff --git a/src/Plivo/Resources/Campaign/CampaignInterface.php b/src/Plivo/Resources/Campaign/CampaignInterface.php index d3d8a3da..9917d3b5 100644 --- a/src/Plivo/Resources/Campaign/CampaignInterface.php +++ b/src/Plivo/Resources/Campaign/CampaignInterface.php @@ -132,6 +132,49 @@ public function create($brand_id,$campaign_alias,$vertical,$usecase,array $sub_u return $response->getContent(); } + + /** + * Update Campaign + * + * @param {string} campaignId + * @param {string} description + * @param {string} reseller_id + * @param {string} sample1 + * @param {string} sample2 + * @param {string} message_flow + * @param {string} help_message + * @param {string} optin_keywords + * @param {string} optin_message + * @param {string} optout_keywords + * @param {string} optout_message + * @param {string} help_keywords + * @return Campaign + */ + public function update($campaignId,$description,$reseller_id,$sample1,$sample2,$message_flow,$help_message,$optin_keywords,$optin_message,$optout_keywords,$optout_message,$help_keywords,array $optionalArgs = []) + { + $mandaoryArgs = [ + 'reseller_id' => $reseller_id, + 'description' => $description, + 'sample1' => $sample1, + 'sample2' => $sample2, + 'message_flow' => $message_flow, + 'help_message' => $help_message, + 'optout_message' => $optout_message, + 'optin_keywords' => $optin_keywords, + 'optout_keywords' => $optout_keywords, + 'optin_message' => $optin_message, + 'help_keywords' => $help_keywords, + ]; + + $response = $this->client->update( + $this->uri . '10dlc/Campaign/'. $campaignId .'/', + array_merge($mandaoryArgs, $optionalArgs) + ); + + $responseContents = $response->getContent(); + return $responseContents; + } + public function getNumber($campaignId, $number) { $response = $this->client->fetch( diff --git a/tests/Mocks/campaignUpdateResponse.json b/tests/Mocks/campaignUpdateResponse.json new file mode 100644 index 00000000..0cce0d3a --- /dev/null +++ b/tests/Mocks/campaignUpdateResponse.json @@ -0,0 +1,40 @@ +{ + "api_id": "95e1df78-3f08-11e7-8bc8-065f6a74a84a", + "campaign": { + "campaign_id": "CMPT4EP", + "registration_status": "FAILED", + "reseller_id": "", + "brand_id": "BS2TTMI", + "usecase": "MARKETING", + "mno_metadata": { + "AT&T": { + "tpm": 4500 + }, + "T-Mobile": { + "brand_tier": "TOP" + }, + "US Cellular": { + "tpm": 4500 + }, + "Verizon Wireless": { + "tpm": 4500 + } + }, + "sample1": "updated sample1 for plivo and tcr", + "sample2": "sample message 2", + "description": "campaign description", + "campaign_attributes": { + "embedded_link": false, + "embedded_phone": false, + "age_gated": false, + "direct_lending": false, + "subscriber_optin": false, + "subscriber_optout": false, + "subscriber_help": false, + "affiliate_marketing": false + }, + "message_flow": "message flow", + "help_message": "help message", + "help_keywords": "HELP UPDATE" + } +} \ No newline at end of file diff --git a/tests/Resources/CampaignTest.php b/tests/Resources/CampaignTest.php index 698a4ee2..e9916b56 100644 --- a/tests/Resources/CampaignTest.php +++ b/tests/Resources/CampaignTest.php @@ -75,6 +75,38 @@ public function testGetCampaign() $this->assertRequest($request); } + + public function testCampaignUpdate() + { + $campaignID = "CMPT4EP"; + $request = new PlivoRequest( + 'POST', + 'Account/MAXXXXXXXXXXXXXXXXXX/10dlc/Campaign/'.$campaignID.'/', + [ + + 'reseller_id' => "", + 'description' => "", + 'sample1' => "sample 1 should be 20 minimum character", + 'sample2' => "", + 'message_flow' => "", + 'help_message' => "", + 'optout_message' => "", + 'optin_keywords' => "", + 'optout_keywords' => "", + 'optin_message' => "", + 'help_keywords' => "", + + ]); + $body = file_get_contents(__DIR__ . '/../Mocks/campaignUpdateResponse.json'); + + $this->mock(new PlivoResponse($request,200, $body)); + + $actual = $this->client->campaign->update($campaignID, "","","sample 1 should be 20 minimum character","","","","","","","",""); + + $this->assertRequest($request); + + self::assertNotNull($actual); + } function testCampaignList() From 2492a0534785b3b8e9817d358c33417fd024b8ac Mon Sep 17 00:00:00 2001 From: NirmitiJain Date: Fri, 16 Dec 2022 16:28:43 +0530 Subject: [PATCH 2/2] version update --- CHANGELOG.md | 3 +++ src/Plivo/Version.php | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7558a64b..c7e65156 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,7 @@ # Change Log +## [v4.39.0](https://github.com/plivo/plivo-php/tree/v4.39.0) (2022-12-16) +- Added update campaign API + ## [v4.38.0](https://github.com/plivo/plivo-php/tree/v4.38.0) (2022-12-06) - Added Delete campaign and brand API diff --git a/src/Plivo/Version.php b/src/Plivo/Version.php index fd65a8cf..885afe22 100644 --- a/src/Plivo/Version.php +++ b/src/Plivo/Version.php @@ -20,7 +20,7 @@ class Version /** * @const int PHP helper library minor version number */ - const MINOR = 38; + const MINOR = 39; /** * @const int PHP helper library patch number