Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
157 changes: 157 additions & 0 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ tags:
description: Guided tours of Makerble's own pages for new colleagues; Organisation Admins choose each team's stops, wording and how strict they are, and see who has finished
- name: Staff Unavailability
description: When colleagues can't work for an Organisation (leave, sickness, training), as on the Staff availability page
- name: Staff Capacity
description: How many appointments and one-to-one Contacts a colleague can take on in an Organisation, as on the Staff availability page
- name: Training Materials
description: An Organisation's links to its own training documents and videos, each shown to the whole Organisation or to chosen Teams and Workspaces
- name: Announcements
Expand Down Expand Up @@ -1316,6 +1318,126 @@ paths:
$ref: '#/components/responses/NotFound'
"422":
$ref: '#/components/responses/UnprocessableEntityList'
/users/{user_id}/capacity:
parameters:
- name: user_id
in: path
required: true
description: The colleague (User)
schema:
type: integer
- name: charity_id
in: query
required: true
description: The Organisation (Charity). A colleague has separate caps in each Organisation.
schema:
type: integer
get:
tags: [Staff Capacity]
summary: Get a colleague's capacity
operationId: getColleagueCapacity
description: |
A colleague's capacity caps in one Organisation, and how much they have taken on, as in the
**Edit capacity** popup on the Staff availability page.

- `max_per_day` and `max_per_week` cap their appointments; `max_one_to_one_contacts` caps the
Contacts who have an upcoming one-to-one appointment with them. `null` means no limit.
- An **appointment** is an event whose Event Format has an `appointment_type`, where the
colleague is an Event Worker. `usage` counts them for today and this week (Monday to
Sunday) in the Organisation's timezone, and counts their ongoing one-to-one Contacts: the
distinct guests of their upcoming one-to-one appointments.
- Anyone who sees the colleague on Staff availability can read this: the colleague themselves,
their Team Leaders, Project Editors of their Projects and Organisation Admins. Anyone else in
the Organisation gets `403`; an Organisation you aren't in returns `404`.
- `can_edit` says whether you may change the caps.
security: [{tokenAuth: []}]
responses:
"200":
description: The colleague's caps and usage
content:
application/json:
schema:
$ref: '#/components/schemas/ColleagueCapacity'
example:
user_id: 812
charity_id: 123
max_per_day: 4
max_per_week: 15
max_one_to_one_contacts: 12
can_edit: true
usage:
appointments_today: 2
appointments_this_week: 11
ongoing_one_to_one_contacts: 9
"401":
$ref: '#/components/responses/Unauthorized'
"403":
description: You can't see this colleague on Staff availability
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error: "forbidden"
"404":
$ref: '#/components/responses/NotFound'
patch:
tags: [Staff Capacity]
summary: Set a colleague's capacity
operationId: updateColleagueCapacity
description: |
Sets a colleague's capacity caps in one Organisation, as **Edit capacity** on the Staff
availability page does. Only the caps you send change; send `null` to remove a limit. Whole
numbers from 0 to 1000.

Only an **Organisation Admin**, or a **Team Leader** of a Team the colleague is in, may set them.
A colleague can't set their own (`403`).
security: [{tokenAuth: []}]
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
max_per_day:
type: integer
nullable: true
description: Maximum appointments a day
max_per_week:
type: integer
nullable: true
description: Maximum appointments a week
max_one_to_one_contacts:
type: integer
nullable: true
description: Maximum ongoing one-to-one Contacts
example:
max_per_day: 4
max_per_week: null
max_one_to_one_contacts: 12
responses:
"200":
description: The colleague's caps and usage, as **Get a colleague's capacity** returns them
content:
application/json:
schema:
$ref: '#/components/schemas/ColleagueCapacity'
"401":
$ref: '#/components/responses/Unauthorized'
"403":
description: You are not an Organisation Admin or a Team Leader of a Team the colleague is in, or this is your own capacity
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error: "Only a Charity Editor, or a Team Leader of a Team the colleague is in, can change their capacity."
"404":
$ref: '#/components/responses/NotFound'
"422":
$ref: '#/components/responses/UnprocessableEntity'

/users/{user_id}/unavailabilities:
parameters:
- name: user_id
Expand Down Expand Up @@ -23600,6 +23722,41 @@ components:
nullable: true
description: Why it can't be deleted yet, or null

ColleagueCapacity:
type: object
description: A colleague's capacity caps in one Organisation, and how much they have taken on.
properties:
user_id:
type: integer
charity_id:
type: integer
max_per_day:
type: integer
nullable: true
description: Maximum appointments a day, or null for no limit
max_per_week:
type: integer
nullable: true
description: Maximum appointments a week, or null for no limit
max_one_to_one_contacts:
type: integer
nullable: true
description: Maximum Contacts with an upcoming one-to-one appointment with them, or null for no limit
can_edit:
type: boolean
description: Whether you may change the caps
usage:
type: object
properties:
appointments_today:
type: integer
appointments_this_week:
type: integer
description: Monday to Sunday, in the Organisation's timezone
ongoing_one_to_one_contacts:
type: integer
description: Distinct guests of their upcoming one-to-one appointments

EventFormatInput:
type: object
description: Settings for creating or editing an Event Format. Only the settings you send change.
Expand Down
33 changes: 33 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -964,6 +964,7 @@ function buildDocsPage() {
<div class="nav-section-label">Events</div>
<a href="#events" class="nav-link"><span class="nav-method method-GET">GET</span>Events</a>
<a href="#event-formats" class="nav-link"><span class="nav-method method-GET">GET</span>Event Formats</a>
<a href="#staff-capacity" class="nav-link"><span class="nav-method method-PATCH">PATCH</span>Staff Capacity</a>
<a href="#staff-unavailability" class="nav-link"><span class="nav-method method-POST">POST</span>Staff Unavailability</a>
</div>
<div class="nav-section">
Expand Down Expand Up @@ -3793,6 +3794,38 @@ function buildDocsPage() {
</section>

<!-- Event Formats -->
<section class="section" id="staff-capacity">
<div class="section-eyebrow">Events</div>
<h2 class="section-title">Staff Capacity</h2>
<div class="section-desc">
<p>How much a colleague can take on in an Organisation: maximum appointments a day and a week, and maximum ongoing one-to-one Contacts (Contacts with an upcoming one-to-one appointment with them). A blank (<code>null</code>) cap means no limit. It appears in the Capacity column of the Staff availability page.</p>
<p>An appointment is an event whose Event Format has an <code>appointment_type</code>, where the colleague is an Event Worker. <code>usage</code> counts today's and this week's appointments, Monday to Sunday in the Organisation's timezone, and the colleague's ongoing one-to-one Contacts.</p>
<p>Anyone who sees the colleague on Staff availability can read their capacity: the colleague themselves, their Team Leaders, Project Editors of their Projects and Organisation Admins. Only Organisation Admins, and Team Leaders of a Team the colleague is in, can change it, and nobody can change their own.</p>
</div>
<div class="endpoint-list">
${endpointCard("GET", "/users/{user_id}/capacity", "Get a colleague's capacity", true, [
{ name: "user_id", in: "path", type: "integer", required: true, desc: "The colleague (User)" },
{ name: "charity_id", type: "integer", required: true, desc: "The Organisation" }
], [
{ code: "200", cls: "response-2xx", desc: "max_per_day, max_per_week, max_one_to_one_contacts, can_edit and usage" },
{ code: "403", cls: "response-4xx", desc: "You can't see this colleague on Staff availability" },
{ code: "404", cls: "response-4xx", desc: "Not found, or an Organisation you are not in" }
])}
${endpointCard("PATCH", "/users/{user_id}/capacity", "Set a colleague's capacity", true, [
{ name: "user_id", in: "path", type: "integer", required: true, desc: "The colleague (User)" },
{ name: "charity_id", type: "integer", required: true, desc: "The Organisation" },
{ name: "max_per_day", in: "body", type: "integer", required: false, desc: "Maximum appointments a day, or null for no limit" },
{ name: "max_per_week", in: "body", type: "integer", required: false, desc: "Maximum appointments a week, or null for no limit" },
{ name: "max_one_to_one_contacts", in: "body", type: "integer", required: false, desc: "Maximum ongoing one-to-one Contacts, or null for no limit" }
], [
{ code: "200", cls: "response-2xx", desc: "Saved — returns the caps and usage" },
{ code: "403", cls: "response-4xx", desc: "Not an Organisation Admin or a Team Leader of the colleague, or your own capacity" },
{ code: "404", cls: "response-4xx", desc: "Not found, or an Organisation you are not in" },
{ code: "422", cls: "response-4xx", desc: "A cap is not a whole number from 0 to 1000" }
])}
</div>
</section>

<section class="section" id="staff-unavailability">
<div class="section-eyebrow">Events</div>
<h2 class="section-title">Staff Unavailability</h2>
Expand Down
Loading