Skip to content

Commit 408eb8b

Browse files
committed
Deploy
1 parent 0b0faaf commit 408eb8b

File tree

12 files changed

+119
-22
lines changed

12 files changed

+119
-22
lines changed

bandwidth/controllers/base_controller.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class BaseController(object):
2727
"""
2828

2929
global_headers = {
30-
'user-agent': 'python-sdk-refs/tags/python6.5.0'
30+
'user-agent': 'python-sdk-refs/tags/python6.6.0'
3131
}
3232

3333
def __init__(self, config, call_back=None):

bandwidth/messaging/controllers/base_controller.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class BaseController(object):
2727
"""
2828

2929
global_headers = {
30-
'user-agent': 'python-sdk-refs/tags/python6.5.0'
30+
'user-agent': 'python-sdk-refs/tags/python6.6.0'
3131
}
3232

3333
def __init__(self, config, call_back=None):
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
__all__ = [
22
'controllers',
3+
'exceptions',
34
'models',
45
'two_factor_auth_client',
56
]

bandwidth/twofactorauth/controllers/api_controller.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from bandwidth.twofactorauth.models.two_factor_voice_response import TwoFactorVoiceResponse
1515
from bandwidth.twofactorauth.models.two_factor_messaging_response import TwoFactorMessagingResponse
1616
from bandwidth.twofactorauth.models.two_factor_verify_code_response import TwoFactorVerifyCodeResponse
17+
from bandwidth.twofactorauth.exceptions.invalid_request_exception import InvalidRequestException
1718

1819

1920
class APIController(BaseController):
@@ -67,6 +68,10 @@ def create_voice_two_factor(self,
6768
_request = self.config.http_client.post(_query_url, headers=_headers, parameters=APIHelper.json_serialize(body))
6869
TwoFactorAuthBasicAuth.apply(self.config, _request)
6970
_response = self.execute_request(_request)
71+
72+
# Endpoint and global error handling using HTTP status codes.
73+
if _response.status_code == 400:
74+
raise InvalidRequestException('client request error', _response)
7075
self.validate_response(_response)
7176

7277
decoded = APIHelper.json_deserialize(_response.text, TwoFactorVoiceResponse.from_dictionary)
@@ -117,6 +122,10 @@ def create_messaging_two_factor(self,
117122
_request = self.config.http_client.post(_query_url, headers=_headers, parameters=APIHelper.json_serialize(body))
118123
TwoFactorAuthBasicAuth.apply(self.config, _request)
119124
_response = self.execute_request(_request)
125+
126+
# Endpoint and global error handling using HTTP status codes.
127+
if _response.status_code == 400:
128+
raise InvalidRequestException('client request error', _response)
120129
self.validate_response(_response)
121130

122131
decoded = APIHelper.json_deserialize(_response.text, TwoFactorMessagingResponse.from_dictionary)
@@ -166,6 +175,10 @@ def create_verify_two_factor(self,
166175
_request = self.config.http_client.post(_query_url, headers=_headers, parameters=APIHelper.json_serialize(body))
167176
TwoFactorAuthBasicAuth.apply(self.config, _request)
168177
_response = self.execute_request(_request)
178+
179+
# Endpoint and global error handling using HTTP status codes.
180+
if _response.status_code == 400:
181+
raise InvalidRequestException('client request error', _response)
169182
self.validate_response(_response)
170183

171184
decoded = APIHelper.json_deserialize(_response.text, TwoFactorVerifyCodeResponse.from_dictionary)

bandwidth/twofactorauth/controllers/base_controller.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class BaseController(object):
2727
"""
2828

2929
global_headers = {
30-
'user-agent': 'python-sdk-refs/tags/python6.5.0'
30+
'user-agent': 'python-sdk-refs/tags/python6.6.0'
3131
}
3232

3333
def __init__(self, config, call_back=None):
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
__all__ = [
2+
'invalid_request_exception',
3+
]
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# -*- coding: utf-8 -*-
2+
3+
"""
4+
bandwidth
5+
6+
This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
7+
"""
8+
9+
from bandwidth.api_helper import APIHelper
10+
import bandwidth.exceptions.api_exception
11+
12+
13+
class InvalidRequestException(bandwidth.exceptions.api_exception.APIException):
14+
def __init__(self, reason, response):
15+
"""Constructor for the InvalidRequestException class
16+
17+
Args:
18+
reason (string): The reason (or error message) for the Exception
19+
to be raised.
20+
response (HttpResponse): The HttpResponse of the API call.
21+
22+
"""
23+
super(InvalidRequestException, self).__init__(reason, response)
24+
dictionary = APIHelper.json_deserialize(self.response.text)
25+
if isinstance(dictionary, dict):
26+
self.unbox(dictionary)
27+
28+
def unbox(self, dictionary):
29+
"""Populates the properties of this object by extracting them from a dictionary.
30+
31+
Args:
32+
dictionary (dictionary): A dictionary representation of the object as
33+
obtained from the deserialization of the server's response. The keys
34+
MUST match property names in the API description.
35+
36+
"""
37+
self.result = dictionary.get('result')

bandwidth/twofactorauth/models/two_factor_code_request_schema.py

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,23 @@ class TwoFactorCodeRequestSchema(object):
1414
TODO: type model description here.
1515
1616
Attributes:
17-
to (string): TODO: type description here.
18-
mfrom (string): TODO: type description here.
19-
application_id (string): TODO: type description here.
20-
scope (string): TODO: type description here.
17+
to (string): The phone number to send the 2fa code to.
18+
mfrom (string): The application phone number, the sender of the 2fa
19+
code.
20+
application_id (string): The application unique ID, obtained from
21+
Bandwidth.
22+
scope (string): An optional field to denote what scope or action the
23+
2fa code is addressing. If not supplied, defaults to "2FA".
24+
message (string): The message format of the 2fa code. There are three
25+
values that the system will replace "{CODE}", "{NAME}", "{SCOPE}".
26+
The "{SCOPE}" and "{NAME} value template are optional, while
27+
"{CODE}" must be supplied. As the name would suggest, code will
28+
be replace with the actual 2fa code. Name is replaced with the
29+
application name, configured during provisioning of 2fa. The
30+
scope value is the same value sent during the call and partitioned
31+
by the server.
32+
digits (float): The number of digits for your 2fa code. The valid
33+
number ranges from 2 to 8, inclusively.
2134
2235
"""
2336

@@ -26,13 +39,17 @@ class TwoFactorCodeRequestSchema(object):
2639
"to": 'to',
2740
"mfrom": 'from',
2841
"application_id": 'applicationId',
42+
"message": 'message',
43+
"digits": 'digits',
2944
"scope": 'scope'
3045
}
3146

3247
def __init__(self,
3348
to=None,
3449
mfrom=None,
3550
application_id=None,
51+
message=None,
52+
digits=None,
3653
scope=None):
3754
"""Constructor for the TwoFactorCodeRequestSchema class"""
3855

@@ -41,6 +58,8 @@ def __init__(self,
4158
self.mfrom = mfrom
4259
self.application_id = application_id
4360
self.scope = scope
61+
self.message = message
62+
self.digits = digits
4463

4564
@classmethod
4665
def from_dictionary(cls,
@@ -63,10 +82,14 @@ def from_dictionary(cls,
6382
to = dictionary.get('to')
6483
mfrom = dictionary.get('from')
6584
application_id = dictionary.get('applicationId')
85+
message = dictionary.get('message')
86+
digits = dictionary.get('digits')
6687
scope = dictionary.get('scope')
6788

6889
# Return an object of this model
6990
return cls(to,
7091
mfrom,
7192
application_id,
93+
message,
94+
digits,
7295
scope)

bandwidth/twofactorauth/models/two_factor_verify_request_schema.py

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,21 @@ class TwoFactorVerifyRequestSchema(object):
1414
TODO: type model description here.
1515
1616
Attributes:
17-
to (string): TODO: type description here.
18-
mfrom (string): TODO: type description here.
19-
application_id (string): TODO: type description here.
20-
scope (string): TODO: type description here.
21-
code (string): TODO: type description here.
17+
to (string): The phone number to send the 2fa code to.
18+
mfrom (string): The application phone number, the sender of the 2fa
19+
code.
20+
application_id (string): The application unique ID, obtained from
21+
Bandwidth.
22+
scope (string): An optional field to denote what scope or action the
23+
2fa code is addressing. If not supplied, defaults to "2FA".
24+
digits (float): The number of digits for your 2fa code. The valid
25+
number ranges from 2 to 8, inclusively.
26+
expiration_time_in_minutes (float): The time period, in minutes, to
27+
validate the 2fa code. By setting this to 3 minutes, it will mean
28+
any code generated within the last 3 minutes are still valid. The
29+
valid range for expiration time is between 0 and 15 minutes,
30+
exclusively and inclusively, respectively.
31+
code (string): The generated 2fa code to check if valid
2232
2333
"""
2434

@@ -27,23 +37,29 @@ class TwoFactorVerifyRequestSchema(object):
2737
"to": 'to',
2838
"mfrom": 'from',
2939
"application_id": 'applicationId',
30-
"scope": 'scope',
31-
"code": 'code'
40+
"digits": 'digits',
41+
"expiration_time_in_minutes": 'expirationTimeInMinutes',
42+
"code": 'code',
43+
"scope": 'scope'
3244
}
3345

3446
def __init__(self,
3547
to=None,
3648
mfrom=None,
3749
application_id=None,
38-
scope=None,
39-
code=None):
50+
digits=None,
51+
expiration_time_in_minutes=None,
52+
code=None,
53+
scope=None):
4054
"""Constructor for the TwoFactorVerifyRequestSchema class"""
4155

4256
# Initialize members of the class
4357
self.to = to
4458
self.mfrom = mfrom
4559
self.application_id = application_id
4660
self.scope = scope
61+
self.digits = digits
62+
self.expiration_time_in_minutes = expiration_time_in_minutes
4763
self.code = code
4864

4965
@classmethod
@@ -67,12 +83,16 @@ def from_dictionary(cls,
6783
to = dictionary.get('to')
6884
mfrom = dictionary.get('from')
6985
application_id = dictionary.get('applicationId')
70-
scope = dictionary.get('scope')
86+
digits = dictionary.get('digits')
87+
expiration_time_in_minutes = dictionary.get('expirationTimeInMinutes')
7188
code = dictionary.get('code')
89+
scope = dictionary.get('scope')
7290

7391
# Return an object of this model
7492
return cls(to,
7593
mfrom,
7694
application_id,
77-
scope,
78-
code)
95+
digits,
96+
expiration_time_in_minutes,
97+
code,
98+
scope)

bandwidth/voice/controllers/base_controller.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class BaseController(object):
2727
"""
2828

2929
global_headers = {
30-
'user-agent': 'python-sdk-refs/tags/python6.5.0'
30+
'user-agent': 'python-sdk-refs/tags/python6.6.0'
3131
}
3232

3333
def __init__(self, config, call_back=None):

0 commit comments

Comments
 (0)