Class: InvestigatorService
Instance Method Summary collapse
-
#initialize ⇒ InvestigatorService
constructor
A new instance of InvestigatorService.
- #post(data) ⇒ Object
Constructor Details
#initialize ⇒ InvestigatorService
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 27 |
# File 'lib/service.rb', line 17 def post(data) = { api_key: @api_key, data: data } @conn.post do |req| req.url '/' req.headers['Content-Type'] = 'application/json' req.body = .to_json end end |