Git Product home page Git Product logo

supermarket's Introduction

Supermarket API Documentation

This documentation provides information on how to use the Supermarket API endpoints.

Getting Started

To run the project locally, follow these steps:

  1. Ensure that Java 17 is installed on your machine. You can download it from here.
  2. Clone this repository:
    git clone https://github.com/MURATKAYMAZ56/supermarket.git
  1. Navigate to the project directory:
    cd supermarket
  1. Build the project:
    ./mvnw clean install
  1. Run the application:
    ./mvnw spring-boot:run

Making API Calls via Postman

You can use Postman (or any other client ) to make API calls to expose endpoints.

Base URL

http://localhost:8080/api/products

Endpoints

1. Upload a File

URL: POST /

Description: Upload a CSV file containing product information. You can use supermarket.csv file (resides in resource folder) for test purposes.

Parameters: file (multipart file): CSV file containing product information.

Example: Use Postman or any REST client to make a POST request to the base URL with a multipart form-data body containing a CSV file.

2. Get All Products

URL: GET / Description: Retrieve all products sorted by expiry date.

Response: A JSON array of product objects.

Example: Make a GET request to the base URL.

3. Get Product by Barcode

URL: GET /{barcode}

Description: Retrieve product information by its barcode.

Parameters: barcode (path parameter): The unique identifier of the product.

Response: A JSON object containing product details.

Example: Make a GET request to the base URL with the barcode appended to it.

4. Delete Product by Barcode

URL: DELETE /{barcode}

Description: Delete a product by its barcode.

Parameters: barcode (path parameter): The unique identifier of the product.

Example: Make a DELETE request to the base URL with the barcode appended

Accessing H2 Console

Supermarket application uses an H2 in-memory database, and you can access the H2 Console to view and query the data.

  1. Open your browser and go to http://localhost:8080/h2-console.
  2. In the login page, set the following values:
    JDBC URL: jdbc:h2:mem:testdb
    User Name: sa
    Password: pwd

3.Click the "Connect" button. 4. You will be redirected to the H2 Console. Here, you can view and execute SQL queries against the in-memory database. 5. To see data Click on PRODUCT table and run below script.

    SELECT * FROM PRODUCT 

Running Tests

To run tests, execute the following command:

    ./mvnw test

supermarket's People

Contributors

muratkaymaz56 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.