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.



43511
43512
43513
43514
43515
43516
43517
43518
43519
43520
43521
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43511

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :number, :item_number, :item_price, :status, :center], '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 = (x = opts.delete(:center); x.is_a?(::Io::Flow::V0::Models::CenterReference) ? x : ::Io::Flow::V0::Models::CenterReference.new(x))
  @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.



43509
43510
43511
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43509

def attributes
  @attributes
end

#centerObject (readonly)

Returns the value of attribute center.



43509
43510
43511
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43509

def center
  @center
end

#idObject (readonly)

Returns the value of attribute id.



43509
43510
43511
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43509

def id
  @id
end

#item_numberObject (readonly)

Returns the value of attribute item_number.



43509
43510
43511
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43509

def item_number
  @item_number
end

#item_priceObject (readonly)

Returns the value of attribute item_price.



43509
43510
43511
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43509

def item_price
  @item_price
end

#numberObject (readonly)

Returns the value of attribute number.



43509
43510
43511
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43509

def number
  @number
end

#statusObject (readonly)

Returns the value of attribute status.



43509
43510
43511
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43509

def status
  @status
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



43527
43528
43529
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43527

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

#to_hashObject



43531
43532
43533
43534
43535
43536
43537
43538
43539
43540
43541
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43531

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

#to_jsonObject



43523
43524
43525
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43523

def to_json
  JSON.dump(to_hash)
end