Update Docs
parent
1158481cb9
commit
a0324ae78c
44
Docs.md
44
Docs.md
|
@ -1,76 +1,120 @@
|
||||||
# Docs for smk-chat
|
# Docs for smk-chat
|
||||||
## API
|
## API
|
||||||
### /api/getCredentialsById/:userId
|
### /api/getCredentialsById/:userId
|
||||||
|
|
||||||
IN: _userId_ (in route)
|
IN: _userId_ (in route)
|
||||||
|
|
||||||
OUT: _lastname_, _firstname_, _middlename_
|
OUT: _lastname_, _firstname_, _middlename_
|
||||||
|
|
||||||
Return credentials of the user whose id is userId.
|
Return credentials of the user whose id is userId.
|
||||||
|
|
||||||
Return -1 if no such user exist.
|
Return -1 if no such user exist.
|
||||||
|
|
||||||
Requires client to be logged in.
|
Requires client to be logged in.
|
||||||
|
|
||||||
### /api/getIdByCredentials
|
### /api/getIdByCredentials
|
||||||
IN: _lastname_, _firstname_, _middlename_
|
IN: _lastname_, _firstname_, _middlename_
|
||||||
|
|
||||||
OUT: _UserID_
|
OUT: _UserID_
|
||||||
|
|
||||||
Returns an ID of the user, whose lastname, firstname and middlename were passed.
|
Returns an ID of the user, whose lastname, firstname and middlename were passed.
|
||||||
|
|
||||||
Returns -1 if user does not exist.
|
Returns -1 if user does not exist.
|
||||||
|
|
||||||
Requires client to be logged in.
|
Requires client to be logged in.
|
||||||
|
|
||||||
### /api/getMessagesFromChat/by-amount
|
### /api/getMessagesFromChat/by-amount
|
||||||
IN: _chatId_, _amount_
|
IN: _chatId_, _amount_
|
||||||
|
|
||||||
OUT: array of objects that represent a message, like {"author_id": ..., time_sent: ..., content: ...}
|
OUT: array of objects that represent a message, like {"author_id": ..., time_sent: ..., content: ...}
|
||||||
|
|
||||||
Returns an array of last _amount_ ordered by date of described objects if everything is okay
|
Returns an array of last _amount_ ordered by date of described objects if everything is okay
|
||||||
|
|
||||||
Returns HTTP/1.1 400 "Chat with id _ID_ does not exist." if no chat with supplied id does not exist.
|
Returns HTTP/1.1 400 "Chat with id _ID_ does not exist." if no chat with supplied id does not exist.
|
||||||
|
|
||||||
Returns HTTP/1.1 403 "You are not a member of this chat" if the statement is true ;)
|
Returns HTTP/1.1 403 "You are not a member of this chat" if the statement is true ;)
|
||||||
|
|
||||||
Requires client to be logged in.
|
Requires client to be logged in.
|
||||||
|
|
||||||
### /api/getMessagesFromChat/by-time
|
### /api/getMessagesFromChat/by-time
|
||||||
IN: _chatId_, _fromTimestamp_, _toTimestamp_
|
IN: _chatId_, _fromTimestamp_, _toTimestamp_
|
||||||
|
|
||||||
OUT: array of objects that represent a message, like {"author_id": ..., time_sent: ..., content: ...}
|
OUT: array of objects that represent a message, like {"author_id": ..., time_sent: ..., content: ...}
|
||||||
|
|
||||||
_fromTimestamp_ must be lower that _toTimestamp_, otherwise it might return nothing.
|
_fromTimestamp_ must be lower that _toTimestamp_, otherwise it might return nothing.
|
||||||
|
|
||||||
Returns an array of described objects if everything is okay
|
Returns an array of described objects if everything is okay
|
||||||
|
|
||||||
Returns HTTP/1.1 400 "Chat with id _ID_ does not exist." if no chat with supplied id does not exist.
|
Returns HTTP/1.1 400 "Chat with id _ID_ does not exist." if no chat with supplied id does not exist.
|
||||||
|
|
||||||
Returns HTTP/1.1 200 and an empty string if no messages in chat are found /shrug.
|
Returns HTTP/1.1 200 and an empty string if no messages in chat are found /shrug.
|
||||||
|
|
||||||
Requires client to be logged in.
|
Requires client to be logged in.
|
||||||
|
|
||||||
### /api/getChats
|
### /api/getChats
|
||||||
IN: _UserID_
|
IN: _UserID_
|
||||||
|
|
||||||
OUT: Array of chat IDs
|
OUT: Array of chat IDs
|
||||||
|
|
||||||
Returs an array with ids of chats which user with passed ID is member in.
|
Returs an array with ids of chats which user with passed ID is member in.
|
||||||
|
|
||||||
Return empty string if user has no membership in any chat.
|
Return empty string if user has no membership in any chat.
|
||||||
|
|
||||||
Requires client to be logged in.
|
Requires client to be logged in.
|
||||||
|
|
||||||
### /api/getChatInfo/:chatId
|
### /api/getChatInfo/:chatId
|
||||||
IN: _chatId_ (in route)
|
IN: _chatId_ (in route)
|
||||||
|
|
||||||
OUT: JSON describes a chat with id: {name: ..., admins: ..., members: ...}
|
OUT: JSON describes a chat with id: {name: ..., admins: ..., members: ...}
|
||||||
|
|
||||||
Note: JSON does not include messages. You have to use __/api/getMessagesFromChat__ to query messages.
|
Note: JSON does not include messages. You have to use __/api/getMessagesFromChat__ to query messages.
|
||||||
|
|
||||||
Returns aforementioned json if the chat exists and user is a member of this chat.
|
Returns aforementioned json if the chat exists and user is a member of this chat.
|
||||||
|
|
||||||
Returns -1 if chat does not exist
|
Returns -1 if chat does not exist
|
||||||
|
|
||||||
Return -2 if user is not a member of the chat
|
Return -2 if user is not a member of the chat
|
||||||
|
|
||||||
Requires client to be logged in.
|
Requires client to be logged in.
|
||||||
|
|
||||||
### /api/createChat
|
### /api/createChat
|
||||||
IN: _UserId_, array of UserIDs that are to be invited.
|
IN: _UserId_, array of UserIDs that are to be invited.
|
||||||
|
|
||||||
OUT: "Ok" if successful, "User with id _MEMBERID_ does not exist."
|
OUT: "Ok" if successful, "User with id _MEMBERID_ does not exist."
|
||||||
|
|
||||||
Return -1 if amout of users to invite is 0.
|
Return -1 if amout of users to invite is 0.
|
||||||
|
|
||||||
Requires client to be logged in
|
Requires client to be logged in
|
||||||
|
|
||||||
### /api/logout
|
### /api/logout
|
||||||
IN: none.
|
IN: none.
|
||||||
|
|
||||||
OUT: redirect to __/login__.
|
OUT: redirect to __/login__.
|
||||||
|
|
||||||
Removes client's session, thus unlogging a user.
|
Removes client's session, thus unlogging a user.
|
||||||
|
|
||||||
Requires client to be logged in.
|
Requires client to be logged in.
|
||||||
|
|
||||||
### /api/register
|
### /api/register
|
||||||
IN: _lastname_, _firstname_, _middlename_, _password_
|
IN: _lastname_, _firstname_, _middlename_, _password_
|
||||||
|
|
||||||
OUT: redirect to __/__
|
OUT: redirect to __/__
|
||||||
|
|
||||||
Checks if user exist. If so, returns 400 with response "Such user exists.".
|
Checks if user exist. If so, returns 400 with response "Such user exists.".
|
||||||
|
|
||||||
Otherwise, registers a user with given data.
|
Otherwise, registers a user with given data.
|
||||||
|
|
||||||
Requires clinet to be not logged in.
|
Requires clinet to be not logged in.
|
||||||
|
|
||||||
### /api/login
|
### /api/login
|
||||||
IN: _lastname_, _firstname_, _middlename_, _password_
|
IN: _lastname_, _firstname_, _middlename_, _password_
|
||||||
|
|
||||||
OUT: redirect to __/__
|
OUT: redirect to __/__
|
||||||
|
|
||||||
Checks if user exists. If not, returns 400 with response "No such user.".
|
Checks if user exists. If not, returns 400 with response "No such user.".
|
||||||
|
|
||||||
Otherwise, compares passwords
|
Otherwise, compares passwords
|
||||||
|
|
||||||
If passwords match, creating session and redirects to __/__
|
If passwords match, creating session and redirects to __/__
|
||||||
|
|
||||||
Requires client to be not logged in.
|
Requires client to be not logged in.
|
||||||
|
|
Loading…
Reference in New Issue