Skip to content

Commit b11ce35

Browse files
Verify Caller ID - Python Changes (#248)
* Verify Caller ID - Python Changes * added SDK version
1 parent a3beecb commit b11ce35

12 files changed

+248
-4
lines changed

CHANGELOG.md

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

3+
## [4.43.0](https://github.com/plivo/plivo-python/tree/v4.43.0) (2023-10-18)
4+
**Feature - Verify CallerID**
5+
- Added Initiate and Verify VerifyCallerID API
6+
- Added Update, Delete, Get and List verified CallerIDs API
7+
38
## [4.42.0](https://github.com/plivo/plivo-python/tree/v4.42.0) (2023-10-16)
49
**Introducing campaign_source**
510
- Added campaign_source in GET / LIST campaign APIs

plivo/exceptions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,7 @@ class ResourceNotFoundError(PlivoRestError):
2525

2626
class ValidationError(PlivoRestError):
2727
pass
28+
29+
30+
class ForbiddenError(PlivoRestError):
31+
pass

plivo/resources/verify_callerid.py

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
from plivo.base import (ListResponseObject, PlivoResource,
2+
PlivoResourceInterface)
3+
from plivo.utils import to_param_dict
4+
5+
6+
class VerifyCallerid(PlivoResource):
7+
_name = 'VerifyCallerid'
8+
9+
def initiate_verify(self):
10+
return self.client.calls.initiate_verify(self.id,
11+
**to_param_dict(self.initiate_verify(), locals()))
12+
13+
def verify_caller_id(self):
14+
return self.client.calls.verify_caller_id(self.id,
15+
**to_param_dict(self.verify_caller_id(), locals()))
16+
17+
def delete_verified_caller_id(self):
18+
return self.client.calls.delete_verified_caller_id(self.id,
19+
**to_param_dict(self.delete_verified_caller_id(), locals()))
20+
21+
def get_verified_caller_id(self):
22+
return self.client.calls.get_verified_caller_id(self.id,
23+
**to_param_dict(self.get_verified_caller_id(), locals()))
24+
25+
def update_verified_caller_id(self):
26+
return self.client.calls.update_verified_caller_id(self.id,
27+
**to_param_dict(self.update_verified_caller_id(), locals()))
28+
29+
def list_verified_caller_id(self):
30+
return self.client.calls.list_verified_caller_id(self.id,
31+
**to_param_dict(self.list_verified_caller_id(), locals()))
32+
33+
34+
class VerifyCallerids(PlivoResourceInterface):
35+
_resource_type = VerifyCallerid
36+
37+
def initiate_verify(self,
38+
phone_number=None,
39+
alias=None,
40+
channel=None,
41+
country=None,
42+
subaccount=None,
43+
account_id=None,
44+
auth_id=None,
45+
auth_token=None
46+
):
47+
return self.client.request('POST', ('VerifiedCallerId',),
48+
to_param_dict(self.initiate_verify, locals()), is_voice_request=True)
49+
50+
def verify_caller_id(self,
51+
verification_uuid,
52+
otp=None,
53+
):
54+
return self.client.request('POST', ('VerifiedCallerId', 'Verification', verification_uuid),
55+
to_param_dict(self.verify_caller_id, locals()), is_voice_request=True)
56+
57+
def delete_verified_caller_id(self,
58+
phone_number
59+
):
60+
return self.client.request('DELETE', ('VerifiedCallerId', phone_number),
61+
to_param_dict(self.delete_verified_caller_id, locals()), is_voice_request=True)
62+
63+
def get_verified_caller_id(self,
64+
phone_number
65+
):
66+
return self.client.request('GET', ('VerifiedCallerId', phone_number), is_voice_request=True)
67+
68+
def update_verified_caller_id(self,
69+
phone_number,
70+
alias=None,
71+
subaccount=None
72+
):
73+
return self.client.request('POST', ('VerifiedCallerId', phone_number),
74+
to_param_dict(self.update_verified_caller_id, locals()), is_voice_request=True)
75+
76+
def list_verified_caller_id(self,
77+
country=None,
78+
subaccount=None,
79+
alias=None,
80+
limit=None,
81+
offset=None
82+
):
83+
return self.client.request('GET', ('VerifiedCallerId',), to_param_dict(self.list_verified_caller_id, locals()),
84+
is_voice_request=True)

plivo/rest/client.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@
1010
from plivo.base import ResponseObject
1111
from plivo.exceptions import (AuthenticationError, InvalidRequestError,
1212
PlivoRestError, PlivoServerError,
13-
ResourceNotFoundError, ValidationError)
14-
from plivo.resources import (Accounts, Addresses, Applications, Calls,Token,
13+
ResourceNotFoundError, ValidationError, ForbiddenError)
14+
from plivo.resources import (Accounts, Addresses, Applications, Calls, Token,
1515
Conferences, Endpoints, Identities,
1616
Messages, Powerpacks, Media, Lookup, Brand, Campaign, Profile,
1717
Numbers, Pricings, Recordings, Subaccounts, CallFeedback, MultiPartyCalls, Sessions)
1818
from plivo.resources.live_calls import LiveCalls
1919
from plivo.resources.maskingsession import MaskingSessions
20+
from plivo.resources.verify_callerid import VerifyCallerids
2021
from plivo.resources.profile import Profile
2122
from plivo.resources.queued_calls import QueuedCalls
2223
from plivo.resources.regulatory_compliance import EndUsers, ComplianceDocumentTypes, ComplianceDocuments, \
@@ -119,6 +120,7 @@ def __init__(self, auth_id=None, auth_token=None, proxies=None, timeout=5):
119120
self.masking_sessions = MaskingSessions(self)
120121
self.voice_retry_count = 0
121122
self.verify_session = Sessions(self)
123+
self.verify_callerids = VerifyCallerids(self)
122124

123125
def __enter__(self):
124126
return self
@@ -164,6 +166,13 @@ def process_response(self,
164166
'Failed to authenticate while accessing resource at: '
165167
'{url}'.format(url=response.url))
166168

169+
if response.status_code == 403:
170+
if response_json and 'error' in response_json:
171+
raise ForbiddenError(response_json.error)
172+
raise ForbiddenError(
173+
'Request Failed : '
174+
'{url}'.format(url=response.url))
175+
167176
if response.status_code == 404:
168177
if response_json and 'error' in response_json:
169178
raise ResourceNotFoundError(response_json.error)

plivo/version.py

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

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.42.0',
13+
version='4.43.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',
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"alias": "test",
3+
"api_id": "ee7c3cb1-c921-42c9-832b-950fb8344b9b",
4+
"country": "IN",
5+
"created_at": "2023-09-22T14:11:03.091534Z",
6+
"modified_at": "2023-09-22T14:11:03.091534Z",
7+
"phone_number": "+919768368718",
8+
"subaccount": "",
9+
"verification_uuid": "0f978b20-9e2b-4cfe-99fe-f7087c03b8e1"
10+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"api_id": "2a5e81d7-deb3-46cd-ac34-c05ca9139b6f",
3+
"message": "Verification code is sent to number +919768368717 which is valid for 15 minutes",
4+
"verification_uuid": "407796a6-1f3e-4607-a9d9-5a5376b59a7b"
5+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"api_id": "3b21c7d7-09f7-489b-b753-659814a676bf",
3+
"meta": {
4+
"limit": 20,
5+
"next": null,
6+
"offset": 0,
7+
"previous": null,
8+
"total_count": 4
9+
},
10+
"objects": [
11+
{
12+
"alias": "abhishek",
13+
"country": "IN",
14+
"created_at": "2023-09-25T14:40:38.68729Z",
15+
"modified_at": "2023-09-25T14:40:38.68729Z",
16+
"phone_number": "+919653244280",
17+
"resource_uri": "/v1/Account/MADCHANDRESH02TANK06/VerifiedCallerId/919653244280",
18+
"subaccount": "",
19+
"verification_uuid": "01be6b07-b106-46e2-8dfc-096d8e22cc0e"
20+
},
21+
{
22+
"alias": "abhishek",
23+
"country": "IN",
24+
"created_at": "2023-09-25T13:10:39.968133Z",
25+
"modified_at": "2023-09-25T13:10:39.968133Z",
26+
"phone_number": "+919768368717",
27+
"resource_uri": "/v1/Account/MADCHANDRESH02TANK06/VerifiedCallerId/919768368717",
28+
"subaccount": "",
29+
"verification_uuid": "2e68eb73-4d54-4391-bc98-71cd380911a4"
30+
},
31+
{
32+
"alias": "test",
33+
"country": "IN",
34+
"created_at": "2023-09-22T14:11:03.091534Z",
35+
"modified_at": "2023-09-22T14:11:03.091534Z",
36+
"phone_number": "+919768368718",
37+
"resource_uri": "/v1/Account/MADCHANDRESH02TANK06/VerifiedCallerId/919768368718",
38+
"subaccount": "",
39+
"verification_uuid": "0f978b20-9e2b-4cfe-99fe-f7087c03b8e1"
40+
},
41+
{
42+
"alias": "Test2",
43+
"country": "",
44+
"created_at": "2023-08-30T07:47:43.87171Z",
45+
"modified_at": "2023-08-30T07:47:43.87171Z",
46+
"phone_number": "+917691021365",
47+
"resource_uri": "/v1/Account/MADCHANDRESH02TANK06/VerifiedCallerId/917691021365",
48+
"subaccount": "SAMTU0Y2FKNGETYZDKNI",
49+
"verification_uuid": "20265c57-2d8e-46fe-8fa8-e8ab4ee58a8c"
50+
}
51+
]
52+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"alias": "testAbhishek",
3+
"api_id": "6b143cb3-9c8a-42ad-b6b7-412ebd5c60a9",
4+
"country": "IN",
5+
"created_at": "2023-09-22T14:11:03.091534Z",
6+
"modified_at": "2023-09-22T14:11:03.091534Z",
7+
"phone_number": "+919768368718",
8+
"subaccount": "SAMTU0Y2FKNGETYZDKNI",
9+
"verification_uuid": "0f978b20-9e2b-4cfe-99fe-f7087c03b8e1"
10+
}

0 commit comments

Comments
 (0)