roblox_api/api/user_agreements/
v1.rs1use serde::{Deserialize, Serialize};
2
3use crate::{Error, client::Client};
4
5pub const URL: &str = "https://apis.roblox.com/user-agreements/v1";
6
7#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
8#[serde(rename_all = "camelCase")]
9pub struct AcceptanceResponse {
10 #[serde(rename = "agreementId")]
11 pub id: String,
12 pub message: String,
13 pub error_code: u16,
14}
15
16pub async fn acceptances(
17 client: &mut Client,
18 ids: &[&str],
19) -> Result<Vec<AcceptanceResponse>, Error> {
20 #[derive(Debug, Serialize)]
21 struct Agreement<'a> {
22 #[serde(rename = "agreementId")]
23 id: &'a str,
24 }
25
26 #[derive(Debug, Serialize)]
27 struct Request<'a> {
28 acceptances: &'a [Agreement<'a>],
29 }
30
31 let acceptances = ids.iter().map(|x| Agreement { id: x }).collect::<Vec<_>>();
32
33 let result = client
34 .requestor
35 .client
36 .post(format!("{URL}/acceptances"))
37 .json(&Request {
38 acceptances: &acceptances,
39 })
40 .headers(client.requestor.default_headers.clone())
41 .send()
42 .await;
43
44 #[derive(Debug, Deserialize)]
45 struct Response {
46 results: Vec<AcceptanceResponse>,
47 }
48
49 let response = client.requestor.validate_response(result).await?;
50 Ok(client
51 .requestor
52 .parse_json::<Response>(response)
53 .await?
54 .results)
55}