Catalog
Building and running
Development
Create DB with test data and start API:
$ docker-compose -p catalog up -d postgres
$ ./scripts/restore_db.sh
$ docker-compose -p catalog up -d api
Default DB password is pass
. API will be available at localhost:8080
.
Tests
You can run tests with:
$ docker-compose up test; docker-compose stop test-postgres
Other
Server port and production PostgreSQL DSN (if you don't want to use environmental variable for that) can be set via CLI flags:
-dsn string
PostgreSQL DSN
-port int
API server port (default 4000)
API
Success response template:
{
"ok": true,
"result": "result of the request will be here"
}
Failure response template:
{
"ok": false,
"error_message": "some error message will be here"
}
Get all organizations in a building
GET /buildings/{id}
where {id}
is an id of the building.
Example response:
{
"ok": true,
"result": [
32,
14,
5,
89
]
}
Get all organizations in a category
GET /categories/{id}
where {id}
is an id of the category.
Example response:
{
"ok": true,
"result": [
156,
12,
89
]
}
Get info about an organization
GET /organizations/{id}
where {id}
is an id of the organization.
Example response:
{
"ok": true,
"result": {
"id": 78213,
"name": "Remedy Dinner",
"address": "245 E Houston St",
"phone_numbers": [
"+1-212-677-5110"
],
"categories": [
2,
3
]
}
}
Create a new building with organizations
POST /buildings/create
Example request body:
{
"address": "245 E Houston St",
"latitude": 40.721728514906026,
"longitude": -73.9854660241876,
"organizations": [
{
"name": "Remedy Dinner",
"phone_numbers": [
"+1-212-677-5110"
],
"categories": [
2,
3
]
},
{
"name": "Chapter NY",
"phone_numbers": [
"+1-646-850-7486"
],
"categories": [
11
]
}
]
}
Example response:
{
"ok": "true",
"result": {
"id": 8921,
"address": "245 E Houston St",
"latitude": 40.721728514906026,
"longitude": -73.9854660241876,
"organizations": [
{
"id": 78213,
"name": "Remedy Dinner",
"phone_numbers": [
"+1-212-677-5110"
],
"categories": [
2,
3
]
},
{
"id": 78214,
"name": "Chapter NY",
"phone_numbers": [
"+1-646-850-7486"
],
"categories": [
11
]
}
]
}
}