Documentation | Release Notes | Solution Overview | Taking it further |
---|
E-Commerce Checkout API is a simplified e-commerce API that provides a single endpoint for performing a checkout action. The API takes a list of watch IDs and calculates the total cost of the watches in the cart based on the provided catalogue.
Below is the catalogue of four watches available in the system, along with their associated prices and discount information:
Watch ID | Watch Name | Unit Price | Discount Quantity | Discount Price |
---|---|---|---|---|
001 | Rolex | $100 | 3 | $200 |
002 | Michael Kors | $80 | 2 | $120 |
003 | Swatch | $50 | 0 | $0 |
004 | Casio | $30 | 0 | $0 |
- The first two products (Rolex and Michael Kors) have possible discounts. For example, if the user checks out three or six Rolex watches, they will receive the discounted price once or twice, respectively.
- There is no limit to the number of items or combinations of watches a user can checkout.
- There is no limit to the number of times a discount can be used.
- A user can checkout a single item if they wish.
To perform the checkout action, use the following endpoint:
Request
POST https://localhost:44361/api/Checkout
Headers
Accept: application/json
Content-Type: application/json
Authorization: ApiKey YOUR_API_KEY (For Test : 123)
Body
[
"001",
"002",
"001",
"004",
"003"
]
Body
{
"TotalPrice": 360
}
Follow the steps below to set up and run the API:
-
Clone the repository to your local machine.
-
Open the solution in Visual Studio.
-
Restore the NuGet packages by right-clicking on the solution and selecting "Restore NuGet Packages".
-
Build the solution by right-clicking on the solution and selecting "Build".
-
Run the API project by pressing F5 or selecting "Start Debugging" from the "Debug" menu.
The API will be running at https://localhost:44361/api/Checkout
.If you want to access it in your local environment, you should replace "44361" with the appropriate port number that you are using locally.
The API includes Swagger documentation for easy exploration of the endpoints. After running the API, you can access the Swagger UI by navigating to the following URL in your web browser:
http://localhost:44361/swagger/index.html
The Swagger UI provides an interactive way to interact with the API's endpoints and test the functionality.