talk_api_internal/
profile.rs

1use reqwest::Method;
2use serde::Deserialize;
3
4use crate::{client::ApiClient, read_structured_response, ApiResult};
5
6#[derive(Debug, Clone, Deserialize)]
7pub struct MeProfile {
8    pub nickname: String,
9
10    #[serde(rename = "userId")]
11    pub user_id: u64,
12
13    #[serde(rename = "backgroundImageUrl")]
14    pub background_image_url: String,
15    #[serde(rename = "originalBackgroundImageUrl")]
16    pub original_background_image_url: String,
17
18    #[serde(rename = "statusMessage")]
19    pub status_message: String,
20
21    #[serde(rename = "profileImageUrl")]
22    pub profile_image_url: String,
23    #[serde(rename = "fullProfileImageUrl")]
24    pub full_profile_image_url: String,
25    #[serde(rename = "originalProfileImageUrl")]
26    pub original_profile_image_url: String,
27}
28
29#[derive(Debug, Clone, Deserialize)]
30pub struct Me {
31    pub profile: MeProfile,
32}
33
34impl Me {
35    pub async fn request(client: ApiClient<'_>) -> ApiResult<Self> {
36        read_structured_response(client.request(Method::GET, "profile3/me.json")?).await
37    }
38}
39#[derive(Debug, Clone, Deserialize)]
40pub struct FriendProfile {
41    #[serde(rename = "userId")]
42    pub user_id: u64,
43
44    #[serde(rename = "backgroundImageUrl")]
45    pub background_image_url: String,
46    #[serde(rename = "originalBackgroundImageUrl")]
47    pub original_background_image_url: String,
48
49    #[serde(rename = "statusMessage")]
50    pub status_message: String,
51
52    #[serde(rename = "profileImageUrl")]
53    pub profile_image_url: String,
54    #[serde(rename = "fullProfileImageUrl")]
55    pub full_profile_image_url: String,
56    #[serde(rename = "originalProfileImageUrl")]
57    pub original_profile_image_url: String,
58}
59
60#[derive(Debug, Clone, Deserialize)]
61pub struct FriendInfo {
62    pub profile: FriendProfile,
63}
64
65impl FriendInfo {
66    pub async fn request(client: ApiClient<'_>, id: u64) -> ApiResult<Self> {
67        read_structured_response(
68            client
69                .request(Method::GET, "profile3/friend_info.json")?
70                .query(&[("id", id)]),
71        )
72        .await
73    }
74}