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.



14270
14271
14272
14273
14274
14275
14276
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14270

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.



14268
14269
14270
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14268

def destination
  @destination
end

#experienceObject (readonly)

Returns the value of attribute experience.



14268
14269
14270
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14268

def experience
  @experience
end

#itemsObject (readonly)

Returns the value of attribute items.



14268
14269
14270
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14268

def items
  @items
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



14282
14283
14284
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14282

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

#to_hashObject



14286
14287
14288
14289
14290
14291
14292
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14286

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

#to_jsonObject



14278
14279
14280
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14278

def to_json
  JSON.dump(to_hash)
end