diff --git a/.woodpecker/pipeline.yml b/.woodpecker/pipeline.yml index 8551885..7a0d6a1 100644 --- a/.woodpecker/pipeline.yml +++ b/.woodpecker/pipeline.yml @@ -39,24 +39,7 @@ pipeline: from_secret: password registry: from_secret: registry - dockerfile: telegram_bot/Dockerfile.bot - platforms: linux/amd64 - when: - path: "telegram_bot/**" - event: push - - build_bot_updates: - image: woodpeckerci/plugin-docker-buildx - settings: - repo: - from_secret: repo_bot_updates - username: - from_secret: username - password: - from_secret: password - registry: - from_secret: registry - dockerfile: telegram_bot/Dockerfile.updates + dockerfile: telegram_bot/Dockerfile platforms: linux/amd64 when: path: "telegram_bot/**" diff --git a/deploy/aktienbot/.env.bot b/deploy/aktienbot/.env.bot index c64cd3c..8b67787 100644 --- a/deploy/aktienbot/.env.bot +++ b/deploy/aktienbot/.env.bot @@ -1,3 +1,6 @@ BOT_API_KEY= NEWS_API_KEY= SECRET_KEY= + +BOT_EMAIL= +BOT_PASSWORD= \ No newline at end of file diff --git a/deploy/aktienbot/docker-compose.yml b/deploy/aktienbot/docker-compose.yml index 991bbdf..46aee48 100644 --- a/deploy/aktienbot/docker-compose.yml +++ b/deploy/aktienbot/docker-compose.yml @@ -30,11 +30,6 @@ services: env_file: - ${PWD}/.env.bot - aktienbot_bot_updates: - image: registry.flokaiser.com/aktienbot/bot_updates - env_file: - - ${PWD}/.env.bot - mariadb: image: mariadb volumes: diff --git a/documentation/api/openapi.json b/documentation/api/openapi.json index f16137b..6b0c300 100644 --- a/documentation/api/openapi.json +++ b/documentation/api/openapi.json @@ -1 +1,1404 @@ -{"components":{"schemas":{"AdminData":{"properties":{"admin":{"type":"boolean"},"email":{"format":"email","type":"string"}},"type":"object"},"DeleteSuccessful":{"properties":{},"type":"object"},"DeleteUser":{"properties":{"email":{"format":"email","type":"string"}},"type":"object"},"HTTPError":{"properties":{"detail":{"type":"object"},"message":{"type":"string"}},"type":"object"},"Keyword":{"properties":{"keyword":{"type":"string"}},"type":"object"},"KeywordResponse":{"properties":{"email":{"format":"email","type":"string"},"keyword":{"type":"string"},"s_id":{"type":"integer"}},"type":"object"},"LoginData":{"properties":{"email":{"format":"email","type":"string"},"password":{"type":"string"}},"type":"object"},"PortfolioResponse":{"properties":{"count":{"type":"integer"},"last_transaction":{"type":"string"},"symbol":{"type":"string"}},"type":"object"},"RegisterData":{"properties":{"email":{"format":"email","type":"string"},"password":{"type":"string"},"username":{"type":"string"}},"type":"object"},"Symbol":{"properties":{"symbol":{"type":"string"}},"type":"object"},"SymbolResponse":{"properties":{"email":{"format":"email","type":"string"},"s_id":{"type":"integer"},"symbol":{"type":"string"}},"type":"object"},"TelegramId":{"properties":{"telegram_user_id":{"type":"string"}},"type":"object"},"Token":{"properties":{"token":{"type":"string"}},"type":"object"},"Transaction":{"properties":{"count":{"type":"integer"},"price":{"type":"number"},"symbol":{"type":"string"},"time":{"pattern":"\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z","type":"string"}},"type":"object"},"TransactionResponse":{"properties":{"count":{"type":"integer"},"email":{"format":"email","type":"string"},"price":{"type":"number"},"symbol":{"type":"string"},"time":{"type":"string"}},"type":"object"},"UpdateUserData":{"properties":{"password":{"type":"string"},"username":{"type":"string"}},"type":"object"},"Users":{"properties":{"admin":{"type":"boolean"},"email":{"format":"email","type":"string"},"password":{"type":"string"},"telegram_user_id":{"type":"string"},"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":{"items":{"$ref":"#/components/schemas/PortfolioResponse"},"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 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/telegram":{"post":{"description":"Connects telegram user id to user account","parameters":[],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TelegramId"}}}},"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"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPError"}}},"description":"Authentication error"}},"security":[{"BearerAuth":[]}],"summary":"Connects telegram user id","tags":["Telegram"]}},"/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/TransactionResponse"},"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/UpdateUserData"}}}},"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/RegisterData"}}}},"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"},{"name":"Telegram"}]} +{ + "components": { + "schemas": { + "AdminData": { + "properties": { + "admin": { + "type": "boolean" + }, + "email": { + "format": "email", + "type": "string" + } + }, + "type": "object" + }, + "CronData": { + "properties": { + "cron": { + "type": "string" + } + }, + "type": "object" + }, + "DeleteSuccessful": { + "properties": {}, + "type": "object" + }, + "DeleteUser": { + "properties": { + "email": { + "format": "email", + "type": "string" + } + }, + "type": "object" + }, + "HTTPError": { + "properties": { + "detail": { + "type": "object" + }, + "message": { + "type": "string" + } + }, + "type": "object" + }, + "Keyword": { + "properties": { + "keyword": { + "type": "string" + } + }, + "type": "object" + }, + "KeywordResponse": { + "properties": { + "email": { + "format": "email", + "type": "string" + }, + "keyword": { + "type": "string" + }, + "s_id": { + "type": "integer" + } + }, + "type": "object" + }, + "LoginData": { + "properties": { + "email": { + "format": "email", + "type": "string" + }, + "password": { + "type": "string" + } + }, + "type": "object" + }, + "PortfolioResponse": { + "properties": { + "comment": { + "type": "string" + }, + "count": { + "type": "integer" + }, + "isin": { + "type": "string" + }, + "last_transaction": { + "type": "string" + } + }, + "type": "object" + }, + "RegisterData": { + "properties": { + "email": { + "format": "email", + "type": "string" + }, + "password": { + "type": "string" + }, + "username": { + "type": "string" + } + }, + "type": "object" + }, + "Symbol": { + "properties": { + "comment": { + "type": "string" + }, + "isin": { + "type": "string" + } + }, + "type": "object" + }, + "SymbolPrice": { + "properties": { + "isin": { + "type": "string" + }, + "price": { + "type": "number" + }, + "time": { + "pattern": "\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z", + "type": "string" + } + }, + "type": "object" + }, + "SymbolRemove": { + "properties": { + "isin": { + "type": "string" + } + }, + "type": "object" + }, + "SymbolResponse": { + "properties": { + "comment": { + "type": "string" + }, + "email": { + "format": "email", + "type": "string" + }, + "isin": { + "type": "string" + }, + "s_id": { + "type": "integer" + } + }, + "type": "object" + }, + "TelegramId": { + "properties": { + "telegram_user_id": { + "type": "string" + } + }, + "type": "object" + }, + "Token": { + "properties": { + "token": { + "type": "string" + } + }, + "type": "object" + }, + "Transaction": { + "properties": { + "comment": { + "type": "string" + }, + "count": { + "type": "integer" + }, + "isin": { + "type": "string" + }, + "price": { + "type": "number" + }, + "time": { + "pattern": "\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z", + "type": "string" + } + }, + "type": "object" + }, + "TransactionResponse": { + "properties": { + "comment": { + "type": "string" + }, + "count": { + "type": "integer" + }, + "email": { + "format": "email", + "type": "string" + }, + "isin": { + "type": "string" + }, + "price": { + "type": "number" + }, + "time": { + "type": "string" + } + }, + "type": "object" + }, + "UpdateUserData": { + "properties": { + "password": { + "type": "string" + }, + "username": { + "type": "string" + } + }, + "type": "object" + }, + "Users": { + "properties": { + "admin": { + "type": "boolean" + }, + "cron": { + "type": "string" + }, + "email": { + "format": "email", + "type": "string" + }, + "password": { + "type": "string" + }, + "telegram_user_id": { + "type": "string" + }, + "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": { + "title": "APIFlask", + "version": "0.1.0" + }, + "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": { + "items": { + "$ref": "#/components/schemas/PortfolioResponse" + }, + "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 portfolio", + "tags": [ + "Portfolio" + ] + } + }, + "/api/share": { + "delete": { + "description": "Removes existing symbol for current user", + "parameters": [], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SymbolRemove" + } + } + } + }, + "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/symbol": { + "post": { + "description": "Adds new price to database", + "parameters": [], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SymbolPrice" + } + } + } + }, + "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": "Adds new price for isin", + "tags": [ + "Share_Price" + ] + } + }, + "/api/symbols": { + "get": { + "description": "Returns all transaction symbols for all users", + "parameters": [], + "responses": { + "204": { + "description": "Successful response" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPError" + } + } + }, + "description": "Authentication error" + } + }, + "security": [ + { + "BearerAuth": [] + } + ], + "summary": "Returns all transaction symbols", + "tags": [ + "Share_Price" + ] + } + }, + "/api/telegram": { + "post": { + "description": "Connects telegram user id to user account", + "parameters": [], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/TelegramId" + } + } + } + }, + "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" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPError" + } + } + }, + "description": "Authentication error" + } + }, + "security": [ + { + "BearerAuth": [] + } + ], + "summary": "Connects telegram user id", + "tags": [ + "Telegram" + ] + } + }, + "/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/TransactionResponse" + }, + "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/UpdateUserData" + } + } + } + }, + "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/RegisterData" + } + } + } + }, + "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/user/setCron": { + "put": { + "description": "Set update cron of specified user", + "parameters": [], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CronData" + } + } + } + }, + "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 update cron", + "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" + ] + } + } + }, + "tags": [ + { + "name": "Keyword" + }, + { + "name": "Share" + }, + { + "name": "Share_Price" + }, + { + "name": "Transaction" + }, + { + "name": "Portfolio" + }, + { + "name": "Users" + }, + { + "name": "Telegram" + } + ] +} diff --git a/documentation/api/postman.json b/documentation/api/postman.json index db6e014..994ca6e 100644 --- a/documentation/api/postman.json +++ b/documentation/api/postman.json @@ -1,10 +1,9 @@ { "info": { - "_postman_id": "eed3eb48-b932-4d72-979a-38de9ae2cbf0", - "name": "APIFlask", - "description": "Webengineering 2 | Telegram Aktienbot", - "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" - }, + "_postman_id": "ab12ad1f-aaf8-44c2-80de-bd4e1ec72c4b", + "name": "APIFlask", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" + }, "item": [ { "name": "Keyword", @@ -34,14 +33,14 @@ } ], "body": { - "mode": "raw", - "raw": "{\n \"keyword\": \"nisi\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, + "mode": "raw", + "raw": "{\n \"keyword\": \"veniam pariatur\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, "url": { "raw": "{{baseUrl}}/api/keyword", "host": [ @@ -67,14 +66,14 @@ } ], "body": { - "mode": "raw", - "raw": "{\n \"keyword\": \"nisi\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, + "mode": "raw", + "raw": "{\n \"keyword\": \"veniam pariatur\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, "url": { "raw": "{{baseUrl}}/api/keyword", "host": [ @@ -96,7 +95,7 @@ } ], "cookie": [], - "body": "{\n \"data\": {},\n \"status\": -35854777,\n \"text\": \"sint in\"\n}" + "body": "{\n \"data\": {},\n \"status\": -6906184,\n \"text\": \"velit ad reprehenderit quis\"\n}" }, { "name": "Validation error", @@ -110,14 +109,14 @@ } ], "body": { - "mode": "raw", - "raw": "{\n \"keyword\": \"nisi\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, + "mode": "raw", + "raw": "{\n \"keyword\": \"veniam pariatur\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, "url": { "raw": "{{baseUrl}}/api/keyword", "host": [ @@ -139,7 +138,7 @@ } ], "cookie": [], - "body": "{\n \"detail\": {\n \"\": {\n \"\": [\n \"anim quis\",\n \"in velit ali\"\n ]\n }\n },\n \"message\": \"nostrud\"\n}" + "body": "{\n \"detail\": {\n \"\": {\n \"\": [\n \"in esse ut consectetur\",\n \"dolor dolore\"\n ]\n }\n },\n \"message\": \"tempor enim magna in\"\n}" }, { "name": "Authentication error", @@ -153,14 +152,14 @@ } ], "body": { - "mode": "raw", - "raw": "{\n \"keyword\": \"nisi\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, + "mode": "raw", + "raw": "{\n \"keyword\": \"veniam pariatur\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, "url": { "raw": "{{baseUrl}}/api/keyword", "host": [ @@ -182,7 +181,7 @@ } ], "cookie": [], - "body": "{\n \"detail\": {},\n \"message\": \"irure ad do quis\"\n}" + "body": "{\n \"detail\": {},\n \"message\": \"non elit\"\n}" } ] }, @@ -211,14 +210,14 @@ } ], "body": { - "mode": "raw", - "raw": "{\n \"keyword\": \"nisi\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, + "mode": "raw", + "raw": "{\n \"keyword\": \"veniam pariatur\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, "url": { "raw": "{{baseUrl}}/api/keyword", "host": [ @@ -244,14 +243,14 @@ } ], "body": { - "mode": "raw", - "raw": "{\n \"keyword\": \"nisi\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, + "mode": "raw", + "raw": "{\n \"keyword\": \"veniam pariatur\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, "url": { "raw": "{{baseUrl}}/api/keyword", "host": [ @@ -273,7 +272,7 @@ } ], "cookie": [], - "body": "{\n \"data\": [\n {\n \"email\": \"8Es0sp5sb@wvQoAOvD.bzz\",\n \"keyword\": \"eiusmo\",\n \"s_id\": -48384117\n },\n {\n \"email\": \"MZ0cnQ1mwRV@oONtzNaRnVSaUXAReoDzwztMr.fiz\",\n \"keyword\": \"ullamco ad\",\n \"s_id\": -36966818\n }\n ],\n \"status\": 55335664,\n \"text\": \"dolor id ex\"\n}" + "body": "{\n \"data\": [\n {\n \"email\": \"4zcg8Ae@mFFZbwrszRgeKi.bmly\",\n \"keyword\": \"laboris\",\n \"s_id\": -29368814\n },\n {\n \"email\": \"WcrLS@cPNpWwtFqRDxUEumdjOsPLukcg.lmxg\",\n \"keyword\": \"veniam\",\n \"s_id\": 58969388\n }\n ],\n \"status\": -62012539,\n \"text\": \"ut incididunt sunt\"\n}" }, { "name": "Validation error", @@ -287,14 +286,14 @@ } ], "body": { - "mode": "raw", - "raw": "{\n \"keyword\": \"nisi\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, + "mode": "raw", + "raw": "{\n \"keyword\": \"veniam pariatur\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, "url": { "raw": "{{baseUrl}}/api/keyword", "host": [ @@ -316,7 +315,7 @@ } ], "cookie": [], - "body": "{\n \"detail\": {\n \"\": {\n \"\": [\n \"anim quis\",\n \"in velit ali\"\n ]\n }\n },\n \"message\": \"nostrud\"\n}" + "body": "{\n \"detail\": {\n \"\": {\n \"\": [\n \"in esse ut consectetur\",\n \"dolor dolore\"\n ]\n }\n },\n \"message\": \"tempor enim magna in\"\n}" }, { "name": "Authentication error", @@ -330,14 +329,14 @@ } ], "body": { - "mode": "raw", - "raw": "{\n \"keyword\": \"nisi\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, + "mode": "raw", + "raw": "{\n \"keyword\": \"veniam pariatur\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, "url": { "raw": "{{baseUrl}}/api/keyword", "host": [ @@ -359,7 +358,7 @@ } ], "cookie": [], - "body": "{\n \"detail\": {},\n \"message\": \"irure ad do quis\"\n}" + "body": "{\n \"detail\": {},\n \"message\": \"non elit\"\n}" } ] }, @@ -428,7 +427,7 @@ } ], "cookie": [], - "body": "{\n \"data\": [\n {\n \"email\": \"8Es0sp5sb@wvQoAOvD.bzz\",\n \"keyword\": \"eiusmo\",\n \"s_id\": -48384117\n },\n {\n \"email\": \"MZ0cnQ1mwRV@oONtzNaRnVSaUXAReoDzwztMr.fiz\",\n \"keyword\": \"ullamco ad\",\n \"s_id\": -36966818\n }\n ],\n \"status\": 55335664,\n \"text\": \"dolor id ex\"\n}" + "body": "{\n \"data\": [\n {\n \"email\": \"4zcg8Ae@mFFZbwrszRgeKi.bmly\",\n \"keyword\": \"laboris\",\n \"s_id\": -29368814\n },\n {\n \"email\": \"WcrLS@cPNpWwtFqRDxUEumdjOsPLukcg.lmxg\",\n \"keyword\": \"veniam\",\n \"s_id\": 58969388\n }\n ],\n \"status\": -62012539,\n \"text\": \"ut incididunt sunt\"\n}" }, { "name": "Authentication error", @@ -462,7 +461,7 @@ } ], "cookie": [], - "body": "{\n \"detail\": {},\n \"message\": \"irure ad do quis\"\n}" + "body": "{\n \"detail\": {},\n \"message\": \"non elit\"\n}" } ] } @@ -496,14 +495,14 @@ } ], "body": { - "mode": "raw", - "raw": "{\n \"symbol\": \"magna Excepteur ullamco aute velit\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, + "mode": "raw", + "raw": "{\n \"isin\": \"quis pariatur\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, "url": { "raw": "{{baseUrl}}/api/share", "host": [ @@ -529,14 +528,14 @@ } ], "body": { - "mode": "raw", - "raw": "{\n \"symbol\": \"magna Excepteur ullamco aute velit\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, + "mode": "raw", + "raw": "{\n \"isin\": \"quis pariatur\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, "url": { "raw": "{{baseUrl}}/api/share", "host": [ @@ -558,7 +557,7 @@ } ], "cookie": [], - "body": "{\n \"data\": {},\n \"status\": -35854777,\n \"text\": \"sint in\"\n}" + "body": "{\n \"data\": {},\n \"status\": -6906184,\n \"text\": \"velit ad reprehenderit quis\"\n}" }, { "name": "Validation error", @@ -572,14 +571,14 @@ } ], "body": { - "mode": "raw", - "raw": "{\n \"symbol\": \"magna Excepteur ullamco aute velit\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, + "mode": "raw", + "raw": "{\n \"isin\": \"quis pariatur\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, "url": { "raw": "{{baseUrl}}/api/share", "host": [ @@ -601,7 +600,7 @@ } ], "cookie": [], - "body": "{\n \"detail\": {\n \"\": {\n \"\": [\n \"anim quis\",\n \"in velit ali\"\n ]\n }\n },\n \"message\": \"nostrud\"\n}" + "body": "{\n \"detail\": {\n \"\": {\n \"\": [\n \"in esse ut consectetur\",\n \"dolor dolore\"\n ]\n }\n },\n \"message\": \"tempor enim magna in\"\n}" }, { "name": "Authentication error", @@ -615,14 +614,14 @@ } ], "body": { - "mode": "raw", - "raw": "{\n \"symbol\": \"magna Excepteur ullamco aute velit\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, + "mode": "raw", + "raw": "{\n \"isin\": \"quis pariatur\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, "url": { "raw": "{{baseUrl}}/api/share", "host": [ @@ -644,7 +643,7 @@ } ], "cookie": [], - "body": "{\n \"detail\": {},\n \"message\": \"irure ad do quis\"\n}" + "body": "{\n \"detail\": {},\n \"message\": \"non elit\"\n}" } ] }, @@ -673,14 +672,14 @@ } ], "body": { - "mode": "raw", - "raw": "{\n \"symbol\": \"magna Excepteur ullamco aute velit\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, + "mode": "raw", + "raw": "{\n \"comment\": \"irure adipisicing consectetur\",\n \"isin\": \"non irure ea labore\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, "url": { "raw": "{{baseUrl}}/api/share", "host": [ @@ -706,14 +705,14 @@ } ], "body": { - "mode": "raw", - "raw": "{\n \"symbol\": \"magna Excepteur ullamco aute velit\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, + "mode": "raw", + "raw": "{\n \"comment\": \"irure adipisicing consectetur\",\n \"isin\": \"non irure ea labore\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, "url": { "raw": "{{baseUrl}}/api/share", "host": [ @@ -735,7 +734,7 @@ } ], "cookie": [], - "body": "{\n \"data\": [\n {\n \"email\": \"j32mUuC@iIJKfYQWSepoVsngEZYbfEmOwCzXXxVMP.alp\",\n \"s_id\": 86469214,\n \"symbol\": \"labore ea\"\n },\n {\n \"email\": \"PwKotAxaLBa8nY@nSsGmaxZeZqnRhOGmHhbICYhqTGLESrq.xy\",\n \"s_id\": 63768957,\n \"symbol\": \"laboris pariatur commodo\"\n }\n ],\n \"status\": -1862021,\n \"text\": \"culpa nulla\"\n}" + "body": "{\n \"data\": [\n {\n \"comment\": \"aute eu id\",\n \"email\": \"7Wq8YgGHE@T.phx\",\n \"isin\": \"amet anim Duis proident dolore\",\n \"s_id\": 87738546\n },\n {\n \"comment\": \"ut mollit\",\n \"email\": \"MT8jKX-7mq@gxctz.tskk\",\n \"isin\": \"in nost\",\n \"s_id\": -16197478\n }\n ],\n \"status\": -39445086,\n \"text\": \"aliqua consequat aute officia\"\n}" }, { "name": "Validation error", @@ -749,14 +748,14 @@ } ], "body": { - "mode": "raw", - "raw": "{\n \"symbol\": \"magna Excepteur ullamco aute velit\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, + "mode": "raw", + "raw": "{\n \"comment\": \"irure adipisicing consectetur\",\n \"isin\": \"non irure ea labore\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, "url": { "raw": "{{baseUrl}}/api/share", "host": [ @@ -778,7 +777,7 @@ } ], "cookie": [], - "body": "{\n \"detail\": {\n \"\": {\n \"\": [\n \"anim quis\",\n \"in velit ali\"\n ]\n }\n },\n \"message\": \"nostrud\"\n}" + "body": "{\n \"detail\": {\n \"\": {\n \"\": [\n \"in esse ut consectetur\",\n \"dolor dolore\"\n ]\n }\n },\n \"message\": \"tempor enim magna in\"\n}" }, { "name": "Authentication error", @@ -792,14 +791,14 @@ } ], "body": { - "mode": "raw", - "raw": "{\n \"symbol\": \"magna Excepteur ullamco aute velit\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, + "mode": "raw", + "raw": "{\n \"comment\": \"irure adipisicing consectetur\",\n \"isin\": \"non irure ea labore\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, "url": { "raw": "{{baseUrl}}/api/share", "host": [ @@ -821,7 +820,7 @@ } ], "cookie": [], - "body": "{\n \"detail\": {},\n \"message\": \"irure ad do quis\"\n}" + "body": "{\n \"detail\": {},\n \"message\": \"non elit\"\n}" } ] }, @@ -890,7 +889,7 @@ } ], "cookie": [], - "body": "{\n \"data\": [\n {\n \"email\": \"j32mUuC@iIJKfYQWSepoVsngEZYbfEmOwCzXXxVMP.alp\",\n \"s_id\": 86469214,\n \"symbol\": \"labore ea\"\n },\n {\n \"email\": \"PwKotAxaLBa8nY@nSsGmaxZeZqnRhOGmHhbICYhqTGLESrq.xy\",\n \"s_id\": 63768957,\n \"symbol\": \"laboris pariatur commodo\"\n }\n ],\n \"status\": -1862021,\n \"text\": \"culpa nulla\"\n}" + "body": "{\n \"data\": [\n {\n \"comment\": \"aute eu id\",\n \"email\": \"7Wq8YgGHE@T.phx\",\n \"isin\": \"amet anim Duis proident dolore\",\n \"s_id\": 87738546\n },\n {\n \"comment\": \"ut mollit\",\n \"email\": \"MT8jKX-7mq@gxctz.tskk\",\n \"isin\": \"in nost\",\n \"s_id\": -16197478\n }\n ],\n \"status\": -39445086,\n \"text\": \"aliqua consequat aute officia\"\n}" }, { "name": "Authentication error", @@ -914,27 +913,312 @@ ] } }, - "status": "Unauthorized", - "code": 401, - "_postman_previewlanguage": "json", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "cookie": [], - "body": "{\n \"detail\": {},\n \"message\": \"irure ad do quis\"\n}" - } - ] - } - ] - }, - { - "name": "Transaction", - "item": [ - { - "name": "Adds new transaction", + "status": "Unauthorized", + "code": 401, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"detail\": {},\n \"message\": \"non elit\"\n}" + } + ] + } + ] + }, + { + "name": "Share_Price", + "item": [ + { + "name": "Adds new price for isin", + "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 \"isin\": \"consequat ut elit incididunt\",\n \"price\": 8596518.682177305,\n \"time\": \"6953-98-62T41:25:08.545Z\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/api/symbol", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "symbol" + ] + }, + "description": "Adds new price to database" + }, + "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 \"isin\": \"consequat ut elit incididunt\",\n \"price\": 8596518.682177305,\n \"time\": \"6953-98-62T41:25:08.545Z\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/api/symbol", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "symbol" + ] + } + }, + "status": "No Content", + "code": 204, + "_postman_previewlanguage": "text", + "header": [ + { + "key": "Content-Type", + "value": "text/plain" + } + ], + "cookie": [], + "body": "" + }, + { + "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 \"isin\": \"consequat ut elit incididunt\",\n \"price\": 8596518.682177305,\n \"time\": \"6953-98-62T41:25:08.545Z\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/api/symbol", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "symbol" + ] + } + }, + "status": "Bad Request", + "code": 400, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"detail\": {\n \"\": {\n \"\": [\n \"in esse ut consectetur\",\n \"dolor dolore\"\n ]\n }\n },\n \"message\": \"tempor enim magna in\"\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 \"isin\": \"consequat ut elit incididunt\",\n \"price\": 8596518.682177305,\n \"time\": \"6953-98-62T41:25:08.545Z\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/api/symbol", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "symbol" + ] + } + }, + "status": "Unauthorized", + "code": 401, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"detail\": {},\n \"message\": \"non elit\"\n}" + } + ] + }, + { + "name": "Returns all transaction symbols", + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "", + "type": "string" + } + ] + }, + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "application/json" + } + ], + "url": { + "raw": "{{baseUrl}}/api/symbols", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "symbols" + ] + }, + "description": "Returns all transaction symbols for all users" + }, + "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/symbols", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "symbols" + ] + } + }, + "status": "No Content", + "code": 204, + "_postman_previewlanguage": "text", + "header": [ + { + "key": "Content-Type", + "value": "text/plain" + } + ], + "cookie": [], + "body": "" + }, + { + "name": "Authentication error", + "originalRequest": { + "method": "GET", + "header": [ + { + "description": "Added as a part of security scheme: bearer", + "key": "Authorization", + "value": "Bearer " + } + ], + "url": { + "raw": "{{baseUrl}}/api/symbols", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "symbols" + ] + } + }, + "status": "Unauthorized", + "code": 401, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"detail\": {},\n \"message\": \"non elit\"\n}" + } + ] + } + ] + }, + { + "name": "Transaction", + "item": [ + { + "name": "Adds new transaction", "request": { "auth": { "type": "bearer", @@ -958,14 +1242,14 @@ } ], "body": { - "mode": "raw", - "raw": "{\n \"count\": 76782033,\n \"price\": -9709838.042264134,\n \"symbol\": \"mollit esse ex in\",\n \"time\": \"2120-69-63T43:76:75.378Z\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, + "mode": "raw", + "raw": "{\n \"comment\": \"non nulla\",\n \"count\": 96442090,\n \"isin\": \"non esse\",\n \"price\": -17020893.639093384,\n \"time\": \"9660-60-73T53:64:02.637Z\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, "url": { "raw": "{{baseUrl}}/api/transaction", "host": [ @@ -991,14 +1275,14 @@ } ], "body": { - "mode": "raw", - "raw": "{\n \"count\": 76782033,\n \"price\": -9709838.042264134,\n \"symbol\": \"mollit esse ex in\",\n \"time\": \"2120-69-63T43:76:75.378Z\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, + "mode": "raw", + "raw": "{\n \"comment\": \"non nulla\",\n \"count\": 96442090,\n \"isin\": \"non esse\",\n \"price\": -17020893.639093384,\n \"time\": \"9660-60-73T53:64:02.637Z\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, "url": { "raw": "{{baseUrl}}/api/transaction", "host": [ @@ -1020,7 +1304,7 @@ } ], "cookie": [], - "body": "{\n \"data\": {\n \"count\": 99691073,\n \"email\": \"DAX6XjHTr8eA6M@xsoUe.id\",\n \"price\": -14617384.086570382,\n \"symbol\": \"eu ad deserunt\",\n \"time\": \"ipsum nisi in laboris\"\n },\n \"status\": -51137224,\n \"text\": \"ipsum culpa amet\"\n}" + "body": "{\n \"data\": {\n \"comment\": \"ex cillum ullamco officia\",\n \"count\": -23493756,\n \"email\": \"fmL6Vhy@daFGKga.aton\",\n \"isin\": \"aliquip enim sint\",\n \"price\": -46738573.8885945,\n \"time\": \"aute enim\"\n },\n \"status\": -46966272,\n \"text\": \"adipisicing qui amet nulla\"\n}" }, { "name": "Validation error", @@ -1034,14 +1318,14 @@ } ], "body": { - "mode": "raw", - "raw": "{\n \"count\": 76782033,\n \"price\": -9709838.042264134,\n \"symbol\": \"mollit esse ex in\",\n \"time\": \"2120-69-63T43:76:75.378Z\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, + "mode": "raw", + "raw": "{\n \"comment\": \"non nulla\",\n \"count\": 96442090,\n \"isin\": \"non esse\",\n \"price\": -17020893.639093384,\n \"time\": \"9660-60-73T53:64:02.637Z\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, "url": { "raw": "{{baseUrl}}/api/transaction", "host": [ @@ -1063,7 +1347,7 @@ } ], "cookie": [], - "body": "{\n \"detail\": {\n \"\": {\n \"\": [\n \"anim quis\",\n \"in velit ali\"\n ]\n }\n },\n \"message\": \"nostrud\"\n}" + "body": "{\n \"detail\": {\n \"\": {\n \"\": [\n \"in esse ut consectetur\",\n \"dolor dolore\"\n ]\n }\n },\n \"message\": \"tempor enim magna in\"\n}" }, { "name": "Authentication error", @@ -1077,14 +1361,14 @@ } ], "body": { - "mode": "raw", - "raw": "{\n \"count\": 76782033,\n \"price\": -9709838.042264134,\n \"symbol\": \"mollit esse ex in\",\n \"time\": \"2120-69-63T43:76:75.378Z\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, + "mode": "raw", + "raw": "{\n \"comment\": \"non nulla\",\n \"count\": 96442090,\n \"isin\": \"non esse\",\n \"price\": -17020893.639093384,\n \"time\": \"9660-60-73T53:64:02.637Z\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, "url": { "raw": "{{baseUrl}}/api/transaction", "host": [ @@ -1106,7 +1390,7 @@ } ], "cookie": [], - "body": "{\n \"detail\": {},\n \"message\": \"irure ad do quis\"\n}" + "body": "{\n \"detail\": {},\n \"message\": \"non elit\"\n}" } ] }, @@ -1175,7 +1459,7 @@ } ], "cookie": [], - "body": "{\n \"data\": {\n \"count\": -37878076,\n \"price\": -40419772.172105886,\n \"symbol\": \"velit ut Ut elit esse\",\n \"time\": \"5462-92-97T03:27:22.076Z\"\n },\n \"status\": -509477,\n \"text\": \"proident\"\n}" + "body": "{\n \"data\": {\n \"comment\": \"ex ipsum adipisicing dolor\",\n \"count\": 46881527,\n \"isin\": \"ad eiusmod\",\n \"price\": -11144262.12990503,\n \"time\": \"5529-43-74T12:79:94.205Z\"\n },\n \"status\": 25470796,\n \"text\": \"exercitation et est\"\n}" }, { "name": "Authentication error", @@ -1209,7 +1493,7 @@ } ], "cookie": [], - "body": "{\n \"detail\": {},\n \"message\": \"irure ad do quis\"\n}" + "body": "{\n \"detail\": {},\n \"message\": \"non elit\"\n}" } ] } @@ -1283,7 +1567,7 @@ } ], "cookie": [], - "body": "{\n \"data\": [\n {\n \"count\": 75537465,\n \"last_transaction\": \"dolor enim\",\n \"symbol\": \"enim nostrud non deserunt\"\n },\n {\n \"count\": -69490418,\n \"last_transaction\": \"et\",\n \"symbol\": \"Excepteur irure est enim\"\n }\n ],\n \"status\": 7099250,\n \"text\": \"dolore in ad\"\n}" + "body": "{\n \"data\": [\n {\n \"comment\": \"sint quis ut\",\n \"count\": 54930744,\n \"isin\": \"labore cillum\",\n \"last_transaction\": \"id cillum non\"\n },\n {\n \"comment\": \"cillum ut ipsum\",\n \"count\": 44991486,\n \"isin\": \"in in consectetur velit\",\n \"last_transaction\": \"anim veniam\"\n }\n ],\n \"status\": 87593619,\n \"text\": \"non culpa occaecat\"\n}" }, { "name": "Authentication error", @@ -1317,7 +1601,7 @@ } ], "cookie": [], - "body": "{\n \"detail\": {},\n \"message\": \"irure ad do quis\"\n}" + "body": "{\n \"detail\": {},\n \"message\": \"non elit\"\n}" } ] } @@ -1351,14 +1635,14 @@ } ], "body": { - "mode": "raw", - "raw": "{\n \"email\": \"HqkZQ@KMWQFPMhWGvBHrdzOdOampAHweUvPCej.kvbl\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, + "mode": "raw", + "raw": "{\n \"email\": \"oG8z5swOjkbst@kinVwpTMhsrUUCewsWdTkNXO.pqv\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, "url": { "raw": "{{baseUrl}}/api/user", "host": [ @@ -1384,14 +1668,14 @@ } ], "body": { - "mode": "raw", - "raw": "{\n \"email\": \"HqkZQ@KMWQFPMhWGvBHrdzOdOampAHweUvPCej.kvbl\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, + "mode": "raw", + "raw": "{\n \"email\": \"oG8z5swOjkbst@kinVwpTMhsrUUCewsWdTkNXO.pqv\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, "url": { "raw": "{{baseUrl}}/api/user", "host": [ @@ -1427,14 +1711,14 @@ } ], "body": { - "mode": "raw", - "raw": "{\n \"email\": \"HqkZQ@KMWQFPMhWGvBHrdzOdOampAHweUvPCej.kvbl\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, + "mode": "raw", + "raw": "{\n \"email\": \"oG8z5swOjkbst@kinVwpTMhsrUUCewsWdTkNXO.pqv\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, "url": { "raw": "{{baseUrl}}/api/user", "host": [ @@ -1456,7 +1740,7 @@ } ], "cookie": [], - "body": "{\n \"detail\": {\n \"\": {\n \"\": [\n \"anim quis\",\n \"in velit ali\"\n ]\n }\n },\n \"message\": \"nostrud\"\n}" + "body": "{\n \"detail\": {\n \"\": {\n \"\": [\n \"in esse ut consectetur\",\n \"dolor dolore\"\n ]\n }\n },\n \"message\": \"tempor enim magna in\"\n}" }, { "name": "Authentication error", @@ -1470,14 +1754,14 @@ } ], "body": { - "mode": "raw", - "raw": "{\n \"email\": \"HqkZQ@KMWQFPMhWGvBHrdzOdOampAHweUvPCej.kvbl\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, + "mode": "raw", + "raw": "{\n \"email\": \"oG8z5swOjkbst@kinVwpTMhsrUUCewsWdTkNXO.pqv\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, "url": { "raw": "{{baseUrl}}/api/user", "host": [ @@ -1499,7 +1783,7 @@ } ], "cookie": [], - "body": "{\n \"detail\": {},\n \"message\": \"irure ad do quis\"\n}" + "body": "{\n \"detail\": {},\n \"message\": \"non elit\"\n}" } ] }, @@ -1568,7 +1852,7 @@ } ], "cookie": [], - "body": "{\n \"data\": {\n \"admin\": false,\n \"email\": \"VNB@NeqjbTmHnkWDwPacdUoXgpYVTNlD.iip\",\n \"password\": \"fugiat ipsum\",\n \"telegram_user_id\": \"et\",\n \"username\": \"nostrud laborum\"\n },\n \"status\": -78288268,\n \"text\": \"laborum minim\"\n}" + "body": "{\n \"data\": {\n \"admin\": true,\n \"cron\": \"id in Excepteur\",\n \"email\": \"E3rj@zUSyCWAiewlz.vrx\",\n \"password\": \"sunt pariatur\",\n \"telegram_user_id\": \"elit\",\n \"username\": \"mollit incididunt nostrud\"\n },\n \"status\": -87469860,\n \"text\": \"ullamco in\"\n}" }, { "name": "Authentication error", @@ -1602,7 +1886,7 @@ } ], "cookie": [], - "body": "{\n \"detail\": {},\n \"message\": \"irure ad do quis\"\n}" + "body": "{\n \"detail\": {},\n \"message\": \"non elit\"\n}" } ] }, @@ -1631,14 +1915,14 @@ } ], "body": { - "mode": "raw", - "raw": "{\n \"password\": \"elit do in esse\",\n \"username\": \"mollit velit sed reprehenderit\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, + "mode": "raw", + "raw": "{\n \"password\": \"ut\",\n \"username\": \"ullamco amet\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, "url": { "raw": "{{baseUrl}}/api/user", "host": [ @@ -1664,14 +1948,14 @@ } ], "body": { - "mode": "raw", - "raw": "{\n \"password\": \"elit do in esse\",\n \"username\": \"mollit velit sed reprehenderit\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, + "mode": "raw", + "raw": "{\n \"password\": \"ut\",\n \"username\": \"ullamco amet\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, "url": { "raw": "{{baseUrl}}/api/user", "host": [ @@ -1707,14 +1991,14 @@ } ], "body": { - "mode": "raw", - "raw": "{\n \"password\": \"elit do in esse\",\n \"username\": \"mollit velit sed reprehenderit\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, + "mode": "raw", + "raw": "{\n \"password\": \"ut\",\n \"username\": \"ullamco amet\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, "url": { "raw": "{{baseUrl}}/api/user", "host": [ @@ -1736,7 +2020,7 @@ } ], "cookie": [], - "body": "{\n \"detail\": {\n \"\": {\n \"\": [\n \"anim quis\",\n \"in velit ali\"\n ]\n }\n },\n \"message\": \"nostrud\"\n}" + "body": "{\n \"detail\": {\n \"\": {\n \"\": [\n \"in esse ut consectetur\",\n \"dolor dolore\"\n ]\n }\n },\n \"message\": \"tempor enim magna in\"\n}" }, { "name": "Authentication error", @@ -1750,14 +2034,14 @@ } ], "body": { - "mode": "raw", - "raw": "{\n \"password\": \"elit do in esse\",\n \"username\": \"mollit velit sed reprehenderit\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, + "mode": "raw", + "raw": "{\n \"password\": \"ut\",\n \"username\": \"ullamco amet\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, "url": { "raw": "{{baseUrl}}/api/user", "host": [ @@ -1779,7 +2063,7 @@ } ], "cookie": [], - "body": "{\n \"detail\": {},\n \"message\": \"irure ad do quis\"\n}" + "body": "{\n \"detail\": {},\n \"message\": \"non elit\"\n}" } ] }, @@ -1798,14 +2082,14 @@ } ], "body": { - "mode": "raw", - "raw": "{\n \"email\": \"YKQkCdcOoJ3vH@wbOpjGTXH.avm\",\n \"password\": \"veniam\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, + "mode": "raw", + "raw": "{\n \"email\": \"GfEubxoHYHPPc4@PXsBSXusLxIotbYTjEAaQnAVHLDz.jv\",\n \"password\": \"Duis ut\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, "url": { "raw": "{{baseUrl}}/api/user/login", "host": [ @@ -1826,14 +2110,14 @@ "method": "POST", "header": [], "body": { - "mode": "raw", - "raw": "{\n \"email\": \"YKQkCdcOoJ3vH@wbOpjGTXH.avm\",\n \"password\": \"veniam\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, + "mode": "raw", + "raw": "{\n \"email\": \"GfEubxoHYHPPc4@PXsBSXusLxIotbYTjEAaQnAVHLDz.jv\",\n \"password\": \"Duis ut\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, "url": { "raw": "{{baseUrl}}/api/user/login", "host": [ @@ -1856,7 +2140,7 @@ } ], "cookie": [], - "body": "{\n \"data\": {\n \"token\": \"do ipsu\"\n },\n \"status\": 31961350,\n \"text\": \"Lorem dolor commodo laborum cillum\"\n}" + "body": "{\n \"data\": {\n \"token\": \"non\"\n },\n \"status\": 92819984,\n \"text\": \"consectetur elit esse non\"\n}" }, { "name": "Validation error", @@ -1864,14 +2148,14 @@ "method": "POST", "header": [], "body": { - "mode": "raw", - "raw": "{\n \"email\": \"YKQkCdcOoJ3vH@wbOpjGTXH.avm\",\n \"password\": \"veniam\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, + "mode": "raw", + "raw": "{\n \"email\": \"GfEubxoHYHPPc4@PXsBSXusLxIotbYTjEAaQnAVHLDz.jv\",\n \"password\": \"Duis ut\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, "url": { "raw": "{{baseUrl}}/api/user/login", "host": [ @@ -1894,7 +2178,7 @@ } ], "cookie": [], - "body": "{\n \"detail\": {\n \"\": {\n \"\": [\n \"anim quis\",\n \"in velit ali\"\n ]\n }\n },\n \"message\": \"nostrud\"\n}" + "body": "{\n \"detail\": {\n \"\": {\n \"\": [\n \"in esse ut consectetur\",\n \"dolor dolore\"\n ]\n }\n },\n \"message\": \"tempor enim magna in\"\n}" } ] }, @@ -1913,14 +2197,14 @@ } ], "body": { - "mode": "raw", - "raw": "{\n \"email\": \"DJR029Ov-keM@pyhCxnpZmcVMxADSiCjmsGRZksCf.zz\",\n \"password\": \"sed voluptate\",\n \"username\": \"voluptate aute proident\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, + "mode": "raw", + "raw": "{\n \"email\": \"3zVMb95E@jZETuCbGKKbkmiNrTNNfdpTPQdkBJNbzD.wicb\",\n \"password\": \"eiusmod cillum\",\n \"username\": \"enim\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, "url": { "raw": "{{baseUrl}}/api/user/register", "host": [ @@ -1941,14 +2225,14 @@ "method": "POST", "header": [], "body": { - "mode": "raw", - "raw": "{\n \"email\": \"DJR029Ov-keM@pyhCxnpZmcVMxADSiCjmsGRZksCf.zz\",\n \"password\": \"sed voluptate\",\n \"username\": \"voluptate aute proident\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, + "mode": "raw", + "raw": "{\n \"email\": \"3zVMb95E@jZETuCbGKKbkmiNrTNNfdpTPQdkBJNbzD.wicb\",\n \"password\": \"eiusmod cillum\",\n \"username\": \"enim\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, "url": { "raw": "{{baseUrl}}/api/user/register", "host": [ @@ -1971,7 +2255,7 @@ } ], "cookie": [], - "body": "{\n \"data\": {\n \"admin\": false,\n \"email\": \"VNB@NeqjbTmHnkWDwPacdUoXgpYVTNlD.iip\",\n \"password\": \"fugiat ipsum\",\n \"telegram_user_id\": \"et\",\n \"username\": \"nostrud laborum\"\n },\n \"status\": -78288268,\n \"text\": \"laborum minim\"\n}" + "body": "{\n \"data\": {\n \"admin\": true,\n \"cron\": \"id in Excepteur\",\n \"email\": \"E3rj@zUSyCWAiewlz.vrx\",\n \"password\": \"sunt pariatur\",\n \"telegram_user_id\": \"elit\",\n \"username\": \"mollit incididunt nostrud\"\n },\n \"status\": -87469860,\n \"text\": \"ullamco in\"\n}" }, { "name": "Validation error", @@ -1979,14 +2263,14 @@ "method": "POST", "header": [], "body": { - "mode": "raw", - "raw": "{\n \"email\": \"DJR029Ov-keM@pyhCxnpZmcVMxADSiCjmsGRZksCf.zz\",\n \"password\": \"sed voluptate\",\n \"username\": \"voluptate aute proident\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, + "mode": "raw", + "raw": "{\n \"email\": \"3zVMb95E@jZETuCbGKKbkmiNrTNNfdpTPQdkBJNbzD.wicb\",\n \"password\": \"eiusmod cillum\",\n \"username\": \"enim\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, "url": { "raw": "{{baseUrl}}/api/user/register", "host": [ @@ -2009,7 +2293,7 @@ } ], "cookie": [], - "body": "{\n \"detail\": {\n \"\": {\n \"\": [\n \"anim quis\",\n \"in velit ali\"\n ]\n }\n },\n \"message\": \"nostrud\"\n}" + "body": "{\n \"detail\": {\n \"\": {\n \"\": [\n \"in esse ut consectetur\",\n \"dolor dolore\"\n ]\n }\n },\n \"message\": \"tempor enim magna in\"\n}" } ] }, @@ -2038,14 +2322,14 @@ } ], "body": { - "mode": "raw", - "raw": "{\n \"admin\": false,\n \"email\": \"qUgn5u1bWI4cwc@LjiesdFcoYwvweQto.dj\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, + "mode": "raw", + "raw": "{\n \"admin\": false,\n \"email\": \"3lnXNx5@NhoXHfuhjTiz.bgre\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, "url": { "raw": "{{baseUrl}}/api/user/setAdmin", "host": [ @@ -2072,14 +2356,14 @@ } ], "body": { - "mode": "raw", - "raw": "{\n \"admin\": false,\n \"email\": \"qUgn5u1bWI4cwc@LjiesdFcoYwvweQto.dj\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, + "mode": "raw", + "raw": "{\n \"admin\": false,\n \"email\": \"3lnXNx5@NhoXHfuhjTiz.bgre\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, "url": { "raw": "{{baseUrl}}/api/user/setAdmin", "host": [ @@ -2116,14 +2400,14 @@ } ], "body": { - "mode": "raw", - "raw": "{\n \"admin\": false,\n \"email\": \"qUgn5u1bWI4cwc@LjiesdFcoYwvweQto.dj\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, + "mode": "raw", + "raw": "{\n \"admin\": false,\n \"email\": \"3lnXNx5@NhoXHfuhjTiz.bgre\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, "url": { "raw": "{{baseUrl}}/api/user/setAdmin", "host": [ @@ -2146,7 +2430,7 @@ } ], "cookie": [], - "body": "{\n \"detail\": {\n \"\": {\n \"\": [\n \"anim quis\",\n \"in velit ali\"\n ]\n }\n },\n \"message\": \"nostrud\"\n}" + "body": "{\n \"detail\": {\n \"\": {\n \"\": [\n \"in esse ut consectetur\",\n \"dolor dolore\"\n ]\n }\n },\n \"message\": \"tempor enim magna in\"\n}" }, { "name": "Authentication error", @@ -2160,14 +2444,14 @@ } ], "body": { - "mode": "raw", - "raw": "{\n \"admin\": false,\n \"email\": \"qUgn5u1bWI4cwc@LjiesdFcoYwvweQto.dj\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, + "mode": "raw", + "raw": "{\n \"admin\": false,\n \"email\": \"3lnXNx5@NhoXHfuhjTiz.bgre\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, "url": { "raw": "{{baseUrl}}/api/user/setAdmin", "host": [ @@ -2180,27 +2464,208 @@ ] } }, - "status": "Unauthorized", - "code": 401, - "_postman_previewlanguage": "json", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "cookie": [], - "body": "{\n \"detail\": {},\n \"message\": \"irure ad do quis\"\n}" - } - ] - }, - { - "name": "Get all users", - "request": { - "auth": { - "type": "bearer", - "bearer": [ - { + "status": "Unauthorized", + "code": 401, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"detail\": {},\n \"message\": \"non elit\"\n}" + } + ] + }, + { + "name": "Set update cron", + "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 \"cron\": \"dolor\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/api/user/setCron", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "user", + "setCron" + ] + }, + "description": "Set update cron 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 \"cron\": \"dolor\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/api/user/setCron", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "user", + "setCron" + ] + } + }, + "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 \"cron\": \"dolor\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/api/user/setCron", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "user", + "setCron" + ] + } + }, + "status": "Bad Request", + "code": 400, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"detail\": {\n \"\": {\n \"\": [\n \"in esse ut consectetur\",\n \"dolor dolore\"\n ]\n }\n },\n \"message\": \"tempor enim magna in\"\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 \"cron\": \"dolor\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/api/user/setCron", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "api", + "user", + "setCron" + ] + } + }, + "status": "Unauthorized", + "code": 401, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"detail\": {},\n \"message\": \"non elit\"\n}" + } + ] + }, + { + "name": "Get all users", + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { "key": "token", "value": "", "type": "string" @@ -2259,7 +2724,7 @@ } ], "cookie": [], - "body": "{\n \"data\": [\n {\n \"admin\": false,\n \"email\": \"paghoo4COL6gQNz@SJXcMSOC.kus\",\n \"password\": \"exercitation laboris Ut cillum nisi\",\n \"telegram_user_id\": \"id in incididunt sint\",\n \"username\": \"sed laborum cill\"\n },\n {\n \"admin\": false,\n \"email\": \"WFYb2q0XXey6WZa@JNSezyFkIVzneuifIXi.la\",\n \"password\": \"velit irure veniam\",\n \"telegram_user_id\": \"pariatur sed commodo\",\n \"username\": \"incididunt consequat\"\n }\n ],\n \"status\": -92106336,\n \"text\": \"commodo ull\"\n}" + "body": "{\n \"data\": [\n {\n \"admin\": false,\n \"cron\": \"cupidatat nostrud\",\n \"email\": \"udtQkVtNcxr@OJMRrDDwMlfw.udu\",\n \"password\": \"dolore consectetur quis n\",\n \"telegram_user_id\": \"sint in\",\n \"username\": \"in minim ea labo\"\n },\n {\n \"admin\": false,\n \"cron\": \"enim exercitation laboris voluptate aute\",\n \"email\": \"jQyQftlI@zOMiqukOfCTGwRN.bp\",\n \"password\": \"non minim tempor laboris exercitation\",\n \"telegram_user_id\": \"ipsum Excepteur adipisicing\",\n \"username\": \"ad\"\n }\n ],\n \"status\": -85994498,\n \"text\": \"pariatur nostrud cupidatat\"\n}" }, { "name": "Authentication error", @@ -2293,7 +2758,7 @@ } ], "cookie": [], - "body": "{\n \"detail\": {},\n \"message\": \"irure ad do quis\"\n}" + "body": "{\n \"detail\": {},\n \"message\": \"non elit\"\n}" } ] } @@ -2327,14 +2792,14 @@ } ], "body": { - "mode": "raw", - "raw": "{\n \"telegram_user_id\": \"do quis\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, + "mode": "raw", + "raw": "{\n \"telegram_user_id\": \"adipisicing ut occaecat\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, "url": { "raw": "{{baseUrl}}/api/telegram", "host": [ @@ -2360,14 +2825,14 @@ } ], "body": { - "mode": "raw", - "raw": "{\n \"telegram_user_id\": \"do quis\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, + "mode": "raw", + "raw": "{\n \"telegram_user_id\": \"adipisicing ut occaecat\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, "url": { "raw": "{{baseUrl}}/api/telegram", "host": [ @@ -2389,7 +2854,7 @@ } ], "cookie": [], - "body": "{\n \"data\": {\n \"admin\": false,\n \"email\": \"VNB@NeqjbTmHnkWDwPacdUoXgpYVTNlD.iip\",\n \"password\": \"fugiat ipsum\",\n \"telegram_user_id\": \"et\",\n \"username\": \"nostrud laborum\"\n },\n \"status\": -78288268,\n \"text\": \"laborum minim\"\n}" + "body": "{\n \"data\": {\n \"admin\": true,\n \"cron\": \"id in Excepteur\",\n \"email\": \"E3rj@zUSyCWAiewlz.vrx\",\n \"password\": \"sunt pariatur\",\n \"telegram_user_id\": \"elit\",\n \"username\": \"mollit incididunt nostrud\"\n },\n \"status\": -87469860,\n \"text\": \"ullamco in\"\n}" }, { "name": "Validation error", @@ -2403,14 +2868,14 @@ } ], "body": { - "mode": "raw", - "raw": "{\n \"telegram_user_id\": \"do quis\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, + "mode": "raw", + "raw": "{\n \"telegram_user_id\": \"adipisicing ut occaecat\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, "url": { "raw": "{{baseUrl}}/api/telegram", "host": [ @@ -2432,7 +2897,7 @@ } ], "cookie": [], - "body": "{\n \"detail\": {\n \"\": {\n \"\": [\n \"velit\",\n \"ut laboris\"\n ]\n }\n },\n \"message\": \"dolore nostrud officia ex\"\n}" + "body": "{\n \"detail\": {\n \"\": {\n \"\": [\n \"tempor consectetur sint adipisicing\",\n \"occaecat laborum consectetur\"\n ]\n }\n },\n \"message\": \"dolor est officia\"\n}" }, { "name": "Authentication error", @@ -2446,14 +2911,14 @@ } ], "body": { - "mode": "raw", - "raw": "{\n \"telegram_user_id\": \"do quis\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, + "mode": "raw", + "raw": "{\n \"telegram_user_id\": \"adipisicing ut occaecat\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, "url": { "raw": "{{baseUrl}}/api/telegram", "host": [ @@ -2475,7 +2940,7 @@ } ], "cookie": [], - "body": "{\n \"detail\": {},\n \"message\": \"irure ad do quis\"\n}" + "body": "{\n \"detail\": {},\n \"message\": \"non elit\"\n}" } ] } @@ -2483,10 +2948,10 @@ } ], "variable": [ - { - "key": "baseUrl", - "value": "https://aktienbot.flokaiser.com", - "type": "string" - } + { + "key": "baseUrl", + "value": "/", + "type": "string" + } ] } \ No newline at end of file diff --git a/telegram_bot/Dockerfile.bot b/telegram_bot/Dockerfile similarity index 78% rename from telegram_bot/Dockerfile.bot rename to telegram_bot/Dockerfile index 58002cc..ca7ffb7 100644 --- a/telegram_bot/Dockerfile.bot +++ b/telegram_bot/Dockerfile @@ -10,5 +10,8 @@ RUN pip install -r requirements.txt --src /usr/local/src --no-warn-script-locati # Copy the source code to the working directory COPY telegram_bot /srv/flask_app -# Run the application -CMD ["/usr/local/bin/python", "bot.py"] +# Change file permissions +RUN chmod +x ./deploy/start.sh + +# Run the app +CMD ["./deploy/start.sh"] \ No newline at end of file diff --git a/telegram_bot/Dockerfile.updates b/telegram_bot/Dockerfile.updates deleted file mode 100644 index 0f7e630..0000000 --- a/telegram_bot/Dockerfile.updates +++ /dev/null @@ -1,14 +0,0 @@ -FROM python:3.10-slim - -# Change the working directory to the root of the project -WORKDIR /srv/flask_app - -# Install the dependencies -COPY telegram_bot/requirements.txt /srv/flask_app/ -RUN pip install -r requirements.txt --src /usr/local/src --no-warn-script-location - -# Copy the source code to the working directory -COPY telegram_bot /srv/flask_app - -# Run the application -CMD ["/usr/local/bin/python", "bot_updates.py"] diff --git a/telegram_bot/api_handling/api_handler.py b/telegram_bot/api_handling/api_handler.py index 181fd71..35aef19 100644 --- a/telegram_bot/api_handling/api_handler.py +++ b/telegram_bot/api_handling/api_handler.py @@ -2,8 +2,8 @@ script for communicating with webservice to get data from database """ __author__ = "Florian Kellermann, Linus Eickhoff" -__date__ = "16.03.2022" -__version__ = "0.0.1" +__date__ = "26.04.2022" +__version__ = "1.0.1" __license__ = "None" #side-dependencies: none @@ -13,6 +13,9 @@ import sys import os import requests as r from croniter import croniter # used for checking cron formatting +from dotenv import load_dotenv + +load_dotenv() # loads environment vars # note: for more information about the api visit swagger documentation on https://gruppe1.testsites.info/api/docs#/ @@ -287,6 +290,7 @@ class API_Handler: int: status code """ with r.Session() as s: + time = time[:-3] + "Z" # remove last character and add Z to make it a valid date for db headers = {'Authorization': 'Bearer ' + self.token + ":" + str(user_id)} transaction = {"comment": str(comment), "count": float(count), "isin": str(isin), "price": float(price), "time": str(time)} # set transaction as JSON with all the attributes needed according to Swagger docs req = s.post(self.db_adress + "/transaction", json=transaction, headers=headers) @@ -340,21 +344,21 @@ class API_Handler: Args: email (string): email of the user - is_admin (String): "true" if user should be Admin, "false" if not + is_admin (bool): "true" if user should be Admin, "false" if not Returns: int: status code """ with r.Session() as s: headers = {'Authorization': 'Bearer ' + self.token} # only bot token is needed, user is chosen by email - req = s.put(self.db_adress + "/user/setAdmin", json={"admin": str(is_admin),"email": str(email)}) + req = s.put(self.db_adress + "/user/setAdmin", json={"admin": is_admin,"email": str(email)}, headers=headers) return req.status_code if __name__ == "__main__": # editable, just for basic on the go testing of new functions print("This is a module for the telegram bot. It is not intended to be run directly.") - handler = API_Handler("https://gruppe1.testsites.info/api", "bot@example.com", "bot") + handler = API_Handler("https://gruppe1.testsites.info/api", str(os.getenv("BOT_EMAIL")), str(os.getenv("BOT_PASSWORD"))) # get creds from env print(handler.token) keywords = handler.get_user_keywords(user_id = 1709356058) #user_id here is currently mine (Linus) print(keywords) diff --git a/telegram_bot/bot.py b/telegram_bot/bot.py index f5c3bef..346a610 100644 --- a/telegram_bot/bot.py +++ b/telegram_bot/bot.py @@ -3,8 +3,8 @@ script for telegram bot and its functions """ __author__ = "Florian Kellermann, Linus Eickhoff" -__date__ = "11.03.2022" -__version__ = "0.0.4" +__date__ = "26.04.2022" +__version__ = "1.2.2" __license__ = "None" # side-dependencies: none @@ -14,13 +14,11 @@ __license__ = "None" # API Documentation https://core.telegram.org/bots/api # Code examples https://github.com/eternnoir/pyTelegramBotAPI#getting-started -import email import os import telebot import sys import logging -import json import re import news.news_fetcher as news @@ -118,7 +116,7 @@ def send_all_users(message): bot.send_message(chat_id=user_id, text=f'Username: {username}\nEmail: {email}\nID: {id}\nCron: {cron}\nAdmin: {admin}') # format user data into readable message text -@bot.message_handler(commands=['setAdmin', 'SetAdmin']) # set admin rights to user TBD: not working!! +@bot.message_handler(commands=['setAdmin', 'SetAdmin', 'setadmin', 'Setadmin']) # set admin rights to user TBD: not working!! def set_admin(message): """ Set admin rights to user @@ -136,7 +134,7 @@ def set_admin(message): bot.reply_to(message, "You have to be an admin to use this command") return - bot.send_message(chat_id=user_id, text='send email and "true" if this account should have admin rights, else "false"\n in format: ,') # ask for email and admin rights to set + bot.send_message(chat_id=user_id, text='send email and true if this account should have admin rights, else false\n in format: ,') # request email and admin rights to change to bot.register_next_step_handler(message, set_admin_step) def set_admin_step(message): @@ -149,7 +147,11 @@ def set_admin_step(message): return email = args_message[0] - is_admin = args_message[1] + is_admin = False # default: False + + if args_message[1].lower() == "true": # if user types true, set is_admin to true + is_admin = True + status = api_handler.set_admin(email, is_admin) # set admin in db if(status == 200): @@ -278,7 +280,7 @@ def send_share_update(message): def send_share_price(message): str_share_price = share_fetcher.get_share_price(str(message.text)) - bot.reply_to(message, str_share_price) + bot.reply_to(message, str_share_price) # add dollar symbol etc. @bot.message_handler(commands=['allnews', 'Allnews']) # /allnews -> get all news @@ -479,8 +481,8 @@ def set_new_transaction_step(message): amount = float(transaction_data[2]) price = float(transaction_data[3]) time = dt.datetime.now().isoformat() - #print("\n\n\n\n\n") - #print(f"{symbol},{amount},{price},{time}") + print("\n\n\n\n\n") + print(f"{isin},{amount},{price},{time}") status = api_handler.set_transaction(user_id, desc, isin, amount, price, time) if status == 200: diff --git a/telegram_bot/bot_updates.py b/telegram_bot/bot_updates.py index 3bca738..f48a824 100644 --- a/telegram_bot/bot_updates.py +++ b/telegram_bot/bot_updates.py @@ -2,21 +2,16 @@ script for regularly sending updates on shares and news based on user interval """ __author__ = "Florian Kellermann, Linus Eickhoff" -__date__ = "05.04.2022" -__version__ = "1.0.1" +__date__ = "26.04.2022" +__version__ = "1.0.2" __license__ = "None" -from calendar import month -from symtable import Symbol from dotenv import load_dotenv -from shares.share_fetcher import get_share_price import news.news_fetcher as news_fetcher import time -import datetime import os from bot import bot import sys -from multiprocessing import Process from apscheduler.schedulers.background import BackgroundScheduler from api_handling.api_handler import API_Handler @@ -153,9 +148,16 @@ def update_for_user(p_user_id, p_my_handler): if(keywords): # if keywords exist and array is not empty send_to_user("If you haven't read yet: \nHere are some interesting news according to your keywords:", pUser_id=p_user_id) for keyword in keywords: - news = news_fetcher.get_top_news_by_keyword(keyword)["articles"][0] # only use the most popular news - news_formatted = news_fetcher.format_article(news) # format for message - send_to_user(f"_keyword: {keyword}_\n\n{news_formatted}", pUser_id=p_user_id, md_mode=True) # send news with related keyword in Markdown + news = news_fetcher.get_top_news_by_keyword(keyword)["articles"] + + if not news: # if empty news array + send_to_user(f"No news found for keyword _{keyword}_.", pUser_id=p_user_id, md_mode=True) + + if news == None: # if news is none + send_to_user(f"Server error for keyword _{keyword}_.", pUser_id=p_user_id, md_mode=True) + else: + news_formatted = news_fetcher.format_article(news[0]) # format for message, only use the most popular article + send_to_user(f"_keyword: {keyword}_\n\n{news_formatted}", pUser_id=p_user_id, md_mode=True) # send news with related keyword in Markdown diff --git a/telegram_bot/deploy/start.sh b/telegram_bot/deploy/start.sh index 232326f..75c6e21 100644 --- a/telegram_bot/deploy/start.sh +++ b/telegram_bot/deploy/start.sh @@ -1,3 +1,4 @@ #!/usr/bin/env sh -python bot.py \ No newline at end of file +python bot.py & +python bot_updates.py \ No newline at end of file diff --git a/telegram_bot/news/news_fetcher.py b/telegram_bot/news/news_fetcher.py index a6dad7e..bd083b5 100644 --- a/telegram_bot/news/news_fetcher.py +++ b/telegram_bot/news/news_fetcher.py @@ -2,15 +2,13 @@ script for news fetching (by keywords) """ __author__ = "Florian Kellermann, Linus Eickhoff" -__date__ = "15.03.2022" -__version__ = "0.0.1" +__date__ = "26.04.2022" +__version__ = "1.0.0" __license__ = "None" import sys import os -import json import requests -import datetime as dt from newsapi import NewsApiClient from dotenv import load_dotenv diff --git a/telegram_bot/shares/share_fetcher.py b/telegram_bot/shares/share_fetcher.py index 1aa3376..c7ec63f 100644 --- a/telegram_bot/shares/share_fetcher.py +++ b/telegram_bot/shares/share_fetcher.py @@ -7,7 +7,6 @@ __version__ = "0.0.2" __license__ = "None" import yfinance -import json def get_share_price(str_symbol):