Class: Io::Flow::V0::Models::DeliveryOptionForm

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

Overview

Represents a way to fulfill a delivery, including an estimates for the date range and cost

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ DeliveryOptionForm

Returns a new instance of DeliveryOptionForm.



11573
11574
11575
11576
11577
11578
11579
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11573

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:delivery, :items, :destination], 'DeliveryOptionForm')
  @delivery = HttpClient::Preconditions.assert_class('delivery', opts.delete(:delivery), 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

#delivery ⇒ Object (readonly)

Returns the value of attribute delivery.



11571
11572
11573
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11571

def delivery
  @delivery
end

#destination ⇒ Object (readonly)

Returns the value of attribute destination.



11571
11572
11573
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11571

def destination
  @destination
end

#items ⇒ Object (readonly)

Returns the value of attribute items.



11571
11572
11573
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11571

def items
  @items
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



11585
11586
11587
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11585

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

#to_hash ⇒ Object



11589
11590
11591
11592
11593
11594
11595
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11589

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

#to_json ⇒ Object



11581
11582
11583
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11581

def to_json
  JSON.dump(to_hash)
end