{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/raiffeisen-ru/main/json-schema/raiffeisen-ru-buyer-schema.json",
  "title": "Buyer",
  "description": "Покупатель",
  "x-generated": "2026-10-09",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/raiffeisen-ru-payment-control-openapi.yml#/components/schemas/Buyer",
  "allOf": [
    {
      "$ref": "#/$defs/BuyerRequisites"
    },
    {
      "properties": {
        "id": {
          "description": "Идентификатор покупателя",
          "format": "uuid",
          "type": "string"
        },
        "createdAt": {
          "description": "Дата и время создания",
          "pattern": "([0-9]{4})-(?:[0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2}).([0-9]{6})",
          "type": "string"
        },
        "clients": {
          "description": "Клиенты связанные с покупателем",
          "items": {
            "$ref": "#/$defs/Client"
          },
          "type": "array"
        },
        "state": {
          "$ref": "#/$defs/BuyerState"
        },
        "cqrsVersion": {
          "$ref": "#/$defs/CqrsVersion"
        }
      },
      "required": [
        "cqrsVersion",
        "id",
        "state"
      ],
      "type": "object"
    }
  ],
  "$defs": {
    "BuyerRequisites": {
      "description": "Реквизиты покупателя",
      "properties": {
        "fullName": {
          "description": "Полное наименование",
          "type": "string"
        },
        "shortName": {
          "description": "Краткое наименование",
          "type": "string"
        },
        "inn": {
          "description": "ИНН",
          "maxLength": 12,
          "minLength": 10,
          "type": "string"
        },
        "ogrn": {
          "description": "ОГРН",
          "maxLength": 15,
          "minLength": 13,
          "type": "string"
        },
        "kpp": {
          "description": "КПП",
          "maxLength": 9,
          "minLength": 9,
          "type": "string"
        }
      },
      "required": [
        "fullName",
        "inn",
        "ogrn"
      ],
      "type": "object"
    },
    "BuyerState": {
      "allOf": [
        {
          "$ref": "#/$defs/State"
        },
        {
          "properties": {
            "status": {
              "$ref": "#/$defs/BuyerStatus"
            }
          },
          "type": "object"
        }
      ],
      "description": "Состояние покупателя",
      "type": "object"
    },
    "BuyerStatus": {
      "description": "Статус покупателя",
      "enum": [
        "SENT_TO_CHECK",
        "APPROVED",
        "REJECTED"
      ],
      "type": "string"
    },
    "Client": {
      "description": "Клиент",
      "properties": {
        "id": {
          "description": "Идентификатор клиента",
          "format": "uuid",
          "type": "string"
        },
        "createdAt": {
          "description": "Дата и время создания",
          "pattern": "([0-9]{4})-(?:[0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2}).([0-9]{6})",
          "type": "string"
        },
        "contacts": {
          "description": "Контакты",
          "items": {
            "$ref": "#/$defs/Contact"
          },
          "type": "array"
        },
        "requisites": {
          "$ref": "#/$defs/OrganizationRequisites"
        },
        "state": {
          "$ref": "#/$defs/ClientState"
        },
        "cqrsVersion": {
          "description": "hashCode от state - состояния объекта",
          "type": "integer"
        }
      },
      "required": [
        "contacts",
        "cqrsVersion",
        "createdAt",
        "id",
        "requisites",
        "state"
      ],
      "type": "object"
    },
    "ClientState": {
      "allOf": [
        {
          "$ref": "#/$defs/State"
        },
        {
          "properties": {
            "status": {
              "$ref": "#/$defs/ClientStatus"
            }
          }
        }
      ],
      "description": "Состояние клиента",
      "type": "object"
    },
    "ClientStatus": {
      "description": "Статус клиента",
      "enum": [
        "SENT_TO_CHECK",
        "APPROVED",
        "REJECTED"
      ],
      "type": "string"
    },
    "Contact": {
      "description": "Контакт",
      "properties": {
        "id": {
          "description": "Идентификатор контакта",
          "format": "uuid",
          "type": "string"
        },
        "createdAt": {
          "description": "Дата и время создания",
          "pattern": "([0-9]{4})-(?:[0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2}).([0-9]{6})",
          "type": "string"
        },
        "email": {
          "description": "Email",
          "format": "email",
          "type": "string"
        },
        "state": {
          "$ref": "#/$defs/ContactState"
        },
        "cqrsVersion": {
          "description": "hashCode от state - состояния объекта",
          "type": "integer"
        }
      },
      "required": [
        "cqrsVersion",
        "createdAt",
        "email",
        "id",
        "state"
      ],
      "type": "object"
    },
    "ContactState": {
      "allOf": [
        {
          "$ref": "#/$defs/State"
        },
        {
          "properties": {
            "status": {
              "$ref": "#/$defs/ContactStatus"
            }
          }
        }
      ],
      "description": "Состояние контакта",
      "type": "object"
    },
    "ContactStatus": {
      "description": "Статус контакта",
      "enum": [
        "CREATED"
      ],
      "type": "string"
    },
    "CqrsVersion": {
      "description": "hashCode от state - состояния объекта",
      "type": "integer"
    },
    "Error": {
      "properties": {
        "code": {
          "$ref": "#/$defs/ErrorCodes"
        },
        "description": {
          "description": "Сообщение",
          "type": "string"
        }
      },
      "required": [
        "code",
        "description"
      ],
      "type": "object"
    },
    "ErrorCodes": {
      "description": "| code       | description                                                  |\n|------------|--------------------------------------------------------------|\n| ERROR_2000 | General service error                                        |\n| ERROR_2001 | Buyer not found                                              |\n| ERROR_2002 | Condition not found                                          |\n| ERROR_2003 | Duplicate supply                                             |\n| ERROR_2004 | Payment date must be after then current date                 |\n| ERROR_2005 | Main document date must be after or equal then contract date |\n| ERROR_2006 | Buyer not valid                                              |\n| ERROR_2007 | Additional document date must be after or equal then contract date                                              |\n",
      "enum": [
        "ERROR_2000",
        "ERROR_2001",
        "ERROR_2002",
        "ERROR_2003",
        "ERROR_2004",
        "ERROR_2005",
        "ERROR_2006",
        "ERROR_2007"
      ],
      "type": "string"
    },
    "OrganizationRequisites": {
      "description": "Реквизиты организации",
      "properties": {
        "fullNameRus": {
          "description": "Полное наименование",
          "type": "string"
        },
        "shortNameRus": {
          "description": "Краткое наименование",
          "type": "string"
        },
        "fullNameEn": {
          "description": "Полное наименование на английском языке",
          "type": "string"
        },
        "shortNameEn": {
          "description": "Краткое наименование на английском языке",
          "type": "string"
        },
        "inn": {
          "description": "ИНН",
          "maxLength": 12,
          "minLength": 10,
          "type": "string"
        },
        "ogrn": {
          "description": "ОГРН",
          "maxLength": 15,
          "minLength": 13,
          "type": "string"
        },
        "kpp": {
          "description": "КПП",
          "maxLength": 9,
          "minLength": 9,
          "type": "string"
        },
        "okved": {
          "description": "ОКВЭД",
          "type": "string"
        },
        "cnum": {
          "description": "Клиентский номер",
          "maxLength": 6,
          "minLength": 6,
          "type": "string"
        },
        "opf": {
          "description": "Организационно правовая форма",
          "type": "string"
        },
        "address": {
          "description": "Адрес",
          "type": "string"
        }
      },
      "required": [
        "address",
        "cnum",
        "fullNameEn",
        "fullNameRus",
        "inn",
        "ogrn",
        "okved",
        "opf",
        "shortNameEn",
        "shortNameRus"
      ],
      "type": "object"
    },
    "State": {
      "description": "Состояние объекта",
      "properties": {
        "statusDate": {
          "description": "yyyy-MM-dd'T'HH:mm:ss.SSSSSS",
          "format": "date-time",
          "pattern": "([0-9]{4})-(?:[0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2}).([0-9]{6})",
          "type": "string"
        },
        "errors": {
          "description": "Ошибки",
          "items": {
            "$ref": "#/$defs/Error"
          },
          "type": "array"
        }
      },
      "required": [
        "statusDate"
      ],
      "type": "object"
    }
  }
}