Class: Io::Flow::V0::Models::Session
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::Session
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
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 = {}) ⇒ Session
constructor
A new instance of Session.
- #subtype_to_hash ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ Session
Returns a new instance of Session.
15313 15314 15315 15316 15317 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15313 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:discriminator], 'Session') @discriminator = HttpClient::Preconditions.assert_class('discriminator', opts.delete(:discriminator), String) end |
Instance Attribute Details
#discriminator ⇒ Object (readonly)
Returns the value of attribute discriminator.
15311 15312 15313 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15311 def discriminator @discriminator end |
Class Method Details
.from_json(hash) ⇒ Object
15327 15328 15329 15330 15331 15332 15333 15334 15335 15336 15337 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15327 def Session.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[session] requires a field named 'discriminator'" end case discriminator when Types::ORGANIZATION_SESSION; OrganizationSession.new(hash) else SessionUndefinedType.new(:discriminator => discriminator) end end |
Instance Method Details
#subtype_to_hash ⇒ Object
15319 15320 15321 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15319 def subtype_to_hash raise 'Cannot serialize an instance of session directly - must use one of the specific types: organization_session' end |
#to_hash ⇒ Object
15323 15324 15325 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15323 def to_hash subtype_to_hash.merge(:discriminator => @discriminator) end |