PromoCodeManager is a SpringBoot application that helps you manage discount codes (promo codes) for sales and promotions.
- Java >= 19.0.1
- 100MB of storage space
- Download the application:
- Visit the Releases section on the project's main page and download the
.jarfile.
- Visit the Releases section on the project's main page and download the
- Run the application:
- Navigate to the directory where you downloaded the
.jarfile. - Open your terminal and run the following command:
- Navigate to the directory where you downloaded the
java -jar <file_name>.jarReplace <file_name> with the actual name of the downloaded .jar file.
-
Create new product (POST):
/products- Creates a new product
- Requries specified
name(String),description(String),price(Double), andcurrency(3 letter currency code String in ISO 4217 format) in the JSON request body.
curl --location 'http://localhost:8080/api/v1/products' \ --header 'Content-Type: application/json' \ --data '{ "name" : "NikeShoes", "description" : "Clothes", "price" : 150.0, "currency" : "USD" }'
-
Get all products (GET):
/products- Retrieves a list of all available products.
curl --location 'http://localhost:8080/api/v1/products' - Retrieves a list of all available products.
-
Get product discount price (GET):
/products/discount-price- Calculates the discounted price of a product based on a provided promo code.
- Requires query parameters
productNameandpromoCodeText.
curl --location 'http://localhost:8080/api/v1/products/discount-price?productName=NikeShoes&promoCodeText=SUMMER2024'
-
Update product data (PUT):
/products- Updates existing product data with new
name,description,price, andcurrency. - Requires
nameof the existing product as a query parameter. - New product information (
name,description,price, andcurrency) in the JSON request body are optional.
curl --location --request PUT 'http://localhost:8080/api/v1/products?name=NikeShoes' \ --header 'Content-Type: application/json' \ --data '{ "description" : "Shoes" }'
- Updates existing product data with new
-
Create new fixed-amount promo code (POST):
/promo-codes/fixed-amount- Creates a new promo code with a fixed discount amount.
- Requires:
text(String),expiration date(YYYY-MM-DDformatted String),allowed usages(Integer),discount amount(Double), andcurrency(3 letter currency code String in ISO 4217 format) in the JSON request body.
curl --location 'http://localhost:8080/api/v1/promo-codes/fixed-amount' \ --header 'Content-Type: application/json' \ --data '{ "text" : "SUMMER2024", "expirationDate" : "2024-08-14", "usagesAllowed" : "5", "discountAmount" : 100, "discountCurrency" : "USD" }'
-
Create new percentage promo code (POST):
/promo-codes/percentage- Creates a new promo code with a percentage discount.
- Requires:
text(String),expiration date(YYYY-MM-DDformatted String),allowed usages(Integer), anddiscount percentage(Integer) in the JSON request body.
curl --location 'http://localhost:8080/api/v1/promo-codes/percentage' \ --header 'Content-Type: application/json' \ --data '{ "text" : "EXTRA2024", "expirationDate" : "2024-08-14", "usagesAllowed" : "1", "discountPercentage" : 65 }'
-
Get all promo codes (GET):
/promo-codes- Retrieves a list of all available promo codes.
curl --location 'http://localhost:8080/api/v1/promo-codes' - Retrieves a list of all available promo codes.
-
Get promo code details (GET):
/promo-codes- Retrieves details of a specific promo code.
- Requires query parameter
text(String).
curl --location 'http://localhost:8080/api/v1/promo-codes?text=SUMMER2024'
-
Simulate purchase (POST):
/purchases- Simulates a purchase for a product with an optional promo code applied.
- Requires query parameters
productName(String) andpromoCodeText(String) (optional).
curl --location --request POST 'http://localhost:8080/api/v1/purchases?productName=NikeShoes&promoCodeText=SUMMER2024'
-
[Implemented in v0.2.0 release] Generate sales report by currency (GET):
/reports/sales/by-currency- Generates a sales report for registered purchases.
- Query parameters
startDateandendDateinYYYY-MM-DDformat are optional.
curl --location 'http://localhost:8080/api/v1/reports/sales/by-currency?startDate=2024-02-04&endDate=2024-06-04'