Class: Io::Flow::V0::Models::PhysicalDelivery
- 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
-
#center ⇒ Object
readonly
Returns the value of attribute center.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#special_services ⇒ Object
readonly
Returns the value of attribute special_services.
Attributes inherited from Delivery
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ PhysicalDelivery
constructor
A new instance of PhysicalDelivery.
- #subtype_to_hash ⇒ Object
- #to_json ⇒ Object
Methods inherited from Delivery
Constructor Details
#initialize(incoming = {}) ⇒ PhysicalDelivery
Returns a new instance of PhysicalDelivery.
35001 35002 35003 35004 35005 35006 35007 35008 35009 35010 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35001 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)) } = 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
#center ⇒ Object (readonly)
Returns the value of attribute center.
34999 35000 35001 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34999 def center @center end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
34999 35000 35001 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34999 def id @id end |
#items ⇒ Object (readonly)
Returns the value of attribute items.
34999 35000 35001 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34999 def items @items end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
34999 35000 35001 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34999 def end |
#special_services ⇒ Object (readonly)
Returns the value of attribute special_services.
34999 35000 35001 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34999 def special_services @special_services end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
35016 35017 35018 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35016 def copy(incoming={}) PhysicalDelivery.new(subtype_to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#subtype_to_hash ⇒ Object
35020 35021 35022 35023 35024 35025 35026 35027 35028 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35020 def subtype_to_hash { :id => id, :center => center.nil? ? nil : center.to_hash, :items => items.map { |o| o.to_hash }, :options => .map { |o| o.to_hash }, :special_services => special_services.nil? ? nil : special_services.map { |o| o.value } } end |
#to_json ⇒ Object
35012 35013 35014 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35012 def to_json JSON.dump(to_hash) end |