{
  "swagger": "2.0",
  "info": {
    "version": "1.0.0",
    "title": "feedbot-server",
    "description": "A basic API for storage of feedbot trees and their versions",
    "termsOfService": "http://swagger.io/terms/",
    "contact": {
      "name": "Jan Dvorak",
      "email": "dvorakj@gmail.com",
      "url": "http://feedyou.agency"
    },
    "license": {
      "name": "MIT",
      "url": "http://github.com/gruntjs/grunt/blob/master/LICENSE-MIT"
    }
  },
  "host": "feedbot-server.azurewebsites.net",
  "basePath": "/api",
  "schemes": ["http"],
  "consumes": ["application/json"],
  "produces": ["application/json"],
  "paths": {
    "/users": {
      "get": {
        "description": "Returns all users in store\n",
        "operationId": "findUsers",
        "responses": {
          "200": {
            "description": "bot response",
            "schema": {
              "type": "array",
              "items": {
                "$ref": "#/definitions/User"
              }
            }
          },
          "default": {
            "description": "unexpected error",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          }
        }
      },
      "post": {
        "description": "Creates a new user in the store.",
        "operationId": "addUser",
        "parameters": [
          {
            "name": "user",
            "in": "body",
            "description": "New user object",
            "required": true,
            "schema": {
              "$ref": "#/definitions/UserInfo"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "user response",
            "schema": {
              "$ref": "#/definitions/User"
            }
          },
          "default": {
            "description": "unexpected error",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          }
        }
      }
    },
    "/users/{id}": {
      "patch": {
        "description": "Updates user in the store.",
        "operationId": "updateUser",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "ID of user to update",
            "required": true,
            "type": "string"
          },
          {
            "name": "user",
            "in": "body",
            "description": "User object",
            "required": true,
            "schema": {
              "$ref": "#/definitions/UserInfo"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "user response",
            "schema": {
              "$ref": "#/definitions/User"
            }
          },
          "default": {
            "description": "unexpected error",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          }
        }
      }
    },
    "/users/domains": {
      "get": {
        "description": "Returns all user domains in store\n",
        "operationId": "getDomains",
        "responses": {
          "200": {
            "description": "bot response",
            "schema": {
              "type": "array",
              "items": {
                "$ref": "#/definitions/Domain"
              }
            }
          },
          "default": {
            "description": "unexpected error",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          }
        }
      },
      "post": {
        "description": "Creates a new domain in the store.",
        "operationId": "addDomain",
        "parameters": [
          {
            "name": "domain",
            "in": "body",
            "description": "New domain object",
            "required": true,
            "schema": {
              "$ref": "#/definitions/DomainInfo"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "domain response",
            "schema": {
              "$ref": "#/definitions/Domain"
            }
          },
          "default": {
            "description": "unexpected error",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          }
        }
      }
    },
    "/users/domains/{domain}": {
      "patch": {
        "description": "Updates domain in the store.",
        "operationId": "updateDomain",
        "parameters": [
          {
            "name": "domain",
            "in": "path",
            "description": "ID of domain to update",
            "required": true,
            "type": "string"
          },
          {
            "name": "domain",
            "in": "body",
            "description": "Domain object",
            "required": true,
            "schema": {
              "$ref": "#/definitions/Domain"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "domain response",
            "schema": {
              "$ref": "#/definitions/Domain"
            }
          },
          "default": {
            "description": "unexpected error",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          }
        }
      },
      "delete": {
        "description": "deletes a single domain based on the ID supplied",
        "operationId": "deleteDomain",
        "parameters": [
          {
            "name": "domain",
            "in": "path",
            "description": "ID of domain to delete",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "204": {
            "description": "domain deleted"
          },
          "default": {
            "description": "unexpected error",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          }
        }
      }
    },
    "/bots": {
      "get": {
        "description": "Returns all bots in store\n",
        "operationId": "findBots",
        "responses": {
          "200": {
            "description": "bot response",
            "schema": {
              "type": "array",
              "items": {
                "$ref": "#/definitions/Bot"
              }
            }
          },
          "default": {
            "description": "unexpected error",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          }
        }
      },
      "post": {
        "description": "Creates a new bot in the store.",
        "operationId": "addBot",
        "parameters": [
          {
            "name": "bot",
            "in": "body",
            "description": "New bot object",
            "required": true,
            "schema": {
              "$ref": "#/definitions/NewBot"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "bot response",
            "schema": {
              "$ref": "#/definitions/Bot"
            }
          },
          "default": {
            "description": "unexpected error",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          }
        }
      }
    },
    "/bots/{id}": {
      "get": {
        "description": "Returns a bot based on a single ID",
        "operationId": "findBotById",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "ID of bot to fetch",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "200": {
            "description": "bot response",
            "schema": {
              "$ref": "#/definitions/Bot"
            }
          },
          "default": {
            "description": "unexpected error",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          }
        }
      },
      "put": {
        "description": "Updates bot in the store.",
        "operationId": "updateBot",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "ID of bot to update",
            "required": true,
            "type": "string"
          },
          {
            "name": "bot",
            "in": "body",
            "description": "Bot object",
            "required": true,
            "schema": {
              "$ref": "#/definitions/Bot"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "bot response",
            "schema": {
              "$ref": "#/definitions/Bot"
            }
          },
          "default": {
            "description": "unexpected error",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          }
        }
      },
      "delete": {
        "description": "deletes a single bot based on the ID supplied",
        "operationId": "deleteBot",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "ID of pet to delete",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "204": {
            "description": "bot deleted"
          },
          "default": {
            "description": "unexpected error",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          }
        }
      }
    },
    "/bots/{id}/channels": {
      "get": {
        "description": "gets channels",
        "operationId": "findBotChannels",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "ID of bot",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "200": {
            "description": "bot response",
            "schema": {
              "type": "array",
              "items": {
                "$ref": "#/definitions/Channel"
              }
            }
          },
          "default": {
            "description": "unexpected error",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          }
        }
      },
      "post": {
        "description": "creates a channel",
        "operationId": "createBotChannel",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "ID of bot",
            "required": true,
            "type": "string"
          },
          {
            "name": "channel",
            "in": "body",
            "description": "Channel object",
            "required": true,
            "schema": {
              "$ref": "#/definitions/Channel"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "bot response",
            "schema": {
              "$ref": "#/definitions/Channel"
            }
          },
          "default": {
            "description": "unexpected error",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          }
        }
      }
    },
    "/bots/{id}/channels/{channelId}": {
      "patch": {
        "description": "updates the channel",
        "operationId": "updateBotChannel",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "ID of bot",
            "required": true,
            "type": "string"
          },
          {
            "name": "channelId",
            "in": "path",
            "description": "ID of a channel",
            "required": true,
            "type": "string"
          },
          {
            "name": "channel",
            "in": "body",
            "description": "Channel object",
            "required": true,
            "schema": {
              "$ref": "#/definitions/Channel"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "bot response",
            "schema": {
              "$ref": "#/definitions/Channel"
            }
          },
          "default": {
            "description": "unexpected error",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          }
        }
      },
      "delete": {
        "description": "deletes the channel",
        "operationId": "updateBotChannel",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "ID of bot",
            "required": true,
            "type": "string"
          },
          {
            "name": "channelId",
            "in": "path",
            "description": "ID of a channel",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "204": {
            "description": "bot deleted"
          },
          "default": {
            "description": "unexpected error",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          }
        }
      }
    },
    "/bots/{id}/versions": {
      "get": {
        "description": "Returns list of given bot versions",
        "operationId": "findBotVersions",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "ID of bot",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "200": {
            "description": "bot response",
            "schema": {
              "type": "object",
              "properties": {
                "versions": {
                  "type": "array",
                  "items": {
                    "$ref": "#/definitions/Version"
                  }
                }
              }
            }
          },
          "default": {
            "description": "unexpected error",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          }
        }
      }
    },
    "/bots/{id}/comments": {
      "get": {
        "description": "Returns list of comments for given bot",
        "operationId": "findBotComments",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "ID of bot",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "200": {
            "description": "bot response",
            "schema": {
              "type": "object",
              "properties": {
                "comments": {
                  "type": "array",
                  "items": {
                    "$ref": "#/definitions/Comment"
                  }
                }
              }
            }
          },
          "default": {
            "description": "unexpected error",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          }
        }
      },
      "post": {
        "description": "Creates a new comment for given bot",
        "operationId": "addBotComment",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "ID of bot",
            "required": true,
            "type": "string"
          },
          {
            "name": "comment",
            "in": "body",
            "description": "Comment object",
            "required": true,
            "schema": {
              "$ref": "#/definitions/Comment"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "comment response",
            "schema": {
              "$ref": "#/definitions/Comment"
            }
          },
          "default": {
            "description": "unexpected error",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          }
        }
      }
    },
    "/bots/{id}/hosting": {
      "post": {
        "description": "Create bot hosting",
        "operationId": "createBotHosting",
        "parameters": [{ "name": "id", "in": "path", "required": true, "type": "string" }],
        "responses": {
          "200": {
            "description": "Success response"
          },
          "default": {
            "description": "Unexpected error",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          }
        }
      },
      "patch": {
        "description": "Hosting successfully created",
        "operationId": "hostingSuccessfullyCreated",
        "parameters": [
          { "name": "id", "in": "path", "required": true, "type": "string" },
          { "name": "apiUrl", "in": "query", "required": true, "type": "string" },
          { "name": "directLineSecret", "in": "query", "required": true, "type": "string" },
          { "name": "previewUrl", "in": "query", "required": true, "type": "string" }
        ],
        "responses": {
          "200": {
            "description": "Success response"
          },
          "default": {
            "description": "Unexpected error",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          }
        }
      }
    },
    "/bots/{id}/comments/{commentId}": {
      "patch": {
        "description": "Updates comment",
        "operationId": "updateComment",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "ID of bot to update",
            "required": true,
            "type": "string"
          },
          {
            "name": "commentId",
            "in": "path",
            "description": "ID of comment to update",
            "required": true,
            "type": "string"
          },
          {
            "name": "comment",
            "in": "body",
            "description": "Diff of comment object",
            "required": true,
            "schema": {
              "$ref": "#/definitions/Comment"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "comment response",
            "schema": {
              "$ref": "#/definitions/Comment"
            }
          },
          "default": {
            "description": "unexpected error",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          }
        }
      }
    }
  },
  "definitions": {
    "User": {
      "allOf": [
        {
          "$ref": "#/definitions/UserInfo"
        },
        {
          "type": "object",
          "additionalProperties": true,
          "required": ["source", "id"],
          "properties": {
            "source": {
              "type": "string"
            },
            "id": {
              "type": "string"
            }
          }
        }
      ]
    },
    "Bot": {
      "allOf": [
        {
          "$ref": "#/definitions/NewBot"
        },
        {
          "type": "object",
          "additionalProperties": true,
          "properties": {
            "id": {
              "type": "string"
            }
          }
        }
      ]
    },
    "UserInfo": {
      "type": "object",
      "additionalProperties": true,
      "properties": {
        "email": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "role": {
          "type": "string"
        }
      }
    },
    "Domain": {
      "allOf": [
        {
          "$ref": "#/definitions/DomainInfo"
        },
        {
          "type": "object",
          "additionalProperties": true,
          "required": ["domain", "role"],
          "properties": {
            "domain": {
              "type": "string"
            },
            "role": {
              "type": "string",
              "default": "view",
              "enum": ["view", "comment", "copywrite", "edit", "admin"]
            }
          }
        }
      ]
    },
    "DomainInfo": {
      "type": "object",
      "additionalProperties": true,
      "properties": {
        "name": {
          "type": "string"
        }
      }
    },
    "NewBot": {
      "type": "object",
      "additionalProperties": true,
      "properties": {}
    },
    "Channel": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "type": {
          "type": "string",
          "enum": ["facebook_messenger", "viber", "amio_chat"]
        },
        "facebook_page": {
          "type": "object",
          "properties": {
            "id": {
              "type": "string"
            },
            "access_token": {
              "type": "string"
            }
          },
          "required": ["id", "access_token"]
        },
        "viber": {
          "type": "object",
          "properties": {
            "access_token": {
              "type": "string"
            }
          },
          "required": ["access_token"]
        }
      }
    },
    "Version": {
      "required": ["version", "author"],
      "properties": {
        "version": {
          "type": "integer",
          "format": "int32"
        },
        "timestamp": {
          "type": "integer",
          "format": "int32"
        },
        "title": {
          "type": "string"
        },
        "author": {
          "type": "object",
          "properties": {
            "id": {
              "type": "string"
            },
            "name": {
              "type": "string"
            }
          },
          "required": ["name"]
        },
        "changes": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "timestamp": {
                "type": "integer",
                "format": "int32"
              },
              "title": {
                "type": "string"
              }
            },
            "required": ["timestamp"]
          }
        }
      }
    },
    "Comment": {
      "type": "object",
      "required": ["id", "text", "author", "status"],
      "properties": {
        "id": {
          "type": "string"
        },
        "stepId": {
          "type": "string"
        },
        "dialogId": {
          "type": "string"
        },
        "inReplyTo": {
          "type": "string"
        },
        "text": {
          "type": "string"
        },
        "timestamp": {
          "type": "integer",
          "format": "int32"
        },
        "assignee": {
          "type": "object",
          "properties": {
            "id": {
              "type": "string"
            }
          }
        },
        "author": {
          "type": "object",
          "properties": {
            "id": {
              "type": "string"
            },
            "name": {
              "type": "string"
            }
          },
          "required": ["name"]
        },
        "status": {
          "type": "string",
          "default": "unassigned",
          "enum": ["unassigned", "assigned", "resolved"]
        },
        "resolved": {
          "type": "object",
          "properties": {
            "by": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                }
              },
              "required": ["name"]
            },
            "timestamp": {
              "type": "integer",
              "format": "int32"
            }
          },
          "required": ["by", "timestamp"]
        }
      }
    },
    "Error": {
      "required": ["code", "message"],
      "properties": {
        "code": {
          "type": "integer",
          "format": "int32"
        },
        "message": {
          "type": "string"
        }
      }
    }
  }
}
