diff --git a/openapi.yaml b/openapi.yaml index b4e0663..d24e58e 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -6473,10 +6473,15 @@ paths: child_title: type: string description: The second side, e.g. Child + counts_as_household: + type: boolean + default: false + description: Whether Contacts linked by this category count as one household example: charity_id: 12 parent_title: Parent child_title: Child + counts_as_household: true responses: "201": description: The Relationship Category made @@ -6505,6 +6510,58 @@ paths: example: errors: ["Already exists"] existing_id: 34 + /relationship_categories/{id}: + patch: + tags: [Beneficiaries] + summary: Update a Relationship Category + description: | + Changes a kind of relationship's two titles, or whether it counts as a household, as Edit + on the organisation's Relationship Types page does. Mark the family relationships an + organisation uses (e.g. Parent & Child, Partner & Partner) with `counts_as_household`, and + Contacts linked by them, directly or through other Contacts, are counted as one household. + Households are recalculated in the background within a few minutes. + + Only organisation editors (Organisation Admins) may change them (`403` otherwise). Send + only the fields to change. + operationId: updateRelationshipCategory + security: [{tokenAuth: []}] + parameters: + - name: id + in: path + required: true + schema: { type: integer } + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + parent_title: + type: string + description: The new first side + child_title: + type: string + description: The new second side + counts_as_household: + type: boolean + description: Whether Contacts linked by this category count as one household + example: + counts_as_household: true + responses: + "200": + description: The Relationship Category as changed + content: + application/json: + schema: { $ref: '#/components/schemas/RelationshipCategory' } + "401": + $ref: '#/components/responses/Unauthorized' + "403": + $ref: '#/components/responses/ForbiddenError' + "404": + $ref: '#/components/responses/NotFound' + "422": + $ref: '#/components/responses/UnprocessableEntityList' /audiences: get: tags: [Beneficiaries] @@ -29781,6 +29838,11 @@ components: child_title: type: string description: The second side, e.g. Pupil + counts_as_household: + type: boolean + description: | + Whether Contacts linked by this category, directly or through other Contacts, are + counted as one household (family), e.g. Parent & Child or Partner & Partner created_at: { type: string, format: date-time } updated_at: { type: string, format: date-time } diff --git a/server.js b/server.js index 96f5fb8..51e0a54 100644 --- a/server.js +++ b/server.js @@ -2152,21 +2152,34 @@ function buildDocsPage() { { 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: "data: each category's id, parent_title and child_title (e.g. School and Pupil), in the paginated envelope" }, + { code: "200", cls: "response-2xx", desc: "data: each category's id, parent_title and child_title (e.g. School and Pupil), and counts_as_household, 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" } + { name: "child_title", in: "body", type: "string", required: true, desc: "The second side, e.g. Child" }, + { name: "counts_as_household", in: "body", type: "boolean", required: false, desc: "Whether Contacts linked by it count as one household. Default false" } ], [ - { code: "201", cls: "response-2xx", desc: "The category made: id, parent_title, child_title" }, + { code: "201", cls: "response-2xx", desc: "The category made: id, parent_title, child_title, counts_as_household" }, { 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("PATCH", "/relationship_categories/{id}", "Update a Relationship Category", true, [ + { name: "id", in: "path", type: "integer", required: true, desc: "The Relationship Category" }, + { name: "parent_title", in: "body", type: "string", required: false, desc: "The new first side" }, + { name: "child_title", in: "body", type: "string", required: false, desc: "The new second side" }, + { name: "counts_as_household", in: "body", type: "boolean", required: false, desc: "Whether Contacts linked by it count as one household" } + ], [ + { code: "200", cls: "response-2xx", desc: "The category as changed: id, parent_title, child_title, counts_as_household" }, + { 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: "A category in an organisation you aren't in" }, + { code: "422", cls: "response-4xx", desc: "A title is blank, or the new pair already exists" } + ], "Edit on the organisation's Relationship Types page. Tick Counts as a household for family relationships such as Parent & Child: Contacts linked by them, directly or through other Contacts, are then counted as one household. Households are recalculated in the background within a few minutes.")} ${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" },