/chat-kata

A Code Kata for building a REST client-server chat app for Android

Primary LanguageJava

chat-kata

A Code Kata for building a REST client-server chat app for Android.

Client-side Kata

Follow the README in client directory

API Contract

The following are the definition of the API resources.

Chat Resource

This the main resource of the chat server.

Endpoint: /api/chat

Get chat messages

Method: GET

Parameters:

NameTypeDescriptionMandatoryCardinalityExample
seqIntegerSequence from last received message. No present if this is the first callNo1/api/chat?seq=3

Response:

  • Response when there are new messages:

     {
     	"messages": [ {"nick":"user1", "message":"hi there"},
                   {"nick":"user2", "message":"hola"} ],
     	"last_seq": 6
     }
  • Response when there are no new messages:

     {
     	"messages": [],
     	"last_seq": 6
     }

Errors:

Status CodeBodyDescription
400
{"error":"invalid seq parameter"}
When the seq parameter is invalid (e.g. an string)

Send chat messages

Method: POST

Body:

{
    "nick":"user1",
	"message": "Hola Mundo Reader"
}

Errors:

Status CodeBodyDescription
400
{"error":"invalid body"}
When no body or invalid JSON is sent
400
{"error":"missing nick parameter"}
When the user nick is missing in the body
400
{"error":"missing message parameter"}
When the message is missing in the body

Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 Unported License.