Class: Io::Flow::V0::Models::OrganizationSession

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

Overview

Represents a session created for an organization. Primary method to select an experience for a given user session and ensure that experience does not change throughout the user’s activity. Provides authentication to objects created during this session (e.g. order).

Instance Attribute Summary collapse

Attributes inherited from Session

#discriminator

Instance Method Summary collapse

Methods inherited from Session

from_json, #to_hash

Constructor Details

#initialize(incoming = {}) ⇒ OrganizationSession

Returns a new instance of OrganizationSession.



42451
42452
42453
42454
42455
42456
42457
42458
42459
42460
42461
42462
42463
42464
42465
42466
42467
42468
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42451

def initialize(incoming={})
  super(:discriminator => Session::Types::ORGANIZATION_SESSION)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :organization, :visitor, :visit, :environment, :attributes], 'OrganizationSession')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @organization = HttpClient::Preconditions.assert_class('organization', opts.delete(:organization), String)
  @visitor = (x = opts.delete(:visitor); x.is_a?(::Io::Flow::V0::Models::SessionVisitor) ? x : ::Io::Flow::V0::Models::SessionVisitor.new(x))
  @visit = (x = opts.delete(:visit); x.is_a?(::Io::Flow::V0::Models::SessionVisit) ? x : ::Io::Flow::V0::Models::SessionVisit.new(x))
  @environment = (x = opts.delete(:environment); x.is_a?(::Io::Flow::V0::Models::Environment) ? x : ::Io::Flow::V0::Models::Environment.apply(x))
  @attributes = HttpClient::Preconditions.assert_class('attributes', opts.delete(:attributes), Hash).inject({}) { |h, d| h[d[0]] = HttpClient::Preconditions.assert_class('attributes', d[1], String); h }
  @ip = (x = opts.delete(:ip); x.nil? ? nil : HttpClient::Preconditions.assert_class('ip', x, String))
  @local = (x = opts.delete(:local); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::LocalSession) ? x : ::Io::Flow::V0::Models::LocalSession.new(x)))
  @geo = (x = opts.delete(:geo); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::SessionGeo) ? x : ::Io::Flow::V0::Models::SessionGeo.new(x)))
  @experience = (x = opts.delete(:experience); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::ExperienceGeo) ? x : ::Io::Flow::V0::Models::ExperienceGeo.new(x)))
  @format = (x = opts.delete(:format); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::SessionFormat) ? x : ::Io::Flow::V0::Models::SessionFormat.new(x)))
  @experiment = (x = opts.delete(:experiment); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::SessionExperiment) ? x : ::Io::Flow::V0::Models::SessionExperiment.new(x)))
  @context = (x = opts.delete(:context); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::ContextReference) ? x : ::Io::Flow::V0::Models::ContextReference.new(x)))
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



42449
42450
42451
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42449

def attributes
  @attributes
end

#contextObject (readonly)

Returns the value of attribute context.



42449
42450
42451
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42449

def context
  @context
end

#environmentObject (readonly)

Returns the value of attribute environment.



42449
42450
42451
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42449

def environment
  @environment
end

#experienceObject (readonly)

Returns the value of attribute experience.



42449
42450
42451
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42449

def experience
  @experience
end

#experimentObject (readonly)

Returns the value of attribute experiment.



42449
42450
42451
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42449

def experiment
  @experiment
end

#formatObject (readonly)

Returns the value of attribute format.



42449
42450
42451
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42449

def format
  @format
end

#geoObject (readonly)

Returns the value of attribute geo.



42449
42450
42451
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42449

def geo
  @geo
end

#idObject (readonly)

Returns the value of attribute id.



42449
42450
42451
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42449

def id
  @id
end

#ipObject (readonly)

Returns the value of attribute ip.



42449
42450
42451
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42449

def ip
  @ip
end

#localObject (readonly)

Returns the value of attribute local.



42449
42450
42451
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42449

def local
  @local
end

#organizationObject (readonly)

Returns the value of attribute organization.



42449
42450
42451
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42449

def organization
  @organization
end

#visitObject (readonly)

Returns the value of attribute visit.



42449
42450
42451
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42449

def visit
  @visit
end

#visitorObject (readonly)

Returns the value of attribute visitor.



42449
42450
42451
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42449

def visitor
  @visitor
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



42474
42475
42476
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42474

def copy(incoming={})
  OrganizationSession.new(subtype_to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end

#subtype_to_hashObject



42478
42479
42480
42481
42482
42483
42484
42485
42486
42487
42488
42489
42490
42491
42492
42493
42494
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42478

def subtype_to_hash
  {
    :id => id,
    :organization => organization,
    :visitor => visitor.to_hash,
    :visit => visit.to_hash,
    :environment => environment.value,
    :attributes => attributes,
    :ip => ip,
    :local => local.nil? ? nil : local.to_hash,
    :geo => geo.nil? ? nil : geo.to_hash,
    :experience => experience.nil? ? nil : experience.to_hash,
    :format => format.nil? ? nil : format.to_hash,
    :experiment => experiment.nil? ? nil : experiment.to_hash,
    :context => context.nil? ? nil : context.to_hash
  }
end

#to_jsonObject



42470
42471
42472
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42470

def to_json
  JSON.dump(to_hash)
end