Class: Io::Flow::V0::Models::DigitalDelivery

Inherits:
Delivery
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Overview

Represents a collection of items that are digitally available and do not require a physical shipment

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 = {}) ⇒ DigitalDelivery

Returns a new instance of DigitalDelivery.



36502
36503
36504
36505
36506
36507
36508
36509
36510
36511
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36502

def initialize(incoming={})
  super(:discriminator => Delivery::Types::DIGITAL_DELIVERY)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :items], 'DigitalDelivery')
  @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))
  @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)) }
  @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)))
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



36500
36501
36502
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36500

def id
  @id
end

#itemsObject (readonly)

Returns the value of attribute items.



36500
36501
36502
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36500

def items
  @items
end

#keyObject (readonly)

Returns the value of attribute key.



36500
36501
36502
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36500

def key
  @key
end

#pricesObject (readonly)

Returns the value of attribute prices.



36500
36501
36502
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36500

def prices
  @prices
end

#totalObject (readonly)

Returns the value of attribute total.



36500
36501
36502
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36500

def total
  @total
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



36517
36518
36519
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36517

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

#subtype_to_hashObject



36521
36522
36523
36524
36525
36526
36527
36528
36529
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36521

def subtype_to_hash
  {
    :id => id,
    :key => key,
    :items => items.map { |o| o.to_hash },
    :prices => prices.nil? ? nil : prices.map { |o| o.to_hash },
    :total => total.nil? ? nil : total.to_hash
  }
end

#to_jsonObject



36513
36514
36515
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36513

def to_json
  JSON.dump(to_hash)
end