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.



18761
18762
18763
18764
18765
18766
18767
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18761

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

#destination ⇒ Object (readonly)

Returns the value of attribute destination.



18759
18760
18761
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18759

def destination
  @destination
end

#experience ⇒ Object (readonly)

Returns the value of attribute experience.



18759
18760
18761
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18759

def experience
  @experience
end

#items ⇒ Object (readonly)

Returns the value of attribute items.



18759
18760
18761
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18759

def items
  @items
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



18773
18774
18775
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18773

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

#to_hash ⇒ Object



18777
18778
18779
18780
18781
18782
18783
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18777

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

#to_json ⇒ Object



18769
18770
18771
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18769

def to_json
  JSON.dump(to_hash)
end