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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
use reqwest::Method;
use serde::Deserialize;

use crate::{client::ApiClient, read_structured_response, ApiResult};

#[derive(Debug, Clone, Deserialize)]
pub struct MeProfile {
    pub nickname: String,

    #[serde(rename = "userId")]
    pub user_id: u64,

    #[serde(rename = "backgroundImageUrl")]
    pub background_image_url: String,
    #[serde(rename = "originalBackgroundImageUrl")]
    pub original_background_image_url: String,

    #[serde(rename = "statusMessage")]
    pub status_message: String,

    #[serde(rename = "profileImageUrl")]
    pub profile_image_url: String,
    #[serde(rename = "fullProfileImageUrl")]
    pub full_profile_image_url: String,
    #[serde(rename = "originalProfileImageUrl")]
    pub original_profile_image_url: String,
}

#[derive(Debug, Clone, Deserialize)]
pub struct Me {
    pub profile: MeProfile,
}

impl Me {
    pub async fn request(client: ApiClient<'_>) -> ApiResult<Self> {
        read_structured_response(client.request(Method::GET, "profile3/me.json")?).await
    }
}
#[derive(Debug, Clone, Deserialize)]
pub struct FriendProfile {
    #[serde(rename = "userId")]
    pub user_id: u64,

    #[serde(rename = "backgroundImageUrl")]
    pub background_image_url: String,
    #[serde(rename = "originalBackgroundImageUrl")]
    pub original_background_image_url: String,

    #[serde(rename = "statusMessage")]
    pub status_message: String,

    #[serde(rename = "profileImageUrl")]
    pub profile_image_url: String,
    #[serde(rename = "fullProfileImageUrl")]
    pub full_profile_image_url: String,
    #[serde(rename = "originalProfileImageUrl")]
    pub original_profile_image_url: String,
}

#[derive(Debug, Clone, Deserialize)]
pub struct FriendInfo {
    pub profile: FriendProfile,
}

impl FriendInfo {
    pub async fn request(client: ApiClient<'_>, id: u64) -> ApiResult<Self> {
        read_structured_response(
            client
                .request(Method::GET, "profile3/friend_info.json")?
                .query(&[("id", id)]),
        )
        .await
    }
}