Skip to content

Commit

Permalink
Merge pull request #220 from plivo/SMS-4994-update-campaign-sdk
Browse files Browse the repository at this point in the history
Update Campaign Python SDK
  • Loading branch information
renoldthomas-plivo authored Jan 5, 2023
2 parents c8ff052 + fde8941 commit 114aec8
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Change Log
## [4.30.0](https://github.com/plivo/plivo-python/tree/v4.30.0) (2022-12-16)
**Adding Update campaign**
-Added update campaign

## [4.29.0](https://github.com/plivo/plivo-python/tree/v4.29.0) (2022-12-06)
**Adding Delete campaign and brand**
-Added delete campaign and brand
Expand Down
21 changes: 21 additions & 0 deletions plivo/resources/campaign.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,27 @@ def get(self, campaign_id):
def delete(self, campaign_id):
return self.client.request(
'DELETE', ('10dlc','Campaign', campaign_id), response_type=None)

@validate_args(
campaign_id=[required(of_type(six.text_type))],
reseller_id=[optional(of_type(six.text_type))],
description=[optional(of_type(six.text_type))],
sample1=[optional(of_type(six.text_type))],
sample2=[optional(of_type(six.text_type))],
help_message=[optional(of_type(six.text_type))],
message_flow=[optional(of_type(six.text_type))],
optin_keywords=[optional(of_type(six.text_type))],
optin_message=[optional(of_type(six.text_type))],
optout_keywords=[optional(of_type(six.text_type))],
optout_message=[optional(of_type(six.text_type))],
help_keywords=[optional(of_type(six.text_type))],
)
def update(self, campaign_id, reseller_id='', description='', sample1='', sample2='', help_message='', message_flow='', optin_keywords='', optin_message='', optout_keywords='', optout_message='', help_keywords=''):

payload = locals()
payload.pop("campaign_id")
return self.client.request(
'POST', ('10dlc','Campaign', campaign_id), to_param_dict(self.update, payload))

@validate_args(
brand=[optional(of_type(six.text_type))],
Expand Down
2 changes: 1 addition & 1 deletion plivo/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# -*- coding: utf-8 -*-
__version__ = '4.29.0'
__version__ = '4.30.0'
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

setup(
name='plivo',
version='4.29.0',
version='4.30.0',
description='A Python SDK to make voice calls & send SMS using Plivo and to generate Plivo XML',
long_description=long_description,
url='https://github.com/plivo/plivo-python',
Expand Down
39 changes: 39 additions & 0 deletions tests/resources/fixtures/campaignUpdateResponse.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"campaign": {
"campaign_id": "CXNSG9W",
"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 asdsdasdfasdsdasdf 2",
"sample2": "sample message sdasdasdasdsdasdasda 2",
"description": "campaign descriptioncampaign descriptioncampaign descriptioncampaign descriptioncampaign descriptioncampaign descriptioncampaign descriptioncampaign descriptioncampaign 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 flowmessage flowmessage flowmessage flowmessage flowmessage flowmessage flowmessage flowmessage flow",
"help_message": "help message 2help message 2help message 2help message 2help message 2help message 2help message 2help message 2",
"help_keywords": "HELP UPDATE"
}
}
8 changes: 8 additions & 0 deletions tests/resources/test_campaign.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ def test_delete(self):
# Verifying the method used
self.assertEqual('DELETE', self.client.current_request.method)

@with_response(200)
def test_update(self):
response = self.client.campaign.update('CXNSG9W', sample1 = "sample message 1 needs minimum 20 character")
self.assertEqual('POST', self.client.current_request.method)
self.assertUrlEqual(
'https://api.plivo.com/v1/Account/MAXXXXXXXXXXXXXXXXXX/10dlc/Campaign/CXNSG9W/',
self.client.current_request.url)

@with_response(200)
def test_list(self):
res = self.client.campaign.list(limit=2, offset=0)
Expand Down

0 comments on commit 114aec8

Please sign in to comment.