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
97 changes: 97 additions & 0 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4842,6 +4842,103 @@ paths:
"404":
$ref: '#/components/responses/NotFound'

/beneficiaries/{beneficiary_id}/bio_fields:
patch:
tags: [Beneficiaries]
summary: Change a Contact's Bio answers
operationId: updateContactBioFields
description: |
Changes a Contact's answers to some of their Bio fields: the fields on their Contact Forms, such as
School, Gender or Date of birth. This is what a cell of the **Bio per Contact** and **Custom Table**
views saves in Edit mode, and it goes through the same save as the Contact's Edit Bio page.

Each field is named by `field_class` and `field_id`:

- `CustomField`: a text, number, date, time or telephone field, by its id. `value` is a string.
Dates may be `YYYY-MM-DD` and times `HH:MM` (24-hour).
- `RatioSet`: a Dropdown, by its id. `value` is an array of answer (Sub Ratio) ids; `[]` clears it.
A Dropdown that allows one answer keeps the first.
- `BeneficiaryColumn`: `date_of_birth` (`YYYY-MM-DD`) or `address`. `value` is a string.

A blank string clears an answer. Every field is checked before anything is saved, so one refused
field leaves the Contact unchanged. A field is refused when you can't edit the Contact (403), Field
Visibility hides it from you (403), it doesn't exist (404), it isn't on any of the Contact's own
Contact Forms, it is a file, signature, weekly availability or extended table field or an email the
organisation messages Contacts through, a mandatory field is left empty, or a Dropdown answer isn't
one of its choices (422).
security: [{tokenAuth: []}]
parameters:
- name: beneficiary_id
in: path
required: true
description: The Contact (Beneficiary)
schema:
type: integer
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [fields]
properties:
fields:
type: array
minItems: 1
maxItems: 50
items:
type: object
required: [field_class, field_id, value]
properties:
field_class:
type: string
enum: [CustomField, RatioSet, BeneficiaryColumn]
field_id:
oneOf:
- type: integer
- type: string
enum: [date_of_birth, address]
value:
oneOf:
- type: string
- type: array
items:
type: integer
example:
fields:
- { field_class: CustomField, field_id: 412, value: Lydiard Park Academy }
- { field_class: RatioSet, field_id: 37, value: [215] }
- { field_class: BeneficiaryColumn, field_id: date_of_birth, value: "2008-04-17" }
responses:
"200":
description: The answers were saved. Each value is what the field now shows (Dropdown answers joined with ", ").
content:
application/json:
schema:
type: object
properties:
data:
type: array
items:
type: object
properties:
field_class: { type: string }
field_id: { type: string }
value: { type: string }
example:
data:
- { field_class: CustomField, field_id: "412", value: Lydiard Park Academy }
- { field_class: RatioSet, field_id: "37", value: Female }
- { field_class: BeneficiaryColumn, field_id: date_of_birth, value: "2008-04-17" }
"401":
$ref: '#/components/responses/Unauthorized'
"403":
$ref: '#/components/responses/Forbidden'
"404":
$ref: '#/components/responses/NotFound'
"422":
$ref: '#/components/responses/UnprocessableEntity'

/beneficiaries/{beneficiary_id}/staff_suggestions:
get:
tags: [Staff Matching]
Expand Down
9 changes: 9 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -1924,6 +1924,15 @@ function buildDocsPage() {
{ code: "200", cls: "response-2xx", desc: "Contact created" },
{ code: "422", cls: "response-4xx", desc: "Validation failed (name and owner_id are required), a field hidden from you by Field Visibility was sent, or a Weekly availability answer can't be read" }
], "Required fields: <code>beneficiary.name</code>, <code>beneficiary.owner_id</code> (User ID of the record owner). Submit custom field values as <code>custom_fields: {\"field_id\": \"value\"}</code>. A Weekly availability field takes a list of days and times: <code>[{\"day\": \"monday\", \"from\": \"15:30\", \"to\": \"18:00\"}]</code>, times HH:MM in 15-minute steps with <code>to</code> after <code>from</code>; overlapping times on a day are joined. Setting a field hidden from you by Field Visibility is refused with 422 and an <code>errors</code> list naming it.")}
${endpointCard("PATCH", "/beneficiaries/{beneficiary_id}/bio_fields", "Change a Contact's Bio answers", true, [
{ name: "beneficiary_id", in: "path", type: "integer", required: true, desc: "Contact ID" },
{ name: "fields", in: "body", type: "array", required: true, desc: "1 to 50 of <code>{field_class, field_id, value}</code>" }
], [
{ code: "200", cls: "response-2xx", desc: "Saved. <code>data</code> lists each field with what it now shows" },
{ code: "403", cls: "response-4xx", desc: "You can't edit the Contact, or Field Visibility hides a field from you" },
{ code: "404", cls: "response-4xx", desc: "The Contact or a field wasn't found" },
{ code: "422", cls: "response-4xx", desc: "A field isn't on the Contact's forms or can't be changed here, a mandatory field was left empty, or a Dropdown answer isn't one of its choices" }
], "Changes a Contact's answers to Bio fields, as a cell of <strong>Bio per Contact</strong> or a <strong>Custom Table</strong> does in Edit mode. <code>field_class</code> is <code>CustomField</code> (a text, number, date, time or telephone field, by id, with a string value), <code>RatioSet</code> (a Dropdown, by id, with an array of answer ids; <code>[]</code> clears it) or <code>BeneficiaryColumn</code> (<code>date_of_birth</code> or <code>address</code>). Dates may be <code>YYYY-MM-DD</code> and times <code>HH:MM</code>. A blank string clears an answer. Every field is checked before anything is saved, so one refused field leaves the Contact unchanged. File, signature, weekly availability and extended table fields are changed on the Contact's Edit Bio page.")}
${endpointCard("GET", "/beneficiaries/{beneficiary_id}/summary", "Get the AI summary of a Contact (SummaryMaker)", true, [
{ name: "beneficiary_id", in: "path", type: "integer", required: true, desc: "Contact ID" }
], [
Expand Down
Loading