docs/src/API.md

117 lines
1.9 KiB
Markdown
Raw Permalink Normal View History

2021-03-16 16:18:01 +00:00
# Hole Frontend API
2021-04-16 15:46:58 +00:00
<!-- ## Loginning and Registration -->
2021-03-16 16:18:01 +00:00
2021-04-16 15:46:58 +00:00
<!-- ### Registration request -->
<!-- On base of password will be generted keypair for signing and keypair for encoding. -->
<!-- ``` json -->
<!-- { -->
<!-- request_type: "registration", -->
<!-- username: "user", -->
<!-- password: "passwd123", -->
<!-- } -->
<!-- ``` -->
2021-03-16 16:18:01 +00:00
2021-04-16 15:46:58 +00:00
<!-- ### Login request -->
<!-- ```json -->
<!-- { -->
<!-- request_type: login, -->
<!-- username: "name", -->
<!-- decode_key: "key", -->
<!-- sign_key: "key", -->
<!-- } -->
<!-- ``` -->
2021-03-16 16:18:01 +00:00
2021-04-16 15:46:58 +00:00
<!-- ## Adding friends -->
<!-- Each user have :w -->
2021-03-16 16:18:01 +00:00
2021-04-16 15:44:07 +00:00
----
# Message type
``` json
{
message: it's a message,
date: Time,
id: Id,
fromMe: bool,
}
}
```
---
2021-04-16 15:44:07 +00:00
# Requests
``` Rust
pub enum Request {
StartApp,
StopApp,
LoadUsers,
#[serde(rename_all = "camelCase")]
SendMessage {
user_id: Id,
message: String,
},
#[serde(rename_all = "camelCase")]
LoadMessages {
user_id: Id,
count: u32,
start_index: u32,
},
#[serde(rename_all = "camelCase")]
AddUser {
name: String,
sign_key: String,
insert_key: String,
}, // CreateInstance TODO v0.3
}
```
## `StartApp`
Require when when client started.
``` json
2021-04-16 15:46:58 +00:00
{
2021-04-16 15:44:07 +00:00
type: "startApp"
2021-04-16 15:46:58 +00:00
}
2021-04-16 15:44:07 +00:00
```
## `StopApp`
``` json
2021-04-16 15:46:58 +00:00
{
2021-04-16 15:44:07 +00:00
type: "stopApp"
2021-04-16 15:46:58 +00:00
}
2021-04-16 15:44:07 +00:00
```
## `LoadUsers`
``` json
2021-04-16 15:46:58 +00:00
{
2021-04-16 15:44:07 +00:00
type: "loadUsers"
2021-04-16 15:46:58 +00:00
}
2021-04-16 15:44:07 +00:00
```
## `SendMessage`
``` json
2021-04-16 15:46:58 +00:00
{
2021-04-16 15:44:07 +00:00
type: "sendMessage",
userId: "UUID_V4...",
message: "hellow world"
2021-04-16 15:46:58 +00:00
}
2021-04-16 15:44:07 +00:00
```
## `AddUser`
``` json
2021-04-16 15:46:58 +00:00
{
2021-04-16 15:44:07 +00:00
type: "addUser",
name: "username",
signKey: "USK@key...",
insertKey: "insertkey..."
2021-04-16 15:46:58 +00:00
}
2021-04-16 15:44:07 +00:00
```
## `LoadMessages`
Requesting `count` messages from `userId` started from `startIndex`'s message
``` json
2021-04-16 15:46:58 +00:00
{
2021-04-16 15:44:07 +00:00
type: "loadMessages",
userId: "UUID_V4...",
count: 10,
startIndex: 30
2021-04-16 15:46:58 +00:00
}
2021-04-16 15:44:07 +00:00
```