diff --git a/.gitignore b/.gitignore index fba0141..ac68c97 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ .idea/* .env -.env.example env Lib Include diff --git a/.env.example b/api/.env.example similarity index 68% rename from .env.example rename to api/.env.example index 921ca00..af67b58 100644 --- a/.env.example +++ b/api/.env.example @@ -5,9 +5,5 @@ MYSQL_DATABASE= MYSQL_USER= MYSQL_PASSWORD= -# Telegram bot api key -BOT_API_KEY="" -NEWS_API_KEY="" - # Flask secret key SECRET_KEY= diff --git a/api/README.md b/api/README.md new file mode 100644 index 0000000..e771473 --- /dev/null +++ b/api/README.md @@ -0,0 +1,41 @@ +# API + +Aktienbot API + +## Development +1. Create virtual environment `python -m venv venv env/Scripts/activate` +2. Install requirements `pip install -r api/requirements.txt` +3. Set environment variables (see list below) + 1. Use `.env`-file in `api` directory like `.env.example` + 2. Or set variables using `export` or `set` commands. (Windows `set`, Linux `export`) +4. Run api `python api/app.py` + +## Environment variables +``` + # Flask secret key + SECRET_KEY= + + # MYSQL Connection + MYSQL_USER= + MYSQL_PASSWORD= + MYSQL_HOST= + MYSQL_PORT= + MYSQL_DATABASE= +``` + +## Docker +``` +docker run -d \ + --name aktienbot_api \ + --hostname aktienbot_api \ + --publish 80:80 \ + --env "SECRET_KEY=" \ + --env "MYSQL_USER=" \ + --env "MYSQL_PASSWORD=" \ + --env "MYSQL_HOST=" \ + --env "MYSQL_PORT=" \ + --env "MYSQL_DATABASE=" \ + --restart unless-stopped \ + registry.flokaiser.com/aktienbot/api:latest +``` +or load environment variables from file by using `--env-file ` \ No newline at end of file diff --git a/documentation/README.md b/documentation/README.md new file mode 100644 index 0000000..bce18b4 --- /dev/null +++ b/documentation/README.md @@ -0,0 +1,20 @@ +# Dokumentation + +## API +- `api/openapi.json` + - OpenAPI-Dokumentation + - von APIFlask generiert + - kann in Postman importiert werden +- `api/postman.json` + - Postman Collection + +## Database +- `database/structure_database.pdf` + - Relationales Modell der Datenbank +- `database/structure_database.uxf` + - Relationales Modell der Datenbank + - Source Datei des Modells + +## Requirements +- `requirements/2022-03-15 Anforderungen an Projekt.pdf` + - Anforderungen an dieses Projekt \ No newline at end of file diff --git a/documentation/api/openapi.json b/documentation/api/openapi.json new file mode 100644 index 0000000..7c9d313 --- /dev/null +++ b/documentation/api/openapi.json @@ -0,0 +1 @@ +{"components":{"schemas":{"AdminData":{"properties":{"admin":{"type":"boolean"},"username":{"type":"string"}},"type":"object"},"DeleteSuccessful":{"properties":{},"type":"object"},"DeleteUser":{"properties":{"username":{"type":"string"}},"type":"object"},"HTTPError":{"properties":{"detail":{"type":"object"},"message":{"type":"string"}},"type":"object"},"Keyword":{"properties":{"keyword":{"type":"string"}},"type":"object"},"KeywordResponse":{"properties":{"keyword":{"type":"string"},"s_id":{"type":"integer"},"user_id":{"type":"integer"}},"type":"object"},"LoginData":{"properties":{"password":{"type":"string"},"username":{"type":"string"}},"type":"object"},"Symbol":{"properties":{"symbol":{"type":"string"}},"type":"object"},"SymbolResponse":{"properties":{"s_id":{"type":"integer"},"symbol":{"type":"string"},"user_id":{"type":"integer"}},"type":"object"},"Token":{"properties":{"token":{"type":"string"}},"type":"object"},"Transaction":{"properties":{"count":{"type":"integer"},"price":{"type":"number"},"symbol":{"type":"string"},"time":{"type":"string"},"user_id":{"type":"integer"}},"type":"object"},"Users":{"properties":{"admin":{"type":"boolean"},"password":{"type":"string"},"telegram_name":{"type":"string"},"user_id":{"type":"integer"},"username":{"type":"string"}},"type":"object"},"ValidationError":{"properties":{"detail":{"properties":{"":{"properties":{"":{"items":{"type":"string"},"type":"array"}},"type":"object"}},"type":"object"},"message":{"type":"string"}},"type":"object"}},"securitySchemes":{"BearerAuth":{"scheme":"Bearer","type":"http"}}},"info":{"description":"Webengineering 2 | Telegram Aktienbot","title":"APIFlask","version":"0.0.1"},"openapi":"3.0.3","paths":{"/api/keyword":{"delete":{"description":"Removes existing keyword for current user","parameters":[],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Keyword"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"properties":{"data":{"$ref":"#/components/schemas/DeleteSuccessful"},"status":{"type":"integer"},"text":{"type":"string"}},"type":"object"}}},"description":"Successful response"},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationError"}}},"description":"Validation error"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPError"}}},"description":"Authentication error"}},"security":[{"BearerAuth":[]}],"summary":"Removes existing keyword","tags":["Keyword"]},"post":{"description":"Adds new keyword for current user","parameters":[],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Keyword"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"properties":{"data":{"items":{"$ref":"#/components/schemas/KeywordResponse"},"type":"array"},"status":{"type":"integer"},"text":{"type":"string"}},"type":"object"}}},"description":"Successful response"},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationError"}}},"description":"Validation error"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPError"}}},"description":"Authentication error"}},"security":[{"BearerAuth":[]}],"summary":"Add new keyword","tags":["Keyword"]}},"/api/keywords":{"get":{"description":"Returns all keywords for current user","parameters":[],"responses":{"200":{"content":{"application/json":{"schema":{"properties":{"data":{"items":{"$ref":"#/components/schemas/KeywordResponse"},"type":"array"},"status":{"type":"integer"},"text":{"type":"string"}},"type":"object"}}},"description":"Successful response"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPError"}}},"description":"Authentication error"}},"security":[{"BearerAuth":[]}],"summary":"Returns all keywords","tags":["Keyword"]}},"/api/portfolio":{"get":{"description":"Returns all shares of current user","parameters":[],"responses":{"200":{"content":{"application/json":{"schema":{"properties":{"data":{"$ref":"#/components/schemas/200"},"status":{"type":"integer"},"text":{"type":"string"}},"type":"object"}}},"description":"Successful response"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPError"}}},"description":"Authentication error"}},"security":[{"BearerAuth":[]}],"summary":"Returns portfolio","tags":["Portfolio"]}},"/api/share":{"delete":{"description":"Removes existing symbol for current user","parameters":[],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Symbol"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"properties":{"data":{"$ref":"#/components/schemas/DeleteSuccessful"},"status":{"type":"integer"},"text":{"type":"string"}},"type":"object"}}},"description":"Successful response"},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationError"}}},"description":"Validation error"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPError"}}},"description":"Authentication error"}},"security":[{"BearerAuth":[]}],"summary":"Removes existing symbol","tags":["Share"]},"post":{"description":"Adds new symbol for current user","parameters":[],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Symbol"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"properties":{"data":{"items":{"$ref":"#/components/schemas/SymbolResponse"},"type":"array"},"status":{"type":"integer"},"text":{"type":"string"}},"type":"object"}}},"description":"Successful response"},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationError"}}},"description":"Validation error"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPError"}}},"description":"Authentication error"}},"security":[{"BearerAuth":[]}],"summary":"Add new symbol","tags":["Share"]}},"/api/shares":{"get":{"description":"Returns all symbols for current user","parameters":[],"responses":{"200":{"content":{"application/json":{"schema":{"properties":{"data":{"items":{"$ref":"#/components/schemas/SymbolResponse"},"type":"array"},"status":{"type":"integer"},"text":{"type":"string"}},"type":"object"}}},"description":"Successful response"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPError"}}},"description":"Authentication error"}},"security":[{"BearerAuth":[]}],"summary":"Returns all symbols","tags":["Share"]}},"/api/transaction":{"post":{"description":"Adds new transaction for current user","parameters":[],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Transaction"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"properties":{"data":{"$ref":"#/components/schemas/()"},"status":{"type":"integer"},"text":{"type":"string"}},"type":"object"}}},"description":"Successful response"},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationError"}}},"description":"Validation error"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPError"}}},"description":"Authentication error"}},"security":[{"BearerAuth":[]}],"summary":"Adds new transaction","tags":["Transaction"]}},"/api/transactions":{"get":{"description":"Returns all transactions for current user","parameters":[],"responses":{"200":{"content":{"application/json":{"schema":{"properties":{"data":{"$ref":"#/components/schemas/Transaction"},"status":{"type":"integer"},"text":{"type":"string"}},"type":"object"}}},"description":"Successful response"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPError"}}},"description":"Authentication error"}},"security":[{"BearerAuth":[]}],"summary":"Returns all transactions","tags":["Transaction"]}},"/api/user":{"delete":{"description":"Deletes user by username","parameters":[],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeleteUser"}}}},"responses":{"204":{"description":"Successful response"},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationError"}}},"description":"Validation error"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPError"}}},"description":"Authentication error"}},"security":[{"BearerAuth":[]}],"summary":"Delete user","tags":["Users"]},"get":{"description":"Returns current user","parameters":[],"responses":{"200":{"content":{"application/json":{"schema":{"properties":{"data":{"$ref":"#/components/schemas/Users"},"status":{"type":"integer"},"text":{"type":"string"}},"type":"object"}}},"description":"Successful response"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPError"}}},"description":"Authentication error"}},"security":[{"BearerAuth":[]}],"summary":"Get current user","tags":["Users"]},"put":{"description":"Changes password and/or username of current user","parameters":[],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LoginData"}}}},"responses":{"204":{"description":"Successful response"},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationError"}}},"description":"Validation error"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPError"}}},"description":"Authentication error"}},"security":[{"BearerAuth":[]}],"summary":"Update user","tags":["Users"]}},"/api/user/login":{"post":{"description":"Returns jwt token if username and password match, otherwise returns error","parameters":[],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LoginData"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"properties":{"data":{"$ref":"#/components/schemas/Token"},"status":{"type":"integer"},"text":{"type":"string"}},"type":"object"}}},"description":"Successful response"},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationError"}}},"description":"Validation error"}},"summary":"Login","tags":["Users"]}},"/api/user/register":{"post":{"description":"Registers user","parameters":[],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LoginData"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"properties":{"data":{"$ref":"#/components/schemas/Users"},"status":{"type":"integer"},"text":{"type":"string"}},"type":"object"}}},"description":"Successful response"},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationError"}}},"description":"Validation error"}},"summary":"Register","tags":["Users"]}},"/api/user/setAdmin":{"put":{"description":"Set admin state of specified user","parameters":[],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminData"}}}},"responses":{"204":{"description":"Successful response"},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationError"}}},"description":"Validation error"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPError"}}},"description":"Authentication error"}},"security":[{"BearerAuth":[]}],"summary":"Set user admin state","tags":["Users"]}},"/api/users":{"get":{"description":"Returns all existing users as array","parameters":[],"responses":{"200":{"content":{"application/json":{"schema":{"properties":{"data":{"items":{"$ref":"#/components/schemas/Users"},"type":"array"},"status":{"type":"integer"},"text":{"type":"string"}},"type":"object"}}},"description":"Successful response"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPError"}}},"description":"Authentication error"}},"security":[{"BearerAuth":[]}],"summary":"Get all users","tags":["Users"]}}},"servers":[{"name":"Production","url":"https://aktienbot.flokaiser.com"},{"name":"Local","url":"http://127.0.0.1:5000"}],"tags":[{"name":"Keyword"},{"name":"Share"},{"name":"Transaction"},{"name":"Portfolio"},{"name":"Users"}]} diff --git a/documentation/api/postman.json b/documentation/api/postman.json index f8260ec..e6fee89 100644 --- a/documentation/api/postman.json +++ b/documentation/api/postman.json @@ -1,21 +1,218 @@ { "info": { - "_postman_id": "67da7d20-d7df-4ad3-9289-a6e40b6cd2ec", - "name": "AktienBot", + "_postman_id": "b478b800-af91-45a7-8713-b199bcc41866", + "name": "APIFlask", + "description": "Webengineering 2 | Telegram Aktienbot", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" }, "item": [ { - "name": "User", + "name": "Keyword", "item": [ { - "name": "/api/register", + "name": "Removes existing keyword", "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "", + "type": "string" + } + ] + }, + "method": "DELETE", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"keyword\": \"elit Lorem\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/api/keyword", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "keyword" + ] + }, + "description": "Removes existing keyword for current user" + }, + "response": [ + { + "name": "Successful response", + "originalRequest": { + "method": "DELETE", + "header": [ + { + "description": "Added as a part of security scheme: bearer", + "key": "Authorization", + "value": "Bearer " + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"keyword\": \"elit Lorem\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/api/keyword", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "keyword" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"data\": {},\n \"status\": 261201,\n \"text\": \"aliqua amet consectetur elit\"\n}" + }, + { + "name": "Validation error", + "originalRequest": { + "method": "DELETE", + "header": [ + { + "description": "Added as a part of security scheme: bearer", + "key": "Authorization", + "value": "Bearer " + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"keyword\": \"elit Lorem\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/api/keyword", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "keyword" + ] + } + }, + "status": "Bad Request", + "code": 400, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"detail\": {\n \"\": {\n \"\": [\n \"labore\",\n \"\"\n ]\n }\n },\n \"message\": \"pariatur cillum qui aute\"\n}" + }, + { + "name": "Authentication error", + "originalRequest": { + "method": "DELETE", + "header": [ + { + "description": "Added as a part of security scheme: bearer", + "key": "Authorization", + "value": "Bearer " + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"keyword\": \"elit Lorem\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/api/keyword", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "keyword" + ] + } + }, + "status": "Unauthorized", + "code": 401, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"detail\": {},\n \"message\": \"eiusmod enim ipsum\"\n}" + } + ] + }, + { + "name": "Add new keyword", + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "", + "type": "string" + } + ] + }, "method": "POST", - "header": [], + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Accept", + "value": "application/json" + } + ], "body": { "mode": "raw", - "raw": "{\n \"username\": \"Username\",\n \"password\": \"Password\"\n}", + "raw": "{\n \"keyword\": \"elit Lorem\"\n}", "options": { "raw": { "language": "json" @@ -23,104 +220,251 @@ } }, "url": { - "raw": "{{BASE_URL}}/api/register", + "raw": "{{baseUrl}}/api/keyword", "host": [ - "{{BASE_URL}}" + "{{baseUrl}}" ], "path": [ "api", - "register" + "keyword" ] - } - }, - "response": [] - }, - { - "name": "/api/login", - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"username\": \"Username\",\n \"password\": \"Password\"\n}", - "options": { - "raw": { - "language": "json" - } - } }, - "url": { - "raw": "{{BASE_URL}}/api/login", - "host": [ - "{{BASE_URL}}" - ], - "path": [ - "api", - "login" - ] - } + "description": "Adds new keyword for current user" }, - "response": [] + "response": [ + { + "name": "Successful response", + "originalRequest": { + "method": "POST", + "header": [ + { + "description": "Added as a part of security scheme: bearer", + "key": "Authorization", + "value": "Bearer " + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"keyword\": \"elit Lorem\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/api/keyword", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "keyword" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"data\": [\n {\n \"keyword\": \"tempor dolor commodo ipsum non\",\n \"s_id\": -64068772,\n \"user_id\": 82510382\n },\n {\n \"keyword\": \"in aute ex\",\n \"s_id\": 60028598,\n \"user_id\": -36905324\n }\n ],\n \"status\": 63124172,\n \"text\": \"amet\"\n}" + }, + { + "name": "Validation error", + "originalRequest": { + "method": "POST", + "header": [ + { + "description": "Added as a part of security scheme: bearer", + "key": "Authorization", + "value": "Bearer " + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"keyword\": \"elit Lorem\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/api/keyword", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "keyword" + ] + } + }, + "status": "Bad Request", + "code": 400, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"detail\": {\n \"\": {\n \"\": [\n \"labore\",\n \"\"\n ]\n }\n },\n \"message\": \"pariatur cillum qui aute\"\n}" + }, + { + "name": "Authentication error", + "originalRequest": { + "method": "POST", + "header": [ + { + "description": "Added as a part of security scheme: bearer", + "key": "Authorization", + "value": "Bearer " + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"keyword\": \"elit Lorem\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/api/keyword", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "keyword" + ] + } + }, + "status": "Unauthorized", + "code": 401, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"detail\": {},\n \"message\": \"eiusmod enim ipsum\"\n}" + } + ] }, { - "name": "/api/logout", - "protocolProfileBehavior": { - "disableBodyPruning": true - }, + "name": "Returns all keywords", "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "", + "type": "string" + } + ] + }, "method": "GET", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"username\": \"Username\",\n \"password\": \"Password\"\n}", - "options": { - "raw": { - "language": "json" - } + "header": [ + { + "key": "Accept", + "value": "application/json" } - }, + ], "url": { - "raw": "{{BASE_URL}}/api/logout", + "raw": "{{baseUrl}}/api/keywords", "host": [ - "{{BASE_URL}}" + "{{baseUrl}}" ], "path": [ "api", - "logout" + "keywords" ] - } - }, - "response": [] - }, - { - "name": "/api/users", - "protocolProfileBehavior": { - "disableBodyPruning": true - }, - "request": { - "method": "GET", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"username\": \"Username\",\n \"password\": \"Password\"\n}", - "options": { - "raw": { - "language": "json" - } - } }, - "url": { - "raw": "{{BASE_URL}}/api/users", - "host": [ - "{{BASE_URL}}" - ], - "path": [ - "api", - "users" - ] - } + "description": "Returns all keywords for current user" }, - "response": [] + "response": [ + { + "name": "Successful response", + "originalRequest": { + "method": "GET", + "header": [ + { + "description": "Added as a part of security scheme: bearer", + "key": "Authorization", + "value": "Bearer " + } + ], + "url": { + "raw": "{{baseUrl}}/api/keywords", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "keywords" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"data\": [\n {\n \"keyword\": \"tempor dolor commodo ipsum non\",\n \"s_id\": -64068772,\n \"user_id\": 82510382\n },\n {\n \"keyword\": \"in aute ex\",\n \"s_id\": 60028598,\n \"user_id\": -36905324\n }\n ],\n \"status\": 63124172,\n \"text\": \"amet\"\n}" + }, + { + "name": "Authentication error", + "originalRequest": { + "method": "GET", + "header": [ + { + "description": "Added as a part of security scheme: bearer", + "key": "Authorization", + "value": "Bearer " + } + ], + "url": { + "raw": "{{baseUrl}}/api/keywords", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "keywords" + ] + } + }, + "status": "Unauthorized", + "code": 401, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"detail\": {},\n \"message\": \"eiusmod enim ipsum\"\n}" + } + ] } ] }, @@ -128,115 +472,494 @@ "name": "Share", "item": [ { - "name": "/api/shares", - "protocolProfileBehavior": { - "disableBodyPruning": true - }, + "name": "Removes existing symbol", "request": { - "method": "GET", - "header": [], + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "", + "type": "string" + } + ] + }, + "method": "DELETE", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Accept", + "value": "application/json" + } + ], "body": { "mode": "raw", - "raw": "" + "raw": "{\n \"symbol\": \"aliquip ullamco Ut\"\n}", + "options": { + "raw": { + "language": "json" + } + } }, "url": { - "raw": "{{BASE_URL}}/api/shares", + "raw": "{{baseUrl}}/api/share", "host": [ - "{{BASE_URL}}" + "{{baseUrl}}" + ], + "path": [ + "api", + "share" + ] + }, + "description": "Removes existing symbol for current user" + }, + "response": [ + { + "name": "Successful response", + "originalRequest": { + "method": "DELETE", + "header": [ + { + "description": "Added as a part of security scheme: bearer", + "key": "Authorization", + "value": "Bearer " + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"symbol\": \"aliquip ullamco Ut\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/api/share", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "share" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"data\": {},\n \"status\": 261201,\n \"text\": \"aliqua amet consectetur elit\"\n}" + }, + { + "name": "Validation error", + "originalRequest": { + "method": "DELETE", + "header": [ + { + "description": "Added as a part of security scheme: bearer", + "key": "Authorization", + "value": "Bearer " + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"symbol\": \"aliquip ullamco Ut\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/api/share", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "share" + ] + } + }, + "status": "Bad Request", + "code": 400, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"detail\": {\n \"\": {\n \"\": [\n \"labore\",\n \"\"\n ]\n }\n },\n \"message\": \"pariatur cillum qui aute\"\n}" + }, + { + "name": "Authentication error", + "originalRequest": { + "method": "DELETE", + "header": [ + { + "description": "Added as a part of security scheme: bearer", + "key": "Authorization", + "value": "Bearer " + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"symbol\": \"aliquip ullamco Ut\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/api/share", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "share" + ] + } + }, + "status": "Unauthorized", + "code": 401, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"detail\": {},\n \"message\": \"eiusmod enim ipsum\"\n}" + } + ] + }, + { + "name": "Add new symbol", + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "", + "type": "string" + } + ] + }, + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"symbol\": \"aliquip ullamco Ut\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/api/share", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "share" + ] + }, + "description": "Adds new symbol for current user" + }, + "response": [ + { + "name": "Successful response", + "originalRequest": { + "method": "POST", + "header": [ + { + "description": "Added as a part of security scheme: bearer", + "key": "Authorization", + "value": "Bearer " + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"symbol\": \"aliquip ullamco Ut\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/api/share", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "share" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"data\": [\n {\n \"s_id\": -53227093,\n \"symbol\": \"veniam ea amet irure\",\n \"user_id\": 7468241\n },\n {\n \"s_id\": -37877246,\n \"symbol\": \"ut tempor labore non\",\n \"user_id\": -72644124\n }\n ],\n \"status\": 87653200,\n \"text\": \"aliquip reprehenderit dolore\"\n}" + }, + { + "name": "Validation error", + "originalRequest": { + "method": "POST", + "header": [ + { + "description": "Added as a part of security scheme: bearer", + "key": "Authorization", + "value": "Bearer " + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"symbol\": \"aliquip ullamco Ut\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/api/share", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "share" + ] + } + }, + "status": "Bad Request", + "code": 400, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"detail\": {\n \"\": {\n \"\": [\n \"labore\",\n \"\"\n ]\n }\n },\n \"message\": \"pariatur cillum qui aute\"\n}" + }, + { + "name": "Authentication error", + "originalRequest": { + "method": "POST", + "header": [ + { + "description": "Added as a part of security scheme: bearer", + "key": "Authorization", + "value": "Bearer " + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"symbol\": \"aliquip ullamco Ut\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/api/share", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "share" + ] + } + }, + "status": "Unauthorized", + "code": 401, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"detail\": {},\n \"message\": \"eiusmod enim ipsum\"\n}" + } + ] + }, + { + "name": "Returns all symbols", + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "", + "type": "string" + } + ] + }, + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "application/json" + } + ], + "url": { + "raw": "{{baseUrl}}/api/shares", + "host": [ + "{{baseUrl}}" ], "path": [ "api", "shares" ] - } - }, - "response": [] - }, - { - "name": "/api/share", - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"symbol\": \"DTEGY\"\n}", - "options": { - "raw": { - "language": "json" - } - } }, - "url": { - "raw": "{{BASE_URL}}/api/share", - "host": [ - "{{BASE_URL}}" - ], - "path": [ - "api", - "share" - ] - } + "description": "Returns all symbols for current user" }, - "response": [] - }, - { - "name": "/api/share", - "request": { - "method": "DELETE", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"symbol\": \"DTEGY\"\n}", - "options": { - "raw": { - "language": "json" + "response": [ + { + "name": "Successful response", + "originalRequest": { + "method": "GET", + "header": [ + { + "description": "Added as a part of security scheme: bearer", + "key": "Authorization", + "value": "Bearer " + } + ], + "url": { + "raw": "{{baseUrl}}/api/shares", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "shares" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" } - } - }, - "url": { - "raw": "{{BASE_URL}}/api/share", - "host": [ - "{{BASE_URL}}" ], - "path": [ - "api", - "share" - ] + "cookie": [], + "body": "{\n \"data\": [\n {\n \"s_id\": -53227093,\n \"symbol\": \"veniam ea amet irure\",\n \"user_id\": 7468241\n },\n {\n \"s_id\": -37877246,\n \"symbol\": \"ut tempor labore non\",\n \"user_id\": -72644124\n }\n ],\n \"status\": 87653200,\n \"text\": \"aliquip reprehenderit dolore\"\n}" + }, + { + "name": "Authentication error", + "originalRequest": { + "method": "GET", + "header": [ + { + "description": "Added as a part of security scheme: bearer", + "key": "Authorization", + "value": "Bearer " + } + ], + "url": { + "raw": "{{baseUrl}}/api/shares", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "shares" + ] + } + }, + "status": "Unauthorized", + "code": 401, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"detail\": {},\n \"message\": \"eiusmod enim ipsum\"\n}" } - }, - "response": [] + ] } ] }, { - "name": "Keyword", + "name": "Transaction", "item": [ { - "name": "/api/keywords", + "name": "Adds new transaction", "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{BASE_URL}}/api/keywords", - "host": [ - "{{BASE_URL}}" - ], - "path": [ - "api", - "keywords" + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "", + "type": "string" + } ] - } - }, - "response": [] - }, - { - "name": "/api/keyword", - "request": { + }, "method": "POST", - "header": [], + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Accept", + "value": "application/json" + } + ], "body": { "mode": "raw", - "raw": "{\n \"keyword\": \"Elon\"\n}", + "raw": "{\n \"count\": 96634001,\n \"price\": -71028444.15053315,\n \"symbol\": \"deserunt officia dolore\",\n \"time\": \"magna occaecat est\",\n \"user_id\": -71272721\n}", "options": { "raw": { "language": "json" @@ -244,94 +967,251 @@ } }, "url": { - "raw": "{{BASE_URL}}/api/keyword", + "raw": "{{baseUrl}}/api/transaction", "host": [ - "{{BASE_URL}}" - ], - "path": [ - "api", - "keyword" - ] - } - }, - "response": [] - }, - { - "name": "/api/keyword", - "request": { - "method": "DELETE", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"keyword\": \"Elon\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{BASE_URL}}/api/keyword", - "host": [ - "{{BASE_URL}}" - ], - "path": [ - "api", - "keyword" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "Transactions", - "item": [ - { - "name": "/api/transactions", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{BASE_URL}}/api/transactions", - "host": [ - "{{BASE_URL}}" - ], - "path": [ - "api", - "transactions" - ] - } - }, - "response": [] - }, - { - "name": "/api/transaction", - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"symbol\": \"DTEGY\",\n \"time\": \"2021-03-14T18:08:44.625Z\",\n \"count\": 1,\n \"price\": 10.0\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{BASE_URL}}/api/transaction", - "host": [ - "{{BASE_URL}}" + "{{baseUrl}}" ], "path": [ "api", "transaction" ] - } + }, + "description": "Adds new transaction for current user" }, - "response": [] + "response": [ + { + "name": "Successful response", + "originalRequest": { + "method": "POST", + "header": [ + { + "description": "Added as a part of security scheme: bearer", + "key": "Authorization", + "value": "Bearer " + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"count\": 96634001,\n \"price\": -71028444.15053315,\n \"symbol\": \"deserunt officia dolore\",\n \"time\": \"magna occaecat est\",\n \"user_id\": -71272721\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/api/transaction", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "transaction" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"data\": {\n \"value\": \"reference #/components/schemas/() not found in the OpenAPI spec\"\n },\n \"status\": 14310780,\n \"text\": \"in sint sit\"\n}" + }, + { + "name": "Validation error", + "originalRequest": { + "method": "POST", + "header": [ + { + "description": "Added as a part of security scheme: bearer", + "key": "Authorization", + "value": "Bearer " + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"count\": 96634001,\n \"price\": -71028444.15053315,\n \"symbol\": \"deserunt officia dolore\",\n \"time\": \"magna occaecat est\",\n \"user_id\": -71272721\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/api/transaction", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "transaction" + ] + } + }, + "status": "Bad Request", + "code": 400, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"detail\": {\n \"\": {\n \"\": [\n \"labore\",\n \"\"\n ]\n }\n },\n \"message\": \"pariatur cillum qui aute\"\n}" + }, + { + "name": "Authentication error", + "originalRequest": { + "method": "POST", + "header": [ + { + "description": "Added as a part of security scheme: bearer", + "key": "Authorization", + "value": "Bearer " + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"count\": 96634001,\n \"price\": -71028444.15053315,\n \"symbol\": \"deserunt officia dolore\",\n \"time\": \"magna occaecat est\",\n \"user_id\": -71272721\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/api/transaction", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "transaction" + ] + } + }, + "status": "Unauthorized", + "code": 401, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"detail\": {},\n \"message\": \"eiusmod enim ipsum\"\n}" + } + ] + }, + { + "name": "Returns all transactions", + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "", + "type": "string" + } + ] + }, + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "application/json" + } + ], + "url": { + "raw": "{{baseUrl}}/api/transactions", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "transactions" + ] + }, + "description": "Returns all transactions for current user" + }, + "response": [ + { + "name": "Successful response", + "originalRequest": { + "method": "GET", + "header": [ + { + "description": "Added as a part of security scheme: bearer", + "key": "Authorization", + "value": "Bearer " + } + ], + "url": { + "raw": "{{baseUrl}}/api/transactions", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "transactions" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"data\": {\n \"count\": -19053100,\n \"price\": 39909986.26075193,\n \"symbol\": \"sit nisi\",\n \"time\": \"pariatur eu proident\",\n \"user_id\": 54782742\n },\n \"status\": 87070947,\n \"text\": \"null\"\n}" + }, + { + "name": "Authentication error", + "originalRequest": { + "method": "GET", + "header": [ + { + "description": "Added as a part of security scheme: bearer", + "key": "Authorization", + "value": "Bearer " + } + ], + "url": { + "raw": "{{baseUrl}}/api/transactions", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "transactions" + ] + } + }, + "status": "Unauthorized", + "code": 401, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"detail\": {},\n \"message\": \"eiusmod enim ipsum\"\n}" + } + ] } ] }, @@ -339,61 +1219,1092 @@ "name": "Portfolio", "item": [ { - "name": "/api/portfolio", + "name": "Returns portfolio", "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "", + "type": "string" + } + ] + }, "method": "GET", - "header": [], + "header": [ + { + "key": "Accept", + "value": "application/json" + } + ], "url": { - "raw": "{{BASE_URL}}/api/portfolio", + "raw": "{{baseUrl}}/api/portfolio", "host": [ - "{{BASE_URL}}" + "{{baseUrl}}" ], "path": [ "api", "portfolio" ] - } + }, + "description": "Returns all shares of current user" }, - "response": [] + "response": [ + { + "name": "Successful response", + "originalRequest": { + "method": "GET", + "header": [ + { + "description": "Added as a part of security scheme: bearer", + "key": "Authorization", + "value": "Bearer " + } + ], + "url": { + "raw": "{{baseUrl}}/api/portfolio", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "portfolio" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"data\": {\n \"value\": \"reference #/components/schemas/200 not found in the OpenAPI spec\"\n },\n \"status\": 14426134,\n \"text\": \"velit in ad dolore\"\n}" + }, + { + "name": "Authentication error", + "originalRequest": { + "method": "GET", + "header": [ + { + "description": "Added as a part of security scheme: bearer", + "key": "Authorization", + "value": "Bearer " + } + ], + "url": { + "raw": "{{baseUrl}}/api/portfolio", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "portfolio" + ] + } + }, + "status": "Unauthorized", + "code": 401, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"detail\": {},\n \"message\": \"eiusmod enim ipsum\"\n}" + } + ] + } + ] + }, + { + "name": "Users", + "item": [ + { + "name": "Delete user", + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "", + "type": "string" + } + ] + }, + "method": "DELETE", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"username\": \"aliqua dolor do\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/api/user", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "user" + ] + }, + "description": "Deletes user by username" + }, + "response": [ + { + "name": "Successful response", + "originalRequest": { + "method": "DELETE", + "header": [ + { + "description": "Added as a part of security scheme: bearer", + "key": "Authorization", + "value": "Bearer " + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"username\": \"aliqua dolor do\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/api/user", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "user" + ] + } + }, + "status": "No Content", + "code": 204, + "_postman_previewlanguage": "text", + "header": [ + { + "key": "Content-Type", + "value": "text/plain" + } + ], + "cookie": [], + "body": "" + }, + { + "name": "Validation error", + "originalRequest": { + "method": "DELETE", + "header": [ + { + "description": "Added as a part of security scheme: bearer", + "key": "Authorization", + "value": "Bearer " + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"username\": \"aliqua dolor do\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/api/user", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "user" + ] + } + }, + "status": "Bad Request", + "code": 400, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"detail\": {\n \"\": {\n \"\": [\n \"cupidatat mollit laborum aute\",\n \"aute in laboris dolor\"\n ]\n }\n },\n \"message\": \"in dolore exercitation eu elit\"\n}" + }, + { + "name": "Authentication error", + "originalRequest": { + "method": "DELETE", + "header": [ + { + "description": "Added as a part of security scheme: bearer", + "key": "Authorization", + "value": "Bearer " + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"username\": \"aliqua dolor do\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/api/user", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "user" + ] + } + }, + "status": "Unauthorized", + "code": 401, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"detail\": {},\n \"message\": \"eiusmod enim ipsum\"\n}" + } + ] + }, + { + "name": "Get current user", + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "", + "type": "string" + } + ] + }, + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "application/json" + } + ], + "url": { + "raw": "{{baseUrl}}/api/user", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "user" + ] + }, + "description": "Returns current user" + }, + "response": [ + { + "name": "Successful response", + "originalRequest": { + "method": "GET", + "header": [ + { + "description": "Added as a part of security scheme: bearer", + "key": "Authorization", + "value": "Bearer " + } + ], + "url": { + "raw": "{{baseUrl}}/api/user", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "user" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"data\": {\n \"admin\": false,\n \"password\": \"voluptate magna esse\",\n \"telegram_name\": \"id\",\n \"user_id\": -55336867,\n \"username\": \"do exercitation\"\n },\n \"status\": -11469710,\n \"text\": \"aute\"\n}" + }, + { + "name": "Authentication error", + "originalRequest": { + "method": "GET", + "header": [ + { + "description": "Added as a part of security scheme: bearer", + "key": "Authorization", + "value": "Bearer " + } + ], + "url": { + "raw": "{{baseUrl}}/api/user", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "user" + ] + } + }, + "status": "Unauthorized", + "code": 401, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"detail\": {},\n \"message\": \"eiusmod enim ipsum\"\n}" + } + ] + }, + { + "name": "Update user", + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "", + "type": "string" + } + ] + }, + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"password\": \"ut minim\",\n \"username\": \"esse sit enim consectetur\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/api/user", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "user" + ] + }, + "description": "Changes password and/or username of current user" + }, + "response": [ + { + "name": "Successful response", + "originalRequest": { + "method": "PUT", + "header": [ + { + "description": "Added as a part of security scheme: bearer", + "key": "Authorization", + "value": "Bearer " + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"password\": \"ut minim\",\n \"username\": \"esse sit enim consectetur\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/api/user", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "user" + ] + } + }, + "status": "No Content", + "code": 204, + "_postman_previewlanguage": "text", + "header": [ + { + "key": "Content-Type", + "value": "text/plain" + } + ], + "cookie": [], + "body": "" + }, + { + "name": "Validation error", + "originalRequest": { + "method": "PUT", + "header": [ + { + "description": "Added as a part of security scheme: bearer", + "key": "Authorization", + "value": "Bearer " + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"password\": \"ut minim\",\n \"username\": \"esse sit enim consectetur\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/api/user", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "user" + ] + } + }, + "status": "Bad Request", + "code": 400, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"detail\": {\n \"\": {\n \"\": [\n \"labore\",\n \"\"\n ]\n }\n },\n \"message\": \"pariatur cillum qui aute\"\n}" + }, + { + "name": "Authentication error", + "originalRequest": { + "method": "PUT", + "header": [ + { + "description": "Added as a part of security scheme: bearer", + "key": "Authorization", + "value": "Bearer " + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"password\": \"ut minim\",\n \"username\": \"esse sit enim consectetur\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/api/user", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "user" + ] + } + }, + "status": "Unauthorized", + "code": 401, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"detail\": {},\n \"message\": \"eiusmod enim ipsum\"\n}" + } + ] + }, + { + "name": "Login", + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"password\": \"ut minim\",\n \"username\": \"esse sit enim consectetur\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/api/user/login", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "user", + "login" + ] + }, + "description": "Returns jwt token if username and password match, otherwise returns error" + }, + "response": [ + { + "name": "Successful response", + "originalRequest": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"password\": \"ut minim\",\n \"username\": \"esse sit enim consectetur\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/api/user/login", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "user", + "login" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"data\": {\n \"token\": \"minim\"\n },\n \"status\": 86563099,\n \"text\": \"non tempor quis ullamco est\"\n}" + }, + { + "name": "Validation error", + "originalRequest": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"password\": \"ut minim\",\n \"username\": \"esse sit enim consectetur\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/api/user/login", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "user", + "login" + ] + } + }, + "status": "Bad Request", + "code": 400, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"detail\": {\n \"\": {\n \"\": [\n \"labore\",\n \"\"\n ]\n }\n },\n \"message\": \"pariatur cillum qui aute\"\n}" + } + ] + }, + { + "name": "Register", + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"password\": \"ut minim\",\n \"username\": \"esse sit enim consectetur\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/api/user/register", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "user", + "register" + ] + }, + "description": "Registers user" + }, + "response": [ + { + "name": "Successful response", + "originalRequest": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"password\": \"ut minim\",\n \"username\": \"esse sit enim consectetur\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/api/user/register", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "user", + "register" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"data\": {\n \"admin\": false,\n \"password\": \"voluptate magna esse\",\n \"telegram_name\": \"id\",\n \"user_id\": -55336867,\n \"username\": \"do exercitation\"\n },\n \"status\": -11469710,\n \"text\": \"aute\"\n}" + }, + { + "name": "Validation error", + "originalRequest": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"password\": \"ut minim\",\n \"username\": \"esse sit enim consectetur\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/api/user/register", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "user", + "register" + ] + } + }, + "status": "Bad Request", + "code": 400, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"detail\": {\n \"\": {\n \"\": [\n \"labore\",\n \"\"\n ]\n }\n },\n \"message\": \"pariatur cillum qui aute\"\n}" + } + ] + }, + { + "name": "Set user admin state", + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "", + "type": "string" + } + ] + }, + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"admin\": true,\n \"username\": \"sunt\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/api/user/setAdmin", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "user", + "setAdmin" + ] + }, + "description": "Set admin state of specified user" + }, + "response": [ + { + "name": "Successful response", + "originalRequest": { + "method": "PUT", + "header": [ + { + "description": "Added as a part of security scheme: bearer", + "key": "Authorization", + "value": "Bearer " + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"admin\": true,\n \"username\": \"sunt\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/api/user/setAdmin", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "user", + "setAdmin" + ] + } + }, + "status": "No Content", + "code": 204, + "_postman_previewlanguage": "text", + "header": [ + { + "key": "Content-Type", + "value": "text/plain" + } + ], + "cookie": [], + "body": "" + }, + { + "name": "Validation error", + "originalRequest": { + "method": "PUT", + "header": [ + { + "description": "Added as a part of security scheme: bearer", + "key": "Authorization", + "value": "Bearer " + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"admin\": true,\n \"username\": \"sunt\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/api/user/setAdmin", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "user", + "setAdmin" + ] + } + }, + "status": "Bad Request", + "code": 400, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"detail\": {\n \"\": {\n \"\": [\n \"labore\",\n \"\"\n ]\n }\n },\n \"message\": \"pariatur cillum qui aute\"\n}" + }, + { + "name": "Authentication error", + "originalRequest": { + "method": "PUT", + "header": [ + { + "description": "Added as a part of security scheme: bearer", + "key": "Authorization", + "value": "Bearer " + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"admin\": true,\n \"username\": \"sunt\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/api/user/setAdmin", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "user", + "setAdmin" + ] + } + }, + "status": "Unauthorized", + "code": 401, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"detail\": {},\n \"message\": \"eiusmod enim ipsum\"\n}" + } + ] + }, + { + "name": "Get all users", + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "", + "type": "string" + } + ] + }, + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "application/json" + } + ], + "url": { + "raw": "{{baseUrl}}/api/users", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "users" + ] + }, + "description": "Returns all existing users as array" + }, + "response": [ + { + "name": "Successful response", + "originalRequest": { + "method": "GET", + "header": [ + { + "description": "Added as a part of security scheme: bearer", + "key": "Authorization", + "value": "Bearer " + } + ], + "url": { + "raw": "{{baseUrl}}/api/users", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "users" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"data\": [\n {\n \"admin\": true,\n \"password\": \"incididunt id dolore\",\n \"telegram_name\": \"id sed\",\n \"user_id\": 15906508,\n \"username\": \"dolor consequat ullamco\"\n },\n {\n \"admin\": true,\n \"password\": \"voluptate non\",\n \"telegram_name\": \"dolor sunt fugiat exercitation\",\n \"user_id\": 95246024,\n \"username\": \"Duis qui culpa Ut labore\"\n }\n ],\n \"status\": 81180129,\n \"text\": \"in ullamco\"\n}" + }, + { + "name": "Authentication error", + "originalRequest": { + "method": "GET", + "header": [ + { + "description": "Added as a part of security scheme: bearer", + "key": "Authorization", + "value": "Bearer " + } + ], + "url": { + "raw": "{{baseUrl}}/api/users", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "users" + ] + } + }, + "status": "Unauthorized", + "code": 401, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"detail\": {},\n \"message\": \"eiusmod enim ipsum\"\n}" + } + ] } ] } ], - "auth": { - "type": "bearer", - "bearer": [ - { - "key": "token", - "value": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6IlVzZXJuYW1lIiwiZXhwIjoxNjQ3Mjk5MzIxfQ.5UoHi9Zu6p9szSVKK2_1Ln2uru4RVTGQl0MyHDB4sqg", - "type": "string" - } - ] - }, - "event": [ - { - "listen": "prerequest", - "script": { - "type": "text/javascript", - "exec": [ - "" - ] - } - }, - { - "listen": "test", - "script": { - "type": "text/javascript", - "exec": [ - "" - ] - } - } - ], "variable": [ { - "key": "BASE_URL", - "value": "https://aktienbot.flokaiser.com/", - "type": "default" + "key": "baseUrl", + "value": "https://aktienbot.flokaiser.com", + "type": "string" } ] } \ No newline at end of file diff --git a/documentation/database/README.md b/documentation/database/README.md deleted file mode 100644 index 26568bd..0000000 --- a/documentation/database/README.md +++ /dev/null @@ -1 +0,0 @@ -This is the database folder diff --git a/telegram_bot/.env.example b/telegram_bot/.env.example new file mode 100644 index 0000000..bcd6a02 --- /dev/null +++ b/telegram_bot/.env.example @@ -0,0 +1,8 @@ +# Telegram bot api key +BOT_API_KEY= + +# News api key +NEWS_API_KEY= + +# Flask secret key +SECRET_KEY= diff --git a/telegram_bot/README.md b/telegram_bot/README.md index abda9e2..05ac44d 100644 --- a/telegram_bot/README.md +++ b/telegram_bot/README.md @@ -1,6 +1,33 @@ -## Local setup for telegram bot -0. optional: build virtual env by ``python -m venv venv`` - ``env/Scripts/activate`` -2. create .env and set API keys etc. (use .env.example as a layout) -3. install required libs via ``pip install -r ./telegram_bot/requirements.txt`` -4. run bot.py via ``python ./telegram_bot/bot.py`` +# Telegram bot + +Aktienbot telegram bot + +## Development +1. Create virtual environment `python -m venv venv env/Scripts/activate` +2. Install requirements `pip install -r telegram_bot/requirements.txt` +3. Set environment variables (see list below) + 1. Use `.env`-file in `api` directory like `.env.example` + 2. Or set variables using `export` or `set` commands. (Windows `set`, Linux `export`) +4. Run api `python telegram_bot/bot.py` + +## Environment variables +``` + # Telegram bot api key + BOT_API_KEY= + + # News api key + NEWS_API_KEY= +``` + +## Docker +``` +docker run -d \ + --name aktienbot_bot \ + --hostname aktienbot_bot \ + --publish 80:80 \ + --env "BOT_API_KEY=" \ + --env "NEWS_API_KEY=" \ + --restart unless-stopped \ + registry.flokaiser.com/aktienbot/bot:latest +``` +or load environment variables from file by using `--env-file ` \ No newline at end of file