From ca012477f4aa8beb856db639423af6b886e0337c Mon Sep 17 00:00:00 2001 From: Jake Epstein Date: Tue, 14 Feb 2017 18:06:08 -0800 Subject: [PATCH] added get_rates method to Order objects --- CHANGELOG | 5 +++++ VERSION | 2 +- easypost/__init__.py | 7 +++++++ easypost/version.py | 2 +- tests/batch.py | 2 +- tests/order.py | 9 +++++++++ tests/shipment.py | 9 +++++++++ 7 files changed, 33 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 2c2762c3..c2afc1f7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,8 @@ +=== 3.5.2 2017-02-14 + +* Added get_rates method to Order objects + + === 3.5.1 2017-01-19 * Fixed create for ScanForms diff --git a/VERSION b/VERSION index d5c0c991..87ce4929 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.5.1 +3.5.2 diff --git a/easypost/__init__.py b/easypost/__init__.py index 88cbed56..ea40594e 100644 --- a/easypost/__init__.py +++ b/easypost/__init__.py @@ -855,6 +855,13 @@ def cancel(self, **params): class Order(AllResource, CreateResource): + 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) + return self + def buy(self, **params): requestor = Requestor(self.api_key) url = "%s/%s" % (self.instance_url(), "buy") diff --git a/easypost/version.py b/easypost/version.py index f8f14bfa..df29a6d3 100644 --- a/easypost/version.py +++ b/easypost/version.py @@ -1 +1 @@ -VERSION = '3.5.1' +VERSION = '3.5.2' diff --git a/tests/batch.py b/tests/batch.py index bd245b9e..10552501 100644 --- a/tests/batch.py +++ b/tests/batch.py @@ -80,7 +80,7 @@ def test_batch_create_and_buy(self): # Assert on fees assert batch.shipments[0].fees[0].amount == '0.03000' - assert batch.shipments[0].fees[1].amount == '6.01000' + assert batch.shipments[0].fees[1].amount == '6.52000' assert batch.shipments[0].fees[2].amount == '1.00000' # Assert on parcel diff --git a/tests/order.py b/tests/order.py index be5980d0..476ab449 100644 --- a/tests/order.py +++ b/tests/order.py @@ -55,6 +55,15 @@ def test_order_create_then_buy(self): }] ) + rate_id = order.shipments[0].rates[0].id + assert rate_id is not None + + order.get_rates() + + new_rate_id = order.shipments[0].rates[0].id + assert new_rate_id is not None + assert new_rate_id != rate_id + assert order.buyer_address.name == to_address['name'] assert order.buyer_address.company == to_address['company'] assert order.buyer_address.street1 == to_address['street1'] diff --git a/tests/shipment.py b/tests/shipment.py index 82930366..d14f964f 100644 --- a/tests/shipment.py +++ b/tests/shipment.py @@ -70,6 +70,15 @@ def test_shipment_creation(self): customs_info=customs_info ) + rate_id = shipment.rates[0].id + assert rate_id is not None + + shipment.get_rates() + + new_rate_id = shipment.rates[0].id + assert new_rate_id is not None + assert new_rate_id != rate_id + # Assert address values match assert shipment.buyer_address.country == to_address.country assert shipment.buyer_address.phone == to_address.phone