Skip to content

This API register and search locations around a requested location

License

Notifications You must be signed in to change notification settings

raulinoneto/partner-location-api

Repository files navigation

Partners Location API

This API simulates a delivery application where you can register and search partners by location.

Requirements

  • Docker 19.03.5 or later
  • docker-compose 1.25.0 or later

Installation

For install the project just run make install or if you prefer can run and install in the same time with make run. The application will run at localhost:3000 Ps.: Observe the disponibility of ips at your docker network.

Deployment

Just run make deploy

Technologies and Paterns

  • GoLang
  • Docker
  • MongoDB
  • Lambda-local
  • Hexagonal Architecture (Ports and Adapters)

Endpoints

Insert Partner

This endpoint saves a Partner.

  • URL

    /partners

  • Method:

    POST

  • Success Response:

    • Code: 200
      Content:
{
	"id": "5e447f4f7cc7ecf5c2a900f1",
	"tradingName": "Adega da Cerveja - Pinheiros",
	"ownerName": "Zé da Silva",
	"document": "1432132123891/0001",
	"coverageArea": {
		"type": "MultiPolygon",
		"coordinates": [
			[
				[
					[30, 20],
					[45, 40],
					[10, 40],
					[30, 20]
				]
			],
			[
				[
					[15, 5],
					[40, 10],
					[10, 20],
					[5, 10],
					[15, 5]
				]
			]
		]
	},
	"address": {
		"type": "Point",
		"coordinates": [-46.57421, -21.785741]
	}
}

Get Partner

This endpoint return a Partner from a provided id.

  • URL

    /partners/{id}

  • Method:

    GET

  • Success Response:

    • Code: 200
      Content:
{
	"id": "5e447f4f7cc7ecf5c2a900f1",
	"tradingName": "Adega da Cerveja - Pinheiros",
	"ownerName": "Zé da Silva",
	"document": "1432132123891/0001",
	"coverageArea": {
		"type": "MultiPolygon",
		"coordinates": [
			[
				[
					[30, 20],
					[45, 40],
					[10, 40],
					[30, 20]
				]
			],
			[
				[
					[15, 5],
					[40, 10],
					[10, 20],
					[5, 10],
					[15, 5]
				]
			]
		]
	},
	"address": {
		"type": "Point",
		"coordinates": [-46.57421, -21.785741]
	}
}

Search Partners

This endpoint return nearest Partner from a provided location.

  • URL

    /partners/lat/{lat}/lng/{lng}

  • Method:

    GET

  • Success Response:

    • Code: 200
      Content:
{
	"id": "5e447f4f7cc7ecf5c2a900f1",
	"tradingName": "Adega da Cerveja - Pinheiros",
	"ownerName": "Zé da Silva",
	"document": "1432132123891/0001",
	"coverageArea": {
		"type": "MultiPolygon",
		"coordinates": [
			[
				[
					[30, 20],
					[45, 40],
					[10, 40],
					[30, 20]
				]
			],
			[
				[
					[15, 5],
					[40, 10],
					[10, 20],
					[5, 10],
					[15, 5]
				]
			]
		]
	},
	"address": {
		"type": "Point",
		"coordinates": [-46.57421, -21.785741]
	}
}