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.
5693 5694 5695 5696 5697 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5693 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.
5691 5692 5693 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5691 def discriminator @discriminator end |
Class Method Details
.from_json(hash) ⇒ Object
5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5707 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
5699 5700 5701 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5699 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
5703 5704 5705 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5703 def to_hash subtype_to_hash.merge(:discriminator => @discriminator) end |