How to use the easypost.__init__.AllResource 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
return convert_to_easypost_object(response, api_key)


class Insurance(AllResource, CreateResource):
    pass


class CustomsItem(AllResource, CreateResource):
    pass


class CustomsInfo(AllResource, CreateResource):
    pass


class Parcel(AllResource, CreateResource):
    pass


class Shipment(AllResource, CreateResource):
    @classmethod
    def track_with_code(cls, api_key=None, **params):
        requestor = Requestor(api_key)
        url = "%s/%s" % (cls.class_url(), "track")
        response, api_key = requestor.request('get', url, params)
        return response

    def get_rates(self):
        requestor = Requestor(self._api_key)
        url = "%s/%s" % (self.instance_url(), "rates")
        response, api_key = requestor.request('get', url)
        self.refresh_from(response, api_key)
github EasyPost / easypost-python / easypost / __init__.py View on Github external
self.refresh_from(response, api_key)
        return self

    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


class PostageLabel(AllResource, CreateResource):
    pass


class Tracker(AllResource, CreateResource):
    @classmethod
    def create_list(cls, api_key=None, **params):
        requestor = Requestor(api_key)
        url = "%s/%s" % (cls.class_url(), "create_list")
        response, api_key = requestor.request('post', url, params)
        return True

    @classmethod
    def all_updated(cls, api_key=None, **params):
        requestor = Requestor(api_key)
        url = "%s/%s" % (cls.class_url(), "all_updated")
        response, api_key = requestor.request('get', url, params)
        return convert_to_easypost_object(response["trackers"], api_key), response["has_more"]


class Pickup(AllResource, CreateResource):
github EasyPost / easypost-python / easypost / __init__.py View on Github external
class ScanForm(AllResource, CreateResource):
    @classmethod
    def create(cls, api_key=None, **params):
        requestor = Requestor(api_key)
        url = cls.class_url()
        response, api_key = requestor.request('post', url, params)
        return convert_to_easypost_object(response, api_key)


class Insurance(AllResource, CreateResource):
    pass


class CustomsItem(AllResource, CreateResource):
    pass


class CustomsInfo(AllResource, CreateResource):
    pass


class Parcel(AllResource, CreateResource):
    pass


class Shipment(AllResource, CreateResource):
    @classmethod
    def track_with_code(cls, api_key=None, **params):
        requestor = Requestor(api_key)
        url = "%s/%s" % (cls.class_url(), "track")
github EasyPost / easypost-python / easypost / __init__.py View on Github external
url += "?carrier=%s" % carrier
        response, api_key = requestor.request('get', url)

        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')
            return verified_address
        else:
            return convert_to_easypost_object(response, api_key)


class ScanForm(AllResource, CreateResource):
    @classmethod
    def create(cls, api_key=None, **params):
        requestor = Requestor(api_key)
        url = cls.class_url()
        response, api_key = requestor.request('post', url, params)
        return convert_to_easypost_object(response, api_key)


class Insurance(AllResource, CreateResource):
    pass


class CustomsItem(AllResource, CreateResource):
    pass
github EasyPost / easypost-python / easypost / __init__.py View on Github external
    @classmethod
    def create_list(cls, api_key=None, **params):
        requestor = Requestor(api_key)
        url = "%s/%s" % (cls.class_url(), "create_list")
        response, api_key = requestor.request('post', url, params)
        return True

    @classmethod
    def all_updated(cls, api_key=None, **params):
        requestor = Requestor(api_key)
        url = "%s/%s" % (cls.class_url(), "all_updated")
        response, api_key = requestor.request('get', url, params)
        return convert_to_easypost_object(response["trackers"], api_key), response["has_more"]


class Pickup(AllResource, CreateResource):
    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

    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


class Order(AllResource, CreateResource):
github EasyPost / easypost-python / easypost / __init__.py View on Github external
response, api_key = requestor.request('post', url, params)
        self.refresh_from(response, api_key)
        return self


class PickupRate(Resource):
    pass


class Event(Resource):
    @classmethod
    def receive(self, values):
        return convert_to_easypost_object(json.loads(values), api_key)


class CarrierAccount(AllResource, CreateResource, UpdateResource, DeleteResource):
    @classmethod
    def types(cls, api_key=None):
        requestor = Requestor(api_key)
        response, api_key = requestor.request('get', "/carrier_types")
        return convert_to_easypost_object(response, api_key)


class User(CreateResource, UpdateResource, DeleteResource):
    @classmethod
    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, False)
        return convert_to_easypost_object(response, api_key)
github EasyPost / easypost-python / easypost / __init__.py View on Github external
verified_address._immutable_values.update('message')
            return verified_address
        else:
            return convert_to_easypost_object(response, api_key)


class ScanForm(AllResource, CreateResource):
    @classmethod
    def create(cls, api_key=None, **params):
        requestor = Requestor(api_key)
        url = cls.class_url()
        response, api_key = requestor.request('post', url, params)
        return convert_to_easypost_object(response, api_key)


class Insurance(AllResource, CreateResource):
    pass


class CustomsItem(AllResource, CreateResource):
    pass


class CustomsInfo(AllResource, CreateResource):
    pass


class Parcel(AllResource, CreateResource):
    pass


class Shipment(AllResource, CreateResource):
github EasyPost / easypost-python / easypost / __init__.py View on Github external
continue

            if lowest_rate is None or float(rate.rate) < float(lowest_rate.rate):
                lowest_rate = rate

        if lowest_rate is None:
            raise Error('No rates found.')

        return lowest_rate


class Rate(CreateResource):
    pass


class Refund(AllResource, CreateResource):
    pass


class Batch(AllResource, CreateResource):
    @classmethod
    def create_and_buy(cls, api_key=None, **params):
        requestor = Requestor(api_key)
        url = "%s/%s" % (cls.class_url(), "create_and_buy")
        wrapped_params = {cls.class_name(): params}
        response, api_key = requestor.request('post', url, wrapped_params)
        return convert_to_easypost_object(response, api_key)

    def buy(self, **params):
        requestor = Requestor(self._api_key)
        url = "%s/%s" % (self.instance_url(), "buy")
        response, api_key = requestor.request('post', url, params)
github EasyPost / easypost-python / easypost / __init__.py View on Github external
self.refresh_from(response, api_key)

        return self


class DeleteResource(Resource):
    def delete(self, **params):
        requestor = Requestor(self._api_key)
        url = self.instance_url()
        response, api_key = requestor.request('delete', url, params)
        self.refresh_from(response, api_key)
        return self


# specific resources
class Address(AllResource, CreateResource):

    @classmethod
    def create(cls, api_key=None, verify=None, verify_strict=None, **params):
        requestor = Requestor(api_key)
        url = cls.class_url()

        if verify or verify_strict:
            verify = verify or []
            verify_strict = verify_strict or []
            url += '?' + '&'.join(
                ['verify[]={0}'.format(opt) for opt in verify] +
                ['verify_strict[]={0}'.format(opt) for opt in verify_strict]
            )

        wrapped_params = {cls.class_name(): params}
        response, api_key = requestor.request('post', url, wrapped_params)
github EasyPost / easypost-python / easypost / __init__.py View on Github external
if lowest_rate is None:
            raise Error('No rates found.')

        return lowest_rate


class Rate(CreateResource):
    pass


class Refund(AllResource, CreateResource):
    pass


class Batch(AllResource, CreateResource):
    @classmethod
    def create_and_buy(cls, api_key=None, **params):
        requestor = Requestor(api_key)
        url = "%s/%s" % (cls.class_url(), "create_and_buy")
        wrapped_params = {cls.class_name(): params}
        response, api_key = requestor.request('post', url, wrapped_params)
        return convert_to_easypost_object(response, api_key)

    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

    def label(self, **params):