diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 00000000..c4745eb8 Binary files /dev/null and b/.DS_Store differ diff --git a/plivo/resources/addresses.py b/plivo/resources/addresses.py index 899c8f8e..0e6f9c17 100644 --- a/plivo/resources/addresses.py +++ b/plivo/resources/addresses.py @@ -68,6 +68,8 @@ def create(self, region, postal_code, address_proof_type, + phone_number_country, + number_type, alias=None, file_to_upload=None, auto_correct_address=None, @@ -116,6 +118,8 @@ def create(self, salutation=[all_of(of_type(six.text_type), is_in(('Mr', 'Ms')))], first_name=[of_type(six.text_type)], last_name=[of_type(six.text_type)], + phone_number_country=[of_type(six.text_type)], + number_type=[of_type(six.text_type)], country_iso=[optional(of_type(six.text_type))], address_line1=[optional(of_type(six.text_type))], address_line2=[optional(of_type(six.text_type))], diff --git a/plivo/resources/applications.py b/plivo/resources/applications.py index 5b2462b1..055f0d9e 100755 --- a/plivo/resources/applications.py +++ b/plivo/resources/applications.py @@ -2,9 +2,10 @@ """ Application class - along with its list class """ - -from plivo.base import (ListResponseObject, PlivoResource, - PlivoResourceInterface) +from plivo.base import (ListResponseObject, + PlivoResource, + PlivoResourceInterface + ) from plivo.resources.accounts import Subaccount from plivo.utils import to_param_dict from plivo.utils.validators import * @@ -56,7 +57,8 @@ class Applications(PlivoResourceInterface): default_number_app=[optional(of_type_exact(bool))], default_endpoint_app=[optional(of_type_exact(bool))], subaccount=[optional(is_subaccount())], - log_incoming_messages = [optional(of_type_exact(bool))]) + log_incoming_messages = [optional(of_type_exact(bool))] + ) def create(self, answer_url, app_name, @@ -76,13 +78,15 @@ def create(self, if isinstance(subaccount, Subaccount): subaccount = subaccount.id - return self.client.request('POST', ('Application', ), - to_param_dict(self.create, locals())) + return self.client.request( + 'POST', ('Application', ), to_param_dict(self.create, locals()) + ) @validate_args(app_id=[of_type(six.text_type)]) def get(self, app_id): return self.client.request( - 'GET', ('Application', app_id), response_type=Application) + 'GET', ('Application', app_id), response_type=Application + ) @validate_args( subaccount=[optional(is_subaccount())], @@ -121,7 +125,8 @@ def list(self, subaccount=None, limit=20, offset=0): default_number_app=[optional(of_type_exact(bool))], default_endpoint_app=[optional(of_type_exact(bool))], subaccount=[optional(is_subaccount())], - log_incoming_messages=[optional(of_type_exact(bool))]) + log_incoming_messages=[optional(of_type_exact(bool))] + ) def update(self, app_id, answer_url, @@ -139,10 +144,12 @@ def update(self, if subaccount: if isinstance(subaccount, Subaccount): subaccount = subaccount.id - return self.client.request('POST', ('Application', app_id), - to_param_dict(self.update, locals())) + return self.client.request( + 'POST', ('Application', app_id), to_param_dict(self.update, locals()) + ) @validate_args(app_id=[of_type(six.text_type)]) def delete(self, app_id): - return self.client.request('DELETE', ('Application', app_id), - to_param_dict(self.update, locals())) + return self.client.request( + 'DELETE', ('Application', app_id), to_param_dict(self.update, locals()) + ) diff --git a/plivo/resources/calls.py b/plivo/resources/calls.py index 2884291e..45da3193 100755 --- a/plivo/resources/calls.py +++ b/plivo/resources/calls.py @@ -3,8 +3,10 @@ Call class - along with its list class """ -from plivo.base import (ListResponseObject, PlivoResource, - PlivoResourceInterface) +from plivo.base import (ListResponseObject, + PlivoResource, + PlivoResourceInterface + ) from plivo.utils import to_param_dict from plivo.utils.validators import * @@ -20,8 +22,9 @@ def update(self, aleg_method=None, bleg_url=None, bleg_method=None): - return self.client.calls.update(call_uuid, - **to_param_dict(self.update, locals())) + return self.client.calls.update( + call_uuid, **to_param_dict(self.update, locals()) + ) def get(self): return self.client.calls.get(self.id) @@ -33,9 +36,10 @@ def record(self, transcription_url=None, transcription_method=None, callback_url=None, - callback_mathod=None): - return self.client.calls.record(self.id, - **to_param_dict(self.record, locals())) + callback_method=None): + return self.client.calls.record( + self.id, **to_param_dict(self.record, locals()) + ) def start_recording(self, time_limit=None, @@ -44,24 +48,28 @@ def start_recording(self, transcription_url=None, transcription_method=None, callback_url=None, - callback_mathod=None): - return self.client.calls.start_recording(self.id, - **to_param_dict( - self.start_recording, - locals())) + callback_method=None): + return self.client.calls.start_recording( + self.id, **to_param_dict( self.start_recording, locals()) + ) def stop_recording(self): return self.client.calls.stop_recording(self.id) def play(self, urls, length=None, legs=None, loop=None, mix=None): - return self.client.calls.play(self.id, - **to_param_dict(self.start_playing, - locals())) + return self.client.calls.play( + self.id, **to_param_dict(self.start_playing, locals()) + ) - def start_playing(self, urls, length=None, legs=None, loop=None, mix=None): - return self.client.calls.play(self.id, - **to_param_dict(self.start_playing, - locals())) + def start_playing(self, + urls, + length=None, + legs=None, + loop=None, + mix=None): + return self.client.calls.play( + self.id, **to_param_dict(self.start_playing, locals()) + ) def stop_playing(self): return self.client.calls.stop_playing(self.id) @@ -74,9 +82,9 @@ def speak(self, legs=None, loop=None, mix=None): - return self.client.calls.speak(self.id, - **to_param_dict(self.start_playing, - locals())) + return self.client.calls.speak( + self.id, **to_param_dict(self.start_playing, locals()) + ) def start_speaking(self, text, @@ -85,18 +93,17 @@ def start_speaking(self, legs=None, loop=None, mix=None): - return self.client.calls.start_speaking(self.id, - **to_param_dict( - self.start_playing, - locals())) + return self.client.calls.start_speaking( + self.id, **to_param_dict(self.start_playing, locals()) + ) def stop_speaking(self): return self.client.calls.stop_speaking(self.id) def send_digits(self, digits, leg): - return self.client.calls.send_digits(self.id, - **to_param_dict( - self.start_playing, locals())) + return self.client.calls.send_digits( + self.id, **to_param_dict(self.start_playing, locals()) + ) def delete(self): return self.client.calls.delete(self.id) @@ -122,14 +129,47 @@ class Calls(PlivoResourceInterface): machine_detection_url=[optional(is_url())], machine_detection_method=[optional(of_type(six.text_type))], caller_name=[optional(of_type(six.text_type))], + send_digits=[optional(of_type(six.text_type))], + send_on_preanswer=[optional(of_type_exact(bool))], + time_limit=[ + optional( + all_of( + of_type(*six.integer_types), + check(lambda time_limit: 0 < time_limit, message='0 < time_limit') + ) + ) + ], + hangup_on_ring=[ + optional( + all_of( + of_type(*six.integer_types), + check(lambda hangup_on_ring: 0 < hangup_on_ring, + message='0 < hangup_on_ring') + ) + ) + ], + machine_detection=[optional(of_type_exact(bool))], + machine_detection_time=[ + optional( + all_of( + of_type(*six.integer_types), + check(lambda machine_detection_time: 2000 <= machine_detection_time <= 10000, + message='2000 <= machine_detection_time <= 10000') + ) + ) + ], + sip_headers=[optional(of_type(six.text_type))], error_if_parent_not_found=[optional(of_type_exact(bool))], parent_call_uuid=[optional(of_type(six.text_type))], ring_timeout=[ - optional(of_type(*six.integer_types)), - check( - lambda ring_timeout: 0 <= ring_timeout, - message='0 <= ring_timeout') - ], + optional( + all_of( + of_type(*six.integer_types), + check(lambda ring_timeout: 0 < ring_timeout, #I have changed the value of ring_timeout to be greater than 0 since having it equal to zero won't make sense. + message='0 < ring_timeout') + ) + ) + ] ) def create(self, from_, @@ -147,7 +187,7 @@ def create(self, send_on_preanswer=False, time_limit=None, hangup_on_ring=None, - machine_detection=None, + machine_detection=False, machine_detection_time=5000, machine_detection_url=None, machine_detection_method='POST', @@ -158,8 +198,9 @@ def create(self, if from_ in to_.split('<'): raise ValidationError('src and destination cannot overlap') - return self.client.request('POST', ('Call', ), - to_param_dict(self.create, locals())) + return self.client.request( + 'POST', ('Call', ), to_param_dict(self.create, locals()) + ) @validate_args( subaccount=[optional(is_subaccount())], @@ -213,10 +254,7 @@ def list(self, hangup_cause_code=None, hangup_source=None): return self.client.request( - 'GET', - ('Call', ), - to_param_dict(self.list, locals()), - response_type=ListResponseObject, + 'GET', ('Call', ), to_param_dict(self.list, locals()), response_type=ListResponseObject ) @validate_args(call_uuid=[of_type(six.text_type)]) @@ -232,6 +270,7 @@ def get(self, call_uuid): bleg_method=[optional(of_type(six.text_type))], bleg_url=[optional(is_url())], ) + def update(self, call_uuid, legs=None, @@ -239,8 +278,19 @@ def update(self, aleg_method=None, bleg_url=None, bleg_method=None): - return self.client.request('POST', ('Call', call_uuid), - to_param_dict(self.update, locals())) + return self.client.request( + 'POST', ('Call', call_uuid), to_param_dict(self.update, locals()) + ) + + @validate_args( + call_uuid=[of_type(six.text_type)], + legs=[of_type(six.text_type), + is_in(('aleg', 'bleg', 'both'))], + aleg_url=[optional(is_url())], + aleg_method=[optional(of_type(six.text_type))], + bleg_method=[optional(of_type(six.text_type))], + bleg_url=[optional(is_url())], + ) def transfer(self, call_uuid, @@ -257,7 +307,25 @@ def transfer(self, bleg_url=bleg_url, bleg_method=bleg_method) - @validate_args(call_uuid=[of_type(six.text_type)]) + @validate_args( + call_uuid=[of_type(six.text_type)], + time_limit=[ + optional( + all_of( + of_type(*six.integer_types), + check(lambda time_limit: 0 < time_limit, message='0 < time_limit') + ) + ) + ], + file_format=[optional(of_type(six.text_type))], + transcription_type=[ + optional(of_type(six.text_type), is_in(('auto', 'hybrid'))) + ], + transcription_url=[optional(is_url())], + transcription_method=[optional(of_type(six.text_type))], + callback_url=[optional(is_url())], + callback_method=[optional(of_type(six.text_type))] + ) def record(self, call_uuid, time_limit=None, @@ -266,11 +334,30 @@ def record(self, transcription_url=None, transcription_method=None, callback_url=None, - callback_mathod=None): - return self.start_recording(**to_param_dict(self.start_recording, - locals())) + callback_method=None): + return self.start_recording( + **to_param_dict(self.start_recording, locals()) + ) - @validate_args(call_uuid=[of_type(six.text_type)]) + @validate_args( + call_uuid=[of_type(six.text_type)], + time_limit=[ + optional( + all_of( + of_type(*six.integer_types), + check(lambda time_limit: 0 < time_limit, message='0 < time_limit') + ) + ) + ], + file_format=[optional(of_type(six.text_type))], + transcription_type=[ + optional(of_type(six.text_type), is_in(('auto', 'hybrid'))) + ], + transcription_url=[optional(is_url())], #will validate entered value. + transcription_method=[optional(of_type(six.text_type))], + callback_url=[optional(is_url())], #will validate entered value. + callback_method=[optional(of_type(six.text_type))] + ) def start_recording(self, call_uuid, time_limit=None, @@ -279,102 +366,239 @@ def start_recording(self, transcription_url=None, transcription_method=None, callback_url=None, - callback_mathod=None): - return self.client.request('POST', ('Call', call_uuid, 'Record'), - to_param_dict(self.start_recording, - locals())) + callback_method=None): + return self.client.request( + 'POST', ( + 'Call', call_uuid, 'Record'), to_param_dict( + self.start_recording, locals() + ) + ) + @validate_args( + call_uuid=[of_type(six.text_type)] + ) def record_stop(self, call_uuid): return self.client.calls.stop_recording(call_uuid) - @validate_args(call_uuid=[of_type(six.text_type)]) + @validate_args( + call_uuid=[of_type(six.text_type)] + ) def stop_recording(self, call_uuid): - return self.client.request('DELETE', ('Call', call_uuid, 'Record')) + return self.client.request( + 'DELETE', ('Call', call_uuid, 'Record') + ) + + @validate_args( + call_uuid=[of_type(six.text_type)], + urls=[is_url()], + length=[ + optional( + all_of( + of_type(*six.integer_types), + check(lambda length: 0 < length, + message='0 < length') + ) + ) + ], + legs=[ + optional(of_type(six.text_type), + is_in(('aleg', 'bleg', 'both'))) + ], + loop=[optional(of_type_exact(bool))], + mix=[optional(of_type_exact(bool))] + ) - @validate_args(call_uuid=[of_type(six.text_type)]) def play(self, call_uuid, urls, length=None, legs=None, - loop=None, - mix=None): - return self.start_playing(**to_param_dict(self.play, locals())) + loop=False, + mix=True): + return self.start_playing( + **to_param_dict(self.play, locals()) + ) - @validate_args(call_uuid=[of_type(six.text_type)]) + @validate_args( + call_uuid=[of_type(six.text_type)], + urls=[is_url()], + length=[ + optional( + all_of( + of_type(*six.integer_types), + check(lambda length: 0 < length, + message='0 < length') + ) + ) + ], + legs=[ + optional(of_type(six.text_type), + is_in(('aleg', 'bleg', 'both'))) + ], + loop=[optional(of_type_exact(bool))], + mix=[optional(of_type_exact(bool))] + ) def start_playing(self, call_uuid, urls, length=None, legs=None, - loop=None, - mix=None): - return self.client.request('POST', ('Call', call_uuid, 'Play'), - to_param_dict(self.play, locals())) + loop=False, + mix=True): + return self.client.request( + 'POST', ('Call', call_uuid, 'Play'), to_param_dict(self.play, locals()) + ) + @validate_args( + call_uuid=[of_type(six.text_type)], + ) def play_stop(self, call_uuid): return self.client.calls.stop_playing(call_uuid) - @validate_args(call_uuid=[of_type(six.text_type)]) + @validate_args( + call_uuid=[of_type(six.text_type)] + ) def stop_playing(self, call_uuid): - return self.client.request('DELETE', ('Call', call_uuid, 'Play')) + return self.client.request( + 'DELETE', ('Call', call_uuid, 'Play') + ) - @validate_args(call_uuid=[of_type(six.text_type)]) + @validate_args( + call_uuid=[of_type(six.text_type)], + text=[of_type(six.text_type)], + voice=[optional(of_type(six.text_type))], + language=[optional(of_type(six.text_type))], + legs=[ + optional(of_type(six.text_type), + is_in(('aleg', 'bleg', 'both'))) + ], + loop=[optional(of_type_exact(bool))], + mix=[optional(of_type_exact(bool))] + ) def speak(self, call_uuid, text, - voice=None, + voice='WOMAN', language=None, legs=None, - loop=None, - mix=None): - return self.start_speaking(call_uuid, text, voice, language, legs, - loop, mix) + loop=False, + mix=True): + return self.start_speaking( + call_uuid, text, voice, language, legs, loop, mix + ) - @validate_args(call_uuid=[of_type(six.text_type)]) + @validate_args( + call_uuid=[of_type(six.text_type)], + text=[of_type(six.text_type)], + voice=[optional(of_type(six.text_type))], + language=[optional(of_type(six.text_type))], + legs=[ + optional(of_type(six.text_type), + is_in(('aleg', 'bleg', 'both'))) + ], + loop=[optional(of_type_exact(bool))], + mix=[optional(of_type_exact(bool))] + ) def start_speaking(self, call_uuid, text, - voice=None, + voice='WOMAN', language=None, legs=None, - loop=None, - mix=None): - return self.client.request('POST', ('Call', call_uuid, 'Speak'), - to_param_dict(self.start_speaking, - locals())) + loop=False, + mix=True): + return self.client.request( + 'POST', ('Call', call_uuid, 'Speak'), to_param_dict(self.start_speaking, locals()) + ) - @validate_args(call_uuid=[of_type(six.text_type)]) + @validate_args( + call_uuid=[of_type(six.text_type)] + ) def stop_speaking(self, call_uuid): return self.client.request('DELETE', ('Call', call_uuid, 'Speak')) + @validate_args( + call_uuid=[of_type(six.text_type)] + ) def speak_stop(self, call_uuid): return self.client.calls.stop_speaking(call_uuid) - @validate_args(call_uuid=[of_type(six.text_type)]) - def send_digits(self, call_uuid, digits, leg=None): - return self.client.request('POST', ('Call', call_uuid, 'DTMF'), - to_param_dict(self.send_digits, locals())) + @validate_args( + call_uuid=[of_type(six.text_type)], + digits=[of_type(six.text_type)], + leg=[ + optional(of_type(six.text_type), + is_in(('aleg', 'bleg'))) + ], + ) + def send_digits(self, call_uuid, digits, leg='aleg'): + return self.client.request( + 'POST', ('Call', call_uuid, 'DTMF'), to_param_dict(self.send_digits, locals()) + ) - @validate_args(call_uuid=[of_type(six.text_type)]) + @validate_args( + call_uuid=[of_type(six.text_type)] + ) def delete(self, call_uuid): return self.client.request('DELETE', ('Call', call_uuid)) - @validate_args(call_uuid=[of_type(six.text_type)]) + @validate_args( + call_uuid=[of_type(six.text_type)] + ) def hangup(self, call_uuid): return self.client.calls.delete(call_uuid) + @validate_args( + request_uuid=[of_type(six.text_type)] + ) def cancel(self, request_uuid): - return self.client.request('DELETE', ('Request', request_uuid)) + return self.client.request( + 'DELETE', ('Request', request_uuid) + ) + @validate_args( + request_uuid=[of_type(six.text_type)], + limit=[ + optional( + all_of( + of_type(*six.integer_types), + check(lambda limit: 0 < limit <= 20, '0 < limit <= 20'))) + ], + offset=[ + optional( + all_of( + of_type(*six.integer_types), + check(lambda offset: 0 <= offset, '0 <= offset'))) + ] + ) def live_call_list_ids(self, limit=None, offset=None): return self.client.live_calls.list_ids(limit, offset) + @validate_args( + _id=[of_type(six.text_type)] + ) def live_call_get(self, _id): return self.client.live_calls.get(_id) + @validate_args( + limit=[ + optional( + all_of( + of_type(*six.integer_types), + check(lambda limit: 0 < limit <= 20, '0 < limit <= 20'))) + ], + offset=[ + optional( + all_of( + of_type(*six.integer_types), + check(lambda offset: 0 <= offset, '0 <= offset'))) + ] + ) def queued_call_list_ids(self, limit=None, offset=None): return self.client.queued_calls.list_ids(limit, offset) + @validate_args( + _id=[of_type(six.text_type)] + ) def queued_call_get(self, _id): return self.client.queued_calls.get(_id) diff --git a/plivo/resources/conferences.py b/plivo/resources/conferences.py index c65144e1..a3756501 100755 --- a/plivo/resources/conferences.py +++ b/plivo/resources/conferences.py @@ -2,10 +2,9 @@ """ Conference class - along with its list class """ - from plivo.base import PlivoResource, PlivoResourceInterface -from plivo.exceptions import InvalidRequestError from plivo.utils import to_param_dict +from plivo.utils.validators import * class ConferenceMember(PlivoResource): @@ -50,18 +49,22 @@ def member_play(self, member_id, url): def member_play_stop(self, member_id): return self.client.conferences.member_play_stop( - self.conference_name, member_id) + self.conference_name, member_id + ) - def member_speak(self, member_id, text, voice=None, language=None): - return self.client.conferences.member_speak(self.conference_name, - member_id, text, - **to_param_dict( - self.member_speak, - locals())) + def member_speak(self, + member_id, + text, + voice="WOMAN", #Changed the value to "WOMAN" since the default value is WOMAN + language=None): + return self.client.conferences.member_speak( + self.conference_name, member_id, text, **to_param_dict( self.member_speak, locals()) + ) def member_speak_stop(self, member_id): return self.client.conferences.member_speak_stop( - self.conference_name, member_id) + self.conference_name, member_id + ) def record(self, file_format=None, @@ -70,9 +73,9 @@ def record(self, transcription_method=None, callback_url=None, callback_method=None): - return self.client.conferences.record(self.conference_name, - **to_param_dict( - self.member_speak, locals())) + return self.client.conferences.record( + self.conference_name, **to_param_dict(self.member_speak, locals()) + ) def record_stop(self): return self.client.conferences.record_stop(self.conference_name) @@ -85,88 +88,163 @@ class Conferences(PlivoResourceInterface): def list(self): return self.client.request('GET', ('Conference', )) + @validate_args( + conference_name=[of_type(six.text_type)] + ) def get(self, conference_name): - return self.client.request('GET', ('Conference', conference_name)) + return self.client.request( + 'GET', ('Conference', conference_name) + ) + @validate_args( + conference_name=[of_type(six.text_type)] + ) def delete(self, conference_name): - return self.client.request('DELETE', ('Conference', conference_name)) + return self.client.request( + 'DELETE', ('Conference', conference_name) + ) def delete_all(self): - return self.client.request('DELETE', ('Conference', )) + return self.client.request( + 'DELETE', ('Conference', ) + ) def hangup_all(self): return self.delete_all() + @validate_args( + conference_name=[of_type(six.text_type)] + ) def hangup(self, conference_name): return self.delete(conference_name) + @validate_args( + conference_name=[of_type(six.text_type)], + member_id=[of_type(six.text_type)], + text=[of_type(six.text_type)], + voice=[optional(of_type(six.text_type))], + language=[optional(of_type(six.text_type))], + ) def member_speak(self, conference_name, member_id, text, - voice=None, - language=None): + voice="WOMAN", #Changed the value to "WOMAN" since the default value is WOMAN + language=None + ): return self.client.request( - 'POST', - ('Conference', conference_name, 'Member', member_id, 'Speak'), - to_param_dict(self.member_speak, locals())) - + 'POST', ('Conference', conference_name, 'Member', member_id, 'Speak'), + to_param_dict(self.member_speak, locals()) + ) + + @validate_args( + conference_name=[of_type(six.text_type)], + member_id=[of_type(six.text_type)], + url=[is_url()], + ) def member_play(self, conference_name, member_id, url): return self.client.request( - 'POST', - ('Conference', conference_name, 'Member', member_id, 'Play'), - to_param_dict(self.member_play, locals())) - + 'POST', ('Conference', conference_name, 'Member', member_id, 'Play'), + to_param_dict(self.member_play, locals()) + ) + + @validate_args( + conference_name=[of_type(six.text_type)], + member_id=[of_type(six.text_type)], + ) def member_deaf(self, conference_name, member_id): return self.client.request( - 'POST', - ('Conference', conference_name, 'Member', member_id, 'Deaf')) + 'POST', ('Conference', conference_name, 'Member', member_id, 'Deaf') + ) + @validate_args( + conference_name=[of_type(six.text_type)], + member_id=[of_type(six.text_type)], + ) def member_mute(self, conference_name, member_id): return self.client.request( - 'POST', - ('Conference', conference_name, 'Member', member_id, 'Mute')) + 'POST', ('Conference', conference_name, 'Member', member_id, 'Mute') + ) + @validate_args( + conference_name=[of_type(six.text_type)], + member_id=[of_type(six.text_type)], + ) def member_speak_stop(self, conference_name, member_id): return self.client.request( - 'DELETE', - ('Conference', conference_name, 'Member', member_id, 'Speak')) + 'DELETE', ('Conference', conference_name, 'Member', member_id, 'Speak') + ) + @validate_args( + conference_name=[of_type(six.text_type)], + member_id=[of_type(six.text_type)], + ) def member_play_stop(self, conference_name, member_id): return self.client.request( - 'DELETE', - ('Conference', conference_name, 'Member', member_id, 'Play')) + 'DELETE', ('Conference', conference_name, 'Member', member_id, 'Play') + ) + @validate_args( + conference_name=[of_type(six.text_type)], + member_id=[of_type(six.text_type)], + ) def member_deaf_stop(self, conference_name, member_id): return self.client.request( - 'DELETE', - ('Conference', conference_name, 'Member', member_id, 'Deaf')) + 'DELETE', ('Conference', conference_name, 'Member', member_id, 'Deaf') + ) + @validate_args( + conference_name=[of_type(six.text_type)], + member_id=[of_type(six.text_type)], + ) def member_mute_stop(self, conference_name, member_id): return self.client.request( - 'DELETE', - ('Conference', conference_name, 'Member', member_id, 'Mute')) + 'DELETE', ('Conference', conference_name, 'Member', member_id, 'Mute') + ) + @validate_args( + conference_name=[of_type(six.text_type)], + member_id=[of_type(six.text_type)], + ) def member_kick(self, conference_name, member_id): return self.client.request( - 'POST', - ('Conference', conference_name, 'Member', member_id, 'Kick')) + 'POST', ('Conference', conference_name, 'Member', member_id, 'Kick') + ) + @validate_args( + conference_name=[of_type(six.text_type)], + member_id=[of_type(six.text_type)], + ) def member_hangup(self, conference_name, member_id): return self.client.request( - 'DELETE', ('Conference', conference_name, 'Member', member_id)) - + 'DELETE', ('Conference', conference_name, 'Member', member_id) + ) + + @validate_args( + conference_name=[of_type(six.text_type)], + file_format=[optional(of_type(six.text_type))], + transcription_type=[ + optional(of_type(six.text_type), is_in(('auto', 'hybrid'))) + ], + transcription_url=[optional(is_url())], #Changed the validation to 'is_url' + transcription_method=[optional(of_type(six.text_type))], + callback_url=[optional(is_url())], #Changed the validation to 'is_url' + callback_method=[optional(of_type(six.text_type))] + ) def record(self, conference_name, file_format=None, transcription_type=None, transcription_url=None, - transcription_method=None, + transcription_method="POST", #Changed the value to "POST" since the default value is POST callback_url=None, - callback_method=None): - return self.client.request('POST', - ('Conference', conference_name, 'Record')) + callback_method="POST" #Changed the value to "POST" since the default value is POST + ): + return self.client.request( + 'POST', ('Conference', conference_name, 'Record') + ) def record_stop(self, conference_name): - return self.client.request('DELETE', - ('Conference', conference_name, 'Record')) + return self.client.request( + 'DELETE', ('Conference', conference_name, 'Record') + ) diff --git a/plivo/resources/identities.py b/plivo/resources/identities.py index b4bb4c0e..4eff5791 100644 --- a/plivo/resources/identities.py +++ b/plivo/resources/identities.py @@ -34,7 +34,8 @@ def update(self, subaccount=None, file_to_upload=None, auto_correct_address=None, - callback_url=None): + callback_url=None, + url=None,): #One of param which was missing. return self.client.identities.update( self.id, country_iso, salutation, first_name, last_name, birth_place, birth_date, nationality, id_nationality, @@ -157,9 +158,9 @@ def update(self, street_code=None, municipal_code=None, subaccount=None, - file_to_upload=None, + file_to_upload=None, # Value in doc 'file' auto_correct_address=None, - callback_url=None): + callback_url=None,): if file_to_upload: file_extension = file_to_upload.strip().split('.')[-1].lower() if file_extension not in ['jpg', 'jpeg', 'png', 'pdf']: diff --git a/plivo/resources/messages.py b/plivo/resources/messages.py index 750e9c78..d75f740b 100755 --- a/plivo/resources/messages.py +++ b/plivo/resources/messages.py @@ -33,6 +33,7 @@ class Messages(PlivoResourceInterface): log=[optional(of_type_exact(bool))], trackable=[optional(of_type_exact(bool))], powerpack_uuid=[optional(of_type(six.text_type))]) + def create(self, dst, text, @@ -86,7 +87,11 @@ def get(self, message_uuid): all_of( of_type(*six.integer_types), check(lambda offset: 0 <= offset, '0 <= offset'))) - ]) + ], + error_code=[optional(is_in(('10','20','30','40','50','60','70','80','90', + '100','110','201','1000')))] + ) #validating error codes. + def list(self, subaccount=None, message_direction=None, diff --git a/plivo/resources/numbers.py b/plivo/resources/numbers.py index 522dd43b..7bd25592 100755 --- a/plivo/resources/numbers.py +++ b/plivo/resources/numbers.py @@ -53,6 +53,7 @@ def search(self, to_param_dict(self.search, locals())) @validate_args( + country_iso=[(is_countryiso())], services=[ optional( is_iterable( @@ -79,10 +80,7 @@ def list(self, services=None, limit=20, offset=0): - return self.client.request( - 'GET', - ('Number', ), - to_param_dict(self.list, locals()), + return self.client.request('GET',('Number', ),to_param_dict(self.list, locals()), objects_type=Number, response_type=ListResponseObject, ) diff --git a/plivo/rest/client.py b/plivo/rest/client.py index 6f8670b2..64667738 100644 --- a/plivo/rest/client.py +++ b/plivo/rest/client.py @@ -53,7 +53,6 @@ class Client(object): def __init__(self, auth_id=None, auth_token=None, proxies=None, timeout=5): """ The Plivo API client. - Deals with all the API requests to be made. """