How to use the easypost.__init__.Requestor function in easypost

To help you get started, we’ve selected a few easypost examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github EasyPost / easypost-python / easypost / __init__.py View on Github external
def label(self, **params):
        requestor = Requestor(self._api_key)
        url = "%s/%s" % (self.instance_url(), "label")

        response, api_key = requestor.request('get', url, params)
        self.refresh_from(response, api_key)
        return self
github EasyPost / easypost-python / easypost / __init__.py View on Github external
def create_and_verify(cls, api_key=None, carrier=None, **params):
        requestor = Requestor(api_key)
        url = "%s/%s" % (cls.class_url(), "create_and_verify")

        wrapped_params = {
            cls.class_name(): params,
            "carrier": carrier
        }
        response, api_key = requestor.request('post', url, wrapped_params)

        response_address = response.get('address', None)
        response_message = response.get('message', None)

        if response_address is not None:
            verified_address = convert_to_easypost_object(response_address, api_key)
            if response_message is not None:
                verified_address.message = response_message
                verified_address._immutable_values.update('message')
github EasyPost / easypost-python / easypost / __init__.py View on Github external
def create_scan_form(self, **params):
        requestor = Requestor(self._api_key)
        url = "%s/%s" % (self.instance_url(), "scan_form")
        response, api_key = requestor.request('post', url, params)
        self.refresh_from(response, api_key)
        return self
github EasyPost / easypost-python / easypost / __init__.py View on Github external
def refund(self, **params):
        requestor = Requestor(self._api_key)
        url = "%s/%s" % (self.instance_url(), "refund")

        response, api_key = requestor.request('get', url, params)
        self.refresh_from(response, api_key)
        return self
github EasyPost / easypost-python / easypost / __init__.py View on Github external
def retrieve(cls, easypost_id, api_key=None, **params):
        try:
            easypost_id = easypost_id['id']
        except (KeyError, TypeError):
            pass

        requestor = Requestor(api_key)
        url = "%s/%s" % (cls.class_url(), easypost_id)
        response, api_key = requestor.request('get', url)
        return response["signed_url"]
github EasyPost / easypost-python / easypost / __init__.py View on Github external
def cancel(self, **params):
        requestor = Requestor(self._api_key)
        url = "%s/%s" % (self.instance_url(), "cancel")
        response, api_key = requestor.request('post', url, params)
        self.refresh_from(response, api_key)
        return self
github EasyPost / easypost-python / easypost / __init__.py View on Github external
def buy(self, **params):
        requestor = Requestor(self._api_key)
        url = "%s/%s" % (self.instance_url(), "buy")
        response, api_key = requestor.request('post', url, params)
        self.refresh_from(response, api_key)
        return self
github EasyPost / easypost-python / easypost / __init__.py View on Github external
def create(cls, api_key=None, **params):
        requestor = Requestor(api_key)
        url = cls.class_url()
        wrapped_params = {cls.class_name(): params}
        response, api_key = requestor.request('post', url, wrapped_params)
        return convert_to_easypost_object(response, api_key)
github EasyPost / easypost-python / easypost / __init__.py View on Github external
def add_shipments(self, **params):
        requestor = Requestor(self._api_key)
        url = "%s/%s" % (self.instance_url(), "add_shipments")
        response, api_key = requestor.request('post', url, params)
        self.refresh_from(response, api_key)
        return self
github EasyPost / easypost-python / easypost / __init__.py View on Github external
def update(self, **params):
        requestor = Requestor(self._api_key)
        url = self.instance_url()
        response, api_key = requestor.request('put', url, params)
        self.refresh_from(response, api_key)
        return self