Class: StatTrackr::Reporter

Inherits:
Object
  • Object
show all
Defined in:
lib/stat_trackr.rb

Instance Method Summary collapse

Constructor Details

#initialize(metric_id) ⇒ Reporter

Returns a new instance of Reporter.



33
34
35
# File 'lib/stat_trackr.rb', line 33

def initialize(metric_id)
  @metric_id = metric_id
end

Instance Method Details

#ping(date, value) ⇒ Object

Raises:



37
38
39
40
41
42
43
44
45
46
# File 'lib/stat_trackr.rb', line 37

def ping(date, value)
  raise Error if StatTrackr.config.url.nil?
  data = {
    "event_date" => date,
    "event_value" => value,
    "metric_id" => @metric_id,
  }
  response = HTTPX.post(StatTrackr.config.url, json: data, ssl: {verify_mode: OpenSSL::SSL::VERIFY_NONE})
  response.status == 200
end