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.



18937
18938
18939
18940
18941
18942
18943
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18937

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::LineItemForm) ? x : ::Io::Flow::V0::Models::LineItemForm.new(x)) }
end

Instance Attribute Details

#destinationObject (readonly)

Returns the value of attribute destination.



18935
18936
18937
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18935

def destination
  @destination
end

#experienceObject (readonly)

Returns the value of attribute experience.



18935
18936
18937
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18935

def experience
  @experience
end

#itemsObject (readonly)

Returns the value of attribute items.



18935
18936
18937
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18935

def items
  @items
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



18949
18950
18951
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18949

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

#to_hashObject



18953
18954
18955
18956
18957
18958
18959
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18953

def to_hash
  {
    :destination => destination.to_hash,
    :experience => experience,
    :items => items.map { |o| o.to_hash }
  }
end

#to_jsonObject



18945
18946
18947
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18945

def to_json
  JSON.dump(to_hash)
end