Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

buyer be able to view available products #64

Conversation

niyibi250
Copy link
Collaborator

What does this PR do?

This pull request implements the AvailableProducts function, which retrieves available products from the database with pagination support. The function allows clients to request available products with optional pagination parameters (limit and page). If pagination parameters are not provided, default values are used (limit=10, page=1).

Description

  • Implementing the AvailableProducts route

This function should execute a database query to fetch available products where theisAvailablefield is set to true.
Pagination should be applied to limit the number of products returned per page and to skip the appropriate number of records based on the page number.
The function should include the category relation to eagerly load associated categories for each product.
Handling pagination:

If pagination parameters (limit and page) are not provided in the query, default values should be used (limit=10, page=1).

  • Constructing a JSON response

Once the products are fetched, the function should construct a JSON response containing the retrieved products, total pages, and the current page.

Total pages should be calculated based on the total count of available products and the specified limit.

  • Implementing error handling

The function should include appropriate error handling to handle any errors that may occur during the execution of the function (e.g., database query error, server error).
If an error occurs, the function should return a 500 status code along with an error message.

  • Testing

Test the AvailableProducts route to ensure it retrieves available products correctly with the expected pagination behavior.
Verify that error handling is working as expected and that appropriate responses are returned in case of errors.

Related Issues:

#37

Testing: I have tested the AvailableProducts function locally and verified that it retrieves available products correctly with the expected pagination behavior.

Screenshots:

  • swagger doc

image

  • postman

image

  • testing

image

- Checklist:

  • Implemented AvailableProducts function
  • Added appropriate error handling
  • Tested locally

@niyibi250 niyibi250 linked an issue May 14, 2024 that may be closed by this pull request
3 tasks
niyibi250 and others added 13 commits May 14, 2024 11:05
Feat: Buyer should be able to list products from vendors #57
This PR add the product swagger docs and some test category
Fixing the errors on the doumentation
…formation

create endpoints for category and also database schema

fix routes for products & categories

implement CRUD operations for category entity

create swagger docs for category routes

adds delete  documentation for category routes

complete documentation for category routes

implementing craate new product route and its controller

implementing get product route and its controller

working on update function

Extend API endpoints

store reference ID of vendor

ft-Product-Docs

This PR add the product swagger docs and some test category

bug-documentation-fixes

Fixing the errors on the doumentation

store reference ID of vendor

replacing try & catch with errorHandler middleware
add category testing cases
wayneleon1 and others added 8 commits May 16, 2024 16:20
-filter product based on availablity
-return number of product based on specified limit and number of page
Feat: Buyer should be able to list products from vendors #57
-am testing status code
-type of content-type if json
-status to be success
#57
Feat: Buyer should be able to list products from vendors #57
@niyibi250 niyibi250 closed this May 16, 2024
@niyibi250 niyibi250 deleted the 57-feat-buyer-should-be-able-to-list-products-from-vendors branch May 16, 2024 16:25
@niyibi250 niyibi250 linked an issue May 16, 2024 that may be closed by this pull request
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants