Class: Io::Flow::V0::Models::Serial

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

Overview

A unique identifier assigned to an individual item.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ Serial

Returns a new instance of Serial.



30655
30656
30657
30658
30659
30660
30661
30662
30663
30664
30665
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30655

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :number, :item_number, :item_price, :status, :center_key], 'Serial')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @number = HttpClient::Preconditions.assert_class('number', opts.delete(:number), String)
  @item_number = HttpClient::Preconditions.assert_class('item_number', opts.delete(:item_number), String)
  @item_price = (x = opts.delete(:item_price); x.is_a?(::Io::Flow::V0::Models::Price) ? x : ::Io::Flow::V0::Models::Price.new(x))
  @status = (x = opts.delete(:status); x.is_a?(::Io::Flow::V0::Models::SerialStatus) ? x : ::Io::Flow::V0::Models::SerialStatus.apply(x))
  @center_key = HttpClient::Preconditions.assert_class('center_key', opts.delete(:center_key), String)
  @attributes = HttpClient::Preconditions.assert_class('attributes', (x = opts.delete(:attributes); x.nil? ? {} : x), Hash).inject({}) { |h, d| h[d[0]] = HttpClient::Preconditions.assert_class('attributes', d[1], String); h }
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



30653
30654
30655
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30653

def attributes
  @attributes
end

#center_keyObject (readonly)

Returns the value of attribute center_key.



30653
30654
30655
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30653

def center_key
  @center_key
end

#idObject (readonly)

Returns the value of attribute id.



30653
30654
30655
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30653

def id
  @id
end

#item_numberObject (readonly)

Returns the value of attribute item_number.



30653
30654
30655
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30653

def item_number
  @item_number
end

#item_priceObject (readonly)

Returns the value of attribute item_price.



30653
30654
30655
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30653

def item_price
  @item_price
end

#numberObject (readonly)

Returns the value of attribute number.



30653
30654
30655
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30653

def number
  @number
end

#statusObject (readonly)

Returns the value of attribute status.



30653
30654
30655
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30653

def status
  @status
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



30671
30672
30673
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30671

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

#to_hashObject



30675
30676
30677
30678
30679
30680
30681
30682
30683
30684
30685
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30675

def to_hash
  {
    :id => id,
    :number => number,
    :item_number => item_number,
    :item_price => item_price.to_hash,
    :status => status.value,
    :center_key => center_key,
    :attributes => attributes
  }
end

#to_jsonObject



30667
30668
30669
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30667

def to_json
  JSON.dump(to_hash)
end