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.
-
#destroy(entry_id:) ⇒ void
Permanently delete a timesheet entry; answers 403 when the caller may not archive or trash it.
-
#for_project(project_id:, from: nil, to: nil, person_id: nil, page: nil, max_items: nil) ⇒ ListEnumerator<Hash>
Get timesheet for a specific project.
-
#for_recording(recording_id:, from: nil, to: nil, person_id: nil, page: nil, max_items: nil) ⇒ ListEnumerator<Hash>
Get timesheet for a specific recording.
-
#get(entry_id:) ⇒ Hash
Get a single timesheet entry.
-
#report(from: nil, to: nil, person_id: nil) ⇒ Array<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
47 48 49 50 51 |
# File 'lib/basecamp/generated/services/timesheets_service.rb', line 47 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 |
#destroy(entry_id:) ⇒ void
This method returns an undefined value.
Permanently delete a timesheet entry; answers 403 when the caller may not archive or trash it.
89 90 91 92 93 94 |
# File 'lib/basecamp/generated/services/timesheets_service.rb', line 89 def destroy(entry_id:) with_operation(service: "timesheets", operation: "destroy", is_mutation: true, resource_id: entry_id) do http_delete("/timesheet_entries/#{entry_id}") nil end end |
#for_project(project_id:, from: nil, to: nil, person_id: nil, page: nil, max_items: nil) ⇒ ListEnumerator<Hash>
Get timesheet for a specific project
18 19 20 21 22 23 |
# File 'lib/basecamp/generated/services/timesheets_service.rb', line 18 def for_project(project_id:, from: nil, to: nil, person_id: nil, page: nil, max_items: 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, page: page) paginate("/projects/#{project_id}/timesheet.json", params: params, operation: "GetProjectTimesheet", max_items: max_items) end end |
#for_recording(recording_id:, from: nil, to: nil, person_id: nil, page: nil, max_items: nil) ⇒ ListEnumerator<Hash>
Get timesheet for a specific recording
33 34 35 36 37 38 |
# File 'lib/basecamp/generated/services/timesheets_service.rb', line 33 def for_recording(recording_id:, from: nil, to: nil, person_id: nil, page: nil, max_items: 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, page: page) paginate("/recordings/#{recording_id}/timesheet.json", params: params, operation: "GetRecordingTimesheet", max_items: max_items) end end |
#get(entry_id:) ⇒ Hash
Get a single timesheet entry
67 68 69 70 71 |
# File 'lib/basecamp/generated/services/timesheets_service.rb', line 67 def get(entry_id:) with_operation(service: "timesheets", operation: "get", is_mutation: false, resource_id: entry_id) do http_get("/timesheet_entries/#{entry_id}", operation: "GetTimesheetEntry").json end end |
#report(from: nil, to: nil, person_id: nil) ⇒ Array<Hash>
Get account-wide timesheet report
58 59 60 61 62 |
# File 'lib/basecamp/generated/services/timesheets_service.rb', line 58 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), operation: "GetTimesheetReport").json end end |
#update(entry_id:, date: nil, hours: nil, description: nil, person_id: nil) ⇒ Hash
Update a timesheet entry
80 81 82 83 84 |
# File 'lib/basecamp/generated/services/timesheets_service.rb', line 80 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 |