Skip to content

Commit

Permalink
Merge pull request #292 from plivo/SMS-4994-update-campaign-sdk
Browse files Browse the repository at this point in the history
Update campaign PHP SDK
  • Loading branch information
renoldthomas-plivo authored Jan 5, 2023
2 parents 2e126c4 + 2492a05 commit c710f88
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
43 changes: 43 additions & 0 deletions src/Plivo/Resources/Campaign/CampaignInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion src/Plivo/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
40 changes: 40 additions & 0 deletions tests/Mocks/campaignUpdateResponse.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
32 changes: 32 additions & 0 deletions tests/Resources/CampaignTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit c710f88

Please sign in to comment.