Class: Io::Flow::V0::Models::Fulfillment

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

Overview

Used to track and manage the fulfillment of an order.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ Fulfillment

Returns a new instance of Fulfillment.



33986
33987
33988
33989
33990
33991
33992
33993
33994
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33986

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:organization, :key, :number, :items], 'Fulfillment')
  @organization = HttpClient::Preconditions.assert_class('organization', opts.delete(:organization), String)
  @key = HttpClient::Preconditions.assert_class('key', opts.delete(:key), String)
  @number = HttpClient::Preconditions.assert_class('number', opts.delete(:number), String)
  @items = HttpClient::Preconditions.assert_class('items', opts.delete(:items), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::FulfillmentItem) ? x : ::Io::Flow::V0::Models::FulfillmentItem.new(x)) }
  @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)))
end

Instance Attribute Details

#centerObject (readonly)

Returns the value of attribute center.



33984
33985
33986
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33984

def center
  @center
end

#itemsObject (readonly)

Returns the value of attribute items.



33984
33985
33986
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33984

def items
  @items
end

#keyObject (readonly)

Returns the value of attribute key.



33984
33985
33986
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33984

def key
  @key
end

#numberObject (readonly)

Returns the value of attribute number.



33984
33985
33986
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33984

def number
  @number
end

#organizationObject (readonly)

Returns the value of attribute organization.



33984
33985
33986
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33984

def organization
  @organization
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



34000
34001
34002
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34000

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

#to_hashObject



34004
34005
34006
34007
34008
34009
34010
34011
34012
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34004

def to_hash
  {
    :organization => organization,
    :key => key,
    :number => number,
    :items => items.map { |o| o.to_hash },
    :center => center.nil? ? nil : center.to_hash
  }
end

#to_jsonObject



33996
33997
33998
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33996

def to_json
  JSON.dump(to_hash)
end