Skip to main content

roblox_api/api/challenge/
v1.rs

1use serde::Serialize;
2
3use crate::{
4    challenge::{Challenge, ChallengeMetadataRequest},
5    endpoint,
6};
7
8pub const URL: &str = "https://apis.roblox.com/challenge/v1";
9
10endpoint! {
11    continue_challenge(challenge: &Challenge, verification_token: &str) -> () {
12        POST "{URL}/continue";
13        types {
14            Request<'a> {
15                id("challengeId"): &'a str,
16                kind("challengeType"): &'a str,
17                metadata("challengeMetadata"): &'a str,
18            }
19        }
20        prelude {
21            let metadata_json = serde_json::to_string(&ChallengeMetadataRequest {
22                verification_token: verification_token.to_string(),
23                challenge_id: challenge.metadata.server_challenge_id.clone(),
24                action_type: challenge.metadata.action_type,
25                remember_device: challenge.metadata.remember_device,
26            })
27            .unwrap();
28        }
29        body_serialize {
30            &Request {
31                id: &challenge.id,
32                kind: &challenge.kind.to_string(),
33                metadata: &metadata_json,
34            }
35        }
36    }
37}