update openapi

This commit is contained in:
Pavel 2024-04-23 14:18:45 +03:00
parent f669d1cc71
commit 16a3779df5
2 changed files with 92 additions and 28 deletions

@ -1,8 +1,6 @@
package controllers package controllers
import ( import (
"amocrm/internal/repository"
"errors"
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
"go.uber.org/zap" "go.uber.org/zap"
"penahub.gitlab.yandexcloud.net/backend/quiz/core.git/middleware" "penahub.gitlab.yandexcloud.net/backend/quiz/core.git/middleware"
@ -65,12 +63,8 @@ func (c *Controller) GetCurrentAccount(ctx *fiber.Ctx) error {
response, err := c.service.GetCurrentAccount(ctx.Context(), accountID) response, err := c.service.GetCurrentAccount(ctx.Context(), accountID)
if err != nil { if err != nil {
switch { return ctx.Status(fiber.StatusInternalServerError).SendString("Internal Server Error")
case errors.Is(err, repository.ErrUserNotFound):
return ctx.Status(fiber.StatusNotFound).SendString("User not found")
default:
return ctx.Status(fiber.StatusInternalServerError).SendString("Internal Server Error")
}
} }
return ctx.Status(fiber.StatusOK).JSON(response) return ctx.Status(fiber.StatusOK).JSON(response)
} }

@ -53,8 +53,6 @@ paths:
$ref: '#/components/schemas/GetCurrentAccountResp' $ref: '#/components/schemas/GetCurrentAccountResp'
'401': '401':
$ref: '#/components/responses/401' $ref: '#/components/responses/401'
'404':
$ref: '#/components/responses/404'
'500': '500':
$ref: '#/components/responses/500' $ref: '#/components/responses/500'
/webhook/create: /webhook/create:
@ -108,15 +106,15 @@ paths:
- size - size
responses: responses:
'200': '200':
description: успешное получение списка пользователей description: успешное получение заданных юзером utm меток
content: content:
'application/json': 'application/json':
schema: schema:
$ref: '#/components/schemas/GetListUserUTMResp' $ref: '#/components/schemas/GetListUserUTMResp'
'401': '401':
$ref: '#/components/responses/401' $ref: '#/components/responses/401'
'404': '400':
$ref: '#/components/responses/404' $ref: '#/components/responses/400'
'500': '500':
$ref: '#/components/responses/500' $ref: '#/components/responses/500'
post: post:
@ -145,8 +143,8 @@ paths:
$ref: '#/components/schemas/ListSavedIDUTMResp' $ref: '#/components/schemas/ListSavedIDUTMResp'
'401': '401':
$ref: '#/components/responses/401' $ref: '#/components/responses/401'
'404': '400':
$ref: '#/components/responses/404' $ref: '#/components/responses/400'
'500': '500':
$ref: '#/components/responses/500' $ref: '#/components/responses/500'
delete: delete:
@ -168,11 +166,9 @@ paths:
$ref: '#/components/schemas/ListDeleteUTMIDsReq' $ref: '#/components/schemas/ListDeleteUTMIDsReq'
responses: responses:
'200': '200':
description: Success $ref: '#/components/responses/200'
'401': '400':
$ref: '#/components/responses/401' $ref: '#/components/responses/400'
'404':
$ref: '#/components/responses/404'
'500': '500':
$ref: '#/components/responses/500' $ref: '#/components/responses/500'
/users: /users:
@ -207,6 +203,10 @@ paths:
'application/json': 'application/json':
schema: schema:
$ref: "#/components/schemas/UserListResp" $ref: "#/components/schemas/UserListResp"
'401':
$ref: '#/components/responses/401'
'500':
$ref: '#/components/responses/500'
patch: patch:
operationId: UpdateListUsers operationId: UpdateListUsers
description: обновление списка юзеров description: обновление списка юзеров
@ -214,7 +214,11 @@ paths:
- main - main
responses: responses:
'200': '200':
description: Success $ref: '#/components/responses/200'
'401':
$ref: '#/components/responses/401'
'500':
$ref: '#/components/responses/500'
/pipelines: /pipelines:
get: get:
operationId: GettingPipelinesFromCash operationId: GettingPipelinesFromCash
@ -247,6 +251,10 @@ paths:
'application/json': 'application/json':
schema: schema:
$ref: "#/components/schemas/UserListPipelinesResp" $ref: "#/components/schemas/UserListPipelinesResp"
'401':
$ref: '#/components/responses/401'
'500':
$ref: '#/components/responses/500'
patch: patch:
operationId: UpdateListPipelines operationId: UpdateListPipelines
description: обновление списка воронок description: обновление списка воронок
@ -254,7 +262,11 @@ paths:
- main - main
responses: responses:
'200': '200':
description: Success $ref: '#/components/responses/200'
'401':
$ref: '#/components/responses/401'
'500':
$ref: '#/components/responses/500'
/steps: /steps:
get: get:
operationId: GettingStepsFromCash operationId: GettingStepsFromCash
@ -287,6 +299,10 @@ paths:
'application/json': 'application/json':
schema: schema:
$ref: "#/components/schemas/UserListStepsResp" $ref: "#/components/schemas/UserListStepsResp"
'401':
$ref: '#/components/responses/401'
'500':
$ref: '#/components/responses/500'
patch: patch:
operationId: UpdateListSteps operationId: UpdateListSteps
description: обновление списка этапов воронок description: обновление списка этапов воронок
@ -294,7 +310,11 @@ paths:
- main - main
responses: responses:
'200': '200':
description: Success $ref: '#/components/responses/200'
'401':
$ref: '#/components/responses/401'
'500':
$ref: '#/components/responses/500'
/fields: /fields:
get: get:
operationId: GettingFieldsFromCash operationId: GettingFieldsFromCash
@ -327,6 +347,10 @@ paths:
'application/json': 'application/json':
schema: schema:
$ref: "#/components/schemas/UserListFieldsResp" $ref: "#/components/schemas/UserListFieldsResp"
'401':
$ref: '#/components/responses/401'
'500':
$ref: '#/components/responses/500'
patch: patch:
operationId: UpdateListCustom operationId: UpdateListCustom
description: обновление списка кастомных полей description: обновление списка кастомных полей
@ -334,7 +358,11 @@ paths:
- main - main
responses: responses:
'200': '200':
description: Success $ref: '#/components/responses/200'
'401':
$ref: '#/components/responses/401'
'500':
$ref: '#/components/responses/500'
/tags: /tags:
get: get:
operationId: GettingTagsFromCash operationId: GettingTagsFromCash
@ -367,6 +395,10 @@ paths:
'application/json': 'application/json':
schema: schema:
$ref: "#/components/schemas/UserListTagsResp" $ref: "#/components/schemas/UserListTagsResp"
'401':
$ref: '#/components/responses/401'
'500':
$ref: '#/components/responses/500'
patch: patch:
operationId: UpdateListTags operationId: UpdateListTags
description: обновление списка тегов description: обновление списка тегов
@ -374,7 +406,11 @@ paths:
- main - main
responses: responses:
'200': '200':
description: Success $ref: '#/components/responses/200'
'401':
$ref: '#/components/responses/401'
'500':
$ref: '#/components/responses/500'
# таких запросах для блупринта обязательно нужно указывать параметры # таких запросах для блупринта обязательно нужно указывать параметры
/rules/{quizID}: /rules/{quizID}:
get: get:
@ -818,9 +854,43 @@ components:
RulesReq: RulesReq:
type: object type: object
properties: properties:
ID: PerformerID:
type: string type: integer
description: ID квиза description: "айдишник ответственного за сделку"
PipelineID:
type: integer
description: "айдишник воронки"
StepID:
type: integer
description: "айдишник этапа"
Utms:
type: array
items:
type: integer
description: "список UTM для этого опроса"
Fieldsrule:
type: object
properties:
Lead:
type: array
items:
$ref: "#/components/schemas/FieldRule"
description: "правила заполнения полей сущностей в амо"
Contact:
type: array
items:
$ref: "#/components/schemas/FieldRule"
description: "правила заполнения полей сущностей в амо"
Company:
type: array
items:
$ref: "#/components/schemas/FieldRule"
description: "правила заполнения полей сущностей в амо"
Customer:
type: array
items:
$ref: "#/components/schemas/FieldRule"
description: "правила заполнения полей сущностей в амо"
responses: responses:
'200': '200':