Skip to content

gunnertech/thumbwar-api

Repository files navigation

Current Host

thumbwar-api-staging.herokuapp.com

Note on examples

The Examples below are all hardcoded with values, which may need to be updated as the data changes

Authorization of requests

You need to pass two parameters with every single request:

token: User’s unique authentication token returned after authenticating with Facebook. facebook_id: User’s unique facebook id, obtained during the first authentication.

There is only one request where that’s not the case (POST /login).

Authentication

POST /login

Params

user[:facebook_token] (required)
user[:facebook_id] (required)
user[:first_name] (required)
user[:last_name] (required)
user[:remote_avatar_url] (required)
user[:email]
user[:mobile]
user[:facebook_ids] (optional - comma delimited string of facebook_ids)

Sample Response

{
  "user":{
    "token":"ZsGkS8nyrx3T_Bzj28pX",

    "id": 1,
    "username":"codyswann",
    "display_name":"Cody Swann",
    "public":true,
    "publish_to_facebook":true,
    "publish_to_twitter":true,
    "sms_notifications":true,
    "email_notifications":true,
    "verified":true,
    "sign_in_count":1,
    "wins":0,
    "losses":0,
    "pushes":0,
    "mobile":"55555555555",
    "facebook_id": "xxxxxxxxxxx", 
    "facebook_token": "xxxxxxxxxxx",
    "email": "xxxxxxxxxxx@xxxxxxxxxxx.com", 
    "first_name": "Cody", 
    "last_name": "Swann",
    "avatar": {
      "square_url": "http://xxxxxxxxxxxx"
    }

    "devices": [
      {
        "id": 1, 
        "token": "Some Token", 
        "user_id": 1,
        "device_type": "ios"
      }
    ]
  }
}

curl

curl "https://thumbwar-api-staging.herokuapp.com/login" -H "Content-type:application/json" --data "{\"facebook_token\":\"CAAMBJZB44Qf8BANFIZA6a6C5qKMY5lKijeI390IX2kYJZCTL24cUWWNWbGPnRnsNl0NmM2vXZCGGNH31F6ZBlTg5Od2hiOrAptbz2Cxn99dMPTlsIghDTQi2N82I99eXDXHHKZB8mzZC5F7WkZC0bq8DYk4wBRgWZBQZCrutHso27ft6bjfDpwD9ksZAogbO2Ayc1tjQiCs3uHEMGd3YxXcjtupoK7Xwyygfr8ZD\", \"facebook_id\":\"10106161156180441\", \"first_name\":\"Cody\", \"last_name\":\"Swann\"}"

Users

DELETE /logout

Sample Response

{}

curl

curl "https://thumbwar-api-staging.herokuapp.com/logout?token=QAbHkj97TqNdgkmL622v&facebook_id=10106161156180441" -H "Content-type:application/json" -X DELETE --data "{}"

GET /users/:user_id

Sample Response

{
  "id": 1,
  "username":"codyswann",
  "display_name":"Cody Swann",
  "public":true,
  "publish_to_facebook":true,
  "publish_to_twitter":true,
  "sms_notifications":true,
  "email_notifications":true,
  "verified":true,
  "sign_in_count":1,
  "wins":0,
  "losses":0,
  "pushes":0,
  "mobile":"55555555555",
  "facebook_id": "xxxxxxxxxxx", 
  "facebook_token": "xxxxxxxxxxx",
  "email": "xxxxxxxxxxx@xxxxxxxxxxx.com", 
  "first_name": "Cody", 
  "last_name": "Swann",
  "avatar": {
    "square_url": "http://xxxxxxxxxxxx"
  }
}

curl

curl "https://thumbwar-api-staging.herokuapp.com/users/1?token=QAbHkj97TqNdgkmL622v&facebook_id=10106161156180441" -H "Content-type:application/json"

GET /users

params

:search (required)

Sample Response

{
  "users":[
    {
      "id": 1,
      "username":"codyswann",
      "display_name":"Cody Swann",
      "public":true,
      "publish_to_facebook":true,
      "publish_to_twitter":true,
      "sms_notifications":true,
      "email_notifications":true,
      "verified":true,
      "sign_in_count":1,
      "wins":0,
      "losses":0,
      "pushes":0,
      "mobile":"55555555555",
      "facebook_id": "xxxxxxxxxxx", 
      "facebook_token": "xxxxxxxxxxx",
      "email": "xxxxxxxxxxx@xxxxxxxxxxx.com", 
      "first_name": "Cody", 
      "last_name": "Swann",
      "avatar": {
        "square_url": "http://xxxxxxxxxxxx"
      }
    }
  ]
}

curl

curl "https://thumbwar-api-staging.herokuapp.com/users?token=QAbHkj97TqNdgkmL622v&facebook_id=10106161156180441&search=10106161156180441" -H "Content-type:application/json"

POST /users

Params

:facebook_id
:first_name (required)
:last_name (required)
:email
:remote_avatar_url
:avatar

Sample Response

{
  "id": 1,
  "username":"codyswann",
  "display_name":"Cody Swann",
  "public":true,
  "publish_to_facebook":true,
  "publish_to_twitter":true,
  "sms_notifications":true,
  "email_notifications":true,
  "verified":true,
  "sign_in_count":1,
  "wins":0,
  "losses":0,
  "pushes":0,
  "mobile":"55555555555",
  "facebook_id": "xxxxxxxxxxx", 
  "facebook_token": "xxxxxxxxxxx",
  "email": "xxxxxxxxxxx@xxxxxxxxxxx.com", 
  "first_name": "Cody", 
  "last_name": "Swann",
  "avatar": {
    "square_url": "http://xxxxxxxxxxxx"
  }
}

curl

curl "https://thumbwar-api-staging.herokuapp.com/users?token=QAbHkj97TqNdgkmL622v&facebook_id=10106161156180441" -H "Content-type:application/json" --data "{\"facebook_id\":\"1234567\",\"first_name\":\"James\",\"last_name\":\"Nickerson\"}"

PUT /users/:id

Params

:first_name
:last_name
:email
:mobile
:remote_avatar_url
:avatar
:public

Sample Response

{
  "id": 1,
  "username":"codyswann",
  "display_name":"Cody Swann",
  "public":true,
  "publish_to_facebook":true,
  "publish_to_twitter":true,
  "sms_notifications":true,
  "email_notifications":true,
  "verified":true,
  "sign_in_count":1,
  "wins":0,
  "losses":0,
  "pushes":0,
  "mobile":"55555555555",
  "facebook_id": "xxxxxxxxxxx", 
  "facebook_token": "xxxxxxxxxxx",
  "email": "xxxxxxxxxxx@xxxxxxxxxxx.com", 
  "first_name": "Cody", 
  "last_name": "Swann",
  "avatar": {
    "square_url": "http://xxxxxxxxxxxx"
  }
}

curl

curl "https://thumbwar-api-staging.herokuapp.com/users/1?token=QAbHkj97TqNdgkmL622v&facebook_id=10106161156180441" -H "Content-type:application/json" -X PUT --data "{\"first_name\":\"james\",\"last_name\":\"duck\"}"

POST /users/:user_id/follow

Sample Response

{}

curl

curl "https://thumbwar-api-staging.herokuapp.com/users/2/follow?token=QAbHkj97TqNdgkmL622v&facebook_id=10106161156180441" -H "Content-type:application/json" --data "{}"

POST /users/:user_id/unfollow

Sample Response

{}

curl

curl "https://thumbwar-api-staging.herokuapp.com/users/2/unfollow?token=QAbHkj97TqNdgkmL622v&facebook_id=10106161156180441" -H "Content-type:application/json" --data "{}"

GET /users/:user_id/followers

Sample Response

{
  "users":[
    {
      "id": 1,
      "username":"codyswann",
      "display_name":"Cody Swann",
      "public":true,
      "publish_to_facebook":true,
      "publish_to_twitter":true,
      "sms_notifications":true,
      "email_notifications":true,
      "verified":true,
      "sign_in_count":1,
      "wins":0,
      "losses":0,
      "pushes":0,
      "mobile":"55555555555",
      "facebook_id": "xxxxxxxxxxx", 
      "facebook_token": "xxxxxxxxxxx",
      "email": "xxxxxxxxxxx@xxxxxxxxxxx.com", 
      "first_name": "Cody", 
      "last_name": "Swann",
      "avatar": {
        "square_url": "http://xxxxxxxxxxxx"
      }
    }
  ]
}

curl

curl "https://thumbwar-api-staging.herokuapp.com/users/1/followers?token=QAbHkj97TqNdgkmL622v&facebook_id=10106161156180441" -H "Content-type:application/json"

GET /users/:user_id/following

Sample Response

{
  "users":[
    {
      "id": 1,
      "username":"codyswann",
      "display_name":"Cody Swann",
      "public":true,
      "publish_to_facebook":true,
      "publish_to_twitter":true,
      "sms_notifications":true,
      "email_notifications":true,
      "verified":true,
      "sign_in_count":1,
      "wins":0,
      "losses":0,
      "pushes":0,
      "mobile":"55555555555",
      "facebook_id": "xxxxxxxxxxx", 
      "facebook_token": "xxxxxxxxxxx",
      "email": "xxxxxxxxxxx@xxxxxxxxxxx.com", 
      "first_name": "Cody", 
      "last_name": "Swann",
      "avatar": {
        "square_url": "http://xxxxxxxxxxxx"
      }
    }
  ]
}

curl

curl "https://thumbwar-api-staging.herokuapp.com/users/1/following?token=QAbHkj97TqNdgkmL622v&facebook_id=10106161156180441" -H "Content-type:application/json"

Devices

POST /devices

Params

:device_type (must be 'ios' right now)(required)
:token (string required)

Sample Response

{}

curl

curl "https://thumbwar-api-staging.herokuapp.com/devices?token=QAbHkj97TqNdgkmL622v&facebook_id=10106161156180441" -H "Content-type:application/json" --data "{\"token\":\"4055dc48a67d7f7656a7a01fb4159964f4f6d81de1d22ae67703f44195544f56\",\"device_type\":\"ios\"}"

Thumbwars

GET /users/:user_id/thumbwars

Sample Response

{
  "thumbwars":[
    {
      "id": 1,
      "body": "sample body goes here here and here",
      "expires_at": "<timestamp>",
      "url": "thumbwar://blahblahblah",
      "wager": "$1",
      "minutes_remaining": "20",
      "created_at": "<timestamp>",
      "has_default_photo": true,
      "status": "win",
      "challengers_proposed_outcome": "win",
      "opponents_proposed_outcome": "win",
      "public": true,
      "comments_count": 10,
      "photo": {
        "url": "http://xxxxx",
        "large_url": "http://xxxxx"
      },
      "evidence_photos": [
        {
          "id":1, 
          "user_id":1, 
          "thumbwar_id":1, 
          "has_default_photo":false,
          "url": "http://blah",
          "large_url": "http://blah",
          "created_at":"<timestamp>", 
          "updated_at":"<timestamp>"
        }
      ],
      "watchings": [
        "side": "opponents",
        "user": {
          "id": 1,
          "username":"codyswann",
          "display_name":"Cody Swann",
          "public":true,
          "publish_to_facebook":true,
          "publish_to_twitter":true,
          "sms_notifications":true,
          "email_notifications":true,
          "verified":true,
          "sign_in_count":1,
          "wins":0,
          "losses":0,
          "pushes":0,
          "mobile":"55555555555",
          "facebook_id": "xxxxxxxxxxx", 
          "facebook_token": "xxxxxxxxxxx",
          "email": "xxxxxxxxxxx@xxxxxxxxxxx.com", 
          "first_name": "Cody", 
          "last_name": "Swann",
          "avatar": {
            "square_url": "http://xxxxxxxxxxxx"
          }
        }
      ],
      "challenges":[
        {
          "id": 1,
          "user_id": 1,
          "thumbwar_id": 1,
          "status": 'win', 
          "challenger_id":1, 
          "created_at": "<timestamp>", 
          "updated_at":"<timestamp>", 
          "user": {
            "id": 1,
            "username":"codyswann",
            "display_name":"Cody Swann",
            "public":true,
            "publish_to_facebook":true,
            "publish_to_twitter":true,
            "sms_notifications":true,
            "email_notifications":true,
            "verified":true,
            "sign_in_count":1,
            "wins":0,
            "losses":0,
            "pushes":0,
            "mobile":"55555555555",
            "facebook_id": "xxxxxxxxxxx", 
            "facebook_token": "xxxxxxxxxxx",
            "email": "xxxxxxxxxxx@xxxxxxxxxxx.com", 
            "first_name": "Cody", 
            "last_name": "Swann",
            "avatar": {
              "square_url": "http://xxxxxxxxxxxx"
            }
          }
        }
      ],
      "comments": [
        {
          "id":1,
          "body": "blah, blah, blah, blah",
          "commentable_type", "Thumbwar",
          "commentable_id": "2",
          "photo": {
            "url": "http://blah",
            "large_url": "http://blah"
          },
          "user": {
            "id": 1,
            "username":"codyswann",
            "display_name":"Cody Swann",
            "public":true,
            "publish_to_facebook":true,
            "publish_to_twitter":true,
            "sms_notifications":true,
            "email_notifications":true,
            "verified":true,
            "sign_in_count":1,
            "wins":0,
            "losses":0,
            "pushes":0,
            "mobile":"55555555555",
            "facebook_id": "xxxxxxxxxxx", 
            "facebook_token": "xxxxxxxxxxx",
            "email": "xxxxxxxxxxx@xxxxxxxxxxx.com", 
            "first_name": "Cody", 
            "last_name": "Swann",
            "avatar": {
              "square_url": "http://xxxxxxxxxxxx"
            }
          }
        }
      ],
      "challenger":{
        "id": 1,
        "username":"codyswann",
        "display_name":"Cody Swann",
        "public":true,
        "publish_to_facebook":true,
        "publish_to_twitter":true,
        "sms_notifications":true,
        "email_notifications":true,
        "verified":true,
        "sign_in_count":1,
        "wins":0,
        "losses":0,
        "pushes":0,
        "mobile":"55555555555",
        "facebook_id": "xxxxxxxxxxx", 
        "facebook_token": "xxxxxxxxxxx",
        "email": "xxxxxxxxxxx@xxxxxxxxxxx.com", 
        "first_name": "Cody", 
        "last_name": "Swann",
        "avatar": {
          "square_url": "http://xxxxxxxxxxxx"
        }
      }
    }
  ]
}

curl

curl "https://thumbwar-api-staging.herokuapp.com/users/1/thumbwars?token=QAbHkj97TqNdgkmL622v&facebook_id=10106161156180441" -H "Content-type:application/json"

GET /thumbwars

Params

:view (required, enum: 'timeline' | 'mine' | 'public' | 'won' | 'lost')
:user_id (defaults to logged in user)
:q (tag search, must be either "$something" or "#something")
:last (the id of the last thumbwar locally)
:newest (the id of the newest thumbwar locally)
:status (win, loss, push)

Sample Response

{
  "thumbwars":[
    {
      "id": 1,
      "body": "sample body goes here here and here",
      "expires_at": "<timestamp>",
      "url": "thumbwar://blahblahblah",
      "wager": "$1",
      "minutes_remaining": "20",
      "created_at": "<timestamp>",
      "has_default_photo": true,
      "status": "win",
      "challengers_proposed_outcome": "win",
      "opponents_proposed_outcome": "win",
      "public": true,
      "comments_count": 10,
      "photo": {
        "url": "http://xxxxx",
        "large_url": "http://xxxxx"
      },
      "evidence_photos": [
        {
          "id":1, 
          "user_id":1, 
          "thumbwar_id":1, 
          "has_default_photo":false,
          "url": "http://blah",
          "large_url": "http://blah",
          "created_at":"<timestamp>", 
          "updated_at":"<timestamp>"
        }
      ],
      "watchings": [
        "side": "opponents",
        "user": {
          "id": 1,
          "username":"codyswann",
          "display_name":"Cody Swann",
          "public":true,
          "publish_to_facebook":true,
          "publish_to_twitter":true,
          "sms_notifications":true,
          "email_notifications":true,
          "verified":true,
          "sign_in_count":1,
          "wins":0,
          "losses":0,
          "pushes":0,
          "mobile":"55555555555",
          "facebook_id": "xxxxxxxxxxx", 
          "facebook_token": "xxxxxxxxxxx",
          "email": "xxxxxxxxxxx@xxxxxxxxxxx.com", 
          "first_name": "Cody", 
          "last_name": "Swann",
          "avatar": {
            "square_url": "http://xxxxxxxxxxxx"
          }
        }
      ],
      "challenges":[
        {
          "id": 1,
          "user_id": 1,
          "thumbwar_id": 1,
          "status": 'win', 
          "challenger_id":1, 
          "created_at": "<timestamp>", 
          "updated_at":"<timestamp>", 
          "user": {
            "id": 1,
            "username":"codyswann",
            "display_name":"Cody Swann",
            "public":true,
            "publish_to_facebook":true,
            "publish_to_twitter":true,
            "sms_notifications":true,
            "email_notifications":true,
            "verified":true,
            "sign_in_count":1,
            "wins":0,
            "losses":0,
            "pushes":0,
            "mobile":"55555555555",
            "facebook_id": "xxxxxxxxxxx", 
            "facebook_token": "xxxxxxxxxxx",
            "email": "xxxxxxxxxxx@xxxxxxxxxxx.com", 
            "first_name": "Cody", 
            "last_name": "Swann",
            "avatar": {
              "square_url": "http://xxxxxxxxxxxx"
            }
          }
        }
      ],
      "comments": [
        {
          "id":1,
          "body": "blah, blah, blah, blah",
          "commentable_type", "Thumbwar",
          "commentable_id": "2",
          "photo": {
            "url": "http://blah",
            "large_url": "http://blah"
          },
          "user": {
            "id": 1,
            "username":"codyswann",
            "display_name":"Cody Swann",
            "public":true,
            "publish_to_facebook":true,
            "publish_to_twitter":true,
            "sms_notifications":true,
            "email_notifications":true,
            "verified":true,
            "sign_in_count":1,
            "wins":0,
            "losses":0,
            "pushes":0,
            "mobile":"55555555555",
            "facebook_id": "xxxxxxxxxxx", 
            "facebook_token": "xxxxxxxxxxx",
            "email": "xxxxxxxxxxx@xxxxxxxxxxx.com", 
            "first_name": "Cody", 
            "last_name": "Swann",
            "avatar": {
              "square_url": "http://xxxxxxxxxxxx"
            }
          }
        }
      ],
      "challenger":{
        "id": 1,
        "username":"codyswann",
        "display_name":"Cody Swann",
        "public":true,
        "publish_to_facebook":true,
        "publish_to_twitter":true,
        "sms_notifications":true,
        "email_notifications":true,
        "verified":true,
        "sign_in_count":1,
        "wins":0,
        "losses":0,
        "pushes":0,
        "mobile":"55555555555",
        "facebook_id": "xxxxxxxxxxx", 
        "facebook_token": "xxxxxxxxxxx",
        "email": "xxxxxxxxxxx@xxxxxxxxxxx.com", 
        "first_name": "Cody", 
        "last_name": "Swann",
        "avatar": {
          "square_url": "http://xxxxxxxxxxxx"
        }
      }
    }
  ]
}

curl

curl "https://thumbwar-api-staging.herokuapp.com/thumbwars?token=QAbHkj97TqNdgkmL622v&facebook_id=10106161156180441&view=mine" -H "Content-type:application/json"

curl "https://thumbwar-api-staging.herokuapp.com/thumbwars?token=QAbHkj97TqNdgkmL622v&facebook_id=10106161156180441&user_id=2&view=timeline" -H "Content-type:application/json"

curl "https://thumbwar-api-staging.herokuapp.com/thumbwars?token=QAbHkj97TqNdgkmL622v&facebook_id=10106161156180441&q=%24money&view=public" -H "Content-type:application/json"

curl "https://thumbwar-api-staging.herokuapp.com/thumbwars?token=QAbHkj97TqNdgkmL622v&facebook_id=10106161156180441&q=%23test&view=public" -H "Content-type:application/json"

curl "https://thumbwar-api-staging.herokuapp.com/thumbwars?token=QAbHkj97TqNdgkmL622v&facebook_id=10106161156180441&view=public&newest=1" -H "Content-type:application/json"

curl "https://thumbwar-api-staging.herokuapp.com/thumbwars?token=QAbHkj97TqNdgkmL622v&facebook_id=10106161156180441&view=public&last=50" -H "Content-type:application/json"

POST /thumbwars

Params

:body (required)
:opponent_id
:expires_in
:wager
:photo
:remote_photo_url
:url (not used)
:publish_to_twitter (not used)
:publish_to_facebook (not used)

Sample Response

{}

curl

curl "https://thumbwar-api-staging.herokuapp.com/thumbwars?token=QAbHkj97TqNdgkmL622v&facebook_id=10106161156180441" -H "Content-type:application/json" --data "{\"body\":\"I can beat your face\",\"expires_in\":20,\"wager\":\"cookies\"}"

curl "https://thumbwar-api-staging.herokuapp.com/thumbwars?token=QAbHkj97TqNdgkmL622v&facebook_id=10106161156180441" -H "Content-type:application/json" --data "{\"body\":\"I can beat your face\",\"opponent_id\":2,\"expires_in\":20,\"wager\":\"cookies\"}"

curl "https://thumbwar-api-staging.herokuapp.com/thumbwars?token=QAbHkj97TqNdgkmL622v&facebook_id=10106161156180441" -H "Content-type:application/json" --data "{\"body\":\"I can beat your face\",\"remote_photo_url\":\"http://cbsradionews.files.wordpress.com/2013/09/gene-simmons-by-afpgetty.jpg\"}"

curl "https://thumbwar-api-staging.herokuapp.com/thumbwars?token=QAbHkj97TqNdgkmL622v&facebook_id=10106161156180441" -H "Content-type:application/json" --data "{\"body\":\"I can beat your face\",\"remote_photo_url\":\"http://cbsradionews.files.wordpress.com/2013/09/gene-simmons-by-afpgetty.jpg\"}"

curl -i  -F "thumbwar[body]=This is an image file" -F "thumbwar[photo]=@/Users/cody/Desktop/fireball-wallpaper-2.jpg" "https://thumbwar-api-staging.herokuapp.com/thumbwars?token=QAbHkj97TqNdgkmL622v&facebook_id=10106161156180441"

DELETE /thumbwars/:id

Params

Notes

Sample Response

{}

curl

curl "https://thumbwar-api-staging.herokuapp.com/thumbwars/94?token=QAbHkj97TqNdgkmL622v&facebook_id=10106161156180441" -H "Content-type:application/json" -X DELETE

PUT /thumbwars/:id

Params

:challenger_id
:body
:expires_in
:wager
:opponents_proposed_outcome (enum 'win' | 'loss' | 'push' ) (defaults to nil)
:challengers_proposed_outcome (enum 'win' | 'loss' | 'push' ) (defaults to nil)
:photo
:remote_photo_url
:url (not used)
:publish_to_twitter (not used) 
:publish_to_facebook (not used)

Notes

If neither equal nil and opponents_proposed_outcome == challengers_proposed_outcome and both == 'win', the result will be a win for the challenger.

If neither equal nil and opponents_proposed_outcome == challengers_proposed_outcome and both == 'loss', the result will be a loss for the challenger.

If neither equal nil and opponents_proposed_outcome != challengers_proposed_outcome, the result will be a push.

Sample Response

{
  "id": 1,
  "body": "sample body goes here here and here",
  "expires_at": "<timestamp>",
  "url": "thumbwar://blahblahblah",
  "wager": "$1",
  "minutes_remaining": "20",
  "created_at": "<timestamp>",
  "has_default_photo": true,
  "status": "win",
  "challengers_proposed_outcome": "win",
  "opponents_proposed_outcome": "win",
  "public": true,
  "comments_count": 10,
  "photo": {
    "url": "http://xxxxx",
    "large_url": "http://xxxxx"
  },
  "evidence_photos": [
    {
      "id":1, 
      "user_id":1, 
      "thumbwar_id":1, 
      "has_default_photo":false,
      "url": "http://blah",
      "large_url": "http://blah",
      "created_at":"<timestamp>", 
      "updated_at":"<timestamp>"
    }
  ],
  "watchings": [
    "side": "opponents",
    "user": {
      "id": 1,
      "username":"codyswann",
      "display_name":"Cody Swann",
      "public":true,
      "publish_to_facebook":true,
      "publish_to_twitter":true,
      "sms_notifications":true,
      "email_notifications":true,
      "verified":true,
      "sign_in_count":1,
      "wins":0,
      "losses":0,
      "pushes":0,
      "mobile":"55555555555",
      "facebook_id": "xxxxxxxxxxx", 
      "facebook_token": "xxxxxxxxxxx",
      "email": "xxxxxxxxxxx@xxxxxxxxxxx.com", 
      "first_name": "Cody", 
      "last_name": "Swann",
      "avatar": {
        "square_url": "http://xxxxxxxxxxxx"
      }
    }
  ],
  "challenges":[
    {
      "id": 1,
      "user_id": 1,
      "thumbwar_id": 1,
      "status": 'win', 
      "challenger_id":1, 
      "created_at": "<timestamp>", 
      "updated_at":"<timestamp>", 
      "user": {
        "id": 1,
        "username":"codyswann",
        "display_name":"Cody Swann",
        "public":true,
        "publish_to_facebook":true,
        "publish_to_twitter":true,
        "sms_notifications":true,
        "email_notifications":true,
        "verified":true,
        "sign_in_count":1,
        "wins":0,
        "losses":0,
        "pushes":0,
        "mobile":"55555555555",
        "facebook_id": "xxxxxxxxxxx", 
        "facebook_token": "xxxxxxxxxxx",
        "email": "xxxxxxxxxxx@xxxxxxxxxxx.com", 
        "first_name": "Cody", 
        "last_name": "Swann",
        "avatar": {
          "square_url": "http://xxxxxxxxxxxx"
        }
      }
    }
  ],
  "comments": [
    {
      "id":1,
      "body": "blah, blah, blah, blah",
      "commentable_type", "Thumbwar",
      "commentable_id": "2",
      "photo": {
        "url": "http://blah",
        "large_url": "http://blah"
      },
      "user": {
        "id": 1,
        "username":"codyswann",
        "display_name":"Cody Swann",
        "public":true,
        "publish_to_facebook":true,
        "publish_to_twitter":true,
        "sms_notifications":true,
        "email_notifications":true,
        "verified":true,
        "sign_in_count":1,
        "wins":0,
        "losses":0,
        "pushes":0,
        "mobile":"55555555555",
        "facebook_id": "xxxxxxxxxxx", 
        "facebook_token": "xxxxxxxxxxx",
        "email": "xxxxxxxxxxx@xxxxxxxxxxx.com", 
        "first_name": "Cody", 
        "last_name": "Swann",
        "avatar": {
          "square_url": "http://xxxxxxxxxxxx"
        }
      }
    }
  ],
  "challenger":{
    "id": 1,
    "username":"codyswann",
    "display_name":"Cody Swann",
    "public":true,
    "publish_to_facebook":true,
    "publish_to_twitter":true,
    "sms_notifications":true,
    "email_notifications":true,
    "verified":true,
    "sign_in_count":1,
    "wins":0,
    "losses":0,
    "pushes":0,
    "mobile":"55555555555",
    "facebook_id": "xxxxxxxxxxx", 
    "facebook_token": "xxxxxxxxxxx",
    "email": "xxxxxxxxxxx@xxxxxxxxxxx.com", 
    "first_name": "Cody", 
    "last_name": "Swann",
    "avatar": {
      "square_url": "http://xxxxxxxxxxxx"
    }
  }
}

curl

curl "https://thumbwar-api-staging.herokuapp.com/thumbwars/94?token=QAbHkj97TqNdgkmL622v&facebook_id=10106161156180441" -H "Content-type:application/json" -X PUT --data "{\"challengers_proposed_outcome\":\"win\"}"

curl "https://thumbwar-api-staging.herokuapp.com/thumbwars/94?token=QAbHkj97TqNdgkmL622v&facebook_id=10106161156180441" -H "Content-type:application/json" -X PUT --data "{\"opponents_proposed_outcome\":\"win\"}"

curl "https://thumbwar-api-staging.herokuapp.com/thumbwars/94?token=QAbHkj97TqNdgkmL622v&facebook_id=10106161156180441" -H "Content-type:application/json" -X PUT --data "{\"challengers_proposed_outcome\":\"loss\"}"

curl "https://thumbwar-api-staging.herokuapp.com/thumbwars/94?token=QAbHkj97TqNdgkmL622v&facebook_id=10106161156180441" -H "Content-type:application/json" -X PUT --data "{\"opponents_proposed_outcome\":\"win\"}"

POST /thumbwars/:thumbwar_id/watch

Params

:side (required - enum - 'challenger' or 'opponents' )

Sample Response

{
  "id": 1,
  "body": "sample body goes here here and here",
  "expires_at": "<timestamp>",
  "url": "thumbwar://blahblahblah",
  "wager": "$1",
  "minutes_remaining": "20",
  "created_at": "<timestamp>",
  "has_default_photo": true,
  "status": "win",
  "challengers_proposed_outcome": "win",
  "opponents_proposed_outcome": "win",
  "public": true,
  "comments_count": 10,
  "photo": {
    "url": "http://xxxxx",
    "large_url": "http://xxxxx"
  },
  "evidence_photos": [
    {
      "id":1, 
      "user_id":1, 
      "thumbwar_id":1, 
      "has_default_photo":false,
      "url": "http://blah",
      "large_url": "http://blah",
      "created_at":"<timestamp>", 
      "updated_at":"<timestamp>"
    }
  ],
  "watchings": [
    "side": "opponents",
    "user": {
      "id": 1,
      "username":"codyswann",
      "display_name":"Cody Swann",
      "public":true,
      "publish_to_facebook":true,
      "publish_to_twitter":true,
      "sms_notifications":true,
      "email_notifications":true,
      "verified":true,
      "sign_in_count":1,
      "wins":0,
      "losses":0,
      "pushes":0,
      "mobile":"55555555555",
      "facebook_id": "xxxxxxxxxxx", 
      "facebook_token": "xxxxxxxxxxx",
      "email": "xxxxxxxxxxx@xxxxxxxxxxx.com", 
      "first_name": "Cody", 
      "last_name": "Swann",
      "avatar": {
        "square_url": "http://xxxxxxxxxxxx"
      }
    }
  ],
  "challenges":[
    {
      "id": 1,
      "user_id": 1,
      "thumbwar_id": 1,
      "status": 'win', 
      "challenger_id":1, 
      "created_at": "<timestamp>", 
      "updated_at":"<timestamp>", 
      "user": {
        "id": 1,
        "username":"codyswann",
        "display_name":"Cody Swann",
        "public":true,
        "publish_to_facebook":true,
        "publish_to_twitter":true,
        "sms_notifications":true,
        "email_notifications":true,
        "verified":true,
        "sign_in_count":1,
        "wins":0,
        "losses":0,
        "pushes":0,
        "mobile":"55555555555",
        "facebook_id": "xxxxxxxxxxx", 
        "facebook_token": "xxxxxxxxxxx",
        "email": "xxxxxxxxxxx@xxxxxxxxxxx.com", 
        "first_name": "Cody", 
        "last_name": "Swann",
        "avatar": {
          "square_url": "http://xxxxxxxxxxxx"
        }
      }
    }
  ],
  "comments": [
    {
      "id":1,
      "body": "blah, blah, blah, blah",
      "commentable_type", "Thumbwar",
      "commentable_id": "2",
      "photo": {
        "url": "http://blah",
        "large_url": "http://blah"
      },
      "user": {
        "id": 1,
        "username":"codyswann",
        "display_name":"Cody Swann",
        "public":true,
        "publish_to_facebook":true,
        "publish_to_twitter":true,
        "sms_notifications":true,
        "email_notifications":true,
        "verified":true,
        "sign_in_count":1,
        "wins":0,
        "losses":0,
        "pushes":0,
        "mobile":"55555555555",
        "facebook_id": "xxxxxxxxxxx", 
        "facebook_token": "xxxxxxxxxxx",
        "email": "xxxxxxxxxxx@xxxxxxxxxxx.com", 
        "first_name": "Cody", 
        "last_name": "Swann",
        "avatar": {
          "square_url": "http://xxxxxxxxxxxx"
        }
      }
    }
  ],
  "challenger":{
    "id": 1,
    "username":"codyswann",
    "display_name":"Cody Swann",
    "public":true,
    "publish_to_facebook":true,
    "publish_to_twitter":true,
    "sms_notifications":true,
    "email_notifications":true,
    "verified":true,
    "sign_in_count":1,
    "wins":0,
    "losses":0,
    "pushes":0,
    "mobile":"55555555555",
    "facebook_id": "xxxxxxxxxxx", 
    "facebook_token": "xxxxxxxxxxx",
    "email": "xxxxxxxxxxx@xxxxxxxxxxx.com", 
    "first_name": "Cody", 
    "last_name": "Swann",
    "avatar": {
      "square_url": "http://xxxxxxxxxxxx"
    }
  }
}

curl

curl "https://thumbwar-api-staging.herokuapp.com/thumbwars/94/watch?token=QAbHkj97TqNdgkmL622v&facebook_id=10106161156180441" -H "Content-type:application/json" --data "{\"side\":\"challenger\"}"

curl "https://thumbwar-api-staging.herokuapp.com/thumbwars/94/watch?token=QAbHkj97TqNdgkmL622v&facebook_id=10106161156180441" -H "Content-type:application/json" --data "{\"side\":\"opponents\"}"

POST /thumbwars/:thumbwar_id/unwatch

Sample Response

{
  "id": 1,
  "body": "sample body goes here here and here",
  "expires_at": "<timestamp>",
  "url": "thumbwar://blahblahblah",
  "wager": "$1",
  "minutes_remaining": "20",
  "created_at": "<timestamp>",
  "has_default_photo": true,
  "status": "win",
  "challengers_proposed_outcome": "win",
  "opponents_proposed_outcome": "win",
  "public": true,
  "comments_count": 10,
  "photo": {
    "url": "http://xxxxx",
    "large_url": "http://xxxxx"
  },
  "evidence_photos": [
    {
      "id":1, 
      "user_id":1, 
      "thumbwar_id":1, 
      "has_default_photo":false,
      "url": "http://blah",
      "large_url": "http://blah",
      "created_at":"<timestamp>", 
      "updated_at":"<timestamp>"
    }
  ],
  "watchings": [
    "side": "opponents",
    "user": {
      "id": 1,
      "username":"codyswann",
      "display_name":"Cody Swann",
      "public":true,
      "publish_to_facebook":true,
      "publish_to_twitter":true,
      "sms_notifications":true,
      "email_notifications":true,
      "verified":true,
      "sign_in_count":1,
      "wins":0,
      "losses":0,
      "pushes":0,
      "mobile":"55555555555",
      "facebook_id": "xxxxxxxxxxx", 
      "facebook_token": "xxxxxxxxxxx",
      "email": "xxxxxxxxxxx@xxxxxxxxxxx.com", 
      "first_name": "Cody", 
      "last_name": "Swann",
      "avatar": {
        "square_url": "http://xxxxxxxxxxxx"
      }
    }
  ],
  "challenges":[
    {
      "id": 1,
      "user_id": 1,
      "thumbwar_id": 1,
      "status": 'win', 
      "challenger_id":1, 
      "created_at": "<timestamp>", 
      "updated_at":"<timestamp>", 
      "user": {
        "id": 1,
        "username":"codyswann",
        "display_name":"Cody Swann",
        "public":true,
        "publish_to_facebook":true,
        "publish_to_twitter":true,
        "sms_notifications":true,
        "email_notifications":true,
        "verified":true,
        "sign_in_count":1,
        "wins":0,
        "losses":0,
        "pushes":0,
        "mobile":"55555555555",
        "facebook_id": "xxxxxxxxxxx", 
        "facebook_token": "xxxxxxxxxxx",
        "email": "xxxxxxxxxxx@xxxxxxxxxxx.com", 
        "first_name": "Cody", 
        "last_name": "Swann",
        "avatar": {
          "square_url": "http://xxxxxxxxxxxx"
        }
      }
    }
  ],
  "comments": [
    {
      "id":1,
      "body": "blah, blah, blah, blah",
      "commentable_type", "Thumbwar",
      "commentable_id": "2",
      "photo": {
        "url": "http://blah",
        "large_url": "http://blah"
      },
      "user": {
        "id": 1,
        "username":"codyswann",
        "display_name":"Cody Swann",
        "public":true,
        "publish_to_facebook":true,
        "publish_to_twitter":true,
        "sms_notifications":true,
        "email_notifications":true,
        "verified":true,
        "sign_in_count":1,
        "wins":0,
        "losses":0,
        "pushes":0,
        "mobile":"55555555555",
        "facebook_id": "xxxxxxxxxxx", 
        "facebook_token": "xxxxxxxxxxx",
        "email": "xxxxxxxxxxx@xxxxxxxxxxx.com", 
        "first_name": "Cody", 
        "last_name": "Swann",
        "avatar": {
          "square_url": "http://xxxxxxxxxxxx"
        }
      }
    }
  ],
  "challenger":{
    "id": 1,
    "username":"codyswann",
    "display_name":"Cody Swann",
    "public":true,
    "publish_to_facebook":true,
    "publish_to_twitter":true,
    "sms_notifications":true,
    "email_notifications":true,
    "verified":true,
    "sign_in_count":1,
    "wins":0,
    "losses":0,
    "pushes":0,
    "mobile":"55555555555",
    "facebook_id": "xxxxxxxxxxx", 
    "facebook_token": "xxxxxxxxxxx",
    "email": "xxxxxxxxxxx@xxxxxxxxxxx.com", 
    "first_name": "Cody", 
    "last_name": "Swann",
    "avatar": {
      "square_url": "http://xxxxxxxxxxxx"
    }
  }
}

curl

curl "https://thumbwar-api-staging.herokuapp.com/thumbwars/94/unwatch?token=QAbHkj97TqNdgkmL622v&facebook_id=10106161156180441" -H "Content-type:application/json" --data "{\"side\":\"challenger\"}"

curl "https://thumbwar-api-staging.herokuapp.com/thumbwars/94/unwatch?token=QAbHkj97TqNdgkmL622v&facebook_id=10106161156180441" -H "Content-type:application/json" --data "{\"side\":\"opponents\"}"

Alerts

GET /alerts

Params

:read - boolean (optional)
:last_seen_id - integer (optional)

Sample Response

{
  "result_count": 1,
  "alerts": [{
    "id": 1, 
    "body": "A Body",
    "alertable_type": "User | Thumbwar | Comment",
    "read": true, 
    "opened": true,
    "alertable":{} <----- can be user / comment / thumbwar
  }]
}

curl

curl "https://thumbwar-api-staging.herokuapp.com/alerts?token=QAbHkj97TqNdgkmL622v&facebook_id=10106161156180441" -H "Content-type:application/json"

GET /alerts/:id

Sample Response

{
  "id": 1, 
  "body": "A Body",
  "alertable_type": "User | Thumbwar | Comment",
  "read": true, 
  "opened": true,
  "alertable":{} <----- can be user / comment / thumbwar
}

curl

curl "https://thumbwar-api-staging.herokuapp.com/alerts/22?token=QAbHkj97TqNdgkmL622v&facebook_id=10106161156180441" -H "Content-type:application/json"

PUT /alerts/:id

Params

alert[read] - boolean (optional)

Sample Response

{
  "id": 1, 
  "body": "A Body",
  "alertable_type": "User | Thumbwar | Comment",
  "read": true, 
  "opened": true,
  "alertable":{} <----- can be user / comment / thumbwar
}

curl

curl "https://thumbwar-api-staging.herokuapp.com/alerts/22?token=QAbHkj97TqNdgkmL622v&facebook_id=10106161156180441" -H "Content-type:application/json" -X PUT --data "{\"read\":0}"

curl "https://thumbwar-api-staging.herokuapp.com/alerts/22?token=QAbHkj97TqNdgkmL622v&facebook_id=10106161156180441" -H "Content-type:application/json" -X PUT --data "{\"read\":1}"

Evidence Photo

POST /evidence_photos

Params

:thumbwar_id, (required)
:photo, (required if remote_photo_url is not provided)
:remote_photo_url (required if photo is not provided)

Sample Response

{
  "id":1, 
  "user_id":1, 
  "thumbwar_id":1, 
  "has_default_photo":false,
  "url": "http://blah",
  "large_url": "http://blah",
  "created_at":"<timestamp>", 
  "updated_at":"<timestamp>"
}

curl

curl "https://thumbwar-api-staging.herokuapp.com/evidence_photos?token=QAbHkj97TqNdgkmL622v&facebook_id=10106161156180441" -H "Content-type:application/json" --data "{\"thumbwar_id\":1,\"remote_photo_url\":\"http://cbsradionews.files.wordpress.com/2013/09/gene-simmons-by-afpgetty.jpg\"}"

curl -i  -F "evidence_photos[thumbwar_id]=1" -F "evidence_photos[photo]=@/Users/cody/Desktop/fireball-wallpaper-2.jpg" "https://thumbwar-api-staging.herokuapp.com/thumbwars?token=QAbHkj97TqNdgkmL622v&facebook_id=10106161156180441"

Challenge

POST /challenges

Params

:user_id, (required)
:status, //pending, accepted, rejected (pending is default)
:thumbwar_id, (required)

Sample Response

{
  "id":1, 
  "user_id":1, 
  "thumbwar_id":1, 
  "status":'accepted', 
  "challenger_id":1, 
  "created_at":"<timestamp>", 
  "updated_at":"<timestamp>"
}

curl "https://thumbwar-api-staging.herokuapp.com/challenges?token=QAbHkj97TqNdgkmL622v&facebook_id=10106161156180441" -H "Content-type:application/json" --data "{\"thumbwar_id\":94,\"user_id\":2}"

PUT /challenges/:id

Params

:status, //pending, accepted, rejected

Sample Response

{
  "id":1, 
  "user_id":1, 
  "thumbwar_id":1, 
  "status":'accepted', 
  "challenger_id":1, 
  "created_at":"<timestamp>", 
  "updated_at":"<timestamp>"
}

curl

curl "https://thumbwar-api-staging.herokuapp.com/challenges/99?token=QAbHkj97TqNdgkmL622v&facebook_id=10106161156180441" -H "Content-type:application/json" -X PUT --data "{\"thumbwar_id\":94,\"status\":\"accepted\"}"

curl "https://thumbwar-api-staging.herokuapp.com/challenges/99?token=QAbHkj97TqNdgkmL622v&facebook_id=10106161156180441" -H "Content-type:application/json" -X PUT --data "{\"thumbwar_id\":94,\"status\":\"rejected\"}"

Comment

POST /thumbwars/:thumbwar_id/comments

Params

comment[:body], text - optional
comment[:photo], file - optional

Sample Response

{
  "id":1,
  "body": "blah, blah, blah, blah",
  "commentable_type", "Thumbwar",
  "commentable_id": "2",
  "photo": {
    "url": "http://blah",
    "large_url": "http://blah"
  },
  "user": {
    "id": 1,
    "username":"codyswann",
    "display_name":"Cody Swann",
    "public":true,
    "publish_to_facebook":true,
    "publish_to_twitter":true,
    "sms_notifications":true,
    "email_notifications":true,
    "verified":true,
    "sign_in_count":1,
    "wins":0,
    "losses":0,
    "pushes":0,
    "mobile":"55555555555",
    "facebook_id": "xxxxxxxxxxx", 
    "facebook_token": "xxxxxxxxxxx",
    "email": "xxxxxxxxxxx@xxxxxxxxxxx.com", 
    "first_name": "Cody", 
    "last_name": "Swann",
    "avatar": {
      "square_url": "http://xxxxxxxxxxxx"
    }
  }
}

curl

curl "https://thumbwar-api-staging.herokuapp.com/thumbwars/94/comments?token=QAbHkj97TqNdgkmL622v&facebook_id=10106161156180441" -H "Content-type:application/json" --data "{\"body\":\"I smell terrible\"}"

curl -i -F "comment[photo]=@/Users/cody/Desktop/fireball-wallpaper-2.jpg"  "https://thumbwar-api-staging.herokuapp.com/thumbwars/94/comments?token=QAbHkj97TqNdgkmL622v&facebook_id=10106161156180441"

GET /thumbwars/:thumbwar_id/comments

Sample Response

[
   {
      "id":166,
      "commentable_id":94,
      "commentable_type":"Thumbwar",
      "title":null,
      "body":"I smell terrible",
      "subject":null,
      "user_id":1,
      "parent_id":null,
      "lft":329,
      "rgt":330,
      "created_at":"2015-01-17T06:04:13.235Z",
      "updated_at":"2015-01-17T06:04:13.235Z",
      "photo":{
         "url":"http://thumbwar-api-staging.herokuapp.com/images/fallback/photos/default.png",
         "large":{
            "url":"http://thumbwar-api-staging.herokuapp.com/images/fallback/photos/large_default.png"
         }
      }
   }
]

curl

curl "https://thumbwar-api-staging.herokuapp.com/thumbwars/94/comments?token=QAbHkj97TqNdgkmL622v&facebook_id=10106161156180441" -H "Content-type:application/json"