Class: Io::Flow::V0::Models::Feed
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::Feed
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Overview
Describes types of feeds that may be produced by Flow.
Direct Known Subclasses
Defined Under Namespace
Modules: Types
Instance Attribute Summary collapse
-
#discriminator ⇒ Object
readonly
Returns the value of attribute discriminator.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(incoming = {}) ⇒ Feed
constructor
A new instance of Feed.
- #subtype_to_hash ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ Feed
8150 8151 8152 8153 8154 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8150 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:discriminator], 'Feed') @discriminator = HttpClient::Preconditions.assert_class('discriminator', opts.delete(:discriminator), String) end |
Instance Attribute Details
#discriminator ⇒ Object (readonly)
Returns the value of attribute discriminator.
8148 8149 8150 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8148 def discriminator @discriminator end |
Class Method Details
.from_json(hash) ⇒ Object
8164 8165 8166 8167 8168 8169 8170 8171 8172 8173 8174 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8164 def Feed.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[feed] requires a field named 'discriminator'" end case discriminator when Types::CATALOG_FEED; CatalogFeed.new(hash) else FeedUndefinedType.new(:discriminator => discriminator) end end |
Instance Method Details
#subtype_to_hash ⇒ Object
8156 8157 8158 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8156 def subtype_to_hash raise 'Cannot serialize an instance of feed directly - must use one of the specific types: catalog_feed' end |
#to_hash ⇒ Object
8160 8161 8162 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8160 def to_hash subtype_to_hash.merge(:discriminator => @discriminator) end |