{
  "swagger": "2.0",
  "info": {
    "version": "1.0.0",
    "title": "Abills API",
    "license": {
      "name": "Apache 2.0",
      "url": "http://www.apache.org/licenses/LICENSE-2.0.html"
    }
  },
  "host": "demo.abills.net.ua:9443",
  "basePath": "/api.cgi",
  "tags": [
    {
      "name": "Users",
      "description": "Работа с пользователями"
    }
  ],
  "schemes": [
    "https"
  ],
  "paths": {
    "/users/login": {
      "post": {
        "tags": [
          "Users"
        ],
        "summary": "Авторизация пользователя",
        "operationId": "loginUser",
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "name": "login",
            "in": "query",
            "description": "Логин пользователя",
            "required": true,
            "type": "string"
          },
          {
            "name": "password",
            "in": "query",
            "description": "Пароль пользователя",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "200": {
            "description": "Успешное выполнение",
            "schema": {
              "$ref": "#/definitions/inline_response_200"
            }
          }
        }
      }
    },
    "/users/": {
      "post": {
        "tags": [
          "Users"
        ],
        "summary": "Добавить нового пользователя",
        "operationId": "addUser",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "in": "body",
            "name": "body",
            "description": "Параметры, которые нужно указать",
            "required": true,
            "schema": {
              "$ref": "#/definitions/User"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "успешное выполнение",
            "schema": {
              "$ref": "#/definitions/UserCreated"
            }
          }
        },
        "security": [
          {
            "KEY": []
          }
        ]
      }
    },
    "/users/{UID}": {
      "get": {
        "tags": [
          "Users"
        ],
        "summary": "Получить пользователя по UID",
        "description": "Возвращает пользователя",
        "operationId": "getUserByUID",
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "name": "UID",
            "in": "path",
            "description": "UID пользователя в биллинге",
            "required": true,
            "type": "integer",
            "format": "int64"
          }
        ],
        "responses": {
          "200": {
            "description": "Успешное выполнение",
            "schema": {
              "$ref": "#/definitions/User"
            }
          },
          "404": {
            "description": "Пользователь не найден",
            "schema": {
              "$ref": "#/definitions/inline_response_404"
            }
          }
        },
        "security": [
          {
            "KEY": []
          }
        ]
      },
      "put": {
        "tags": [
          "Users"
        ],
        "summary": "Обновить информацию о пользователе",
        "operationId": "updateUser",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "name": "UID",
            "in": "path",
            "description": "UID пользователь",
            "required": true,
            "type": "integer",
            "format": "int64"
          },
          {
            "in": "body",
            "name": "body",
            "description": "Pet object that needs to be added to the store",
            "required": true,
            "schema": {
              "$ref": "#/definitions/User"
            }
          }
        ],
        "responses": {
          "400": {
            "description": "Invalid ID supplied"
          },
          "404": {
            "description": "Pet not found"
          },
          "405": {
            "description": "Validation exception"
          }
        },
        "security": [
          {
            "KEY": []
          }
        ]
      },
      "delete": {
        "tags": [
          "Users"
        ],
        "summary": "Удалить пользователя",
        "operationId": "deleteUser",
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "name": "UID",
            "in": "path",
            "description": "UID пользователя",
            "required": true,
            "type": "integer",
            "format": "int64"
          }
        ],
        "responses": {
          "404": {
            "description": "Пользователь не найден",
            "schema": {
              "$ref": "#/definitions/inline_response_404"
            }
          }
        },
        "security": [
          {
            "KEY": []
          }
        ]
      }
    },
    "/users/{UID}/contacts": {
      "get": {
        "tags": [
          "Users"
        ],
        "summary": "Получить контакты пользователя по UID",
        "description": "Возвращает контакты пользователя",
        "operationId": "getUserContactsByUID",
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "name": "UID",
            "in": "path",
            "description": "UID пользователя в биллинге",
            "required": true,
            "type": "integer",
            "format": "int64"
          }
        ],
        "responses": {
          "200": {
            "description": "Успешное выполнение",
            "schema": {
              "$ref": "#/definitions/ContactsArray"
            }
          },
          "404": {
            "description": "Пользователь не найден",
            "schema": {
              "$ref": "#/definitions/inline_response_404"
            }
          }
        },
        "security": [
          {
            "KEY": []
          }
        ]
      },
      "post": {
        "tags": [
          "Users"
        ],
        "summary": "Добавление контакта пользователю",
        "operationId": "updateUserContact",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "name": "UID",
            "in": "path",
            "description": "UID пользователь",
            "required": true,
            "type": "integer",
            "format": "int64"
          },
          {
            "in": "body",
            "name": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/User"
            }
          }
        ],
        "responses": {
          "404": {
            "description": "Пользователь не найден",
            "schema": {
              "$ref": "#/definitions/inline_response_404"
            }
          }
        },
        "security": [
          {
            "KEY": []
          }
        ]
      },
      "put": {
        "tags": [
          "Users"
        ],
        "summary": "Обновить информацию о пользователе",
        "operationId": "updateUserConctact",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "name": "UID",
            "in": "path",
            "description": "UID пользователь",
            "required": true,
            "type": "integer",
            "format": "int64"
          },
          {
            "in": "body",
            "name": "body",
            "description": "Pet object that needs to be added to the store",
            "required": true,
            "schema": {
              "$ref": "#/definitions/User"
            }
          }
        ],
        "responses": {
          "400": {
            "description": "Invalid ID supplied"
          },
          "404": {
            "description": "Pet not found"
          },
          "405": {
            "description": "Validation exception"
          }
        },
        "security": [
          {
            "KEY": []
          }
        ]
      },
      "delete": {
        "tags": [
          "Users"
        ],
        "summary": "Удалить пользователя",
        "operationId": "deleteUserContact",
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "name": "UID",
            "in": "path",
            "description": "UID пользователя",
            "required": true,
            "type": "integer",
            "format": "int64"
          }
        ],
        "responses": {
          "404": {
            "description": "Пользователь не найден",
            "schema": {
              "$ref": "#/definitions/inline_response_404"
            }
          }
        },
        "security": [
          {
            "KEY": []
          }
        ]
      }
    },
    "/users/contacts": {
      "post": {
        "tags": [
          "Users"
        ],
        "summary": "Получить контакты",
        "description": "Возвращает контакты пользователей",
        "operationId": "getContacts",
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "in": "body",
            "name": "body",
            "description": "Параметры для фильтрации контактов",
            "required": true,
            "schema": {
              "$ref": "#/definitions/Contacts"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Успешное выполнение",
            "schema": {
              "$ref": "#/definitions/ContactsArray"
            }
          }
        },
        "security": [
          {
            "KEY": []
          }
        ]
      }
    }
  },
  "securityDefinitions": {
    "KEY": {
      "type": "apiKey",
      "name": "KEY",
      "in": "header"
    }
  },
  "definitions": {
    "User": {
      "type": "object",
      "properties": {
        "login": {
          "type": "string",
          "example": "testUser"
        },
        "password": {
          "type": "string",
          "example": "123456"
        },
        "createBill": {
          "type": "integer"
        }
      }
    },
    "UserCreated": {
      "type": "object",
      "properties": {
        "preAdd": {
          "type": "integer",
          "example": 1
        },
        "total": {
          "type": "integer",
          "example": 0
        },
        "insertId": {
          "type": "string",
          "example": "17"
        },
        "uid": {
          "type": "string",
          "example": "32"
        },
        "affected": {
          "type": "integer",
          "example": 1
        },
        "login": {
          "type": "string",
          "example": "testUser"
        }
      }
    },
    "Contacts": {
      "type": "object",
      "properties": {
        "value": {
          "type": "string",
          "example": "test@gmail.com"
        },
        "type": {
          "type": "string",
          "example": "_SHOW",
          "description": "_SHOW - отобразить поле"
        },
        "typeName": {
          "type": "string",
          "example": "_SHOW"
        }
      }
    },
    "ContactsArray": {
      "type": "array",
      "items": {
        "$ref": "#/definitions/ContactsArray_inner"
      }
    },
    "ApiResponse": {
      "type": "object",
      "properties": {
        "code": {
          "type": "integer",
          "format": "int32"
        },
        "type": {
          "type": "string"
        },
        "message": {
          "type": "string"
        }
      }
    },
    "inline_response_200": {
      "type": "object",
      "properties": {
        "login": {
          "type": "string",
          "example": "testuser"
        },
        "sid": {
          "type": "string",
          "example": "sW44EJZLyWDMeXAV"
        },
        "uid": {
          "type": "string",
          "example": "5690"
        }
      }
    },
    "inline_response_404": {
      "type": "object",
      "properties": {
        "errstr": {
          "type": "string",
          "example": "ERROR_NOT_EXIST"
        },
        "errno": {
          "type": "integer",
          "example": 2
        }
      }
    },
    "ContactsArray_inner": {
      "type": "object",
      "properties": {
        "id": {
          "type": "integer",
          "example": 1
        },
        "uid": {
          "type": "string",
          "example": "132"
        },
        "value": {
          "type": "string",
          "example": "test@gmail.com"
        },
        "typeName": {
          "type": "string",
          "example": "Email"
        }
      }
    }
  }
}