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.



15796
15797
15798
15799
15800
15801
15802
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15796

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)
  @items = HttpClient::Preconditions.assert_class('items', opts.delete(:items), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::LineItemForm) ? x : ::Io::Flow::V0::Models::LineItemForm.new(x)) }
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



15794
15795
15796
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15794

def id
  @id
end

#itemsObject (readonly)

Returns the value of attribute items.



15794
15795
15796
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15794

def items
  @items
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



15808
15809
15810
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15808

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

#subtype_to_hashObject



15812
15813
15814
15815
15816
15817
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15812

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

#to_jsonObject



15804
15805
15806
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15804

def to_json
  JSON.dump(to_hash)
end