Предметные инструменты · sale

Ведение профилей покупателей

sale_site_sale_buyer_profiles_m116_writeИзменение

Создаёт, копирует и редактирует профиль, записывает указанные свойства или импортирует значения из существующего заказа. Сохраняет ревизию, подтверждение, request_id по схеме и правила файловых значений.

Действия

В tools/call передайте имя инструмента, значение action и параметры действия во вложенном объекте arguments.

Скопировать профиль покупателя

copy

Создаёт новый профиль того же типа плательщика и копирует значения через штатные Add и владельческие методы значений. Отдельного SDK Copy нет. Целевой покупатель проверяется отдельно; копирование FILE, ADDRESS и неподдержанного представления отклоняется до создания. Ошибка после создания сохраняет частичный результат для проверки.

site_id
строка · обязательный параметр
person_type_id
целое число · обязательный параметр
user_id
целое число · обязательный параметр
profile_id
целое число · обязательный параметр
target_user_id
целое число · обязательный параметр
name
строка · обязательный параметр
expected_revision
строка · обязательный параметр

Ревизия из подготовки изменения; устаревшая ревизия отклоняется до записи.

confirm
логическое значение · обязательный параметр

Перед изменением передайте true.

Схема параметров JSON
{
  "type": "object",
  "properties": {
    "site_id": {
      "type": "string",
      "pattern": "^[A-Za-z0-9]{2}$"
    },
    "person_type_id": {
      "type": "integer",
      "minimum": 1,
      "maximum": 2147483647
    },
    "user_id": {
      "type": "integer",
      "minimum": 1,
      "maximum": 2147483647
    },
    "profile_id": {
      "type": "integer",
      "minimum": 1,
      "maximum": 2147483647
    },
    "target_user_id": {
      "type": "integer",
      "minimum": 1,
      "maximum": 2147483647
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 255
    },
    "expected_revision": {
      "type": "string",
      "pattern": "^[0-9a-f]{64}$",
      "description": "Ревизия из подготовки изменения; устаревшая ревизия отклоняется до записи."
    },
    "confirm": {
      "type": "boolean",
      "description": "Перед изменением передайте true."
    }
  },
  "required": [
    "site_id",
    "person_type_id",
    "user_id",
    "profile_id",
    "target_user_id",
    "name",
    "expected_revision",
    "confirm"
  ],
  "additionalProperties": false
}

Создать профиль покупателя

create

Создаёт профиль указанного покупателя и типа плательщика. Можно сразу записать выбранные свойства. Все значения проверяются до создания; ошибка после начала записи означает возможный частичный результат. Автоматического повторения и скрытого удаления нет.

site_id
строка · обязательный параметр
person_type_id
целое число · обязательный параметр
user_id
целое число · обязательный параметр
name
строка · обязательный параметр
values
массив
expected_revision
строка · обязательный параметр

Ревизия из подготовки изменения; устаревшая ревизия отклоняется до записи.

confirm
логическое значение · обязательный параметр

Перед изменением передайте true.

Схема параметров JSON
{
  "type": "object",
  "properties": {
    "site_id": {
      "type": "string",
      "pattern": "^[A-Za-z0-9]{2}$"
    },
    "person_type_id": {
      "type": "integer",
      "minimum": 1,
      "maximum": 2147483647
    },
    "user_id": {
      "type": "integer",
      "minimum": 1,
      "maximum": 2147483647
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 255
    },
    "values": {
      "type": "array",
      "minItems": 1,
      "maxItems": 100,
      "items": {
        "type": "object",
        "properties": {
          "property_id": {
            "type": "integer",
            "minimum": 1,
            "maximum": 2147483647
          },
          "value": {
            "type": [
              "string",
              "array",
              "object"
            ],
            "maxLength": 255,
            "maxItems": 100,
            "items": {
              "type": "string",
              "maxLength": 255
            },
            "properties": {
              "request_id": {
                "type": "string",
                "pattern": "^[a-f0-9]{32}$"
              },
              "filename": {
                "type": "string",
                "maxLength": 100
              },
              "data_base64": {
                "type": "string",
                "maxLength": 65536
              }
            },
            "required": [
              "request_id",
              "filename",
              "data_base64"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "property_id",
          "value"
        ],
        "additionalProperties": false
      }
    },
    "expected_revision": {
      "type": "string",
      "pattern": "^[0-9a-f]{64}$",
      "description": "Ревизия из подготовки изменения; устаревшая ревизия отклоняется до записи."
    },
    "confirm": {
      "type": "boolean",
      "description": "Перед изменением передайте true."
    }
  },
  "required": [
    "site_id",
    "person_type_id",
    "user_id",
    "name",
    "expected_revision",
    "confirm"
  ],
  "additionalProperties": false
}

Изменить название профиля покупателя

edit

Изменяет название существующего профиля после проверки владельца, типа плательщика и ревизии. Перенос между покупателями или типами плательщика не выполняется.

site_id
строка · обязательный параметр
person_type_id
целое число · обязательный параметр
user_id
целое число · обязательный параметр
profile_id
целое число · обязательный параметр
name
строка · обязательный параметр
expected_revision
строка · обязательный параметр

Ревизия из подготовки изменения; устаревшая ревизия отклоняется до записи.

confirm
логическое значение · обязательный параметр

Перед изменением передайте true.

Схема параметров JSON
{
  "type": "object",
  "properties": {
    "site_id": {
      "type": "string",
      "pattern": "^[A-Za-z0-9]{2}$"
    },
    "person_type_id": {
      "type": "integer",
      "minimum": 1,
      "maximum": 2147483647
    },
    "user_id": {
      "type": "integer",
      "minimum": 1,
      "maximum": 2147483647
    },
    "profile_id": {
      "type": "integer",
      "minimum": 1,
      "maximum": 2147483647
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 255
    },
    "expected_revision": {
      "type": "string",
      "pattern": "^[0-9a-f]{64}$",
      "description": "Ревизия из подготовки изменения; устаревшая ревизия отклоняется до записи."
    },
    "confirm": {
      "type": "boolean",
      "description": "Перед изменением передайте true."
    }
  },
  "required": [
    "confirm",
    "expected_revision",
    "name",
    "person_type_id",
    "profile_id",
    "site_id",
    "user_id"
  ],
  "additionalProperties": false
}

Перенести сведения из заказа в профиль покупателя

import_order

Создаёт, копирует и редактирует профиль, записывает указанные свойства или импортирует значения из существующего заказа. Сохраняет ревизию, подтверждение, request_id по схеме и правила файловых значений.

site_id
строка · обязательный параметр
person_type_id
целое число · обязательный параметр
user_id
целое число · обязательный параметр
profile_id
целое число · обязательный параметр
source_order_id
целое число · обязательный параметр
profile_name
строка
expected_revision
строка · обязательный параметр
request_id
строка · обязательный параметр
confirm
логическое значение · обязательный параметр
Схема параметров JSON
{
  "type": "object",
  "properties": {
    "site_id": {
      "type": "string",
      "pattern": "^[A-Za-z0-9]{2}$"
    },
    "person_type_id": {
      "type": "integer",
      "minimum": 1,
      "maximum": 2147483647
    },
    "user_id": {
      "type": "integer",
      "minimum": 1,
      "maximum": 2147483647
    },
    "profile_id": {
      "type": "integer",
      "minimum": 1,
      "maximum": 2147483647
    },
    "source_order_id": {
      "type": "integer",
      "minimum": 1,
      "maximum": 2147483647
    },
    "profile_name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 255
    },
    "expected_revision": {
      "type": "string",
      "pattern": "^[a-f0-9]{64}$"
    },
    "request_id": {
      "type": "string",
      "pattern": "^[a-f0-9]{32}$"
    },
    "confirm": {
      "type": "boolean"
    }
  },
  "required": [
    "site_id",
    "person_type_id",
    "user_id",
    "profile_id",
    "source_order_id",
    "expected_revision",
    "request_id",
    "confirm"
  ],
  "additionalProperties": false
}

Скачать исходное примечание

Изменить свойства профиля покупателя

set_values

Добавляет или изменяет только перечисленные свойства профиля. Остальные значения сохраняются. Для одного FILE передайте объект request_id, filename, data_base64 с новым файлом до 48 КиБ. Для MULTIPLE=Y передайте request_id и files — упорядоченный список filename/data_base64. Общий запрос остаётся в обычном лимите 256 КиБ; возможное число файлов зависит также от длины сохранённых ID в колонке VALUE. Частичный исход требует проверки без автоматического повтора. Прежние файлы и общие ссылки сохраняются; произвольный ID файла не принимается. Строка, число, да/нет, варианты, дата и местоположение сохраняют прежний контракт. Для ADDRESS передайте request_id и address.fields — список type/value для новой локальной карточки; язык берётся из серверного контекста. Прежние адреса сохраняются. В address можно добавить ручные latitude/longitude — десятичные строки, до шести знаков после точки. Геокодирование не выполняется. ID готового адреса, location, провайдер и ссылки не принимаются. Товары и пользовательские типы здесь закрыты.

site_id
строка · обязательный параметр
person_type_id
целое число · обязательный параметр
user_id
целое число · обязательный параметр
profile_id
целое число · обязательный параметр
values
массив · обязательный параметр
expected_revision
строка · обязательный параметр

Ревизия из подготовки изменения; устаревшая ревизия отклоняется до записи.

confirm
логическое значение · обязательный параметр

Перед изменением передайте true.

Схема параметров JSON
{
  "type": "object",
  "properties": {
    "site_id": {
      "type": "string",
      "pattern": "^[A-Za-z0-9]{2}$"
    },
    "person_type_id": {
      "type": "integer",
      "minimum": 1,
      "maximum": 2147483647
    },
    "user_id": {
      "type": "integer",
      "minimum": 1,
      "maximum": 2147483647
    },
    "profile_id": {
      "type": "integer",
      "minimum": 1,
      "maximum": 2147483647
    },
    "values": {
      "type": "array",
      "minItems": 1,
      "maxItems": 100,
      "items": {
        "type": "object",
        "properties": {
          "property_id": {
            "type": "integer",
            "minimum": 1,
            "maximum": 2147483647
          },
          "value": {
            "type": [
              "string",
              "array",
              "object"
            ],
            "maxLength": 255,
            "maxItems": 100,
            "items": {
              "type": "string",
              "maxLength": 255
            },
            "properties": {
              "request_id": {
                "type": "string",
                "pattern": "^[a-f0-9]{32}$"
              },
              "filename": {
                "type": "string",
                "maxLength": 100
              },
              "data_base64": {
                "type": "string",
                "maxLength": 65536
              },
              "files": {
                "type": "array",
                "minItems": 1,
                "maxItems": 26,
                "items": {
                  "type": "object",
                  "properties": {
                    "filename": {
                      "type": "string",
                      "maxLength": 100
                    },
                    "data_base64": {
                      "type": "string",
                      "maxLength": 65536
                    }
                  },
                  "required": [
                    "filename",
                    "data_base64"
                  ],
                  "additionalProperties": false
                }
              },
              "address": {
                "type": "object",
                "properties": {
                  "fields": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 20,
                    "items": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "integer",
                          "enum": [
                            0,
                            50,
                            100,
                            200,
                            210,
                            220,
                            230,
                            300,
                            310,
                            320,
                            330,
                            340,
                            400,
                            410,
                            420,
                            430,
                            600,
                            700,
                            710,
                            800
                          ]
                        },
                        "value": {
                          "type": "string",
                          "maxLength": 1024
                        }
                      },
                      "required": [
                        "type",
                        "value"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "latitude": {
                    "type": "string",
                    "pattern": "^-?(?:0|[1-9][0-9]?)(?:\\.[0-9]{1,6})?$"
                  },
                  "longitude": {
                    "type": "string",
                    "pattern": "^-?(?:0|[1-9][0-9]{0,2})(?:\\.[0-9]{1,6})?$"
                  }
                },
                "required": [
                  "fields"
                ],
                "additionalProperties": false
              },
              "legacy_location_id": {
                "type": "integer",
                "minimum": 1,
                "maximum": 2147483647
              },
              "clear_to_null": {
                "type": "boolean",
                "enum": [
                  true
                ]
              },
              "create_null": {
                "type": "boolean",
                "enum": [
                  true
                ],
                "description": "With request_id, create one observed-missing optional single LOCATION association with SQL NULL. Use change_context create_null_property_id for its revision. Existing rows, including NULL, are refused."
              }
            },
            "required": [
              "request_id"
            ],
            "additionalProperties": false,
            "description": "Scalar and string-list values retain their existing contract. A FILE object is exactly the original {request_id,filename,data_base64} or the MULTIPLE=Y form {request_id,files:[{filename,data_base64},...]}; closed adapter validation rejects mixed/incomplete forms. File order is preserved. ADDRESS uses exactly {request_id,address:{fields:[{type,value},...]}} for one new local address; existing address/location/provider/link IDs and mixed objects are refused. Optional latitude/longitude are manual decimal strings with up to six fractional digits; exact native numeric rendering and actual standard nullable DECIMAL columns are checked before ownership. No geocoder/provider runs. Server language applies; old native cards remain retained. Single LOCATION values accept exactly {request_id,legacy_location_id}; the original numeric-ID owner is Update for an existing value or Add for an observed missing value under the existing profile. Scalar CODE strings keep their original contract. One existing optional single LOCATION or ADDRESS value can instead use exactly {request_id,clear_to_null:true}; original Update receives false to preserve the row and set SQL NULL. ADDRESS retains every existing address card, field and link; it accepts no address ID or resource deletion. The same selector also accepts one existing optional single FILE value using original legacy Update(false) semantics, distinct from the UI File validator that rejects scalar false; it retains file rows and the observed local upload tree, and accepts no resource ID or deletion. JSON null, false and empty strings retain their separate existing contracts."
          }
        },
        "required": [
          "property_id",
          "value"
        ],
        "additionalProperties": false
      }
    },
    "expected_revision": {
      "type": "string",
      "pattern": "^[0-9a-f]{64}$",
      "description": "Ревизия из подготовки изменения; устаревшая ревизия отклоняется до записи."
    },
    "confirm": {
      "type": "boolean",
      "description": "Перед изменением передайте true."
    }
  },
  "required": [
    "site_id",
    "person_type_id",
    "user_id",
    "profile_id",
    "values",
    "expected_revision",
    "confirm"
  ],
  "additionalProperties": false
}