Class: Io::Flow::V0::Models::OrderIdentifier

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

Overview

Represents alternate identifiers that can be used to lookup an order. Common use cases are to support attaching a primary identifier (e.g. a nice order number) post order submission or attaching IDs that are used by the warehouse to ship the orders.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ OrderIdentifier

Returns a new instance of OrderIdentifier.



40984
40985
40986
40987
40988
40989
40990
40991
40992
40993
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40984

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :order, :identifier, :primary], 'OrderIdentifier')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @order = (x = opts.delete(:order); x.is_a?(::Io::Flow::V0::Models::OrderReference) ? x : ::Io::Flow::V0::Models::OrderReference.new(x))
  @name = HttpClient::Preconditions.assert_class('name', (x = opts.delete(:name); x.nil? ? "external" : x), String)
  @identifier = HttpClient::Preconditions.assert_class('identifier', opts.delete(:identifier), String)
  @primary = HttpClient::Preconditions.assert_boolean('primary', opts.delete(:primary))
  @number = (x = opts.delete(:number); x.nil? ? nil : HttpClient::Preconditions.assert_class('number', x, String))
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



40982
40983
40984
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40982

def id
  @id
end

#identifierObject (readonly)

Returns the value of attribute identifier.



40982
40983
40984
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40982

def identifier
  @identifier
end

#nameObject (readonly)

Returns the value of attribute name.



40982
40983
40984
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40982

def name
  @name
end

#numberObject (readonly)

Returns the value of attribute number.



40982
40983
40984
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40982

def number
  @number
end

#orderObject (readonly)

Returns the value of attribute order.



40982
40983
40984
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40982

def order
  @order
end

#primaryObject (readonly)

Returns the value of attribute primary.



40982
40983
40984
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40982

def primary
  @primary
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



40999
41000
41001
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40999

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

#to_hashObject



41003
41004
41005
41006
41007
41008
41009
41010
41011
41012
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41003

def to_hash
  {
    :id => id,
    :order => order.to_hash,
    :name => name,
    :identifier => identifier,
    :primary => primary,
    :number => number
  }
end

#to_jsonObject



40995
40996
40997
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40995

def to_json
  JSON.dump(to_hash)
end