Skip to content

Commit ca01247

Browse files
author
Jake Epstein
committed
added get_rates method to Order objects
1 parent f7f6cf8 commit ca01247

File tree

7 files changed

+33
-3
lines changed

7 files changed

+33
-3
lines changed

CHANGELOG

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
=== 3.5.2 2017-02-14
2+
3+
* Added get_rates method to Order objects
4+
5+
16
=== 3.5.1 2017-01-19
27

38
* Fixed create for ScanForms

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.5.1
1+
3.5.2

easypost/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,13 @@ def cancel(self, **params):
855855

856856

857857
class Order(AllResource, CreateResource):
858+
def get_rates(self):
859+
requestor = Requestor(self.api_key)
860+
url = "%s/%s" % (self.instance_url(), "rates")
861+
response, api_key = requestor.request('get', url)
862+
self.refresh_from(response, api_key)
863+
return self
864+
858865
def buy(self, **params):
859866
requestor = Requestor(self.api_key)
860867
url = "%s/%s" % (self.instance_url(), "buy")

easypost/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VERSION = '3.5.1'
1+
VERSION = '3.5.2'

tests/batch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def test_batch_create_and_buy(self):
8080

8181
# Assert on fees
8282
assert batch.shipments[0].fees[0].amount == '0.03000'
83-
assert batch.shipments[0].fees[1].amount == '6.01000'
83+
assert batch.shipments[0].fees[1].amount == '6.52000'
8484
assert batch.shipments[0].fees[2].amount == '1.00000'
8585

8686
# Assert on parcel

tests/order.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,15 @@ def test_order_create_then_buy(self):
5555
}]
5656
)
5757

58+
rate_id = order.shipments[0].rates[0].id
59+
assert rate_id is not None
60+
61+
order.get_rates()
62+
63+
new_rate_id = order.shipments[0].rates[0].id
64+
assert new_rate_id is not None
65+
assert new_rate_id != rate_id
66+
5867
assert order.buyer_address.name == to_address['name']
5968
assert order.buyer_address.company == to_address['company']
6069
assert order.buyer_address.street1 == to_address['street1']

tests/shipment.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,15 @@ def test_shipment_creation(self):
7070
customs_info=customs_info
7171
)
7272

73+
rate_id = shipment.rates[0].id
74+
assert rate_id is not None
75+
76+
shipment.get_rates()
77+
78+
new_rate_id = shipment.rates[0].id
79+
assert new_rate_id is not None
80+
assert new_rate_id != rate_id
81+
7382
# Assert address values match
7483
assert shipment.buyer_address.country == to_address.country
7584
assert shipment.buyer_address.phone == to_address.phone

0 commit comments

Comments
 (0)