Class: Io::Flow::V0::Clients::RatecardEstimates
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::RatecardEstimates
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
-
#initialize(client) ⇒ RatecardEstimates
constructor
A new instance of RatecardEstimates.
-
#post(organization, ratecard_estimate_form, incoming = {}) ⇒ Object
Endpoint to get shipment cost estimates based on applicable rate cards.
-
#post_summaries(organization, ratecard_estimate_summary_form, incoming = {}) ⇒ Object
Endpoint to get a summary of the shipment estimates based on applicable rate cards.
Constructor Details
#initialize(client) ⇒ RatecardEstimates
Returns a new instance of RatecardEstimates.
4328 4329 4330 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4328 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#post(organization, ratecard_estimate_form, incoming = {}) ⇒ Object
Endpoint to get shipment cost estimates based on applicable rate cards. An origin and destination address must be provided. Final amounts are based on either gravitational weight or dimensional weight. When estimating based off gravitational weight, the weight field must be set. When estimating based off dimensional weight, then length/width/depth must be set. For either one, the appropriate unit of measurement must be given.
4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4338 def post(organization, ratecard_estimate_form, incoming={}) HttpClient::Preconditions.assert_class('organization', organization, String) opts = HttpClient::Helper.symbolize_keys(incoming) query = { :context => (x = opts.delete(:context); x.nil? ? nil : HttpClient::Preconditions.assert_class('context', x, String)) }.delete_if { |k, v| v.nil? } (x = ratecard_estimate_form; x.is_a?(::Io::Flow::V0::Models::RatecardEstimateForm) ? x : ::Io::Flow::V0::Models::RatecardEstimateForm.from_json(x)) r = @client.request("/#{CGI.escape(organization)}/ratecard_estimates").with_query(query).with_json(ratecard_estimate_form.to_json).post r.map { |x| ::Io::Flow::V0::Models::RatecardEstimate.from_json(x) } end |
#post_summaries(organization, ratecard_estimate_summary_form, incoming = {}) ⇒ Object
Endpoint to get a summary of the shipment estimates based on applicable rate cards. An origin and destination country must be provided.
4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4351 def post_summaries(organization, ratecard_estimate_summary_form, incoming={}) HttpClient::Preconditions.assert_class('organization', organization, String) opts = HttpClient::Helper.symbolize_keys(incoming) query = { :context => (x = opts.delete(:context); x.nil? ? nil : HttpClient::Preconditions.assert_class('context', x, String)) }.delete_if { |k, v| v.nil? } (x = ratecard_estimate_summary_form; x.is_a?(::Io::Flow::V0::Models::RatecardEstimateSummaryForm) ? x : ::Io::Flow::V0::Models::RatecardEstimateSummaryForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/ratecard_estimates/summaries").with_query(query).with_json(ratecard_estimate_summary_form.to_json).post r.map { |x| ::Io::Flow::V0::Models::RatecardEstimate.from_json(x) } end |