diff --git a/openapi.yaml b/openapi.yaml index a5e77f3..ba36b91 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -1903,6 +1903,70 @@ paths: $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 /beneficiaries/bulk_actions/{id}: get: tags: [Beneficiaries] diff --git a/server.js b/server.js index 5bec9d5..696e2ce 100644 --- a/server.js +++ b/server.js @@ -1604,6 +1604,17 @@ function buildDocsPage() { { 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: id, parent_title, child_title" }, + { 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: existing_id is the one already there, to reuse" } + ], "New Relationship Type on the organisation's Relationship Types page, e.g. Parent & Child or Client & 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", "/beneficiaries/bulk_actions/{id}", "Get the progress of a bulk action on Contacts", true, [ { name: "id", in: "path", type: "integer", required: true, desc: "The id returned by a bulk change, e.g. POST /events/{id}/guests with filter_data" } ], [