openapi: "3.0.2" info: title: API version: "1.0" servers: - url: http://localhost/api tags: - name: auth description: Authentication microservice - name: users description: User microservice - name: booking description: Booking microservice - name: payments description: Payments microservice - name: status description: status microservice - name: facility description: facility microservice paths: /auth/login: post: tags: - auth description: "Logs a user into the system, returning a JWT if successful." requestBody: $ref: "#/components/requestBodies/Credentials" responses: "200": $ref: "#/components/responses/JWT" /auth/logout: post: tags: - auth description: "Logs a user out of the system, invalidating their JWT" security: - JWT: [] responses: "200": description: "OK" content: application/json: schema: type: object properties: success: type: boolean description: If the operation was successful /auth/register: post: tags: - auth description: "Registers a user into the system, returning a JWT if successful." requestBody: $ref: "#/components/requestBodies/Credentials" responses: "200": $ref: "#/components/responses/JWT" /auth/password-reset: put: tags: - auth description: "Resets a user's password." requestBody: $ref: "#/components/requestBodies/PasswordReset" responses: "200": description: "OK" content: application/json: schema: type: object properties: success: type: boolean description: If the operation was successful /auth/token: post: tags: - auth description: "Refreshes a JWT" security: - JWT: [] requestBody: $ref: "#/components/requestBodies/RefreshToken" responses: "200": $ref: "#/components/responses/JWT" /auth/session: get: tags: - auth description: "Validates a JWT, returning it's contents if valid" security: - JWT: [] responses: "200": $ref: "#/components/responses/DecodedJWT" /auth/users: get: tags: - auth description: "Returns all users in the auth service (paginated)" security: - JWT: [] parameters: - name: pageIndex in: query schema: type: number minimum: 0 exclusiveMinimum: true required: false example: 0 - name: limit in: query schema: type: number minimum: 0 required: false example: 20 - name: role in: query schema: $ref: "#/components/schemas/UserRole" required: false example: "USER" responses: "200": description: "OK" content: application/json: schema: type: object properties: success: type: boolean description: If the operation was successful data: type: array items: $ref: "#/components/schemas/AuthUserData" /auth/users/{userId}: get: tags: - auth description: "Returns a user in the auth service" security: - JWT: [] parameters: - name: userId in: path schema: type: number minimum: 0 exclusiveMinimum: true required: true example: 0 responses: "200": description: "OK" content: application/json: schema: type: object properties: success: type: boolean description: If the operation was successful data: $ref: "#/components/schemas/AuthUserData" patch: tags: - auth description: "Updates a user in the auth service" security: - JWT: [] parameters: - name: userId in: path schema: type: number minimum: 0 exclusiveMinimum: true required: true example: 0 requestBody: content: application/json: schema: type: object properties: role: $ref: "#/components/schemas/UserRole" responses: "200": description: "OK" content: application/json: schema: type: object properties: success: type: boolean description: If the operation was successful data: $ref: "#/components/schemas/AuthUserData" /auth/health: get: tags: - auth description: "Returns the health of the auth service" responses: "200": $ref: "#/components/responses/HealthCheck" /payments/checkout-session: post: tags: - payments description: Generates checkout sessions for products in stripe requestBody: description: Gets the data needed for checkout required: true content: application/json: schema: type: array items: type: object properties: type: type: string description: The type of product purchased example: session data: type: object description: Additional data associated with the product oneOf: - properties: eventId: type: integer description: The ID of the event example: 1 userId: type: integer description: The ID of the user example: 1 starts: type: string format: date-time description: The start time of the event example: "2022-01-01T00:00:00Z" required: - userId - eventId - starts - properties: url: type: string format: url description: The page to return to following checkout (url is only needed for success/cancel objects) example: http://successful/checkout/url required: - url required: - type - data responses: "200": description: Successful operation on checkout content: application/json: schema: type: object properties: checkout: type: string format: url example: http://successful/checkout description: Url for the successful checkout session "401": description: Missing authorization header content: application/json: schema: type: object properties: message: type: string example: "Missing authorization header" description: Returns meaningful message for this case "504": description: Request timed out content: application/json: schema: type: object properties: error: type: string example: "The request timed out" description: Returns meaningful message for this case "500": description: An error occured during request content: application/json: schema: type: object properties: error: type: string example: "An error occured during request" description: Returns meaningful message for this case /payments/change-price: post: tags: - payments description: "Allows the user with management authority to change price" requestBody: required: true content: application/json: schema: type: object properties: new_price: type: number description: The new price for the product example: 13.99 product_name: type: string description: The name of the product to be changed example: "session" responses: "200": description: Successful operation returns a message content: application/json: schema: type: object properties: message: type: string example: "Discount amount changed successfully" "500": description: Stripe error occured content: application/json: schema: type: object properties: error: type: string example: "A stripe error has occured" /payments/webhook: post: tags: - payments description: "Provides purchased products to user after successful payment" requestBody: content: application/json: schema: type: object responses: "200": description: Webhook processed successfully content: application/json: schema: type: object properties: response: type: string example: "" "400": description: Invalid request or invalid payload content: application/json: schema: type: object properties: message: type: string example: "An error occured with the transaction" "401": description: Error for signature missing or invalid signature content: application/json: schema: type: object properties: message: type: string example: "Signature missing" /payments/purchased-products/{userID}: get: parameters: - name: userID in: path schema: type: number required: true example: 6 tags: - payments description: "Retrieves all purchased products for a given user" responses: "200": description: Returns the purchased products for the given user content: application/json: schema: type: array items: type: object properties: product_id: type: integer example: 1 product_type: type: string example: "session" purchase_date: type: string format: date-time example: "2022-01-01T00:00:00Z" expiry_date: type: string format: date-time example: "2022-01-01T00:00:00Z" receipt_pdf: type: string format: Url example: http://successful/pdf/downloadlink "400": description: Missing authorization token content: application/json: schema: type: object properties: message: type: string example: Missing authentication token description: Missing authentication token error message "401": description: Invalid authorization token content: application/json: schema: type: object properties: message: type: string example: "Invalid token" description: Invalid token error message "403": description: Called by a not authorized user content: application/json: schema: type: object properties: message: type: string example: "Access denied" description: Authorization denial /payments/get-prices/{product_type}: get: parameters: - name: product_type in: path schema: type: string required: true example: "session" tags: - payments description: "Returns pricing list for the chosen product type" responses: "200": description: Returns the pricing list for the given product type content: application/json: schema: type: array items: type: object properties: product_name: type: string description: The name of the product example: "Monthly subscription" product_price: type: integer description: The price of the products example: 15.00 "404": description: No prices found for the specified product type content: application/json: schema: type: object properties: error: type: string description: The error message for this Case example: "No prices found" /payments/discount/change/{amount}: get: parameters: - name: amount in: path schema: type: number required: true example: 0.9 tags: - payments description: "Enables a user with management authority to change the discount amount" responses: "200": description: Successful response content: application/json: schema: type: object properties: message: type: string example: "Discount amount changed successfully" "401": description: Authentication header missing content: application/json: schema: type: object properties: message: type: string example: "Missing authorization header" "403": description: The user does not have the authority content: application/json: schema: type: object properties: message: type: string example: "Access denied" "500": description: Stripe error occured content: application/json: schema: type: object properties: error: type: string example: "An error occured with stripe during the operation" /payments/sales/{product_type}: get: parameters: - name: product_type in: path schema: type: string required: true example: "session" description: The product type to get the sales for tags: - payments description: "Returns the sales of the past week as dictionaries for the specified product type" responses: "200": description: Sales data retrieved successfully content: application/json: schema: type: object properties: sales: type: array items: type: object properties: product_name: type: string example: "Monthly subscription" product_type: type: string example: "Subscription" units_sold: type: number example: 110 total_sales: type: number example: 2090.00 "401": description: Authorization header is missing content: application/json: schema: type: object properties: message: type: string example: "Authorization header is missing" "403": description: User does not have the necessary authority content: application/json: schema: type: object properties: message: type: string example: Access denied /payments/customer-portal/{user_id}: get: parameters: - name: user_id in: path schema: type: integer required: true example: 1 description: user ID which passed in as a parameter tags: - payments description: "Generates a stripe customer portal URL for the customer" responses: "200": description: Returns the customer portal Url content: application/json: schema: type: object properties: Portal: type: string description: Customer portal URL generated "400": description: Missing authorization token content: application/json: schema: type: object properties: message: type: string example: Missing authentication token description: Missing authentication token error message "401": description: Invalid authorization token content: application/json: schema: type: object properties: message: type: string example: "Invalid token" description: Invalid token error message "403": description: Called by a not authorized user content: application/json: schema: type: object properties: message: type: string example: "Access denied" description: Authorization denial "404": description: Case where the customer portal was not generated content: application/json: schema: type: object properties: message: type: string example: "Could not generate customer portal URL" description: Error message in case the customer portal could not be generated /payments/cancel-membership/{user_id}: get: description: "Cancels existing membership for the given user" parameters: - name: user_id required: true in: path schema: type: integer tags: - payments requestBody: description: JWT token used for authentication required: true content: application/json: schema: type: object properties: Authorization: type: string description: "JWT token received as parameter" responses: "200": description: Successful operation content: application/json: schema: type: object properties: response: type: string example: "200" "401": description: Missing authorization header content: application/json: schema: type: object properties: message: type: string example: "Missing authorization header" "403": description: Access is denied content: application/json: schema: type: object properties: message: type: string example: "Access denied" "404": description: User is not found content: application/json: schema: type: object properties: message: type: string example: "User not found" /payments/refund/{booking_id}: get: description: Endpoint to process a booking parameters: - name: booking_id in: path schema: type: number required: true description: Booking ID to be refunded tags: - payments responses: "200": description: Refund processed successfully content: application/json: schema: type: object properties: message: type: string description: Successful refund message example: Refund processed successfully. "400": description: Failed to process refund content: application/json: schema: type: object properties: error: type: string description: Error message example: There was an error refunding your booking. "404": description: Booking not found for the given booking id content: application/json: schema: type: object properties: error: type: string description: Error message example: Purchase not found. /payments/receipt/{booking_id}: get: description: Gets the download link for the receipt of specified booking parameters: - name: booking_id in: path schema: type: number required: true tags: - payments responses: "200": description: The download link for the receipt content: application/json: schema: type: object properties: receipt: type: string format: Url description: URL for downloading the receipt example: http://successful/receipt/link "404": description: The booking ID was not found or no receipt available content: application/json: schema: type: object properties: error: type: string description: URL for downloading the receipt example: Purchase not found /payments/health: get: tags: - payments description: "Returns the health of the payments service" responses: "200": $ref: "#/components/responses/HealthCheck" /status/report: get: tags: - status description: "Returns the status report of the system" responses: "200": $ref: "#/components/responses/ServiceStatusReport" /status/health: get: tags: - status description: "Returns the health of the status service" responses: "200": $ref: "#/components/responses/HealthCheck" /users/health: get: tags: - users description: "Returns the health of the users service" summary: "Returns the health of the users service" responses: "200": $ref: "#/components/responses/HealthCheck" /users/{id}/viewFullRecord: get: tags: - users description: "Returns the record in database for a specified user. Requires matching ID in JWT and path, or admin role or employee role." summary: "Returns full record of a user" responses: "200": $ref: "#/components/responses/UserReturned" "500": $ref: "#/components/responses/NotFound" "400": $ref: "#/components/responses/BadRequest" parameters: - name: "id" in: "path" description: "ID of user to view" schema: type: integer required: true /users/{id}/updateFirstName: put: tags: - users description: "Updates the first name of a specified user. Requires matching ID in JWT and path, or admin role or employee role." summary: "Updates first name of a user" responses: "200": $ref: "#/components/responses/UpdatedUser" "500": $ref: "#/components/responses/NotFound" "400": $ref: "#/components/responses/BadRequest" parameters: - name: id in: "path" description: "ID of user to update" schema: type: integer required: true - name: "firstName" in: "header" description: "First name of user to update" schema: type: string required: true /users/{id}/updateSurname: put: tags: - users description: "Updates the surname of a specified user. Requires matching ID in JWT and path, or admin role or employee role." summary: "Updates surname of a user" responses: "200": $ref: "#/components/responses/UpdatedUser" "500": $ref: "#/components/responses/NotFound" "400": $ref: "#/components/responses/BadRequest" parameters: - name: id in: "path" description: "ID of user to update" schema: type: integer required: true - name: "surname" in: "header" description: "Surname of user to update" schema: type: string required: true /users/{id}/updatePaymentID: put: tags: - users description: "Updates the Payment ID of a specified user. Requires matching ID in JWT and path, or admin role or employee role." summary: "Updates payment ID of a user" responses: "200": $ref: "#/components/responses/UpdatedUser" "500": $ref: "#/components/responses/NotFound" "400": $ref: "#/components/responses/BadRequest" parameters: - name: id in: "path" description: "ID of user to update" schema: type: integer required: true - name: "paymentID" in: "header" description: "Payment ID of user to update" schema: type: integer required: true /users/{id}/updateMembership: put: tags: - users description: "Updates the Membership of a specified user. Requires matching ID in JWT and path, or admin role or employee role." summary: "Updates membership of a user" responses: "200": $ref: "#/components/responses/UpdatedUser" "500": $ref: "#/components/responses/InternalServerError" "400": $ref: "#/components/responses/BadRequest" parameters: - name: id in: "path" description: "ID of user to update" schema: type: integer required: true - name: "membership" in: "header" description: "Membership of user to update" schema: type: string required: true /users/testing: get: tags: - users description: "Returns the values of the users microservice used for testing and feature showcase" summary: "Experimental endpoint for testing and feature showcase" responses: "200": $ref: "#/components/responses/UpdatedUser" parameters: - name: id in: "header" description: "ID of user to view" schema: type: integer required: true - name: "firstName" in: "header" description: "First name of user to view" schema: type: string required: true - name: "surname" in: "header" description: "Surname of user to view" required: true schema: type: string - name: "paymentID" in: "header" description: "Payment ID of user to view" required: true schema: type: string - name: "membership" in: "header" description: "Membership of user to view" required: true schema: type: string /users/createUser: post: tags: - users description: "Creates a new users in the users database. Requires matching ID in JWT and path, or admin role or employee role." summary: "Creates a new user" responses: "200": $ref: "#/components/responses/UserCreated" "500": $ref: "#/components/responses/InternalServerError" "400": $ref: "#/components/responses/BadRequest" parameters: - name: id in: "header" description: "ID of user to create" required: true schema: type: integer - name: "firstName" in: "header" description: "First name of user to create" required: true schema: type: string - name: "surname" in: "header" description: "Surname of user to create" required: true schema: type: string /users/{id}/deleteUser: delete: tags: - users description: "Delete an existing user in the users database. Requires matching ID in JWT and path, or admin role or employee role." summary: "Delete a user" responses: "200": $ref: "#/components/responses/UserDeleted" "500": $ref: "#/components/responses/InternalServerError" "400": $ref: "#/components/responses/BadRequest" parameters: - name: id in: "path" description: "ID of user to delete" required: true schema: type: string /booking/bookings: get: tags: - booking summary: Returns all bookings description: Returns all the bookings operationId: getBookings parameters: - in: query name: limit schema: type: integer maximum: 256 minimum: 1 required: false example: 10 - in: query name: page schema: type: integer minimum: 1 required: false example: 1 - in: query name: user schema: type: integer minimum: 1 required: false example: 1 responses: "200": description: Successful operation returns the array of bookings content: application/json: schema: type: object properties: status: type: string example: "OK" description: Whether the operation was a success or whether there were any errors bookings: type: array items: $ref: "#/components/schemas/Booking" metadata: $ref: "#/components/schemas/BookingPagination" "400": description: Invalid input post: tags: - booking summary: Add a new booking description: Add a new booking operationId: addBooking requestBody: description: Create a new booking required: true content: application/json: schema: type: object properties: userId: type: integer description: The user the booking relates to eventId: type: integer description: The event that the booking relates to starts: type: string description: the start time of the booking examples: example: summary: Example value: userId: 1 eventId: 1 starts: "2023-03-02T10:00:00.000Z" responses: "200": description: Successful operation returns the new booking content: application/json: schema: type: object properties: status: type: string example: "OK" description: Whether the operation was a success or whether there were any errors booking: $ref: "#/components/schemas/Booking" "400": description: Invalid input /booking/bookings/{bookingId}: get: tags: - booking summary: Returns a booking with the specified ID description: Returns a booking with the specified ID operationId: getBookingById parameters: - in: path name: bookingId schema: type: integer required: true example: 1 responses: "200": description: Successful operation returns the booking content: application/json: schema: type: object properties: status: type: string example: "OK" description: Whether the operation was a success or whether there were any errors booking: $ref: "#/components/schemas/Booking" "400": description: Invalid input put: tags: - booking summary: Updates a booking with the specified ID description: Updates a booking with the specified ID operationId: updateBookingById parameters: - in: path name: bookingId schema: type: integer required: true example: 1 requestBody: description: update a booking required: true content: application/json: schema: type: object properties: userId: type: integer description: The user the booking relates to eventId: type: integer description: The event that the booking relates to starts: type: string description: the start time of the booking examples: example: summary: Example value: userId: 1 eventId: 1 starts: "2023-03-02T10:00:00.000Z" responses: "200": description: Successful operation returns the updated booking content: application/json: schema: type: object properties: status: type: string example: "OK" description: Whether the operation was a success or whether there were any errors booking: $ref: "#/components/schemas/Booking" "400": description: Invalid input delete: tags: - booking summary: Deletes a booking with the specified ID description: Deletes a booking with the specified ID operationId: deleteBookingById parameters: - in: path name: bookingId schema: type: integer required: true example: 1 responses: "200": description: Successful operation returns the deleted booking content: application/json: schema: type: object properties: status: type: string example: "OK" description: Whether the operation was a success or whether there were any errors booking: $ref: "#/components/schemas/Booking" "400": description: Invalid input /booking/bookings/availability: get: tags: - booking summary: Returns possible bookings description: Returns an array of possible bookings depending on supplied parameters operationId: getAvailableBookings parameters: - in: query name: limit description: Max integer of bookings to return in one query schema: type: integer maximum: 256 minimum: 1 required: false example: 10 - in: query name: page description: Page of results to return schema: type: integer minimum: 1 required: false example: 1 - in: query name: start description: Start timestamp in milliseconds schema: type: integer minimum: 1 maximum: 2147483647 required: false example: 10 - in: query name: end description: End timestamp in milliseconds schema: type: integer minimum: 1 maximum: 2147483647 required: false example: 1 - in: query name: activity description: Activity id to filter by schema: type: integer maximum: 256 minimum: 1 required: false example: 10 - in: query name: facility description: Facility id to filter by schema: type: integer minimum: 1 required: false example: 1 responses: "200": description: Successful operation returns the booking content: application/json: schema: type: object properties: status: type: string example: "OK" description: Whether the operation was a success or whether there were any errors availableBookings: type: array items: $ref: "#/components/schemas/PossibleBooking" metadata: type: object properties: count: type: integer example: 1 "400": description: Invalid input /booking/bookings/book: post: tags: - booking summary: The method called to book a booking for a user description: Returns the booking if successful operationId: bookBooking requestBody: description: book a booking required: true content: application/json: schema: type: object properties: user: type: integer description: The event that the booking relates to event: type: integer description: The event that the booking relates to starts: type: string description: the start time of the booking examples: example: summary: Example value: userId: 1 eventId: 1 starts: "2023-03-02T10:00:00.000Z" responses: "200": description: Successful operation returns the booking content: application/json: schema: type: object properties: status: type: string example: "OK" description: Whether the operation was a success or whether there were any errors booking: type: array items: $ref: "#/components/schemas/Booking" "400": description: Invalid input /booking/events: get: tags: - booking summary: Returns all events description: Returns all the events operationId: getEvents responses: "200": description: Successful operation returns the array of events content: application/json: schema: type: object properties: status: type: string example: "OK" description: Whether the operation was a success or whether there were any errors events: type: array items: $ref: "#/components/schemas/Event" "400": description: Invalid input post: tags: - booking summary: Add a new event description: Add a new event operationId: addevent requestBody: description: Create a new event required: true content: application/json: schema: type: object properties: name: type: string description: The user the event relates to activityId: type: integer description: The event that the event relates to day: type: integer description: The transaction linked with this event time: type: integer description: the start time of the event duration: type: number description: the length of time of the event in minutes type: type: string enum: ["OPEN_USE", "TEAM_EVENT", "SESSION"] examples: example: summary: Example value: name: "Event name" activityId: 1 day: 1 time: 480 duration: 60 type: "OPEN_USE" responses: "200": description: Successful operation returns the new event content: application/json: schema: type: object properties: status: type: string example: "OK" description: Whether the operation was a success or whether there were any errors event: $ref: "#/components/schemas/Event" "400": description: Invalid input /facilities/facilities: get: tags: - facility summary: Returns all facilities description: Returns all the facilities operationId: get_facilities parameters: - in: query name: limit schema: type: number required: false example: 10 - in: query name: page schema: type: number required: false example: 1 responses: "200": description: Successful operation returns the array of facilities content: application/json: schema: type: object properties: facilities: type: array items: $ref: "#/components/schemas/Facility" post: tags: - facility summary: Add a new facility description: Add a new facility. Requires "admin" role in auth token to access. operationId: add_facility requestBody: description: Create a new facility required: true content: application/json: schema: type: object properties: name: type: string description: The name of the new facility capacity: type: number description: The capacity of the new facility examples: example: summary: Example value: name: "Football Pitch" capacity: 30 description: "A football pitch" responses: "200": description: Successful operation returns the new facility content: application/json: schema: $ref: "#/components/schemas/Facility" /facilities/facilities/{facility_id}: get: tags: - facility summary: Returns a facility with the specified ID description: Returns a facility with the specified ID operationId: get_facility parameters: - in: path name: facility_id schema: type: number required: true example: 1 responses: "200": description: Successful operation returns the facility content: application/json: schema: type: object properties: status: type: string example: "ok" description: Whether the operation was a success or whether there were any errors facility: $ref: "#/components/schemas/Facility" put: tags: - facility summary: Updates the facility with the specified ID. Requires "admin" role in auth token. description: Updates the facility with the specified ID operationId: update_facility parameters: - in: path name: facility_id schema: type: number required: true example: 1 responses: "200": description: Successful operation returns the updated facility content: application/json: schema: type: object properties: status: type: string example: "ok" description: Whether the operation was a success or not message: type: string example: "facility updated" description: More detail on the result of the operation facility: $ref: "#/components/schemas/Facility" delete: tags: - facility summary: Deletes the facility with the specified ID. Requires "admin" role in auth token. description: Deletes the facility with the specified ID operationId: delete_facility parameters: - in: path name: facility_id schema: type: number required: true example: 1 responses: "200": description: Successful operation returns deleted facility content: application/json: schema: type: object properties: status: type: string example: "ok" description: Whether the operation was a success or not message: type: string example: "facility deleted" description: More detail on the result of the operation facility: $ref: "#/components/schemas/Facility" /facilities/times: get: tags: - facility summary: Returns all times description: Returns all times operationId: get_open_times parameters: - in: query name: limit schema: type: number required: false example: 10 - in: query name: page schema: type: number required: false example: 1 responses: "200": description: Successful operation returns the array of opening times content: application/json: schema: type: object properties: opening_times: type: array items: $ref: "#/components/schemas/OpenTime" post: tags: - facility summary: Add a new opening time. Requires "admin" role in auth token. description: Add a new opening time operationId: add_open_time requestBody: description: Create a new opening time required: true content: application/json: schema: type: object properties: day: type: string description: The day the opening time takes place opening_time: type: number description: The minutes after midnight the opening time takes place closing_time: type: number description: The minutes after midnight the closing time takes place facility_id: type: number description: The ID of the facility associated with this opening time examples: example: summary: Example value: day: "Monday" opening_time: 600 closing_time: 900 facility_id: 1 responses: "200": description: Successful operation returns the new opening time content: application/json: schema: $ref: "#/components/schemas/OpenTime" /facilities/times/{time_id}: get: tags: - facility summary: Returns the opening time with the specified ID description: Returns the opening time with the specified ID operationId: get_open_time parameters: - in: path name: time_id schema: type: number required: true example: 1 responses: "200": description: Successful operation returns the opening time content: application/json: schema: type: object properties: status: type: string example: "ok" description: Whether the operation was a success or whether there were any errors OpenTime: $ref: "#/components/schemas/OpenTime" put: tags: - facility summary: Updates the opening time with the specified ID. Requires "admin" role in auth token. description: Updates the opening time with the specified ID operationId: update_open_time parameters: - in: path name: time_id schema: type: number required: true example: 1 responses: "200": description: Successful operation returns the updated opening time content: application/json: schema: type: object properties: status: type: string example: "ok" description: Whether the operation was a success or not message: type: string example: "open time updated" description: More detail on the result of the operation OpenTime: $ref: "#/components/schemas/OpenTime" delete: tags: - facility summary: Deletes the opening time with the specified ID. Requires "admin" role in auth token. description: Deletes the opening time with the specified ID operationId: delete_open_time parameters: - in: path name: time_id schema: type: number required: true example: 1 responses: "200": description: Successful operation returns deleted opening time content: application/json: schema: type: object properties: status: type: string example: "ok" description: Whether the operation was a success or not message: type: string example: "opening time deleted" description: More detail on the result of the operation OpenTime: $ref: "#/components/schemas/OpenTime" /facilities/activities: get: tags: - facility summary: Returns all activities description: Returns all activities operationId: get_activities parameters: - in: query name: limit schema: type: number required: false example: 10 - in: query name: page schema: type: number required: false example: 1 responses: "200": description: Successful operation returns the array of activities content: application/json: schema: type: object properties: activities: type: array items: $ref: "#/components/schemas/Activity" post: tags: - facility summary: Add a new activity. Requires "admin" role in auth token. description: Add a new activity operationId: add_activity requestBody: description: Create a new activity required: true content: application/json: schema: type: object properties: name: type: string description: The name of the activity duration: type: number description: The length of the activity capacity: type: number description: The amount of people that can take part in the activity facility_id: type: number description: The ID of the facility associated with this activity examples: example: summary: Example value: name: "Football Match" duration: 90 capacity: 30 facility_id: 1 responses: "200": description: Successful operation returns the new activity content: application/json: schema: $ref: "#/components/schemas/Activity" /facilities/activities/{activity_id}: get: tags: - facility summary: Returns the activity with the specified ID description: Returns the activity with the specified ID operationId: get_activity parameters: - in: path name: activity_id schema: type: number required: true example: 1 responses: "200": description: Successful operation returns the activity content: application/json: schema: type: object properties: status: type: string example: "ok" description: Whether the operation was a success or whether there were any errors activity: $ref: "#/components/schemas/Activity" put: tags: - facility summary: Updates the activity with the specified ID. Requires "admin" role in auth token. description: Updates the activity with the specified ID operationId: update_activity parameters: - in: path name: activity_id schema: type: number required: true example: 1 responses: "200": description: Successful operation returns the updated activity content: application/json: schema: type: object properties: status: type: string example: "ok" description: Whether the operation was a success or not message: type: string example: "activity updated" description: More detail on the result of the operation activity: $ref: "#/components/schemas/Activity" delete: tags: - facility summary: Deletes the activity with the specified ID. Requires "admin" role in auth token. description: Deletes the activity with the specified ID operationId: delete_activity parameters: - in: path name: activity_id schema: type: number required: true example: 1 responses: "200": description: Successful operation returns deleted activity content: application/json: schema: type: object properties: status: type: string example: "ok" description: Whether the operation was a success or not message: type: string example: "activity deleted" description: More detail on the result of the operation activity: $ref: "#/components/schemas/Activity" /facilities/health: get: tags: - facility summary: Returns the status of the microservice description: Returns status of the microservice operationId: get_health responses: "200": description: Returns healthy or degraded based on the connection to the database. content: application/json: schema: type: object properties: status: type: string example: "healthy" description: Returns healthy or degraded based on the status of connecting to the database. components: securitySchemes: JWT: type: http scheme: bearer bearerFormat: JWT schemas: UserRole: type: string description: User's role enum: - USER - EMPLOYEE - ADMIN AuthUserData: type: object properties: id: type: number description: User's ID email: type: string description: User's Email role: $ref: "#/components/schemas/UserRole" createdAt: type: string description: User's registration date updatedAt: type: string description: User's last update date tokenAndRefreshToken: type: object properties: token: type: string refreshToken: type: string DecodedJWT: type: object properties: user: type: object properties: email: type: string description: User Email role: type: string description: User's role type: type: string enum: [access] iat: type: number description: Issued At exp: type: number description: Expires At iss: type: string enum: [auth] description: Issuer sub: type: number description: User Unique ID jti: type: string description: JWT ID User: type: object properties: id: type: number description: User ID firstName: type: string description: User's first name lastName: type: string description: User's last name paymentID: type: number description: User's payment ID membership: type: string description: User's membership ID Booking: type: object properties: id: type: integer description: Booking ID example: 1 userId: type: integer description: User ID example: 1 eventId: type: integer description: Event ID example: 1 starts: type: string description: Start time of the booking example: "2023-03-02T10:00:00.000Z" created: type: string description: When the booking was created example: "2023-03-02T10:00:00.000Z" updated: type: string description: When the booking was last updated example: "2023-03-02T10:00:00.000Z" PossibleBooking: type: object properties: starts: type: string description: Start time of the booking example: "2023-03-02T10:00:00.000Z" duration: type: integer description: Length of the booking example: 60 event: type: object $ref: "#/components/schemas/Event" capacity: type: object properties: current: type: integer description: current number of bookings for current event example: 15 max: type: integer description: maximum number of bookings for the current event example: 30 BookingPagination: type: object properties: count: type: integer description: The number of elements example: 1 limit: type: integer description: The maximum number of elements to be returned in one query example: 25 page: type: integer description: The current page of results that has been returned example: 1 pageCount: type: integer description: The maximum number of pages for the results example: 1 Event: type: object properties: id: type: integer description: Event ID example: 1 name: type: string description: Name of the event example: 1 activityId: type: integer description: Activity ID example: 1 day: type: integer description: The Day with 0 being Monday and 6 being Sunday example: 1 time: type: integer description: Start time of the event as minutes since 00:00 example: 480 duration: type: integer description: Length of the booking in minutes example: 60 type: type: string enum: ["OPEN_USE", "TEAM_EVENT", "SESSION"] description: Type of event example: "OPEN_USE" Facility: type: object properties: id: type: number description: Facility ID example: 1 name: type: string description: Name of facility example: "Swimming Pool" capacity: type: number description: Capacity of facility example: 30 description: type: string description: A description of the facility example: "A swimming pool fitting 30 people" OpenTime: type: object properties: id: type: number description: OpenTime ID example: 1 day: type: string description: Day of the week that the time is associated with example: "Monday" opening_time: type: number description: The minutes after midnight at which a facility opens. example: 600 closing_time: type: number description: The minutes after midnight at which a facility closes. example: 900 facility_id: type: number description: Foreign key to facility associated with this opening. example: 1 Activity: type: object properties: id: type: number description: Activity ID example: 1 name: type: string description: Name of activity example: "Swimming lesson" duration: type: number description: Duration of the activity in minutes example: 60 capacity: type: number description: Amount of people the activity can account for example: 30 facility_id: type: number description: Foreign key to facility associated with this activity example: 1 requestBodies: Credentials: description: "User's credentials (email password)" required: true content: application/json: schema: type: object properties: email: type: string description: "The user's email" password: type: string description: "The user's password" rememberMe: type: boolean description: "If the refresh token should be long lived" PasswordReset: description: "Password reset (email old new password)" required: true content: application/json: schema: type: object properties: email: type: string description: "The user's email" password: type: string description: "The user's old password" newPassword: type: string description: "The user's new password" RefreshToken: description: "Refresh token" required: true content: application/json: schema: type: object properties: refreshToken: type: string responses: JWT: description: JSON Web Token content: application/json: schema: type: object properties: success: type: boolean description: If the operation was successful data: $ref: "#/components/schemas/tokenAndRefreshToken" DecodedJWT: description: JSON Web Token decoded contents content: application/json: schema: type: object properties: success: type: boolean description: If the operation was successful data: $ref: "#/components/schemas/DecodedJWT" HealthCheck: description: Health check successful content: application/json: schema: type: object properties: status: type: string description: "The health status of the service" enum: - "up" - "down" - "degraded" ServiceStatusReport: description: Status report of the system content: application/json: schema: type: array items: type: object properties: service: type: string description: "The id of the service" example: "auth" status: type: string description: "The status of the system" enum: - "up" - "down" - "degraded" timestamp: type: number description: "The milliseconds since epoch" example: 1680307200000 UpdatedUser: description: Updated user content: application/json: schema: type: object properties: status: type: string description: "The status of the operation" enum: - "OK" - "ERROR" InternalServerError: description: Internal server error content: application/json: schema: type: object properties: status: type: string description: "The status of the operation" enum: - "ERROR" NotFound: description: Not found content: application/json: schema: type: object properties: status: type: string description: "The status of the operation" enum: - "ERROR" BadRequest: description: Bad request content: application/json: schema: type: object properties: status: type: string description: "The status of the operation" enum: - "ERROR" UserCreated: description: User created content: application/json: schema: type: object properties: status: type: string description: "The status of the operation" enum: - "OK" - "ERROR" UserDeleted: description: User deleted content: application/json: schema: type: object properties: status: type: string description: "The status of the operation" enum: - "OK" - "ERROR" UserReturned: description: User returned content: application/json: schema: type: object properties: status: type: string description: "The status of the operation" enum: - "OK" - "ERROR" user: $ref: "#/components/schemas/User"