goshippo / shippo-ruby-client

Shipping API Ruby library (USPS, FedEx, UPS and more)
https://goshippo.com/docs/
76 stars 72 forks source link

Fix rate call for Shipments #83

Closed mtking2 closed 5 years ago

mtking2 commented 6 years ago

Calling Shippo::Shipment.rates('<shipment_object_id>') would result in the following error:

Shippo::Exceptions::ConnectionError: Shippo::Exceptions::ConnectionError (Could not connect to the Shippo API, via URL
https://api.goshippo.com/shipments/rates/<shipment_object_id>/.
Please check your Internet connection, try again, if the problem
persists please contact Shippo Customer Support.
Error Description:
RestClient::NotFound ⇨ 404 Not Found)

This would just normally mean there are no rates for that shipment.

However,

[https://api.goshippo.com/shipments/rates//]()

is not the correct endpoint.

This PR adds a param for the shipment object ID and interpolates it into the url, resulting in the endpoint with correct params: [https://api.goshippo.com/shipments//rates]()

With these changes it can be called without error like so:

Shippo::Shipment.rates('<shipment_object_id>') or Shippo::Shipment.rates('<shipment_object_id>', '<currency_code>')