Class: MetricsApi::V3::Endpoints::Global

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
app/services/metrics_api/v3/endpoints/global.rb

Overview

Global endpoint. Returns a list of presented DailyMetrics models

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#parse_date_param

Constructor Details

#initialize(params) ⇒ Global

All endpoints take in a params hash, this endpoint has no params however



12
13
14
15
# File 'app/services/metrics_api/v3/endpoints/global.rb', line 12

def initialize(params)
  @start_date = parse_date_param(params[:start_date]) || Time.zone.yesterday
  @end_date = parse_date_param(params[:end_date]) || Time.zone.today
end

Instance Attribute Details

#end_dateObject (readonly)

Returns the value of attribute end_date.



9
10
11
# File 'app/services/metrics_api/v3/endpoints/global.rb', line 9

def end_date
  @end_date
end

#start_dateObject (readonly)

Returns the value of attribute start_date.



9
10
11
# File 'app/services/metrics_api/v3/endpoints/global.rb', line 9

def start_date
  @start_date
end

Instance Method Details

#callObject

TODO: Better way of collecting display_collection names



18
19
20
21
22
# File 'app/services/metrics_api/v3/endpoints/global.rb', line 18

def call
  metrics = SupplejackApi::DailyMetrics.created_between(start_date, end_date)

  metrics.map(&MetricsApi::V3::Presenters::DailyMetric)
end