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

from_json, #to_hash

Constructor Details

#initialize(incoming = {}) ⇒ Subcatalog

Returns a new instance of Subcatalog.



31022
31023
31024
31025
31026
31027
31028
31029
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31022

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

#catalogObject (readonly)

Returns the value of attribute catalog.



31020
31021
31022
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31020

def catalog
  @catalog
end

#idObject (readonly)

Returns the value of attribute id.



31020
31021
31022
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31020

def id
  @id
end

#settingsObject (readonly)

Returns the value of attribute settings.



31020
31021
31022
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31020

def settings
  @settings
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



31035
31036
31037
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31035

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

#subtype_to_hashObject



31039
31040
31041
31042
31043
31044
31045
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31039

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

#to_jsonObject



31031
31032
31033
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31031

def to_json
  JSON.dump(to_hash)
end