Class: Basecamp::Services::SchedulesService

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

Overview

Service for Schedules operations

Instance Method Summary collapse

Constructor Details

This class inherits a constructor from Basecamp::Services::BaseService

Instance Method Details

#create_entry(schedule_id:, summary:, starts_at:, ends_at:, description: nil, participant_ids: nil, all_day: nil, notify: nil, subscriptions: nil, visible_to_clients: nil) ⇒ Hash

Create a new schedule entry

Parameters:

  • schedule_id (Integer)

    schedule id ID

  • summary (String)

    summary

  • starts_at (String)

    starts at (RFC3339 (e.g., 2024-12-15T09:00:00Z))

  • ends_at (String)

    ends at (RFC3339 (e.g., 2024-12-15T09:00:00Z))

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

    description

  • participant_ids (Array, nil) (defaults to: nil)

    participant ids

  • all_day (Boolean, nil) (defaults to: nil)

    all day

  • notify (Boolean, nil) (defaults to: nil)

    notify

  • subscriptions (Array, nil) (defaults to: nil)

    subscriptions

  • visible_to_clients (Boolean, nil) (defaults to: nil)

    visible to clients

Returns:

  • (Hash)

    response data



95
96
97
98
99
# File 'lib/basecamp/generated/services/schedules_service.rb', line 95

def create_entry(schedule_id:, summary:, starts_at:, ends_at:, description: nil, participant_ids: nil, all_day: nil, notify: nil, subscriptions: nil, visible_to_clients: nil)
  with_operation(service: "schedules", operation: "create_entry", is_mutation: true, resource_id: schedule_id) do
    http_post("/schedules/#{schedule_id}/entries.json", body: compact_params(summary: summary, starts_at: starts_at, ends_at: ends_at, description: description, participant_ids: participant_ids, all_day: all_day, notify: notify, subscriptions: subscriptions, visible_to_clients: visible_to_clients)).json
  end
end

#get(schedule_id:) ⇒ Hash

Get a schedule

Parameters:

  • schedule_id (Integer)

    schedule id ID

Returns:

  • (Hash)

    response data



56
57
58
59
60
# File 'lib/basecamp/generated/services/schedules_service.rb', line 56

def get(schedule_id:)
  with_operation(service: "schedules", operation: "get", is_mutation: false, resource_id: schedule_id) do
    http_get("/schedules/#{schedule_id}").json
  end
end

#get_entry(entry_id:) ⇒ Hash

Get a single schedule entry by id.

Parameters:

  • entry_id (Integer)

    entry id ID

Returns:

  • (Hash)

    response data



13
14
15
16
17
# File 'lib/basecamp/generated/services/schedules_service.rb', line 13

def get_entry(entry_id:)
  with_operation(service: "schedules", operation: "get_entry", is_mutation: false, resource_id: entry_id) do
    http_get("/schedule_entries/#{entry_id}").json
  end
end

#get_entry_occurrence(entry_id:, date:) ⇒ Hash

Get a specific occurrence of a recurring schedule entry

Parameters:

  • entry_id (Integer)

    entry id ID

  • date (String)

    date ID

Returns:

  • (Hash)

    response data



47
48
49
50
51
# File 'lib/basecamp/generated/services/schedules_service.rb', line 47

def get_entry_occurrence(entry_id:, date:)
  with_operation(service: "schedules", operation: "get_entry_occurrence", is_mutation: false, resource_id: entry_id) do
    http_get("/schedule_entries/#{entry_id}/occurrences/#{date}").json
  end
end

#list_entries(schedule_id:, status: nil) ⇒ Enumerator<Hash>

List entries on a schedule

Parameters:

  • schedule_id (Integer)

    schedule id ID

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

    active|archived|trashed

Returns:

  • (Enumerator<Hash>)

    paginated results



76
77
78
79
80
81
# File 'lib/basecamp/generated/services/schedules_service.rb', line 76

def list_entries(schedule_id:, status: nil)
  wrap_paginated(service: "schedules", operation: "list_entries", is_mutation: false, resource_id: schedule_id) do
    params = compact_query_params(status: status)
    paginate("/schedules/#{schedule_id}/entries.json", params: params)
  end
end

#update_entry(entry_id:, summary: nil, starts_at: nil, ends_at: nil, description: nil, participant_ids: nil, all_day: nil, notify: nil) ⇒ Hash

Update an existing schedule entry

Parameters:

  • entry_id (Integer)

    entry id ID

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

    summary

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

    starts at (RFC3339 (e.g., 2024-12-15T09:00:00Z))

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

    ends at (RFC3339 (e.g., 2024-12-15T09:00:00Z))

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

    description

  • participant_ids (Array, nil) (defaults to: nil)

    Replaces the entry's participants.

    Omitting this member preserves the current participants; sending an empty array clears them. That guarantee is BC3-side and recent: until basecamp/bc3#12425, Schedules::EntriesController#update called replace_participants unconditionally, so any update omitting the key — including the shape in BC3's own "Update a schedule entry" doc example — silently removed every participant and notified each one. The controller now guards on the request actually addressing participants.

  • all_day (Boolean, nil) (defaults to: nil)

    all day

  • notify (Boolean, nil) (defaults to: nil)

    notify

Returns:

  • (Hash)

    response data



37
38
39
40
41
# File 'lib/basecamp/generated/services/schedules_service.rb', line 37

def update_entry(entry_id:, summary: nil, starts_at: nil, ends_at: nil, description: nil, participant_ids: nil, all_day: nil, notify: nil)
  with_operation(service: "schedules", operation: "update_entry", is_mutation: true, resource_id: entry_id) do
    http_put("/schedule_entries/#{entry_id}", body: compact_params(summary: summary, starts_at: starts_at, ends_at: ends_at, description: description, participant_ids: participant_ids, all_day: all_day, notify: notify)).json
  end
end

#update_settings(schedule_id:, include_due_assignments:) ⇒ Hash

Update schedule settings

Parameters:

  • schedule_id (Integer)

    schedule id ID

  • include_due_assignments (Boolean)

    include due assignments

Returns:

  • (Hash)

    response data



66
67
68
69
70
# File 'lib/basecamp/generated/services/schedules_service.rb', line 66

def update_settings(schedule_id:, include_due_assignments:)
  with_operation(service: "schedules", operation: "update_settings", is_mutation: true, resource_id: schedule_id) do
    http_put("/schedules/#{schedule_id}", body: compact_params(include_due_assignments: include_due_assignments)).json
  end
end