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.



59735
59736
59737
59738
59739
59740
59741
59742
59743
59744
59745
59746
59747
59748
59749
59750
59751
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59735

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)
  @key = (x = opts.delete(:key); x.nil? ? nil : HttpClient::Preconditions.assert_class('key', x, 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)))
  @fulfillment_routing = (x = opts.delete(:fulfillment_routing); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::FulfillmentRouting) ? x : ::Io::Flow::V0::Models::FulfillmentRouting.apply(x)))
  @ship_from_country = (x = opts.delete(:ship_from_country); x.nil? ? nil : HttpClient::Preconditions.assert_class('ship_from_country', x, String))
  @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)) }
  @special_services = (x = opts.delete(:special_services); x.nil? ? nil : HttpClient::Preconditions.assert_class('special_services', x, Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::PhysicalDeliverySpecialSerivce) ? x : ::Io::Flow::V0::Models::PhysicalDeliverySpecialSerivce.apply(x)) })
  @prices = (x = opts.delete(:prices); x.nil? ? nil : HttpClient::Preconditions.assert_class('prices', x, Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::OrderPriceDetail) ? x : ::Io::Flow::V0::Models::OrderPriceDetail.new(x)) })
  @total = (x = opts.delete(:total); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::LocalizedTotal) ? x : ::Io::Flow::V0::Models::LocalizedTotal.new(x)))
  @goods_supply = (x = opts.delete(:goods_supply); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::GoodsSupply) ? x : ::Io::Flow::V0::Models::GoodsSupply.apply(x)))
  @merchant_of_record_flow_entity = (x = opts.delete(:merchant_of_record_flow_entity); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::FlowEntity) ? x : ::Io::Flow::V0::Models::FlowEntity.apply(x)))
end

Instance Attribute Details

#centerObject (readonly)

Returns the value of attribute center.



59733
59734
59735
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59733

def center
  @center
end

#fulfillment_routingObject (readonly)

Returns the value of attribute fulfillment_routing.



59733
59734
59735
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59733

def fulfillment_routing
  @fulfillment_routing
end

#goods_supplyObject (readonly)

Returns the value of attribute goods_supply.



59733
59734
59735
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59733

def goods_supply
  @goods_supply
end

#idObject (readonly)

Returns the value of attribute id.



59733
59734
59735
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59733

def id
  @id
end

#itemsObject (readonly)

Returns the value of attribute items.



59733
59734
59735
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59733

def items
  @items
end

#keyObject (readonly)

Returns the value of attribute key.



59733
59734
59735
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59733

def key
  @key
end

#merchant_of_record_flow_entityObject (readonly)

Returns the value of attribute merchant_of_record_flow_entity.



59733
59734
59735
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59733

def merchant_of_record_flow_entity
  @merchant_of_record_flow_entity
end

#optionsObject (readonly)

Returns the value of attribute options.



59733
59734
59735
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59733

def options
  @options
end

#pricesObject (readonly)

Returns the value of attribute prices.



59733
59734
59735
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59733

def prices
  @prices
end

#ship_from_countryObject (readonly)

Returns the value of attribute ship_from_country.



59733
59734
59735
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59733

def ship_from_country
  @ship_from_country
end

#special_servicesObject (readonly)

Returns the value of attribute special_services.



59733
59734
59735
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59733

def special_services
  @special_services
end

#totalObject (readonly)

Returns the value of attribute total.



59733
59734
59735
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59733

def total
  @total
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



59757
59758
59759
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59757

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

#subtype_to_hashObject



59761
59762
59763
59764
59765
59766
59767
59768
59769
59770
59771
59772
59773
59774
59775
59776
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59761

def subtype_to_hash
  {
    :id => id,
    :key => key,
    :center => center.nil? ? nil : center.to_hash,
    :fulfillment_routing => fulfillment_routing.nil? ? nil : fulfillment_routing.value,
    :ship_from_country => ship_from_country,
    :items => items.map { |o| o.to_hash },
    :options => options.map { |o| o.to_hash },
    :special_services => special_services.nil? ? nil : special_services.map { |o| o.value },
    :prices => prices.nil? ? nil : prices.map { |o| o.to_hash },
    :total => total.nil? ? nil : total.to_hash,
    :goods_supply => goods_supply.nil? ? nil : goods_supply.value,
    :merchant_of_record_flow_entity => merchant_of_record_flow_entity.nil? ? nil : merchant_of_record_flow_entity.value
  }
end

#to_jsonObject



59753
59754
59755
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59753

def to_json
  JSON.dump(to_hash)
end