Skip to content

mmjck/backend_challenge_carbigdata

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Backend Challenge Carbigdata

🚀 Technologies used

How to run

  • Clone the repository
git clone https://github.com/mmjck/backend_challenge_carbigdata.git
  • Build Application image on Docker
docker-compose build -d

Application will be running http://localhost:8080/

See file to example of how to use api

⚠️

  • It is necessary create a bucket first to upload images
  • Access http://localhost:9001/# with and input this credentiais
    • username: username
    • password: password

Create bucket with this name occurrences-images

Endpoints

The REST API app is described below.

Auth module

1. Create new Client

POST /api/v1/auth/register

{
	"name": "Joao das silva",
	"birth_date": "2000-01-01T10:00:00",
	"cpf": "00000000000",
	"password": "teste123"
}

2. Login

POST /api/v1/auth/#

{
	"cpf": "00000000000",
	"password": "teste123"
}

⚠️ Both cases return a json with token generated. Ex:

{
	"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJtcy1zZXJ2aWNlIiwic3ViIjoiMDI2ODMxMDkyMDIiLCJleHAiOjE3MjIyMDMxODZ9.oDNyay6YTZokNIavC5l_O0DjjElUQ14fU7pUMWoqb5s"
}

Clients

1. Update client

PUT /api/v1/client/{id}

{
	"name": "Joao das silva",
	"birth_date": "2000-01-01T10:00:00",
	"cpf": "00000000000",
	
}

2. Get client by id

GET /api/v1/client/{id}

Example os response

{
	"id": 1,
	"fullName": "Maria das silva",
	"cpf": "00000000000",
	"birthDate": "2000-01-01T10:00:00",
	"createdAt": "2024-07-28T14:46:26.450442"
}

3. Delete client

DELETE /api/v1/client/{id}

Address Module

1. Create address

POST /api/v1/address

{
	"zip_code": "123123",
	"steet": "street",
	"city": "city",
	"state": "State",
	"district": "district"
}

2. Update address

PUT /api/v1/address

body:

{
	"zip_code": "123123",
	"steet": "street",
	"city": "city",
	"state": "State",
	"district": "district"
}

3. Get adddress by id

GET /api/v1/address/{id}

Example of response:

{
	"id": 2,
	"state": "state",
	"city": "city",
	"zipCode": "zipCode",
	"district": "district",
	"createdAt": "2024-07-28T13:41:34.976314"
}

4. Delete address

DELETE /api/v1/address/{id}

Occurrence images Module

1. Create occurrence image

POST /api/v1/occurrence-images

This is multipart/form-data request You need includ some fields: occurrence_id: {occurrenceId} files: array of images

2. Update occurrence image

  • Only can update images

POST /api/v1/occurrence-images/{id}

This is multipart/form-data request You need includ some fields: occurrence_id: {occurrenceId} files: array of images

3. Get by occurrence image id

GET /api/v1/occurrence-images/{id}

Example of response

{
	"id": 4,
	"occurrenceId": 4,
	"hash": "<path>",
	"path": "<url>",
	"createdAt": "2024-07-28T15:35:19.153032"
}

4. Delete

DELETE /api/v1/occurrence-images/{id}

Occurrences Module

1. Create Occurrence

POST api/v1/occurrence

This is multipart/form-data request You need includ some fields: body:

{
	"zip_code": "<zipcode>",
	"steet": "<steet>",
	"city": "<city>",
	"state": "<state>",
	"district": "<district>",
	"cpf": "<cpf>",
	"full_name": "<full_name>"
}

files: array of images

2. Get All

GET /api/v1/occurrence/list

[
	{
		"id": "4",
		"state": "<state>",
		"createdAt": "2024-07-28 15:35:19.134404",
		"status": "ACTIVE",
		"cpf": "<cpf>",
		"district": "<district>",
		"city": "<city>",
		"fullName": "<fullname>",
		"zipCode": "<zicode>",
		"clientId": 1,
		"images": [
			{
				"hash": "<hash>",
				"path": "<hash>"
			},
			
		]
	}
]

3. Finish occurrence

GET /api/v1/occurrence/finish/{id}

Missing requirements

  • Ordering the list of occurrences by creation date

    • ASC
    • DESC
  • Ordering the list of occurrences by city name

    • ASC
    • DESC
  • Update field occurrence_id by endpoint api/v1/occurrence-images

  • Update related fields from api/v1/occurrence