1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
use crate::{handle_error, ErrorResponse, Result, Tarkov, PROD_ENDPOINT};
use crate::profile::Side;
use serde::Deserialize;
#[derive(Debug, Deserialize)]
struct FriendResponse {
#[serde(flatten)]
error: ErrorResponse,
data: Option<Friends>,
}
#[derive(Debug, Deserialize, Clone, PartialEq)]
#[serde(rename_all = "PascalCase")]
pub struct Friends {
pub friends: Vec<Friend>,
pub ignore: Vec<String>,
pub in_ignore_list: Vec<String>,
}
#[derive(Debug, Deserialize, Clone, PartialEq)]
#[serde(rename_all = "PascalCase")]
pub struct Friend {
#[serde(rename = "_id")]
pub id: String,
pub info: Info,
}
#[derive(Debug, Deserialize, Clone, PartialEq)]
#[serde(rename_all = "PascalCase")]
pub struct Info {
pub nickname: String,
pub side: Side,
pub level: u64,
pub member_category: String,
}
impl Tarkov {
pub async fn get_friends(&self) -> Result<Friends> {
let url = format!("{}/client/friend/list", PROD_ENDPOINT);
let res: FriendResponse = self.post_json(&url, &{}).await?;
handle_error(res.error, res.data)
}
}