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

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

Overview

Represents alternate numbers with which to identify an order.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ OrderIdentifier

Returns a new instance of OrderIdentifier.



20753
20754
20755
20756
20757
20758
20759
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20753

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :order, :number], '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))
  @number = HttpClient::Preconditions.assert_class('number', opts.delete(:number), String)
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



20751
20752
20753
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20751

def id
  @id
end

#numberObject (readonly)

Returns the value of attribute number.



20751
20752
20753
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20751

def number
  @number
end

#orderObject (readonly)

Returns the value of attribute order.



20751
20752
20753
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20751

def order
  @order
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



20765
20766
20767
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20765

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

#to_hashObject



20769
20770
20771
20772
20773
20774
20775
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20769

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

#to_jsonObject



20761
20762
20763
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20761

def to_json
  JSON.dump(to_hash)
end