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
112 changes: 112 additions & 0 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2045,6 +2045,98 @@ paths:
example:
errors: ["Already exists"]
existing_id: 34
/audiences:
get:
tags: [Beneficiaries]
summary: List the organisation's audiences
description: |
The organisation's audiences (Contact Roles; Beneficiary Roles), e.g. Participant or Parent,
as on its Audiences page, by name. Each lists the Contact Types (Person, Organisation, …) it
is for. A flexible Signup Page signs people up as audiences, and a permitted relationship
says which audiences may be on each side of a Relationship Category. Any member of the
organisation can list them. `charity_id` may be left out when the user belongs to one
organisation.
operationId: listAudiences
security: [{tokenAuth: []}]
parameters:
- name: charity_id
in: query
required: false
schema: { type: integer }
- $ref: '#/components/parameters/Page'
- $ref: '#/components/parameters/PerPage'
- $ref: '#/components/parameters/LastSyncDatetime'
responses:
"200":
description: A page of audiences, by name
content:
application/json:
schema:
allOf:
- $ref: '#/components/schemas/PaginationEnvelope'
- type: object
properties:
data:
type: array
items: { $ref: '#/components/schemas/Audience' }
"401":
$ref: '#/components/responses/Unauthorized'
"404":
$ref: '#/components/responses/NotFound'
"422":
$ref: '#/components/responses/UnprocessableEntityList'
post:
tags: [Beneficiaries]
summary: Create an audience
description: |
Adds an audience (Contact Role; Beneficiary Role), as the New Audience page does. `color` is
one of the approved colours (the first, `#f96d67`, if left out). `contact_type_id` links it to
a Contact Type (`GET /beneficiary_types`); it is linked to Person if left out. Only
organisation editors (Organisation Admins) may create audiences (`403` otherwise). Names
aren't unique, so list them first with `GET /audiences` and reuse one that fits.
operationId: createAudience
security: [{tokenAuth: []}]
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [name]
properties:
charity_id:
type: integer
description: The organisation to add it to
name:
type: string
description: e.g. Participant
color:
type: string
description: |
One of #f96d67, #f31208, #bc1204, #f92915, #f26f21, #ff6800, #e59200, #ffa300,
#62a837, #71c240, #2b800e, #36ac9a, #2e9283, #226c61, #225f85, #2e85bc, #3596d6,
#063262, #ac3898, #6c235f, #620a4d, #8c1b6d, #d07db7, #a81e6a, #e82a92, #8e0132
contact_type_id:
type: integer
description: The Contact Type (Beneficiary Type) it is for; Person if left out
example:
charity_id: 12
name: Parent
color: '#ac3898'
responses:
"201":
description: The audience made
content:
application/json:
schema: { $ref: '#/components/schemas/Audience' }
"401":
$ref: '#/components/responses/Unauthorized'
"403":
$ref: '#/components/responses/ForbiddenError'
"404":
$ref: '#/components/responses/NotFound'
"422":
$ref: '#/components/responses/UnprocessableEntityList'
/beneficiary_types:
get:
tags: [Beneficiary Types]
Expand Down Expand Up @@ -15132,6 +15224,26 @@ components:
created_at: { type: string, format: date-time }
updated_at: { type: string, format: date-time }

Audience:
type: object
description: An audience (Contact Role; Beneficiary Role), e.g. Participant or Parent
properties:
id: { type: integer }
name: { type: string }
color:
type: string
description: Its colour on the Audiences page, e.g. '#f96d67'
contact_types:
type: array
description: The Contact Types (Beneficiary Types) it is for
items:
type: object
properties:
id: { type: integer }
name: { type: string }
created_at: { type: string, format: date-time }
updated_at: { type: string, format: date-time }

BeneficiaryCategory:
allOf:
- $ref: '#/components/schemas/Timestamps'
Expand Down
22 changes: 22 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -1592,6 +1592,28 @@ function buildDocsPage() {
{ code: "404", cls: "response-4xx", desc: "An organisation you aren't in" },
{ code: "422", cls: "response-4xx", desc: "A title is missing, or the pair already exists in any case: <code>existing_id</code> is the one already there, to reuse" }
], "<strong>New Relationship Type</strong> on the organisation's Relationship Types page, e.g. Parent &amp; Child or Client &amp; Emergency Contact. A fixed Signup Page needs one to connect the people it signs up. List them first and reuse one that fits.")}
${endpointCard("GET", "/audiences", "List the organisation's audiences", true, [
{ name: "charity_id", in: "query", type: "integer", required: false, desc: "The organisation. Optional if you belong to only one" },
{ name: "page", in: "query", type: "integer", required: false, desc: "Page number" },
{ name: "per_page", in: "query", type: "integer", required: false, desc: "Default 10, max 200" },
{ name: "last_synced_datetime", in: "query", type: "string", required: false, desc: "Only audiences changed since then" }
], [
{ code: "200", cls: "response-2xx", desc: "<code>data</code>: each audience's <code>id</code>, <code>name</code>, <code>color</code> and <code>contact_types</code>, by name, in the paginated envelope" },
{ code: "401", cls: "response-4xx", desc: "Not authenticated" },
{ code: "404", cls: "response-4xx", desc: "An organisation you aren't in" }
], "Audiences (Contact Roles), e.g. Participant or Parent, as on the organisation's Audiences page. A flexible Signup Page signs people up as audiences. Any member of the organisation can list them.")}
${endpointCard("POST", "/audiences", "Create an audience", true, [
{ name: "charity_id", in: "body", type: "integer", required: false, desc: "The organisation. Optional if you belong to only one" },
{ name: "name", in: "body", type: "string", required: true, desc: "e.g. Participant" },
{ name: "color", in: "body", type: "string", required: false, desc: "One of the approved colours; <code>#f96d67</code> if left out" },
{ name: "contact_type_id", in: "body", type: "integer", required: false, desc: "The Contact Type (<code>GET /beneficiary_types</code>); Person if left out" }
], [
{ code: "201", cls: "response-2xx", desc: "The audience made" },
{ code: "401", cls: "response-4xx", desc: "Not authenticated" },
{ code: "403", cls: "response-4xx", desc: "You aren't an organisation editor (Organisation Admin)" },
{ code: "404", cls: "response-4xx", desc: "An organisation you aren't in" },
{ code: "422", cls: "response-4xx", desc: "No name, a colour that isn't approved, or an unknown Contact Type" }
], "<strong>New Audience</strong> on the Audiences page. Names aren't unique: list them first and reuse one that fits.")}
</div>
</section>

Expand Down
Loading