Class: Io::Flow::V0::Clients::RatecardEstimates

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ RatecardEstimates

Returns a new instance of RatecardEstimates.



4122
4123
4124
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4122

def initialize(client)
  @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client)
end

Instance Method Details

#post(organization, ratecard_estimate_form) ⇒ 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.



4132
4133
4134
4135
4136
4137
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4132

def post(organization, ratecard_estimate_form)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  (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_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) ⇒ Object

Endpoint to get a summary of the shipment estimates based on applicable rate cards. An origin and destination country must be provided.



4141
4142
4143
4144
4145
4146
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4141

def post_summaries(organization, ratecard_estimate_summary_form)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  (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_json(ratecard_estimate_summary_form.to_json).post
  r.map { |x| ::Io::Flow::V0::Models::RatecardEstimate.from_json(x) }
end