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.



39155
39156
39157
39158
39159
39160
39161
39162
39163
39164
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 39155

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)) }
  @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)) })
end

Instance Attribute Details

#centerObject (readonly)

Returns the value of attribute center.



39153
39154
39155
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 39153

def center
  @center
end

#idObject (readonly)

Returns the value of attribute id.



39153
39154
39155
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 39153

def id
  @id
end

#itemsObject (readonly)

Returns the value of attribute items.



39153
39154
39155
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 39153

def items
  @items
end

#optionsObject (readonly)

Returns the value of attribute options.



39153
39154
39155
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 39153

def options
  @options
end

#special_servicesObject (readonly)

Returns the value of attribute special_services.



39153
39154
39155
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 39153

def special_services
  @special_services
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



39170
39171
39172
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 39170

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

#subtype_to_hashObject



39174
39175
39176
39177
39178
39179
39180
39181
39182
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 39174

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 },
    :special_services => special_services.nil? ? nil : special_services.map { |o| o.value }
  }
end

#to_jsonObject



39166
39167
39168
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 39166

def to_json
  JSON.dump(to_hash)
end