initial SDK commit

e911_addr
Maria Bermudez 7 years ago
parent aba615329e
commit 3d3e115c2b
  1. 1
      .gitignore
  2. 28
      LICENSE
  3. 2
      MANIFEST.in
  4. 43
      demo.py
  5. 10
      flowroutenumbersandmessaging/__init__.py
  6. BIN
      flowroutenumbersandmessaging/__init__.pyc
  7. 402
      flowroutenumbersandmessaging/api_helper.py
  8. BIN
      flowroutenumbersandmessaging/api_helper.pyc
  9. 33
      flowroutenumbersandmessaging/configuration.py
  10. BIN
      flowroutenumbersandmessaging/configuration.pyc
  11. 6
      flowroutenumbersandmessaging/controllers/__init__.py
  12. BIN
      flowroutenumbersandmessaging/controllers/__init__.pyc
  13. 94
      flowroutenumbersandmessaging/controllers/base_controller.py
  14. BIN
      flowroutenumbersandmessaging/controllers/base_controller.pyc
  15. 190
      flowroutenumbersandmessaging/controllers/messages_controller.py
  16. BIN
      flowroutenumbersandmessaging/controllers/messages_controller.pyc
  17. 385
      flowroutenumbersandmessaging/controllers/numbers_controller.py
  18. BIN
      flowroutenumbersandmessaging/controllers/numbers_controller.pyc
  19. 208
      flowroutenumbersandmessaging/controllers/routes_controller.py
  20. BIN
      flowroutenumbersandmessaging/controllers/routes_controller.pyc
  21. 22
      flowroutenumbersandmessaging/decorators.py
  22. BIN
      flowroutenumbersandmessaging/decorators.pyc
  23. 4
      flowroutenumbersandmessaging/exceptions/__init__.py
  24. BIN
      flowroutenumbersandmessaging/exceptions/__init__.pyc
  25. 32
      flowroutenumbersandmessaging/exceptions/api_exception.py
  26. BIN
      flowroutenumbersandmessaging/exceptions/api_exception.pyc
  27. 40
      flowroutenumbersandmessaging/exceptions/error_exception.py
  28. BIN
      flowroutenumbersandmessaging/exceptions/error_exception.pyc
  29. 39
      flowroutenumbersandmessaging/flowroutenumbersandmessaging_client.py
  30. BIN
      flowroutenumbersandmessaging/flowroutenumbersandmessaging_client.pyc
  31. 10
      flowroutenumbersandmessaging/http/__init__.py
  32. BIN
      flowroutenumbersandmessaging/http/__init__.pyc
  33. 3
      flowroutenumbersandmessaging/http/auth/__init__.py
  34. BIN
      flowroutenumbersandmessaging/http/auth/__init__.pyc
  35. 28
      flowroutenumbersandmessaging/http/auth/basic_auth.py
  36. BIN
      flowroutenumbersandmessaging/http/auth/basic_auth.pyc
  37. 36
      flowroutenumbersandmessaging/http/http_call_back.py
  38. 177
      flowroutenumbersandmessaging/http/http_client.py
  39. BIN
      flowroutenumbersandmessaging/http/http_client.pyc
  40. 34
      flowroutenumbersandmessaging/http/http_context.py
  41. BIN
      flowroutenumbersandmessaging/http/http_context.pyc
  42. 47
      flowroutenumbersandmessaging/http/http_method_enum.py
  43. BIN
      flowroutenumbersandmessaging/http/http_method_enum.pyc
  44. 81
      flowroutenumbersandmessaging/http/http_request.py
  45. BIN
      flowroutenumbersandmessaging/http/http_request.pyc
  46. 37
      flowroutenumbersandmessaging/http/http_response.py
  47. BIN
      flowroutenumbersandmessaging/http/http_response.pyc
  48. 100
      flowroutenumbersandmessaging/http/requests_client.py
  49. BIN
      flowroutenumbersandmessaging/http/requests_client.pyc
  50. 20
      flowroutenumbersandmessaging/models/__init__.py
  51. BIN
      flowroutenumbersandmessaging/models/__init__.pyc
  52. 63
      flowroutenumbersandmessaging/models/account_routes.py
  53. 129
      flowroutenumbersandmessaging/models/attributes.py
  54. BIN
      flowroutenumbersandmessaging/models/attributes.pyc
  55. 87
      flowroutenumbersandmessaging/models/attributes_28.py
  56. BIN
      flowroutenumbersandmessaging/models/attributes_28.pyc
  57. 69
      flowroutenumbersandmessaging/models/attributes_62.py
  58. 69
      flowroutenumbersandmessaging/models/data.py
  59. BIN
      flowroutenumbersandmessaging/models/data.pyc
  60. 82
      flowroutenumbersandmessaging/models/data_27.py
  61. BIN
      flowroutenumbersandmessaging/models/data_27.pyc
  62. 63
      flowroutenumbersandmessaging/models/data_61.py
  63. 81
      flowroutenumbersandmessaging/models/delivery_receipt.py
  64. BIN
      flowroutenumbersandmessaging/models/delivery_receipt.pyc
  65. 75
      flowroutenumbersandmessaging/models/error_1.py
  66. BIN
      flowroutenumbersandmessaging/models/error_1.pyc
  67. 61
      flowroutenumbersandmessaging/models/error_84.py
  68. 56
      flowroutenumbersandmessaging/models/links.py
  69. BIN
      flowroutenumbersandmessaging/models/links.pyc
  70. 57
      flowroutenumbersandmessaging/models/mdr_2.py
  71. BIN
      flowroutenumbersandmessaging/models/mdr_2.pyc
  72. 81
      flowroutenumbersandmessaging/models/message.py
  73. 24
      flowroutenumbersandmessaging/models/message_type_enum.py
  74. 57
      flowroutenumbersandmessaging/models/new_route.py
  75. 63
      flowroutenumbersandmessaging/models/number_26.py
  76. BIN
      flowroutenumbersandmessaging/models/number_26.pyc
  77. 27
      flowroutenumbersandmessaging/models/number_type_enum.py
  78. 30
      flowroutenumbersandmessaging/models/route_type_enum.py
  79. 4
      requirements.txt
  80. 29
      setup.py

1
.gitignore vendored

@ -0,0 +1 @@
*.swp

@ -0,0 +1,28 @@
License:
========
The MIT License (MIT)
http://opensource.org/licenses/MIT
Copyright (c) 2014 - 2016 APIMATIC Limited
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Trade Mark:
==========
APIMATIC is a trade mark for APIMATIC Limited

@ -0,0 +1,2 @@
include LICENSE
include README.md

@ -0,0 +1,43 @@
#!/usr/bin/env python
"""
demo.py
Flowroute-numbers-python is a Python API Wrapper that provides methods for interacting with v1 (version 1)
of the Flowroute API. These methods can be used to accomplish the following:
* Search for purchasable phone numbers
* Purchase phone numbers
* View the phone numbers you own, as well as their related details
* Create a new inbound route
* Update the primary and failover route on a phone number
Copyright Flowroute, Inc. 2016
"""
import pprint
import os
from flowroutenumbersandmessaging.flowroutenumbersandmessaging_client import FlowroutenumbersandmessagingClient
print("Number Control Demo")
# Setup your api credentials
basic_auth_user_name = os.environ.get('FR_ACCESS_KEY')
basic_auth_password = os.environ.get('FR_SECRET_KEY')
# Create our controller
client = FlowroutenumbersandmessagingClient(basic_auth_user_name, basic_auth_password)
numbers_controller = client.numbers
starts_with = 201
ends_with = None
contains = None
limit = 3
offset = None
print("--List Account Phone Numbers")
result = numbers_controller.get_account_phone_numbers(starts_with, ends_with, contains, limit, offset)
pprint.pprint(result)

@ -0,0 +1,10 @@
__all__ = [
'api_helper',
'configuration',
'models',
'controllers',
'http',
'exceptions',
'decorators',
'flowroute_numbers_and_messaging_client',
]

@ -0,0 +1,402 @@
# -*- coding: utf-8 -*-
"""
flowroutenumbersandmessaging.api_helper
This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io )
"""
import re
import sys
import datetime
import calendar
import email.utils as eut
from time import mktime
import jsonpickle
import dateutil.parser
from requests.utils import quote
class APIHelper(object):
"""A Helper Class for various functions associated with API Calls.
This class contains static methods for operations that need to be
performed during API requests. All of the methods inside this class are
static methods, there is no need to ever initialise an instance of this
class.
"""
@staticmethod
def merge_dicts(dict1, dict2):
"""Merges two dictionaries into one as a shallow copy.
Args:
dict1 (dict): The first dictionary.
dict2 (dict): The second dictionary.
Returns:
dict: A dictionary containing key value pairs
from both the argument dictionaries. In the case
of a key conflict, values from dict2 are used
and those from dict1 are lost.
"""
temp = dict1.copy()
temp.update(dict2)
return temp
@staticmethod
def json_serialize(obj):
"""JSON Serialization of a given object.
Args:
obj (object): The object to serialise.
Returns:
str: The JSON serialized string of the object.
"""
if obj is None:
return None
# Resolve any Names if it's one of our objects that needs to have this called on
if isinstance(obj, list):
value = list()
for item in obj:
if hasattr(item, "_names"):
value.append(APIHelper.to_dictionary(item))
else:
value.append(item)
obj = value
else:
if hasattr(obj, "_names"):
obj = APIHelper.to_dictionary(obj)
return jsonpickle.encode(obj, False)
@staticmethod
def json_deserialize(json, unboxing_function=None):
"""JSON Deerialization of a given string.
Args:
json (str): The JSON serialized string to deserialize.
Returns:
dict: A dictionary representing the data contained in the
JSON serialized string.
"""
if json is None:
return None
try:
decoded = jsonpickle.decode(json)
except:
return json
if unboxing_function is None:
return decoded
elif isinstance(decoded, list):
return [unboxing_function(element) for element in decoded]
else:
return unboxing_function(decoded)
@staticmethod
def serialize_array(key, array, formatting="indexed"):
"""Converts an array parameter to a list of key value tuples.
Args:
key (str): The name of the parameter.
array (list): The value of the parameter.
formatting (str): The type of key formatting expected.
Returns:
list: A list with key value tuples for the array elements.
"""
tuples = []
if sys.version_info[0] < 3:
serializable_types = (str, int, long, float, bool, datetime.date, APIHelper.CustomDate)
else:
serializable_types = (str, int, float, bool, datetime.date, APIHelper.CustomDate)
if isinstance(array[0], serializable_types):
if formatting is "unindexed":
tuples += [("{0}[]".format(key), element) for element in array]
elif formatting is "indexed":
tuples += [("{0}[{1}]".format(key, index), element) for index, element in enumerate(array)]
elif formatting is "plain":
tuples += [(key, element) for element in array]
else:
raise ValueError("Invalid format provided.")
else:
tuples += [("{0}[{1}]".format(key, index), element) for index, element in enumerate(array)]
return tuples
@staticmethod
def append_url_with_template_parameters(url,
parameters):
"""Replaces template parameters in the given url.
Args:
url (str): The query url string to replace the template parameters.
parameters (dict): The parameters to replace in the url.
Returns:
str: URL with replaced parameters.
"""
# Parameter validation
if url is None:
raise ValueError("URL is None.")
if parameters is None:
return url
# Iterate and replace parameters
for key in parameters:
element = parameters[key]
replace_value = ""
# Load parameter value
if element is None:
replace_value = ""
elif isinstance(element, list):
replace_value = "/".join(quote(str(x), safe='') for x in element)
else:
replace_value = quote(str(element), safe='')
url = url.replace('{{{0}}}'.format(key), str(replace_value))
return url
@staticmethod
def append_url_with_query_parameters(url,
parameters,
array_serialization="indexed"):
"""Adds query parameters to a URL.
Args:
url (str): The URL string.
parameters (dict): The query parameters to add to the URL.
array_serialization (str): The format of array parameter serialization.
Returns:
str: URL with added query parameters.
"""
# Parameter validation
if url is None:
raise ValueError("URL is None.")
if parameters is None:
return url
for key, value in parameters.items():
seperator = '&' if '?' in url else '?'
if value is not None:
if isinstance(value, list):
value = [element for element in value if element]
if array_serialization is "csv":
url += "{0}{1}={2}".format(seperator, key,
",".join(quote(str(x), safe='') for x in value))
elif array_serialization is "psv":
url += "{0}{1}={2}".format(seperator, key,
"|".join(quote(str(x), safe='') for x in value))
elif array_serialization is "tsv":
url += "{0}{1}={2}".format(seperator, key,
"\t".join(quote(str(x), safe='') for x in value))
else:
url += "{0}{1}".format(seperator,
"&".join(("{0}={1}".format(k, quote(str(v), safe='')))
for k, v in APIHelper.serialize_array(key, value, array_serialization)))
else:
url += "{0}{1}={2}".format(seperator, key, quote(str(value), safe=''))
return url
@staticmethod
def clean_url(url):
"""Validates and processes the given query Url to clean empty slashes.
Args:
url (str): The given query Url to process.
Returns:
str: Clean Url as string.
"""
# Ensure that the urls are absolute
regex = "^https?://[^/]+"
match = re.match(regex, url)
if match is None:
raise ValueError('Invalid Url format.')
protocol = match.group(0)
index = url.find('?')
query_url = url[len(protocol): index if index != -1 else None]
query_url = re.sub("//+", "/", query_url)
parameters = url[index:] if index != -1 else ""
return protocol + query_url + parameters
@staticmethod
def form_encode_parameters(form_parameters,
array_serialization="indexed"):
"""Form encodes a dictionary of form parameters
Args:
form_parameters (dictionary): The given dictionary which has
atleast one model to form encode.
array_serialization (str): The format of array parameter serialization.
Returns:
dict: A dictionary of form encoded properties of the model.
"""
encoded = []
for key, value in form_parameters.items():
encoded += APIHelper.form_encode(value, key, array_serialization)
return encoded
@staticmethod
def form_encode(obj,
instance_name,
array_serialization="indexed"):
"""Encodes a model in a form-encoded manner such as person[Name]
Args:
obj (object): The given Object to form encode.
instance_name (string): The base name to appear before each entry
for this object.
array_serialization (string): The format of array parameter serialization.
Returns:
dict: A dictionary of form encoded properties of the model.
"""
retval = []
# If we received an object, resolve it's field names.
if hasattr(obj, "_names"):
obj = APIHelper.to_dictionary(obj)
if obj is None:
return []
elif isinstance(obj, list):
for element in APIHelper.serialize_array(instance_name, obj, array_serialization):
retval += APIHelper.form_encode(element[1], element[0], array_serialization)
elif isinstance(obj, dict):
for item in obj:
retval += APIHelper.form_encode(obj[item], instance_name + "[" + item + "]", array_serialization)
else:
retval.append((instance_name, obj))
return retval
@staticmethod
def to_dictionary(obj):
"""Creates a dictionary representation of a class instance. The
keys are taken from the API description and may differ from language
specific variable names of properties.
Args:
obj: The object to be converted into a dictionary.
Returns:
dictionary: A dictionary form of the model with properties in
their API formats.
"""
dictionary = dict()
# Loop through all properties in this model
for name in obj._names:
value = getattr(obj, name)
if isinstance(value, list):
# Loop through each item
dictionary[obj._names[name]] = list()
for item in value:
dictionary[obj._names[name]].append(APIHelper.to_dictionary(item) if hasattr(item, "_names") else item)
elif isinstance(value, dict):
# Loop through each item
dictionary[obj._names[name]] = dict()
for key in value:
dictionary[obj._names[name]][key] = APIHelper.to_dictionary(value[key]) if hasattr(value[key], "_names") else value[key]
else:
dictionary[obj._names[name]] = APIHelper.to_dictionary(value) if hasattr(value, "_names") else value
# Return the result
return dictionary
class CustomDate(object):
""" A base class for wrapper classes of datetime.
This class contains methods which help in
appropriate serialization of datetime objects.
"""
def __init__(self, dtime, value=None):
self.datetime = dtime
if not value:
self.value = self.from_datetime(dtime)
else:
self.value = value
def __str__(self):
return self.value
def __getstate__(self):
return self.value
def __setstate__(self, state):
pass
class HttpDateTime(CustomDate):
""" A wrapper class for datetime to support HTTP date format."""
@classmethod
def from_datetime(cls, date_time):
return eut.formatdate(timeval=mktime(date_time.timetuple()),
localtime=False, usegmt=True)
@classmethod
def from_value(cls, value):
dtime = datetime.datetime.fromtimestamp(eut.mktime_tz(eut.parsedate_tz(value)))
return cls(dtime, value)
class UnixDateTime(CustomDate):
""" A wrapper class for datetime to support Unix date format."""
def __str__(self):
return str(self.value)
@classmethod
def from_datetime(cls, date_time):
return calendar.timegm(date_time.utctimetuple())
@classmethod
def from_value(cls, value):
dtime = datetime.datetime.utcfromtimestamp(float(value))
return cls(dtime, float(value))
class RFC3339DateTime(CustomDate):
""" A wrapper class for datetime to support Rfc 3339 format."""
@classmethod
def from_datetime(cls, date_time):
return date_time.isoformat()
@classmethod
def from_value(cls, value):
dtime = dateutil.parser.parse(value)
return cls(dtime, value)

@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
"""
flowroutenumbersandmessaging.configuration
This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io )
"""
from .api_helper import APIHelper
class Configuration(object):
"""A class used for configuring the SDK by a user.
This class need not be instantiated and all properties and methods
are accessible without instance creation.
"""
# Set the array parameter serialization method
# (allowed: indexed, unindexed, plain, csv, tsv, psv)
array_serialization = "indexed"
# The base Uri for API calls
base_uri = 'https://api.flowroute.com'
# The username to use with basic authentication
# TODO: Set an appropriate value
basic_auth_user_name = "TODO: Replace"
# The password to use with basic authentication
# TODO: Set an appropriate value
basic_auth_password = "TODO: Replace"

@ -0,0 +1,6 @@
__all__ = [
'base_controller',
'numbers_controller',
'routes_controller',
'messages_controller',
]

@ -0,0 +1,94 @@
# -*- coding: utf-8 -*-
"""
flowroutenumbersandmessagingcontrollers.base_controller
This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
"""
from ..api_helper import APIHelper
from ..http.http_context import HttpContext
from ..http.requests_client import RequestsClient
from ..exceptions.api_exception import APIException
class BaseController(object):
"""All controllers inherit from this base class.
Attributes:
http_client (HttpClient): The HttpClient which a specific controller
instance will use. By default all the controller objects share
the same HttpClient. A user can use his own custom HttpClient
as well.
http_call_back (HttpCallBack): An object which holds call back
methods to be called before and after the execution of an HttpRequest.
global_headers (dict): The global headers of the API which are sent with
every request.
"""
http_client = RequestsClient()
http_call_back = None
global_headers = {
'user-agent': 'APIMATIC 2.0'
}
def __init__(self, client=None, call_back=None):
if client != None:
self.http_client = client
if call_back != None:
self.http_call_back = call_back
def validate_parameters(self, **kwargs):
"""Validates required parameters of an endpoint.
Args:
kwargs (dict): A dictionary of the required parameters.
"""
for name, value in kwargs.items():
if value is None:
raise ValueError("Required parameter {} cannot be None.".format(name))
def execute_request(self, request, binary=False):
"""Executes an HttpRequest.
Args:
request (HttpRequest): The HttpRequest to execute.
binary (bool): A flag which should be set to True if
a binary response is expected.
Returns:
HttpContext: The HttpContext of the request. It contains,
both, the request itself and the HttpResponse object.
"""
# Invoke the on before request HttpCallBack if specified
if self.http_call_back != None:
self.http_call_back.on_before_request(request)
# Add global headers to request
request.headers = APIHelper.merge_dicts(self.global_headers, request.headers)
# Invoke the API call to fetch the response.
func = self.http_client.execute_as_binary if binary else self.http_client.execute_as_string
response = func(request)
context = HttpContext(request, response)
# Invoke the on after response HttpCallBack if specified
if self.http_call_back != None:
self.http_call_back.on_after_response(context)
return context
def validate_response(self, context):
"""Validates an HTTP response by checking for global errors.
Args:
context (HttpContext): The HttpContext of the API call.
"""
if (context.response.status_code < 200) or (context.response.status_code > 208): #[200,208] = HTTP OK
raise APIException('HTTP response not OK.', context)

@ -0,0 +1,190 @@
# -*- coding: utf-8 -*-
"""
flowroutenumbersandmessaging.controllers.messages_controller
This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
"""
from .base_controller import BaseController
from ..api_helper import APIHelper
from ..configuration import Configuration
from ..http.auth.basic_auth import BasicAuth
from ..models.mdr_2 import MDR2
from ..exceptions.error_exception import ErrorException
class MessagesController(BaseController):
"""A Controller to access Endpoints in the flowroutenumbersandmessaging API."""
def get_look_up_a_set_of_messages(self,
start_date,
end_date=None,
limit=None,
offset=None):
"""Does a GET request to /v2.1/messages.
Retrieves a list of Message Detail Records (MDRs) within a specified
date range. Date and time is based on Coordinated Universal Time
(UTC).
Args:
start_date (datetime): The beginning date and time, in UTC, on
which to perform an MDR search. The DateTime can be formatted
as YYYY-MM-DDor YYYY-MM-DDTHH:mm:ss.SSZ.
end_date (datetime, optional): The ending date and time, in UTC,
on which to perform an MDR search. The DateTime can be
formatted as YYYY-MM-DD or YYYY-MM-DDTHH:mm:ss.SSZ.
limit (int, optional): The number of MDRs to retrieve at one time.
You can set as high of a number as you want, but the number
cannot be negative and must be greater than 0 (zero).
offset (int, optional): The number of MDRs to skip when performing
a query. The number must be 0 (zero) or greater, but cannot be
negative.
Returns:
mixed: Response from the API. OK
Raises:
APIException: When an error occurs while fetching the data from
the remote API. This exception includes the HTTP Response
code, an error message, and the HTTP body that was received in
the request.
"""
# Prepare query URL
_query_builder = Configuration.base_uri
_query_builder += '/v2.1/messages'
_query_parameters = {
'start_date': APIHelper.RFC3339DateTime(start_date),
'end_date': APIHelper.RFC3339DateTime(end_date),
'limit': limit,
'offset': offset
}
_query_builder = APIHelper.append_url_with_query_parameters(_query_builder,
_query_parameters, Configuration.array_serialization)
_query_url = APIHelper.clean_url(_query_builder)
# Prepare headers
_headers = {
'accept': 'application/json'
}
# Prepare and execute request
_request = self.http_client.get(_query_url, headers=_headers)
BasicAuth.apply(_request)
_context = self.execute_request(_request)
# Endpoint and global error handling using HTTP status codes.
if _context.response.status_code == 401:
raise ErrorException('Unauthorized – There was an issue with your API credentials.', _context)
elif _context.response.status_code == 404:
raise ErrorException('The specified resource was not found', _context)
self.validate_response(_context)
# Return appropriate type
return APIHelper.json_deserialize(_context.response.raw_body)
def get_look_up_a_message_detail_record(self,
id):
"""Does a GET request to /v2.1/messages/{id}.
Searches for a specific message record ID and returns a Message Detail
Record (in MDR2 format).
Args:
id (string): The unique message detail record identifier (MDR ID)
of any message. When entering the MDR ID, the number should
include the mdr2- preface.
Returns:
MDR2: Response from the API. OK
Raises:
APIException: When an error occurs while fetching the data from
the remote API. This exception includes the HTTP Response
code, an error message, and the HTTP body that was received in
the request.
"""
# Prepare query URL
_query_builder = Configuration.base_uri
_query_builder += '/v2.1/messages/{id}'
_query_builder = APIHelper.append_url_with_template_parameters(_query_builder, {
'id': id
})
_query_url = APIHelper.clean_url(_query_builder)
# Prepare headers
_headers = {
'accept': 'application/json'
}
# Prepare and execute request
_request = self.http_client.get(_query_url, headers=_headers)
BasicAuth.apply(_request)
_context = self.execute_request(_request)
# Endpoint and global error handling using HTTP status codes.
if _context.response.status_code == 401:
raise ErrorException('Unauthorized – There was an issue with your API credentials.', _context)
elif _context.response.status_code == 404:
raise ErrorException('The specified resource was not found', _context)
self.validate_response(_context)
# Return appropriate type
return APIHelper.json_deserialize(_context.response.raw_body, MDR2.from_dictionary)
def create_send_a_message(self,
body):
"""Does a POST request to /v2.1/messages.
Sends an SMS or MMS from a Flowroute long code or toll-free phone
number to another valid phone number.
Args:
body (Message): The SMS or MMS message to send.
Returns:
mixed: Response from the API. ACCEPTED
Raises:
APIException: When an error occurs while fetching the data from
the remote API. This exception includes the HTTP Response
code, an error message, and the HTTP body that was received in
the request.
"""
# Prepare query URL
_query_builder = Configuration.base_uri
_query_builder += '/v2.1/messages'
_query_url = APIHelper.clean_url(_query_builder)
# Prepare headers
_headers = {
'accept': 'application/json',
'content-type': 'application/json; charset=utf-8'
}
# Prepare and execute request
_request = self.http_client.post(_query_url, headers=_headers, parameters=APIHelper.json_serialize(body))
BasicAuth.apply(_request)
_context = self.execute_request(_request)
# Endpoint and global error handling using HTTP status codes.
if _context.response.status_code == 401:
raise ErrorException('Unauthorized – There was an issue with your API credentials.', _context)
elif _context.response.status_code == 403:
raise ErrorException('Forbidden – You don\'t have permission to access this resource.', _context)
elif _context.response.status_code == 404:
raise ErrorException('The specified resource was not found', _context)
elif _context.response.status_code == 422:
raise ErrorException('Unprocessable Entity - You tried to enter an incorrect value.', _context)
self.validate_response(_context)
# Return appropriate type
return APIHelper.json_deserialize(_context.response.raw_body)

@ -0,0 +1,385 @@
# -*- coding: utf-8 -*-
"""
flowroutenumbersandmessaging.controllers.numbers_controller
This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
"""
from .base_controller import BaseController
from ..api_helper import APIHelper
from ..configuration import Configuration
from ..http.auth.basic_auth import BasicAuth
from ..models.number_26 import Number26
from ..exceptions.error_exception import ErrorException
from ..exceptions.api_exception import APIException
class NumbersController(BaseController):
"""A Controller to access Endpoints in the flowroutenumbersandmessaging API."""
def list_available_exchange_codes(self,
limit=None,
offset=None,
max_setup_cost=None,
areacode=None):
"""Does a GET request to /v2/numbers/available/exchanges.
Returns a list of all Central Office (exchange) codes containing
purchasable phone numbers.
Args:
limit (int, optional): Limits the number of items to retrieve. A
maximum of 200 items can be retrieved.
offset (int, optional): Offsets the list of phone numbers by your
specified value. For example, if you have 4 phone numbers and
you entered 1 as your offset value, then only 3 of your phone
numbers will be displayed in the response.
max_setup_cost (float, optional): Restricts the results to the
specified maximum non-recurring setup cost.
areacode (int, optional): Restricts the results to the specified
area code.
Returns:
void: Response from the API. OK
Raises:
APIException: When an error occurs while fetching the data from
the remote API. This exception includes the HTTP Response
code, an error message, and the HTTP body that was received in
the request.
"""
# Prepare query URL
_query_builder = Configuration.base_uri
_query_builder += '/v2/numbers/available/exchanges'
_query_parameters = {
'limit': limit,
'offset': offset,
'max_setup_cost': max_setup_cost,
'areacode': areacode
}
_query_builder = APIHelper.append_url_with_query_parameters(_query_builder,
_query_parameters, Configuration.array_serialization)
_query_url = APIHelper.clean_url(_query_builder)
# Prepare and execute request
_request = self.http_client.get(_query_url)
BasicAuth.apply(_request)
_context = self.execute_request(_request)
# Endpoint and global error handling using HTTP status codes.
if _context.response.status_code == 401:
raise ErrorException('Unauthorized – There was an issue with your API credentials.', _context)
elif _context.response.status_code == 404:
raise ErrorException('The specified resource was not found', _context)
self.validate_response(_context)
def list_available_area_codes(self,
limit=None,
offset=None,
max_setup_cost=None):
"""Does a GET request to /v2/numbers/available/areacodes.
Returns a list of all Numbering Plan Area (NPA) codes containing
purchasable phone numbers.
Args:
limit (int, optional): Limits the number of items to retrieve. A
maximum of 400 items can be retrieved.
offset (int, optional): Offsets the list of phone numbers by your
specified value. For example, if you have 4 phone numbers and
you entered 1 as your offset value, then only 3 of your phone
numbers will be displayed in the response.
max_setup_cost (float, optional): Restricts the results to the
specified maximum non-recurring setup cost.
Returns:
void: Response from the API. OK
Raises:
APIException: When an error occurs while fetching the data from
the remote API. This exception includes the HTTP Response
code, an error message, and the HTTP body that was received in
the request.
"""
# Prepare query URL
_query_builder = Configuration.base_uri
_query_builder += '/v2/numbers/available/areacodes'
_query_parameters = {
'limit': limit,
'offset': offset,
'max_setup_cost': max_setup_cost
}
_query_builder = APIHelper.append_url_with_query_parameters(_query_builder,
_query_parameters, Configuration.array_serialization)
_query_url = APIHelper.clean_url(_query_builder)
# Prepare and execute request
_request = self.http_client.get(_query_url)
BasicAuth.apply(_request)
_context = self.execute_request(_request)
# Endpoint and global error handling using HTTP status codes.
if _context.response.status_code == 401:
raise ErrorException('Unauthorized – There was an issue with your API credentials.', _context)
elif _context.response.status_code == 404:
raise ErrorException('The specified resource was not found', _context)
self.validate_response(_context)
def search_for_purchasable_phone_numbers(self,
starts_with=None,
contains=None,
ends_with=None,
limit=None,
offset=None,
rate_center=None,
state=None):
"""Does a GET request to /v2/numbers/available.
This endpoint lets you search for phone numbers by state or rate
center, or by your specified search value.
Args:
starts_with (int, optional): Retrieve phone numbers that start
with the specified value.
contains (int, optional): Retrieve phone numbers containing the
specified value.
ends_with (int, optional): Retrieve phone numbers that end with
the specified value.
limit (int, optional): Limits the number of items to retrieve. A
maximum of 200 items can be retrieved.
offset (int, optional): Offsets the list of phone numbers by your
specified value. For example, if you have 4 phone numbers and
you entered 1 as your offset value, then only 3 of your phone
numbers will be displayed in the response.
rate_center (string, optional): Filters by and displays phone
numbers in the specified rate center.
state (string, optional): Filters by and displays phone numbers in
the specified state. Optional unless a ratecenter is
specified.
Returns:
mixed: Response from the API. OK
Raises:
APIException: When an error occurs while fetching the data from
the remote API. This exception includes the HTTP Response
code, an error message, and the HTTP body that was received in
the request.
"""
# Prepare query URL
_query_builder = Configuration.base_uri
_query_builder += '/v2/numbers/available'
_query_parameters = {
'starts_with': starts_with,
'contains': contains,
'ends_with': ends_with,
'limit': limit,
'offset': offset,
'rate_center': rate_center,
'state': state
}
_query_builder = APIHelper.append_url_with_query_parameters(_query_builder,
_query_parameters, Configuration.array_serialization)
_query_url = APIHelper.clean_url(_query_builder)
# Prepare headers
_headers = {
'accept': 'application/json'
}
# Prepare and execute request
_request = self.http_client.get(_query_url, headers=_headers)
BasicAuth.apply(_request)
_context = self.execute_request(_request)
# Endpoint and global error handling using HTTP status codes.
if _context.response.status_code == 401:
raise ErrorException('Unauthorized – There was an issue with your API credentials.', _context)
elif _context.response.status_code == 404:
raise ErrorException('The specified resource was not found', _context)
self.validate_response(_context)
# Return appropriate type
return APIHelper.json_deserialize(_context.response.raw_body)
def get_account_phone_numbers(self,
starts_with=None,
ends_with=None,
contains=None,
limit=None,
offset=None):
"""Does a GET request to /v2/numbers.
Returns a list of all phone numbers currently on your Flowroute
account. The response includes details such as the phone number's rate
center, state, number type, and whether CNAM Lookup is enabled for
that number.
Args:
starts_with (int, optional): Retrieves phone numbers that start
with the specified value.
ends_with (int, optional): Retrieves phone numbers that end with
the specified value.
contains (int, optional): Retrieves phone numbers containing the
specified value.
limit (int, optional): Limits the number of items to retrieve. A
maximum of 200 items can be retrieved.
offset (int, optional): Offsets the list of phone numbers by your
specified value. For example, if you have 4 phone numbers and
you entered 1 as your offset value, then only 3 of your phone
numbers will be displayed in the response.
Returns:
mixed: Response from the API. A JSON object of phone numbers in
your account
Raises:
APIException: When an error occurs while fetching the data from
the remote API. This exception includes the HTTP Response
code, an error message, and the HTTP body that was received in
the request.
"""
# Prepare query URL
_query_builder = Configuration.base_uri
_query_builder += '/v2/numbers'
_query_parameters = {
'starts_with': starts_with,
'ends_with': ends_with,
'contains': contains,
'limit': limit,
'offset': offset
}
_query_builder = APIHelper.append_url_with_query_parameters(_query_builder,
_query_parameters, Configuration.array_serialization)
_query_url = APIHelper.clean_url(_query_builder)
# Prepare headers
_headers = {
'accept': 'application/json'
}
# Prepare and execute request
_request = self.http_client.get(_query_url, headers=_headers)
BasicAuth.apply(_request)
_context = self.execute_request(_request)
# Endpoint and global error handling using HTTP status codes.
if _context.response.status_code == 401:
raise ErrorException('Unauthorized – There was an issue with your API credentials.', _context)
elif _context.response.status_code == 404:
raise ErrorException('The specified resource was not found', _context)
self.validate_response(_context)
# Return appropriate type
return APIHelper.json_deserialize(_context.response.raw_body)
def create_purchase_a_phone_number(self,
id):
"""Does a POST request to /v2/numbers/{id}.
Lets you purchase a phone number from available Flowroute inventory.
Args:
id (int): Phone number to purchase. Must be in 11-digit E.164
format; e.g. 12061231234.
Returns:
Number26: Response from the API. CREATED
Raises:
APIException: When an error occurs while fetching the data from
the remote API. This exception includes the HTTP Response
code, an error message, and the HTTP body that was received in
the request.
"""
# Prepare query URL
_query_builder = Configuration.base_uri
_query_builder += '/v2/numbers/{id}'
_query_builder = APIHelper.append_url_with_template_parameters(_query_builder, {
'id': id
})
_query_url = APIHelper.clean_url(_query_builder)
# Prepare headers
_headers = {
'accept': 'application/json'
}
# Prepare and execute request
_request = self.http_client.post(_query_url, headers=_headers)
BasicAuth.apply(_request)
_context = self.execute_request(_request)
# Endpoint and global error handling using HTTP status codes.
if _context.response.status_code == 401:
raise ErrorException('Unauthorized – There was an issue with your API credentials.', _context)
elif _context.response.status_code == 404:
raise ErrorException('The specified resource was not found', _context)
self.validate_response(_context)
# Return appropriate type
return APIHelper.json_deserialize(_context.response.raw_body, Number26.from_dictionary)
def get_phone_number_details(self,
id):
"""Does a GET request to /v2/numbers/{id}.
Lists all of the information associated with any of the phone numbers
in your account, including billing method, primary voice route, and
failover voice route.
Args:
id (int): Phone number to search for which must be a number that
you own. Must be in 11-digit E.164 format; e.g. 12061231234.
Returns:
Number26: Response from the API. A JSON object of phone numbers in
your account
Raises:
APIException: When an error occurs while fetching the data from
the remote API. This exception includes the HTTP Response
code, an error message, and the HTTP body that was received in
the request.
"""
# Prepare query URL
_query_builder = Configuration.base_uri
_query_builder += '/v2/numbers/{id}'
_query_builder = APIHelper.append_url_with_template_parameters(_query_builder, {
'id': id
})
_query_url = APIHelper.clean_url(_query_builder)
# Prepare headers
_headers = {
'accept': 'application/json'
}
# Prepare and execute request
_request = self.http_client.get(_query_url, headers=_headers)
BasicAuth.apply(_request)
_context = self.execute_request(_request)
# Endpoint and global error handling using HTTP status codes.
if _context.response.status_code == 401:
raise APIException('Unauthorized', _context)
elif _context.response.status_code == 404:
raise APIException('Not Found', _context)
self.validate_response(_context)
# Return appropriate type
return APIHelper.json_deserialize(_context.response.raw_body, Number26.from_dictionary)

@ -0,0 +1,208 @@
# -*- coding: utf-8 -*-
"""
flowroutenumbersandmessaging.controllers.routes_controller
This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
"""
from .base_controller import BaseController
from ..api_helper import APIHelper
from ..configuration import Configuration
from ..http.auth.basic_auth import BasicAuth
from ..exceptions.error_exception import ErrorException
from ..exceptions.api_exception import APIException
class RoutesController(BaseController):
"""A Controller to access Endpoints in the flowroutenumbersandmessaging API."""
def create_an_inbound_route(self,
body):
"""Does a POST request to /v2/routes.
Creates a new inbound route which can then be associated with phone
numbers. Please see "List Inbound Routes" to review the route values
that you can associate with your Flowroute phone numbers.
Args:
body (NewRoute): The new inbound route to be created.
Returns:
void: Response from the API. CREATED
Raises:
APIException: When an error occurs while fetching the data from
the remote API. This exception includes the HTTP Response
code, an error message, and the HTTP body that was received in
the request.
"""
# Prepare query URL
_query_builder = Configuration.base_uri
_query_builder += '/v2/routes'
_query_url = APIHelper.clean_url(_query_builder)
# Prepare headers
_headers = {
'content-type': 'application/json; charset=utf-8'
}
# Prepare and execute request
_request = self.http_client.post(_query_url, headers=_headers, parameters=APIHelper.json_serialize(body))
BasicAuth.apply(_request)
_context = self.execute_request(_request)
# Endpoint and global error handling using HTTP status codes.
if _context.response.status_code == 401:
raise ErrorException('Unauthorized – There was an issue with your API credentials.', _context)
elif _context.response.status_code == 404:
raise ErrorException('The specified resource was not found', _context)
self.validate_response(_context)
def list_inbound_routes(self,
limit=None,
offset=None):
"""Does a GET request to /v2/routes.
Returns a list of your inbound routes. From the list, you can then
select routes to use as the primary and failover routes for a phone
number, which you can do via "Update Primary Voice Route for a Phone
Number" and "Update Failover Voice Route for a Phone Number".
Args:
limit (int, optional): Limits the number of routes to retrieve. A
maximum of 200 items can be retrieved.
offset (int, optional): Offsets the list of routes by your
specified value. For example, if you have 4 inbound routes and
you entered 1 as your offset value, then only 3 of your routes
will be displayed in the response.
Returns:
void: Response from the API. OK
Raises:
APIException: When an error occurs while fetching the data from
the remote API. This exception includes the HTTP Response
code, an error message, and the HTTP body that was received in
the request.
"""
# Prepare query URL
_query_builder = Configuration.base_uri
_query_builder += '/v2/routes'
_query_parameters = {
'limit': limit,
'offset': offset
}
_query_builder = APIHelper.append_url_with_query_parameters(_query_builder,
_query_parameters, Configuration.array_serialization)
_query_url = APIHelper.clean_url(_query_builder)
# Prepare and execute request
_request = self.http_client.get(_query_url)
BasicAuth.apply(_request)
_context = self.execute_request(_request)
# Endpoint and global error handling using HTTP status codes.
if _context.response.status_code == 401:
raise APIException('Unauthorized', _context)
elif _context.response.status_code == 404:
raise APIException('Not Found', _context)
self.validate_response(_context)
def update_failover_voice_route_for_a_phone_number(self,
number_id,
body):
"""Does a PATCH request to /v2/numbers/{number_id}/relationships/failover_route.
Use this endpoint to update the failover voice route for a phone
number. You must create the route first by following "Create an
Inbound Route". You can then assign the created route by specifying
its value in a PATCH request.
Args:
number_id (int): The phone number in E.164 11-digit North American
format to which the failover route for voice will be
assigned.
body (void): The failover route to be assigned.
Returns:
void: Response from the API. NO CONTENT
Raises:
APIException: When an error occurs while fetching the data from
the remote API. This exception includes the HTTP Response
code, an error message, and the HTTP body that was received in
the request.
"""
# Prepare query URL
_query_builder = Configuration.base_uri
_query_builder += '/v2/numbers/{number_id}/relationships/failover_route'
_query_builder = APIHelper.append_url_with_template_parameters(_query_builder, {
'number_id': number_id
})
_query_url = APIHelper.clean_url(_query_builder)
# Prepare and execute request
_request = self.http_client.patch(_query_url, parameters=str(body))
BasicAuth.apply(_request)
_context = self.execute_request(_request)
# Endpoint and global error handling using HTTP status codes.
if _context.response.status_code == 401:
raise ErrorException('Unauthorized – There was an issue with your API credentials.', _context)
elif _context.response.status_code == 404:
raise ErrorException('The specified resource was not found', _context)
self.validate_response(_context)
def update_primary_voice_route_for_a_phone_number(self,
number_id,
body):
"""Does a PATCH request to /v2/numbers/{number_id}/relationships/primary_route.
Use this endpoint to update the primary voice route for a phone
number. You must create the route first by following "Create an
Inbound Route". You can then assign the created route by specifying
its value in a PATCH request.
Args:
number_id (int): The phone number in E.164 11-digit North American
format to which the primary route for voice will be assigned.
body (void): The primary route to be assigned.
Returns:
void: Response from the API. NO CONTENT
Raises:
APIException: When an error occurs while fetching the data from
the remote API. This exception includes the HTTP Response
code, an error message, and the HTTP body that was received in
the request.
"""
# Prepare query URL
_query_builder = Configuration.base_uri
_query_builder += '/v2/numbers/{number_id}/relationships/primary_route'
_query_builder = APIHelper.append_url_with_template_parameters(_query_builder, {
'number_id': number_id
})
_query_url = APIHelper.clean_url(_query_builder)
# Prepare and execute request
_request = self.http_client.patch(_query_url, parameters=str(body))
BasicAuth.apply(_request)
_context = self.execute_request(_request)
# Endpoint and global error handling using HTTP status codes.
if _context.response.status_code == 401:
raise ErrorException('Unauthorized – There was an issue with your API credentials.', _context)
elif _context.response.status_code == 404:
raise ErrorException('The specified resource was not found', _context)
self.validate_response(_context)

@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
"""
flowroutenumbersandmessaging.decorators
This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io )
"""
class lazy_property(object):
"""A decorator class for lazy instantiation."""
def __init__(self, fget):
self.fget = fget
self.func_name = fget.__name__
def __get__(self, obj, cls):
if obj is None:
return None
value = self.fget(obj)
setattr(obj, self.func_name, value)
return value

@ -0,0 +1,4 @@
__all__ = [
'api_exception',
'error_exception',
]

@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
"""
flowroutenumbersandmessaging.exceptions.api_exception
This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io )
"""
class APIException(Exception):
"""Class that handles HTTP Exceptions when fetching API Endpoints.
Attributes:
response_code (int): The status code of the response.
context (HttpContext): The HttpContext of the API call.
"""
def __init__(self,
reason,
context):
"""Constructor for the APIException class
Args:
reason (string): The reason (or error message) for the Exception
to be raised.
context (HttpContext): The HttpContext of the API call.
"""
super(APIException, self).__init__(reason)
self.context = context
self.response_code = context.response.status_code

@ -0,0 +1,40 @@
# -*- coding: utf-8 -*-
"""
flowroutenumbersandmessaging.models.error_exception
This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io )
"""
from ..api_helper import APIHelper
import flowroutenumbersandmessaging.exceptions.api_exception
import flowroutenumbersandmessaging.models.error_1
class ErrorException(flowroutenumbersandmessaging.exceptions.api_exception.APIException):
def __init__(self, reason, context):
"""Constructor for the ErrorException class
Args:
reason (string): The reason (or error message) for the Exception
to be raised.
context (HttpContext): The HttpContext of the API call.
"""
super(ErrorException, self).__init__(reason, context)
dictionary = APIHelper.json_deserialize(self.context.response.raw_body)
if isinstance(dictionary, dict):
self.unbox(dictionary)
def unbox(self, dictionary):
"""Populates the properties of this object by extracting them 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.
"""
self.errors = None
if dictionary.get("errors") != None:
self.errors = list()
for structure in dictionary.get("errors"):
self.errors.append(flowroutenumbersandmessaging.models.error_1.Error1.from_dictionary(structure))

@ -0,0 +1,39 @@
# -*- coding: utf-8 -*-
"""
flowroutenumbersandmessaging.flowroute_numbers_and_messaging_client
This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
"""
from .decorators import lazy_property
from .configuration import Configuration
from .controllers.numbers_controller import NumbersController
from .controllers.routes_controller import RoutesController
from .controllers.messages_controller import MessagesController
class FlowroutenumbersandmessagingClient(object):
config = Configuration
@lazy_property
def numbers(self):
return NumbersController()
@lazy_property
def routes(self):
return RoutesController()
@lazy_property
def messages(self):
return MessagesController()
def __init__(self,
basic_auth_user_name = None,
basic_auth_password = None):
if basic_auth_user_name != None:
Configuration.basic_auth_user_name = basic_auth_user_name
if basic_auth_password != None:
Configuration.basic_auth_password = basic_auth_password

@ -0,0 +1,10 @@
__all__ = [
'auth',
'http_method_enum',
'http_request',
'http_response',
'http_client',
'http_context',
'requests_client',
'http_call_back',
]

@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
"""
flowroutenumbersandmessaging.http.auth.basic_auth
This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io )
"""
import base64
from ...configuration import Configuration
class BasicAuth:
@staticmethod
def apply(http_request):
""" Add basic authentication to the request.
Args:
http_request (HttpRequest): The HttpRequest object to which
authentication will be added.
"""
username = Configuration.basic_auth_user_name
password = Configuration.basic_auth_password
joined = "{}:{}".format(username, password)
encoded = base64.b64encode(str.encode(joined)).decode('iso-8859-1')
header_value = "Basic {}".format(encoded)
http_request.headers["Authorization"] = header_value

@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
"""
flowroutenumbersandmessaging.http.http_call_back
This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
"""
class HttpCallBack(object):
"""An interface for the callback to be called before and after the
HTTP call for an endpoint is made.
This class should not be instantiated but should be used as a base class
for HttpCallBack classes.
"""
def on_before_request(self,
request):
"""The controller will call this method before making the HttpRequest.
Args:
request (HttpRequest): The request object which will be sent
to the HttpClient to be executed.
"""
raise NotImplementedError("This method has not been implemented.")
def on_after_response(self,
context):
"""The controller will call this method after making the HttpRequest.
Args:
context (HttpContext): The HttpContext of the API call.
"""
raise NotImplementedError("This method has not been implemented.")

@ -0,0 +1,177 @@
# -*- coding: utf-8 -*-
"""
flowroutenumbersandmessaging.http.http_client
This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
"""
from .http_request import HttpRequest
from .http_method_enum import HttpMethodEnum
class HttpClient(object):
"""An interface for the methods that an HTTP Client must implement
This class should not be instantiated but should be used as a base class
for HTTP Client classes.
"""
def execute_as_string(self, request):
"""Execute a given HttpRequest to get a string response back
Args:
request (HttpRequest): The given HttpRequest to execute.
Returns:
HttpResponse: The response of the HttpRequest.
"""
raise NotImplementedError("Please Implement this method")
def execute_as_binary(self, request):
"""Execute a given HttpRequest to get a binary response back
Args:
request (HttpRequest): The given HttpRequest to execute.
Returns:
HttpResponse: The response of the HttpRequest.
"""
raise NotImplementedError("Please Implement this method")
def convert_response(self, response, binary):
"""Converts the Response object of the HttpClient into an
HttpResponse object.
Args:
response (dynamic): The original response object.
Returns:
HttpResponse: The converted HttpResponse object.
"""
raise NotImplementedError("Please Implement this method")
def get(self, query_url,
headers={},
query_parameters={}):
"""Create a simple GET HttpRequest object for the given parameters
Args:
query_url (string): The URL to send the request to.
headers (dict, optional): The headers for the HTTP Request.
query_parameters (dict, optional): Query parameters to add in the URL.
Returns:
HttpRequest: The generated HttpRequest for the given paremeters.
"""
return HttpRequest(HttpMethodEnum.GET,
query_url,
headers,
query_parameters,
None,
None)
def post(self, query_url,
headers={},
query_parameters={},
parameters={},
files={}):
"""Create a simple POST HttpRequest object for the given parameters
Args:
query_url (string): The URL to send the request to.
headers (dict, optional): The headers for the HTTP Request.
query_parameters (dict, optional): Query parameters to add in the URL.
parameters (dict, optional): Form or body parameters to be included in the body.
files (dict, optional): Files to be sent with the request.
Returns:
HttpRequest: The generated HttpRequest for the given paremeters.
"""
return HttpRequest(HttpMethodEnum.POST,
query_url,
headers,
query_parameters,
parameters,
files)
def put(self, query_url,
headers={},
query_parameters={},
parameters={},
files={}):
"""Create a simple PUT HttpRequest object for the given parameters
Args:
query_url (string): The URL to send the request to.
headers (dict, optional): The headers for the HTTP Request.
query_parameters (dict, optional): Query parameters to add in the URL.
parameters (dict, optional): Form or body parameters to be included in the body.
files (dict, optional): Files to be sent with the request.
Returns:
HttpRequest: The generated HttpRequest for the given paremeters.
"""
return HttpRequest(HttpMethodEnum.PUT,
query_url,
headers,
query_parameters,
parameters,
files)
def patch(self, query_url,
headers={},
query_parameters={},
parameters={},
files={}):
"""Create a simple PATCH HttpRequest object for the given parameters
Args:
query_url (string): The URL to send the request to.
headers (dict, optional): The headers for the HTTP Request.
query_parameters (dict, optional): Query parameters to add in the URL.
parameters (dict, optional): Form or body parameters to be included in the body.
files (dict, optional): Files to be sent with the request.
Returns:
HttpRequest: The generated HttpRequest for the given paremeters.
"""
return HttpRequest(HttpMethodEnum.PATCH,
query_url,
headers,
query_parameters,
parameters,
files)
def delete(self, query_url,
headers={},
query_parameters={},
parameters={},
files={}):
"""Create a simple DELETE HttpRequest object for the given parameters
Args:
query_url (string): The URL to send the request to.
headers (dict, optional): The headers for the HTTP Request.
query_parameters (dict, optional): Query parameters to add in the URL.
parameters (dict, optional): Form or body parameters to be included in the body.
files (dict, optional): Files to be sent with the request.
Returns:
HttpRequest: The generated HttpRequest for the given paremeters.
"""
return HttpRequest(HttpMethodEnum.DELETE,
query_url,
headers,
query_parameters,
parameters,
files)

@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
"""
flowroutenumbersandmessaging.http.http_context
This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
"""
class HttpContext(object):
"""An HTTP Context that contains both the original HttpRequest
object that intitiated the call and the HttpResponse object that
is the result of the call.
Attributes:
request (HttpRequest): The original request object.
response (HttpResponse): The returned response object after
executing the request. Note that this may be None
depending on if and when an error occurred.
"""
def __init__(self,
request,
response):
"""Constructor for the HttpContext class
Args:
request (HttpRequest): The HTTP Request.
response (HttpResponse): The HTTP Response.
"""
self.request = request
self.response = response

@ -0,0 +1,47 @@
# -*- coding: utf-8 -*-
"""
flowroutenumbersandmessaging.http.http_method_enum
This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
"""
class HttpMethodEnum(object):
"""Enumeration of an HTTP Method
Attributes:
GET: A GET Request
POST: A POST Request
PUT: A PUT Request
PATCH: A PATCH Request
DELETE: A DELETE Request
"""
GET = "GET"
POST = "POST"
PUT = "PUT"
PATCH = "PATCH"
DELETE = "DELETE"
@classmethod
def to_string(cls, val):
"""Returns the string equivalent for the Enum.
"""
for k, v in list(vars(cls).items()):
if v == val:
return k
@classmethod
def from_string(cls, str):
"""Creates an instance of the Enum from a given string.
"""
return getattr(cls, str.upper(), None)

@ -0,0 +1,81 @@
# -*- coding: utf-8 -*-
"""
flowroutenumbersandmessaging.http.http_request
This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
"""
from ..api_helper import APIHelper
class HttpRequest(object):
"""Information about an HTTP Request including its method, headers,
parameters, URL, and Basic Auth details
Attributes:
http_method (HttpMethodEnum): The HTTP Method that this request should
perform when called.
headers (dict): A dictionary of headers (key : value) that should be
sent along with the request.
query_url (string): The URL that the request should be sent to.
parameters (dict): A dictionary of parameters that are to be sent along
with the request in the form body of the request
"""
def __init__(self,
http_method,
query_url,
headers=None,
query_parameters=None,
parameters=None,
files=None):
"""Constructor for the HttpRequest class
Args:
http_method (HttpMethodEnum): The HTTP Method.
query_url (string): The URL to send the request to.
headers (dict, optional): The headers for the HTTP Request.
query_parameters (dict, optional): Query parameters to add in the URL.
parameters (dict, optional): Form or body parameters to be included in the body.
files (dict, optional): Files to be sent with the request.
"""
self.http_method = http_method
self.query_url = query_url
self.headers = headers
self.query_parameters = query_parameters
self.parameters = parameters
self.files = files
def add_header(self, name, value):
""" Add a header to the HttpRequest.
Args:
name (string): The name of the header.
value (string): The value of the header.
"""
self.headers[name] = value
def add_parameter(self, name, value):
""" Add a parameter to the HttpRequest.
Args:
name (string): The name of the parameter.
value (string): The value of the parameter.
"""
self.parameters[name] = value
def add_query_parameter(self, name, value):
""" Add a query parameter to the HttpRequest.
Args:
name (string): The name of the query parameter.
value (string): The value of the query parameter.
"""
self.query_url = APIHelper.append_url_with_query_parameters(self.query_url,
{name:value})
self.query_url = APIHelper.clean_url(self.query_url)

@ -0,0 +1,37 @@
# -*- coding: utf-8 -*-
"""
flowroutenumbersandmessaging.http.http_response
This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
"""
class HttpResponse(object):
"""Information about an HTTP Response including its status code, returned
headers, and raw body
Attributes:
status_code (int): The status code response from the server that
corresponds to this response.
headers (dict): A dictionary of headers (key : value) that were
returned with the response
raw_body (string): The Raw body of the HTTP Response as a string
"""
def __init__(self,
status_code,
headers,
raw_body):
"""Constructor for the HttpResponse class
Args:
status_code (int): The response status code.
headers (dict): The response headers.
raw_body (string): The raw body from the server.
"""
self.status_code = status_code
self.headers = headers
self.raw_body = raw_body

@ -0,0 +1,100 @@
# -*- coding: utf-8 -*-
"""
flowroutenumbersandmessaging.http.requests_client
This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
"""
import requests
from cachecontrol import CacheControl
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.retry import Retry
from .http_client import HttpClient
from .http_response import HttpResponse
from .http_method_enum import HttpMethodEnum
class RequestsClient(HttpClient):
"""An implementation of HttpClient that uses Requests as its HTTP Client
Attributes:
timeout (int): The default timeout for all API requests.
"""
def __init__(self, timeout=60, cache=False, max_retries=None, retry_interval=None):
"""The constructor.
Args:
timeout (float): The default global timeout(seconds).
"""
self.timeout = timeout
self.session = requests.session()
if max_retries and retry_interval:
retries = Retry(total=max_retries, backoff_factor=retry_interval)
self.session.mount('http://', HTTPAdapter(max_retries=retries))
self.session.mount('https://', HTTPAdapter(max_retries=retries))
if cache:
self.session = CacheControl(self.session)
def execute_as_string(self, request):
"""Execute a given HttpRequest to get a string response back
Args:
request (HttpRequest): The given HttpRequest to execute.
Returns:
HttpResponse: The response of the HttpRequest.
"""
response = self.session.request(HttpMethodEnum.to_string(request.http_method),
request.query_url,
headers=request.headers,
params=request.query_parameters,
data=request.parameters,
files=request.files,
timeout=self.timeout)
return self.convert_response(response, False)
def execute_as_binary(self, request):
"""Execute a given HttpRequest to get a binary response back
Args:
request (HttpRequest): The given HttpRequest to execute.
Returns:
HttpResponse: The response of the HttpRequest.
"""
response = self.session.request(HttpMethodEnum.to_string(request.http_method),
request.query_url,
headers=request.headers,
params=request.query_parameters,
data=request.parameters,
files=request.files,
timeout=self.timeout)
return self.convert_response(response, True)
def convert_response(self, response, binary):
"""Converts the Response object of the HttpClient into an
HttpResponse object.
Args:
response (dynamic): The original response object.
Returns:
HttpResponse: The converted HttpResponse object.
"""
if binary:
return HttpResponse(response.status_code, response.headers, response.content)
else:
return HttpResponse(response.status_code, response.headers, response.text)

@ -0,0 +1,20 @@
__all__ = [
'error_84',
'new_route',
'links',
'attributes',
'attributes_28',
'data_27',
'delivery_receipt',
'message',
'error_1',
'account_routes',
'attributes_62',
'data_61',
'number_26',
'mdr_2',
'data',
'route_type_enum',
'number_type_enum',
'message_type_enum',
]

@ -0,0 +1,63 @@
# -*- coding: utf-8 -*-
"""
flowroutenumbersandmessaging.models.account_routes
This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io )
"""
class AccountRoutes(object):
"""Implementation of the 'AccountRoutes' model.
TODO: type model description here.
Attributes:
data (list of object): TODO: type description here.
links (object): TODO: type description here.
"""
# Create a mapping from Model property names to API property names
_names = {
"data" : "data",
"links" : "links"
}
def __init__(self,
data=None,
links=None):
"""Constructor for the AccountRoutes class"""
# Initialize members of the class
self.data = data
self.links = links
@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
data = dictionary.get("data")
links = dictionary.get("links")
# Return an object of this model
return cls(data,
links)

@ -0,0 +1,129 @@
# -*- coding: utf-8 -*-
"""
flowroutenumbersandmessaging.models.attributes
This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io )
"""
from flowroutenumbersandmessaging.api_helper import APIHelper
import flowroutenumbersandmessaging.models.delivery_receipt
class Attributes(object):
"""Implementation of the 'Attributes' model.
TODO: type model description here.
Attributes:
amount_display (float): TODO: type description here.
amount_nanodollars (float): TODO: type description here.
body (string): TODO: type description here.
delivery_receipts (list of DeliveryReceipt): TODO: type description
here.
direction (string): TODO: type description here.
mfrom (string): TODO: type description here.
is_mms (bool): TODO: type description here.
message_encoding (int): TODO: type description here.
message_type (MessageTypeEnum): TODO: type description here.
status (string): TODO: type description here.
timestamp (datetime): TODO: type description here.
to (string): TODO: type description here.
"""
# Create a mapping from Model property names to API property names
_names = {
"amount_display" : "amount_display",
"amount_nanodollars" : "amount_nanodollars",
"body" : "body",
"delivery_receipts" : "delivery_receipts",
"direction" : "direction",
"mfrom" : "from",
"is_mms" : "is_mms",
"message_encoding" : "message_encoding",
"message_type" : "message_type",
"status" : "status",
"timestamp" : "timestamp",
"to" : "to"
}
def __init__(self,
amount_display=None,
amount_nanodollars=None,
body=None,
delivery_receipts=None,
direction=None,
mfrom=None,
is_mms=None,
message_encoding=None,
message_type=None,
status=None,
timestamp=None,
to=None):
"""Constructor for the Attributes class"""
# Initialize members of the class
self.amount_display = amount_display
self.amount_nanodollars = amount_nanodollars
self.body = body
self.delivery_receipts = delivery_receipts
self.direction = direction
self.mfrom = mfrom
self.is_mms = is_mms
self.message_encoding = message_encoding
self.message_type = message_type
self.status = status
self.timestamp = APIHelper.RFC3339DateTime(timestamp) if timestamp else None
self.to = to
@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
amount_display = dictionary.get("amount_display")
amount_nanodollars = dictionary.get("amount_nanodollars")
body = dictionary.get("body")
delivery_receipts = None
if dictionary.get("delivery_receipts") != None:
delivery_receipts = list()
for structure in dictionary.get("delivery_receipts"):
delivery_receipts.append(flowroutenumbersandmessaging.models.delivery_receipt.DeliveryReceipt.from_dictionary(structure))
direction = dictionary.get("direction")
mfrom = dictionary.get("from")
is_mms = dictionary.get("is_mms")
message_encoding = dictionary.get("message_encoding")
message_type = dictionary.get("message_type")
status = dictionary.get("status")
timestamp = APIHelper.RFC3339DateTime.from_value(dictionary.get("timestamp")).datetime if dictionary.get("timestamp") else None
to = dictionary.get("to")
# Return an object of this model
return cls(amount_display,
amount_nanodollars,
body,
delivery_receipts,
direction,
mfrom,
is_mms,
message_encoding,
message_type,
status,
timestamp,
to)

@ -0,0 +1,87 @@
# -*- coding: utf-8 -*-
"""
flowroutenumbersandmessaging.models.attributes_28
This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io )
"""
class Attributes28(object):
"""Implementation of the 'Attributes28' model.
TODO: type model description here.
Attributes:
alias (string): TODO: type description here.
cnam_lookups_enabled (bool): TODO: type description here.
number_type (NumberTypeEnum): TODO: type description here.
rate_center (string): TODO: type description here.
state (string): TODO: type description here.
value (int): TODO: type description here.
"""
# Create a mapping from Model property names to API property names
_names = {
"alias" : "alias",
"cnam_lookups_enabled" : "cnam_lookups_enabled",
"number_type" : "number_type",
"rate_center" : "rate_center",
"state" : "state",
"value" : "value"
}
def __init__(self,
alias=None,
cnam_lookups_enabled=None,
number_type=None,
rate_center=None,
state=None,
value=None):
"""Constructor for the Attributes28 class"""
# Initialize members of the class
self.alias = alias
self.cnam_lookups_enabled = cnam_lookups_enabled
self.number_type = number_type
self.rate_center = rate_center
self.state = state
self.value = value
@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
alias = dictionary.get("alias")
cnam_lookups_enabled = dictionary.get("cnam_lookups_enabled")
number_type = dictionary.get("number_type")
rate_center = dictionary.get("rate_center")
state = dictionary.get("state")
value = dictionary.get("value")
# Return an object of this model
return cls(alias,
cnam_lookups_enabled,
number_type,
rate_center,
state,
value)

@ -0,0 +1,69 @@
# -*- coding: utf-8 -*-
"""
flowroutenumbersandmessaging.models.attributes_62
This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io )
"""
class Attributes62(object):
"""Implementation of the 'Attributes62' model.
TODO: type model description here.
Attributes:
alias (string): TODO: type description here.
route_type (RouteTypeEnum): TODO: type description here.
value (string): TODO: type description here.
"""
# Create a mapping from Model property names to API property names
_names = {
"alias" : "alias",
"route_type" : "route_type",
"value" : "value"
}
def __init__(self,
alias=None,
route_type='sip-reg',
value=None):
"""Constructor for the Attributes62 class"""
# Initialize members of the class
self.alias = alias
self.route_type = route_type
self.value = value
@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
alias = dictionary.get("alias")
route_type = dictionary.get("route_type") if dictionary.get("route_type") else 'sip-reg'
value = dictionary.get("value")
# Return an object of this model
return cls(alias,
route_type,
value)

@ -0,0 +1,69 @@
# -*- coding: utf-8 -*-
"""
flowroutenumbersandmessaging.models.data
This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io )
"""
import flowroutenumbersandmessaging.models.attributes
class Data(object):
"""Implementation of the 'Data' model.
TODO: type model description here.
Attributes:
attributes (Attributes): TODO: type description here.
id (string): TODO: type description here.
mtype (string): TODO: type description here.
"""
# Create a mapping from Model property names to API property names
_names = {
"attributes" : "attributes",
"id" : "id",
"mtype" : "type"
}
def __init__(self,
attributes=None,
id=None,
mtype='message'):
"""Constructor for the Data class"""
# Initialize members of the class
self.attributes = attributes
self.id = id
self.mtype = mtype
@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
attributes = flowroutenumbersandmessaging.models.attributes.Attributes.from_dictionary(dictionary.get("attributes")) if dictionary.get("attributes") else None
id = dictionary.get("id")
mtype = dictionary.get("type") if dictionary.get("type") else 'message'
# Return an object of this model
return cls(attributes,
id,
mtype)

@ -0,0 +1,82 @@
# -*- coding: utf-8 -*-
"""
flowroutenumbersandmessaging.models.data_27
This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io )
"""
import flowroutenumbersandmessaging.models.attributes_28
import flowroutenumbersandmessaging.models.links
class Data27(object):
"""Implementation of the 'Data27' model.
TODO: type model description here.
Attributes:
attributes (Attributes28): TODO: type description here.
id (string): TODO: type description here.
links (Links): TODO: type description here.
relationships (object): TODO: type description here.
mtype (string): TODO: type description here.
"""
# Create a mapping from Model property names to API property names
_names = {
"attributes" : "attributes",
"id" : "id",
"links" : "links",
"relationships" : "relationships",
"mtype" : "type"
}
def __init__(self,
attributes=None,
id=None,
links=None,
relationships=None,
mtype='number'):
"""Constructor for the Data27 class"""
# Initialize members of the class
self.attributes = attributes
self.id = id
self.links = links
self.relationships = relationships
self.mtype = mtype
@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
attributes = flowroutenumbersandmessaging.models.attributes_28.Attributes28.from_dictionary(dictionary.get("attributes")) if dictionary.get("attributes") else None
id = dictionary.get("id")
links = flowroutenumbersandmessaging.models.links.Links.from_dictionary(dictionary.get("links")) if dictionary.get("links") else None
relationships = dictionary.get("relationships")
mtype = dictionary.get("type") if dictionary.get("type") else 'number'
# Return an object of this model
return cls(attributes,
id,
links,
relationships,
mtype)

@ -0,0 +1,63 @@
# -*- coding: utf-8 -*-
"""
flowroutenumbersandmessaging.models.data_61
This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io )
"""
import flowroutenumbersandmessaging.models.attributes_62
class Data61(object):
"""Implementation of the 'Data61' model.
TODO: type model description here.
Attributes:
mtype (string): TODO: type description here.
attributes (Attributes62): TODO: type description here.
"""
# Create a mapping from Model property names to API property names
_names = {
"mtype" : "type",
"attributes" : "attributes"
}
def __init__(self,
mtype='route',
attributes=None):
"""Constructor for the Data61 class"""
# Initialize members of the class
self.mtype = mtype
self.attributes = attributes
@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
mtype = dictionary.get("type") if dictionary.get("type") else 'route'
attributes = flowroutenumbersandmessaging.models.attributes_62.Attributes62.from_dictionary(dictionary.get("attributes")) if dictionary.get("attributes") else None
# Return an object of this model
return cls(mtype,
attributes)

@ -0,0 +1,81 @@
# -*- coding: utf-8 -*-
"""
flowroutenumbersandmessaging.models.delivery_receipt
This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io )
"""
from flowroutenumbersandmessaging.api_helper import APIHelper
class DeliveryReceipt(object):
"""Implementation of the 'DeliveryReceipt' model.
TODO: type model description here.
Attributes:
level (int): TODO: type description here.
status (string): TODO: type description here.
status_code (int): TODO: type description here.
status_code_description (string): TODO: type description here.
timestamp (datetime): TODO: type description here.
"""
# Create a mapping from Model property names to API property names
_names = {
"level" : "level",
"status" : "status",
"status_code" : "status_code",
"status_code_description" : "status_code_description",
"timestamp" : "timestamp"
}
def __init__(self,
level=None,
status=None,
status_code=None,
status_code_description=None,
timestamp=None):
"""Constructor for the DeliveryReceipt class"""
# Initialize members of the class
self.level = level
self.status = status
self.status_code = status_code
self.status_code_description = status_code_description
self.timestamp = APIHelper.RFC3339DateTime(timestamp) if timestamp else None
@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
level = dictionary.get("level")
status = dictionary.get("status")
status_code = dictionary.get("status_code")
status_code_description = dictionary.get("status_code_description")
timestamp = APIHelper.RFC3339DateTime.from_value(dictionary.get("timestamp")).datetime if dictionary.get("timestamp") else None
# Return an object of this model
return cls(level,
status,
status_code,
status_code_description,
timestamp)

@ -0,0 +1,75 @@
# -*- coding: utf-8 -*-
"""
flowroutenumbersandmessaging.models.error_1
This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io )
"""
class Error1(object):
"""Implementation of the 'Error1' model.
TODO: type model description here.
Attributes:
id (string): TODO: type description here.
status (int): TODO: type description here.
detail (string): TODO: type description here.
title (string): TODO: type description here.
"""
# Create a mapping from Model property names to API property names
_names = {
"id" : "id",
"status" : "status",
"detail" : "detail",
"title" : "title"
}
def __init__(self,
id=None,
status=None,
detail=None,
title=None):
"""Constructor for the Error1 class"""
# Initialize members of the class
self.id = id
self.status = status
self.detail = detail
self.title = title
@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
id = dictionary.get("id")
status = dictionary.get("status")
detail = dictionary.get("detail")
title = dictionary.get("title")
# Return an object of this model
return cls(id,
status,
detail,
title)

@ -0,0 +1,61 @@
# -*- coding: utf-8 -*-
"""
flowroutenumbersandmessaging.models.error_84
This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io )
"""
import flowroutenumbersandmessaging.models.error_1
class Error84(object):
"""Implementation of the 'Error84' model.
TODO: type model description here.
Attributes:
errors (list of Error1): TODO: type description here.
"""
# Create a mapping from Model property names to API property names
_names = {
"errors" : "errors"
}
def __init__(self,
errors=None):
"""Constructor for the Error84 class"""
# Initialize members of the class
self.errors = errors
@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
errors = None
if dictionary.get("errors") != None:
errors = list()
for structure in dictionary.get("errors"):
errors.append(flowroutenumbersandmessaging.models.error_1.Error1.from_dictionary(structure))
# Return an object of this model
return cls(errors)

@ -0,0 +1,56 @@
# -*- coding: utf-8 -*-
"""
flowroutenumbersandmessaging.models.links
This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io )
"""
class Links(object):
"""Implementation of the 'Links' model.
TODO: type model description here.
Attributes:
self (string): TODO: type description here.
"""
# Create a mapping from Model property names to API property names
_names = {
"self" : "self"
}
def __init__(self):
"""Constructor for the Links class"""
# Initialize members of the class
self.self = self
@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
self = dictionary.get("self")
# Return an object of this model
return cls(self)

@ -0,0 +1,57 @@
# -*- coding: utf-8 -*-
"""
flowroutenumbersandmessaging.models.mdr_2
This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io )
"""
import flowroutenumbersandmessaging.models.data
class MDR2(object):
"""Implementation of the 'MDR2' model.
TODO: type model description here.
Attributes:
data (Data): TODO: type description here.
"""
# Create a mapping from Model property names to API property names
_names = {
"data" : "data"
}
def __init__(self,
data=None):
"""Constructor for the MDR2 class"""
# Initialize members of the class
self.data = data
@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
data = flowroutenumbersandmessaging.models.data.Data.from_dictionary(dictionary.get("data")) if dictionary.get("data") else None
# Return an object of this model
return cls(data)

@ -0,0 +1,81 @@
# -*- coding: utf-8 -*-
"""
flowroutenumbersandmessaging.models.message
This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io )
"""
class Message(object):
"""Implementation of the 'Message' model.
TODO: type model description here.
Attributes:
mfrom (string): TODO: type description here.
to (string): TODO: type description here.
body (string): TODO: type description here.
media_urls (list of string): TODO: type description here.
is_mms (bool): TODO: type description here.
"""
# Create a mapping from Model property names to API property names
_names = {
"mfrom" : "from",
"to" : "to",
"body" : "body",
"media_urls" : "media_urls",
"is_mms" : "is_mms"
}
def __init__(self,
mfrom=None,
to=None,
body=None,
media_urls=None,
is_mms=None):
"""Constructor for the Message class"""
# Initialize members of the class
self.mfrom = mfrom
self.to = to
self.body = body
self.media_urls = media_urls
self.is_mms = is_mms
@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
mfrom = dictionary.get("from")
to = dictionary.get("to")
body = dictionary.get("body")
media_urls = dictionary.get("media_urls")
is_mms = dictionary.get("is_mms")
# Return an object of this model
return cls(mfrom,
to,
body,
media_urls,
is_mms)

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
"""
flowroutenumbersandmessaging.models.message_type_enum
This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io )
"""
class MessageTypeEnum(object):
"""Implementation of the 'MessageType' enum.
TODO: type enum description here.
Attributes:
LONGCODE: TODO: type description here.
TOLLFREE: TODO: type description here.
"""
LONGCODE = 'longcode'
TOLLFREE = 'toll-free'

@ -0,0 +1,57 @@
# -*- coding: utf-8 -*-
"""
flowroutenumbersandmessaging.models.new_route
This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io )
"""
import flowroutenumbersandmessaging.models.data_61
class NewRoute(object):
"""Implementation of the 'NewRoute' model.
TODO: type model description here.
Attributes:
data (Data61): TODO: type description here.
"""
# Create a mapping from Model property names to API property names
_names = {
"data" : "data"
}
def __init__(self,
data=None):
"""Constructor for the NewRoute class"""
# Initialize members of the class
self.data = data
@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
data = flowroutenumbersandmessaging.models.data_61.Data61.from_dictionary(dictionary.get("data")) if dictionary.get("data") else None
# Return an object of this model
return cls(data)

@ -0,0 +1,63 @@
# -*- coding: utf-8 -*-
"""
flowroutenumbersandmessaging.models.number_26
This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io )
"""
import flowroutenumbersandmessaging.models.data_27
class Number26(object):
"""Implementation of the 'Number26' model.
TODO: type model description here.
Attributes:
data (Data27): TODO: type description here.
included (list of object): TODO: type description here.
"""
# Create a mapping from Model property names to API property names
_names = {
"data" : "data",
"included" : "included"
}
def __init__(self,
data=None,
included=None):
"""Constructor for the Number26 class"""
# Initialize members of the class
self.data = data
self.included = included
@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
data = flowroutenumbersandmessaging.models.data_27.Data27.from_dictionary(dictionary.get("data")) if dictionary.get("data") else None
included = dictionary.get("included")
# Return an object of this model
return cls(data,
included)

@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
"""
flowroutenumbersandmessaging.models.number_type_enum
This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io )
"""
class NumberTypeEnum(object):
"""Implementation of the 'NumberType' enum.
TODO: type enum description here.
Attributes:
STANDARD: TODO: type description here.
TOLLFREE: TODO: type description here.
INUM: TODO: type description here.
"""
STANDARD = 'standard'
TOLLFREE = 'tollfree'
INUM = 'inum'

@ -0,0 +1,30 @@
# -*- coding: utf-8 -*-
"""
flowroutenumbersandmessaging.models.route_type_enum
This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io )
"""
class RouteTypeEnum(object):
"""Implementation of the 'RouteType' enum.
TODO: type enum description here.
Attributes:
SIPREG: TODO: type description here.
HOST: TODO: type description here.
URI: TODO: type description here.
NUMBER: TODO: type description here.
"""
SIPREG = 'sip-reg'
HOST = 'host'
URI = 'uri'
NUMBER = 'number'

@ -0,0 +1,4 @@
requests==2.9.1
jsonpickle==0.7.1
cachecontrol==0.11.7
python-dateutil==2.5.3

@ -0,0 +1,29 @@
from setuptools import setup, find_packages
# Try to convert markdown README to rst format for PyPI.
try:
import pypandoc
long_description = pypandoc.convert('README.md', 'rst')
except(IOError, ImportError):
long_description = open('README.md').read()
setup(
name='flowroutenumbersandmessaging',
version='3.0.0',
description='The Flowroute APIs are organized around REST. Our APIs have resource-oriented URLs, support HTTP Verbs, and respond with HTTP Status Codes. All API requests and responses, including errors, will be represented as JSON objects. You can use the Flowroute APIs to manage your Flowroute phone numbers including setting primary and failover routes for inbound calls, and sending text messages (SMS and MMS) using long-code or toll-free numbers in your account.',
long_description=long_description,
author='APIMatic SDK Generator',
author_email='support@apimatic.io',
url='https://apimatic.io/',
packages=find_packages(),
install_requires=[
'requests>=2.9.1, <3.0',
'jsonpickle>=0.7.1, <1.0',
'cachecontrol>=0.11.7, <1.0',
'python-dateutil>=2.5.3, <3.0'
],
tests_require=[
'nose>=1.3.7'
],
test_suite = 'nose.collector'
)
Loading…
Cancel
Save