swagger: "2.0"
basePath: /api
info:
  title: AltoroJ REST API
  version: 1.0.2
  x-apisguru-categories:
    - security
  x-origin:
    - format: swagger
      url: https://demo.testfire.net/swagger/properties.json
      version: "2.0"
  x-providerName: testfire.net
  x-serviceName: altoroj
tags:
  - description: Login mechanism
    name: 1. Login
  - description: View account information
    name: 2. Account
  - description: Transfer funds between accounts
    name: 3. Transfer
  - description: Submit and review feedback
    name: 4. Feedback
  - description: Add and change user details
    name: 5. Admin
  - description: Logout mechanism
    name: 6. Logout
paths:
  /account:
    get:
      description: Returns a list of all the accounts owned by the user
      operationId: getAccount
      parameters:
        - description: Authorization token (provided upon successful login)
          in: header
          name: Authorization
          required: true
          type: string
      produces:
        - application/json
      responses:
        "200":
          description: Successful operation
        "401":
          description: Unauthorized request
        "500":
          description: Internal server error
      tags:
        - 2. Account
  "/account/{accountNo}":
    get:
      description: Returns details about a specific account
      operationId: getAccountBalance
      parameters:
        - description: Authorization token (provided upon successful login)
          in: header
          name: Authorization
          required: true
          type: string
        - description: Account id
          in: path
          name: accountNo
          required: true
          type: string
      produces:
        - application/json
      responses:
        "200":
          description: Successful operation
        "401":
          description: Unauthorized request
        "500":
          description: Internal server error
      tags:
        - 2. Account
  "/account/{accountNo}/transactions":
    get:
      description: Returns the last 10 transactions attached to an account
      operationId: showLastTenTransactions
      parameters:
        - description: Authorization token (provided upon successful login)
          in: header
          name: Authorization
          required: true
          type: string
        - description: Account id
          in: path
          name: accountNo
          required: true
          type: string
      produces:
        - application/json
      responses:
        "200":
          description: Successful operation
        "401":
          description: Unauthorized request
        "500":
          description: Internal server error
      tags:
        - 2. Account
    post:
      consumes:
        - application/json
      description: Return transactions between 2 specific dates
      operationId: getTransactions
      parameters:
        - description: Authorization token (provided upon successful login)
          in: header
          name: Authorization
          required: true
          type: string
        - description: Account id
          in: path
          name: accountNo
          required: true
          type: string
        - description: A start date and an end date
          in: body
          name: body
          required: true
          schema:
            $ref: "#/definitions/dates"
      produces:
        - application/json
      responses:
        "200":
          description: Successful operation
        "400":
          description: "Bad parameters: Please check provided values"
        "401":
          description: Unauthorized request
        "501":
          description: Internal server error
      tags:
        - 2. Account
  /admin/addUser:
    post:
      consumes:
        - application/json
      description: Add new user
      operationId: addUser
      parameters:
        - description: Authorization token (provided upon successful login)
          in: header
          name: Authorization
          required: true
          type: string
        - description: Details of a new user including first name, last name, desired username and a password
          in: body
          name: body
          required: true
          schema:
            $ref: "#/definitions/newUser"
      produces:
        - application/json
      responses:
        "200":
          description: Successful operation
        "400":
          description: Unauthorized request
        "401":
          description: Unauthorized request
        "500":
          description: Error creating user
      tags:
        - 5. Admin
  /admin/changePassword:
    post:
      consumes:
        - application/json
      description: Change user password
      operationId: changePassword
      parameters:
        - description: Authorization token (provided upon successful login)
          in: header
          name: Authorization
          required: true
          type: string
        - description: Information about the user password to be changed including id and new password
          in: body
          name: body
          required: true
          schema:
            $ref: "#/definitions/changePassword"
      produces:
        - application/json
      responses:
        "200":
          description: Successful operation
        "400":
          description: Unauthorized request
        "401":
          description: Unauthorized request
        "500":
          description: Error in changing the username password
      tags:
        - 5. Admin
  /feedback/submit:
    post:
      consumes:
        - application/json
      description: Submit feedback for the bank
      operationId: sendFeedback
      parameters:
        - description: Feedback details including name, email the subject and complete message
          in: body
          name: body
          required: true
          schema:
            $ref: "#/definitions/feedback"
      produces:
        - application/json
      responses:
        "200":
          description: Successful operation
        "401":
          description: Unauthorized request
        "500":
          description: Internal server error
      tags:
        - 4. Feedback
  "/feedback/{feedbackId}":
    get:
      description: Retrieve feedback
      operationId: getFeedback
      parameters:
        - description: Authorization token (provided upon successful login)
          in: header
          name: Authorization
          required: true
          type: string
        - in: path
          name: feedbackId
          required: true
          type: string
      produces:
        - application/json
      responses:
        "200":
          description: Successful operation
        "400":
          description: "Bad parameters: Please check provided values"
        "401":
          description: Unauthorized request
        "500":
          description: Internal server error
      tags:
        - 4. Feedback
  /login:
    get:
      description: If a user is loggedin the username will be returned
      operationId: checkLogin
      parameters:
        - description: Authorization token (provided upon successful login)
          in: header
          name: Authorization
          required: true
          type: string
      produces:
        - application/json
      responses:
        "200":
          description: Logged in
        "401":
          description: Logged out
      summary: Check if any user is logged in
      tags:
        - 1. Login
    post:
      consumes:
        - application/json
      description: After a successful login a token is returned. This is a Bearer token. To authenticate with it use the Authorization header and set value to Bearer empty space and the token value.
      operationId: login
      parameters:
        - description: Username and password combination to allow users to log-in
          in: body
          name: body
          required: true
          schema:
            $ref: "#/definitions/login"
      produces:
        - application/json
      responses:
        "200":
          description: Success message when login is complete
        "400":
          description: "Bad parameters: Please check provided values"
        "500":
          description: "Internal server error: Please see error message or logs for details"
      summary: Login method
      tags:
        - 1. Login
  /logout:
    get:
      description: Logout from the bank
      operationId: doLogOut
      parameters: []
      produces:
        - application/json
      responses:
        "200":
          description: Successful operation
        "500":
          description: "Unauthorized request "
      tags:
        - 6. Logout
  /transfer:
    post:
      consumes:
        - application/json
      description: Transfer money between two accounts
      operationId: trasnfer
      parameters:
        - description: Authorization token (provided upon successful login)
          in: header
          name: Authorization
          required: true
          type: string
        - description: Transfer details including ammount, sender and receiver
          in: body
          name: body
          required: true
          schema:
            $ref: "#/definitions/transfer"
      produces:
        - application/json
      responses:
        "200":
          description: Successful operation
        "400":
          description: "Bad parameters: Please check provided values"
        "501":
          description: Internal server error
      tags:
        - 3. Transfer
definitions:
  changePassword:
    properties:
      password1:
        example: Th1s!sz3nu3Passv0rd
        format: password
        type: string
      password2:
        example: Th1s!sz3nu3Passv0rd
        format: password
        type: string
      username:
        example: jdoe
        type: string
    required:
      - username
      - passwrod1
      - password2
    type: object
  dates:
    properties:
      endDate:
        example: 2012-03-17
        format: date
        type: string
      startDate:
        example: 2012-03-12
        format: date
        type: string
    required:
      - startDate
      - endDate
    type: object
  feedback:
    properties:
      email:
        example: jsmtih@altoromutual.com
        format: email
        type: string
      message:
        example: I like the new look of your applicaiton
        type: string
      name:
        example: J Smith
        type: string
      subject:
        example: Amazing web design
        type: string
    required:
      - name
      - email
      - subject
      - message
    type: object
  login:
    properties:
      password:
        example: demo1234
        type: string
      username:
        example: jsmith
        type: string
    required:
      - username
      - password
    type: object
  newUser:
    properties:
      firstname:
        example: Bilbo
        type: string
      lastname:
        example: Baggins
        type: string
      password1:
        example: S3l3ctS0methingStr0ng5AsP@ssword
        format: password
        type: string
      password2:
        example: S3l3ctS0methingStr0ng5AsP@ssword
        format: password
        type: string
      username:
        example: bilbob
        type: string
        uniqueItems: true
    required:
      - firstname
      - lastname
      - username
      - password1
      - password2
    type: object
  transfer:
    properties:
      fromAccount:
        example: "800003"
        type: string
      toAccount:
        example: "800002"
        type: string
      transferAmount:
        example: "200"
        type: string
    required:
      - toAccount
      - fromAccount
      - transferAmount
    type: object
