Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
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')
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
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
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"]
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
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 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)
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
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