Class: Basecamp::Services::TimesheetsService
- Inherits:
-
BaseService
- Object
- BaseService
- Basecamp::Services::TimesheetsService
- Defined in:
- lib/basecamp/generated/services/timesheets_service.rb
Overview
Service for Timesheets operations
Instance Method Summary collapse
-
#create(recording_id:, date:, hours:, description: nil, person_id: nil) ⇒ Hash
Create a timesheet entry on a recording.
-
#for_project(project_id:, from: nil, to: nil, person_id: nil) ⇒ Enumerator<Hash>
Get timesheet for a specific project.
-
#for_recording(recording_id:, from: nil, to: nil, person_id: nil) ⇒ Enumerator<Hash>
Get timesheet for a specific recording.
-
#get(entry_id:) ⇒ Hash
Get a single timesheet entry.
-
#report(from: nil, to: nil, person_id: nil) ⇒ Hash
Get account-wide timesheet report.
-
#update(entry_id:, date: nil, hours: nil, description: nil, person_id: nil) ⇒ Hash
Update a timesheet entry.
Constructor Details
This class inherits a constructor from Basecamp::Services::BaseService
Instance Method Details
#create(recording_id:, date:, hours:, description: nil, person_id: nil) ⇒ Hash
Create a timesheet entry on a recording
43 44 45 46 47 |
# File 'lib/basecamp/generated/services/timesheets_service.rb', line 43 def create(recording_id:, date:, hours:, description: nil, person_id: nil) with_operation(service: "timesheets", operation: "create", is_mutation: true, resource_id: recording_id) do http_post("/recordings/#{recording_id}/timesheet/entries.json", body: compact_params(date: date, hours: hours, description: description, person_id: person_id)).json end end |
#for_project(project_id:, from: nil, to: nil, person_id: nil) ⇒ Enumerator<Hash>
Get timesheet for a specific project
16 17 18 19 20 21 |
# File 'lib/basecamp/generated/services/timesheets_service.rb', line 16 def for_project(project_id:, from: nil, to: nil, person_id: nil) wrap_paginated(service: "timesheets", operation: "for_project", is_mutation: false, project_id: project_id) do params = compact_query_params(from: from, to: to, person_id: person_id) paginate("/projects/#{project_id}/timesheet.json", params: params) end end |
#for_recording(recording_id:, from: nil, to: nil, person_id: nil) ⇒ Enumerator<Hash>
Get timesheet for a specific recording
29 30 31 32 33 34 |
# File 'lib/basecamp/generated/services/timesheets_service.rb', line 29 def for_recording(recording_id:, from: nil, to: nil, person_id: nil) wrap_paginated(service: "timesheets", operation: "for_recording", is_mutation: false, resource_id: recording_id) do params = compact_query_params(from: from, to: to, person_id: person_id) paginate("/recordings/#{recording_id}/timesheet.json", params: params) end end |
#get(entry_id:) ⇒ Hash
Get a single timesheet entry
63 64 65 66 67 |
# File 'lib/basecamp/generated/services/timesheets_service.rb', line 63 def get(entry_id:) with_operation(service: "timesheets", operation: "get", is_mutation: false, resource_id: entry_id) do http_get("/timesheet_entries/#{entry_id}").json end end |
#report(from: nil, to: nil, person_id: nil) ⇒ Hash
Get account-wide timesheet report
54 55 56 57 58 |
# File 'lib/basecamp/generated/services/timesheets_service.rb', line 54 def report(from: nil, to: nil, person_id: nil) with_operation(service: "timesheets", operation: "report", is_mutation: false) do http_get("/reports/timesheet.json", params: compact_query_params(from: from, to: to, person_id: person_id)).json end end |
#update(entry_id:, date: nil, hours: nil, description: nil, person_id: nil) ⇒ Hash
Update a timesheet entry
76 77 78 79 80 |
# File 'lib/basecamp/generated/services/timesheets_service.rb', line 76 def update(entry_id:, date: nil, hours: nil, description: nil, person_id: nil) with_operation(service: "timesheets", operation: "update", is_mutation: true, resource_id: entry_id) do http_put("/timesheet_entries/#{entry_id}", body: compact_params(date: date, hours: hours, description: description, person_id: person_id)).json end end |