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
117 changes: 117 additions & 0 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1942,6 +1942,109 @@ paths:
"401":
$ref: '#/components/responses/Unauthorized'

/relationship_categories:
get:
tags: [Beneficiaries]
summary: List the organisation's Relationship Categories
description: |
The kinds of relationship Contacts can have with each other in the organisation, each with
its two sides, e.g. School & Pupil or Mother & Son. A fixed Signup Page and a permitted
relationship (`POST /permitted_relationships`) use one. Any member of the organisation can
list them.
`charity_id` may be left out when the user belongs to one organisation.
operationId: listRelationshipCategories
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 Relationship Categories, by title
content:
application/json:
schema:
allOf:
- $ref: '#/components/schemas/PaginationEnvelope'
- type: object
properties:
data:
type: array
items: { $ref: '#/components/schemas/RelationshipCategory' }
"401":
$ref: '#/components/responses/Unauthorized'
"404":
$ref: '#/components/responses/NotFound'
"422":
$ref: '#/components/responses/UnprocessableEntityList'
post:
tags: [Beneficiaries]
summary: Create a Relationship Category
description: |
Adds a kind of relationship Contacts can have with each other, as the New Relationship Type
page does: its two sides, e.g. Parent & Child or Client & Emergency Contact. A fixed Signup
Page needs at least one to connect the people it signs up.

Only organisation editors (Organisation Admins) may create them (`403` otherwise). The same
pair of titles can't exist twice in an organisation, whatever their case: `422` then gives
`existing_id`, the one already there, to reuse. List them first with
`GET /relationship_categories`. `charity_id` may be left out when the user belongs to one
organisation.
operationId: createRelationshipCategory
security: [{tokenAuth: []}]
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [parent_title, child_title]
properties:
charity_id:
type: integer
description: The organisation to add it to
parent_title:
type: string
description: The first side, e.g. Parent
child_title:
type: string
description: The second side, e.g. Child
example:
charity_id: 12
parent_title: Parent
child_title: Child
responses:
"201":
description: The Relationship Category made
content:
application/json:
schema: { $ref: '#/components/schemas/RelationshipCategory' }
"401":
$ref: '#/components/responses/Unauthorized'
"403":
$ref: '#/components/responses/ForbiddenError'
"404":
$ref: '#/components/responses/NotFound'
"422":
description: Validation failed, or the pair of titles already exists
content:
application/json:
schema:
type: object
properties:
errors:
type: array
items: { type: string }
existing_id:
type: integer
description: The Relationship Category with these titles already, when that is why
example:
errors: ["Already exists"]
existing_id: 34
/beneficiary_types:
get:
tags: [Beneficiary Types]
Expand Down Expand Up @@ -15015,6 +15118,20 @@ components:
type: string
enum: [Person, Organisation, Animal, Object]

RelationshipCategory:
type: object
description: A kind of relationship between Contacts, with its two sides
properties:
id: { type: integer }
parent_title:
type: string
description: The first side, e.g. School
child_title:
type: string
description: The second side, e.g. Pupil
created_at: { type: string, format: date-time }
updated_at: { type: string, format: date-time }

BeneficiaryCategory:
allOf:
- $ref: '#/components/schemas/Timestamps'
Expand Down
21 changes: 21 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -1571,6 +1571,27 @@ function buildDocsPage() {
{ code: "401", cls: "response-4xx", desc: "Not authenticated" },
{ code: "404", cls: "response-4xx", desc: "Not found, or started by someone else" }
], "Only the user who started the move can see it.")}
${endpointCard("GET", "/relationship_categories", "List the organisation's Relationship Categories", 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 categories changed since then" }
], [
{ code: "200", cls: "response-2xx", desc: "<code>data</code>: each category's <code>id</code>, <code>parent_title</code> and <code>child_title</code> (e.g. School and Pupil), in the paginated envelope" },
{ code: "401", cls: "response-4xx", desc: "Not authenticated" },
{ code: "404", cls: "response-4xx", desc: "An organisation you aren't in" }
], "The kinds of relationship Contacts can have with each other in the organisation. Any member of the organisation can list them.")}
${endpointCard("POST", "/relationship_categories", "Create a Relationship Category", true, [
{ name: "charity_id", in: "body", type: "integer", required: false, desc: "The organisation. Optional if you belong to only one" },
{ name: "parent_title", in: "body", type: "string", required: true, desc: "The first side, e.g. Parent" },
{ name: "child_title", in: "body", type: "string", required: true, desc: "The second side, e.g. Child" }
], [
{ code: "201", cls: "response-2xx", desc: "The category made: <code>id</code>, <code>parent_title</code>, <code>child_title</code>" },
{ 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: "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.")}
</div>
</section>

Expand Down
Loading