From 90ec8764f804a30828d1a329a362fc74b208c0b8 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 30 Nov 2026 22:07:48 +0000 Subject: [PATCH] Document the Reporting Cycles endpoints GET, POST and PATCH /reporting_cycles (CP-8227): a series of reports owed to one recipient, each Deadline saying which Report Template, which projects and albums, which timeframe and when it is due. Adds the openapi.yaml paths and schemas and the matching endpoint cards. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01F1a5xpgPaoHB2phiSFV4gE --- openapi.yaml | 382 +++++++++++++++++++++++++++++++++++++++++++++++++++ server.js | 52 +++++++ 2 files changed, 434 insertions(+) diff --git a/openapi.yaml b/openapi.yaml index e62865e..c3236bf 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -13298,6 +13298,177 @@ paths: $ref: '#/components/responses/NotFound' "422": $ref: '#/components/responses/UnprocessableEntity' + /reporting_cycles: + get: + tags: [Reports] + summary: List Reporting Cycles + operationId: listReportingCycles + description: | + Reporting Cycles in ReportMaker. A Reporting Cycle is a series of reports owed to one + recipient (e.g. quarterly to Comic Relief), each Deadline saying which Report Template, which + projects and albums, which timeframe and when it is due. An Organisation Admin sees every cycle + of the organisation; anyone else sees only the cycles they are an Editor or Reporter of. + security: [{tokenAuth: []}] + parameters: + - name: charity_id + in: query + required: false + schema: + type: integer + example: 42 + description: Only this organisation's cycles; leave out for every organisation you belong to + - name: q + in: query + required: false + schema: + type: string + example: Comic Relief + description: Words in the name or the recipient + - $ref: '#/components/parameters/Page' + - $ref: '#/components/parameters/PerPage' + - $ref: '#/components/parameters/LastSyncDatetime' + responses: + "200": + description: The Reporting Cycles you can see + content: + application/json: + schema: + $ref: '#/components/schemas/PaginatedReportingCycles' + "401": + $ref: '#/components/responses/Unauthorized' + "404": + $ref: '#/components/responses/NotFound' + post: + tags: [Reports] + summary: Create a Reporting Cycle + operationId: createReportingCycle + description: | + Creates a Reporting Cycle with its Deadlines, as **Create a Reporting Cycle** does. Give + every Deadline explicit dates (`YYYY-MM-DD`). Every id must belong to the organisation: + `editor_ids` and `reporter_ids` are its users, `project_ids` its projects you can view, + `album_ids` its albums and `report_template_id` a Report Template it can use. Errors name the + Deadline, e.g. `Deadline "Q1": Timeframe from must be on or before timeframe to`. Requires an + Organisation Admin; another organisation is a 404. + security: [{tokenAuth: []}] + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/ReportingCycleInput' + example: + charity_id: 42 + name: Comic Relief 2027 + recipient: Comic Relief + reporter_ids: [118] + deadlines: + - name: Q1 2027 report + report_template_id: 7 + timeframe_from: "2027-01-01" + timeframe_to: "2027-03-31" + submission_deadline: "2027-04-30" + project_ids: [301, 302] + album_ids: [12] + - name: Q2 2027 report + report_template_id: 7 + timeframe_from: "2027-04-01" + timeframe_to: "2027-06-30" + submission_deadline: "2027-07-31" + project_ids: [301, 302] + album_ids: [12] + responses: + "201": + description: The new Reporting Cycle + content: + application/json: + schema: + type: object + properties: + data: + $ref: '#/components/schemas/ReportingCycle' + "401": + $ref: '#/components/responses/Unauthorized' + "404": + $ref: '#/components/responses/NotFound' + "422": + $ref: '#/components/responses/UnprocessableEntity' + /reporting_cycles/{id}: + get: + tags: [Reports] + summary: Get a Reporting Cycle + operationId: getReportingCycle + description: One Reporting Cycle with its Deadlines in due order. A cycle you can't see is a 404. + security: [{tokenAuth: []}] + parameters: + - name: id + in: path + required: true + schema: + type: integer + example: 15 + responses: + "200": + description: The Reporting Cycle + content: + application/json: + schema: + type: object + properties: + data: + $ref: '#/components/schemas/ReportingCycle' + "401": + $ref: '#/components/responses/Unauthorized' + "404": + $ref: '#/components/responses/NotFound' + patch: + tags: [Reports] + summary: Change a Reporting Cycle + operationId: updateReportingCycle + description: | + Changes a Reporting Cycle, as **Edit Reporting Cycle** does. Fields left out stay as they are; + `editor_ids` and `reporter_ids`, when given, replace the list. In `deadlines`, give an existing + Deadline's `id` to change it (Deadlines without one are added), and `{id, _destroy: true}` to + remove one; Deadlines not listed are kept. Requires an Organisation Admin or an Editor of the + cycle; a Reporter of it gets 403. Deleting a cycle is only on its page. + security: [{tokenAuth: []}] + parameters: + - name: id + in: path + required: true + schema: + type: integer + example: 15 + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/ReportingCycleInput' + example: + deadlines: + - id: 51 + timeframe_from: "2027-01-01" + timeframe_to: "2027-03-31" + - id: 52 + _destroy: true + responses: + "200": + description: The changed Reporting Cycle + content: + application/json: + schema: + type: object + properties: + data: + $ref: '#/components/schemas/ReportingCycle' + "401": + $ref: '#/components/responses/Unauthorized' + "403": + $ref: '#/components/responses/Forbidden' + "404": + $ref: '#/components/responses/NotFound' + "422": + $ref: '#/components/responses/UnprocessableEntity' /requirement_sets: get: tags: [Reports] @@ -26993,6 +27164,217 @@ components: type: array items: $ref: '#/components/schemas/ReportTemplate' + NamedRecord: + type: object + properties: + id: + type: integer + name: + type: string + ReportingCycleSummary: + type: object + properties: + id: + type: integer + charity_id: + type: integer + name: + type: string + recipient: + type: string + nullable: true + editor_ids: + type: array + items: + type: integer + reporter_ids: + type: array + items: + type: integer + deadline_count: + type: integer + next_deadline: + type: object + nullable: true + description: The earliest Deadline due today or later + properties: + id: + type: integer + name: + type: string + submission_deadline: + type: string + format: date + updated_at: + type: string + format: date-time + PaginatedReportingCycles: + type: object + properties: + page: + type: integer + page_size: + type: integer + page_count: + type: integer + total_count: + type: integer + data: + type: array + items: + $ref: '#/components/schemas/ReportingCycleSummary' + Deadline: + type: object + description: One report owed in a Reporting Cycle + properties: + id: + type: integer + name: + type: string + report_template: + allOf: + - $ref: '#/components/schemas/NamedRecord' + nullable: true + timeframe_from: + type: string + format: date + nullable: true + timeframe_to: + type: string + format: date + nullable: true + submission_deadline: + type: string + format: date + nullable: true + projects: + type: array + description: Work to include + items: + $ref: '#/components/schemas/NamedRecord' + albums: + type: array + description: Work to include + items: + $ref: '#/components/schemas/NamedRecord' + exclusive_focus_filter_data: + type: object + description: Exclusive Focus, the Contact filters the report is limited to + reporting_guidance: + type: string + nullable: true + nuance: + type: string + nullable: true + editors: + type: array + items: + $ref: '#/components/schemas/NamedRecord' + reporters: + type: array + items: + $ref: '#/components/schemas/NamedRecord' + ReportingCycle: + type: object + description: A series of reports owed to one recipient + properties: + id: + type: integer + charity_id: + type: integer + name: + type: string + recipient: + type: string + nullable: true + reporting_guidance: + type: string + nullable: true + nuance: + type: string + nullable: true + editors: + type: array + items: + $ref: '#/components/schemas/NamedRecord' + reporters: + type: array + items: + $ref: '#/components/schemas/NamedRecord' + deadlines: + type: array + items: + $ref: '#/components/schemas/Deadline' + updated_at: + type: string + format: date-time + ReportingCycleInput: + type: object + properties: + charity_id: + type: integer + description: The organisation, when creating + name: + type: string + recipient: + type: string + reporting_guidance: + type: string + nuance: + type: string + editor_ids: + type: array + items: + type: integer + reporter_ids: + type: array + items: + type: integer + deadlines: + type: array + items: + type: object + properties: + id: + type: integer + description: An existing Deadline, to change or remove it + _destroy: + type: boolean + name: + type: string + report_template_id: + type: integer + timeframe_from: + type: string + format: date + timeframe_to: + type: string + format: date + submission_deadline: + type: string + format: date + project_ids: + type: array + items: + type: integer + album_ids: + type: array + items: + type: integer + exclusive_focus_filter_data: + type: object + reporting_guidance: + type: string + nuance: + type: string + editor_ids: + type: array + items: + type: integer + reporter_ids: + type: array + items: + type: integer RequirementSet: type: object description: A funder's reporting requirements for a programme, and the metrics that answer each diff --git a/server.js b/server.js index 426ca75..2f30914 100644 --- a/server.js +++ b/server.js @@ -954,6 +954,7 @@ function buildDocsPage() { GETLibrary GETExplore Surveys GETReport Templates + GETReporting Cycles GETRequirement Sets GETReport answers GETExplore Report Templates @@ -3315,6 +3316,57 @@ function buildDocsPage() { + +
+
Reporting
+

Reporting Cycles

+
+

A Reporting Cycle is a series of reports owed to one recipient, e.g. quarterly to Comic Relief. Each Deadline is one report owed: which Report Template it answers, which projects and albums it covers (its Work to include), which timeframe, and when it is due.

+

Every id must belong to the organisation: editor_ids and reporter_ids are its users, project_ids its projects you can view, album_ids its albums, and report_template_id a Report Template it can use. Dates are YYYY-MM-DD, and a Deadline's timeframe_from must be on or before its timeframe_to. Deleting a cycle is only on its page.

+
+
+ ${endpointCard("GET", "/reporting_cycles", "List Reporting Cycles", true, [ + { name: "charity_id", type: "integer", required: false, desc: "Only this organisation's cycles; leave out for every organisation you belong to" }, + { name: "q", type: "string", required: false, desc: "Words in the name or the recipient" }, + { name: "page", type: "integer", required: false, desc: "Page number" }, + { name: "per_page", type: "integer", required: false, desc: "Cycles per page (default 10, max 200)" }, + { name: "last_synced_datetime", type: "string", required: false, desc: "ISO 8601 — only cycles updated after this" } + ], [ + { code: "200", cls: "response-2xx", desc: "The cycles you can see (all of an organisation for an Organisation Admin, otherwise those you are an Editor or Reporter of), each with id, charity_id, name, recipient, editor_ids, reporter_ids, deadline_count, next_deadline and updated_at" }, + { code: "404", cls: "response-4xx", desc: "No such organisation" } + ])} + ${endpointCard("GET", "/reporting_cycles/{id}", "Get a Reporting Cycle", true, [ + { name: "id", in: "path", type: "integer", required: true, desc: "The Reporting Cycle" } + ], [ + { code: "200", cls: "response-2xx", desc: "In data: name, recipient, reporting_guidance, nuance, editors, reporters and deadlines in due order, each with report_template, timeframe_from, timeframe_to, submission_deadline, projects, albums, exclusive_focus_filter_data, reporting_guidance, nuance, editors and reporters" }, + { code: "404", cls: "response-4xx", desc: "Not found, or one you can't see" } + ])} + ${endpointCard("POST", "/reporting_cycles", "Create a Reporting Cycle", true, [ + { name: "charity_id", in: "body", type: "integer", required: true, desc: "The organisation" }, + { name: "name", in: "body", type: "string", required: true, desc: "e.g. Comic Relief 2027" }, + { name: "recipient", in: "body", type: "string", required: false, desc: "Who the reports go to" }, + { name: "reporting_guidance", in: "body", type: "string", required: false, desc: "What every report should cover" }, + { name: "nuance", in: "body", type: "string", required: false, desc: "What the people writing the reports should bear in mind" }, + { name: "editor_ids", in: "body", type: "array", required: false, desc: "Colleagues who may change the cycle" }, + { name: "reporter_ids", in: "body", type: "array", required: false, desc: "Colleagues who contribute to its reports" }, + { name: "deadlines", in: "body", type: "array", required: false, desc: "Each with name, report_template_id, timeframe_from, timeframe_to, submission_deadline, project_ids, album_ids, exclusive_focus_filter_data, reporting_guidance, nuance, editor_ids and reporter_ids" } + ], [ + { code: "201", cls: "response-2xx", desc: "The new Reporting Cycle, in data" }, + { code: "404", cls: "response-4xx", desc: "An organisation you aren't an Organisation Admin of" }, + { code: "422", cls: "response-4xx", desc: "errors naming the Deadline, e.g. Deadline \"Q1\": Timeframe from must be on or before timeframe to" } + ])} + ${endpointCard("PATCH", "/reporting_cycles/{id}", "Change a Reporting Cycle", true, [ + { name: "id", in: "path", type: "integer", required: true, desc: "The Reporting Cycle" }, + { name: "deadlines", in: "body", type: "array", required: false, desc: "Give an existing Deadline's id to change it; Deadlines without one are added; {id, _destroy: true} removes one; Deadlines not listed are kept" } + ], [ + { code: "200", cls: "response-2xx", desc: "The changed Reporting Cycle, in data" }, + { code: "403", cls: "response-4xx", desc: "Not an Organisation Admin or an Editor of the cycle" }, + { code: "404", cls: "response-4xx", desc: "Not found, or one you can't see" }, + { code: "422", cls: "response-4xx", desc: "errors" } + ], "Fields left out stay as they are. editor_ids and reporter_ids, when given, replace the list.")} +
+
+
Reporting