Fork me on GitHub

Chat and ChatMessages represent, respectively, a conversation between two users and its messages. At this moment, it is only possible to view these resources via API. The possibility of creating and removing chat messages, as well as the streaming of them, will be available soon.

Chat

GET /api/users/:id/chats

Returns all the chats of the user in question.

Authorization

You need to have permission for user management.

Parameters

Parameter Description Restrictions
id User ID or login N/A

Example

Request:

GET /api/users/guiocavalcanti/chats12

Response:

[ {
"links": [
{
  "rel": "self",
    "href": "http://redu.com.br/api/chats/1475"
},
{
  "rel": "user",
  "href": "http://redu.com.br/api/users/guiocavalcanti"
},
{
  "rel": "contact",
  "href": "http://redu.com.br/api/users/tiago"
},
{
  "rel": "chat_messages",
  "href": "http://redu.com.br/api/chats/1475/chat_messages"
}
],
  "id": 1475,
  "created_at": "2012-09-19T15:29:13-03:00",
  "updated_at": "2012-09-19T15:29:13-03:00"
},
{
"links": [
{
  "rel": "self",
  "href": "http://redu.com.br/api/chats/1477"
},
{
  "rel": "user",
  "href": "http://redu.com.br/api/users/guiocavalcanti"
},
{
  "rel": "contact",
  "href": "http://redu.com.br/api/users/test_user"
},
{
  "rel": "chat_messages",
  "href": "http://redu.com.br/api/chats/1477/chat_messages"
}
],
  "id": 1477,
  "created_at": "2012-09-19T15:29:13-03:00",
  "updated_at": "2012-09-19T15:29:13-03:00"
} ]

GET /api/chats/:id

Returns the chat in question. The Chat resource contains all the messages between two users which were sent by using the Redu chat system.

Authorization

You need to participate in the chat to view this resource

Parameters

Parameter Description Restrictions
id Chat ID N/A

Example

Request:

GET /api/chats/1475

Response:

{
  "links": [
      {
          "rel": "self",
          "href": "http://redu.com.br/api/chats/1475"
      },
      {
          "rel": "user",
          "href": "http://redu.com.br/api/users/guiocavalcanti"
      },
      {
          "rel": "contact",
          "href": "http://127.0.0.1:3000/api/users/tiago"
      },
      {
          "rel": "chat_messages",
          "href": "http://127.0.0.1:3000/api/chats/1475/chat_messages"
      }
  ],
  "id": 1475,
  "created_at": "2012-09-19T15:29:13-03:00",
  "updated_at": "2012-09-19T15:29:13-03:00"
}

Chat message

GET /api/chats/:id/chat_messages

Returns all the messages that belong to a chat.

Authorization

You need to participate in the chat to view this resource

Parameters

Parameter Description Restrictions
id Chat ID N/A

Example

Request:

GET /api/chats/1475/chat_messages

Response:

[
{
  "links": [
  {
    "rel": "self",
      "href": "http://127.0.0.1:3000/api/chat_messages/16"
  },
  {
    "rel": "user",
    "href": "http://127.0.0.1:3000/api/users/guiocavalcanti"
  },
  {
    "rel": "contact",
    "href": "http://127.0.0.1:3000/api/users/tiago"
  },
  {
    "rel": "sender_chat",
    "href": "http://127.0.0.1:3000/api/chats/1475"
  },
  {
    "rel": "receiver_chat",
    "href": "http://127.0.0.1:3000/api/chats/1476"
  }
  ],
    "id": 16,
    "created_at": "2011-06-29T13:15:18-03:00",
    "message": "Opa!",
    "updated_at": "2011-06-29T13:15:18-03:00"
},
{
  "links": [
  {
    "rel": "self",
    "href": "http://127.0.0.1:3000/api/chat_messages/34"
  },
  {
    "rel": "user",
    "href": "http://127.0.0.1:3000/api/users/guiocavalcanti"
  },
  {
    "rel": "contact",
    "href": "http://127.0.0.1:3000/api/users/tiago"
  },
  {
    "rel": "sender_chat",
    "href": "http://127.0.0.1:3000/api/chats/1475"
  },
  {
    "rel": "receiver_chat",
    "href": "http://127.0.0.1:3000/api/chats/1476"
  }
  ],
    "id": 34,
    "created_at": "2011-06-29T13:55:35-03:00",
    "message": "Todo mundo com foto",
    "updated_at": "2011-06-29T13:55:35-03:00"
}
]

GET /api/chat_messages/:id

Returns a chat message.

Authorization

You need to participate in the chat to view this resource

Parameters

Parameter Description Restrictions
id Message ID N/A

Example

Request:

GET /api/chat_messages/169

Response:

{
  "links": [
  {
    "rel": "self",
      "href": "http://127.0.0.1:3000/api/chat_messages/16"
  },
  {
    "rel": "user",
    "href": "http://127.0.0.1:3000/api/users/guiocavalcanti"
  },
  {
    "rel": "contact",
    "href": "http://127.0.0.1:3000/api/users/tiago"
  },
  {
    "rel": "sender_chat",
    "href": "http://127.0.0.1:3000/api/chats/1475"
  },
  {
    "rel": "receiver_chat",
    "href": "http://127.0.0.1:3000/api/chats/1476"
  }
  ],
    "id": 16,
    "created_at": "2011-06-29T13:15:18-03:00",
    "message": "Opa!",
    "updated_at": "2011-06-29T13:15:18-03:00"
}