Class: Io::Flow::V0::Models::Session

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Direct Known Subclasses

OrganizationSession, SessionUndefinedType

Defined Under Namespace

Modules: Types

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#discriminatorObject (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_hashObject



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_hashObject



15323
15324
15325
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15323

def to_hash
  subtype_to_hash.merge(:discriminator => @discriminator)
end