Skip to main content

azisaba_graph/apis/
players_api.rs

1/*
2 * Azisaba Graph API
3 *
4 * An API for connecting and sharing data across the Azisaba Network.
5 *
6 * The version of the OpenAPI document: 0.0.1
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17/// struct for passing parameters to the method [`accept_player_friend_request`]
18#[derive(Clone, Debug)]
19pub struct AcceptPlayerFriendRequestParams {
20    /// The unique identifier of the player.
21    pub player_id: String,
22    /// The unique identifier of the player sending the friend request.
23    pub sender_id: String
24}
25
26/// struct for passing parameters to the method [`add_player_friend`]
27#[derive(Clone, Debug)]
28pub struct AddPlayerFriendParams {
29    /// The unique identifier of the player.
30    pub player_id: String,
31    /// The unique identifier of the friend player.
32    pub friend_id: String
33}
34
35/// struct for passing parameters to the method [`add_player_friend_request`]
36#[derive(Clone, Debug)]
37pub struct AddPlayerFriendRequestParams {
38    /// The unique identifier of the player.
39    pub player_id: String,
40    /// The unique identifier of the player sending the friend request.
41    pub sender_id: String
42}
43
44/// struct for passing parameters to the method [`get_player_by_id`]
45#[derive(Clone, Debug)]
46pub struct GetPlayerByIdParams {
47    /// The unique identifier of the player.
48    pub player_id: String
49}
50
51/// struct for passing parameters to the method [`list_player_friend_requests`]
52#[derive(Clone, Debug)]
53pub struct ListPlayerFriendRequestsParams {
54    /// The unique identifier of the player.
55    pub player_id: String,
56    /// The maximum number of friend requests to return.
57    pub limit: Option<u8>,
58    /// The cursor returned by the previous request.
59    pub cursor: Option<String>,
60    /// The unique identifier of the sender used to filter friend requests.
61    pub sender_id: Option<String>
62}
63
64/// struct for passing parameters to the method [`list_player_friends`]
65#[derive(Clone, Debug)]
66pub struct ListPlayerFriendsParams {
67    /// The unique identifier of the player.
68    pub player_id: String,
69    /// The maximum number of friends to return.
70    pub limit: Option<u8>,
71    /// The cursor returned by the previous request.
72    pub cursor: Option<String>,
73    /// The unique identifier of the friend used to filter friendships.
74    pub friend_id: Option<String>
75}
76
77/// struct for passing parameters to the method [`list_players`]
78#[derive(Clone, Debug)]
79pub struct ListPlayersParams {
80    /// The maximum number of players to return.
81    pub limit: Option<u8>,
82    /// The cursor returned by the previous request.
83    pub cursor: Option<String>,
84    /// The username used to filter players.
85    pub username: Option<String>,
86    /// The Discord user ID used to filter players. Requires the `players:read-details` scope.
87    pub discord_id: Option<String>,
88    /// The online status used to filter players.
89    pub status: Option<String>
90}
91
92/// struct for passing parameters to the method [`reject_player_friend_request`]
93#[derive(Clone, Debug)]
94pub struct RejectPlayerFriendRequestParams {
95    /// The unique identifier of the player.
96    pub player_id: String,
97    /// The unique identifier of the player sending the friend request.
98    pub sender_id: String
99}
100
101/// struct for passing parameters to the method [`remove_player_friend`]
102#[derive(Clone, Debug)]
103pub struct RemovePlayerFriendParams {
104    /// The unique identifier of the player.
105    pub player_id: String,
106    /// The unique identifier of the friend player.
107    pub friend_id: String
108}
109
110/// struct for passing parameters to the method [`remove_player_friend_request`]
111#[derive(Clone, Debug)]
112pub struct RemovePlayerFriendRequestParams {
113    /// The unique identifier of the player.
114    pub player_id: String,
115    /// The unique identifier of the player sending the friend request.
116    pub sender_id: String
117}
118
119/// struct for passing parameters to the method [`update_player_by_id`]
120#[derive(Clone, Debug)]
121pub struct UpdatePlayerByIdParams {
122    /// The unique identifier of the player.
123    pub player_id: String,
124    pub update_player_by_id_request: models::UpdatePlayerByIdRequest
125}
126
127
128/// struct for typed errors of method [`accept_player_friend_request`]
129#[derive(Debug, Clone, Serialize, Deserialize)]
130#[serde(untagged)]
131pub enum AcceptPlayerFriendRequestError {
132    Status401(),
133    Status403(),
134    Status404(),
135    Status409(),
136    UnknownValue(serde_json::Value),
137}
138
139/// struct for typed errors of method [`add_player_friend`]
140#[derive(Debug, Clone, Serialize, Deserialize)]
141#[serde(untagged)]
142pub enum AddPlayerFriendError {
143    Status400(),
144    Status401(),
145    Status403(),
146    Status404(),
147    Status409(),
148    UnknownValue(serde_json::Value),
149}
150
151/// struct for typed errors of method [`add_player_friend_request`]
152#[derive(Debug, Clone, Serialize, Deserialize)]
153#[serde(untagged)]
154pub enum AddPlayerFriendRequestError {
155    Status401(),
156    Status403(),
157    Status404(),
158    Status409(),
159    UnknownValue(serde_json::Value),
160}
161
162/// struct for typed errors of method [`get_player_by_id`]
163#[derive(Debug, Clone, Serialize, Deserialize)]
164#[serde(untagged)]
165pub enum GetPlayerByIdError {
166    Status401(),
167    Status403(),
168    Status404(),
169    UnknownValue(serde_json::Value),
170}
171
172/// struct for typed errors of method [`list_player_friend_requests`]
173#[derive(Debug, Clone, Serialize, Deserialize)]
174#[serde(untagged)]
175pub enum ListPlayerFriendRequestsError {
176    Status400(),
177    Status401(),
178    Status403(),
179    Status404(),
180    UnknownValue(serde_json::Value),
181}
182
183/// struct for typed errors of method [`list_player_friends`]
184#[derive(Debug, Clone, Serialize, Deserialize)]
185#[serde(untagged)]
186pub enum ListPlayerFriendsError {
187    Status400(),
188    Status401(),
189    Status403(),
190    Status404(),
191    UnknownValue(serde_json::Value),
192}
193
194/// struct for typed errors of method [`list_players`]
195#[derive(Debug, Clone, Serialize, Deserialize)]
196#[serde(untagged)]
197pub enum ListPlayersError {
198    Status400(),
199    Status401(),
200    Status403(),
201    UnknownValue(serde_json::Value),
202}
203
204/// struct for typed errors of method [`reject_player_friend_request`]
205#[derive(Debug, Clone, Serialize, Deserialize)]
206#[serde(untagged)]
207pub enum RejectPlayerFriendRequestError {
208    Status401(),
209    Status403(),
210    Status404(),
211    UnknownValue(serde_json::Value),
212}
213
214/// struct for typed errors of method [`remove_player_friend`]
215#[derive(Debug, Clone, Serialize, Deserialize)]
216#[serde(untagged)]
217pub enum RemovePlayerFriendError {
218    Status400(),
219    Status401(),
220    Status403(),
221    Status404(),
222    UnknownValue(serde_json::Value),
223}
224
225/// struct for typed errors of method [`remove_player_friend_request`]
226#[derive(Debug, Clone, Serialize, Deserialize)]
227#[serde(untagged)]
228pub enum RemovePlayerFriendRequestError {
229    Status401(),
230    Status403(),
231    Status404(),
232    UnknownValue(serde_json::Value),
233}
234
235/// struct for typed errors of method [`update_player_by_id`]
236#[derive(Debug, Clone, Serialize, Deserialize)]
237#[serde(untagged)]
238pub enum UpdatePlayerByIdError {
239    Status400(),
240    Status401(),
241    Status403(),
242    Status404(),
243    UnknownValue(serde_json::Value),
244}
245
246
247/// Accepts the specified sender's friend request and adds the sender to the player's friends.
248pub async fn accept_player_friend_request(configuration: &configuration::Configuration, params: AcceptPlayerFriendRequestParams) -> Result<(), Error<AcceptPlayerFriendRequestError>> {
249
250    let uri_str = format!("{}/players/{playerId}/friend-requests/{senderId}/accept", configuration.base_path, playerId=crate::apis::urlencode(params.player_id), senderId=crate::apis::urlencode(params.sender_id));
251    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
252
253    if let Some(ref user_agent) = configuration.user_agent {
254        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
255    }
256    if let Some(ref token) = configuration.bearer_access_token {
257        req_builder = req_builder.bearer_auth(token.to_owned());
258    };
259
260    let req = req_builder.build()?;
261    let resp = configuration.client.execute(req).await?;
262
263    let status = resp.status();
264
265    if !status.is_client_error() && !status.is_server_error() {
266        Ok(())
267    } else {
268        let content = resp.text().await?;
269        let entity: Option<AcceptPlayerFriendRequestError> = serde_json::from_str(&content).ok();
270        Err(Error::ResponseError(ResponseContent { status, content, entity }))
271    }
272}
273
274/// Adds the specified friend to the player's friends.
275pub async fn add_player_friend(configuration: &configuration::Configuration, params: AddPlayerFriendParams) -> Result<models::Player, Error<AddPlayerFriendError>> {
276
277    let uri_str = format!("{}/players/{playerId}/friends/{friendId}", configuration.base_path, playerId=crate::apis::urlencode(params.player_id), friendId=crate::apis::urlencode(params.friend_id));
278    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
279
280    if let Some(ref user_agent) = configuration.user_agent {
281        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
282    }
283    if let Some(ref token) = configuration.bearer_access_token {
284        req_builder = req_builder.bearer_auth(token.to_owned());
285    };
286
287    let req = req_builder.build()?;
288    let resp = configuration.client.execute(req).await?;
289
290    let status = resp.status();
291    let content_type = resp
292        .headers()
293        .get("content-type")
294        .and_then(|v| v.to_str().ok())
295        .unwrap_or("application/octet-stream");
296    let content_type = super::ContentType::from(content_type);
297
298    if !status.is_client_error() && !status.is_server_error() {
299        let content = resp.text().await?;
300        match content_type {
301            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
302            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Player`"))),
303            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Player`")))),
304        }
305    } else {
306        let content = resp.text().await?;
307        let entity: Option<AddPlayerFriendError> = serde_json::from_str(&content).ok();
308        Err(Error::ResponseError(ResponseContent { status, content, entity }))
309    }
310}
311
312/// Adds a friend request from the specified sender to the player's friend requests.
313pub async fn add_player_friend_request(configuration: &configuration::Configuration, params: AddPlayerFriendRequestParams) -> Result<(), Error<AddPlayerFriendRequestError>> {
314
315    let uri_str = format!("{}/players/{playerId}/friend-requests/{senderId}", configuration.base_path, playerId=crate::apis::urlencode(params.player_id), senderId=crate::apis::urlencode(params.sender_id));
316    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
317
318    if let Some(ref user_agent) = configuration.user_agent {
319        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
320    }
321    if let Some(ref token) = configuration.bearer_access_token {
322        req_builder = req_builder.bearer_auth(token.to_owned());
323    };
324
325    let req = req_builder.build()?;
326    let resp = configuration.client.execute(req).await?;
327
328    let status = resp.status();
329
330    if !status.is_client_error() && !status.is_server_error() {
331        Ok(())
332    } else {
333        let content = resp.text().await?;
334        let entity: Option<AddPlayerFriendRequestError> = serde_json::from_str(&content).ok();
335        Err(Error::ResponseError(ResponseContent { status, content, entity }))
336    }
337}
338
339/// Returns the player with the specified ID. The `discordId` field is `null` unless the API key has the `players:read-details` scope. 
340pub async fn get_player_by_id(configuration: &configuration::Configuration, params: GetPlayerByIdParams) -> Result<models::Player, Error<GetPlayerByIdError>> {
341
342    let uri_str = format!("{}/players/{playerId}", configuration.base_path, playerId=crate::apis::urlencode(params.player_id));
343    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
344
345    if let Some(ref user_agent) = configuration.user_agent {
346        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
347    }
348    if let Some(ref token) = configuration.bearer_access_token {
349        req_builder = req_builder.bearer_auth(token.to_owned());
350    };
351
352    let req = req_builder.build()?;
353    let resp = configuration.client.execute(req).await?;
354
355    let status = resp.status();
356    let content_type = resp
357        .headers()
358        .get("content-type")
359        .and_then(|v| v.to_str().ok())
360        .unwrap_or("application/octet-stream");
361    let content_type = super::ContentType::from(content_type);
362
363    if !status.is_client_error() && !status.is_server_error() {
364        let content = resp.text().await?;
365        match content_type {
366            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
367            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Player`"))),
368            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Player`")))),
369        }
370    } else {
371        let content = resp.text().await?;
372        let entity: Option<GetPlayerByIdError> = serde_json::from_str(&content).ok();
373        Err(Error::ResponseError(ResponseContent { status, content, entity }))
374    }
375}
376
377/// Returns a list of friend requests received by the specified player.
378pub async fn list_player_friend_requests(configuration: &configuration::Configuration, params: ListPlayerFriendRequestsParams) -> Result<models::ListPlayers200Response, Error<ListPlayerFriendRequestsError>> {
379
380    let uri_str = format!("{}/players/{playerId}/friend-requests", configuration.base_path, playerId=crate::apis::urlencode(params.player_id));
381    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
382
383    if let Some(ref param_value) = params.limit {
384        req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
385    }
386    if let Some(ref param_value) = params.cursor {
387        req_builder = req_builder.query(&[("cursor", &param_value.to_string())]);
388    }
389    if let Some(ref param_value) = params.sender_id {
390        req_builder = req_builder.query(&[("senderId", &param_value.to_string())]);
391    }
392    if let Some(ref user_agent) = configuration.user_agent {
393        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
394    }
395    if let Some(ref token) = configuration.bearer_access_token {
396        req_builder = req_builder.bearer_auth(token.to_owned());
397    };
398
399    let req = req_builder.build()?;
400    let resp = configuration.client.execute(req).await?;
401
402    let status = resp.status();
403    let content_type = resp
404        .headers()
405        .get("content-type")
406        .and_then(|v| v.to_str().ok())
407        .unwrap_or("application/octet-stream");
408    let content_type = super::ContentType::from(content_type);
409
410    if !status.is_client_error() && !status.is_server_error() {
411        let content = resp.text().await?;
412        match content_type {
413            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
414            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListPlayers200Response`"))),
415            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ListPlayers200Response`")))),
416        }
417    } else {
418        let content = resp.text().await?;
419        let entity: Option<ListPlayerFriendRequestsError> = serde_json::from_str(&content).ok();
420        Err(Error::ResponseError(ResponseContent { status, content, entity }))
421    }
422}
423
424/// Returns a list of friends of the specified player.
425pub async fn list_player_friends(configuration: &configuration::Configuration, params: ListPlayerFriendsParams) -> Result<models::ListPlayers200Response, Error<ListPlayerFriendsError>> {
426
427    let uri_str = format!("{}/players/{playerId}/friends", configuration.base_path, playerId=crate::apis::urlencode(params.player_id));
428    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
429
430    if let Some(ref param_value) = params.limit {
431        req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
432    }
433    if let Some(ref param_value) = params.cursor {
434        req_builder = req_builder.query(&[("cursor", &param_value.to_string())]);
435    }
436    if let Some(ref param_value) = params.friend_id {
437        req_builder = req_builder.query(&[("friendId", &param_value.to_string())]);
438    }
439    if let Some(ref user_agent) = configuration.user_agent {
440        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
441    }
442    if let Some(ref token) = configuration.bearer_access_token {
443        req_builder = req_builder.bearer_auth(token.to_owned());
444    };
445
446    let req = req_builder.build()?;
447    let resp = configuration.client.execute(req).await?;
448
449    let status = resp.status();
450    let content_type = resp
451        .headers()
452        .get("content-type")
453        .and_then(|v| v.to_str().ok())
454        .unwrap_or("application/octet-stream");
455    let content_type = super::ContentType::from(content_type);
456
457    if !status.is_client_error() && !status.is_server_error() {
458        let content = resp.text().await?;
459        match content_type {
460            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
461            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListPlayers200Response`"))),
462            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ListPlayers200Response`")))),
463        }
464    } else {
465        let content = resp.text().await?;
466        let entity: Option<ListPlayerFriendsError> = serde_json::from_str(&content).ok();
467        Err(Error::ResponseError(ResponseContent { status, content, entity }))
468    }
469}
470
471/// Returns a list of players. The `discordId` field is `null` unless the API key has the `players:read-details` scope. 
472pub async fn list_players(configuration: &configuration::Configuration, params: ListPlayersParams) -> Result<models::ListPlayers200Response, Error<ListPlayersError>> {
473
474    let uri_str = format!("{}/players", configuration.base_path);
475    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
476
477    if let Some(ref param_value) = params.limit {
478        req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
479    }
480    if let Some(ref param_value) = params.cursor {
481        req_builder = req_builder.query(&[("cursor", &param_value.to_string())]);
482    }
483    if let Some(ref param_value) = params.username {
484        req_builder = req_builder.query(&[("username", &param_value.to_string())]);
485    }
486    if let Some(ref param_value) = params.discord_id {
487        req_builder = req_builder.query(&[("discordId", &param_value.to_string())]);
488    }
489    if let Some(ref param_value) = params.status {
490        req_builder = req_builder.query(&[("status", &param_value.to_string())]);
491    }
492    if let Some(ref user_agent) = configuration.user_agent {
493        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
494    }
495    if let Some(ref token) = configuration.bearer_access_token {
496        req_builder = req_builder.bearer_auth(token.to_owned());
497    };
498
499    let req = req_builder.build()?;
500    let resp = configuration.client.execute(req).await?;
501
502    let status = resp.status();
503    let content_type = resp
504        .headers()
505        .get("content-type")
506        .and_then(|v| v.to_str().ok())
507        .unwrap_or("application/octet-stream");
508    let content_type = super::ContentType::from(content_type);
509
510    if !status.is_client_error() && !status.is_server_error() {
511        let content = resp.text().await?;
512        match content_type {
513            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
514            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListPlayers200Response`"))),
515            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ListPlayers200Response`")))),
516        }
517    } else {
518        let content = resp.text().await?;
519        let entity: Option<ListPlayersError> = serde_json::from_str(&content).ok();
520        Err(Error::ResponseError(ResponseContent { status, content, entity }))
521    }
522}
523
524/// Rejects the specified sender's friend request and removes it from the player's friend requests.
525pub async fn reject_player_friend_request(configuration: &configuration::Configuration, params: RejectPlayerFriendRequestParams) -> Result<(), Error<RejectPlayerFriendRequestError>> {
526
527    let uri_str = format!("{}/players/{playerId}/friend-requests/{senderId}/reject", configuration.base_path, playerId=crate::apis::urlencode(params.player_id), senderId=crate::apis::urlencode(params.sender_id));
528    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
529
530    if let Some(ref user_agent) = configuration.user_agent {
531        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
532    }
533    if let Some(ref token) = configuration.bearer_access_token {
534        req_builder = req_builder.bearer_auth(token.to_owned());
535    };
536
537    let req = req_builder.build()?;
538    let resp = configuration.client.execute(req).await?;
539
540    let status = resp.status();
541
542    if !status.is_client_error() && !status.is_server_error() {
543        Ok(())
544    } else {
545        let content = resp.text().await?;
546        let entity: Option<RejectPlayerFriendRequestError> = serde_json::from_str(&content).ok();
547        Err(Error::ResponseError(ResponseContent { status, content, entity }))
548    }
549}
550
551/// Removes the specified friend from the player's friends.
552pub async fn remove_player_friend(configuration: &configuration::Configuration, params: RemovePlayerFriendParams) -> Result<(), Error<RemovePlayerFriendError>> {
553
554    let uri_str = format!("{}/players/{playerId}/friends/{friendId}", configuration.base_path, playerId=crate::apis::urlencode(params.player_id), friendId=crate::apis::urlencode(params.friend_id));
555    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
556
557    if let Some(ref user_agent) = configuration.user_agent {
558        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
559    }
560    if let Some(ref token) = configuration.bearer_access_token {
561        req_builder = req_builder.bearer_auth(token.to_owned());
562    };
563
564    let req = req_builder.build()?;
565    let resp = configuration.client.execute(req).await?;
566
567    let status = resp.status();
568
569    if !status.is_client_error() && !status.is_server_error() {
570        Ok(())
571    } else {
572        let content = resp.text().await?;
573        let entity: Option<RemovePlayerFriendError> = serde_json::from_str(&content).ok();
574        Err(Error::ResponseError(ResponseContent { status, content, entity }))
575    }
576}
577
578/// Removes the specified sender's friend request from the player's friend requests.
579pub async fn remove_player_friend_request(configuration: &configuration::Configuration, params: RemovePlayerFriendRequestParams) -> Result<(), Error<RemovePlayerFriendRequestError>> {
580
581    let uri_str = format!("{}/players/{playerId}/friend-requests/{senderId}", configuration.base_path, playerId=crate::apis::urlencode(params.player_id), senderId=crate::apis::urlencode(params.sender_id));
582    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
583
584    if let Some(ref user_agent) = configuration.user_agent {
585        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
586    }
587    if let Some(ref token) = configuration.bearer_access_token {
588        req_builder = req_builder.bearer_auth(token.to_owned());
589    };
590
591    let req = req_builder.build()?;
592    let resp = configuration.client.execute(req).await?;
593
594    let status = resp.status();
595
596    if !status.is_client_error() && !status.is_server_error() {
597        Ok(())
598    } else {
599        let content = resp.text().await?;
600        let entity: Option<RemovePlayerFriendRequestError> = serde_json::from_str(&content).ok();
601        Err(Error::ResponseError(ResponseContent { status, content, entity }))
602    }
603}
604
605/// Updates the player with the specified ID.
606pub async fn update_player_by_id(configuration: &configuration::Configuration, params: UpdatePlayerByIdParams) -> Result<models::Player, Error<UpdatePlayerByIdError>> {
607
608    let uri_str = format!("{}/players/{playerId}", configuration.base_path, playerId=crate::apis::urlencode(params.player_id));
609    let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
610
611    if let Some(ref user_agent) = configuration.user_agent {
612        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
613    }
614    if let Some(ref token) = configuration.bearer_access_token {
615        req_builder = req_builder.bearer_auth(token.to_owned());
616    };
617    req_builder = req_builder.json(&params.update_player_by_id_request);
618
619    let req = req_builder.build()?;
620    let resp = configuration.client.execute(req).await?;
621
622    let status = resp.status();
623    let content_type = resp
624        .headers()
625        .get("content-type")
626        .and_then(|v| v.to_str().ok())
627        .unwrap_or("application/octet-stream");
628    let content_type = super::ContentType::from(content_type);
629
630    if !status.is_client_error() && !status.is_server_error() {
631        let content = resp.text().await?;
632        match content_type {
633            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
634            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Player`"))),
635            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Player`")))),
636        }
637    } else {
638        let content = resp.text().await?;
639        let entity: Option<UpdatePlayerByIdError> = serde_json::from_str(&content).ok();
640        Err(Error::ResponseError(ResponseContent { status, content, entity }))
641    }
642}
643