tolulope-od/banka

View on GitHub
swagger.json

Summary

Maintainability
Test Coverage
{
  "basePath": "/",
  "host": "bankaa-app.herokuapp.com",
  "info": {
    "title": "Banka App",
    "version": "1.0.0",
    "license": {
      "name": "MIT",
      "url": "https://opensource.org/licenses/MIT"
    },
    "contact": "tolulope.od@gmail.com",
    "description": "A light-weight core banking application that supports a single bank and allows users create bank accounts and make withdrawals & deposits by visiting a local branch"
  },
  "tags": [
    {
      "name": "Auth",
      "description": "API Endpoints for authentication users in the app"
    },
    {
      "name": "Accounts",
      "description": "API Endpoints for bank accounts in the app"
    },
    {
      "name": "Transactions",
      "description": "API Endpoints for transactions in the app"
    },
    {
      "name": "User",
      "description": "API Endpoints for user actions in the app"
    }
  ],
  "schemes": ["http", "https"],
  "consumes": ["application/json", "application/x-www-form-urlencoded"],
  "produces": ["application/json"],
  "paths": {
    "/": {
      "get": {
        "summary": "Server Test Response",
        "consumes": ["application/json"],
        "description": "Test server response",
        "parameters": [],
        "produces": ["application/json"],
        "responses": {
          "200": {
            "schema": {
              "type": "object",
              "properties": {
                "message": {
                  "type": "string",
                  "example": "BANKA APP API RESPONSE SUCCESSFUL"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/auth/signup": {
      "post": {
        "tags": ["Auth"],
        "description": "Registration of new users in the app",
        "summary": "User Registration",
        "consumes": ["application/json", "application/x-www-form-urlencoded"],
        "parameters": [
          {
            "name": "body",
            "in": "body",
            "required": true,
            "description": "The request body containing all required, first name, last name, email and password fields required for registration",
            "example": {
              "firstName": "Albus",
              "lastName": "Dumbledore",
              "email": "albus@hogwarts.com",
              "password": "thephoenix"
            }
          }
        ],
        "produces": ["application/json"],
        "responses": {
          "201": {
            "description": "Successful User Registration",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 201
                },
                "data": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "token": {
                        "type": "string"
                      },
                      "id": {
                        "type": "number"
                      },
                      "firstName": {
                        "type": "string"
                      },
                      "lastName": {
                        "type": "string"
                      },
                      "email": {
                        "type": "string"
                      },
                      "type": {
                        "type": "string"
                      },
                      "createdAt": {
                        "type": "string"
                      }
                    }
                  },
                  "example": [
                    {
                      "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6NiwiZW1haWwiOiJzbmFwZUBob2d3YXJ0cy5jb20iLCJ0eXBlIjoiY2xpZW50IiwiZmlyc3ROYW1lIjoiU2V2ZXJ1cyIsImxhc3ROYW1lIjoiU25hcGUiLCJpc0FkbWluIjpmYWxzZSwiaWF0IjoxNTU1OTUwNjU1LCJleHAiOjE1NTU5NTQyNTV9.C04ZzO2jQy-87NTURx2yPg63dsI88pCxG4DqPH8sZLQ",
                      "id": 6,
                      "firstName": "Severus",
                      "lastName": "Snape",
                      "email": "snape@hogwarts.com",
                      "type": "client",
                      "createdAt": "2019-04-22T16:30:55.066Z"
                    }
                  ]
                },
                "message": {
                  "type": "string",
                  "example": "User registered successfully"
                }
              }
            }
          },
          "400": {
            "description": "Required Field Missing",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 400
                },
                "error": {
                  "type": "string",
                  "example": "First name is required"
                }
              }
            }
          },
          "409": {
            "description": "Duplicate Email",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 409
                },
                "error": {
                  "type": "string",
                  "example": "User already exists"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/auth/signin": {
      "post": {
        "tags": ["Auth"],
        "description": "Log in a registered user",
        "summary": "User Login",
        "consumes": ["application/json", "application/x-www-form-urlencoded"],
        "parameters": [
          {
            "name": "body",
            "in": "body",
            "required": true,
            "description": "Email and Password of Returning the User",
            "example": {
              "email": "someexisting@user.com",
              "password": "examplePassword1"
            }
          }
        ],
        "produces": ["application/json"],
        "responses": {
          "200": {
            "description": "Successful User Login",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 200
                },
                "data": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "token": {
                        "type": "string"
                      },
                      "id": {
                        "type": "number"
                      },
                      "firstName": {
                        "type": "string"
                      },
                      "lastName": {
                        "type": "string"
                      },
                      "email": {
                        "type": "string"
                      },
                      "type": {
                        "type": "string"
                      }
                    }
                  },
                  "example": [
                    {
                      "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6NSwiZW1haWwiOiJkYXJ0aEB0aGVlbXBpcmUuY29tIiwidHlwZSI6ImNsaWVudCIsImZpcnN0TmFtZSI6IkRhcnRoIiwibGFzdE5hbWUiOiJWYWRlciIsImlzQWRtaW4iOmZhbHNlLCJpYXQiOjE1NTU5NTA2NTUsImV4cCI6MTU1NTk1NDI1NX0.JlfF8g1YUX8mZSgIlud17CMAfUddONImk9nbqxsJm4Q",
                      "id": 5,
                      "firstName": "Darth",
                      "lastName": "Vader",
                      "email": "darth@theempire.com",
                      "type": "client"
                    }
                  ]
                },
                "message": {
                  "type": "string",
                  "example": "Login successful"
                }
              }
            }
          },
          "400": {
            "description": "Failed user login when a required field is missing",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 400
                },
                "error": {
                  "type": "string",
                  "example": "Email is required"
                }
              }
            }
          },
          "403": {
            "description": "Failed user login when the user does not exist",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 403
                },
                "error": {
                  "type": "string",
                  "example": "User not found"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/accounts": {
      "get": {
        "tags": ["Accounts"],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "description": "Return all user bank accounts in the system",
        "summary": "Get All Bank Accounts",
        "consumes": ["application/json"],
        "parameters": [],
        "produces": ["application/json"],
        "responses": {
          "200": {
            "description": "All accounts returned successfully",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 200
                },
                "data": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "number"
                      },
                      "accountNumber": {
                        "type": "number"
                      },
                      "createdOn": {
                        "type": "string"
                      },
                      "owner": {
                        "type": "number"
                      },
                      "type": {
                        "type": "string"
                      },
                      "status": {
                        "type": "string"
                      },
                      "balance": {
                        "type": "number"
                      }
                    },
                    "required": [
                      "id",
                      "accountNumber",
                      "createdOn",
                      "owner",
                      "type",
                      "status",
                      "balance"
                    ]
                  },
                  "example": [
                    {
                      "id": 1,
                      "accountNumber": 5563847290,
                      "createdOn": "2019-02-11T23:00:00.000Z",
                      "owner": 2,
                      "type": "current",
                      "status": "active",
                      "balance": 349876358.08
                    },
                    {
                      "id": 3,
                      "accountNumber": 9427914582,
                      "createdOn": "2019-04-10T14:58:51.203Z",
                      "owner": 2,
                      "type": "savings",
                      "status": "active",
                      "balance": 0
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Error when authorization token is invalid",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 401
                },
                "error": {
                  "type": "string",
                  "example": "Token is invalid"
                }
              }
            }
          },
          "403": {
            "description": "Error when an unauthorized user tries to access a protected route",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 403
                },
                "error": {
                  "type": "string",
                  "example": "Unauthorized! You must be logged in for that"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": ["Accounts"],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "description": "User can create a bank account",
        "summary": "Create Bank Account",
        "consumes": ["application/json"],
        "parameters": [
          {
            "name": "body",
            "in": "body",
            "required": true,
            "example": {
              "type": "current"
            },
            "description": "The type of account to be created"
          }
        ],
        "produces": ["application/json"],
        "responses": {
          "201": {
            "description": "Successful creation of a bank account for a user",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 201
                },
                "data": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "number"
                      },
                      "accountNumber": {
                        "type": "number"
                      },
                      "createdOn": {
                        "type": "string"
                      },
                      "owner": {
                        "type": "number"
                      },
                      "type": {
                        "type": "string"
                      },
                      "status": {
                        "type": "string"
                      },
                      "balance": {
                        "type": "number"
                      }
                    },
                    "required": [
                      "id",
                      "accountNumber",
                      "createdOn",
                      "owner",
                      "type",
                      "status",
                      "balance"
                    ]
                  },
                  "example": [
                    {
                      "id": 1,
                      "accountNumber": 5563847290,
                      "createdOn": "2019-02-11T23:00:00.000Z",
                      "owner": 2,
                      "type": "current",
                      "status": "active",
                      "balance": 0.0
                    }
                  ]
                },
                "message": {
                  "type": "string",
                  "example": "Account created successfully"
                }
              }
            }
          },
          "400": {
            "description": "Error when the required field to create a bank account is missing",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 400
                },
                "error": {
                  "type": "string",
                  "example": "Account type is required"
                }
              }
            }
          },
          "401": {
            "description": "Error when a user that's not a 'client' attempts to create a bank account",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 401
                },
                "error": {
                  "type": "string",
                  "example": "Only clients can create accounts"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/accounts/{accountNumber}/transactions": {
      "get": {
        "tags": ["Accounts"],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "description": "View an account’s transaction history",
        "summary": "View Account Transaction History",
        "consumes": ["application/json"],
        "parameters": [
          {
            "name": "accountNumber",
            "in": "path",
            "required": true,
            "description": "The account number's transactions to fetch"
          }
        ],
        "produces": ["application/json"],
        "responses": {
          "200": {
            "description": "All transactions returned successfully",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 200
                },
                "data": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "transactionId": {
                        "type": "number"
                      },
                      "type": {
                        "type": "string"
                      },
                      "accountNumber": {
                        "type": "number"
                      },
                      "owner": {
                        "type": "number"
                      },
                      "cashier": {
                        "type": "string"
                      },
                      "amount": {
                        "type": "number"
                      },
                      "oldbalance": {
                        "type": "number"
                      },
                      "newbalance": {
                        "type": "number"
                      },
                      "createdon": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "transactionId",
                      "type",
                      "accountNumber",
                      "owner",
                      "type",
                      "amount",
                      "oldbalance",
                      "newbalance",
                      "createdon"
                    ]
                  },
                  "example": [
                    {
                      "transactionid": 1,
                      "type": "credit",
                      "accountnumber": "8897654324",
                      "owner": 3,
                      "cashier": 4,
                      "amount": "400500.0",
                      "oldbalance": "7264935.97",
                      "newbalance": "7665435.97",
                      "createdon": "2019-04-22T16:32:15.625Z"
                    },
                    {
                      "transactionid": 2,
                      "type": "debit",
                      "accountnumber": "8897654324",
                      "owner": 3,
                      "cashier": 1,
                      "amount": "100500.0",
                      "oldbalance": "7264935.97",
                      "newbalance": "7665435.97",
                      "createdon": "2019-04-22T16:32:15.625Z"
                    },
                    {
                      "transactionid": 4,
                      "type": "credit",
                      "accountnumber": "8897654324",
                      "owner": 3,
                      "cashier": 4,
                      "amount": "500900.05",
                      "oldbalance": "7665435.97",
                      "newbalance": "8166336.02",
                      "createdon": "2019-04-22T16:32:25.574Z"
                    },
                    {
                      "transactionid": 5,
                      "type": "debit",
                      "accountnumber": "8897654324",
                      "owner": 3,
                      "cashier": 4,
                      "amount": "90900.05",
                      "oldbalance": "8166336.02",
                      "newbalance": "8075435.97",
                      "createdon": "2019-04-22T16:32:25.610Z"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Error when authorization token is invalid",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 401
                },
                "error": {
                  "type": "string",
                  "example": "Token is invalid"
                }
              }
            }
          },
          "403": {
            "description": "Error when an unauthorized user tries to access a protected route",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 403
                },
                "error": {
                  "type": "string",
                  "example": "Unauthorized! You must be logged in for that"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/accounts?status=active": {
      "get": {
        "tags": ["Accounts"],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "description": "Return all active accounts in the system",
        "summary": "Get All Active Bank Accounts",
        "consumes": ["application/json"],
        "parameters": [],
        "produces": ["application/json"],
        "responses": {
          "200": {
            "description": "All accounts returned successfully",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 200
                },
                "data": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "number"
                      },
                      "accountNumber": {
                        "type": "number"
                      },
                      "createdOn": {
                        "type": "string"
                      },
                      "owner": {
                        "type": "number"
                      },
                      "type": {
                        "type": "string"
                      },
                      "status": {
                        "type": "string"
                      },
                      "balance": {
                        "type": "number"
                      }
                    },
                    "required": [
                      "id",
                      "accountNumber",
                      "createdOn",
                      "owner",
                      "type",
                      "status",
                      "balance"
                    ]
                  },
                  "example": [
                    {
                      "id": 1,
                      "accountNumber": 5563847290,
                      "createdOn": "2019-02-11T23:00:00.000Z",
                      "owner": 2,
                      "type": "current",
                      "status": "active",
                      "balance": 349876358.08
                    },
                    {
                      "id": 3,
                      "accountNumber": 9427914582,
                      "createdOn": "2019-04-10T14:58:51.203Z",
                      "owner": 2,
                      "type": "savings",
                      "status": "active",
                      "balance": 0
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Error when authorization token is invalid",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 401
                },
                "error": {
                  "type": "string",
                  "example": "Token is invalid"
                }
              }
            }
          },
          "403": {
            "description": "Error when an unauthorized user tries to access a protected route",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 403
                },
                "error": {
                  "type": "string",
                  "example": "Unauthorized! You must be logged in for that"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/accounts?status=dormant": {
      "get": {
        "tags": ["Accounts"],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "description": "Return all dormant accounts in the system",
        "summary": "Get All Dormant Bank Accounts",
        "consumes": ["application/json"],
        "parameters": [],
        "produces": ["application/json"],
        "responses": {
          "200": {
            "description": "All accounts returned successfully",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 200
                },
                "data": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "number"
                      },
                      "accountNumber": {
                        "type": "number"
                      },
                      "createdOn": {
                        "type": "string"
                      },
                      "owner": {
                        "type": "number"
                      },
                      "type": {
                        "type": "string"
                      },
                      "status": {
                        "type": "string"
                      },
                      "balance": {
                        "type": "number"
                      }
                    },
                    "required": [
                      "id",
                      "accountNumber",
                      "createdOn",
                      "owner",
                      "type",
                      "status",
                      "balance"
                    ]
                  },
                  "example": [
                    {
                      "id": 4,
                      "accountNumber": 1458294279,
                      "createdOn": "2019-02-11T23:00:00.000Z",
                      "owner": 3,
                      "type": "current",
                      "status": "dormant",
                      "balance": 349876358.08
                    },
                    {
                      "id": 5,
                      "accountNumber": 9427914582,
                      "createdOn": "2019-04-10T14:58:51.203Z",
                      "owner": 4,
                      "type": "savings",
                      "status": "dormant",
                      "balance": 43323.09
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Error when authorization token is invalid",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 401
                },
                "error": {
                  "type": "string",
                  "example": "Token is invalid"
                }
              }
            }
          },
          "403": {
            "description": "Error when an unauthorized user tries to access a protected route",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 403
                },
                "error": {
                  "type": "string",
                  "example": "Unauthorized! You must be logged in for that"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/accounts/{accountNumber}": {
      "patch": {
        "tags": ["Accounts"],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "description": "Edit a bank account's status",
        "summary": "Edit Bank Account Status",
        "consumes": ["application/json"],
        "parameters": [
          {
            "name": "accountNumber",
            "in": "path",
            "required": true,
            "example": 1263847087,
            "description": "Account Number of the account to be edited"
          },
          {
            "name": "status",
            "in": "body",
            "required": true,
            "example": {
              "status": "dormant"
            },
            "description": "The new status of the account"
          }
        ],
        "produces": ["application/json"],
        "responses": {
          "200": {
            "description": "Successful modification of a bank account's status",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 200
                },
                "data": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "number"
                      },
                      "accountNumber": {
                        "type": "number"
                      },
                      "createdOn": {
                        "type": "string"
                      },
                      "owner": {
                        "type": "number"
                      },
                      "type": {
                        "type": "string"
                      },
                      "status": {
                        "type": "string"
                      },
                      "balance": {
                        "type": "number"
                      }
                    },
                    "required": [
                      "id",
                      "accountNumber",
                      "createdOn",
                      "owner",
                      "type",
                      "status",
                      "balance"
                    ]
                  },
                  "example": [
                    {
                      "id": 4,
                      "accountNumber": 1263847087,
                      "owner": 2,
                      "type": "current",
                      "status": "dormant",
                      "balance": 6358.08
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Error when the account number is greater than the required number",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 400
                },
                "error": {
                  "type": "string",
                  "example": "Account number must be 10 digits"
                }
              }
            }
          },
          "401": {
            "description": "Error when a non-staff user tries to modify an account's status",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 401
                },
                "error": {
                  "type": "string",
                  "example": "You are not authorized to carry out that action"
                }
              }
            }
          },
          "404": {
            "description": "Error when trying to modify the status of an non-existent bank account",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 404
                },
                "error": {
                  "type": "string",
                  "example": "Account does not exist"
                }
              }
            }
          },
          "409": {
            "description": "Error when trying to set the status of an account to its already current state",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 409
                },
                "error": {
                  "type": "string",
                  "example": "Account is already dormant"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": ["Accounts"],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "description": "Return a single user's bank account in the system",
        "summary": "View an Account's details",
        "consumes": ["application/json"],
        "parameters": [
          {
            "name": "accountNumber",
            "in": "path",
            "required": true
          }
        ],
        "produces": ["application/json"],
        "responses": {
          "200": {
            "description": "Success when the account is found and details are returned",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 200
                },
                "data": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "number"
                      },
                      "accountNumber": {
                        "type": "number"
                      },
                      "createdOn": {
                        "type": "string"
                      },
                      "owner": {
                        "type": "number"
                      },
                      "type": {
                        "type": "string"
                      },
                      "status": {
                        "type": "string"
                      },
                      "balance": {
                        "type": "number"
                      }
                    },
                    "required": [
                      "id",
                      "accountNumber",
                      "createdOn",
                      "owner",
                      "type",
                      "status",
                      "balance"
                    ]
                  },
                  "example": [
                    {
                      "id": 3,
                      "accountNumber": 9427914582,
                      "createdOn": "2019-04-10T14:58:51.203Z",
                      "owner": 2,
                      "type": "savings",
                      "status": "active",
                      "balance": 8943898.07
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 400
                },
                "error": {
                  "type": "string",
                  "example": "Account number can only contain digits"
                }
              }
            }
          },
          "404": {
            "description": "Error when the account doesn't exist",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 404
                },
                "error": {
                  "type": "string",
                  "example": "Account does not exist"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": ["Accounts"],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "description": "Delete a user's account in the system",
        "summary": "Delete Bank Account",
        "consumes": ["application/json"],
        "parameters": [
          {
            "name": "accountNumber",
            "in": "path",
            "required": true,
            "description": "The number of the account to be deleted must be specified in the request parameters"
          }
        ],
        "produces": ["application/json"],
        "responses": {
          "200": {
            "description": "Success when an account is deleted",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 200
                },
                "message": {
                  "type": "string",
                  "example": "Account deleted successfully"
                }
              }
            }
          },
          "401": {
            "description": "Error when an unauthorized used tries to delete a bank account",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 401
                },
                "error": {
                  "type": "string",
                  "example": "You are not authorized to delete an account"
                }
              }
            }
          },
          "404": {
            "description": "Error when trying to delete an account that doesn't exist inthe system",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 404
                },
                "error": {
                  "type": "string",
                  "example": "Account does not exist"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/user/{userEmail}/accounts": {
      "get": {
        "tags": ["User"],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "description": "Fetch all accounts a user owns",
        "summary": "Get all accounts a user owns",
        "consumes": ["application/json"],
        "parameters": [
          {
            "name": "userEmail",
            "in": "path",
            "required": true,
            "example": "thor@avengers.com",
            "description": "The user who's accounts will be retrieved must have the email specified in the request parameters"
          }
        ],
        "produces": ["application/json"],
        "responses": {
          "200": {
            "description": "Success when an accounts for a user are found",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 200
                },
                "data": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "number"
                      },
                      "accountnumber": {
                        "type": "string"
                      },
                      "owner": {
                        "type": "number"
                      },
                      "type": {
                        "type": "string"
                      },
                      "status": {
                        "type": "string"
                      },
                      "balance": {
                        "type": "string"
                      },
                      "owneremail": {
                        "type": "string"
                      },
                      "createdon": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "id",
                      "accountnumber",
                      "owner",
                      "type",
                      "status",
                      "balance",
                      "owneremail",
                      "createdon"
                    ]
                  },
                  "example": [
                    {
                      "id": 3,
                      "accountnumber": "8894354324",
                      "owner": 3,
                      "type": "current",
                      "status": "draft",
                      "balance": "43435.97",
                      "owneremail": "olegunnar@manutd.com",
                      "createdon": "2019-04-22T16:30:45.163Z"
                    },
                    {
                      "id": 2,
                      "accountnumber": "8897654324",
                      "owner": 3,
                      "type": "savings",
                      "status": "draft",
                      "balance": "8075435.97",
                      "owneremail": "olegunnar@manutd.com",
                      "createdon": "2019-04-22T16:30:45.163Z"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Error if an invalid email is provided",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 400
                },
                "error": {
                  "type": "string",
                  "example": "Please provide a valid email address"
                }
              }
            }
          },
          "403": {
            "description": "Error when a non-staff user tries to get list of accounts of other users",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 403
                },
                "error": {
                  "type": "string",
                  "example": "You are not authorized to carry out that action"
                }
              }
            }
          },
          "404": {
            "description": "Error when the accounts owner does not exist in the db",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 404
                },
                "error": {
                  "type": "string",
                  "example": "User not found"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/transactions/{accountNumber}/credit": {
      "post": {
        "tags": ["Transactions"],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "description": "Credit a user's account",
        "summary": "Credit Transaction",
        "consumes": ["application/json"],
        "parameters": [
          {
            "name": "accountNumber",
            "in": "path",
            "required": true,
            "example": 8897654324,
            "description": "Account number of the account to be credited"
          },
          {
            "name": "body",
            "in": "body",
            "required": true,
            "example": {
              "creditAmount": 39000.98
            }
          }
        ],
        "produces": ["application/json"],
        "responses": {
          "200": {
            "description": "Response when an account has been credited successfully",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 200
                },
                "data": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "transactionId": {
                        "type": "number"
                      },
                      "accountNumber": {
                        "type": "string"
                      },
                      "amount": {
                        "type": "string"
                      },
                      "cashier": {
                        "type": "number"
                      },
                      "transactionType": {
                        "type": "string"
                      },
                      "accountBalance": {
                        "type": "string"
                      }
                    }
                  },
                  "example": [
                    {
                      "transactionId": 4,
                      "accountNumber": "8897654324",
                      "amount": "500900.05",
                      "cashier": 4,
                      "transactionType": "credit",
                      "accountBalance": "8166336.02"
                    }
                  ]
                },
                "message": {
                  "type": "string",
                  "example": "Account credited successfully"
                }
              }
            }
          },
          "400": {
            "description": "Error when trying to credit an account with a negative figure",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 400
                },
                "error": {
                  "type": "string",
                  "example": "Credit transaction cannot be less than 1 Naira"
                }
              }
            }
          },
          "401": {
            "description": "Error when a non-staff user tries to credit an account",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 401
                },
                "error": {
                  "type": "string",
                  "example": "You are not authorized to carry out that action"
                }
              }
            }
          },
          "404": {
            "description": "Error when trying to credit an account that does not exist",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 404
                },
                "error": {
                  "type": "string",
                  "example": "Account does not exist"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/transactions/{accountNumber}/debit": {
      "post": {
        "tags": ["Transactions"],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "description": "Debit a user's bank account in the system",
        "summary": "Debit Transaction",
        "consumes": ["application/json"],
        "parameters": [
          {
            "name": "accountNumber",
            "in": "path",
            "required": true,
            "example": 8897654324,
            "description": "Account number of the account to be debited"
          },
          {
            "name": "debitAmount",
            "in": "body",
            "required": true,
            "example": {
              "debitAmount": 39000.98
            },
            "description": "The amount to be debited from the account"
          }
        ],
        "produces": ["application/json"],
        "responses": {
          "200": {
            "description": "Response when an account is debited succesffuly",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 200
                },
                "data": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "transactionId": {
                        "type": "number"
                      },
                      "accountNumber": {
                        "type": "string"
                      },
                      "amount": {
                        "type": "string"
                      },
                      "cashier": {
                        "type": "number"
                      },
                      "transactionType": {
                        "type": "string"
                      },
                      "accountBalance": {
                        "type": "string"
                      }
                    }
                  },
                  "example": [
                    {
                      "transactionId": 5,
                      "accountNumber": "8897654324",
                      "amount": "90900.05",
                      "cashier": 4,
                      "transactionType": "debit",
                      "accountBalance": "8075435.97"
                    }
                  ]
                },
                "message": {
                  "type": "string",
                  "example": "Account debited successfully"
                }
              }
            }
          },
          "400": {
            "description": "Error when the transaction amount contains non-numbers",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 400
                },
                "error": {
                  "type": "string",
                  "example": "Transactions can only contain digits"
                }
              }
            }
          },
          "401": {
            "description": "Error when a non-staff user tries to debit an account",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 401
                },
                "error": {
                  "type": "string",
                  "example": "You are not authorized to carry out that action"
                }
              }
            }
          },
          "404": {
            "description": "Error when trying to debit an account that doesn't exist",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 404
                },
                "error": {
                  "type": "string",
                  "example": "Account does not exist"
                }
              }
            }
          },
          "409": {
            "description": "Error if the amount being debited is more than the account balance",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 409
                },
                "error": {
                  "type": "string",
                  "example": "Insufficient funds, your account balance is 8075435.97"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/transactions/{transactionId}": {
      "get": {
        "tags": ["Transactions"],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "description": "Get a single transaction record",
        "summary": "Fetch a single transaction",
        "consumes": ["application/json"],
        "parameters": [
          {
            "name": "transactionId",
            "in": "path",
            "required": true,
            "example": 2,
            "description": "The ID of the transaction record we wish to view"
          }
        ],
        "produces": ["application/json"],
        "responses": {
          "200": {
            "description": "Response when transaction is found and returned",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 200
                },
                "data": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "transactionid": {
                        "type": "number"
                      },
                      "type": {
                        "type": "string"
                      },
                      "accountnumber": {
                        "type": "string"
                      },
                      "owner": {
                        "type": "number"
                      },
                      "cashier": {
                        "type": "number"
                      },
                      "amount": {
                        "type": "string"
                      },
                      "oldbalance": {
                        "type": "string"
                      },
                      "newbalance": {
                        "type": "string"
                      },
                      "createdon": {
                        "type": "string"
                      }
                    }
                  },
                  "example": [
                    {
                      "transactionid": 3,
                      "type": "credit",
                      "accountnumber": "5563847290",
                      "owner": 2,
                      "cashier": 4,
                      "amount": "400500.0",
                      "oldbalance": "7264935.97",
                      "newbalance": "7665435.97",
                      "createdon": "2019-04-22T16:30:45.163Z"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Response when the ID is not correctly formatted",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 400
                },
                "error": {
                  "type": "string",
                  "example": "Transaction ID can only contain digits"
                }
              }
            }
          },
          "404": {
            "description": "Response when an the transaction is not found",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 404
                },
                "error": {
                  "type": "string",
                  "example": "Transaction does not exist"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/users": {
      "get": {
        "tags": ["User"],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "description": "Get all Staff",
        "summary": "Return all staff in the DB",
        "consumes": ["application/json", "application/x-www-form-urlencoded"],
        "parameters": [],
        "produces": ["application/json"],
        "responses": {
          "200": {
            "description": "All staff returned successfully",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 200
                },
                "data": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "number"
                      },
                      "firstname": {
                        "type": "string"
                      },
                      "lastname": {
                        "type": "string"
                      },
                      "email": {
                        "type": "string"
                      },
                      "type": {
                        "type": "string"
                      },
                      "isadmin": {
                        "type": "boolean"
                      },
                      "createdat": {
                        "type": "string"
                      }
                    }
                  },
                  "example": [
                    {
                      "id": 1,
                      "firstname": "Obiwan",
                      "lastname": "Kenobi",
                      "email": "obiwan@therebellion.com",
                      "type": "staff",
                      "isadmin": true,
                      "createdat": "2019-05-09T09:04:36.181Z"
                    },
                    {
                      "id": 4,
                      "firstname": "Kylo",
                      "lastname": "Ren",
                      "email": "kyloren@vader.com",
                      "type": "staff",
                      "isadmin": false,
                      "createdat": "2019-05-09T09:04:36.181Z"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Non-staff trying to access the route",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 401
                },
                "error": {
                  "type": "string",
                  "example": "Not allowed!"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": ["User"],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "description": "Change a user type from client to staff",
        "summary": "Change a user type",
        "consumes": ["application/json"],
        "parameters": [
          {
            "name": "userDetail",
            "in": "body",
            "required": true,
            "example": {
              "userEmail": "thor@avengers.com"
            },
            "description": "The email of the user to be upgraded to a staff"
          }
        ],
        "produces": ["application/json"],
        "responses": {
          "200": {
            "description": "Successful modification of a user's type from client to staff",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 200
                },
                "data": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "number"
                      },
                      "firstname": {
                        "type": "string"
                      },
                      "lastname": {
                        "type": "string"
                      },
                      "email": {
                        "type": "string"
                      },
                      "password": {
                        "type": "string"
                      },
                      "isadmin": {
                        "type": "boolean"
                      },
                      "type": {
                        "type": "string"
                      },
                      "createdat": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "id",
                      "firstname",
                      "lastname",
                      "email",
                      "password",
                      "isadmin",
                      "type",
                      "createdat"
                    ]
                  },
                  "example": [
                    {
                      "id": 2,
                      "firstname": "Thor",
                      "lastname": "Odinson",
                      "email": "thor@avengers.com",
                      "password": "$2b$10$pPe2BPbZ.zHkWqEn5h8Zce9jmEExa8NxJKAFVjDAxvz7zEzd.GE1G",
                      "isadmin": false,
                      "type": "staff",
                      "createdat": "2019-04-26T00:35:24.414Z"
                    }
                  ]
                },
                "message": {
                  "type": "string",
                  "example": "User is now a staff"
                }
              }
            }
          },
          "400": {
            "description": "Error when the aemail address is not properly formatted",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 400
                },
                "error": {
                  "type": "string",
                  "example": "APlease provide a valid email address"
                }
              }
            }
          },
          "401": {
            "description": "Error when a non-admin user tries to modify user type",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 401
                },
                "error": {
                  "type": "string",
                  "example": "You are not allowed to carry out that action"
                }
              }
            }
          },
          "404": {
            "description": "Error when trying to modify user type of a non-existing user",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 404
                },
                "error": {
                  "type": "string",
                  "example": "User not found"
                }
              }
            }
          },
          "409": {
            "description": "Error when trying to change an already existing staff to a staff user",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 409
                },
                "error": {
                  "type": "string",
                  "example": "User is already a staff"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": ["User"],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "description": "Create a Staff",
        "summary": "Admin Staff Registration",
        "consumes": ["application/json", "application/x-www-form-urlencoded"],
        "parameters": [
          {
            "name": "newStaff",
            "in": "body",
            "required": true,
            "description": "The request body containing all required, first name, last name, email and admin fields required for registration",
            "example": {
              "firstName": "Albus",
              "lastName": "Dumbledore",
              "email": "albus@hogwarts.com",
              "admin": true
            }
          }
        ],
        "produces": ["application/json"],
        "responses": {
          "201": {
            "description": "Successful Creation of a Staff",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 201
                },
                "data": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "token": {
                        "type": "string"
                      },
                      "id": {
                        "type": "number"
                      },
                      "firstName": {
                        "type": "string"
                      },
                      "lastName": {
                        "type": "string"
                      },
                      "email": {
                        "type": "string"
                      },
                      "type": {
                        "type": "string"
                      },
                      "isadmin": {
                        "type": "boolean"
                      },
                      "createdAt": {
                        "type": "string"
                      }
                    }
                  },
                  "example": [
                    {
                      "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6NiwiZW1haWwiOiJzbmFwZUBob2d3YXJ0cy5jb20iLCJ0eXBlIjoiY2xpZW50IiwiZmlyc3ROYW1lIjoiU2V2ZXJ1cyIsImxhc3ROYW1lIjoiU25hcGUiLCJpc0FkbWluIjpmYWxzZSwiaWF0IjoxNTU1OTUwNjU1LCJleHAiOjE1NTU5NTQyNTV9.C04ZzO2jQy-87NTURx2yPg63dsI88pCxG4DqPH8sZLQ",
                      "id": 7,
                      "firstName": "Clark",
                      "lastName": "Kent",
                      "email": "notsuperman@test.com",
                      "type": "staff",
                      "isadmin": true,
                      "createdat": "2019-04-22T16:30:55.066Z"
                    }
                  ]
                },
                "message": {
                  "type": "string",
                  "example": "Staff created successfully"
                }
              }
            }
          },
          "400": {
            "description": "Required Field Missing",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 400
                },
                "error": {
                  "type": "string",
                  "example": "First name is required"
                }
              }
            }
          },
          "409": {
            "description": "Duplicate Email",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 409
                },
                "error": {
                  "type": "string",
                  "example": "Staff already exists"
                }
              }
            }
          }
        }
      }
    },
    "*": {
      "get": {
        "tags": ["Errors"],
        "description": "Error Returned for undefined routes",
        "summary": "Undefined Route Error",
        "parameters": [],
        "produces": ["application/json"],
        "responses": {
          "404": {
            "description": "Response when an undefined route is accessed",
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "number",
                  "example": 404
                },
                "error": {
                  "type": "string",
                  "example": "Not Found"
                }
              }
            }
          }
        }
      }
    }
  },
  "securityDefinitions": {
    "bearerAuth": {
      "type": "apiKey",
      "name": "Authorization",
      "scheme": "bearer",
      "in": "header",
      "description": "For accessing the API routes other than Sign In and Sign Up, a valid JWT must be added in all the requests in the the Authorization Header"
    }
  },
  "swagger": "2.0"
}