Skip to content

Instantly share code, notes, and snippets.

@justinvdm
Last active December 9, 2016 13:47
Show Gist options
  • Save justinvdm/3b09a092e0a893f413556d393da8d6a2 to your computer and use it in GitHub Desktop.
Save justinvdm/3b09a092e0a893f413556d393da8d6a2 to your computer and use it in GitHub Desktop.

chat api

list

request

GET /mentor/chat_message/

response

{
  result: [{
    id: '21',
    message_type: 'USER',
    direction: 'INBOUND',
    time_sent: '2016-11-30T09:43:20.311Z',
    content: 'Sputnik sickles found in the seats'
  }]
}

query params

page_size

Choose number of items to return per page. Should be easy to add via django rest framework's out of the box pagination support.

fields

direction

direction is something the client side will use to figure out whether this is a sent message (if value is OUTBOUND), or received message (if value is INBOUND). This will be much easier for the client side than trying to figure this out from the sender and receiver addresses.

it doesnt necessarily have to be a field on the model, it can be calculated in serializer if it makes more sense

message_type

mUSER if the message was sent by a mentor or mentee, SYSTEM if the message was sent by the system.

create

request

POST /mentor/chat_message/
{
  content: 'To whisper the winds plea to accept an emptied room'
}

response

{
  id: '23',
  message_type: 'USER',
  direction: 'OUTBOUND',
  time_sent: '2016-11-30T09:43:20.311Z',
  content: 'To whisper the winds plea to accept an emptied room'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment