From ccc734f879079b9f0ced41f77fb98a859407d62c Mon Sep 17 00:00:00 2001 From: NirmitiJain Date: Tue, 15 Nov 2022 11:10:13 +0530 Subject: [PATCH 01/13] Delete Campaign - Brand Request - Python SDK --- plivo/resources/brand.py | 5 +++++ plivo/resources/campaign.py | 5 +++++ tests/resources/fixtures/brandDeleteResponse.json | 4 ++++ .../fixtures/campaignDeleteResponse.json | 4 ++++ tests/resources/test_brand.py | 15 ++++++++++++++- tests/resources/test_campaign.py | 11 +++++++++++ 6 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 tests/resources/fixtures/brandDeleteResponse.json create mode 100644 tests/resources/fixtures/campaignDeleteResponse.json diff --git a/plivo/resources/brand.py b/plivo/resources/brand.py index 99236bb8..1a28215f 100644 --- a/plivo/resources/brand.py +++ b/plivo/resources/brand.py @@ -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) diff --git a/plivo/resources/campaign.py b/plivo/resources/campaign.py index 8dba9fcc..aaf45767 100644 --- a/plivo/resources/campaign.py +++ b/plivo/resources/campaign.py @@ -17,6 +17,11 @@ 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( brand=[optional(of_type(six.text_type))], usecase=[optional(of_type(six.text_type))], diff --git a/tests/resources/fixtures/brandDeleteResponse.json b/tests/resources/fixtures/brandDeleteResponse.json new file mode 100644 index 00000000..f4987bc3 --- /dev/null +++ b/tests/resources/fixtures/brandDeleteResponse.json @@ -0,0 +1,4 @@ +{ + "message": "Brand Deactivated", + "brand_id": "BRPXS6E" +} \ No newline at end of file diff --git a/tests/resources/fixtures/campaignDeleteResponse.json b/tests/resources/fixtures/campaignDeleteResponse.json new file mode 100644 index 00000000..c37a0d52 --- /dev/null +++ b/tests/resources/fixtures/campaignDeleteResponse.json @@ -0,0 +1,4 @@ +{ + "message": "Campaign Deactivated", + "campaign_id": "CUU5RCB" +} \ No newline at end of file diff --git a/tests/resources/test_brand.py b/tests/resources/test_brand.py index a2f305ae..77e40de9 100644 --- a/tests/resources/test_brand.py +++ b/tests/resources/test_brand.py @@ -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) \ No newline at end of file + self.assertEqual('GET', self.client.current_request.method) + + @with_response(200) + def test_delete(self): + response = self.client.brand.get(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) diff --git a/tests/resources/test_campaign.py b/tests/resources/test_campaign.py index 075dbca9..72944a6b 100644 --- a/tests/resources/test_campaign.py +++ b/tests/resources/test_campaign.py @@ -49,6 +49,17 @@ 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.get(campaign_id='CUU5RCB') + # Verifying the endpoint hit + self.assertUrlEqual( + 'https://api.plivo.com/v1/Account/MAXXXXXXXXXXXXXXXXXX/10dlc/Campaign/BRPXS6E/', + self.client.current_request.url) + + # Verifying the method used + self.assertEqual('DELETE', self.client.current_request.method) @with_response(200) def test_list(self): From b3e45c3523044c23586c64bc2b59fd8548d9bac1 Mon Sep 17 00:00:00 2001 From: NirmitiJain Date: Tue, 15 Nov 2022 11:14:47 +0530 Subject: [PATCH 02/13] delete UT --- tests/resources/test_brand.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/resources/test_brand.py b/tests/resources/test_brand.py index 77e40de9..388f0ae5 100644 --- a/tests/resources/test_brand.py +++ b/tests/resources/test_brand.py @@ -57,7 +57,7 @@ def test_get_usecases(self): @with_response(200) def test_delete(self): - response = self.client.brand.get(brand_id='BRPXS6E') + response = self.client.brand.delete(brand_id='BRPXS6E') self.client.set_expected_response( status_code=202, data_to_return=response) # Verifying the endpoint hit From cde6de70dd7ed9f25cc448101f9ed5e5ef2ef3de Mon Sep 17 00:00:00 2001 From: NirmitiJain Date: Tue, 15 Nov 2022 11:18:30 +0530 Subject: [PATCH 03/13] campaign ut --- tests/resources/test_campaign.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/resources/test_campaign.py b/tests/resources/test_campaign.py index 72944a6b..d8d3d429 100644 --- a/tests/resources/test_campaign.py +++ b/tests/resources/test_campaign.py @@ -55,7 +55,7 @@ def test_delete(self): response = self.client.campaign.get(campaign_id='CUU5RCB') # Verifying the endpoint hit self.assertUrlEqual( - 'https://api.plivo.com/v1/Account/MAXXXXXXXXXXXXXXXXXX/10dlc/Campaign/BRPXS6E/', + 'https://api.plivo.com/v1/Account/MAXXXXXXXXXXXXXXXXXX/10dlc/Campaign/CUU5RCB/', self.client.current_request.url) # Verifying the method used From 441a8816964f533c1194adada2a46f455846a46a Mon Sep 17 00:00:00 2001 From: NirmitiJain Date: Tue, 15 Nov 2022 11:27:30 +0530 Subject: [PATCH 04/13] delete campaign ut --- tests/resources/test_campaign.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/resources/test_campaign.py b/tests/resources/test_campaign.py index d8d3d429..fdda503b 100644 --- a/tests/resources/test_campaign.py +++ b/tests/resources/test_campaign.py @@ -52,7 +52,7 @@ def test_get(self): @with_response(200) def test_delete(self): - response = self.client.campaign.get(campaign_id='CUU5RCB') + response = self.client.campaign.delete(campaign_id='CUU5RCB') # Verifying the endpoint hit self.assertUrlEqual( 'https://api.plivo.com/v1/Account/MAXXXXXXXXXXXXXXXXXX/10dlc/Campaign/CUU5RCB/', From aa6ec20f2d12084b331af25049cd537569b270e7 Mon Sep 17 00:00:00 2001 From: NirmitiJain Date: Tue, 6 Dec 2022 15:04:39 +0530 Subject: [PATCH 05/13] version update --- CHANGELOG.md | 4 ++++ plivo/version.py | 2 +- setup.py | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index df01f804..5a658f4e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,8 @@ # Change Log +## [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 + ## [4.28.0](https://github.com/plivo/plivo-python/tree/v4.28.0) (2022-11-03) **Adding Brand Usecase request** -Added Brand Usecase request diff --git a/plivo/version.py b/plivo/version.py index 5f2ef79e..50646287 100644 --- a/plivo/version.py +++ b/plivo/version.py @@ -1,2 +1,2 @@ # -*- coding: utf-8 -*- -__version__ = '4.28.0' +__version__ = '4.29.0' diff --git a/setup.py b/setup.py index 3f7975fe..f0347d8b 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ setup( name='plivo', - version='4.28.0', + version='4.29.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', From a16183d2440094018ccc50e5ecfa6546524e1694 Mon Sep 17 00:00:00 2001 From: NirmitiJain Date: Tue, 29 Nov 2022 20:19:30 +0530 Subject: [PATCH 06/13] Update Campaign Python SDK --- plivo/resources/campaign.py | 18 +++++++++ .../fixtures/campaignUpdateResponse.json | 39 +++++++++++++++++++ tests/resources/test_campaign.py | 8 ++++ 3 files changed, 65 insertions(+) create mode 100644 tests/resources/fixtures/campaignUpdateResponse.json diff --git a/plivo/resources/campaign.py b/plivo/resources/campaign.py index aaf45767..1d693af9 100644 --- a/plivo/resources/campaign.py +++ b/plivo/resources/campaign.py @@ -21,6 +21,24 @@ 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=''): + return self.client.request( + 'PUT', ('10dlc','Campaign', campaign_id), to_param_dict(self.update, locals())) @validate_args( brand=[optional(of_type(six.text_type))], diff --git a/tests/resources/fixtures/campaignUpdateResponse.json b/tests/resources/fixtures/campaignUpdateResponse.json new file mode 100644 index 00000000..9e802ce4 --- /dev/null +++ b/tests/resources/fixtures/campaignUpdateResponse.json @@ -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" + } +} \ No newline at end of file diff --git a/tests/resources/test_campaign.py b/tests/resources/test_campaign.py index fdda503b..c331e008 100644 --- a/tests/resources/test_campaign.py +++ b/tests/resources/test_campaign.py @@ -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('PUT', self.client.current_request.method) + self.assertUrlEqual( + 'https://api.plivo.com/v1/Account/MAXXXXXXXXXXXXXXXXXX/10dlc/Campaign/', + self.client.current_request.url) + @with_response(200) def test_list(self): res = self.client.campaign.list(limit=2, offset=0) From 6948e3f1609867e7510b9e06f544b07d00e062d9 Mon Sep 17 00:00:00 2001 From: NirmitiJain Date: Tue, 29 Nov 2022 20:21:56 +0530 Subject: [PATCH 07/13] conflict removed --- plivo/resources/campaign.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/plivo/resources/campaign.py b/plivo/resources/campaign.py index 1d693af9..dc85dc10 100644 --- a/plivo/resources/campaign.py +++ b/plivo/resources/campaign.py @@ -17,10 +17,6 @@ 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))], From 0d7f525f89c7e9a972043cfc3bbe48ed2050489b Mon Sep 17 00:00:00 2001 From: NirmitiJain Date: Tue, 29 Nov 2022 20:27:00 +0530 Subject: [PATCH 08/13] UT --- tests/resources/test_campaign.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/resources/test_campaign.py b/tests/resources/test_campaign.py index c331e008..e6f3ad8e 100644 --- a/tests/resources/test_campaign.py +++ b/tests/resources/test_campaign.py @@ -66,7 +66,7 @@ def test_update(self): response = self.client.campaign.update('CXNSG9W', sample1 = "sample message 1 needs minimum 20 character") self.assertEqual('PUT', self.client.current_request.method) self.assertUrlEqual( - 'https://api.plivo.com/v1/Account/MAXXXXXXXXXXXXXXXXXX/10dlc/Campaign/', + 'https://api.plivo.com/v1/Account/MAXXXXXXXXXXXXXXXXXX/10dlc/Campaign/CXNSG9W/', self.client.current_request.url) @with_response(200) From c7abef51f174be0221ae5312c0ea05fe4504f023 Mon Sep 17 00:00:00 2001 From: NirmitiJain Date: Thu, 1 Dec 2022 10:36:29 +0530 Subject: [PATCH 09/13] POST method --- plivo/resources/campaign.py | 2 +- tests/resources/test_campaign.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plivo/resources/campaign.py b/plivo/resources/campaign.py index dc85dc10..0a3b6782 100644 --- a/plivo/resources/campaign.py +++ b/plivo/resources/campaign.py @@ -34,7 +34,7 @@ def get(self, campaign_id): ) def update(self, campaign_id, reseller_id='', description='', sample1='', sample2='', help_message='', message_flow='', optin_keywords='', optin_message='', optout_keywords='', optout_message='', help_keywords=''): return self.client.request( - 'PUT', ('10dlc','Campaign', campaign_id), to_param_dict(self.update, locals())) + 'POST', ('10dlc','Campaign', campaign_id), to_param_dict(self.update, locals())) @validate_args( brand=[optional(of_type(six.text_type))], diff --git a/tests/resources/test_campaign.py b/tests/resources/test_campaign.py index e6f3ad8e..60645b63 100644 --- a/tests/resources/test_campaign.py +++ b/tests/resources/test_campaign.py @@ -64,7 +64,7 @@ def test_delete(self): @with_response(200) def test_update(self): response = self.client.campaign.update('CXNSG9W', sample1 = "sample message 1 needs minimum 20 character") - self.assertEqual('PUT', self.client.current_request.method) + 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) From 9f342de43ce31ce969f0d9d08b90f25394797817 Mon Sep 17 00:00:00 2001 From: NirmitiJain Date: Thu, 15 Dec 2022 12:45:16 +0530 Subject: [PATCH 10/13] payload update --- plivo/resources/campaign.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plivo/resources/campaign.py b/plivo/resources/campaign.py index 0a3b6782..bea048ae 100644 --- a/plivo/resources/campaign.py +++ b/plivo/resources/campaign.py @@ -167,5 +167,7 @@ def number_unlink(self, url='', method='POST' ): + payload = locals() + payload.pop("campaign_id") return self.client.request('DELETE', ('10dlc', 'Campaign', campaign_id, 'Number', number), - to_param_dict(self.create, locals())) \ No newline at end of file + to_param_dict(self.create, payload)) \ No newline at end of file From b40b638375379b894e5b42adae9617037c4765c9 Mon Sep 17 00:00:00 2001 From: NirmitiJain Date: Thu, 15 Dec 2022 13:01:31 +0530 Subject: [PATCH 11/13] payload in update --- plivo/resources/campaign.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/plivo/resources/campaign.py b/plivo/resources/campaign.py index bea048ae..f478d335 100644 --- a/plivo/resources/campaign.py +++ b/plivo/resources/campaign.py @@ -33,8 +33,11 @@ def get(self, campaign_id): 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, locals())) + 'POST', ('10dlc','Campaign', campaign_id), to_param_dict(self.update, payload)) @validate_args( brand=[optional(of_type(six.text_type))], @@ -167,7 +170,5 @@ def number_unlink(self, url='', method='POST' ): - payload = locals() - payload.pop("campaign_id") return self.client.request('DELETE', ('10dlc', 'Campaign', campaign_id, 'Number', number), - to_param_dict(self.create, payload)) \ No newline at end of file + to_param_dict(self.create, locals())) \ No newline at end of file From 46b383ade763775b7d77a300f3e31e301af32b9b Mon Sep 17 00:00:00 2001 From: NirmitiJain Date: Fri, 16 Dec 2022 12:46:20 +0530 Subject: [PATCH 12/13] conflict fix --- plivo/resources/campaign.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plivo/resources/campaign.py b/plivo/resources/campaign.py index f478d335..cc71d499 100644 --- a/plivo/resources/campaign.py +++ b/plivo/resources/campaign.py @@ -17,6 +17,10 @@ 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))], From fde89418fcea7dea209d8a5d2a35ec253b730ca3 Mon Sep 17 00:00:00 2001 From: NirmitiJain Date: Fri, 16 Dec 2022 15:31:29 +0530 Subject: [PATCH 13/13] version update --- CHANGELOG.md | 4 ++++ plivo/version.py | 2 +- setup.py | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a658f4e..f94838bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/plivo/version.py b/plivo/version.py index 50646287..7aa9cd74 100644 --- a/plivo/version.py +++ b/plivo/version.py @@ -1,2 +1,2 @@ # -*- coding: utf-8 -*- -__version__ = '4.29.0' +__version__ = '4.30.0' diff --git a/setup.py b/setup.py index f0347d8b..83054ddf 100644 --- a/setup.py +++ b/setup.py @@ -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',