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
6765 6766 6767 6768 6769 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6765 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.
6763 6764 6765 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6763 def discriminator @discriminator end |
Class Method Details
.from_json(hash) ⇒ Object
6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6779 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
6771 6772 6773 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6771 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
6775 6776 6777 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6775 def to_hash subtype_to_hash.merge(:discriminator => @discriminator) end |