Class: Basecamp::Services::TimesheetsService

Inherits:
BaseService
  • Object
show all
Defined in:
lib/basecamp/generated/services/timesheets_service.rb

Overview

Service for Timesheets operations

Instance Method Summary collapse

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

Parameters:

  • recording_id (Integer)

    recording id ID

  • date (String)

    date

  • hours (String)

    hours

  • description (String, nil) (defaults to: nil)

    description

  • person_id (Integer, nil) (defaults to: nil)

    person id

Returns:

  • (Hash)

    response data



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

Parameters:

  • project_id (Integer)

    project id ID

  • from (String, nil) (defaults to: nil)

    from

  • to (String, nil) (defaults to: nil)

    to

  • person_id (Integer, nil) (defaults to: nil)

    person id

Returns:

  • (Enumerator<Hash>)

    paginated results



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

Parameters:

  • recording_id (Integer)

    recording id ID

  • from (String, nil) (defaults to: nil)

    from

  • to (String, nil) (defaults to: nil)

    to

  • person_id (Integer, nil) (defaults to: nil)

    person id

Returns:

  • (Enumerator<Hash>)

    paginated results



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

Parameters:

  • entry_id (Integer)

    entry id ID

Returns:

  • (Hash)

    response data



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

Parameters:

  • from (String, nil) (defaults to: nil)

    from

  • to (String, nil) (defaults to: nil)

    to

  • person_id (Integer, nil) (defaults to: nil)

    person id

Returns:

  • (Hash)

    response data



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

Parameters:

  • entry_id (Integer)

    entry id ID

  • date (String, nil) (defaults to: nil)

    date

  • hours (String, nil) (defaults to: nil)

    hours

  • description (String, nil) (defaults to: nil)

    description

  • person_id (Integer, nil) (defaults to: nil)

    person id

Returns:

  • (Hash)

    response data



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