GithubHelp home page GithubHelp logo

bike_api's Introduction

BikeApi

Setup

mix deps.get
cp config/dev.exs config/dev.secret.exs

Generate secret key:

mix guardian.gen.secret

and copy it.

Paste following text to dev.secret.exs:

use Mix.Config

config :bike_api, BikeApi.Guardian,
  issuer: "bike_api",
  secret_key: "paste secret key here"

Create DB and run migrations:

mix ecto.create && mix ecto.migrate

Run the project

mix phx.server

Run tests

mix test

Test examples

  • curl -X POST http://localhost:4000/api/v1/sign_up -H "Content-Type: application/json" -d '{"user": {"email": "[email protected]", "password": "password", "password_confirmation": "password"}}'
    {
      "data": {
        "id": 1,
        "email": "[email protected]"
      }
    }
  • curl -X POST -i http://localhost:4000/api/v1/sign_in -H "Content-Type: application/json" -d '{"email": "[email protected]", "password": "password"}'
    {
      "jwt": token
    }
  • curl -X GET http://localhost:4000/api/v1/profile -H "Content-Type: application/json" -H "Authorization: Bearer token"
    {
      "data": {
        "id": 1,
        "email": "[email protected]"
      }
    }
  • curl -X POST http://localhost:4000/api/v1/events -H "Content-Type: application/json" -H "Authorization: Bearer token" -d '{"event": {"name": "football", "lat": 52.512649, "lon": -0.133057, "radius": 2}}'
    {
      "data": {
        "radius": 2,
        "name": "football",
        "lon": -0.133057,
        "lat": 52.512649,
        "id": 1
      }
    }
  • curl -X POST http://localhost:4000/api/v1/promo_codes -H "Content-Type: application/json" -H "Authorization: Bearer token" -d '{"promo_code": {"amount": 1000, "expirates_at": "2018-10-14T08:20:32.22", "active": false, "event_id": 1}}'
    {
      "data": {
        "id": 1,
        "expirates_at": "2018-10-14T08:20:32.22Z",
        "event_id": 1,
        "amount": 1000,
        "active": false
      }
    }
  • curl -X GET http://localhost:4000/api/v1/promo_codes\?active\=false -H "Content-Type: application/json" -H "Authorization: Bearer token"
    {
      "data": [
        {
          "id": 1,
          "expirates_at": "2018-10-14T08:20:32.22Z",
          "event_id": 1,
          "amount": 1000,
          "active": false
        }
      ]
    }
  • curl -X POST http://localhost:4000/api/v1/promo_codes/14/check -H "Content-Type: application/json" -H "Authorization: Bearer token" -d '{"trip": {"origin": {"lat": 51.512649, "lon": -0.133057}, "destination": {"lat": 53.512649, "lon": 1.133057}}}'
    {
      "data": {
        "id": 1,
        "expirates_at": "2018-10-14T08:20:32.22Z",
        "event_id": 1,
        "amount": 1000,
        "active": false
      }
    }

bike_api's People

Contributors

astorre88 avatar

Watchers

James Cloos avatar  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.