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

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

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.



21167
21168
21169
21170
21171
21172
21173
21174
21175
21176
21177
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21167

def initialize(incoming={})
  super(:discriminator => Session::Types::ORGANIZATION_SESSION)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :organization, :environment, :attributes], 'OrganizationSession')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @organization = HttpClient::Preconditions.assert_class('organization', opts.delete(:organization), String)
  @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)))
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



21165
21166
21167
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21165

def attributes
  @attributes
end

#environmentObject (readonly)

Returns the value of attribute environment.



21165
21166
21167
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21165

def environment
  @environment
end

#idObject (readonly)

Returns the value of attribute id.



21165
21166
21167
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21165

def id
  @id
end

#ipObject (readonly)

Returns the value of attribute ip.



21165
21166
21167
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21165

def ip
  @ip
end

#localObject (readonly)

Returns the value of attribute local.



21165
21166
21167
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21165

def local
  @local
end

#organizationObject (readonly)

Returns the value of attribute organization.



21165
21166
21167
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21165

def organization
  @organization
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



21183
21184
21185
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21183

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

#subtype_to_hashObject



21187
21188
21189
21190
21191
21192
21193
21194
21195
21196
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21187

def subtype_to_hash
  {
    :id => id,
    :organization => organization,
    :environment => environment.value,
    :attributes => attributes,
    :ip => ip,
    :local => local.nil? ? nil : local.to_hash
  }
end

#to_jsonObject



21179
21180
21181
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21179

def to_json
  JSON.dump(to_hash)
end