Class: ShippyProAPI::ShipmentResource
- Inherits:
-
Resource
- Object
- Resource
- ShippyProAPI::ShipmentResource
show all
- Defined in:
- lib/shippy_pro_api/resources/shipment.rb
Instance Attribute Summary
Attributes inherited from Resource
#client
Instance Method Summary
collapse
Methods inherited from Resource
#initialize
Instance Method Details
#create(attributes) ⇒ Object
5
6
7
|
# File 'lib/shippy_pro_api/resources/shipment.rb', line 5
def create(attributes)
Shipment.new(post_request("Ship", body: attributes).body)
end
|
#retrieve_rates(attributes) ⇒ Object
9
10
11
12
13
14
15
16
|
# File 'lib/shippy_pro_api/resources/shipment.rb', line 9
def retrieve_rates(attributes)
response = post_request("GetRates", body: attributes).body
available_rates = response['Rates']&.map { |rate| Rate.new(rate) }
rates_errors = response['RatesErrors']&.map { |rate| RateError.new(rate) }
Rates.new(rates: available_rates, rates_errors: rates_errors)
end
|
#track(tracking_number) ⇒ Object
18
19
20
21
22
|
# File 'lib/shippy_pro_api/resources/shipment.rb', line 18
def track(tracking_number)
attributes = { code: tracking_number }
TrackingInfo.new(post_request("GetTracking", body: attributes).body)
end
|