Deem Offers API Documentation

Users

Many of the resources on the users API provide a shortcut for getting information about the currently authenticated user. If a request URL does not include a :user parameter than the response will be for the user infered from an access token.

Get a user

GET /users/:user_id

Response

Status: 200 OK
{
  "status": "success",
  "user": {
    "id": "ABC123",
    "firstname": "deal",
    "lastname": "seeker",
    "image_url": "http://graph.facebook.com/508354830/picture?type=large",
    "points": 100,
    "token": "partner_provided"
  }
}

Create a user

POST /users

Parameters

email
String
source
  • String used for reporting
  • only valid with api_token
token
  • String partner token
  • only valid with api_token
first_name
String
last_name
String
birthday
String
postal_code
String
credits
Integer Amount of credits in cents. If this value is not provided, the default new user signup credit will be assigned.
partner_data
Hash Store data about a user. Be careful to not overwrite this value.
session_id (optional)
STRING If specified, the action will find the affiliate information from the session and remember the user is created through the affiliate

Response

Status: 200 OK
{
  "status": "success",
  "user_id": "abc123"
}

Update a user

PUT /users/:user_id

Parameters

email
String
source
  • String used for reporting
  • only valid with api_token
token
  • String partner token
  • only valid with api_token
first_name
String
last_name
String
birthday
String
postal_code
String
pass
String Password, must be at least 5 characters long. If updating this value, pass_confirmation must also be provided.
pass_confirmation
String Same as pass
partner_data
Hash Store data about a user. Be careful to not overwrite this value.
is_deleted
Boolean The soft delete status of a user.

Response

Status: 200 OK
{
  "status": "success",
  "user": {
    "id": "ABC123",
    "firstname": "deal",
    "lastname": "seeker",
    "image_url": "http://graph.facebook.com/508354830/picture?type=large",
    "points": 100,
    "token": "partner_provided"
  }
}

Update a user by email

This particular resource can be accessed with an optional request parameter

Without the optional parameter the request will look like this

PUT /api/v1/users/:user@email_address.com/update_by_email

With the optional parameter the request will look like this

PUT /api/v1/users/:user@email_address.com/update_by_email?overwrite_token=true

The ramifications of this are as follows:-

  • assuming the user pre-exists in the offer engine

    • if a token is included in the request but it has not changed
      then no further action is required

    • if a token is included in the request and there was not a token previously
      then no further action is required

    • if a token is included in the request but it has changed
      then the overwrite_token = true option must be included:

      • this will instruct the api to update the users token with the new value,
        failure to include the option will result in a 422 error
  • assuming the user does not exist yet in the offer engine

    • this resource can still be PUT to,
      resulting in the user being created in the offer engine:
      The overwrite token is not required in this scenario

Parameters

source
  • String used for reporting
  • only valid with api_token
token
  • String partner token
  • only valid with api_token
  • see note above: optional overwrite_token=true might be required on the request
first_name
String
last_name
String
birthday
String
postal_code
String
partner_data
Hash Store data about a user. Be careful to not overwrite this value.
is_deleted
Boolean The soft delete status of a user.

Response

Status: 200 OK
{
  "status": "success",
  "user": {
    "id": "ABC123",
    "firstname": "deal",
    "lastname": "seeker",
    "image_url": "http://graph.facebook.com/508354830/picture?type=large",
    "points": 100,
    "token": "partner_provided"
  }
}
  • if the token has changed for an existing user and the overwrite_token=true option
    was not included on the request then the reponse will be
Status: 422 Unprocessable Entity
{
  "status": "error",
  "error_type": "update_failed",
  "error_msg": "Unable to update, partner token has changed"
}