# Microservice API Docs # Administration (Nick, Justus) ## Admin User Service (Justus) * Login * Register (nur angemeldete) * Update User (*) * Refresh token ### Login [/login] #### Login with e-mail [POST] Example description + Request (application/json) { "email": "test@test.de", "password": "test" } + Response 200 (application/json) + Body { "token": "jwtoken" } + Response 403 (application/json) + Body { "success": "false", "message": "Unauthorized" } ## Product Service (Nick) * Create new product * Get all products (with filters) * Get one product by id * Update product by id * Mark for deleted by id ## Notification Service (Justus) * Periodic cronjob that sends out mails * Send mail ## Tracking Service (Nick) * Track product * Get trackings by user id with time filter ## Frontend * Angular Application <!-- Shop Services ---> # Shop (Yannik, Marina, Kevin) ## Shop User Service (Kevin) * Register (/) * Login (/) * Update data (x) * Refresh token (x) * Forget password (x) * Get user data (x) ### Login [/login] [POST] Log in with e-mail and password + Request (application/json) { "email": "test@test.de", "password": "test" } + Response 200 (application/json) + Body { "token": "jwt-token" } + Response 403 (application/json) + Body { "reason": "Account not found or password mismatch" } ### Register [/register] [POST] + Request (application/json) { "email": "test@test.de", "password": "test" } + Response 200 (application/json) + Body { "email": "test1@test.de" } + Response 400 (application/json) + Body { "reason": "Account with that email does already exist" } ## Review Service (Marina) #### Create review [POST] A review consists of a title, rating and a description. The rating can be set from 0-5.The review is associated with an user. For better handling each review has an unique id. (UUID) + Request (application/json) { "productId": "333333-e89b-12d3-a456-426614174000" "id": "123e4567-e89b-12d3-a456-426614174000", "title": "Stupid App", "description": "App does not work", "rating": "0" } + Response 200 (application/json) + Body { "message": "Review saved" } + Response 403 (application/json) + Body { "success": "false", "message": "Unauthorized" } #### Change review by id [PUT] Changes an existing review of the user. The review gets changed by id with the adjusted title, description, date and rating. + Request (application/json) { "id": "123e4567-e89b-12d3-a456-426614174000", "title": "Stupid App", "description": "App does not work", "date": "01.01.2021", "rating": "0" } + Response 200 (application/json) + Body { "message": "Review changes saved" } + Response 403 (application/json) + Body { "success": "false", "message": "Unauthorized" } #### Delete own reviews by id [DELETE] Deletes and existing review of the user. + Request (application/json) { "id": "123e4567-e89b-12d3-a456-426614174000" } + Response 200 (application/json) + Body { "message": "Review deleted" } + Response 404 (application/json) + Body { "success": "false", "message": "Review not found" } + Response 403 (application/json) + Body { "success": "false", "message": "Unauthorized" } ## Cart Service (Yannik) [/cart] ## User Access ### JWT Structure This Microservice expects an accountID, iad (creation timestamp), exp (expiration timestamp) aswell as the subject for authentification within the payload of a JWT-Token. The secret key is generated using the HS512 algorithm. ### Add Items to Cart [/] [POST] + Request (application/json) #### Header ```json { "...": ..., "Authorization": "Bearer ...", //JWT-Token } ``` #### Body ```json { "productId": ..., "count": ... } ``` + Response 200 (application/json) #### Body ```json [ { "productId": ..., "count": ... }, ... ] ``` <hr> ### Get Cart [/] [GET] + Request (application/json) #### Header ```json { "...": ..., "Authorization": "Bearer ...", //JWT-Token } ``` + Response 200 (application/json) #### Body ```json [ { "productId": ..., "count": ... }, ... ] ``` <hr> ### Remove Items from Cart [/delete] [DELETE] + Request (application/json) #### Header ```json { "...": ..., "Authorization": "Bearer ...", //JWT-Token } ``` #### Body ```json { "productId": ..., "count": ... } ``` + Response 200 (application/json) + Body ```json [ { "productId": ..., "count": ... }, ... ] ``` <hr> ### Clear Cart [/clear] [DELETE] + Request (application/json) #### Header ```json { "...": ..., "Authorization": "Bearer ...", //JWT-Token } ``` #### Body ```json {} ``` + Response 200 (application/json) #### Body ```json [] ``` ## Service Access ### JWT Structure Service related requests need to contain an (encrypted) service secret to validate the request origin and authorize advanced administrative execution. ### Get Cart [/] [GET] + Request (application/json) #### Header ```json { "...": ..., "Authorization": "Bearer ...", //Service JWT-Token } ``` #### Body ```json { "userId": ..., } ``` + Response 200 (application/json) #### Body ```json [ { "productId": ..., "count": ... }, ... ] ``` <hr> ### Clear Cart [/clear] [DELETE] + Request (application/json) #### Header ```json { "...": ..., "Authorization": "Bearer ...", // Service JWT-Token } ``` #### Body ```json { "userId": ..., } ``` + Response 200 (application/json) #### Body ```json [] ``` ## Checkout Service (Marina) * Checkout (hole alle produkte aus dem warenkorb von yannik mit id, neue order erstellen und an shipping service schicken) order * Get orders, alle vergangen ## Shipping Service (Yannik) ### Create Shipping Info [/create/{userId}] [POST] + Request (application/json) #### Header ```json { "...": ..., "Authorization": "Bearer ...", // Service JWT-Token } ``` #### Body ```json <Order>{...order} ``` + Response 200 (application/json) #### Body ```json { "id": ..., "addressId": ..., "orderId": ..., "address": <Address>{...address} } ``` ## Frontend * Angular Application