twilio.base package¶
Submodules¶
twilio.base.deserialize module¶
-
twilio.base.deserialize.
decimal
(d)[source]¶ Parses a decimal string into a Decimal :param d: decimal string :return: Decimal
-
twilio.base.deserialize.
integer
(i)[source]¶ Parses an integer string into an int :param i: integer string :return: int
-
twilio.base.deserialize.
iso8601_date
(s)[source]¶ Parses an ISO 8601 date string and returns a UTC date object or the string if the parsing failed. :param s: ISO 8601-formatted date string (2015-01-25) :return:
twilio.base.domain module¶
-
class
twilio.base.domain.
Domain
(twilio)[source]¶ Bases:
object
This represents at Twilio API subdomain.
Like, api.twilio.com or `lookups.twilio.com’.
-
absolute_url
(uri)[source]¶ Converts a relative uri to an absolute url. :param string uri: The relative uri to make absolute. :return: An absolute url (based off this domain)
-
request
(method, uri, params=None, data=None, headers=None, auth=None, timeout=None, allow_redirects=False)[source]¶ Makes an HTTP request to this domain. :param string method: The HTTP method. :param string uri: The HTTP uri. :param dict params: Query parameters. :param object data: The request body. :param dict headers: The HTTP headers. :param tuple auth: Basic auth tuple of (username, password) :param int timeout: The request timeout. :param bool allow_redirects: True if the client should follow HTTP redirects.
-
twilio.base.exceptions module¶
-
exception
twilio.base.exceptions.
TwilioRestException
(status, uri, msg='', code=None, method='GET', details=None)[source]¶ Bases:
twilio.base.exceptions.TwilioException
A generic 400 or 500 level exception from the Twilio API
Parameters: - status (int) – the HTTP status that was returned for the exception
- uri (str) – The URI that caused the exception
- msg (str) – A human-readable message for the error
- method (str) – The HTTP method used to make the request
- code (int|None) – A Twilio-specific error code for the error. This is not available for all errors.
- details (dictionary|None) – Additional error details returned for the exception
twilio.base.instance_context module¶
twilio.base.instance_resource module¶
twilio.base.list_resource module¶
twilio.base.obsolete module¶
-
exception
twilio.base.obsolete.
ObsoleteException
[source]¶ Bases:
Exception
Base class for warnings about obsolete features.
twilio.base.page module¶
-
class
twilio.base.page.
Page
(version, response)[source]¶ Bases:
object
Represents a page of records in a collection.
A Page lets you iterate over its records and fetch the next and previous pages in the collection.
-
META_KEYS
= {'end', 'first_page_uri', 'last_page_uri', 'next_page_uri', 'num_pages', 'page', 'page_size', 'previous_page_uri', 'start', 'total', 'uri'}¶
-
get_instance
(payload)[source]¶ Parameters: payload (dict) – A JSON-loaded representation of an instance record. Returns: A rich, resource-dependent object.
-
load_page
(payload)[source]¶ Parses the collection of records out of a list payload.
Parameters: payload (dict) – The JSON-loaded content. Return list: The list of records.
-
next_page_url
¶ Return str: Returns a link to the next_page_url or None if doesn’t exist.
-
previous_page_url
¶ Return str: Returns a link to the previous_page_url or None if doesn’t exist.
-
twilio.base.serialize module¶
-
twilio.base.serialize.
iso8601_date
(d)[source]¶ Return a string representation of a date that the Twilio API understands Format is YYYY-MM-DD. Returns None if d is not a string, datetime, or date
-
twilio.base.serialize.
iso8601_datetime
(d)[source]¶ Return a string representation of a date that the Twilio API understands Format is YYYY-MM-DD. Returns None if d is not a string, datetime, or date
-
twilio.base.serialize.
map
(lst, serialize_func)[source]¶ Applies serialize_func to every element in lst
twilio.base.values module¶
twilio.base.version module¶
-
class
twilio.base.version.
Version
(domain)[source]¶ Bases:
object
Represents an API version.
-
create
(method, uri, params=None, data=None, headers=None, auth=None, timeout=None, allow_redirects=False)[source]¶ Create a resource instance.
-
delete
(method, uri, params=None, data=None, headers=None, auth=None, timeout=None, allow_redirects=False)[source]¶ Delete a resource.
-
classmethod
exception
(method, uri, response, message)[source]¶ Wraps an exceptional response in a TwilioRestException.
-
fetch
(method, uri, params=None, data=None, headers=None, auth=None, timeout=None, allow_redirects=False)[source]¶ Fetch a resource instance.
-
page
(method, uri, params=None, data=None, headers=None, auth=None, timeout=None, allow_redirects=False)[source]¶ Makes an HTTP request.
-
read_limits
(limit=None, page_size=None)[source]¶ Takes a limit on the max number of records to read and a max page_size and calculates the max number of pages to read.
Parameters: Return dict: A dictionary of paging limits.
-
request
(method, uri, params=None, data=None, headers=None, auth=None, timeout=None, allow_redirects=False)[source]¶ Make an HTTP request.
-