Giter Site home page Giter Site logo

catalog's Introduction

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
        ]
      }
    ]
  }
}

catalog's People

Contributors

salkirr avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.