Class: PlausibleApi::Stats::Timeseries

Inherits:
Object
  • Object
show all
Defined in:
lib/plausible_api/api/stats/timeseries.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Timeseries

Returns a new instance of Timeseries.



6
7
8
9
10
# File 'lib/plausible_api/api/stats/timeseries.rb', line 6

def initialize(options = {})
  @period = options[:period] || '3mo'
  @filter = options[:filter]
  @date   = options[:date]
end

Instance Method Details

#request_urlObject



12
13
14
15
16
17
18
19
20
21
# File 'lib/plausible_api/api/stats/timeseries.rb', line 12

def request_url
  url = "/api/v1/stats/timeseries?site_id=$SITE_ID&period=#{@period}"
  if @filter
    url += "&filter=#{CGI.escape(@filter)}"
  end
  if @date
    url += "&date=#{@date}"
  end
  url
end