yo two api

An simple API for a mobile app development workshop

YoTWo

This is the API for a the YoTWo app, a voice message sharing system.

Requirements

  • Ruby 2.1.1
  • Bundler
  • Postgres

Setup Instructions

cd into the project’s root directory

If you have rvm installed correctly and you do not have the correct version of Ruby, you will be prompted to download it.
If you need to do so, follow the instructions, then cd .

Install the gem dependencies with bundle install --path=vendor/bundle

Make sure Postgres is running.

Setup the DB with bin/rake db:create db:migrate

Run the server with bin/rails s

Hit “http://localhost:3000?format=json” in your browser to confirm its running

API Endpoints

All endpoints are JSON

GET /?format=json

Returns a status check

GET /users.json

Get a list of users

GET /users/:id.json

Get a single user

POST /users

Create a new user

GET /voice_messages.json?for=:user_id

Get a list of voice messages for a user

GET /voice_messages/:id.json

Get a single voice message

POST /voice_messages

Create a new voice message

Objects Contracts

User:

Get:

{
    "id": integer
    "name": string
    "created_at": datetime
    "updated_at": datetime
}

Creation:

{
    "user": {
        "name": string (required)
    }
}

Voice Message:

Get:

{
    "id": integer
    "location": string,
    "from": integer,
    "to": integer
    "created_at": datetime
    "updated_at": datetime
}

Creation:

{
    "voice_message": {
        "location": string (required),
        "from": integer (required),
        "to": integer (required),
    }
}