Skip to content

Latest commit

 

History

History
38 lines (22 loc) · 1.56 KB

README.md

File metadata and controls

38 lines (22 loc) · 1.56 KB

RestTemplate Initialization:

RestTemplate is initialized as an instance variable of the class. This will be used to make HTTP requests to external APIs.

getSingleProduct Method:

This method retrieves information about a single product by its ID from an external API. It uses RestTemplate to perform a GET request to the specified API endpoint. The response is converted into a ProductDto object. The data from ProductDto is then used to create and return a Product object.

getCart Method:

This method retrieves all products available in the store from an external API. It uses RestTemplate to perform a GET request to the specified API endpoint. The response containing an array of Product objects is retrieved and returned.

updateProduct Method:

This method updates the details of a product with a given ID. It first retrieves the existing product using getSingleProduct method. Then, it creates a ProductDto object with the updated details from the retrieved Product object. It uses RestTemplate to perform a PUT request to update the product information on the external API.

deleteProduct Method:

This method deletes a product with the given ID. It retrieves the product using getSingleProduct method. Then, it uses RestTemplate to perform a DELETE request to remove the product from the external API. Overall, this code provides functionality to interact with an external API that manages product information. It supports retrieving single product details, fetching all products, updating product information, and deleting products.