amo-server/tests/fixtures/amocrm_responses.py

722 lines
25 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""
Real AMO CRM API response examples for testing
Based on AMO CRM HAL+JSON format
"""
# Users (Пользователи) response example
USERS_RESPONSE = {
"_page": 1,
"_links": {
"self": {
"href": "https://example.amocrm.ru/api/v4/users?page=1&limit=250"
},
"next": {
"href": "https://example.amocrm.ru/api/v4/users?page=2&limit=250"
}
},
"_embedded": {
"users": [
{
"id": 504141,
"name": "Иван Иванов",
"email": "ivan@example.com",
"lang": "ru",
"rights": {
"leads": {
"view": "A",
"edit": "A",
"add": "A",
"delete": "A",
"export": "A"
},
"contacts": {
"view": "A",
"edit": "A",
"add": "A",
"delete": "A",
"export": "A"
}
},
"is_admin": True,
"is_free": False,
"is_active": True,
"group_id": 0,
"role_id": None,
"uuid": "550e8400-e29b-41d4-a716-446655440000",
"_links": {
"self": {
"href": "https://example.amocrm.ru/api/v4/users/504141"
}
}
},
{
"id": 504142,
"name": "Мария Петрова",
"email": "maria@example.com",
"lang": "ru",
"rights": {
"leads": {
"view": "A",
"edit": "A",
"add": "A",
"delete": "A",
"export": "A"
}
},
"is_admin": False,
"is_free": False,
"is_active": True,
"group_id": 0,
"role_id": 123456,
"uuid": "550e8400-e29b-41d4-a716-446655440001",
"_links": {
"self": {
"href": "https://example.amocrm.ru/api/v4/users/504142"
}
}
}
]
}
}
# Pipelines (Воронки) response example
PIPELINES_RESPONSE = {
"_page": 1,
"_links": {
"self": {
"href": "https://example.amocrm.ru/api/v4/leads/pipelines"
}
},
"_embedded": {
"pipelines": [
{
"id": 3130966,
"name": "Продажи",
"sort": 1,
"is_main": True,
"is_unsorted": False,
"is_archive": False,
"account_id": 28805383,
"created_at": 1640995200,
"updated_at": 1704067200,
"_embedded": {
"statuses": [
{
"id": 32532070,
"name": "Неразобранное",
"sort": 10,
"is_editable": False,
"pipeline_id": 3130966,
"color": "#c1c1c1",
"type": 1,
"account_id": 28805383,
"_links": {
"self": {
"href": "https://example.amocrm.ru/api/v4/leads/pipelines/3130966/statuses/32532070"
}
}
},
{
"id": 32532073,
"name": "Первичный контакт",
"sort": 20,
"is_editable": True,
"pipeline_id": 3130966,
"color": "#99ccff",
"type": 0,
"account_id": 28805383,
"_links": {
"self": {
"href": "https://example.amocrm.ru/api/v4/leads/pipelines/3130966/statuses/32532073"
}
}
},
{
"id": 32532076,
"name": "Переговоры",
"sort": 30,
"is_editable": True,
"pipeline_id": 3130966,
"color": "#ffff99",
"type": 0,
"account_id": 28805383,
"_links": {
"self": {
"href": "https://example.amocrm.ru/api/v4/leads/pipelines/3130966/statuses/32532076"
}
}
},
{
"id": 142,
"name": "Успешно реализовано",
"sort": 10000,
"is_editable": False,
"pipeline_id": 3130966,
"color": "#CCFF66",
"type": 0,
"account_id": 28805383,
"_links": {
"self": {
"href": "https://example.amocrm.ru/api/v4/leads/pipelines/3130966/statuses/142"
}
}
},
{
"id": 143,
"name": "Закрыто и не реализовано",
"sort": 11000,
"is_editable": False,
"pipeline_id": 3130966,
"color": "#D5D8DB",
"type": 0,
"account_id": 28805383,
"_links": {
"self": {
"href": "https://example.amocrm.ru/api/v4/leads/pipelines/3130966/statuses/143"
}
}
}
]
},
"_links": {
"self": {
"href": "https://example.amocrm.ru/api/v4/leads/pipelines/3130966"
}
}
}
]
}
}
# Companies (Компании) response example
COMPANIES_RESPONSE = {
"_page": 1,
"_links": {
"self": {
"href": "https://example.amocrm.ru/api/v4/companies?page=1&limit=250"
},
"next": {
"href": "https://example.amocrm.ru/api/v4/companies?page=2&limit=250"
}
},
"_embedded": {
"companies": [
{
"id": 15960673,
"name": "ООО \"Рога и копыта\"",
"responsible_user_id": 504141,
"group_id": 0,
"created_by": 504141,
"updated_by": 504142,
"created_at": 1640995200,
"updated_at": 1704067200,
"closest_task_at": None,
"is_deleted": False,
"custom_fields_values": [
{
"field_id": 123456,
"field_name": "Телефон",
"field_code": "PHONE",
"field_type": "multitext",
"values": [
{
"value": "+7 (495) 123-45-67",
"enum_id": 456789,
"enum": "WORK"
}
]
},
{
"field_id": 123457,
"field_name": "Email",
"field_code": "EMAIL",
"field_type": "multitext",
"values": [
{
"value": "info@example.com",
"enum_id": 456790,
"enum": "WORK"
}
]
},
{
"field_id": 987654,
"field_name": "Отрасль",
"field_code": None,
"field_type": "select",
"values": [
{
"value": "IT",
"enum_id": 111222,
"enum": "IT"
}
]
}
],
"account_id": 28805383,
"_links": {
"self": {
"href": "https://example.amocrm.ru/api/v4/companies/15960673"
}
}
}
]
}
}
# Contacts (Контакты) response example
CONTACTS_RESPONSE = {
"_page": 1,
"_links": {
"self": {
"href": "https://example.amocrm.ru/api/v4/contacts?page=1&limit=250"
},
"next": {
"href": "https://example.amocrm.ru/api/v4/contacts?page=2&limit=250"
}
},
"_embedded": {
"contacts": [
{
"id": 19421421,
"name": "Алексей Смирнов",
"first_name": "Алексей",
"last_name": "Смирнов",
"responsible_user_id": 504141,
"group_id": 0,
"created_by": 504141,
"updated_by": 504141,
"created_at": 1640995200,
"updated_at": 1704067200,
"closest_task_at": 1704153600,
"is_deleted": False,
"custom_fields_values": [
{
"field_id": 123456,
"field_name": "Телефон",
"field_code": "PHONE",
"field_type": "multitext",
"values": [
{
"value": "+7 (903) 123-45-67",
"enum_id": 456789,
"enum": "MOB"
}
]
},
{
"field_id": 123457,
"field_name": "Email",
"field_code": "EMAIL",
"field_type": "multitext",
"values": [
{
"value": "alexey@example.com",
"enum_id": 456790,
"enum": "PRIV"
}
]
},
{
"field_id": 555666,
"field_name": "Должность",
"field_code": None,
"field_type": "text",
"values": [
{
"value": "Менеджер по продажам"
}
]
}
],
"account_id": 28805383,
"_links": {
"self": {
"href": "https://example.amocrm.ru/api/v4/contacts/19421421"
}
},
"_embedded": {
"companies": [
{
"id": 15960673,
"_links": {
"self": {
"href": "https://example.amocrm.ru/api/v4/companies/15960673"
}
}
}
]
}
}
]
}
}
# Deals (Сделки) response example
DEALS_RESPONSE = {
"_page": 1,
"_links": {
"self": {
"href": "https://example.amocrm.ru/api/v4/leads?page=1&limit=250"
},
"next": {
"href": "https://example.amocrm.ru/api/v4/leads?page=2&limit=250"
}
},
"_embedded": {
"leads": [
{
"id": 19620805,
"name": "Сделка с ООО \"Рога и копыта\"",
"price": 150000,
"responsible_user_id": 504141,
"group_id": 0,
"status_id": 32532073,
"pipeline_id": 3130966,
"loss_reason_id": None,
"created_by": 504141,
"updated_by": 504141,
"closed_at": None,
"created_at": 1640995200,
"updated_at": 1704067200,
"closest_task_at": 1704153600,
"is_deleted": False,
"custom_fields_values": [
{
"field_id": 777888,
"field_name": "Приоритет",
"field_code": None,
"field_type": "select",
"values": [
{
"value": "Высокий",
"enum_id": 999111,
"enum": "HIGH"
}
]
},
{
"field_id": 777889,
"field_name": "Источник",
"field_code": None,
"field_type": "text",
"values": [
{
"value": "Холодный звонок"
}
]
},
{
"field_id": 777890,
"field_name": "Дата закрытия",
"field_code": None,
"field_type": "date",
"values": [
{
"value": "1704326400"
}
]
},
{
"field_id": 777891,
"field_name": "Бюджет клиента",
"field_code": None,
"field_type": "numeric",
"values": [
{
"value": "200000"
}
]
}
],
"score": None,
"account_id": 28805383,
"_links": {
"self": {
"href": "https://example.amocrm.ru/api/v4/leads/19620805"
}
},
"_embedded": {
"contacts": [
{
"id": 19421421,
"is_main": True,
"_links": {
"self": {
"href": "https://example.amocrm.ru/api/v4/contacts/19421421"
}
}
}
],
"companies": [
{
"id": 15960673,
"is_main": True,
"_links": {
"self": {
"href": "https://example.amocrm.ru/api/v4/companies/15960673"
}
}
}
]
}
},
{
"id": 19620806,
"name": "Повторная сделка",
"price": 75000,
"responsible_user_id": 504142,
"group_id": 0,
"status_id": 32532076,
"pipeline_id": 3130966,
"loss_reason_id": None,
"created_by": 504142,
"updated_by": 504142,
"closed_at": None,
"created_at": 1701388800,
"updated_at": 1704067200,
"closest_task_at": None,
"is_deleted": False,
"custom_fields_values": [
{
"field_id": 777888,
"field_name": "Приоритет",
"field_code": None,
"field_type": "select",
"values": [
{
"value": "Средний",
"enum_id": 999112,
"enum": "MEDIUM"
}
]
}
],
"score": None,
"account_id": 28805383,
"_links": {
"self": {
"href": "https://example.amocrm.ru/api/v4/leads/19620806"
}
},
"_embedded": {
"contacts": [
{
"id": 19421421,
"is_main": False,
"_links": {
"self": {
"href": "https://example.amocrm.ru/api/v4/contacts/19421421"
}
}
}
]
}
}
]
}
}
# Events (События) response example
EVENTS_RESPONSE = {
"_page": 1,
"_links": {
"self": {
"href": "https://example.amocrm.ru/api/v4/events?page=1&limit=250"
},
"next": {
"href": "https://example.amocrm.ru/api/v4/events?page=2&limit=250"
}
},
"_embedded": {
"events": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"type": "lead_status_changed",
"entity_id": 19620805,
"entity_type": "lead",
"created_by": 504141,
"created_at": 1704067200,
"value_after": [
{
"lead_status": {
"id": 32532073,
"name": "Первичный контакт",
"color": "#99ccff",
"pipeline_id": 3130966
}
}
],
"value_before": [
{
"lead_status": {
"id": 32532070,
"name": "Неразобранное",
"color": "#c1c1c1",
"pipeline_id": 3130966
}
}
],
"account_id": 28805383,
"_links": {
"self": {
"href": "https://example.amocrm.ru/api/v4/events/550e8400-e29b-41d4-a716-446655440000"
}
}
},
{
"id": "550e8400-e29b-41d4-a716-446655440001",
"type": "incoming_call",
"entity_id": 19421421,
"entity_type": "contact",
"created_by": 504141,
"created_at": 1704060000,
"value_after": [
{
"call": {
"duration": 120,
"phone": "+7 (903) 123-45-67",
"call_status": "Дозвонился",
"call_result": "Договорились о встрече"
}
}
],
"value_before": [],
"account_id": 28805383,
"_links": {
"self": {
"href": "https://example.amocrm.ru/api/v4/events/550e8400-e29b-41d4-a716-446655440001"
}
}
},
{
"id": "550e8400-e29b-41d4-a716-446655440002",
"type": "outgoing_call",
"entity_id": 15960673,
"entity_type": "company",
"created_by": 504142,
"created_at": 1704052800,
"value_after": [
{
"call": {
"duration": 0,
"phone": "+7 (495) 123-45-67",
"call_status": "Не дозвонился",
"call_result": "Занято"
}
}
],
"value_before": [],
"account_id": 28805383,
"_links": {
"self": {
"href": "https://example.amocrm.ru/api/v4/events/550e8400-e29b-41d4-a716-446655440002"
}
}
}
]
}
}
# Custom fields metadata response (for understanding field types)
CUSTOM_FIELDS_RESPONSE = {
"_page": 1,
"_links": {
"self": {
"href": "https://example.amocrm.ru/api/v4/leads/custom_fields"
}
},
"_embedded": {
"custom_fields": [
{
"id": 777888,
"name": "Приоритет",
"type": "select",
"account_id": 28805383,
"code": None,
"sort": 1,
"api_code": None,
"is_computed": False,
"is_predefined": False,
"entity_type": "leads",
"enums": [
{
"id": 999111,
"value": "Высокий",
"sort": 1,
"api_code": "HIGH"
},
{
"id": 999112,
"value": "Средний",
"sort": 2,
"api_code": "MEDIUM"
},
{
"id": 999113,
"value": "Низкий",
"sort": 3,
"api_code": "LOW"
}
],
"_links": {
"self": {
"href": "https://example.amocrm.ru/api/v4/leads/custom_fields/777888"
}
}
},
{
"id": 777889,
"name": "Источник",
"type": "text",
"account_id": 28805383,
"code": None,
"sort": 2,
"api_code": None,
"is_computed": False,
"is_predefined": False,
"entity_type": "leads",
"_links": {
"self": {
"href": "https://example.amocrm.ru/api/v4/leads/custom_fields/777889"
}
}
},
{
"id": 777890,
"name": "Дата закрытия",
"type": "date",
"account_id": 28805383,
"code": None,
"sort": 3,
"api_code": None,
"is_computed": False,
"is_predefined": False,
"entity_type": "leads",
"_links": {
"self": {
"href": "https://example.amocrm.ru/api/v4/leads/custom_fields/777890"
}
}
},
{
"id": 777891,
"name": "Бюджет клиента",
"type": "numeric",
"account_id": 28805383,
"code": None,
"sort": 4,
"api_code": None,
"is_computed": False,
"is_predefined": False,
"entity_type": "leads",
"_links": {
"self": {
"href": "https://example.amocrm.ru/api/v4/leads/custom_fields/777891"
}
}
}
]
}
}