Class: Io::Flow::V0::Models::SerialForm

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 = {}) ⇒ SerialForm

Returns a new instance of SerialForm.



46220
46221
46222
46223
46224
46225
46226
46227
46228
46229
46230
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46220

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:number, :item_number, :item_price, :item_currency, :status], 'SerialForm')
  @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 = HttpClient::Preconditions.assert_class('item_price', HttpClient::Helper.to_big_decimal(opts.delete(:item_price)), BigDecimal)
  @item_currency = HttpClient::Preconditions.assert_class('item_currency', opts.delete(:item_currency), String)
  @status = (x = opts.delete(:status); x.is_a?(::Io::Flow::V0::Models::SerialStatus) ? x : ::Io::Flow::V0::Models::SerialStatus.apply(x))
  @center_key = (x = opts.delete(:center_key); x.nil? ? nil : HttpClient::Preconditions.assert_class('center_key', x, String))
  @attributes = (x = opts.delete(:attributes); x.nil? ? nil : HttpClient::Preconditions.assert_class('attributes', 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.



46218
46219
46220
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46218

def attributes
  @attributes
end

#center_keyObject (readonly)

Returns the value of attribute center_key.



46218
46219
46220
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46218

def center_key
  @center_key
end

#item_currencyObject (readonly)

Returns the value of attribute item_currency.



46218
46219
46220
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46218

def item_currency
  @item_currency
end

#item_numberObject (readonly)

Returns the value of attribute item_number.



46218
46219
46220
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46218

def item_number
  @item_number
end

#item_priceObject (readonly)

Returns the value of attribute item_price.



46218
46219
46220
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46218

def item_price
  @item_price
end

#numberObject (readonly)

Returns the value of attribute number.



46218
46219
46220
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46218

def number
  @number
end

#statusObject (readonly)

Returns the value of attribute status.



46218
46219
46220
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46218

def status
  @status
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



46236
46237
46238
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46236

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

#to_hashObject



46240
46241
46242
46243
46244
46245
46246
46247
46248
46249
46250
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46240

def to_hash
  {
    :number => number,
    :item_number => item_number,
    :item_price => item_price.to_f.to_s,
    :item_currency => item_currency,
    :status => status.value,
    :center_key => center_key,
    :attributes => attributes.nil? ? nil : attributes
  }
end

#to_jsonObject



46232
46233
46234
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46232

def to_json
  JSON.dump(to_hash)
end