Class: Io::Flow::V0::Models::RatecardEstimateV3

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

Overview

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

Instance Attribute Summary collapse

Attributes inherited from RatecardEstimate

#discriminator

Instance Method Summary collapse

Methods inherited from RatecardEstimate

from_json, #to_hash

Constructor Details

#initialize(incoming = {}) ⇒ RatecardEstimateV3

Returns a new instance of RatecardEstimateV3.



62070
62071
62072
62073
62074
62075
62076
62077
62078
62079
62080
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 62070

def initialize(incoming={})
  super(:discriminator => RatecardEstimate::Types::RATECARD_ESTIMATE_V3)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:hops, :delivered_duty, :ratecard], 'RatecardEstimateV3')
  @hops = HttpClient::Preconditions.assert_class('hops', opts.delete(:hops), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::Hop) ? x : ::Io::Flow::V0::Models::Hop.new(x)) }
  @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)) })
  @ratecard = (x = opts.delete(:ratecard); x.is_a?(::Io::Flow::V0::Models::RatecardSummary) ? x : ::Io::Flow::V0::Models::RatecardSummary.new(x))
end

Instance Attribute Details

#delivered_dutyObject (readonly)

Returns the value of attribute delivered_duty.



62068
62069
62070
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 62068

def delivered_duty
  @delivered_duty
end

#dimensional_weightObject (readonly)

Returns the value of attribute dimensional_weight.



62068
62069
62070
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 62068

def dimensional_weight
  @dimensional_weight
end

#gravitational_weightObject (readonly)

Returns the value of attribute gravitational_weight.



62068
62069
62070
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 62068

def gravitational_weight
  @gravitational_weight
end

#hopsObject (readonly)

Returns the value of attribute hops.



62068
62069
62070
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 62068

def hops
  @hops
end

#line_itemsObject (readonly)

Returns the value of attribute line_items.



62068
62069
62070
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 62068

def line_items
  @line_items
end

#ratecardObject (readonly)

Returns the value of attribute ratecard.



62068
62069
62070
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 62068

def ratecard
  @ratecard
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



62086
62087
62088
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 62086

def copy(incoming={})
  RatecardEstimateV3.new(subtype_to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end

#subtype_to_hashObject



62090
62091
62092
62093
62094
62095
62096
62097
62098
62099
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 62090

def subtype_to_hash
  {
    :hops => hops.map { |o| o.to_hash },
    :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 },
    :ratecard => ratecard.to_hash
  }
end

#to_jsonObject



62082
62083
62084
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 62082

def to_json
  JSON.dump(to_hash)
end