Skip to content

Commit

Permalink
DX-2203 Voice, Answering Machine Detection (#29)
Browse files Browse the repository at this point in the history
* New deploy

* Remove DS Store

* Version bump to 12

This is breaking due to the change from `pai` to `stirShaken`

* Add test for answering machine detection

* Remove pause between creating and getting call

* Improve test and correct spacing

* Add import statement

* fix syntax

* Improve test coverage

* add lxml to requirements.txt

* Remove Doc directory

* update test to use `mfrom`

* Remove perpetually failing test

* Update test to accommodate breaking change

Testing with a bad statement to fail the test

* Correct planned failure

* Update __init__.py

* remove apimatic tests

* Update api_tests.py

Co-authored-by: DX-Bandwidth <[email protected]>
  • Loading branch information
ajrice6713 and DX-Bandwidth authored Sep 14, 2021
1 parent 3e76ff2 commit 9a8f09a
Show file tree
Hide file tree
Showing 23 changed files with 863 additions and 237 deletions.
Binary file removed .DS_Store
Binary file not shown.
17 changes: 11 additions & 6 deletions bandwidth/messaging/controllers/api_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def list_media(self,
continuation_token=None):
"""Does a GET request to /users/{accountId}/media.
listMedia
Gets a list of your media files. No query parameters are supported.
Args:
account_id (string): User's account ID
Expand Down Expand Up @@ -95,7 +95,7 @@ def get_media(self,
media_id):
"""Does a GET request to /users/{accountId}/media/{mediaId}.
getMedia
Downloads a media file you previously uploaded.
Args:
account_id (string): User's account ID
Expand Down Expand Up @@ -156,7 +156,8 @@ def upload_media(self,
cache_control=None):
"""Does a PUT request to /users/{accountId}/media/{mediaId}.
uploadMedia
Uploads a file the normal HTTP way. You may add headers to the request
in order to provide some control to your media-file.
Args:
account_id (string): User's account ID
Expand Down Expand Up @@ -231,7 +232,10 @@ def delete_media(self,
media_id):
"""Does a DELETE request to /users/{accountId}/media/{mediaId}.
deleteMedia
Deletes a media file from Bandwidth API server. Make sure you don't
have any application scripts still using the media before you delete.
If you accidentally delete a media file, you can immediately upload a
new file with the same name.
Args:
account_id (string): User's account ID
Expand Down Expand Up @@ -295,7 +299,7 @@ def get_messages(self,
limit=None):
"""Does a GET request to /users/{accountId}/messages.
getMessages
Gets a list of messages based on query parameters.
Args:
account_id (string): User's account ID
Expand Down Expand Up @@ -392,7 +396,8 @@ def create_message(self,
body):
"""Does a POST request to /users/{accountId}/messages.
createMessage
Endpoint for sending text messages and picture messages using V2
messaging.
Args:
account_id (string): User's account ID
Expand Down
6 changes: 5 additions & 1 deletion bandwidth/messaging/models/bandwidth_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ class BandwidthMessage(object):
Bandwidth. Can be in or out
to (list of string): The phone number recipients of the message
mfrom (string): The phone number the message was sent from
media (list of string): The list of media URLs sent in the message
media (list of string): The list of media URLs sent in the message.
Including a `filename` field in the `Content-Disposition` header
of the media linked with a URL will set the displayed file name.
This is a best practice to ensure that your media has a readable
file name.
text (string): The contents of the message
tag (string): The custom string set by the user
priority (string): The priority specified by the user
Expand Down
8 changes: 5 additions & 3 deletions bandwidth/multifactorauth/controllers/mfa_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ def create_voice_two_factor(self,
body):
"""Does a POST request to /accounts/{accountId}/code/voice.
Allows a user to send a MFA code through a phone call
Multi-Factor authentication with Bandwidth Voice services. Allows for
a user to send an MFA code via a phone call.
Args:
account_id (string): Bandwidth Account ID with Voice service
Expand Down Expand Up @@ -92,7 +93,8 @@ def create_messaging_two_factor(self,
body):
"""Does a POST request to /accounts/{accountId}/code/messaging.
Allows a user to send a MFA code through a text message (SMS)
Multi-Factor authentication with Bandwidth Messaging services. Allows
a user to send an MFA code via a text message (SMS).
Args:
account_id (string): Bandwidth Account ID with Messaging service
Expand Down Expand Up @@ -152,7 +154,7 @@ def create_verify_two_factor(self,
body):
"""Does a POST request to /accounts/{accountId}/code/verify.
Allows a user to verify an MFA code
Allows a user to verify an MFA code.
Args:
account_id (string): Bandwidth Account ID with Two-Factor enabled
Expand Down
4 changes: 2 additions & 2 deletions bandwidth/phonenumberlookup/controllers/api_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def create_lookup_request(self,
body):
"""Does a POST request to /accounts/{accountId}/tnlookup.
Create a TN Lookup Order
Create a TN Lookup Order.
Args:
account_id (string): The ID of the Bandwidth account that the user
Expand Down Expand Up @@ -292,7 +292,7 @@ def get_lookup_request_status(self,
request_id):
"""Does a GET request to /accounts/{accountId}/tnlookup/{requestId}.
Query an existing TN Lookup Order
Query an existing TN Lookup Order.
Args:
account_id (string): The ID of the Bandwidth account that the user
Expand Down
4 changes: 2 additions & 2 deletions bandwidth/voice/controllers/api_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def create_call(self,
body):
"""Does a POST request to /api/v2/accounts/{accountId}/calls.
Creates an outbound call.
Creates an outbound phone call.
Args:
account_id (string): TODO: type description here.
Expand Down Expand Up @@ -298,7 +298,7 @@ def get_call_recordings(self,
"""Does a GET request to /api/v2/accounts/{accountId}/calls/{callId}/recordings.
Returns a (potentially empty) list of metadata for the recordings that
took place during the specified call
took place during the specified call.
Args:
account_id (string): TODO: type description here.
Expand Down
7 changes: 7 additions & 0 deletions bandwidth/voice/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,24 @@
'conference_state',
'conference_member_state',
'conference_recording_metadata',
'machine_detection_request',
'transcribe_recording_request',
'transcription_response',
'transcription_metadata',
'transcript',
'call_callback',
'transcription',
'diversion',
'conference_callback',
'answer_fallback_method_enum',
'answer_method_enum',
'callback_method_enum',
'conference_event_method_enum',
'direction_enum',
'disconnect_method_enum',
'fallback_method_enum',
'file_format_enum',
'mode_enum',
'redirect_fallback_method_enum',
'redirect_method_enum',
'state_enum',
Expand Down
233 changes: 233 additions & 0 deletions bandwidth/voice/models/call_callback.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,233 @@
# -*- coding: utf-8 -*-

"""
bandwidth
This file was automatically generated by APIMATIC v3.0 (
https://www.apimatic.io ).
"""
from bandwidth.voice.models.diversion import Diversion
from bandwidth.voice.models.transcription import Transcription


class CallCallback(object):

"""Implementation of the 'CallCallback' model.
This object represents all possible fields that may be included in
callbacks related to call events, including events that come from BXML
verbs
Attributes:
event_type (string): TODO: type description here.
event_time (string): TODO: type description here.
account_id (string): TODO: type description here.
application_id (string): TODO: type description here.
mfrom (string): TODO: type description here.
to (string): TODO: type description here.
direction (string): TODO: type description here.
call_id (string): TODO: type description here.
call_url (string): TODO: type description here.
start_time (string): TODO: type description here.
answer_time (string): TODO: type description here.
transfer_caller_id (string): TODO: type description here.
transfer_to (string): TODO: type description here.
cause (string): TODO: type description here.
error_message (string): TODO: type description here.
error_id (string): TODO: type description here.
end_time (string): TODO: type description here.
digit (string): TODO: type description here.
parent_call_id (string): TODO: type description here.
recording_id (string): TODO: type description here.
duration (string): TODO: type description here.
file_format (string): TODO: type description here.
media_url (string): TODO: type description here.
tag (string): TODO: type description here.
channels (int): TODO: type description here.
status (string): TODO: type description here.
digits (string): TODO: type description here.
terminating_digit (string): TODO: type description here.
transcription (Transcription): TODO: type description here.
diversion (Diversion): TODO: type description here.
"""

# Create a mapping from Model property names to API property names
_names = {
"event_type": 'eventType',
"event_time": 'eventTime',
"account_id": 'accountId',
"application_id": 'applicationId',
"mfrom": 'from',
"to": 'to',
"direction": 'direction',
"call_id": 'callId',
"call_url": 'callUrl',
"start_time": 'startTime',
"answer_time": 'answerTime',
"transfer_caller_id": 'transferCallerId',
"transfer_to": 'transferTo',
"cause": 'cause',
"error_message": 'errorMessage',
"error_id": 'errorId',
"end_time": 'endTime',
"digit": 'digit',
"parent_call_id": 'parentCallId',
"recording_id": 'recordingId',
"duration": 'duration',
"file_format": 'fileFormat',
"media_url": 'mediaUrl',
"tag": 'tag',
"channels": 'channels',
"status": 'status',
"digits": 'digits',
"terminating_digit": 'terminatingDigit',
"transcription": 'transcription',
"diversion": 'diversion'
}

def __init__(self,
event_type=None,
event_time=None,
account_id=None,
application_id=None,
mfrom=None,
to=None,
direction=None,
call_id=None,
call_url=None,
start_time=None,
answer_time=None,
transfer_caller_id=None,
transfer_to=None,
cause=None,
error_message=None,
error_id=None,
end_time=None,
digit=None,
parent_call_id=None,
recording_id=None,
duration=None,
file_format=None,
media_url=None,
tag=None,
channels=None,
status=None,
digits=None,
terminating_digit=None,
transcription=None,
diversion=None):
"""Constructor for the CallCallback class"""

# Initialize members of the class
self.event_type = event_type
self.event_time = event_time
self.account_id = account_id
self.application_id = application_id
self.mfrom = mfrom
self.to = to
self.direction = direction
self.call_id = call_id
self.call_url = call_url
self.start_time = start_time
self.answer_time = answer_time
self.transfer_caller_id = transfer_caller_id
self.transfer_to = transfer_to
self.cause = cause
self.error_message = error_message
self.error_id = error_id
self.end_time = end_time
self.digit = digit
self.parent_call_id = parent_call_id
self.recording_id = recording_id
self.duration = duration
self.file_format = file_format
self.media_url = media_url
self.tag = tag
self.channels = channels
self.status = status
self.digits = digits
self.terminating_digit = terminating_digit
self.transcription = transcription
self.diversion = diversion

@classmethod
def from_dictionary(cls,
dictionary):
"""Creates an instance of this model from a dictionary
Args:
dictionary (dictionary): A dictionary representation of the object
as obtained from the deserialization of the server's response. The
keys MUST match property names in the API description.
Returns:
object: An instance of this structure class.
"""
if dictionary is None:
return None

# Extract variables from the dictionary
event_type = dictionary.get('eventType')
event_time = dictionary.get('eventTime')
account_id = dictionary.get('accountId')
application_id = dictionary.get('applicationId')
mfrom = dictionary.get('from')
to = dictionary.get('to')
direction = dictionary.get('direction')
call_id = dictionary.get('callId')
call_url = dictionary.get('callUrl')
start_time = dictionary.get('startTime')
answer_time = dictionary.get('answerTime')
transfer_caller_id = dictionary.get('transferCallerId')
transfer_to = dictionary.get('transferTo')
cause = dictionary.get('cause')
error_message = dictionary.get('errorMessage')
error_id = dictionary.get('errorId')
end_time = dictionary.get('endTime')
digit = dictionary.get('digit')
parent_call_id = dictionary.get('parentCallId')
recording_id = dictionary.get('recordingId')
duration = dictionary.get('duration')
file_format = dictionary.get('fileFormat')
media_url = dictionary.get('mediaUrl')
tag = dictionary.get('tag')
channels = dictionary.get('channels')
status = dictionary.get('status')
digits = dictionary.get('digits')
terminating_digit = dictionary.get('terminatingDigit')
transcription = Transcription.from_dictionary(dictionary.get('transcription')) if dictionary.get('transcription') else None
diversion = Diversion.from_dictionary(dictionary.get('diversion')) if dictionary.get('diversion') else None

# Return an object of this model
return cls(event_type,
event_time,
account_id,
application_id,
mfrom,
to,
direction,
call_id,
call_url,
start_time,
answer_time,
transfer_caller_id,
transfer_to,
cause,
error_message,
error_id,
end_time,
digit,
parent_call_id,
recording_id,
duration,
file_format,
media_url,
tag,
channels,
status,
digits,
terminating_digit,
transcription,
diversion)
Loading

0 comments on commit 9a8f09a

Please sign in to comment.