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.



7643
7644
7645
7646
7647
7648
7649
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7643

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::LineItem) ? x : ::Io::Flow::V0::Models::LineItem.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

#deliveryObject (readonly)

Returns the value of attribute delivery.



7641
7642
7643
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7641

def delivery
  @delivery
end

#destinationObject (readonly)

Returns the value of attribute destination.



7641
7642
7643
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7641

def destination
  @destination
end

#itemsObject (readonly)

Returns the value of attribute items.



7641
7642
7643
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7641

def items
  @items
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



7655
7656
7657
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7655

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

#to_hashObject



7659
7660
7661
7662
7663
7664
7665
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7659

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

#to_jsonObject



7651
7652
7653
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7651

def to_json
  JSON.dump(to_hash)
end