Class: OSA::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/osa/util/context.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = nil) ⇒ Context

Returns a new instance of Context.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/osa/util/context.rb', line 13

def initialize(config = nil)
  @config = config || Config.first

  if @config.nil?
    $stderr.puts 'OSA not configured'
    exit 1
  end

  auth_client = MSAuthClient.new
  @auth_service = AuthService.new(auth_client)
  token = auth_service.refresh_token(@config)

  @graph_client = MSGraphClient.new(token['access_token'])
end

Instance Attribute Details

#auth_serviceObject (readonly)

Returns the value of attribute auth_service.



10
11
12
# File 'lib/osa/util/context.rb', line 10

def auth_service
  @auth_service
end

#configObject (readonly)

Returns the value of attribute config.



11
12
13
# File 'lib/osa/util/context.rb', line 11

def config
  @config
end

#graph_clientObject (readonly)

Returns the value of attribute graph_client.



9
10
11
# File 'lib/osa/util/context.rb', line 9

def graph_client
  @graph_client
end