class Io::Flow::V0::Models::RatecardEstimateV1

Represents a summary of a cost estimate based on rate card data for an origin/destination and weight, either gravitational or dimensional

Attributes

amount[R]
currency[R]
delivered_duty[R]
dimensional_weight[R]
fees[R]
gravitational_weight[R]
line_items[R]
service[R]
shipment_window[R]
total[R]

Public Class Methods

new(incoming={}) click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 61984
def initialize(incoming={})
  super(:discriminator => RatecardEstimate::Types::RATECARD_ESTIMATE_V1)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:service, :shipment_window, :currency, :amount, :fees, :total, :delivered_duty], 'RatecardEstimateV1')
  @service = (x = opts.delete(:service); x.is_a?(::Io::Flow::V0::Models::RatecardServiceSummary) ? x : ::Io::Flow::V0::Models::RatecardServiceSummary.new(x))
  @shipment_window = (x = opts.delete(:shipment_window); x.is_a?(::Io::Flow::V0::Models::ShipmentWindow) ? x : ::Io::Flow::V0::Models::ShipmentWindow.new(x))
  @currency = HttpClient::Preconditions.assert_class('currency', opts.delete(:currency), String)
  @amount = HttpClient::Preconditions.assert_class('amount', opts.delete(:amount), Numeric)
  @fees = HttpClient::Preconditions.assert_class('fees', opts.delete(:fees), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::RatecardFee) ? x : ::Io::Flow::V0::Models::RatecardFee.from_json(x)) }
  @total = HttpClient::Preconditions.assert_class('total', opts.delete(:total), Numeric)
  @delivered_duty = (x = opts.delete(:delivered_duty); x.is_a?(::Io::Flow::V0::Models::DeliveredDuty) ? x : ::Io::Flow::V0::Models::DeliveredDuty.apply(x))
  @dimensional_weight = (x = opts.delete(:dimensional_weight); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::Measurement) ? x : ::Io::Flow::V0::Models::Measurement.new(x)))
  @gravitational_weight = (x = opts.delete(:gravitational_weight); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::Measurement) ? x : ::Io::Flow::V0::Models::Measurement.new(x)))
  @line_items = (x = opts.delete(:line_items); x.nil? ? nil : HttpClient::Preconditions.assert_class('line_items', x, Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::LineItemForm) ? x : ::Io::Flow::V0::Models::LineItemForm.new(x)) })
end

Public Instance Methods

copy(incoming={}) click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 62004
def copy(incoming={})
  RatecardEstimateV1.new(subtype_to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end
subtype_to_hash() click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 62008
def subtype_to_hash
  {
    :service => service.to_hash,
    :shipment_window => shipment_window.to_hash,
    :currency => currency,
    :amount => amount,
    :fees => fees.map { |o| o.to_hash },
    :total => total,
    :delivered_duty => delivered_duty.value,
    :dimensional_weight => dimensional_weight.nil? ? nil : dimensional_weight.to_hash,
    :gravitational_weight => gravitational_weight.nil? ? nil : gravitational_weight.to_hash,
    :line_items => line_items.nil? ? nil : line_items.map { |o| o.to_hash }
  }
end
to_json() click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 62000
def to_json
  JSON.dump(to_hash)
end