Class: InvestigatorService

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/service.rb

Instance Method Summary collapse

Constructor Details

#initializeInvestigatorService

Returns a new instance of InvestigatorService.



6
7
8
9
10
11
12
13
14
15
# File 'lib/service.rb', line 6

def initialize
  @api_key = ENV.fetch("ACTIVITY_API_KEY", nil)
  @api_url = ENV.fetch("ACTIVITY_API_URL", nil)

  unless @api_key && @api_url
    raise "ACTIVITY_API_KEY and ACTIVITY_API_URL are required."
  end

  @conn = Faraday.new(url: @api_url)
end

Instance Method Details

#post(data) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/service.rb', line 17

def post(data)
  message = {
    api_key: @api_key,
    data: data
  }
  @conn.post do |req|
    req.headers['Content-Type'] = 'application/json'
    req.body = message.to_json
  end
end