-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #239 from plivo/VT-6125
Python : Number Masking SDK implementation
- Loading branch information
Showing
14 changed files
with
510 additions
and
11 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
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,110 @@ | ||
from plivo.base import (ListResponseObject, PlivoResource, | ||
PlivoResourceInterface) | ||
from plivo.utils import to_param_dict | ||
from plivo.utils.validators import * | ||
|
||
class MaskingSession(PlivoResource): | ||
_name = 'MaskingSession' | ||
_identifier_string = 'session_uuid' | ||
def create_masking_session(self): | ||
return self.client.calls.create_masking_session(self.id, | ||
**to_param_dict(self.create_masking_session(), locals())) | ||
|
||
def delete_masking_session(self): | ||
return self.client.calls.delete_masking_session(self.id, | ||
**to_param_dict(self.delete_masking_session(), locals())) | ||
|
||
def get_masking_session(self): | ||
return self.client.calls.get_masking_session(self.id, | ||
**to_param_dict(self.get_masking_session(), locals())) | ||
|
||
def update_masking_session(self): | ||
return self.client.calls.update_masking_session(self.id, | ||
**to_param_dict(self.update_masking_session(), locals())) | ||
|
||
def list_masking_session(self): | ||
return self.client.calls.list_masking_session(self.id, | ||
**to_param_dict(self.list_masking_session(), locals())) | ||
|
||
|
||
class MaskingSessions(PlivoResourceInterface): | ||
_resource_type = MaskingSession | ||
|
||
@validate_args( | ||
callback_url=[optional(is_url())], | ||
recording_callback_url=[optional(is_url())], | ||
first_party_play_url=[optional(is_url())], | ||
second_party_play_url=[optional(is_url())], | ||
) | ||
def create_masking_session(self, | ||
first_party=None, | ||
second_party=None, | ||
session_expiry=None, | ||
call_time_limit=None, | ||
record=None, | ||
record_file_format=None, | ||
recording_callback_url=None, | ||
initiate_call_to_first_party=None, | ||
callback_url=None, | ||
callback_method=None, | ||
ring_timeout=None, | ||
first_party_play_url=None, | ||
second_party_play_url=None, | ||
recording_callback_method=None | ||
): | ||
return self.client.request('POST', ('Masking', 'Session',), | ||
to_param_dict(self.create_masking_session, locals()), is_voice_request=True) | ||
|
||
def delete_masking_session(self, | ||
session_uuid | ||
): | ||
return self.client.request('DELETE', ('Masking', 'Session', session_uuid), | ||
to_param_dict(self.delete_masking_session, locals()), is_voice_request=True) | ||
|
||
def get_masking_session(self, | ||
session_uuid | ||
): | ||
return self.client.request('GET', ('Masking', 'Session', session_uuid), is_voice_request=True) | ||
|
||
def update_masking_session(self, | ||
session_uuid, | ||
session_expiry=None, | ||
call_time_limit=None, | ||
record=None, | ||
record_file_format=None, | ||
recording_callback_url=None, | ||
callback_url=None, | ||
callback_method=None, | ||
ring_timeout=None, | ||
first_party_play_url=None, | ||
second_party_play_url=None, | ||
recording_callback_method=None | ||
): | ||
return self.client.request('POST', ('Masking', 'Session', session_uuid), | ||
to_param_dict(self.update_masking_session, locals()), is_voice_request=True) | ||
|
||
def list_masking_session(self, | ||
first_party=None, | ||
second_party=None, | ||
virtual_number=None, | ||
status=None, | ||
created_time=None, | ||
created_time__lt=None, | ||
created_time__lte=None, | ||
created_time__gt=None, | ||
created_time__gte=None, | ||
expiry_time=None, | ||
expiry_time__lt=None, | ||
expiry_time__lte=None, | ||
expiry_time__gt=None, | ||
expiry_time__gte=None, | ||
duration=None, | ||
duration__lt=None, | ||
duration__lte=None, | ||
duration__gt=None, | ||
duration__gte=None, | ||
limit=None, | ||
offset=None | ||
): | ||
return self.client.request('GET', ('Masking', 'Session'), to_param_dict(self.list_masking_session, 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.37.0' | ||
__version__ = '4.38.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
35 changes: 35 additions & 0 deletions
35
tests/resources/fixtures/maskingSessionCreateResponse.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,35 @@ | ||
{ | ||
"api_id": "7fef62d3-a451-40ef-95e7-b4ad9969aa1e", | ||
"session_uuid": "bc0a20bb-9f09-4116-b3f8-709def3a89df", | ||
"virtual_number": "+916361728680", | ||
"message": "Session created", | ||
"session": { | ||
"first_party": "917708772011", | ||
"second_party": "919976106830", | ||
"virtual_number": "916361728680", | ||
"status": "active", | ||
"initiate_call_to_first_party": false, | ||
"session_uuid": "bc0a20bb-9f09-4116-b3f8-709def3a89df", | ||
"callback_url": "http://plivobin.non-prod.plivops.com/1jvpmrs1", | ||
"callback_method": "GET", | ||
"created_time": "2023-07-12 15:52:14.772699 +0000 UTC", | ||
"modified_time": "2023-07-12 15:52:14.772699 +0000 UTC", | ||
"expiry_time": "2023-07-12 17:32:14.772699 +0000 UTC", | ||
"duration": 6000, | ||
"amount": 0, | ||
"call_time_limit": 14400, | ||
"ring_timeout": 120, | ||
"first_party_play_url": "https://s3.amazonaws.com/plivosamplexml/play_url.xml", | ||
"second_party_play_url": "https://plivobin-prod-usw.plivops.com/api/v1/speak.xml", | ||
"record": false, | ||
"record_file_format": "mp3", | ||
"recording_callback_url": "https://plivobin-prod-usw.plivops.com/api/v1/speak.xml", | ||
"recording_callback_method": "GET", | ||
"interaction": null, | ||
"total_call_amount": 0, | ||
"total_call_count": 0, | ||
"total_call_billed_duration": 0, | ||
"total_session_amount": 0, | ||
"last_interaction_time": "" | ||
} | ||
} |
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,4 @@ | ||
{ | ||
"api_id": "f91f459a-283d-4850-9b33-ad914dcb64c0", | ||
"message": "Session Deleted" | ||
} |
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,32 @@ | ||
{ | ||
"api_id": "b503c0b9-a419-406f-8e49-9856844600ab", | ||
"response": { | ||
"first_party": "917708772011", | ||
"second_party": "919976106830", | ||
"virtual_number": "916361728680", | ||
"status": "active", | ||
"initiate_call_to_first_party": false, | ||
"session_uuid": "c2146ba4-798d-49b0-8580-53851a16e055", | ||
"callback_url": "http://plivobin.non-prod.plivops.com/w7mf5kw7", | ||
"callback_method": "GET", | ||
"created_time": "2023-07-05 10:25:40.877364 +0000 UTC", | ||
"modified_time": "2023-07-05 10:25:40.877364 +0000 UTC", | ||
"expiry_time": "2023-07-05 12:05:40.877364 +0000 UTC", | ||
"duration": 6000, | ||
"amount": 0, | ||
"call_time_limit": 14400, | ||
"ring_timeout": 120, | ||
"first_party_play_url": "https://s3.amazonaws.com/plivosamplexml/play_url.xml", | ||
"second_party_play_url": "https://plivobin-prod-usw.plivops.com/api/v1/speak.xml", | ||
"record": false, | ||
"record_file_format": "mp3", | ||
"recording_callback_url": "https://plivobin-prod-usw.plivops.com/api/v1/speak.xml", | ||
"recording_callback_method": "GET", | ||
"interaction": null, | ||
"total_call_amount": 0, | ||
"total_call_count": 0, | ||
"total_call_billed_duration": 0, | ||
"total_session_amount": 0, | ||
"last_interaction_time": "" | ||
} | ||
} |
Oops, something went wrong.