Categorygithub.com/fabiotavarespr/crm-backend

# README

CRM Backend - Udacity Golang Nanodegree Project

Go Gin Mongo GitHub release

This project implements a basic CRUD in a REST-API.

Your context would be for a customer in a CRM project scenario

Index

Stack

Execution

First, you need to start your docker infrastructure with the following command:

Start infrastructure

Makefile

make docker-compose-up

Docker Compose

docker-compose -f resources/docker-compose/docker-compose.yaml up -d

Stop infrastructure

Makefile

make docker-compose-down

Docker Compose

docker-compose -f resources/docker-compose/docker-compose.yaml down --remove-orphans

Start project

Once your infrastructure is up, start the API with the following command:

Makefile

make run-api

Go command

go run ./cmd/main.go

API

MethodResource
GET/health
GET/customers
GET/customers/{id}
POST/customers
PUT/customers/{id}
DELETE/customers/{id}

Import the postman collection for more details.

Endpoint

Getting all customers

  • GET - /customers

Request example

curl --location --request GET 'http://localhost:3000/customers'

Body example

No body

Response Example

{
    "customers": [
        {
            "id": "636fec6fad4733dfb2c87aef",
            "name": "Marty Zemlak",
            "email": "[email protected]",
            "role": "onwer",
            "phone": "+1 (870) 940-4987",
            "contacted": false,
            "created_at": "2022-11-12T18:56:47.017Z",
            "updated_at": "2022-11-12T18:56:47.017Z"
        }
    ]
}

Getting a single customer

  • GET - /customers/{id}

Request example

curl --location --request GET 'http://localhost:3000/customers/636fec6fad4733dfb2c87aef'

Body example

No body

Response Example

{
    "id": "636fec6fad4733dfb2c87aef",
    "name": "Marty Zemlak",
    "email": "[email protected]",
    "role": "onwer",
    "phone": "+1 (870) 940-4987",
    "contacted": false,
    "created_at": "2022-11-12T18:56:47.017Z",
    "updated_at": "2022-11-12T18:56:47.017Z"
}

Creating a customer

  • POST - /customers/

Request example

curl --location --request POST 'http://localhost:3000/customers' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name": "Marty Zemlak",
    "role": "onwer",
    "email": "[email protected]",
    "phone": "+1 (870) 940-4987",
    "contacted": false
}'

Body example

{
    "name": "Marty Zemlak",
    "role": "onwer",
    "email": "[email protected]",
    "phone": "+1 (870) 940-4987",
    "contacted": false
}

Response Example

{
    "id": "636fec6fad4733dfb2c87aef",
    "name": "Marty Zemlak",
    "email": "[email protected]",
    "role": "onwer",
    "phone": "+1 (870) 940-4987",
    "contacted": false,
    "created_at": "2022-11-12T18:56:47.017Z",
    "updated_at": "2022-11-12T18:56:47.017Z"
}

Updating a customer

  • PUT - /customers/{id}

Request example

curl --location --request PUT 'http://localhost:3000/customers/636fec6fad4733dfb2c87aef' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name": "Mr. Walker Moore VI",
    "role": "manager",
    "email": "[email protected]",
    "phone": "(660) 365-7314",
    "contacted": true
}'

Body example

{
    "name": "Mr. Walker Moore VI",
    "role": "manager",
    "email": "[email protected]",
    "phone": "(660) 365-7314",
    "contacted": true
}

Response Example

{
    "id": "636fec6fad4733dfb2c87aef",
    "name": "Mr. Walker Moore VI",
    "email": "[email protected]",
    "role": "manager",
    "phone": "(660) 365-7314",
    "contacted": true,
    "created_at": "2022-11-12T18:56:47.017Z",
    "updated_at": "2022-11-12T18:59:16.437Z"
}

Deleting a customer

  • DELETE - /customers/{id}

Request example

curl --location --request DELETE 'http://localhost:3000/customers/636fec6fad4733dfb2c87aef'

Body example

No body

Response Example

No Content

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author