Skip to content

Commit

Permalink
added get_rates method to Order objects
Browse files Browse the repository at this point in the history
  • Loading branch information
victoryftw committed Feb 15, 2017
1 parent f7f6cf8 commit ca01247
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.5.1
3.5.2
7 changes: 7 additions & 0 deletions easypost/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion easypost/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = '3.5.1'
VERSION = '3.5.2'
2 changes: 1 addition & 1 deletion tests/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions tests/order.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down
9 changes: 9 additions & 0 deletions tests/shipment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ca01247

Please sign in to comment.