Class: Io::Flow::V0::Models::DeliveryForm

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

Overview

Represents a collection of items, the available delivery option tier for that collection of items, and metadata about those options

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ DeliveryForm

Returns a new instance of DeliveryForm.



12440
12441
12442
12443
12444
12445
12446
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12440

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:quote, :items, :destination], 'DeliveryForm')
  @quote = HttpClient::Preconditions.assert_class('quote', opts.delete(:quote), 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)) }
  @destination = (x = opts.delete(:destination); x.is_a?(::Io::Flow::V0::Models::ShippingAddress) ? x : ::Io::Flow::V0::Models::ShippingAddress.new(x))
end

Instance Attribute Details

#destinationObject (readonly)

Returns the value of attribute destination.



12438
12439
12440
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12438

def destination
  @destination
end

#itemsObject (readonly)

Returns the value of attribute items.



12438
12439
12440
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12438

def items
  @items
end

#quoteObject (readonly)

Returns the value of attribute quote.



12438
12439
12440
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12438

def quote
  @quote
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



12452
12453
12454
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12452

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

#to_hashObject



12456
12457
12458
12459
12460
12461
12462
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12456

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

#to_jsonObject



12448
12449
12450
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12448

def to_json
  JSON.dump(to_hash)
end