openapi: 3.0.3 info: title: QUIZ AMOCRM integration description: Интеграция с Амо. Ключевая задача - создавать заявки в соответствующей воронкой подключенного аккаунта version: 1.0.0 tags: - name: main description: Операции связанные с AmoCRM paths: /account: post: operationId: ConnectAccount description: подключение аккаунта амо к аккаунту quiz. На вход получает только токен. На выход отдаёт ссылку для подключения. Создаёт модель аккаунта, имеющую связь с основным аккаунтом tags: - main responses: '200': description: успешное создание ссылки для авторизации content: 'application/json': schema: $ref: '#/components/schemas/ConnectAccountResp' '401': $ref: '#/components/responses/401' '500': $ref: '#/components/responses/500' delete: operationId: SoftDeleteAccount description: мягкое удаление аккаунта. Юзер должен иметь возможность создать новый аккаунт, взамен удалённого tags: - main responses: '200': $ref: '#/components/responses/200' '401': $ref: '#/components/responses/401' '500': $ref: '#/components/responses/500' get: operationId: GetCurrentAccount description: получение текущего аккаунта tags: - main responses: '200': description: аккаунт интеграции с амо content: 'application/json': schema: $ref: '#/components/schemas/User' '401': $ref: '#/components/responses/401' '500': $ref: '#/components/responses/500' /webhook/create: get: operationId: WebhookCreate description: это метод для получения пары токенов для аккаунта. Пары токенов стоит хранить в отдельной таблице и завести воркер, который будет обновлять рефреш. https://www.amocrm.ru/developers/content/oauth/step-by-step - вот дока для этого метода tags: - main responses: '200': description: Success /webhook/delete: get: operationId: WebhookDelete description: это метод для оповещения об удалении итеграции из учетки в амо. При его вызове надо мягко удалить соответствующий аккаунт. https://www.amocrm.ru/developers/content/oauth/step-by-step#%D0%A5%D1%83%D0%BA-%D0%BE%D0%B1-%D0%BE%D1%82%D0%BA%D0%BB%D1%8E%D1%87%D0%B5%D0%BD%D0%B8%D0%B8-%D0%B8%D0%BD%D1%82%D0%B5%D0%B3%D1%80%D0%B0%D1%86%D0%B8%D0%B8 tags: - main responses: '200': description: Success # /utms/{quizID}: # get: # operationId: GettingUserUTM # tags: # - main # description: получение списка заданных юзером utm меток. Это чисто наша сущность, в амо она представлена кастомными полями сделки # parameters: # - in: path # name: quizID # required: true # schema: # type: string # description: Id квиза # - in: query # name: Pagination # description: Параметры пагинации # required: false # schema: # type: object # properties: # page: # type: integer # description: Номер страницы пагинации. Если не указан, используется значение по умолчанию. # example: 1 # size: # type: integer # description: Размер страницы пагинации. Если не указан, используется значение по умолчанию. # example: 25 # required: # - page # - size # responses: # '200': # description: успешное получение заданных юзером utm меток # content: # 'application/json': # schema: # $ref: '#/components/schemas/GetListUserUTMResp' # '401': # $ref: '#/components/responses/401' # '400': # $ref: '#/components/responses/400' # '500': # $ref: '#/components/responses/500' # post: # operationId: SavingUserUTM # tags: # - main # description: сохранение списка заданных юзером utm меток # parameters: # - in: path # name: quizID # required: true # schema: # type: string # description: Id квиза # requestBody: # content: # application/json: # schema: # $ref: "#/components/schemas/SaveUserListUTMReq" # responses: # '200': # description: успешное сохранение списка utm меток # content: # 'application/json': # schema: # $ref: '#/components/schemas/ListSavedIDUTMResp' # '401': # $ref: '#/components/responses/401' # '400': # $ref: '#/components/responses/400' # '500': # $ref: '#/components/responses/500' # delete: # operationId: DeletingUserUTM # tags: # - main # description: удаление utm по айдишникам # parameters: # - in: path # name: quizID # required: true # schema: # type: string # description: Id квиза # requestBody: # content: # 'application/json': # schema: # $ref: '#/components/schemas/ListDeleteUTMIDsReq' # responses: # '200': # $ref: '#/components/responses/200' # '400': # $ref: '#/components/responses/400' # '500': # $ref: '#/components/responses/500' /users: get: operationId: GettingUserWithPagination tags: - main description: получение списка юзеров, закешированных у нас, с пагинацией https://www.amocrm.ru/developers/content/crm_platform/users-api#users-list parameters: - in: query name: Pagination description: Параметры пагинации required: false schema: type: object properties: page: type: integer description: Номер страницы пагинации. Если не указан, используется значение по умолчанию. example: 1 size: type: integer description: Размер страницы пагинации. Если не указан, используется значение по умолчанию. example: 25 required: - page - size responses: '200': description: успешное получение списка пользователей content: 'application/json': schema: $ref: "#/components/schemas/UserListResp" '400': $ref: '#/components/responses/400' '401': $ref: '#/components/responses/401' '500': $ref: '#/components/responses/500' patch: operationId: UpdateListUsers description: обновление списка юзеров tags: - main responses: '200': $ref: '#/components/responses/200' '401': $ref: '#/components/responses/401' '500': $ref: '#/components/responses/500' /pipelines: get: operationId: GetPipelinesWithPagination tags: - main description: получение списка воронок, закешированных у нас, с пагинацией https://www.amocrm.ru/developers/content/crm_platform/leads_pipelines parameters: - in: query name: Pagination description: Параметры пагинации required: false schema: type: object properties: page: type: integer description: Номер страницы пагинации. Если не указан, используется значение по умолчанию. example: 1 size: type: integer description: Размер страницы пагинации. Если не указан, используется значение по умолчанию. example: 25 required: - page - size responses: '200': description: успешное получение списка воронок content: 'application/json': schema: $ref: "#/components/schemas/UserListPipelinesResp" '400': $ref: '#/components/responses/400' '401': $ref: '#/components/responses/401' '500': $ref: '#/components/responses/500' patch: operationId: UpdateListPipelines description: обновление списка воронок tags: - main responses: '200': $ref: '#/components/responses/200' '401': $ref: '#/components/responses/401' '500': $ref: '#/components/responses/500' /steps: get: operationId: GetStepsWithPagination tags: - main description: получение списка этапов воронок, закешированных у нас, с пагинацией https://www.amocrm.ru/developers/content/crm_platform/leads_pipelines#%D0%A1%D0%BF%D0%B8%D1%81%D0%BE%D0%BA-%D1%81%D1%82%D0%B0%D1%82%D1%83%D1%81%D0%BE%D0%B2-%D0%B2%D0%BE%D1%80%D0%BE%D0%BD%D0%BA%D0%B8-%D1%81%D0%B4%D0%B5%D0%BB%D0%BE%D0%BA parameters: - in: query name: Pagination description: Параметры пагинации required: false schema: type: object properties: pipelineID: type: integer description: id воронки которой принадлежат шаги example: 123 page: type: integer description: Номер страницы пагинации. Если не указан, используется значение по умолчанию. example: 1 size: type: integer description: Размер страницы пагинации. Если не указан, используется значение по умолчанию. example: 25 required: - pipelineID - page - size responses: '200': description: успешное получение списка шагов воронок content: 'application/json': schema: $ref: "#/components/schemas/UserListStepsResp" '400': $ref: '#/components/responses/400' '401': $ref: '#/components/responses/401' '500': $ref: '#/components/responses/500' patch: operationId: UpdateListSteps description: обновление списка этапов воронок tags: - main responses: '200': $ref: '#/components/responses/200' '401': $ref: '#/components/responses/401' '500': $ref: '#/components/responses/500' /fields: get: operationId: GetFieldsWithPagination tags: - main description: получение списка кастомных полей, закешированных у нас, с пагинацией https://www.amocrm.ru/developers/content/crm_platform/custom-fields#%D0%A1%D0%BF%D0%B8%D1%81%D0%BE%D0%BA-%D0%BF%D0%BE%D0%BB%D0%B5%D0%B9-%D1%81%D1%83%D1%89%D0%BD%D0%BE%D1%81%D1%82%D0%B8 parameters: - in: query name: Pagination description: Параметры пагинации required: false schema: type: object properties: page: type: integer description: Номер страницы пагинации. Если не указан, используется значение по умолчанию. example: 1 size: type: integer description: Размер страницы пагинации. Если не указан, используется значение по умолчанию. example: 25 required: - page - size responses: '200': description: успешное получение списка тегов content: 'application/json': schema: $ref: "#/components/schemas/UserListFieldsResp" '400': $ref: '#/components/responses/400' '401': $ref: '#/components/responses/401' '500': $ref: '#/components/responses/500' patch: operationId: UpdateListCustom description: обновление списка кастомных полей tags: - main responses: '200': $ref: '#/components/responses/200' '401': $ref: '#/components/responses/401' '500': $ref: '#/components/responses/500' /tags: get: operationId: GetTagsWithPagination tags: - main description: получение списка тегов, закешированных у нас, с пагинацией https://www.amocrm.ru/developers/content/crm_platform/tags-api#%D0%A1%D0%BF%D0%B8%D1%81%D0%BE%D0%BA-%D1%82%D0%B5%D0%B3%D0%BE%D0%B2-%D0%B4%D0%BB%D1%8F-%D1%81%D1%83%D1%89%D0%BD%D0%BE%D1%81%D1%82%D0%B8 parameters: - in: query name: Pagination description: Параметры пагинации required: false schema: type: object properties: page: type: integer description: Номер страницы пагинации. Если не указан, используется значение по умолчанию. example: 1 size: type: integer description: Размер страницы пагинации. Если не указан, используется значение по умолчанию. example: 25 required: - page - size responses: '200': description: успешное получение списка тегов content: 'application/json': schema: $ref: "#/components/schemas/UserListTagsResp" '400': $ref: '#/components/responses/400' '401': $ref: '#/components/responses/401' '500': $ref: '#/components/responses/500' patch: operationId: UpdateListTags description: обновление списка тегов tags: - main responses: '200': $ref: '#/components/responses/200' '401': $ref: '#/components/responses/401' '500': $ref: '#/components/responses/500' # таких запросах для блупринта обязательно нужно указывать параметры /rules/{quizID}: get: operationId: GettingQuizRules tags: - main description: получение настроек интеграции для конкретного квиза parameters: - in: path name: quizID required: true schema: type: string description: Id квиза responses: '200': description: успешное получение настройки интеграции content: 'application/json': schema: $ref: "#/components/schemas/Rule" '400': $ref: '#/components/responses/400' '500': $ref: '#/components/responses/500' post: operationId: SetQuizSettings description: создание настроек интеграции для конкретного квиза, при успешном исходе кладет задачу в кафку, на 1 квиз 1 правило tags: - main parameters: - in: path name: quizID required: true schema: type: string description: Id квиза requestBody: content: application/json: schema: $ref: "#/components/schemas/RulesReq" responses: '200': $ref: '#/components/responses/200' '400': $ref: '#/components/responses/400' '401': $ref: '#/components/responses/401' '500': $ref: '#/components/responses/500' patch: operationId: ChangeQuizSettings description: изменение настроек интеграции для конкретного квиза, при успешном исходе кладет задачу в кафку, на 1 квиз 1 правило tags: - main parameters: - in: path name: quizID required: true schema: type: string description: Id квиза requestBody: content: application/json: schema: $ref: "#/components/schemas/RulesReq" responses: '200': $ref: '#/components/responses/200' '400': $ref: '#/components/responses/400' '401': $ref: '#/components/responses/401' '500': $ref: '#/components/responses/500' components: schemas: Rule: type: object description: объект настройки правил сохранения данных в амо properties: ID: type: integer description: айдишник в нашей системе Primary Key AccountID: type: integer description: связь с аккаунтом в интеграции амо id в амо QuizID: type: integer description: айдишник опроса PerformerID: type: integer description: айдишник ответственного за сделку PipelineID: type: integer description: айдишник воронки StepID: type: integer description: айдишник этапа # UTMs: # type: array # items: # type: integer # description: список UTM для этого опроса FieldsRule: type: object description: правила заполнения полей сущностей в амо properties: lead: type: array items: $ref: '#/components/schemas/FieldRule' contact: type: array items: $ref: '#/components/schemas/ContactRules' company: type: array items: $ref: '#/components/schemas/FieldRule' customer: type: array items: $ref: '#/components/schemas/FieldRule' Deleted: type: boolean description: флаг мягкого удаления CreatedAt: type: integer description: таймштамп создания воронки в нашей системе FieldRule: type: object description: правила сопоставления вопроса полю properties: QuestionID: type: integer additionalProperties: type: integer description: сопоставление айдишника вопроса полю, которое будет заполняться ответом. соответственно QuestionID это айдишник вопроса. это я так мэпу пытался записать. Мапа, где ключи - QuestionID, значения - ID кастомного поля Pipeline: type: object description: объект воронки амо properties: ID: type: integer description: айдишник в нашей системе Primary Key AmoID: type: integer description: айдишник воронки в амо AccountID: type: integer description: связь с аккаунтом в интеграции амо id аккаунта в амо Name: type: string description: название воронки в амо IsArchive: type: boolean description: флаг архивной воронки в амо Deleted: type: boolean description: флаг мягкого удаления CreatedAt: type: integer description: таймштамп создания воронки в нашей системе Step: type: object description: объект шага воронки амо properties: ID: type: integer description: айдишник в нашей системе Primary Key AmoID: type: integer description: айдишник шага воронки в амо PipelineID: type: integer description: айдишник воронки в амо AccountID: type: integer description: связь с аккаунтом в интеграции амо id в амо Name: type: string description: название воронки в амо Color: type: string description: цвет шага в амо Deleted: type: boolean description: флаг мягкого удаления CreatedAt: type: integer description: таймштамп создания воронки в нашей системе Field: type: object description: объект кастомного поля амо properties: ID: type: integer description: айдишник в нашей системе Primary Key AmoID: type: integer description: айдишник кастомного поля в амо Code: type: string description: кодовое слово в амо AccountID: type: integer description: связь с аккаунтом в интеграции амо id аккаунта в амо Name: type: string description: название воронки в амо EntityType: type: string description: тип сущности в амо, для которой это кастомное поле Type: type: string description: тип поля https://www.amocrm.ru/developers/content/crm_platform/custom-fields#%D0%94%D0%BE%D1%81%D1%82%D1%83%D0%BF%D0%BD%D1%8B%D0%B5-%D1%82%D0%B8%D0%BF%D1%8B-%D0%BF%D0%BE%D0%BB%D0%B5%D0%B9 Deleted: type: boolean description: флаг мягкого удаления CreatedAt: type: integer description: таймштамп создания воронки в нашей системе UTM: type: object description: объект настройки UTM, данные о которых мы сохраняем в амо properties: ID: type: integer description: айдишник в нашей системе Primary Key AmoFieldID: type: integer description: айдишник кастомного поля в амо QuizID: type: integer description: айдишник квиза AccountID: type: integer description: связь с аккаунтом в интеграции амо id амо Name: type: string description: название тега в амо Deleted: type: boolean description: флаг мягкого удаления CreatedAt: type: integer description: таймштамп создания тега в нашей системе Tag: type: object description: объект тега из амо properties: ID: type: integer description: айдишник в нашей системе Primary Key AmoID: type: integer description: айдишник тега в амо AccountID: type: integer description: связь с аккаунтом в интеграции амо id аккаунта в амо Entity: type: string description: сущность, к которой принадлежит этот тег. Наверное, стоит сделать через enum в базе Name: type: string description: название тега в амо Color: type: string description: цвет тега в амо Deleted: type: boolean description: флаг мягкого удаления CreatedAt: type: integer description: таймштамп создания тега в нашей системе User: type: object description: объект пользователя из амо properties: ID: type: integer description: айдишник в нашей системе Primary Key AccountID: type: string description: id пользователя из токена в нашей системе AmoID: type: integer description: айдишник пользователя в амо Name: type: string description: имя пользователя в амо Email: type: string description: почта пользователя из амо Role: type: string description: роль пользователя в амо Group: type: integer description: группа пользователя в амо Deleted: type: boolean description: флаг мягкого удаления CreatedAt: type: integer description: таймштамп создания тега в нашей системе Subdomain: type: string description: поддомен организации Amoiserid: type: integer description: id в amo пользователя который подключал интеграцию Country: type: string description: страна указанная в настройках аккаунта амо ConnectAccountResp: type: object properties: link: type: string description: ссылка для авторизации в амо GetCurrentAccountResp: type: object properties: ID: type: integer description: id аккаунта в амо сервисе тут Primary Key AccountID: type: string description: связь с аккаунтом в квизе id из токена AmocrmID: type: integer description: связь с аккаунтом в амо id аккаунта из амо Name: type: string description: имя аккаунта в амо Subdomain: type: string description: поддомен организации в амо AmoUserID: type: integer description: айдишник пользвателя, который подключал интеграцию Country: type: string description: страна указанная в настройках амо CreatedAt: type: integer description: таймштамп создания аккаунта GetListUserUTMResp: type: object properties: count: type: integer description: общее количество юзеров, которые у нас закешированы для этого пользователя items: type: array description: список юзеров, которые были закешированы нашим сервисом items: $ref: "#/components/schemas/UTM" SaveUserListUTMReq: type: object properties: utms: type: array description: список utm для сохранения. сохранять только те, которых в этом аккаунте ещё нет items: $ref: "#/components/schemas/UTM" ListSavedIDUTMResp: type: object properties: IDs: type: array description: список айдишников сохранённых меток items: type: string ListDeleteUTMIDsReq: type: object properties: utms: type: array description: список айдишников utm которые удалить items: type: integer UserListResp: type: object properties: count: type: integer description: общее количество юзеров, которые у нас закешированы для этого пользователя items: type: array description: список юзеров, которые были закешированы нашим сервисом items: $ref: "#/components/schemas/User" UserListPipelinesResp: type: object properties: count: type: integer description: общее количество воронок, которые у нас закешированы для этого пользователя items: type: array description: список воронок, которые были закешированы нашим сервисом items: $ref: "#/components/schemas/Pipeline" UserListStepsResp: type: object properties: count: type: integer description: общее количество шагов воронок, которые у нас закешированы для этого пользователя items: type: array description: список шагов воронок, которые были закешированы нашим сервисом items: $ref: "#/components/schemas/Step" UserListFieldsResp: type: object properties: count: type: integer description: общее количество кастомных полей, которые у нас закешированы для этого пользователя items: type: array description: список кастомных полей, которые были закешированы нашим сервисом items: $ref: "#/components/schemas/Field" UserListTagsResp: type: object properties: count: type: integer description: общее количество тегов, которые у нас закешированы для этого пользователя items: type: array description: список тегов, которые были закешированы нашим сервисом items: $ref: "#/components/schemas/Tag" PaginationReq: type: object properties: page: type: integer description: указание страницы пагинации. Если страница не указана, применять 0 size: type: integer description: указание размера страницы пагинации. По умолчанию применять 25 RulesReq: type: object properties: PerformerID: type: integer 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/ContactRules" description: "правила заполнения полей контакта в амо, передавать не стоит, будут парситься из конфига опроса переданного в правиле" Company: type: array items: $ref: "#/components/schemas/FieldRule" description: "правила заполнения полей сущностей в амо" Customer: type: array items: $ref: "#/components/schemas/FieldRule" description: "правила заполнения полей сущностей в амо" ContactRules: type: object description: правила заполнения сущности контакта, название поля = id кастомного поля в амо properties: ContactRuleMap: type: string additionalProperties: type: integer responses: '200': description: Success content: application/json: schema: type: string description: Success '201': description: Created content: application/json: schema: type: string description: Created '204': description: No content content: application/json: schema: type: string description: No content '400': description: Bad Request content: application/json: schema: type: string description: Bad Request '401': description: Unauthorized content: application/json: schema: type: string description: Unauthorized '403': description: Forbidden content: application/json: schema: type: string description: Forbidden '404': description: Not Found content: application/json: schema: type: string description: Not Found '500': description: Internal Server Error content: application/json: schema: type: string description: Internal Server Error