Class: Sqreen::Kit::Signals::AuthSignalsClient

Inherits:
Object
  • Object
show all
Defined in:
lib/sqreen/kit/signals/auth_signals_client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(signals_client, auth_data) ⇒ AuthSignalsClient

Returns a new instance of AuthSignalsClient.

Parameters:

  • signals_client (SignalsClient)
  • auth_data (Hash)

    :session_key, :api_key, :app_name



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/sqreen/kit/signals/auth_signals_client.rb', line 16

def initialize(signals_client, auth_data)
  @signals_client = signals_client

  @headers = {}
  session_key = auth_data[:session_key]
  api_key = auth_data[:api_key]
  app_name = auth_data[:app_name]
  if session_key
    @headers['X-Session-Key'] = session_key
  elsif api_key
    @headers['X-Api-Key'] = api_key
    @headers['X-App-Name'] = app_name if app_name
  else
    raise ArgumentError, 'Authentication data not provided'
  end
end

Instance Attribute Details

#headersObject (readonly)

for testing only



12
13
14
# File 'lib/sqreen/kit/signals/auth_signals_client.rb', line 12

def headers
  @headers
end

Instance Method Details

#report_batch(signals_and_traces) ⇒ Object

Parameters:



34
35
36
# File 'lib/sqreen/kit/signals/auth_signals_client.rb', line 34

def report_batch(signals_and_traces)
  @signals_client.report_batch(signals_and_traces, @headers)
end

#report_signal(signal) ⇒ Object

Parameters:



39
40
41
# File 'lib/sqreen/kit/signals/auth_signals_client.rb', line 39

def report_signal(signal)
  @signals_client.report_signal(signal, @headers)
end

#report_trace(trace) ⇒ Object

Parameters:



44
45
46
# File 'lib/sqreen/kit/signals/auth_signals_client.rb', line 44

def report_trace(trace)
  @signals_client.report_trace(trace, @headers)
end