From 412e40f7696c6201ec80ce649661ba4380fe93ea Mon Sep 17 00:00:00 2001 From: vinaykumar-plivo <136321153+vinaykumar-plivo@users.noreply.github.com> Date: Wed, 13 Mar 2024 17:11:37 +0530 Subject: [PATCH] SDK changes for Import Campaign API (#259) * SDK changes for Import Campaign API * changelog and updated version * date change * Removing url and method from func args * Retaining url and method in func args * review comments changes * assigning None to url and method in import_campaign method * updating change log date --------- Co-authored-by: Thumpala Vinay Kumar Co-authored-by: Sajal Singhal Co-authored-by: Sajal Singhal --- CHANGELOG.md | 4 ++++ plivo/resources/campaign.py | 9 +++++++++ plivo/version.py | 2 +- setup.py | 2 +- .../fixtures/campaignImportResponse.json | 5 +++++ tests/resources/test_campaign.py | 15 +++++++++++++++ 6 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 tests/resources/fixtures/campaignImportResponse.json diff --git a/CHANGELOG.md b/CHANGELOG.md index 04a53b2e..7148300e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## [4.49.0](https://github.com/plivo/plivo-python/tree/v4.49.0) (2024-03-13) +**Adding Import Campaign** +-Added Import Campaign API + ## [4.48.2](https://github.com/plivo/plivo-python/tree/v4.48.2) (2024-02-28) **Feature - Log Redaction Enhancement** - Added log attribute in GET and List MDR response diff --git a/plivo/resources/campaign.py b/plivo/resources/campaign.py index 196b7bfe..cdeff846 100644 --- a/plivo/resources/campaign.py +++ b/plivo/resources/campaign.py @@ -123,6 +123,15 @@ def create(self, return self.client.request('POST', ('10dlc', 'Campaign'), to_param_dict(self.create, locals())) + @validate_args( + campaign_id=[required(of_type(six.text_type))], + campaign_alias=[required(of_type(six.text_type))], + method=[optional(of_type(six.text_type))], + url=[optional(of_type(six.text_type))], + ) + def import_campaign(self,campaign_id, campaign_alias, url=None, method=None): + return self.client.request('POST', ('10dlc', 'Campaign', 'Import'), + to_param_dict(self.import_campaign, locals())) @validate_args( campaign_id=[required(of_type(six.text_type))], diff --git a/plivo/version.py b/plivo/version.py index 33a87b1e..7fc7b21d 100644 --- a/plivo/version.py +++ b/plivo/version.py @@ -1,2 +1,2 @@ # -*- coding: utf-8 -*- -__version__ = '4.48.2' +__version__ = '4.49.0' diff --git a/setup.py b/setup.py index 3ee3ccf7..77d8c50a 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ setup( name='plivo', - version='4.48.2', + version='4.49.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', diff --git a/tests/resources/fixtures/campaignImportResponse.json b/tests/resources/fixtures/campaignImportResponse.json new file mode 100644 index 00000000..a1e522f4 --- /dev/null +++ b/tests/resources/fixtures/campaignImportResponse.json @@ -0,0 +1,5 @@ +{ + "api_id": "2c6c5e16-090a-11ed-bb48-0242ac110004", + "campaign_id": "CNTQ0OD", + "message": "Request to import campaign was received and is being processed." +} \ No newline at end of file diff --git a/tests/resources/test_campaign.py b/tests/resources/test_campaign.py index 60645b63..055e6d92 100644 --- a/tests/resources/test_campaign.py +++ b/tests/resources/test_campaign.py @@ -39,6 +39,21 @@ def test_create(self): 'https://api.plivo.com/v1/Account/MAXXXXXXXXXXXXXXXXXX/10dlc/Campaign/', self.client.current_request.url) + @with_response(200) + def test_import(self): + response = self.client.campaign.import_campaign( + campaign_id = "CNTQ0OD", + campaign_alias= "New Contact by vinay for ct", + ) + self.assertEqual('POST', self.client.current_request.method) + self.assertUrlEqual( + 'https://api.plivo.com/v1/Account/MAXXXXXXXXXXXXXXXXXX/10dlc/Campaign/Import/', + self.client.current_request.url) + + self.assertEqual('CNTQ0OD', response.campaign_id) + self.assertEqual('Request to import campaign was received and is being processed.', response.message) + + @with_response(200) def test_get(self): response = self.client.campaign.get(campaign_id='BRPXS6E')