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.



35878
35879
35880
35881
35882
35883
35884
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35878

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



35876
35877
35878
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35876

def delivery
  @delivery
end

#destinationObject (readonly)

Returns the value of attribute destination.



35876
35877
35878
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35876

def destination
  @destination
end

#itemsObject (readonly)

Returns the value of attribute items.



35876
35877
35878
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35876

def items
  @items
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



35890
35891
35892
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35890

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

#to_hashObject



35894
35895
35896
35897
35898
35899
35900
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35894

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

#to_jsonObject



35886
35887
35888
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35886

def to_json
  JSON.dump(to_hash)
end