{
 "openapi": "3.1.0",
 "info": {
  "title": "API партнёра",
  "version": "1.0"
 },
 "tags": [
  {
   "name": "API партнёра",
   "description": "Брони и матчи клуба по ключу партнёра."
  }
 ],
 "paths": {
  "/v1/partner/club": {
   "get": {
    "tags": [
     "API партнёра"
    ],
    "summary": "Клуб",
    "description": "Клуб, которому принадлежит ключ: название, адрес, часовой пояс, часы работы, длительность брони.",
    "operationId": "p_club_v1_partner_club_get",
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/PartnerClub"
        }
       }
      }
     },
     "401": {
      "description": "Нет ключа, ключ неверен или отозван"
     },
     "403": {
      "description": "Модуль «Интеграции» не подключён клубу"
     },
     "429": {
      "description": "Превышен лимит запросов в минуту; заголовок Retry-After — через сколько секунд"
     }
    },
    "security": [
     {
      "Ключ партнёра": []
     }
    ]
   }
  },
  "/v1/partner/courts": {
   "get": {
    "tags": [
     "API партнёра"
    ],
    "summary": "Корты",
    "description": "Корты клуба, открытые для онлайн-записи.",
    "operationId": "p_courts_v1_partner_courts_get",
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "items": {
          "$ref": "#/components/schemas/PartnerCourt"
         },
         "type": "array",
         "title": "Response P Courts V1 Partner Courts Get"
        }
       }
      }
     },
     "401": {
      "description": "Нет ключа, ключ неверен или отозван"
     },
     "403": {
      "description": "Модуль «Интеграции» не подключён клубу"
     },
     "429": {
      "description": "Превышен лимит запросов в минуту; заголовок Retry-After — через сколько секунд"
     }
    },
    "security": [
     {
      "Ключ партнёра": []
     }
    ]
   }
  },
  "/v1/partner/slots": {
   "get": {
    "tags": [
     "API партнёра"
    ],
    "summary": "Свободное время",
    "description": "Свободное время одного дня: какие корты свободны и цена по сетке клуба. День — от сегодня до предела записи клуба (bookingDepthDays).",
    "operationId": "p_slots_v1_partner_slots_get",
    "security": [
     {
      "Ключ партнёра": []
     }
    ],
    "parameters": [
     {
      "name": "day",
      "in": "query",
      "required": false,
      "schema": {
       "anyOf": [
        {
         "type": "string",
         "format": "date"
        },
        {
         "type": "null"
        }
       ],
       "description": "День, ГГГГ-ММ-ДД; по умолчанию сегодня",
       "title": "Day"
      },
      "description": "День, ГГГГ-ММ-ДД; по умолчанию сегодня"
     },
     {
      "name": "court_id",
      "in": "query",
      "required": false,
      "schema": {
       "anyOf": [
        {
         "type": "string",
         "maxLength": 64
        },
        {
         "type": "null"
        }
       ],
       "description": "Только этот корт",
       "title": "Court Id"
      },
      "description": "Только этот корт"
     }
    ],
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/PartnerSlots"
        }
       }
      }
     },
     "401": {
      "description": "Нет ключа, ключ неверен или отозван"
     },
     "403": {
      "description": "Модуль «Интеграции» не подключён клубу"
     },
     "429": {
      "description": "Превышен лимит запросов в минуту; заголовок Retry-After — через сколько секунд"
     },
     "422": {
      "description": "Validation Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/HTTPValidationError"
        }
       }
      }
     }
    }
   }
  },
  "/v1/partner/bookings": {
   "post": {
    "tags": [
     "API партнёра"
    ],
    "summary": "Создать бронь",
    "description": "Бронь корта с оплатой в клубе. Цена — по сетке клуба, как у брони из приложения. Корт не указан — первый свободный. Повтор с тем же externalRef вернёт ту же бронь (duplicate=true). Будущих броней на один ключ — не больше 30.",
    "operationId": "p_book_v1_partner_bookings_post",
    "security": [
     {
      "Ключ партнёра": []
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/PartnerBookingIn"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/PartnerBookingOut"
        }
       }
      }
     },
     "401": {
      "description": "Нет ключа, ключ неверен или отозван"
     },
     "403": {
      "description": "module_not_enabled или pay_at_club_disabled — клуб не принимает оплату в клубе"
     },
     "429": {
      "description": "Превышен лимит запросов в минуту; заголовок Retry-After — через сколько секунд"
     },
     "400": {
      "description": "bad_slot_time, slot_in_past, past_day"
     },
     "404": {
      "description": "court_not_found"
     },
     "409": {
      "description": "slot_taken, too_far_ahead, active_limit"
     },
     "422": {
      "description": "Validation Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/HTTPValidationError"
        }
       }
      }
     }
    }
   },
   "get": {
    "tags": [
     "API партнёра"
    ],
    "summary": "Свои брони",
    "description": "Брони, созданные этим ключом, за период по дню игры. По умолчанию — две недели с сегодняшнего дня, период не больше 92 дней. Брони клуба, сделанные не этим ключом, не отдаются.",
    "operationId": "p_bookings_v1_partner_bookings_get",
    "security": [
     {
      "Ключ партнёра": []
     }
    ],
    "parameters": [
     {
      "name": "date_from",
      "in": "query",
      "required": false,
      "schema": {
       "anyOf": [
        {
         "type": "string",
         "format": "date"
        },
        {
         "type": "null"
        }
       ],
       "description": "С какого дня",
       "title": "Date From"
      },
      "description": "С какого дня"
     },
     {
      "name": "date_to",
      "in": "query",
      "required": false,
      "schema": {
       "anyOf": [
        {
         "type": "string",
         "format": "date"
        },
        {
         "type": "null"
        }
       ],
       "description": "По какой день включительно",
       "title": "Date To"
      },
      "description": "По какой день включительно"
     }
    ],
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "type": "array",
         "items": {
          "$ref": "#/components/schemas/PartnerBookingOut"
         },
         "title": "Response P Bookings V1 Partner Bookings Get"
        }
       }
      }
     },
     "401": {
      "description": "Нет ключа, ключ неверен или отозван"
     },
     "403": {
      "description": "Модуль «Интеграции» не подключён клубу"
     },
     "429": {
      "description": "Превышен лимит запросов в минуту; заголовок Retry-After — через сколько секунд"
     },
     "422": {
      "description": "Validation Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/HTTPValidationError"
        }
       }
      }
     }
    }
   }
  },
  "/v1/partner/bookings/{booking_id}": {
   "get": {
    "tags": [
     "API партнёра"
    ],
    "summary": "Бронь",
    "description": "Одна бронь этого ключа. Чужая или несуществующая — 404 booking_not_found.",
    "operationId": "p_booking_v1_partner_bookings__booking_id__get",
    "security": [
     {
      "Ключ партнёра": []
     }
    ],
    "parameters": [
     {
      "name": "booking_id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "title": "Booking Id"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/PartnerBookingOut"
        }
       }
      }
     },
     "401": {
      "description": "Нет ключа, ключ неверен или отозван"
     },
     "403": {
      "description": "Модуль «Интеграции» не подключён клубу"
     },
     "429": {
      "description": "Превышен лимит запросов в минуту; заголовок Retry-After — через сколько секунд"
     },
     "422": {
      "description": "Validation Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/HTTPValidationError"
        }
       }
      }
     }
    }
   }
  },
  "/v1/partner/bookings/{booking_id}/cancel": {
   "post": {
    "tags": [
     "API партнёра"
    ],
    "summary": "Отменить бронь",
    "description": "Отмена своей брони до начала игры. Денег бронь партнёра не брала, возвращать нечего. Повтор отмены ничего не меняет и отвечает той же бронью.",
    "operationId": "p_cancel_v1_partner_bookings__booking_id__cancel_post",
    "security": [
     {
      "Ключ партнёра": []
     }
    ],
    "parameters": [
     {
      "name": "booking_id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "title": "Booking Id"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/PartnerBookingOut"
        }
       }
      }
     },
     "401": {
      "description": "Нет ключа, ключ неверен или отозван"
     },
     "403": {
      "description": "Модуль «Интеграции» не подключён клубу"
     },
     "429": {
      "description": "Превышен лимит запросов в минуту; заголовок Retry-After — через сколько секунд"
     },
     "404": {
      "description": "booking_not_found"
     },
     "409": {
      "description": "already_started — игра уже началась"
     },
     "422": {
      "description": "Validation Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/HTTPValidationError"
        }
       }
      }
     }
    }
   }
  },
  "/v1/partner/matches": {
   "get": {
    "tags": [
     "API партнёра"
    ],
    "summary": "Матчи",
    "description": "Сыгранные матчи клуба за период: счёт, победитель, игроки (имя и первая буква фамилии). Матчи, которые кто-то из игроков скрыл, и отменённые клубом не отдаются. По умолчанию — две недели по сегодняшний день, период не больше 92 дней, новые первыми.",
    "operationId": "p_matches_v1_partner_matches_get",
    "security": [
     {
      "Ключ партнёра": []
     }
    ],
    "parameters": [
     {
      "name": "date_from",
      "in": "query",
      "required": false,
      "schema": {
       "anyOf": [
        {
         "type": "string",
         "format": "date"
        },
        {
         "type": "null"
        }
       ],
       "description": "С какого дня",
       "title": "Date From"
      },
      "description": "С какого дня"
     },
     {
      "name": "date_to",
      "in": "query",
      "required": false,
      "schema": {
       "anyOf": [
        {
         "type": "string",
         "format": "date"
        },
        {
         "type": "null"
        }
       ],
       "description": "По какой день включительно",
       "title": "Date To"
      },
      "description": "По какой день включительно"
     },
     {
      "name": "limit",
      "in": "query",
      "required": false,
      "schema": {
       "type": "integer",
       "maximum": 500,
       "minimum": 1,
       "description": "Сколько матчей вернуть",
       "default": 100,
       "title": "Limit"
      },
      "description": "Сколько матчей вернуть"
     }
    ],
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "type": "array",
         "items": {
          "$ref": "#/components/schemas/PartnerMatch"
         },
         "title": "Response P Matches V1 Partner Matches Get"
        }
       }
      }
     },
     "401": {
      "description": "Нет ключа, ключ неверен или отозван"
     },
     "403": {
      "description": "Модуль «Интеграции» не подключён клубу"
     },
     "429": {
      "description": "Превышен лимит запросов в минуту; заголовок Retry-After — через сколько секунд"
     },
     "422": {
      "description": "Validation Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/HTTPValidationError"
        }
       }
      }
     }
    }
   }
  },
  "/v1/partner/matches/{match_id}": {
   "get": {
    "tags": [
     "API партнёра"
    ],
    "summary": "Результат матча",
    "description": "Один матч клуба. Скрытый игроком, отменённый, чужой или несуществующий — 404 match_not_found.",
    "operationId": "p_match_v1_partner_matches__match_id__get",
    "security": [
     {
      "Ключ партнёра": []
     }
    ],
    "parameters": [
     {
      "name": "match_id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "title": "Match Id"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/PartnerMatch"
        }
       }
      }
     },
     "401": {
      "description": "Нет ключа, ключ неверен или отозван"
     },
     "403": {
      "description": "Модуль «Интеграции» не подключён клубу"
     },
     "429": {
      "description": "Превышен лимит запросов в минуту; заголовок Retry-After — через сколько секунд"
     },
     "422": {
      "description": "Validation Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/HTTPValidationError"
        }
       }
      }
     }
    }
   }
  }
 },
 "components": {
  "schemas": {
   "HTTPValidationError": {
    "properties": {
     "detail": {
      "items": {
       "$ref": "#/components/schemas/ValidationError"
      },
      "type": "array",
      "title": "Detail"
     }
    },
    "type": "object",
    "title": "HTTPValidationError"
   },
   "PartnerBookingIn": {
    "properties": {
     "day": {
      "type": "string",
      "format": "date",
      "title": "Day",
      "description": "День, ГГГГ-ММ-ДД"
     },
     "time": {
      "type": "string",
      "pattern": "^\\d{2}:\\d{2}$",
      "title": "Time",
      "description": "Начало, ЧЧ:ММ — одно из времён из /slots"
     },
     "courtId": {
      "anyOf": [
       {
        "type": "string",
        "maxLength": 64
       },
       {
        "type": "null"
       }
      ],
      "title": "Courtid",
      "description": "Корт; не указан — первый свободный"
     },
     "customerName": {
      "type": "string",
      "maxLength": 80,
      "title": "Customername",
      "description": "Имя гостя для администратора клуба; контакты гостя не передаются",
      "default": ""
     },
     "externalRef": {
      "type": "string",
      "maxLength": 64,
      "pattern": "^[A-Za-z0-9._:-]*$",
      "title": "Externalref",
      "description": "Номер брони у партнёра; повтор с тем же номером вернёт ту же бронь",
      "default": ""
     }
    },
    "type": "object",
    "required": [
     "day",
     "time"
    ],
    "title": "PartnerBookingIn"
   },
   "PartnerBookingOut": {
    "properties": {
     "id": {
      "type": "string",
      "title": "Id",
      "description": "Номер брони"
     },
     "courtId": {
      "type": "string",
      "title": "Courtid",
      "description": "Номер корта"
     },
     "court": {
      "type": "string",
      "title": "Court",
      "description": "Название корта"
     },
     "day": {
      "type": "string",
      "format": "date",
      "title": "Day",
      "description": "День"
     },
     "start": {
      "type": "string",
      "title": "Start",
      "description": "Начало, ЧЧ:ММ"
     },
     "durationMin": {
      "type": "integer",
      "title": "Durationmin",
      "description": "Длительность в минутах"
     },
     "status": {
      "type": "string",
      "title": "Status",
      "description": "confirmed — действует, cancelled — отменена"
     },
     "price": {
      "type": "integer",
      "title": "Price",
      "description": "Цена в валюте клуба"
     },
     "payment": {
      "type": "string",
      "title": "Payment",
      "description": "at_club — оплата в клубе"
     },
     "customerName": {
      "type": "string",
      "title": "Customername",
      "description": "Имя гостя, как передал партнёр"
     },
     "externalRef": {
      "type": "string",
      "title": "Externalref",
      "description": "Номер брони у партнёра"
     },
     "duplicate": {
      "type": "boolean",
      "title": "Duplicate",
      "description": "true — бронь с этим externalRef уже была, новая не создана",
      "default": false
     },
     "sandbox": {
      "type": "boolean",
      "title": "Sandbox",
      "description": "true — бронь песочницы, корт не занят",
      "default": false
     }
    },
    "type": "object",
    "required": [
     "id",
     "courtId",
     "court",
     "day",
     "start",
     "durationMin",
     "status",
     "price",
     "payment",
     "customerName",
     "externalRef"
    ],
    "title": "PartnerBookingOut"
   },
   "PartnerClub": {
    "properties": {
     "id": {
      "type": "string",
      "title": "Id",
      "description": "Код клуба"
     },
     "name": {
      "type": "string",
      "title": "Name",
      "description": "Название"
     },
     "address": {
      "type": "string",
      "title": "Address",
      "description": "Адрес"
     },
     "timeZone": {
      "type": "string",
      "title": "Timezone",
      "description": "Часовой пояс клуба; все дни и время в API — местные"
     },
     "openFrom": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Openfrom",
      "description": "Открытие, ЧЧ:ММ"
     },
     "openTo": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Opento",
      "description": "Закрытие, ЧЧ:ММ"
     },
     "slotMinutes": {
      "type": "integer",
      "title": "Slotminutes",
      "description": "Длительность брони в минутах"
     },
     "bookingDepthDays": {
      "type": "integer",
      "title": "Bookingdepthdays",
      "description": "На сколько дней вперёд можно бронировать"
     },
     "sandbox": {
      "type": "boolean",
      "title": "Sandbox",
      "description": "true — ключ песочницы, данные выдуманные"
     }
    },
    "type": "object",
    "required": [
     "id",
     "name",
     "address",
     "timeZone",
     "openFrom",
     "openTo",
     "slotMinutes",
     "bookingDepthDays",
     "sandbox"
    ],
    "title": "PartnerClub"
   },
   "PartnerCourt": {
    "properties": {
     "id": {
      "type": "string",
      "title": "Id",
      "description": "Номер корта"
     },
     "name": {
      "type": "string",
      "title": "Name",
      "description": "Название"
     },
     "indoor": {
      "type": "boolean",
      "title": "Indoor",
      "description": "Крытый"
     },
     "sport": {
      "type": "string",
      "title": "Sport",
      "description": "Вид спорта: padel, tennis, pickleball, squash, badminton"
     }
    },
    "type": "object",
    "required": [
     "id",
     "name",
     "indoor",
     "sport"
    ],
    "title": "PartnerCourt"
   },
   "PartnerMatch": {
    "properties": {
     "id": {
      "type": "string",
      "title": "Id",
      "description": "Номер матча"
     },
     "day": {
      "type": "string",
      "format": "date",
      "title": "Day",
      "description": "День"
     },
     "start": {
      "type": "string",
      "title": "Start",
      "description": "Начало, ЧЧ:ММ"
     },
     "courtId": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Courtid",
      "description": "Номер корта; null — корт не найден"
     },
     "court": {
      "type": "string",
      "title": "Court",
      "description": "Название корта"
     },
     "sets": {
      "items": {
       "$ref": "#/components/schemas/PartnerSet"
      },
      "type": "array",
      "title": "Sets",
      "description": "Счёт по сетам"
     },
     "winnerTeam": {
      "type": "integer",
      "title": "Winnerteam",
      "description": "Победитель: 1 или 2"
     },
     "players": {
      "items": {
       "$ref": "#/components/schemas/PartnerPlayer"
      },
      "type": "array",
      "title": "Players",
      "description": "Игроки по командам"
     },
     "bookingId": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Bookingid",
      "description": "Бронь этого ключа, к которой относится матч; null — бронь не ваша или её нет"
     }
    },
    "type": "object",
    "required": [
     "id",
     "day",
     "start",
     "courtId",
     "court",
     "sets",
     "winnerTeam",
     "players",
     "bookingId"
    ],
    "title": "PartnerMatch"
   },
   "PartnerPlayer": {
    "properties": {
     "team": {
      "type": "integer",
      "title": "Team",
      "description": "Команда: 1 или 2"
     },
     "name": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Name",
      "description": "Имя и первая буква фамилии; null — имени нет"
     }
    },
    "type": "object",
    "required": [
     "team",
     "name"
    ],
    "title": "PartnerPlayer"
   },
   "PartnerSet": {
    "properties": {
     "team1": {
      "type": "integer",
      "title": "Team1",
      "description": "Геймы команды 1"
     },
     "team2": {
      "type": "integer",
      "title": "Team2",
      "description": "Геймы команды 2"
     }
    },
    "type": "object",
    "required": [
     "team1",
     "team2"
    ],
    "title": "PartnerSet"
   },
   "PartnerSlot": {
    "properties": {
     "time": {
      "type": "string",
      "title": "Time",
      "description": "Начало, ЧЧ:ММ"
     },
     "freeCourtIds": {
      "items": {
       "type": "string"
      },
      "type": "array",
      "title": "Freecourtids",
      "description": "Свободные корты"
     },
     "price": {
      "type": "integer",
      "title": "Price",
      "description": "Цена за бронь в валюте клуба по сетке клуба"
     }
    },
    "type": "object",
    "required": [
     "time",
     "freeCourtIds",
     "price"
    ],
    "title": "PartnerSlot"
   },
   "PartnerSlots": {
    "properties": {
     "day": {
      "type": "string",
      "format": "date",
      "title": "Day",
      "description": "День"
     },
     "durationMin": {
      "type": "integer",
      "title": "Durationmin",
      "description": "Длительность брони в минутах"
     },
     "items": {
      "items": {
       "$ref": "#/components/schemas/PartnerSlot"
      },
      "type": "array",
      "title": "Items",
      "description": "Время, где свободен хотя бы один корт; прошедшее время не отдаётся"
     }
    },
    "type": "object",
    "required": [
     "day",
     "durationMin",
     "items"
    ],
    "title": "PartnerSlots"
   },
   "ValidationError": {
    "properties": {
     "loc": {
      "items": {
       "anyOf": [
        {
         "type": "string"
        },
        {
         "type": "integer"
        }
       ]
      },
      "type": "array",
      "title": "Location"
     },
     "msg": {
      "type": "string",
      "title": "Message"
     },
     "type": {
      "type": "string",
      "title": "Error Type"
     },
     "input": {
      "title": "Input"
     },
     "ctx": {
      "type": "object",
      "title": "Context"
     }
    },
    "type": "object",
    "required": [
     "loc",
     "msg",
     "type"
    ],
    "title": "ValidationError"
   }
  },
  "securitySchemes": {
   "Ключ партнёра": {
    "type": "apiKey",
    "description": "Ключ партнёра от клуба. Ключ песочницы начинается с aipp_test_.",
    "in": "header",
    "name": "X-Partner-Key"
   }
  }
 }
}
