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
Returns a new instance of Feed.
6196 6197 6198 6199 6200 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6196 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.
6194 6195 6196 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6194 def discriminator @discriminator end |
Class Method Details
.from_json(hash) ⇒ Object
6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6210 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
6202 6203 6204 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6202 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
6206 6207 6208 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6206 def to_hash subtype_to_hash.merge(:discriminator => @discriminator) end |