Example #1
0
    async def create(cls, api_key=None, **params):
        requestor = api_requestor.APIRequestor(api_key)
        url = cls.class_url()
        params = util.rewrite_reserved_words(params)
        response, api_key = await requestor.request("post", url, params)

        return convert_to_telnyx_object(response, api_key)
Example #2
0
    def serialize(self, previous):
        params = {}
        unsaved_keys = self._unsaved_values or set()
        previous = previous or self._previous or {}

        for k, v in six.iteritems(self):
            if k == "id" or (isinstance(k, str) and k.startswith("_")):
                continue
            elif isinstance(v, telnyx.api_resources.abstract.APIResource):
                continue
            elif hasattr(v, "serialize"):
                child = v.serialize(previous.get(k, None))
                if child != {}:
                    params[k] = child
            elif k in unsaved_keys:
                params[k] = _compute_diff(v, previous.get(k, None))
            elif k == "additional_owners" and v is not None:
                params[k] = _serialize_list(v, previous.get(k, None))

        params = util.rewrite_reserved_words(params)

        return params
 async def _modify(cls, url, api_key=None, **params):
     requestor = api_requestor.APIRequestor(api_key)
     params = util.rewrite_reserved_words(params)
     response, api_key = requestor.request("patch", url, params)
     return aioutil.convert_to_telnyx_object(response, api_key)
Example #4
0
 async def send_from_alphanumeric_sender_id(cls, **params):
     params = util.rewrite_reserved_words(params)
     return await Message.create_alphanumeric_sender_id(None, **params)
Example #5
0
 def nested_resource_request(cls, method, url, api_key=None, **params):
     requestor = api_requestor.APIRequestor(api_key)
     params = util.rewrite_reserved_words(params)
     response, api_key = requestor.request(method, url, params)
     return util.convert_to_telnyx_object(response, api_key)