Class: Io::Flow::V0::Models::ExpandableSubcatalog
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::ExpandableSubcatalog
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Overview
A subcatalog can be represented with just it’s ID, or the entire model
Direct Known Subclasses
ExpandableSubcatalogUndefinedType, Subcatalog, SubcatalogReference
Defined Under Namespace
Modules: Types
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(incoming = {}) ⇒ ExpandableSubcatalog
constructor
A new instance of ExpandableSubcatalog.
- #subtype_to_hash ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ ExpandableSubcatalog
Returns a new instance of ExpandableSubcatalog.
4354 4355 4356 4357 4358 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4354 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:name], 'ExpandableSubcatalog') @name = HttpClient::Preconditions.assert_class('name', opts.delete(:name), String) end |
Class Method Details
.from_json(hash) ⇒ Object
4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4368 def ExpandableSubcatalog.from_json(hash) HttpClient::Preconditions.assert_class('hash', hash, Hash) discriminator = HttpClient::Helper.symbolize_keys(hash)[:discriminator].to_s.strip if discriminator.empty? raise "Union type[expandable_subcatalog] requires a field named 'discriminator'" end case discriminator when Types::SUBCATALOG; Subcatalog.new(hash) when Types::SUBCATALOG_REFERENCE; SubcatalogReference.new(hash) else ExpandableSubcatalogUndefinedType.new(:name => discriminator) end end |
Instance Method Details
#subtype_to_hash ⇒ Object
4360 4361 4362 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4360 def subtype_to_hash raise 'Cannot serialize an instance of expandable_subcatalog directly - must use one of the specific types: subcatalog, subcatalog_reference' end |
#to_hash ⇒ Object
4364 4365 4366 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4364 def to_hash subtype_to_hash.merge(:discriminator => @name) end |