Class: Io::Flow::V0::Models::ServiceDescription
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::ServiceDescription
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Direct Known Subclasses
ServiceDescriptionUndefinedType, ServiceSummary, ServiceUnknown
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 = {}) ⇒ ServiceDescription
constructor
A new instance of ServiceDescription.
- #subtype_to_hash ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ ServiceDescription
Returns a new instance of ServiceDescription.
15181 15182 15183 15184 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15181 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) @discriminator = HttpClient::Preconditions.assert_class('discriminator', opts.delete(:discriminator) || 'service_summary', String) end |
Instance Attribute Details
#discriminator ⇒ Object (readonly)
Returns the value of attribute discriminator.
15179 15180 15181 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15179 def discriminator @discriminator end |
Class Method Details
.from_json(hash) ⇒ Object
15194 15195 15196 15197 15198 15199 15200 15201 15202 15203 15204 15205 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15194 def ServiceDescription.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[service_description] requires a field named 'discriminator'" end case discriminator when Types::SERVICE_SUMMARY; ServiceSummary.new(hash) when Types::SERVICE_UNKNOWN; ServiceUnknown.new(hash) else ServiceDescriptionUndefinedType.new(:discriminator => discriminator) end end |
Instance Method Details
#subtype_to_hash ⇒ Object
15186 15187 15188 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15186 def subtype_to_hash raise 'Cannot serialize an instance of service_description directly - must use one of the specific types: service_summary, service_unknown' end |
#to_hash ⇒ Object
15190 15191 15192 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15190 def to_hash subtype_to_hash.merge(:discriminator => @discriminator) end |