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.



24338
24339
24340
24341
24342
24343
24344
24345
24346
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24338

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))
  @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.



24336
24337
24338
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24336

def id
  @id
end

#identifierObject (readonly)

Returns the value of attribute identifier.



24336
24337
24338
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24336

def identifier
  @identifier
end

#numberObject (readonly)

Returns the value of attribute number.



24336
24337
24338
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24336

def number
  @number
end

#orderObject (readonly)

Returns the value of attribute order.



24336
24337
24338
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24336

def order
  @order
end

#primaryObject (readonly)

Returns the value of attribute primary.



24336
24337
24338
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24336

def primary
  @primary
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



24352
24353
24354
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24352

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

#to_hashObject



24356
24357
24358
24359
24360
24361
24362
24363
24364
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24356

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

#to_jsonObject



24348
24349
24350
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24348

def to_json
  JSON.dump(to_hash)
end