-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Verify Caller ID - Python Changes (#248)
* Verify Caller ID - Python Changes * added SDK version
- Loading branch information
1 parent
a3beecb
commit b11ce35
Showing
12 changed files
with
248 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
from plivo.base import (ListResponseObject, PlivoResource, | ||
PlivoResourceInterface) | ||
from plivo.utils import to_param_dict | ||
|
||
|
||
class VerifyCallerid(PlivoResource): | ||
_name = 'VerifyCallerid' | ||
|
||
def initiate_verify(self): | ||
return self.client.calls.initiate_verify(self.id, | ||
**to_param_dict(self.initiate_verify(), locals())) | ||
|
||
def verify_caller_id(self): | ||
return self.client.calls.verify_caller_id(self.id, | ||
**to_param_dict(self.verify_caller_id(), locals())) | ||
|
||
def delete_verified_caller_id(self): | ||
return self.client.calls.delete_verified_caller_id(self.id, | ||
**to_param_dict(self.delete_verified_caller_id(), locals())) | ||
|
||
def get_verified_caller_id(self): | ||
return self.client.calls.get_verified_caller_id(self.id, | ||
**to_param_dict(self.get_verified_caller_id(), locals())) | ||
|
||
def update_verified_caller_id(self): | ||
return self.client.calls.update_verified_caller_id(self.id, | ||
**to_param_dict(self.update_verified_caller_id(), locals())) | ||
|
||
def list_verified_caller_id(self): | ||
return self.client.calls.list_verified_caller_id(self.id, | ||
**to_param_dict(self.list_verified_caller_id(), locals())) | ||
|
||
|
||
class VerifyCallerids(PlivoResourceInterface): | ||
_resource_type = VerifyCallerid | ||
|
||
def initiate_verify(self, | ||
phone_number=None, | ||
alias=None, | ||
channel=None, | ||
country=None, | ||
subaccount=None, | ||
account_id=None, | ||
auth_id=None, | ||
auth_token=None | ||
): | ||
return self.client.request('POST', ('VerifiedCallerId',), | ||
to_param_dict(self.initiate_verify, locals()), is_voice_request=True) | ||
|
||
def verify_caller_id(self, | ||
verification_uuid, | ||
otp=None, | ||
): | ||
return self.client.request('POST', ('VerifiedCallerId', 'Verification', verification_uuid), | ||
to_param_dict(self.verify_caller_id, locals()), is_voice_request=True) | ||
|
||
def delete_verified_caller_id(self, | ||
phone_number | ||
): | ||
return self.client.request('DELETE', ('VerifiedCallerId', phone_number), | ||
to_param_dict(self.delete_verified_caller_id, locals()), is_voice_request=True) | ||
|
||
def get_verified_caller_id(self, | ||
phone_number | ||
): | ||
return self.client.request('GET', ('VerifiedCallerId', phone_number), is_voice_request=True) | ||
|
||
def update_verified_caller_id(self, | ||
phone_number, | ||
alias=None, | ||
subaccount=None | ||
): | ||
return self.client.request('POST', ('VerifiedCallerId', phone_number), | ||
to_param_dict(self.update_verified_caller_id, locals()), is_voice_request=True) | ||
|
||
def list_verified_caller_id(self, | ||
country=None, | ||
subaccount=None, | ||
alias=None, | ||
limit=None, | ||
offset=None | ||
): | ||
return self.client.request('GET', ('VerifiedCallerId',), to_param_dict(self.list_verified_caller_id, locals()), | ||
is_voice_request=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
# -*- coding: utf-8 -*- | ||
__version__ = '4.42.0' | ||
__version__ = '4.43.0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"alias": "test", | ||
"api_id": "ee7c3cb1-c921-42c9-832b-950fb8344b9b", | ||
"country": "IN", | ||
"created_at": "2023-09-22T14:11:03.091534Z", | ||
"modified_at": "2023-09-22T14:11:03.091534Z", | ||
"phone_number": "+919768368718", | ||
"subaccount": "", | ||
"verification_uuid": "0f978b20-9e2b-4cfe-99fe-f7087c03b8e1" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"api_id": "2a5e81d7-deb3-46cd-ac34-c05ca9139b6f", | ||
"message": "Verification code is sent to number +919768368717 which is valid for 15 minutes", | ||
"verification_uuid": "407796a6-1f3e-4607-a9d9-5a5376b59a7b" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{ | ||
"api_id": "3b21c7d7-09f7-489b-b753-659814a676bf", | ||
"meta": { | ||
"limit": 20, | ||
"next": null, | ||
"offset": 0, | ||
"previous": null, | ||
"total_count": 4 | ||
}, | ||
"objects": [ | ||
{ | ||
"alias": "abhishek", | ||
"country": "IN", | ||
"created_at": "2023-09-25T14:40:38.68729Z", | ||
"modified_at": "2023-09-25T14:40:38.68729Z", | ||
"phone_number": "+919653244280", | ||
"resource_uri": "/v1/Account/MADCHANDRESH02TANK06/VerifiedCallerId/919653244280", | ||
"subaccount": "", | ||
"verification_uuid": "01be6b07-b106-46e2-8dfc-096d8e22cc0e" | ||
}, | ||
{ | ||
"alias": "abhishek", | ||
"country": "IN", | ||
"created_at": "2023-09-25T13:10:39.968133Z", | ||
"modified_at": "2023-09-25T13:10:39.968133Z", | ||
"phone_number": "+919768368717", | ||
"resource_uri": "/v1/Account/MADCHANDRESH02TANK06/VerifiedCallerId/919768368717", | ||
"subaccount": "", | ||
"verification_uuid": "2e68eb73-4d54-4391-bc98-71cd380911a4" | ||
}, | ||
{ | ||
"alias": "test", | ||
"country": "IN", | ||
"created_at": "2023-09-22T14:11:03.091534Z", | ||
"modified_at": "2023-09-22T14:11:03.091534Z", | ||
"phone_number": "+919768368718", | ||
"resource_uri": "/v1/Account/MADCHANDRESH02TANK06/VerifiedCallerId/919768368718", | ||
"subaccount": "", | ||
"verification_uuid": "0f978b20-9e2b-4cfe-99fe-f7087c03b8e1" | ||
}, | ||
{ | ||
"alias": "Test2", | ||
"country": "", | ||
"created_at": "2023-08-30T07:47:43.87171Z", | ||
"modified_at": "2023-08-30T07:47:43.87171Z", | ||
"phone_number": "+917691021365", | ||
"resource_uri": "/v1/Account/MADCHANDRESH02TANK06/VerifiedCallerId/917691021365", | ||
"subaccount": "SAMTU0Y2FKNGETYZDKNI", | ||
"verification_uuid": "20265c57-2d8e-46fe-8fa8-e8ab4ee58a8c" | ||
} | ||
] | ||
} |
10 changes: 10 additions & 0 deletions
10
tests/resources/fixtures/verifyCalleridUpdateResponse.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"alias": "testAbhishek", | ||
"api_id": "6b143cb3-9c8a-42ad-b6b7-412ebd5c60a9", | ||
"country": "IN", | ||
"created_at": "2023-09-22T14:11:03.091534Z", | ||
"modified_at": "2023-09-22T14:11:03.091534Z", | ||
"phone_number": "+919768368718", | ||
"subaccount": "SAMTU0Y2FKNGETYZDKNI", | ||
"verification_uuid": "0f978b20-9e2b-4cfe-99fe-f7087c03b8e1" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"alias": "abhishek", | ||
"api_id": "584a97aa-ca1d-44f2-9dd3-e58fbacd6649", | ||
"channel": "call", | ||
"country": "IN", | ||
"created_at": "2023-09-25T13:10:39.968133341Z", | ||
"phone_number": "+919768368717", | ||
"verification_uuid": "2e68eb73-4d54-4391-bc98-71cd380911a4" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
from tests.base import PlivoResourceTestCase | ||
from tests.decorators import with_response | ||
|
||
|
||
class VerifyCalleridTest(PlivoResourceTestCase): | ||
@with_response(201) | ||
def test_initiate(self): | ||
self.client.verify_callerids.initiate_verify(phone_number='917708772011', | ||
alias='test', | ||
channel='call') | ||
self.assertEqual(self.client.current_request.method, 'POST') | ||
self.assertUrlEqual( | ||
self.get_voice_url('VerifiedCallerId'), self.client.current_request.url) | ||
|
||
@with_response(201) | ||
def test_verify(self): | ||
verification_uuid = 'eeab1477-e59b-4821-9e61-fd5847c2a5db' | ||
self.client.verify_callerids.verify_caller_id( | ||
verification_uuid='eeab1477-e59b-4821-9e61-fd5847c2a5db', otp='610534') | ||
self.assertEqual(self.client.current_request.method, 'POST') | ||
self.assertUrlEqual( | ||
self.get_voice_url('VerifiedCallerId', 'Verification', verification_uuid), self.client.current_request.url) | ||
|
||
@with_response(200) | ||
def test_delete(self): | ||
phone_number = "917708772011" | ||
self.client.verify_callerids.delete_verified_caller_id( | ||
phone_number) | ||
self.assertEqual(self.client.current_request.method, 'DELETE') | ||
self.assertUrlEqual( | ||
self.get_voice_url('VerifiedCallerId', phone_number), self.client.current_request.url) | ||
|
||
@with_response(200) | ||
def test_get(self): | ||
phone_number = "917708772011" | ||
self.client.verify_callerids.get_verified_caller_id(phone_number) | ||
self.assertEqual(self.client.current_request.method, 'GET') | ||
self.assertUrlEqual( | ||
self.get_voice_url('VerifiedCallerId', phone_number), self.client.current_request.url) | ||
|
||
@with_response(200) | ||
def test_update(self): | ||
phone_number = "917708772011" | ||
self.client.verify_callerids.update_verified_caller_id( | ||
phone_number=phone_number, | ||
alias='test123') | ||
self.assertEqual(self.client.current_request.method, 'POST') | ||
self.assertUrlEqual( | ||
self.get_voice_url('VerifiedCallerId', phone_number), self.client.current_request.url) | ||
|
||
@with_response(200) | ||
def test_list(self): | ||
self.client.verify_callerids.list_verified_caller_id() | ||
self.assertEqual(self.client.current_request.method, 'GET') | ||
self.assertUrlEqual( | ||
self.get_voice_url('VerifiedCallerId'), self.client.current_request.url) |