Skip to content

Commit

Permalink
Merge pull request #290 from plivo/SMS-4914-sdk-for-delete-campaign-b…
Browse files Browse the repository at this point in the history
…rand-api

Delete Campaign - Brand Request - PHP SDK
  • Loading branch information
renoldthomas-plivo authored Dec 15, 2022
2 parents 1a75707 + e63f7f4 commit 2e126c4
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 3 deletions.
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.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

Expand Down
21 changes: 21 additions & 0 deletions src/Plivo/Resources/Brand/BrandInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,25 @@ public function get_brand_usecases($brandId)
$this->pathParams['authId'], $this->uri);
}

/**
* @param $brand_id
* @return Message
* @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 .'/',
[]
);

return $response->getContent();
}

}
20 changes: 20 additions & 0 deletions src/Plivo/Resources/Campaign/CampaignInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,24 @@ public function deleteNumber($campaignId, $number, $optionalArgs = [])
);
return $response->getContent();
}

/**
* @param $campaign_id
* @return Message
* @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 .'/',
[]
);
return $response->getContent();
}
}
4 changes: 2 additions & 2 deletions src/Plivo/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
5 changes: 5 additions & 0 deletions tests/Mocks/brandDeleteResponse.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"message": "Brand Deactivated",
"brand_id": "BRPXS6E",
"api_id": "4bac497c-b963-11ec-b7ca-0242ac110002"
}
5 changes: 5 additions & 0 deletions tests/Mocks/campaignDeleteResponse.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"message": "Campaign Deactivated",
"campaign_id": "CMPT4EP",
"api_id": "4bac497c-b963-11ec-b7ca-0242ac110002"
}
17 changes: 17 additions & 0 deletions tests/Resources/BrandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

}

}
19 changes: 18 additions & 1 deletion tests/Resources/CampaignTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,22 @@ function testCampaignListNumber()

}

public function testDeleteCampaign()
{
$campaignID = "CMPT4EP";
$request = new PlivoRequest(
'DELETE',
'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);

}


}
}

0 comments on commit 2e126c4

Please sign in to comment.