From e41a32fb0f1e7d59c5d9a6fece4abced72f509ff Mon Sep 17 00:00:00 2001 From: pasha1coil Date: Wed, 30 Apr 2025 17:57:01 +0300 Subject: [PATCH] start new api2 omenapi added account to new openapi --- api/openapi2.yaml | 765 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 765 insertions(+) create mode 100644 api/openapi2.yaml diff --git a/api/openapi2.yaml b/api/openapi2.yaml new file mode 100644 index 0000000..d2e00e5 --- /dev/null +++ b/api/openapi2.yaml @@ -0,0 +1,765 @@ +openapi: 3.0.3 +info: + title: QUIZ service api + description: Title + version: 2.0.0 +paths: + /account/get: + get: + tags: [Account] + summary: Get the current account details + security: + - bearerAuth: [] + responses: + '200': + description: Successfully retrieved account details + content: + application/json: + schema: + $ref: '#/components/schemas/Account' + '401': + $ref: '#/components/responses/UnauthorizedError' + '404': + $ref: '#/components/responses/NotFoundError' + '500': + $ref: '#/components/responses/InternalServerError' + + /account/create: + post: + tags: [Account] + summary: Create a new account + security: + - bearerAuth: [] + responses: + '200': + description: Account created successfully + content: + application/json: + schema: + $ref: '#/components/schemas/Account' + '401': + $ref: '#/components/responses/UnauthorizedError' + '409': + $ref: '#/components/responses/ConflictError' + '500': + $ref: '#/components/responses/InternalServerError' + + /account/delete: + delete: + tags: [Account] + summary: Delete the current account + security: + - bearerAuth: [] + responses: + '200': + description: Account deleted successfully + content: + application/json: + schema: + type: object + properties: + accountId: + type: string + '401': + $ref: '#/components/responses/UnauthorizedError' + '500': + $ref: '#/components/responses/InternalServerError' + + /accounts: + get: + tags: [Account] + summary: Retrieve a list of accounts + security: + - bearerAuth: [] + parameters: + - name: limit + in: query + description: The number of accounts to return + required: false + schema: + type: integer + format: uint64 + - name: page + in: query + description: The page number of accounts to retrieve + required: false + schema: + type: integer + format: uint64 + responses: + '200': + description: Successfully retrieved list of accounts + content: + application/json: + schema: + type: object + properties: + count: + type: integer + format: uint64 + items: + type: array + items: + $ref: '#/components/schemas/Account' + '400': + $ref: '#/components/responses/BadRequestError' + '401': + $ref: '#/components/responses/UnauthorizedError' + '500': + $ref: '#/components/responses/InternalServerError' + + /privilege/{userId}: + get: + tags: [Account] + summary: Get privileges by user ID + parameters: + - name: userId + in: path + required: true + schema: + type: string + security: + - bearerAuth: [] + responses: + '200': + description: Successfully retrieved privileges for the user + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/ShortPrivilege' + '400': + $ref: '#/components/responses/BadRequestError' + '401': + $ref: '#/components/responses/UnauthorizedError' + '500': + $ref: '#/components/responses/InternalServerError' + + /account/{userId}: + delete: + tags: [Account] + summary: Delete account by user ID + parameters: + - name: userId + in: path + required: true + schema: + type: string + security: + - bearerAuth: [] + responses: + '200': + description: Successfully deleted the account + content: + application/json: + schema: + type: object + properties: + userId: + type: string + '400': + $ref: '#/components/responses/BadRequestError' + '401': + $ref: '#/components/responses/UnauthorizedError' + '500': + $ref: '#/components/responses/InternalServerError' + + /account/manualdone: + post: + tags: [Account] + summary: Manually mark an account as done + requestBody: + required: true + content: + application/json: + schema: + type: object + required: + - id + properties: + id: + type: string + description: User ID to mark as done + security: + - bearerAuth: [] + responses: + '200': + description: Account marked as done + '400': + $ref: '#/components/responses/BadRequestError' + '401': + $ref: '#/components/responses/UnauthorizedError' + '404': + $ref: '#/components/responses/NotFoundError' + '500': + $ref: '#/components/responses/InternalServerError' + + /account/leadtarget: + post: + tags: [Account] + summary: Add a lead target for sending client requests + requestBody: + required: true + content: + application/json: + schema: + type: object + required: + - type + - quizID + - target + properties: + type: + type: string + description: Type of target (mail, telegram, whatsapp) + enum: + - mail + - telegram + - whatsapp + quizID: + type: integer + format: int32 + description: The associated quiz ID (0 for general rules) + target: + type: string + description: The target address (email, channel ID, phone number) + name: + type: string + description: Name (e.g., for Telegram channel) + security: + - bearerAuth: [] + responses: + '200': + description: Lead target added successfully + '208': + $ref: '#/components/responses/AlreadyReportedError' + '400': + $ref: '#/components/responses/BadRequestError' + '401': + $ref: '#/components/responses/UnauthorizedError' + '404': + $ref: '#/components/responses/NotFoundError' + '500': + $ref: '#/components/responses/InternalServerError' + + put: + tags: [Account] + summary: Update a lead target + requestBody: + required: true + content: + application/json: + schema: + type: object + required: + - id + - target + properties: + id: + type: integer + format: int64 + description: Lead target ID (primary key) + target: + type: string + description: The target address (email, channel ID, phone number) + security: + - bearerAuth: [] + responses: + '200': + description: Lead target updated successfully + '400': + $ref: '#/components/responses/BadRequestError' + '401': + $ref: '#/components/responses/UnauthorizedError' + '404': + $ref: '#/components/responses/NotFoundError' + '500': + $ref: '#/components/responses/InternalServerError' + + /account/leadtarget/{id}: + delete: + tags: [Account] + summary: Delete a lead target by its ID + parameters: + - name: id + in: path + required: true + description: The ID of the lead target to delete + schema: + type: string + security: + - bearerAuth: [] + responses: + '200': + description: Lead target deleted successfully + '400': + $ref: '#/components/responses/BadRequestError' + '401': + $ref: '#/components/responses/UnauthorizedError' + '500': + $ref: '#/components/responses/InternalServerError' + + /account/leadtarget/{quizID}: + get: + tags: [Account] + summary: Get lead target by quiz ID + parameters: + - name: quizID + in: path + required: true + description: The quiz ID associated with the lead target + schema: + type: string + security: + - bearerAuth: [] + responses: + '200': + description: Successfully retrieved lead target by quiz ID + content: + application/json: + schema: + $ref: '#/components/schemas/LeadTarget' + '400': + $ref: '#/components/responses/BadRequestError' + '401': + $ref: '#/components/responses/UnauthorizedError' + '404': + $ref: '#/components/responses/NotFoundError' + '500': + $ref: '#/components/responses/InternalServerError' + + + /question/create: + post: + tags: [ Question ] + summary: Create a question + responses: + '200': + description: OK + '500': + description: Internal Server Error + + /question/getList: + post: + tags: [ Question ] + summary: Get list of questions + responses: + '200': + description: OK + '500': + description: Internal Server Error + + /question/edit: + patch: + tags: [ Question ] + summary: Edit a question + responses: + '200': + description: OK + '500': + description: Internal Server Error + + /question/copy: + post: + tags: [ Question ] + summary: Copy a question + responses: + '200': + description: OK + '500': + description: Internal Server Error + + /question/history: + post: + tags: [ Question ] + summary: Get question history + responses: + '200': + description: OK + '500': + description: Internal Server Error + + /question/delete: + delete: + tags: [ Question ] + summary: Delete a question + responses: + '200': + description: OK + '500': + description: Internal Server Error + + /quiz/create: + post: + tags: [ Quiz ] + summary: Create a quiz + responses: + '200': + description: OK + '500': + description: Internal Server Error + + /quiz/getList: + post: + tags: [ Quiz ] + summary: Get list of quizzes + responses: + '200': + description: OK + '500': + description: Internal Server Error + + /quiz/edit: + patch: + tags: [ Quiz ] + summary: Edit a quiz + responses: + '200': + description: OK + '500': + description: Internal Server Error + + /quiz/copy: + post: + tags: [ Quiz ] + summary: Copy a quiz + responses: + '200': + description: OK + '500': + description: Internal Server Error + + /quiz/history: + post: + tags: [ Quiz ] + summary: Get quiz history + responses: + '200': + description: OK + '500': + description: Internal Server Error + + /quiz/delete: + delete: + tags: [ Quiz ] + summary: Delete a quiz + responses: + '200': + description: OK + '500': + description: Internal Server Error + + /quiz/archive: + patch: + tags: [ Quiz ] + summary: Archive a quiz + responses: + '200': + description: OK + '500': + description: Internal Server Error + + /quiz/move: + post: + tags: [ Quiz ] + summary: Move a quiz + responses: + '200': + description: OK + '500': + description: Internal Server Error + + /quiz/template: + post: + tags: [ Quiz ] + summary: Copy quiz from template + responses: + '200': + description: OK + '500': + description: Internal Server Error + + /results/getResults/{quizId}: + post: + tags: [ Result ] + summary: получение списка результатов респондентов проходивших опрос + parameters: + - name: quizId + in: path + required: true + schema: + type: string + responses: + '200': + description: OK + '500': + description: Internal Server Error + + /results/delete/{resultId}: + delete: + tags: [ Result ] + summary: мягкое удаление результата. не удаляет, но помечает удаленным + parameters: + - name: resultId + in: path + required: true + schema: + type: string + responses: + '200': + description: OK + '500': + description: Internal Server Error + + /result/seen: + patch: + tags: [ Result ] + summary: устаревает результаты, т.е. делает их new = false + responses: + '200': + description: OK + '500': + description: Internal Server Error + + /results/{quizID}/export: + post: + tags: [ Result ] + summary: экспорт результатов quiz в csv + parameters: + - name: quizID + in: path + required: true + schema: + type: string + responses: + '200': + description: OK + '500': + description: Internal Server Error + + /result/{resultID}: + get: + tags: [ Result ] + summary: возвращает все ответы по resultID (answerID) в рамках сессии resultID + parameters: + - name: resultID + in: path + required: true + schema: + type: string + responses: + '200': + description: OK + '500': + description: Internal Server Error + + /statistic/{quizID}/devices: + post: + tags: [ Statistic ] + summary: Get device statistics for quiz + parameters: + - name: quizID + in: path + required: true + schema: + type: string + responses: + '200': + description: OK + '500': + description: Internal Server Error + + /statistic/{quizID}/general: + post: + tags: [ Statistic ] + summary: Get general statistics for quiz + parameters: + - name: quizID + in: path + required: true + schema: + type: string + responses: + '200': + description: OK + '500': + description: Internal Server Error + + /statistic/{quizID}/questions: + post: + tags: [ Statistic ] + summary: Get question statistics for quiz + parameters: + - name: quizID + in: path + required: true + schema: + type: string + responses: + '200': + description: OK + '500': + description: Internal Server Error + + /statistic: + post: + tags: [ Statistic ] + summary: Get global service statistics + responses: + '200': + description: OK + '500': + description: Internal Server Error + + /statistics/{quizID}/pipelines: + get: + tags: [ Statistic ] + summary: Get pipeline statistics for quiz + parameters: + - name: quizID + in: path + required: true + schema: + type: string + responses: + '200': + description: OK + '500': + description: Internal Server Error + + /telegram/pool: + get: + tags: [ Telegram ] + summary: возвращает все неудаленные аккаунты тг, активные, не активные и баны, тело пустое + responses: + '200': + description: OK + '500': + description: Internal Server Error + + /telegram/create: + post: + tags: [ Telegram ] + summary: метод для автторизации сервера в тг аккаунте + responses: + '200': + description: OK + '500': + description: Internal Server Error + + /telegram/{id}: + delete: + tags: [ Telegram ] + summary: метод мягкого удаления аккаунта по id primary key + parameters: + - name: id + in: path + required: true + schema: + type: string + responses: + '200': + description: OK + '500': + description: Internal Server Error + + /telegram/setCode: + post: + tags: [ Telegram ] + summary: метод для отправки кода авторизации, который пришел от телеграмма + responses: + '200': + description: OK + '500': + description: Internal Server Error + +components: + securitySchemes: + bearerAuth: + type: http + scheme: bearer + bearerFormat: JWT + + responses: + UnauthorizedError: + description: Unauthorized – authentication required + NotFoundError: + description: Resource not found + InternalServerError: + description: Internal server error + BadRequestError: + description: Invalid request data + ConflictError: + description: Conflict – resource already exists + AlreadyReportedError: + description: Resource already used + + + schemas: + Account: + type: object + properties: + id: + type: string + user_id: + type: string + created_at: + type: string + format: date-time + deleted: + type: boolean + privileges: + type: object + additionalProperties: + $ref: '#/components/schemas/ShortPrivilege' + + ShortPrivilege: + type: object + properties: + id: + type: string + privilege_id: + type: string + privilege_name: + type: string + amount: + type: integer + format: uint64 + created_at: + type: string + format: date-time + LeadTarget: + type: object + properties: + id: + type: integer + format: int64 + description: The ID of the lead target. + accountID: + type: string + description: The ID of the associated account. + type: + type: string + description: The type of lead target (mail, telegram, whatsapp). + enum: + - mail + - telegram + - whatsapp + quizID: + type: integer + format: int32 + description: The quiz ID associated with the lead target (0 if not attached to a specific quiz). + target: + type: string + description: The target address (email for mail, channel ID for telegram, phone number for whatsapp). + inviteLink: + type: string + description: An invite link for the created telegram channel. + deleted: + type: boolean + description: Whether the lead target is marked as deleted. + createdAt: + type: string + format: date-time + description: The date and time when the lead target was created. \ No newline at end of file