Class: Io::Flow::V0::Models::RatecardEstimateFormV2

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

Instance Attribute Summary collapse

Attributes inherited from RatecardEstimateForm

#discriminator

Instance Method Summary collapse

Methods inherited from RatecardEstimateForm

from_json, #to_hash

Constructor Details

#initialize(incoming = {}) ⇒ RatecardEstimateFormV2

Returns a new instance of RatecardEstimateFormV2.



44728
44729
44730
44731
44732
44733
44734
44735
44736
44737
44738
44739
44740
44741
44742
44743
44744
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 44728

def initialize(incoming={})
  super(:discriminator => RatecardEstimateForm::Types::RATECARD_ESTIMATE_FORM_V2)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:origin_address, :destination_address], 'RatecardEstimateFormV2')
  @origin_address = (x = opts.delete(:origin_address); x.is_a?(::Io::Flow::V0::Models::Address) ? x : ::Io::Flow::V0::Models::Address.new(x))
  @destination_address = (x = opts.delete(:destination_address); x.is_a?(::Io::Flow::V0::Models::Address) ? x : ::Io::Flow::V0::Models::Address.new(x))
  @weight_unit = (x = opts.delete(:weight_unit); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::UnitOfMeasurement) ? x : ::Io::Flow::V0::Models::UnitOfMeasurement.apply(x)))
  @distance_unit = (x = opts.delete(:distance_unit); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::UnitOfMeasurement) ? x : ::Io::Flow::V0::Models::UnitOfMeasurement.apply(x)))
  @service = (x = opts.delete(:service); x.nil? ? nil : HttpClient::Preconditions.assert_class('service', x, String))
  @weight = (x = opts.delete(:weight); x.nil? ? nil : HttpClient::Preconditions.assert_class('weight', x, Numeric))
  @length = (x = opts.delete(:length); x.nil? ? nil : HttpClient::Preconditions.assert_class('length', x, Numeric))
  @width = (x = opts.delete(:width); x.nil? ? nil : HttpClient::Preconditions.assert_class('width', x, Numeric))
  @depth = (x = opts.delete(:depth); x.nil? ? nil : HttpClient::Preconditions.assert_class('depth', x, Numeric))
  @delivered_duty = (x = opts.delete(:delivered_duty); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::DeliveredDuty) ? x : ::Io::Flow::V0::Models::DeliveredDuty.apply(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)) })
  @center_id = (x = opts.delete(:center_id); x.nil? ? nil : HttpClient::Preconditions.assert_class('center_id', x, String))
end

Instance Attribute Details

#center_idObject (readonly)

Returns the value of attribute center_id.



44726
44727
44728
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 44726

def center_id
  @center_id
end

#delivered_dutyObject (readonly)

Returns the value of attribute delivered_duty.



44726
44727
44728
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 44726

def delivered_duty
  @delivered_duty
end

#depthObject (readonly)

Returns the value of attribute depth.



44726
44727
44728
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 44726

def depth
  @depth
end

#destination_addressObject (readonly)

Returns the value of attribute destination_address.



44726
44727
44728
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 44726

def destination_address
  @destination_address
end

#distance_unitObject (readonly)

Returns the value of attribute distance_unit.



44726
44727
44728
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 44726

def distance_unit
  @distance_unit
end

#lengthObject (readonly)

Returns the value of attribute length.



44726
44727
44728
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 44726

def length
  @length
end

#line_itemsObject (readonly)

Returns the value of attribute line_items.



44726
44727
44728
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 44726

def line_items
  @line_items
end

#origin_addressObject (readonly)

Returns the value of attribute origin_address.



44726
44727
44728
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 44726

def origin_address
  @origin_address
end

#serviceObject (readonly)

Returns the value of attribute service.



44726
44727
44728
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 44726

def service
  @service
end

#weightObject (readonly)

Returns the value of attribute weight.



44726
44727
44728
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 44726

def weight
  @weight
end

#weight_unitObject (readonly)

Returns the value of attribute weight_unit.



44726
44727
44728
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 44726

def weight_unit
  @weight_unit
end

#widthObject (readonly)

Returns the value of attribute width.



44726
44727
44728
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 44726

def width
  @width
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



44750
44751
44752
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 44750

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

#subtype_to_hashObject



44754
44755
44756
44757
44758
44759
44760
44761
44762
44763
44764
44765
44766
44767
44768
44769
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 44754

def subtype_to_hash
  {
    :origin_address => origin_address.to_hash,
    :destination_address => destination_address.to_hash,
    :weight_unit => weight_unit.nil? ? nil : weight_unit.value,
    :distance_unit => distance_unit.nil? ? nil : distance_unit.value,
    :service => service,
    :weight => weight,
    :length => length,
    :width => width,
    :depth => depth,
    :delivered_duty => delivered_duty.nil? ? nil : delivered_duty.value,
    :line_items => line_items.nil? ? nil : line_items.map { |o| o.to_hash },
    :center_id => center_id
  }
end

#to_jsonObject



44746
44747
44748
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 44746

def to_json
  JSON.dump(to_hash)
end