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.



18136
18137
18138
18139
18140
18141
18142
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18136

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.



18134
18135
18136
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18134

def id
  @id
end

#numberObject (readonly)

Returns the value of attribute number.



18134
18135
18136
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18134

def number
  @number
end

#orderObject (readonly)

Returns the value of attribute order.



18134
18135
18136
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18134

def order
  @order
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



18148
18149
18150
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18148

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

#to_hashObject



18152
18153
18154
18155
18156
18157
18158
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18152

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

#to_jsonObject



18144
18145
18146
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18144

def to_json
  JSON.dump(to_hash)
end