Class: ShelfWatch::Resources::Reports

Inherits:
Object
  • Object
show all
Defined in:
lib/shelfwatch/resources/reports.rb

Overview

Report list and generate endpoints.

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Reports

Returns a new instance of Reports.



7
8
9
# File 'lib/shelfwatch/resources/reports.rb', line 7

def initialize(client)
  @client = client
end

Instance Method Details

#generate(report_id, start_date:, end_date:, project_id: nil) ⇒ Object

Generate a report by report_id (see #list).



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/shelfwatch/resources/reports.rb', line 21

def generate(report_id, start_date:, end_date:, project_id: nil)
  @client.request(
    "GET",
    "/v2/reports/generate",
    params: Http.drop_none(
      project_id: @client.project(project_id),
      report_id: report_id,
      start_date: Http.format_day(start_date),
      end_date: Http.format_day(end_date)
    )
  )
end

#list(project_id: nil) ⇒ Object

List available reports for the project.



12
13
14
15
16
17
18
# File 'lib/shelfwatch/resources/reports.rb', line 12

def list(project_id: nil)
  @client.request(
    "GET",
    "/v2/reports",
    params: Http.drop_none(project_id: @client.project(project_id))
  )
end