The Furniture Shop API allows developers to access and integrate the functionality of Furniture Shop with other applications. The API allows users to search for and retrieve information about furniture products, as well as place orders for furniture.
- Git (to clone the repository)
- Ruby 2.7.4
- Ruby on Rails 7.0.4
- SQLITE3 (to run the database locally)
- PostgreSQL (deployment)
- Postman / Thunderclient (to test the API)
- Railway/Render CLI (if you want to deploy to railway or render)
- Clone the repository
- Run the following commands in the repository:
- cd <path_to_project> (if you cloned the repository)
- bundle install
- rails db:migrate
- rails server
- Open Postman to test the API endpoints or use the following link:
- http://localhost:3000/<the_endpoint>
-
/products
- This endpoint returns a list of all the products available in the furniture shop. -
/products/:id
- This endpoint returns the details of a specific product based on its id. -
/categories
- This endpoint returns a list of all the categories of products available in the furniture shop. -
/signup
- This endpoint is used to create a new account for the user in the furniture shop. -
/login
- This endpoint is used to log in to the user's account in the furniture shop. -
/me
- This endpoint keeps the user logged in using session cookies -
/logout
- This endpoint is used to log out from the user's account in the furniture shop.
-
/products
- None -
/products/:id
- id (required) - The unique ID of the product to retrieve. -
/signup - username (required) - The desired username for the new account. Password (required) - The desired password for the new account. Email (required) - The email address associated with the new account.
{
"username":"testuser",
"email":"testuser@example.com",
"password":"xxxxxxxx",
"password_confirmation":"xxxxxxxx"
}
/login
- username (required) - The username of the account to log in to. password (required) - The password of the account to log in to.
{
"username":"testuser",
"password":"xxxxxxxx",
}
-
/logout
- None -
/categories
- None
GET /products
- An array of objects, each representing a furniture product in the shop.
[
{
"id": 9,
"title": "Foster 8 Seater Dining Set",
"description": "Create lifetime memories while dinning with family and friends using this high quality 8 Seater Dining Set. The set is tied off nicely with a set of 8 high quality wooden dining chairs. It will surely be the center piece of your home.",
"image_url": "https://elegance.co.ke/pub/media/catalog/product/cache/8d8a0146498f1100582724fca223eeb2/f/o/foster_1.jpg",
"price": 129995,
"category": {
"name": "Dining"
}
},
{
"id": 10,
"title": "Vickie 4 Seater Dining Set",
"description": "Show your home some love by adding this classy dining set.\n\nIt accommodates 4 and comes with a large table, offering plenty room for everyone.\n\nIts seats are also cushioned, making meal times a comfy affair.",
"image_url": "https://elegance.co.ke/pub/media/catalog/product/cache/b7c3a6b28eb4432f8bd6c315e4890c68/v/i/vickie_1.jpg",
"price": 59995,
"category": {
"name": "Dining"
}
}
]
GET /products/:id
- A single object representing the requested furniture product.
{
"id": 9,
"title": "Foster 8 Seater Dining Set",
"description": "Create lifetime memories while dinning with family and friends using this high quality 8 Seater Dining Set. The set is tied off nicely with a set of 8 high quality wooden dining chairs. It will surely be the center piece of your home.",
"image_url": "https://elegance.co.ke/pub/media/catalog/product/cache/8d8a0146498f1100582724fca223eeb2/f/o/foster_1.jpg",
"price": 129995,
"quantity": 1,
"category": {
"name": "Dining"
},
"reviews": []
}
GET /categories
- An array of objects, each representing a furniture category in the shop.
[
{
"id": 1,
"name": "Living-Room",
"description": "Funiture intended for user in the living room."
},
{
"id": 2,
"name": "Kitchen",
"description": "Pieces of furniture in a kitchen, like cabinets, countertops, sinks, and so forth."
},
{
"id": 3,
"name": "Dining",
"description": "Furniture intended for use in a dining room. These items include tables and chairs."
},
{
"id": 4,
"name": "Bedroom",
"description": "Funiture intended for user in the bedroom."
}
]
POST /signup
- A success (user object) or error message indicating whether the account was successfully created.
{
"errors": [
"Password can't be blank",
"Username can't be blank",
"Email can't be blank",
"Password is too short (minimum is 8 characters)"
]
}
POST /login
- A success (user object) or error message indicating whether the user was successfully logged in.
{
"errors": [
"Invalid username or password"
]
}
POST /logout
- A success or error message indicating whether the user was successfully logged out.
So far so good there are no bugs related to this project.
To make a contribution to the code used or any suggestions you can click on the contact link and email me your suggestions.
- Email: wafulacharles47@gmail.com
This project is under MIT.
Copyright (c) 2022 Charles Wafula