Skip to main content

ncm_api_rs/api/
user_update.rs

1use super::Query;
2use crate::error::Result;
3/// 更新用户资料
4/// 对应 Node.js module/user_update.js
5use crate::request::{ApiClient, ApiResponse, CryptoType};
6use serde_json::json;
7
8impl ApiClient {
9    /// 更新用户资料
10    /// 对应 /user/update
11    pub async fn user_update(&self, query: &Query) -> Result<ApiResponse> {
12        let data = json!({
13            "birthday": query.get_or("birthday", ""),
14            "city": query.get_or("city", ""),
15            "gender": query.get_or("gender", ""),
16            "nickname": query.get_or("nickname", ""),
17            "province": query.get_or("province", ""),
18            "signature": query.get_or("signature", "")
19        });
20        self.request(
21            "/api/user/profile/update",
22            data,
23            query.to_option(CryptoType::default()),
24        )
25        .await
26    }
27}