diff --git a/README.md b/README.md index d73479448bbf60988fbb985c6f60f34c2ceb5d47..ec22eba212687057edd8f6ac45aa15c8f662fdf3 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,15 @@ -## gomazon +# gomazon ## Getting Started -### Start without Docker: +#### Start without Docker: ``` ./scripts/start-mariadb.sh # cd src/gomazon && go run main.go ``` -### Build, Start and Stop service using Docker Compose +#### Build, Start and Stop service using Docker Compose ``` docker compose build @@ -20,9 +20,9 @@ docker compose down ## All API Functions In this section all API-Functions will be presented with an example call! +### BASIC FUNCTIONS - -### GET JWT-Token +#### GET JWT-Token Use the Result-Token for all marked API-Functions! ``` curl --location --request GET 'localhost:8080/createJWT' \ @@ -33,7 +33,15 @@ curl --location --request GET 'localhost:8080/createJWT' \ }' ``` -### CREATE PRODUCT (Admin only) +#### Health Check +Function tests if the service is running. +``` +curl --location 'localhost:8080/health' +``` + +### Product-Functions + +#### CREATE PRODUCT (Admin only) (TOKEN REQUIRED) ``` curl --location 'localhost:8080/products' \ --header 'Content-Type: application/json' \ @@ -45,7 +53,7 @@ curl --location 'localhost:8080/products' \ }' ``` -### UPDATE PRODUCT (Admin only) +#### UPDATE PRODUCT (Admin only) (TOKEN REQUIRED) ``` curl --location --request PUT 'localhost:8080/products/1' \ --header 'Content-Type: application/json' \ @@ -57,24 +65,94 @@ curl --location --request PUT 'localhost:8080/products/1' \ }' ``` -### DELETE PRODUCT (Admin only) +#### DELETE PRODUCT (Admin only) (TOKEN REQUIRED) ``` curl --location --request DELETE 'localhost:8080/products/1' \ --header 'Authorization: Bearer INSERT_TOKEN_HERE' ``` -### GET ALL PRODUCTS +#### GET ALL PRODUCTS ``` curl --location 'localhost:8080/products' ``` -### GET SINGLE PRODUCT +#### GET SINGLE PRODUCT ``` curl --location 'localhost:8080/products/1' ``` -### Health Check -Function tests if the service is running. +### Rating-Functions + +#### POST RATING (TOKEN REQUIRED) ``` -curl --location 'localhost:8080/health' -``` \ No newline at end of file +curl --location 'localhost:8080/products/2/rating' \ +--header 'Content-Type: application/json' \ +--header 'Authorization: Bearer INSERT_TOKEN_HERE' \ +--data '{ + "Content": "Great Product!", + "Rating": 5 +}' +``` + +#### DELETE RATING (TOKEN REQUIRED) +Only Admins and Owner of the Rating can use this +``` +curl --location --request DELETE 'localhost:8080/ratings/3' \ +--header 'Authorization: Bearer INSERT_TOKEN_HERE' +``` + +#### READ ALL RATINGS +``` +curl --location 'localhost:8080/ratings' +``` + +### Bankaccount-Functions + +#### CREATE BANKACCOUNT (TOKEN REQUIRED) +If one user has already an account, the existing account is the result value. +``` +curl --location 'localhost:8080/bankaccounts' \ +--header 'Content-Type: application/json' \ +--header 'Authorization: Bearer INSERT_TOKEN_HERE' \ +--data '{ + "iban": "DE1234", + "bankName": "Sparkasse", + "balance": 200.00 +}' +``` + +#### Deposit or withdraw (TOKEN REQUIRED) +``` +curl --location --request PUT 'localhost:8080/bankaccounts' \ +--header 'Content-Type: application/json' \ +--header 'Authorization: Bearer INSERT_TOKEN_HERE' \ +--data '{ + "amount": 50.0 +}' +``` + +### ShoppingCart-Functions + +#### CREATE SHOPPINGCART (TOKEN REQUIRED) +If one user has already an ShoppingCart, the existing ShoppingCart is the result value. +``` +curl --location --request POST 'localhost:8080/ShoppingCart' \ +--header 'Authorization: Bearer INSERT_TOKEN_HERE' +``` + +#### ADD PRODUCT TO SHOPPINGCART (TOKEN REQUIRED) +``` +curl --location 'localhost:8080/ShoppingCart/Product/1' \ +--header 'Content-Type: application/json' \ +--header 'Authorization: Bearer INSERT_TOKEN_HERE' \ +--data '{ + "amount": 3 +}' +``` + +#### PAY SHOPPINGCART (TOKEN REQUIRED) +``` +curl --location --request POST 'localhost:8080/ShoppingCart/pay' \ +--header 'Authorization: Bearer INSERT_TOKEN_HERE' +``` +