Class: Io::Flow::V0::Models::SubcatalogItem

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

Overview

Represents information specific to an item in a given subcatalog

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ SubcatalogItem



40251
40252
40253
40254
40255
40256
40257
40258
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40251

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :item, :status], 'SubcatalogItem')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @item = (x = opts.delete(:item); x.is_a?(::Io::Flow::V0::Models::Item) ? x : ::Io::Flow::V0::Models::Item.new(x))
  @status = (x = opts.delete(:status); x.is_a?(::Io::Flow::V0::Models::SubcatalogItemStatus) ? x : ::Io::Flow::V0::Models::SubcatalogItemStatus.apply(x))
  @item_function = (x = opts.delete(:item_function); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::ExpandableItemFunction) ? x : ::Io::Flow::V0::Models::ExpandableItemFunction.from_json(x)))
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



40249
40250
40251
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40249

def id
  @id
end

#itemObject (readonly)

Returns the value of attribute item.



40249
40250
40251
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40249

def item
  @item
end

#item_functionObject (readonly)

Returns the value of attribute item_function.



40249
40250
40251
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40249

def item_function
  @item_function
end

#statusObject (readonly)

Returns the value of attribute status.



40249
40250
40251
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40249

def status
  @status
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



40264
40265
40266
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40264

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

#to_hashObject



40268
40269
40270
40271
40272
40273
40274
40275
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40268

def to_hash
  {
    :id => id,
    :item => item.to_hash,
    :status => status.value,
    :item_function => item_function.nil? ? nil : item_function.to_hash
  }
end

#to_jsonObject



40260
40261
40262
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40260

def to_json
  JSON.dump(to_hash)
end