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.



20230
20231
20232
20233
20234
20235
20236
20237
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20230

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)) }
  @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)))
end

Instance Attribute Details

#delivered_dutyObject (readonly)

Returns the value of attribute delivered_duty.



20228
20229
20230
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20228

def delivered_duty
  @delivered_duty
end

#destinationObject (readonly)

Returns the value of attribute destination.



20228
20229
20230
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20228

def destination
  @destination
end

#experienceObject (readonly)

Returns the value of attribute experience.



20228
20229
20230
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20228

def experience
  @experience
end

#itemsObject (readonly)

Returns the value of attribute items.



20228
20229
20230
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20228

def items
  @items
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



20243
20244
20245
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20243

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

#to_hashObject



20247
20248
20249
20250
20251
20252
20253
20254
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20247

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
  }
end

#to_jsonObject



20239
20240
20241
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20239

def to_json
  JSON.dump(to_hash)
end