Skip to content

Commit

Permalink
Merge branch 'master' into message-expiry
Browse files Browse the repository at this point in the history
  • Loading branch information
narayana-plivo authored Jan 18, 2023
2 parents 768ea74 + 114aec8 commit 04007da
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 1 deletion.
5 changes: 5 additions & 0 deletions plivo/resources/brand.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,8 @@ def create(self,
def get_usecases(self, brand_id):
return self.client.request(
'GET', ('10dlc','Brand', brand_id, 'usecases'), response_type=None)

@validate_args(brand_id=[required(of_type(six.text_type))])
def delete(self, brand_id):
return self.client.request(
'DELETE', ('10dlc','Brand', brand_id), response_type=None)
26 changes: 26 additions & 0 deletions plivo/resources/campaign.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,32 @@ def get(self, campaign_id):
return self.client.request(
'GET', ('10dlc','Campaign', campaign_id), response_type=None)

@validate_args(campaign_id=[required(of_type(six.text_type))])
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))],
usecase=[optional(of_type(six.text_type))],
Expand Down
4 changes: 4 additions & 0 deletions tests/resources/fixtures/brandDeleteResponse.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"message": "Brand Deactivated",
"brand_id": "BRPXS6E"
}
4 changes: 4 additions & 0 deletions tests/resources/fixtures/campaignDeleteResponse.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"message": "Campaign Deactivated",
"campaign_id": "CUU5RCB"
}
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"
}
}
15 changes: 14 additions & 1 deletion tests/resources/test_brand.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,17 @@ def test_get_usecases(self):
self.client.current_request.url)

# Verifying the method used
self.assertEqual('GET', self.client.current_request.method)
self.assertEqual('GET', self.client.current_request.method)

@with_response(200)
def test_delete(self):
response = self.client.brand.delete(brand_id='BRPXS6E')
self.client.set_expected_response(
status_code=202, data_to_return=response)
# Verifying the endpoint hit
self.assertUrlEqual(
'https://api.plivo.com/v1/Account/MAXXXXXXXXXXXXXXXXXX/10dlc/Brand/BRPXS6E/',
self.client.current_request.url)

# Verifying the method used
self.assertEqual('DELETE', self.client.current_request.method)
19 changes: 19 additions & 0 deletions tests/resources/test_campaign.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,25 @@ def test_get(self):

# Verifying the method used
self.assertEqual('GET', self.client.current_request.method)

@with_response(200)
def test_delete(self):
response = self.client.campaign.delete(campaign_id='CUU5RCB')
# Verifying the endpoint hit
self.assertUrlEqual(
'https://api.plivo.com/v1/Account/MAXXXXXXXXXXXXXXXXXX/10dlc/Campaign/CUU5RCB/',
self.client.current_request.url)

# 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):
Expand Down

0 comments on commit 04007da

Please sign in to comment.