Class: Io::Flow::V0::Models::PhysicalDelivery

Inherits:
Delivery
  • 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

Attributes inherited from Delivery

#discriminator

Instance Method Summary collapse

Methods inherited from Delivery

from_json, #to_hash

Constructor Details

#initialize(incoming = {}) ⇒ PhysicalDelivery

Returns a new instance of PhysicalDelivery.



33450
33451
33452
33453
33454
33455
33456
33457
33458
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33450

def initialize(incoming={})
  super(:discriminator => Delivery::Types::PHYSICAL_DELIVERY)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :items, :options], 'PhysicalDelivery')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @center = (x = opts.delete(:center); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::CenterSummary) ? x : ::Io::Flow::V0::Models::CenterSummary.new(x)))
  @items = HttpClient::Preconditions.assert_class('items', opts.delete(:items), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::DeliveryItem) ? x : ::Io::Flow::V0::Models::DeliveryItem.new(x)) }
  @options = HttpClient::Preconditions.assert_class('options', opts.delete(:options), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::DeliveryOption) ? x : ::Io::Flow::V0::Models::DeliveryOption.new(x)) }
end

Instance Attribute Details

#centerObject (readonly)

Returns the value of attribute center.



33448
33449
33450
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33448

def center
  @center
end

#idObject (readonly)

Returns the value of attribute id.



33448
33449
33450
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33448

def id
  @id
end

#itemsObject (readonly)

Returns the value of attribute items.



33448
33449
33450
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33448

def items
  @items
end

#optionsObject (readonly)

Returns the value of attribute options.



33448
33449
33450
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33448

def options
  @options
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



33464
33465
33466
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33464

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

#subtype_to_hashObject



33468
33469
33470
33471
33472
33473
33474
33475
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33468

def subtype_to_hash
  {
    :id => id,
    :center => center.nil? ? nil : center.to_hash,
    :items => items.map { |o| o.to_hash },
    :options => options.map { |o| o.to_hash }
  }
end

#to_jsonObject



33460
33461
33462
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33460

def to_json
  JSON.dump(to_hash)
end