diff --git a/backend/api.yaml b/backend/api.yaml index 0e60bbd3..d0684e4b 100644 --- a/backend/api.yaml +++ b/backend/api.yaml @@ -77,12 +77,8 @@ paths: application/json: schema: $ref: "#/components/schemas/User" - "401": - description: Not logged in - content: - application/json: - schema: - $ref: "#/components/schemas/NotLoggedIn" + "307": + $ref: "#/components/responses/NotLoggedIn" /user/name: patch: operationId: updateUserName @@ -108,12 +104,8 @@ paths: message: type: string example: Successfully updated name - "401": - description: Not logged in. - content: - application/json: - schema: - $ref: "#/components/schemas/NotLoggedIn" + "307": + $ref: "#/components/responses/NotLoggedIn" /user/pronouns: patch: operationId: updateUserPronouns @@ -139,12 +131,8 @@ paths: message: type: string example: Successfully updated pronouns - "401": - description: Not logged in. - content: - application/json: - schema: - $ref: "#/components/schemas/NotLoggedIn" + "307": + $ref: "#/components/responses/NotLoggedIn" /user/gender: patch: operationId: updateUserGender @@ -170,12 +158,8 @@ paths: message: type: string example: Successfully updated gender - "401": - description: Not logged in. - content: - application/json: - schema: - $ref: "#/components/schemas/NotLoggedIn" + "307": + $ref: "#/components/responses/NotLoggedIn" /user/zid: patch: operationId: updateUserZid @@ -201,12 +185,8 @@ paths: message: type: string example: Successfully updated zID - "401": - description: Not logged in. - content: - application/json: - schema: - $ref: "#/components/schemas/NotLoggedIn" + "307": + $ref: "#/components/responses/NotLoggedIn" /user/degree: patch: operationId: updateUserDegree @@ -235,12 +215,8 @@ paths: message: type: string example: Successfully updated email - "401": - description: Not logged in. - content: - application/json: - schema: - $ref: "#/components/schemas/NotLoggedIn" + "307": + $ref: "#/components/responses/NotLoggedIn" /user/applications: get: operationId: getUserApplications @@ -258,12 +234,8 @@ paths: type: array items: $ref: "#/components/schemas/ApplicationDetails" - "401": - description: Not logged in. - content: - application/json: - schema: - $ref: "#/components/schemas/NotLoggedIn" + "307": + $ref: "#/components/responses/NotLoggedIn" /organisation: post: @@ -305,6 +277,8 @@ paths: application/json: schema: $ref: "#/components/schemas/Unauthorized" + "307": + $ref: "#/components/responses/NotLoggedIn" /organisation/slug_check: post: operationId: checkOrganisationSlugAvailability @@ -336,6 +310,8 @@ paths: application/json: schema: $ref: "#/components/schemas/BadRequest" + "307": + $ref: "#/components/responses/NotLoggedIn" /organisation/{id}: get: operationId: getOrganisationById @@ -347,7 +323,7 @@ paths: schema: type: integer format: int64 - description: Returns info about specified organisation. + description: Returns info about specified organisation tags: - Organisation responses: @@ -356,29 +332,9 @@ paths: content: application/json: schema: - properties: - id: - type: integer - format: int64 - example: 6996987893965262849 - name: - type: string - example: UNSW Software Development Society - logo: - type: string - example: "76718252-2a13-4de2-bc07-f977c75dc52b" - created_at: - type: string - example: 2024-02-10T18:25:43.511Z - "401": - description: Not logged in. - content: - application/json: - schema: - properties: - error: - type: string - example: Not logged in. + $ref: "#/components/schemas/OrganisationDetails" + "307": + $ref: "#/components/responses/NotLoggedIn" delete: operationId: deleteOrganisationById parameters: @@ -389,7 +345,7 @@ paths: schema: type: integer format: int64 - description: Deletes specified organisation. + description: Deletes specified organisation tags: - Organisation responses: @@ -401,28 +357,111 @@ paths: properties: message: type: string - example: Successfully deleted organisation. - "401": - description: Not logged in. + example: Successfully deleted organisation + "403": + description: User is not a SuperUser + content: + application/json: + schema: + $ref: "#/components/schemas/Unauthorized" + "307": + $ref: "#/components/responses/NotLoggedIn" + /organisation/slug/{slug}: + get: + operationId: getOrganisationBySlug + parameters: + - name: slug + in: path + description: Organisation slug + required: true + schema: + type: string + description: Returns info about specified organisation + tags: + - Organisation + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/OrganisationDetails" + "307": + $ref: "#/components/responses/NotLoggedIn" + /organisation/{id}/campaign: + post: + operationId: createCampaign + parameters: + - name: id + in: path + description: Organisation ID + required: true + schema: + type: integer + format: int64 + description: Create a new campaign inside specified organisation + tags: + - Organisation + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/NewCampaign" + responses: + "200": + description: OK content: application/json: schema: properties: - error: + message: type: string - example: Not logged in. - "403": - description: User is not a super user. + example: Successfully created campaign + "401": + $ref: "#/components/responses/NotOrganisationAdmin" + "307": + $ref: "#/components/responses/NotLoggedIn" + /organisation/{id}/campaign/slug_check: + post: + operationId: checkCampaignSlugAvailability + parameters: + - name: id + in: path + description: Organisation ID + required: true + schema: + type: integer + format: int64 + description: Checks availability of campaign slug in specified organisation + tags: + - Organisation + requestBody: + required: true + content: + application/json: + schema: + properties: + slug: + type: string + example: 2024-subcom-recruitment + responses: + "200": + description: OK content: application/json: schema: properties: - error: + message: type: string - example: Unauthorized + example: Campaign slug is available + "401": + $ref: "#/components/responses/NotOrganisationAdmin" + "307": + $ref: "#/components/responses/NotLoggedIn" /organisation/{id}/campaigns: get: - operationId: getOrganisationCampaignsById + operationId: getAllOrganisationCampaigns parameters: - name: id in: path @@ -431,7 +470,7 @@ paths: schema: type: integer format: int64 - description: Returns active campaigns for specified organisation. + description: Returns all (active & ended) campaigns for specified organisation. However, ended campaigns cannot have new applications tags: - Organisation responses: @@ -445,16 +484,68 @@ paths: type: array items: $ref: "#/components/schemas/OrganisationCampaign" - "401": - description: Not logged in. + "307": + $ref: "#/components/responses/NotLoggedIn" + /organisation/{id}/email_template: + post: + operationId: createEmailTemplate + parameters: + - name: id + in: path + description: Organisation ID + required: true + schema: + type: integer + format: int64 + description: Create a new email template within the organisation + tags: + - Organisation + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/NewEmailTemplate" + responses: + "200": + description: OK content: application/json: schema: properties: - error: + message: type: string - example: Not logged in. - + example: Successfully created email template + "401": + $ref: "#/components/responses/NotOrganisationAdmin" + "307": + $ref: "#/components/responses/NotLoggedIn" + /organisation/{id}/email_templates: + get: + operationId: getAllOrganisationEmailTemplates + parameters: + - name: id + in: path + description: Organisation ID + required: true + schema: + type: integer + format: int64 + description: Get all email templates for specified organisation + tags: + - Organisation + responses: + "200": + description: OK + content: + application/json: + schema: + type: array + items: + $ref: "#/components/schemas/EmailTemplate" + "401": + $ref: "#/components/responses/NotOrganisationAdmin" + "307": + $ref: "#/components/responses/NotLoggedIn" /organisation/{id}/logo: patch: operationId: updateOrganisationLogoById @@ -466,7 +557,7 @@ paths: schema: type: integer format: int64 - description: Updates logo for specified organistion. + description: Update logo for specified organistion. Returns a PUT url to upload new image to tags: - Organisation responses: @@ -478,27 +569,12 @@ paths: properties: upload_url: type: string - description: Presigned S3 url to upload file. - example: https://www.youtube.com/watch?v=dQw4w9WgXcQ + description: Presigned S3 url to upload file + example: https://presignedurldemo.s3.eu-west-2.amazonaws.com/6996987893965262849/2d19617b-46fd-4927-9f53-77d69232ba5d "401": - description: Not logged in. - content: - application/json: - schema: - properties: - error: - type: string - example: Not logged in. - "403": - description: User is not an organisation admin. - content: - application/json: - schema: - properties: - error: - type: string - example: Unauthorized - + $ref: "#/components/responses/NotOrganisationAdmin" + "307": + $ref: "#/components/responses/NotLoggedIn" /organisation/{id}/member: get: operationId: getOrganisationMembersById @@ -808,58 +884,6 @@ paths: error: type: string example: Unauthorized - - /organisation/{id}/campaign: - post: - operationId: createCampaign - parameters: - - name: id - in: path - description: Organisation ID - required: true - schema: - type: integer - format: int64 - description: Creates a new campaign inside specified organisation. - tags: - - Organisation - requestBody: - required: true - content: - application/json: - schema: - properties: - name: - type: string - example: 2024 Subcommittee Recruitment - description: - type: string - example: Are you excited to make a difference? - starts_at: - type: string - example: 2024-03-15T18:25:43.511Z - ends_at: - type: string - example: 2024-04-15T18:25:43.511Z - responses: - "200": - description: OK - content: - application/json: - schema: - properties: - message: - type: string - example: Successfully created campaign. - "403": - description: User is not an admin of specified organisation. - content: - application/json: - schema: - properties: - error: - type: string - example: Unauthorized /campaign: get: operationId: getAllCampaigns @@ -1066,7 +1090,7 @@ paths: upload_url: type: string description: Presigned S3 url to upload file. - example: https://www.youtube.com/watch?v=dQw4w9WgXcQ + example: https://presignedurldemo.s3.eu-west-2.amazonaws.com/6996987893965262849/2d19617b-46fd-4927-9f53-77d69232ba5d "401": description: Not logged in. content: @@ -1670,6 +1694,26 @@ components: - Rejected - Successful + OrganisationDetails: + type: object + properties: + id: + type: integer + format: int64 + example: 6996987893965262849 + slug: + type: string + example: devsoc-unsw + name: + type: string + example: UNSW Software Development Society + logo: + type: string + example: "76718252-2a13-4de2-bc07-f977c75dc52b" + created_at: + type: string + example: 2024-02-10T18:25:43.511Z + OrganisationCampaign: type: object properties: @@ -1677,6 +1721,9 @@ components: type: integer format: int64 example: 6996987893965262849 + slug: + type: string + example: 2024-subcom-recruitment name: type: string example: 2024 Subcommittee Recruitment @@ -1823,3 +1870,118 @@ components: type: integer format: int32 example: 1 + + NewCampaign: + type: object + properties: + name: + type: string + example: 2024 Subcommittee Recruitment + slug: + type: string + example: 2024-subcom-recruitment + description: + type: string + example: Are you excited to make a difference? + starts_at: + type: string + example: 2024-03-15T18:25:43.511Z + ends_at: + type: string + example: 2024-04-15T18:25:43.511Z + + Campaign: + type: object + properties: + id: + type: integer + format: int64 + example: 1541815603606036480 + slug: + type: string + example: 2024-subcom-recruitment + name: + type: string + example: 2024 Subcommittee Recruitment + organisation_id: + type: integer + format: int64 + example: 1541815603606036480 + organisation_name: + type: string + example: UNSW Software Development Society + cover_image: + type: string + format: uuid + example: 05ebad1e-8be4-40c3-9d36-140cac9a0075 + nullable: true + description: + type: string + example: Are you excited to make a difference? + nullable: true + starts_at: + type: string + example: 2024-03-15T18:25:43.511Z + ends_at: + type: string + example: 2024-04-15T18:25:43.511Z + created_at: + type: string + example: 2024-02-15T18:25:43.511Z + updated_at: + type: string + example: 2024-02-15T18:25:43.511Z + + EmailTemplate: + type: object + properties: + id: + type: integer + format: int64 + example: 1541815603606036480 + organisation_id: + type: integer + format: int64 + example: 1541815603606036480 + name: + type: string + example: Success Email + template_subject: + type: string + example: "[OUTCOME] {{campaign_name}} - {{role_name}}" + template_body: + type: string + example: "Hi {{name}}, you have been successful in your application for {{organisation_name}} {{role_name}}. Regards {{organisation_name}} Exec" + + NewEmailTemplate: + type: object + properties: + name: + type: string + example: Success Email + template_subject: + type: string + example: "[OUTCOME] {{campaign_name}} - {{role_name}}" + template_body: + type: string + example: "Hi {{name}}, you have been successful in your application for {{organisation_name}} {{role_name}}. Regards {{organisation_name}} Exec" + + responses: + NotLoggedIn: + description: Redirect to login + headers: + Location: + description: Login url + schema: + type: string + format: uri + + NotOrganisationAdmin: + description: User is not an organisation admin + content: + application/json: + schema: + properties: + error: + type: string + example: Unauthorized