Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement API endpoints for Categories and Products (#4)
* chore: Switch from jbuilder to jsonapi-serializer This change came about after a number of research. I found that JSON:API standard follows best practices and it's something I want to become very good at. Also, based on the benchmark tests, it is way faster than jbuilder and the alternatives I found. * feat: Update schema to make category_id optional on products This update makes the `category_id` on the `products` to be optional so that it doesn't need to be provided when a product does not fit into a category yet. It also ensures that when a category is deleted, the products that depend will have their `category_id` field set to null. Finally, `available` and `currency` have been introduced to the `products` to table to help know the availability status of a product and the currency it uses. * test: Add tests for updates and deletion for products and category models * chore: Add default URLs to test and development environments * feat: Add helper to retrieve response body * test: Add test for controller routing to endpoints * chore: Include RequestsHelper in spec_helper.rb file * feat: Add routes for version 1 of categories and unmatched endpoints * feat: Add error handling and JsonResponse helper for API responses * chore: Add coverage for tests * chore: Ignore coverage directory * chore: Add 'simplecov' configuration to spec_helper.rb * refactor: Update error handling for controllers * feat: Add serializer for Category model * feat: Add JsonResponse and PaginationHelper for API responses * test: Add unit tests for CategoriesController to validate all actions * feat: Add controller for category API operations * style: Update code style * test: Add unit tests for validating filtering by name and search keywords * feat: Implement filtering based on name and search keywords * refactor: Move authentication validation to application controller * refactor: Update error handling responses and include Authentication mixin * feat: Add an authentication module to validate dev tokens and user IDs * feat: Add endpoints for products API operations * chore: Add database cleaner for active record * refactor: Update application_controller.rb to handle validation error * refactor: Update developer token and user ID retrieval * refactor: Add status code success metadata for successful JSON responses * refactor: Update to mock the valid_developer_token to return true always * feat: Add redis and HTTParty * test: Fix test cases for categories_controller.rb * feat: Update schema to include app ID * feat: Update authentication.rb to use the user service for validations * refactor: Improve pagination response * feat: Implement a method to handle bad requests. * feat: Add Redis as the caching store * feat: Add caching for single results * test: Add tests for route matching for products API endpoints * feat: Implement user service client to validate user, app and developer details * test: Add tests for UserServiceClient * feat: Add database_cleaner and shared_context.rb files * feat: Fix failing tests after adding mandatory app_id field * feat: Add authentication helper for request to spec_helper.rb * refactor: Move authentication helper to a separate module * feat: Update shared_contexts.rb to retrieve valid data * style: Rubocop style fixes * feat: Add logic for filtering products * feat: Add the AuthenticationHelper for request type tests * test: Add tests for product operation endpoints * feat: Add controller actions for Product endpoints * feat: Add serializer for products * style: Rubocop style fixes
- Loading branch information