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.
6253 6254 6255 6256 6257 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6253 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.
6251 6252 6253 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6251 def discriminator @discriminator end |
Class Method Details
.from_json(hash) ⇒ Object
6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6267 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
6259 6260 6261 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6259 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
6263 6264 6265 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6263 def to_hash subtype_to_hash.merge(:discriminator => @discriminator) end |