{"openapi":"3.0.0","info":{"title":"2.4Api","description":"2.4Api","version":"2.0.0"},"servers":[{"url":"https://virtserver.swaggerhub.com/nickvst/2.4api/1.0.0"}],"tags":[{"name":"Authentication","description":"Actions that are related to user authentication"},{"name":"Money Transfer","description":"Actions that have to do with transferring, depositing or withdrawing money"}],"paths":{"/users":{"get":{"tags":["Users"],"description":"Gets all users in the database.","parameters":[{"name":"count","in":"query","description":"The maximum amount of users to return.","required":false,"style":"form","explode":true,"schema":{"type":"integer","default":20}}],"responses":{"200":{"description":"Successfully executed query."},"400":{"description":"Something went wrong when executing query."}},"security":[{"ApiKeyAuth":[]}]},"post":{"tags":["Users"],"description":"Creates a new user in the database.","requestBody":{"description":"Information of the user to add","content":{"application/json":{"schema":{"$ref":"#/components/schemas/User"}}},"required":true},"responses":{"201":{"description":"User has been added successfully."}},"security":[{"ApiKeyAuth":[]}]}},"/users/{id}":{"get":{"tags":["Users"],"description":"Gets the user with the specified ID.","parameters":[{"name":"id","in":"path","description":"The id of the user to get.","required":true,"style":"simple","explode":false,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Successfully executed query."},"400":{"description":"Something went wrong when executing query."}},"security":[{"ApiKeyAuth":[]}]},"put":{"tags":["Users"],"description":"Updates a user with the specified ID.","parameters":[{"name":"id","in":"path","description":"The id of the user to update.","required":true,"style":"simple","explode":false,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Successfully updated user."},"404":{"description":"Could not find user with specified ID."}},"security":[{"ApiKeyAuth":[]}]},"delete":{"tags":["Users"],"description":"Removes a user with the specified ID.","parameters":[{"name":"id","in":"path","description":"The id of the user to delete.","required":true,"style":"simple","explode":false,"schema":{"type":"integer"}}],"responses":{"200":{"description":"User has been deleted."},"404":{"description":"Could not find user with specified ID."}},"security":[{"ApiKeyAuth":[]}]}},"/users/{id}/accounts":{"get":{"tags":["Accounts"],"description":"Gets the accounts that belong to the user specified.","parameters":[{"name":"id","in":"path","description":"The ID that belongs to the user","required":true,"style":"simple","explode":false,"schema":{"type":"integer"}}],"responses":{"200":{"description":"OK"},"403":{"description":"Do not have the right privileges to obtain this user's accounts"},"404":{"description":"Could not find specified user"}},"security":[{"ApiKeyAuth":[]}]}},"/users/register":{"post":{"tags":["Authentication"],"summary":"Registers a user","description":"Creates a new user account, if the UserName is not already in use.","requestBody":{"description":"Body parameters, Possibly coming from textboxes in forms.","content":{"application/x-www-form-urlencoded":{"schema":{"$ref":"#/components/schemas/body"}}},"required":true},"responses":{"201":{"description":"User created","content":{"text/plain":{"schema":{"type":"string","example":"has been created."}}}},"401":{"description":"Unauthenticated, please log in first."},"403":{"description":"Unauthorized, not allowed to create an account."}}}},"/users/login":{"post":{"tags":["Authentication"],"summary":"Logs a user in","description":"Logs a user in and returns an auth-token, if the specified username and password are correct.","requestBody":{"description":"Body parameters, possibly coming from textboxes in Forms.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/User"}}},"required":true},"responses":{"200":{"description":"Logged in","content":{"application/json":{"schema":{"type":"object","items":{"$ref":"#/components/schemas/AuthToken"}}}}},"400":{"description":"The provided username and password are not known."}}}},"/accounts":{"get":{"tags":["Accounts"],"description":"Gets all accounts","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Account"}}}}},"403":{"description":"Unauthorized"}},"security":[{"ApiKeyAuth":[]}]}},"/accounts/{id}":{"get":{"tags":["Accounts"],"description":"Gets account specified by ID","parameters":[{"name":"id","in":"path","description":"ID that belongs to the account","required":true,"schema":{"type":"string","pattern":"[A-Z]{2}\\d{2}[A-Z]{4}\\d{10}"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Account"}}}}},"security":[{"ApiKeyAuth":[]}]},"delete":{"tags":["Accounts"],"description":"Deletes account specified by ID","parameters":[{"name":"id","in":"path","description":"ID that belongs to the account","required":true,"schema":{"type":"string","pattern":"[A-Z]{2}\\d{2}[A-Z]{4}\\d{10}"}}],"responses":{"200":{"description":"OK"},"403":{"description":"Unauthorized"}},"security":[{"ApiKeyAuth":[]}]}},"/transaction":{"post":{"tags":["Money Transfer"],"summary":"transfer money","description":"calling this allows you to tranfer money to an IBAN account","operationId":"transfer","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Transaction"}}}},"responses":{"200":{"description":"Money successfully transferred"},"400":{"description":"Invalid amount entered"},"404":{"description":"From or To IBAN does not exist"}},"security":[{"ApiKeyAuth":[]}]}},"/deposit":{"post":{"tags":["Money Transfer"],"summary":"Deposit money","description":"Deposits money in a user's account (by adding physical money to the bank's account, and then transferring it to the user). Must be performed by a user authenticated as ATM.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Deposit"}}}},"responses":{"200":{"description":"OK","content":{"text/plain":{"schema":{"type":"string","example":"success response"}}}},"400":{"description":"Bad request, IBAN string must be a valid IBAN and amount has to be a positive number."},"401":{"description":"User is either not logged in as user to ATM, or ATM is not logged in as ATM."},"404":{"description":"Resource not found."}},"security":[{"ApiKeyAuth":[]}]}},"/withdraw":{"post":{"tags":["Money Transfer"],"summary":"Withdraw money","description":"Withdraws money from a user's account (transfers it to the account belonging to the bank, and then removes it from that account). Must be performed by a user authenticated as ATM.","operationId":"withdraw","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Withdraw"}}}},"responses":{"200":{"description":"money successfully withdrawn"},"202":{"description":"invalid amount entered"},"404":{"description":"from iban does not exist"}},"security":[{"ApiKeyAuth":[]}]}}},"components":{"schemas":{"Account":{"required":["balance","iban","owner","type"],"type":"object","properties":{"iban":{"pattern":"[A-Z]{2}\\d{2}[A-Z]{4}\\d{10}","type":"string"},"balance":{"type":"number","format":"double"},"type":{"type":"string","enum":["current","savings"]},"owner":{"type":"integer"},"transactionDayLimit":{"minimum":0,"type":"number"},"transactionAmountLimit":{"minimum":0,"type":"number","format":"double"},"balanceLimit":{"maximum":0,"type":"number","format":"double"}}},"User":{"required":["FirstName","LastName","Password","Username"],"type":"object","properties":{"firstName":{"type":"string","example":"FirstName"},"lastName":{"type":"string","example":"LastName"},"username":{"maxLength":16,"minLength":4,"type":"string","example":"Username"},"password":{"maxLength":20,"minLength":6,"type":"string","example":"Password"}}},"AuthToken":{"type":"object","properties":{"AuthToken":{"type":"string","example":"1234-abcd-5678-efgh"}},"description":"AuthToken that gets returned if the specified username and password is correct."},"Transaction":{"type":"object","properties":{"from":{"type":"string","pattern":"NL\\d{2}INHO\\d{10}"},"to":{"type":"string","pattern":"[A-Z]{2}\\d{2}[A-Z]{4}\\d{10}"},"amount":{"type":"integer","minimum":1}}},"Deposit":{"type":"object","properties":{"to":{"type":"string","pattern":"NL\\d{2}INHO\\d{10}"},"amount":{"type":"integer","minimum":1}}},"Withdraw":{"type":"object","properties":{"from":{"type":"string","pattern":"NL\\d{2}INHO\\d{10}"},"amount":{"type":"integer","minimum":1}}},"body":{"required":["passWord","userName"],"type":"object","properties":{"firstName":{"type":"string"},"lastName":{"type":"string"},"userName":{"type":"string"},"passWord":{"type":"string"}}}},"securitySchemes":{"BasicAuth":{"type":"http","scheme":"basic"},"ApiKeyAuth":{"type":"apiKey","name":"X-Auth-Token","in":"header"}}}}