Skip to content

Commit f215bf0

Browse files
authored
Merge pull request #186 from plivo/10dlc-api
10dlc api suppport
2 parents 207dfca + 59d3ff3 commit f215bf0

16 files changed

+474
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Change Log
22

3+
## [4.20.0](https://github.com/plivo/plivo-python/tree/v4.20.0) (2021-12-02)
4+
**Features - Messaging: 10 DLC API**
5+
- 10 DLC API's for brand and campaign support.
6+
37
## [4.19.1](https://github.com/plivo/plivo-python/tree/v4.19.1) (2021-11-30)
48
**Bug fix**
59
- Library `PyJWT` version mismatch in setup.py compared with requirement.txt.

plivo/resources/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,6 @@
1515
from .call_feedback import CallFeedback
1616
from .powerpacks import Powerpacks
1717
from .lookup import Lookup
18+
from .brand import Brand
19+
from .campaign import Campaign
1820
from .multipartycall import MultiPartyCalls, MultiPartyCall, MultiPartyCallParticipant

plivo/resources/brand.py

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# -*- coding: utf-8 -*-
2+
from plivo.utils.validators import *
3+
4+
from ..base import ListResponseObject, PlivoResource, PlivoResourceInterface
5+
from ..exceptions import *
6+
from ..utils import *
7+
8+
class Brand(PlivoResource):
9+
_name = 'Brand'
10+
_identifier_string = 'brand_id'
11+
12+
class Brand(PlivoResourceInterface):
13+
_resource_type = Brand
14+
15+
@validate_args(brand_id=[of_type(six.text_type)])
16+
def get(self, brand_id):
17+
return self.client.request(
18+
'GET', ('10dlc','Brand', brand_id), response_type=None)
19+
20+
@validate_args(
21+
type=[optional(of_type(six.text_type))],
22+
status=[optional(of_type(six.text_type))])
23+
def list(self, type=None, status=None):
24+
return self.client.request(
25+
'GET', ('10dlc', 'Brand'),
26+
to_param_dict(self.list, locals()),
27+
response_type=None,
28+
objects_type=None)
29+
30+
@validate_args(
31+
alt_business_id_type=[optional(of_type(six.text_type))],
32+
alt_business_id=[optional(of_type(six.text_type))],
33+
city=[optional(of_type(six.text_type))],
34+
company_name=[optional(of_type(six.text_type))],
35+
country=[optional(of_type(six.text_type))],
36+
ein=[optional(of_type(six.text_type))],
37+
ein_issuing_country=[optional(of_type(six.text_type))],
38+
email=[optional(of_type(six.text_type))],
39+
entity_type=[optional(of_type(six.text_type))],
40+
first_name=[optional(of_type(six.text_type))],
41+
last_name=[optional(of_type(six.text_type))],
42+
phone=[optional(of_type(six.text_type))],
43+
postal_code=[optional(of_type(six.text_type))],
44+
registration_status=[optional(of_type(six.text_type))],
45+
state=[optional(of_type(six.text_type))],
46+
stock_exchange=[optional(of_type(six.text_type))],
47+
stock_symbol=[optional(of_type(six.text_type))],
48+
street=[optional(of_type(six.text_type))],
49+
vertical=[optional(of_type(six.text_type))],
50+
website=[optional(of_type(six.text_type))],
51+
secondary_vetting=[optional(of_type(six.text_type))])
52+
def create(self,
53+
vertical,
54+
street,
55+
stock_symbol,
56+
stock_exchange,
57+
state,
58+
registration_status,
59+
postal_code,
60+
phone,
61+
entity_type,
62+
email,
63+
ein_issuing_country,
64+
ein,
65+
country,
66+
company_name,
67+
city,
68+
alt_business_id_type=None,
69+
alt_business_id=None,
70+
first_name=None,
71+
last_name=False,
72+
website=None,
73+
secondary_vetting=None):
74+
return self.client.request('POST', ('10dlc', 'Brand'),
75+
to_param_dict(self.create, locals()))

plivo/resources/campaign.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# -*- coding: utf-8 -*-
2+
from plivo.utils.validators import *
3+
4+
from ..base import ListResponseObject, PlivoResource, PlivoResourceInterface
5+
from ..exceptions import *
6+
from ..utils import *
7+
8+
class Campaign(PlivoResource):
9+
_name = 'Campaign'
10+
_identifier_string = 'campaign_id'
11+
12+
class Campaign(PlivoResourceInterface):
13+
_resource_type = Campaign
14+
15+
@validate_args(campaign_id=[of_type(six.text_type)])
16+
def get(self, campaign_id):
17+
return self.client.request(
18+
'GET', ('10dlc','Campaign', campaign_id), response_type=None)
19+
20+
@validate_args(
21+
brand=[optional(of_type(six.text_type))],
22+
usecase=[optional(of_type(six.text_type))])
23+
def list(self, brand=None, usecase=None):
24+
return self.client.request(
25+
'GET', ('10dlc', 'Campaign'),
26+
to_param_dict(self.list, locals()),
27+
response_type=None,
28+
objects_type=None)
29+
30+
@validate_args(
31+
brand_id=[optional(of_type(six.text_type))],
32+
campaign_alias=[optional(of_type(six.text_type))],
33+
vertical=[optional(of_type(six.text_type))],
34+
usecase=[optional(of_type(six.text_type))],
35+
description=[optional(of_type(six.text_type))],
36+
embedded_link=[optional(of_type_exact(bool))],
37+
embedded_phone=[optional(of_type_exact(bool))],
38+
age_gated=[optional(of_type_exact(bool))],
39+
direct_lending=[optional(of_type_exact(bool))],
40+
subscriber_optin=[optional(of_type_exact(bool))],
41+
subscriber_optout=[optional(of_type_exact(bool))],
42+
subscriber_help=[optional(of_type_exact(bool))],
43+
sample1=[optional(of_type(six.text_type))],
44+
sample2=[optional(of_type(six.text_type))])
45+
def create(self,
46+
brand_id,
47+
vertical,
48+
usecase,
49+
description,
50+
sample1,
51+
sample2,
52+
embedded_link=False,
53+
embedded_phone=False,
54+
age_gated=False,
55+
direct_lending=False,
56+
subscriber_optout=True,
57+
subscriber_optin=True,
58+
subscriber_help=True,
59+
campaign_alias=None,
60+
sub_usecases=None):
61+
return self.client.request('POST', ('10dlc', 'Campaign'),
62+
to_param_dict(self.create, locals()))

plivo/rest/client.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
ResourceNotFoundError, ValidationError)
1414
from plivo.resources import (Accounts, Addresses, Applications, Calls,
1515
Conferences, Endpoints, Identities,
16-
Messages, Powerpacks, Media, Lookup,
16+
Messages, Powerpacks, Media, Lookup, Brand,Campaign,
1717
Numbers, Pricings, Recordings, Subaccounts, CallFeedback, MultiPartyCalls)
1818
from plivo.resources.live_calls import LiveCalls
1919
from plivo.resources.queued_calls import QueuedCalls
@@ -98,6 +98,8 @@ def __init__(self, auth_id=None, auth_token=None, proxies=None, timeout=5):
9898
self.lookup = Lookup(self)
9999
self.numbers = Numbers(self)
100100
self.powerpacks = Powerpacks(self)
101+
self.brand = Brand(self)
102+
self.campaign = Campaign(self)
101103
self.media = Media(self)
102104
self.pricing = Pricings(self)
103105
self.recordings = Recordings(self)

plivo/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# -*- coding: utf-8 -*-
2-
__version__ = '4.19.1'
2+
__version__ = '4.20.0'
33

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
setup(
1212
name='plivo',
13-
version='4.19.1',
13+
version='4.20.0',
1414
description='A Python SDK to make voice calls & send SMS using Plivo and to generate Plivo XML',
1515
long_description=long_description,
1616
url='https://github.com/plivo/plivo-python',

tests/resources/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,6 @@
1212
from .test_pricings import *
1313
from .test_recordings import *
1414
from .test_signature import *
15-
from .test_subaccounts import *
15+
from .test_subaccounts import *
16+
from .test_brand import *
17+
from .test_campaign import *
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"api_id": "a52a5398-3751-11ec-8e4c-0242ac110002",
3+
"brand": {
4+
"alt_business_id_type": "GIIN",
5+
"brand_id": "BVI0UQA",
6+
"city": "New York",
7+
"country": "US",
8+
"ein_issuing_country": "US",
9+
"email": "johndoe@abc.com",
10+
"entity_type": "SOLE_PROPRIETOR",
11+
"first_name": "John",
12+
"last_name": "Doe",
13+
"phone": "+11234567890",
14+
"postal_code": "10001",
15+
"registration_status": "PENDING",
16+
"state": "NY",
17+
"stock_exchange": "NASDAQ",
18+
"stock_symbol": "ABC",
19+
"street": "123",
20+
"vertical": "RETAIL",
21+
"website": "http://www.abcmobile.com"
22+
}
23+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"api_id": "71aa47e0-3750-11ec-8e4c-0242ac110002",
3+
"brand": {
4+
"brand_id": "BRPXS6E",
5+
"company_name": "ABC Inc.",
6+
"ein": "111111111",
7+
"ein_issuing_country": "US",
8+
"email": "johndoe@abc.com",
9+
"entity_type": "PRIVATE_PROFIT",
10+
"registration_status": "COMPLETED",
11+
"vertical": "RETAIL",
12+
"website": "http://www.abcmobile.com"
13+
}
14+
}

0 commit comments

Comments
 (0)