Git Product home page Git Product logo

sample-api's Introduction

Setup

  1. bundle install

Database

SQLite3 is used for simplicity

  1. copy database config cp config/database.yml.sample config/database.yml

  2. Prepare database rake db:create && rake db:migrate

  3. Seed data rake db:seed, available country codes: uk, de, pl

  4. run rails server rails s

API endpoints

##Public /api/v1/public/

locations

http://localhost:3000/api/v1/public/locations/:country_code

target groups

http://localhost:3000/api/v1/public/target_groups/:country_code

Private /api/v1/private/

authentication token

too-many-secrets

locations

http://localhost:3000/api/v1/private/locations/pl?token=too-many-secrets

target groups

http://localhost:3000/api/v1/private/target_groups/pl?token=too-many-secrets

Unauthorized access

Any private endpoint call without token causes Unauthorized error (code 401)

evaluate target

POST http://localhost:3000/api/v1/private/evaluate_target/?token=too-many-secrets

evaluate_target sample payload

{
    "country_code": "uk",
    "target_group_id": 1,
    "locations": [
      {
        "id":123,
        "panel_size": 200
      }
    ]
}

evaluate_target sample response

{
    "price": 56
}

sample-api's People

Contributors

empa76 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.