Class: Io::Flow::V0::Models::Subcatalog

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

Overview

A configuration with custom query to select a subset of master catalog items for a localized experience

Instance Attribute Summary collapse

Attributes inherited from ExpandableSubcatalog

#discriminator

Instance Method Summary collapse

Methods inherited from ExpandableSubcatalog

#to_hash

Constructor Details

#initialize(incoming = {}) ⇒ Subcatalog

Returns a new instance of Subcatalog.



20547
20548
20549
20550
20551
20552
20553
20554
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20547

def initialize(incoming={})
  super(:discriminator => ExpandableSubcatalog::Types::SUBCATALOG)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :catalog, :settings], 'Subcatalog')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @catalog = (x = opts.delete(:catalog); x.is_a?(::Io::Flow::V0::Models::Catalog) ? x : ::Io::Flow::V0::Models::Catalog.new(x))
  @settings = (x = opts.delete(:settings); x.is_a?(::Io::Flow::V0::Models::SubcatalogSettings) ? x : ::Io::Flow::V0::Models::SubcatalogSettings.new(x))
end

Instance Attribute Details

#catalog ⇒ Object (readonly)

Returns the value of attribute catalog.



20545
20546
20547
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20545

def catalog
  @catalog
end

#id ⇒ Object (readonly)

Returns the value of attribute id.



20545
20546
20547
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20545

def id
  @id
end

#settings ⇒ Object (readonly)

Returns the value of attribute settings.



20545
20546
20547
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20545

def settings
  @settings
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



20560
20561
20562
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20560

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

#subtype_to_hash ⇒ Object



20564
20565
20566
20567
20568
20569
20570
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20564

def subtype_to_hash
  {
    :id => id,
    :catalog => catalog.to_hash,
    :settings => settings.to_hash
  }
end

#to_json ⇒ Object



20556
20557
20558
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20556

def to_json
  JSON.dump(to_hash)
end