diff --git a/openapi.yaml b/openapi.yaml index dfd0292..49d6984 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -179,6 +179,8 @@ tags: description: The gift icon's Wishlist - your feature requests and feedback, and what Makerble is building next (Coming soon) - name: Saved Filters description: Saved Filters for Contacts, Events and Cases, and adding one to a project's toolbar as a shortcut + - name: Toolkits + description: Toolkits (Collections) are ready-made sets of Surveys, Contact Forms, Impact Frameworks, metrics and tips on Explore Toolkits - name: Albums description: Albums (Bundles; being renamed Portfolios on screen) group Projects so their results can be seen together - name: Age Bands @@ -2542,6 +2544,134 @@ paths: "422": $ref: '#/components/responses/UnprocessableEntity' + /toolkits: + get: + tags: [Toolkits] + summary: List Toolkits + description: | + The Toolkits on Explore Toolkits: ready-made sets of Surveys, Contact Forms, Impact Frameworks, + metrics and tips an organisation can add to its Projects in one go (Collections in the + database). A user with Marketing or Admin system access also sees listed Toolkits still + awaiting approval, as Site Overview › Manage Toolkits shows them. + operationId: listToolkits + security: [{tokenAuth: []}] + parameters: + - $ref: '#/components/parameters/Page' + - $ref: '#/components/parameters/PerPage' + - $ref: '#/components/parameters/LastSyncDatetime' + responses: + "200": + description: Paginated list of Toolkits + content: + application/json: + schema: + $ref: '#/components/schemas/ToolkitList' + "401": + $ref: '#/components/responses/Unauthorized' + + /toolkits/{id}: + get: + tags: [Toolkits] + summary: Get a Toolkit + description: | + One Toolkit, if the user can see its page: a Toolkit on Explore Toolkits, or one the user can + edit. Any other returns 404. + operationId: getToolkit + security: [{tokenAuth: []}] + parameters: + - $ref: '#/components/parameters/ResourceId' + responses: + "200": + description: The Toolkit + content: + application/json: + schema: + $ref: '#/components/schemas/Toolkit' + "401": + $ref: '#/components/responses/Unauthorized' + "404": + $ref: '#/components/responses/NotFound' + + patch: + tags: [Toolkits] + summary: Update a Toolkit's number and image settings + description: | + Sets the Toolkit number and whether the thumbnail (on Explore Toolkits) and the cover image (on + the Toolkit's page) are darkened, as the Create/Edit Collection page does. Only the fields sent + change. The user must be able to edit the Toolkit: its owner, an editor of its Organisation, or + a user with Marketing or Admin system access. + operationId: updateToolkit + security: [{tokenAuth: []}] + parameters: + - $ref: '#/components/parameters/ResourceId' + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/ToolkitUpdateRequest' + example: + toolkit_number: "T14" + darken_cover_image: true + responses: + "200": + description: The Toolkit + content: + application/json: + schema: + $ref: '#/components/schemas/Toolkit' + "401": + $ref: '#/components/responses/Unauthorized' + "403": + $ref: '#/components/responses/ForbiddenError' + "404": + $ref: '#/components/responses/NotFound' + "422": + $ref: '#/components/responses/UnprocessableEntity' + + /toolkits/{id}/image: + patch: + tags: [Toolkits] + summary: Replace a Toolkit's thumbnail or cover image + description: | + Uploads a new thumbnail (`kind: thumbnail`, shown on Explore Toolkits) or cover image + (`kind: cover`, shown on the Toolkit's page), as Replace does on Site Overview › Manage + Toolkits. Send it as `multipart/form-data`. The image must be a JPEG or PNG. Needs Marketing or + Admin system access. + operationId: replaceToolkitImage + security: [{tokenAuth: []}] + parameters: + - $ref: '#/components/parameters/ResourceId' + requestBody: + required: true + content: + multipart/form-data: + schema: + type: object + required: [kind, image] + properties: + kind: + type: string + enum: [thumbnail, cover] + image: + type: string + format: binary + responses: + "200": + description: The Toolkit, with its new image + content: + application/json: + schema: + $ref: '#/components/schemas/Toolkit' + "401": + $ref: '#/components/responses/Unauthorized' + "403": + $ref: '#/components/responses/ForbiddenError' + "404": + $ref: '#/components/responses/NotFound' + "422": + $ref: '#/components/responses/UnprocessableEntity' + /albums: get: tags: [Albums] @@ -20922,6 +21052,81 @@ components: type: string example: "Enrolled" + Toolkit: + type: object + description: A Toolkit (Collection in the database) on Explore Toolkits. + properties: + id: + type: integer + name: + type: string + slug: + type: string + nullable: true + toolkit_number: + type: string + nullable: true + description: The Toolkit's number, e.g. "T14", shown on Site Overview › Manage Toolkits + strapline: + type: string + nullable: true + description: + type: string + nullable: true + approved: + type: boolean + description: Whether Makerble has approved the Toolkit for Explore Toolkits + thumbnail_image_url: + type: string + nullable: true + description: The image on the Toolkit's Explore Toolkits card; when null, the card uses the cover image + cover_image_url: + type: string + nullable: true + description: The image at the top of the Toolkit's page + darken_thumbnail_image: + type: boolean + description: Whether a dark translucent layer covers the thumbnail on Explore Toolkits + darken_cover_image: + type: boolean + description: Whether a dark translucent layer covers the cover image on the Toolkit's page + url: + type: string + description: The Toolkit's page in Makerble + created_at: + type: string + format: date-time + updated_at: + type: string + format: date-time + + ToolkitList: + 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/Toolkit' + + ToolkitUpdateRequest: + type: object + properties: + toolkit_number: + type: string + nullable: true + darken_thumbnail_image: + type: boolean + darken_cover_image: + type: boolean + Album: type: object description: An Album (Bundle; Portfolio on screen) groups Projects so their results can be seen together. diff --git a/server.js b/server.js index 3733203..b898c4d 100644 --- a/server.js +++ b/server.js @@ -924,6 +924,7 @@ function buildDocsPage() { GETProjects POSTSaved Filters GETAlbums (Portfolios) + GETToolkits POSTProgress Boards POSTSignup Pages POSTUsers @@ -1410,6 +1411,55 @@ function buildDocsPage() { + +
+
Core resource
+

Toolkits

+
+

A Toolkit is a ready-made set of Surveys, Contact Forms, Impact Frameworks, metrics and tips on Explore Toolkits that an Organisation can add to its Projects in one go. The database calls them Collections; the API uses toolkits. Each has a Toolkit number (e.g. T14), a thumbnail for its Explore Toolkits card, a cover image for its page, and a setting for each image that lays a dark translucent layer over it.

+
+
+ ${endpointCard("GET", "/toolkits", "List Toolkits", true, [ + { name: "page", type: "integer", required: false, desc: "Page number (default 1)" }, + { name: "per_page", type: "integer", required: false, desc: "Records per page (default 10, max 200)" }, + { name: "last_synced_datetime", type: "string", required: false, desc: "ISO 8601 — return only Toolkits updated after this" } + ], [ + { code: "200", cls: "response-2xx", desc: "Paginated list of Toolkits" }, + { code: "401", cls: "response-4xx", desc: "Not authenticated" } + ], "The Toolkits on Explore Toolkits. With Marketing or Admin system access you also see listed Toolkits awaiting approval, as Site Overview › Manage Toolkits shows them.")} + ${endpointCard("GET", "/toolkits/{id}", "Get a Toolkit", true, [ + { name: "id", in: "path", type: "integer", required: true, desc: "Toolkit ID" } + ], [ + { code: "200", cls: "response-2xx", desc: "The Toolkit: toolkit_number, thumbnail_image_url, cover_image_url, darken_thumbnail_image, darken_cover_image and its page url" }, + { code: "401", cls: "response-4xx", desc: "Not authenticated" }, + { code: "404", cls: "response-4xx", desc: "Not found, or a Toolkit you can't see" } + ])} + ${endpointCard("PATCH", "/toolkits/{id}", "Change a Toolkit's number and image darkening", true, [ + { name: "id", in: "path", type: "integer", required: true, desc: "Toolkit ID" }, + { name: "toolkit_number", type: "string", required: false, desc: "The Toolkit's number, e.g. T14; null clears it" }, + { name: "darken_thumbnail_image", type: "boolean", required: false, desc: "Darken the thumbnail on Explore Toolkits" }, + { name: "darken_cover_image", type: "boolean", required: false, desc: "Darken the cover image on the Toolkit's page" } + ], [ + { code: "200", cls: "response-2xx", desc: "The Toolkit" }, + { code: "401", cls: "response-4xx", desc: "Not authenticated" }, + { code: "403", cls: "response-4xx", desc: "You can see the Toolkit but not edit it" }, + { code: "404", cls: "response-4xx", desc: "Not found, or a Toolkit you can't see" }, + { code: "422", cls: "response-4xx", desc: "{errors: [...]}" } + ], "As the Create/Edit Collection page does. Only the fields sent change. You must be able to edit the Toolkit: its owner, an editor of its Organisation, or a user with Marketing or Admin system access.")} + ${endpointCard("PATCH", "/toolkits/{id}/image", "Replace a Toolkit's thumbnail or cover image", true, [ + { name: "id", in: "path", type: "integer", required: true, desc: "Toolkit ID" }, + { name: "kind", type: "string", required: true, desc: "thumbnail (Explore Toolkits card) or cover (top of the Toolkit's page)" }, + { name: "image", type: "file", required: true, desc: "A JPEG or PNG, sent as multipart/form-data" } + ], [ + { code: "200", cls: "response-2xx", desc: "The Toolkit, with its new image URL" }, + { code: "401", cls: "response-4xx", desc: "Not authenticated" }, + { code: "403", cls: "response-4xx", desc: "Needs Marketing or Admin system access" }, + { code: "404", cls: "response-4xx", desc: "Not found, or a Toolkit you can't see" }, + { code: "422", cls: "response-4xx", desc: "{errors: [...]}, e.g. an unknown kind or a file that isn't an image" } + ], "As Replace does on Site Overview › Manage Toolkits.")} +
+
+
Core resource