This CRM API is a simple back-end service built in Go that allows users to manage a collection of customer records. It provides functionality for creating, reading, updating, and deleting customer records.
The API enables the following functionalities:
- Getting a list of all customers
- Getting data for a single customer
- Adding a customer
- Updating a customer's information
- Batch updating customers' information
- Removing a customer
- API Overview (accessible at the root endpoint)
To install the project, you'll need to have Go installed on your machine. Follow these steps:
- Clone the repository:
git clone https://github.com/your-username/your-repo.git
cd your-repo
- Build the application:
go build -o crm-api
You can launch the API by running the compiled binary:
./crm-api
By default, the server will start on port 8080. You can access the API at http://localhost:8080
.
Here's how you can interact with the API using common HTTP methods:
- Method: GET
- Endpoint:
/customers
- Example:
curl http://localhost:8080/customers
- Method: GET
- Endpoint:
/customers/{id}
- Example:
curl http://localhost:8080/customers/1
- Method: POST
- Endpoint:
/customers
- Body:
{
"name": "Example Name",
"role": "Example Role",
"email": "Example Email",
"phone": 5550199,
"contacted": true
}
- Example:
curl -X POST -H "Content-Type: application/json" -d '{"name": "Example Name", "role": "Example Role", "email": "Example Email", "phone": 5550199, "contacted": true}' http://localhost:8080/customers
- Method: DELETE
- Endpoint:
/customers/{id}
- Example:
curl -X PUT -H "Content-Type: application/json" -d '{"name": "Updated Name", "role": "Updated Role", "email": "Updated Email", "phone": 5550199, "contacted": true}' http://localhost:8080/customers/1
- Method: DELETE
- Endpoint:
/customers/{id}
- Example:
curl -X DELETE http://localhost:8080/customers/1
- Method: PUT
- Endpoint:
/customers/batchUpdate
- Body: An array of customer objects to be updated.
[
{
"id": "1",
"name": "Updated Name",
"role": "Updated Role",
"email": "Updated Email",
"phone": 5550199,
"contacted": true
},
{
"id": "2",
"name": "Another Updated Name",
"role": "Another Updated Role",
"email": "AnotherUpdatedEmail@example.com",
"phone": 5550299,
"contacted": false
}
]
- Example:
curl -X PUT -H "Content-Type: application/json" -d @batch_update.json http://localhost:8080/customers/batchUpdate
You can run the unit tests for the project by executing:
go test
Feel free to fork the repository and submit pull requests.
This project is licensed under the MIT License - see the LICENSE.md file for details.