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

Returns a new instance of SubcatalogItem.



52739
52740
52741
52742
52743
52744
52745
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 52739

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))
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



52737
52738
52739
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 52737

def id
  @id
end

#itemObject (readonly)

Returns the value of attribute item.



52737
52738
52739
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 52737

def item
  @item
end

#statusObject (readonly)

Returns the value of attribute status.



52737
52738
52739
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 52737

def status
  @status
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



52751
52752
52753
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 52751

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

#to_hashObject



52755
52756
52757
52758
52759
52760
52761
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 52755

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

#to_jsonObject



52747
52748
52749
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 52747

def to_json
  JSON.dump(to_hash)
end