Skip to content

Fawry-Intern-Round4/Product-Api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Product API

The Product API service manages product-related operations such as adding, retrieving, and updating product details. It is part of the organization's microservices architecture.

Overview

The Product API provides functionality for:

  • Adding new products.
  • Retrieving product details by ID, code, or a list of IDs.
  • Updating product information.

Endpoints

Add Product

  • URL: /product
  • Method: POST
  • Description: Adds a new product.
  • Request Body:
    {
      "code": "string",
      "name": "string",
      "description": "string",
      "price": "number",
      "image": "string"
    }
  • Response:
    {
      "id": "long",
      "code": "string",
      "name": "string",
      "description": "string",
      "price": "number",
      "image": "string"
    }
  • Response Code: 201 Created

Get Product by ID

  • URL: /product/{id}
  • Method: GET
  • Description: Retrieves a product by its ID.
  • Path Variable: id (Long)
  • Response:
    {
      "id": "long",
      "code": "string",
      "name": "string",
      "description": "string",
      "price": "number",
      "image": "string"
    }
  • Response Code: 200 OK

Get Product by Code

  • URL: /product?code={code}
  • Method: GET
  • Description: Retrieves a product by its unique code.
  • Request Param: code (String)
  • Response:
    {
      "id": "long",
      "code": "string",
      "name": "string",
      "description": "string",
      "price": "number",
      "image": "string"
    }
  • Response Code: 200 OK

Get Products by List of IDs

  • URL: /product?ids={ids}
  • Method: GET
  • Description: Retrieves a list of products by their IDs.
  • Request Param: ids (Set of Longs)
  • Response:
    [
      {
        "id": "long",
        "code": "string",
        "name": "string",
        "description": "string",
        "price": "number",
        "image": "string"
      }
    ]
  • Response Code: 200 OK

Get All Products

  • URL: /product
  • Method: GET
  • Description: Retrieves a list of all products.
  • Response:
    [
      {
        "id": "long",
        "code": "string",
        "name": "string",
        "description": "string",
        "price": "number",
        "image": "string"
      }
    ]
  • Response Code: 200 OK

Update Product

  • URL: /product/{id}
  • Method: PUT
  • Description: Updates an existing product by ID.
  • Path Variable: id (Long)
  • Request Body:
    {
      "code": "string",
      "name": "string",
      "description": "string",
      "price": "number",
      "image": "string"
    }
  • Response:
    {
      "id": "long",
      "code": "string",
      "name": "string",
      "description": "string",
      "price": "number",
      "image": "string"
    }
  • Response Code: 200 OK

Configuration

  • Configure the database connection in the application.properties file:
    spring.datasource.url=jdbc:mysql://localhost:3306/your_database_name
    spring.datasource.username=your_db_username
    spring.datasource.password=your_db_password

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages