Class: Io::Flow::V0::Models::QuoteForm

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ QuoteForm

Returns a new instance of QuoteForm.



56739
56740
56741
56742
56743
56744
56745
56746
56747
56748
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56739

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:destination, :experience, :items], 'QuoteForm')
  @destination = (x = opts.delete(:destination); x.is_a?(::Io::Flow::V0::Models::ShippingAddress) ? x : ::Io::Flow::V0::Models::ShippingAddress.new(x))
  @experience = HttpClient::Preconditions.assert_class('experience', opts.delete(:experience), String)
  @items = HttpClient::Preconditions.assert_class('items', opts.delete(:items), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::QuoteLineItemForm) ? x : ::Io::Flow::V0::Models::QuoteLineItemForm.new(x)) }
  @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)))
  @delivered_duties = (x = opts.delete(:delivered_duties); x.nil? ? nil : HttpClient::Preconditions.assert_class('delivered_duties', x, Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::DeliveredDuty) ? x : ::Io::Flow::V0::Models::DeliveredDuty.apply(x)) })
  @direction = (x = opts.delete(:direction); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::LaneDirection) ? x : ::Io::Flow::V0::Models::LaneDirection.apply(x)))
end

Instance Attribute Details

#delivered_dutiesObject (readonly)

Returns the value of attribute delivered_duties.



56737
56738
56739
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56737

def delivered_duties
  @delivered_duties
end

#delivered_dutyObject (readonly)

Returns the value of attribute delivered_duty.



56737
56738
56739
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56737

def delivered_duty
  @delivered_duty
end

#destinationObject (readonly)

Returns the value of attribute destination.



56737
56738
56739
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56737

def destination
  @destination
end

#directionObject (readonly)

Returns the value of attribute direction.



56737
56738
56739
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56737

def direction
  @direction
end

#experienceObject (readonly)

Returns the value of attribute experience.



56737
56738
56739
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56737

def experience
  @experience
end

#itemsObject (readonly)

Returns the value of attribute items.



56737
56738
56739
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56737

def items
  @items
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



56754
56755
56756
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56754

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

#to_hashObject



56758
56759
56760
56761
56762
56763
56764
56765
56766
56767
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56758

def to_hash
  {
    :destination => destination.to_hash,
    :experience => experience,
    :items => items.map { |o| o.to_hash },
    :delivered_duty => delivered_duty.nil? ? nil : delivered_duty.value,
    :delivered_duties => delivered_duties.nil? ? nil : delivered_duties.map { |o| o.value },
    :direction => direction.nil? ? nil : direction.value
  }
end

#to_jsonObject



56750
56751
56752
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56750

def to_json
  JSON.dump(to_hash)
end