idkollen_client/models/
age_verification.rs1use serde::{Deserialize, Serialize};
2
3use super::common::ApiErrorCode;
4use super::url::Url;
5
6#[must_use]
11#[derive(Debug, Clone, Default, Serialize)]
12#[serde(rename_all = "camelCase")]
13pub struct AgeVerificationRequest {
14 #[serde(skip_serializing_if = "Option::is_none")]
16 pub min_age: Option<u32>,
17 #[serde(skip_serializing_if = "Option::is_none")]
19 pub max_age: Option<u32>,
20 #[serde(skip_serializing_if = "Option::is_none")]
22 pub ref_id: Option<String>,
23 #[serde(skip_serializing_if = "Option::is_none")]
25 pub callback_url: Option<Url>,
26 #[serde(skip_serializing_if = "Option::is_none")]
28 pub redirect_url: Option<Url>,
29}
30
31impl AgeVerificationRequest {
32 #[inline]
33 pub fn new() -> Self {
34 Self::default()
35 }
36
37 #[inline]
38 pub fn min_age(mut self, age: u32) -> Self {
39 self.min_age = Some(age);
40 self
41 }
42
43 #[inline]
44 pub fn max_age(mut self, age: u32) -> Self {
45 self.max_age = Some(age);
46 self
47 }
48
49 #[inline]
50 pub fn ref_id(mut self, ref_id: impl Into<String>) -> Self {
51 self.ref_id = Some(ref_id.into());
52 self
53 }
54
55 #[inline]
56 pub fn callback_url(mut self, url: Url) -> Self {
57 self.callback_url = Some(url);
58 self
59 }
60
61 #[inline]
62 pub fn redirect_url(mut self, url: Url) -> Self {
63 self.redirect_url = Some(url);
64 self
65 }
66}
67
68#[non_exhaustive]
70#[derive(Debug, Clone, Deserialize)]
71#[serde(tag = "status")]
72pub enum AgeVerificationStatus {
73 #[serde(rename = "PENDING")]
74 Pending(AgeVerificationPending),
75 #[serde(rename = "COMPLETED")]
76 Completed(AgeVerificationCompleted),
77 #[serde(rename = "FAILED")]
78 Failed(AgeVerificationFailed),
79}
80
81#[derive(Debug, Clone, Deserialize)]
83#[serde(rename_all = "camelCase")]
84pub struct AgeVerificationPending {
85 pub id: String,
86 pub url: Option<String>,
87 pub min_age: Option<u32>,
88 pub max_age: Option<u32>,
89}
90
91#[derive(Debug, Clone, Deserialize)]
93#[serde(rename_all = "camelCase")]
94pub struct AgeVerificationCompleted {
95 pub id: String,
96 pub age_verified: bool,
98}
99
100#[derive(Debug, Clone, Deserialize)]
102#[serde(rename_all = "camelCase")]
103pub struct AgeVerificationFailed {
104 pub id: String,
105 pub error: ApiErrorCode,
106}