icheck.io-client
v1.0.0
Published
Icheck.io sdk for web
Downloads
3
Readme
icheck.io-client
Example
icheckio.initializeApp(window.location.origin, {
query: {
token: "jwt...."
}
});
var conversations = [];
var ref = icheckio.ref("/users/1/conversations")
.limit(5)
.sort("id desc")
.on("child_added", (data) => {
conversations.push(data);
})
.on("child_changed", (data) => {
// change conversation
})
.on("child_deleted" => {
// delete conversation
})
// next page
ref.next();
var messageRef = icheckio.ref("/conversations/1/messages")
.limit(5)
.sort("id desc")
.on("child_added", (data) => {
conversations.push(data);
})
// next page
messageRef.next();
messageRef.push({
message: "content"
})
Using other method
GET
icheckio.get("/users/1", {}, (data) => {
//console.log(data);
});
POST
icheckio.post("/conversations/1/messages", {body:"demo"}, (data) => {
//console.log(data);
});
PUT
icheckio.put("/messages/1", {body:"demo"}, (data) => {
//console.log(data);
});
DELETE
icheckio.delete("/messages/1", {}, (data) => {
//console.log(data);
});
List the conversations
of the user #i-1498892184948:
GET /users/i-1498892184948/conversations
Expected response
{
"status": 200,
"data": [
{
"conversation_id": "596c3682d41e36927de44558",
"user_id": "i-1498892184948",
"metadata": {},
"createdAt": "2017-07-17T04:01:06.115Z",
"updatedAt": "2017-07-17T06:23:55.008Z",
"last_sender": "i-1498892184948",
"last_message": "3",
"id": "596c3682d41e36927de4455a",
"other_user_id": "i-1500112969899",
"participants": [
"i-1498892184948",
"i-1500112969899"
],
"unread_count": 5
}
]
}
List the messages
of the conversation #i-1500112969899:
GET /conversations/i-1500112969899/messages
Expected response
{
"status": 200,
"data": [
{
"conversation_id": "596c3682d41e36927de44558",
"sender_id": "i-1498892184948",
"body": "3",
"attachments": [],
"unread": true,
"metadata": {},
"createdAt": "2017-07-17T06:23:54.992Z",
"updatedAt": "2017-07-17T06:23:54.992Z",
"id": "596c57fa30fea5773a434021"
}
]
}