clerk_fapi_rs/models/
client_client.rs

1/*
2 * Clerk Frontend API
3 *
4 * The Clerk REST Frontend API, meant to be accessed from a browser or native environment.  This is a Form Based API and all the data must be sent and formatted according to the `application/x-www-form-urlencoded` content type.  ### Versions  When the API changes in a way that isn't compatible with older versions, a new version is released. Each version is identified by its release date, e.g. `2021-02-05`. For more information, please see [Clerk API Versions](https://clerk.com/docs/backend-requests/versioning/overview).  ### Using the Try It Console  The `Try It` feature of the docs only works for **Development Instances** when using the `DevBrowser` security scheme. To use it, first generate a dev instance token from the `/v1/dev_browser` endpoint.  Please see https://clerk.com/docs for more information.
5 *
6 * The version of the OpenAPI document: v1
7 * Contact: support@clerk.com
8 * Generated by: https://openapi-generator.tech
9 */
10
11use crate::models;
12use serde::{Deserialize, Serialize};
13
14#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
15pub struct ClientClient {
16    /// String representing the object's type. Objects of the same type share the same value.
17    #[serde(rename = "object")]
18    pub object: Object,
19    /// String representing the identifier of the session.
20    #[serde(rename = "id")]
21    pub id: String,
22    #[serde(rename = "sessions")]
23    pub sessions: Vec<models::ClientSession>,
24    #[serde(rename = "sign_in", deserialize_with = "Option::deserialize")]
25    pub sign_in: Option<Box<models::ClientSignIn>>,
26    #[serde(rename = "sign_up", deserialize_with = "Option::deserialize")]
27    pub sign_up: Option<Box<models::ClientSignUp>>,
28    /// Last active session_id.
29    #[serde(
30        rename = "last_active_session_id",
31        deserialize_with = "Option::deserialize"
32    )]
33    pub last_active_session_id: Option<String>,
34    /// Unix timestamp of the cookie expiration.
35    #[serde(rename = "cookie_expires_at", deserialize_with = "Option::deserialize")]
36    pub cookie_expires_at: Option<i64>,
37    /// Whether the client can bypass CAPTCHA.
38    #[serde(rename = "captcha_bypass")]
39    pub captcha_bypass: bool,
40    /// Unix timestamp of creation.
41    #[serde(rename = "created_at")]
42    pub created_at: i64,
43    /// Unix timestamp of last update.
44    #[serde(rename = "updated_at")]
45    pub updated_at: i64,
46}
47
48impl ClientClient {
49    pub fn new(
50        object: Object,
51        id: String,
52        sessions: Vec<models::ClientSession>,
53        sign_in: Option<models::ClientSignIn>,
54        sign_up: Option<models::ClientSignUp>,
55        last_active_session_id: Option<String>,
56        cookie_expires_at: Option<i64>,
57        captcha_bypass: bool,
58        created_at: i64,
59        updated_at: i64,
60    ) -> ClientClient {
61        ClientClient {
62            object,
63            id,
64            sessions,
65            sign_in: sign_in.map(Box::new),
66            sign_up: sign_up.map(Box::new),
67            last_active_session_id,
68            cookie_expires_at,
69            captcha_bypass,
70            created_at,
71            updated_at,
72        }
73    }
74}
75
76impl From<models::schemas_client_client::SchemasClientClient> for ClientClient {
77    fn from(value: models::schemas_client_client::SchemasClientClient) -> Self {
78        ClientClient {
79            object: Object::Client,
80            id: value.id,
81            sessions: value.sessions.into_iter().map(|s| s.into()).collect(),
82            sign_in: value.sign_in,
83            sign_up: value.sign_up,
84            last_active_session_id: value.last_active_session_id,
85            cookie_expires_at: value.cookie_expires_at,
86            captcha_bypass: value.captcha_bypass,
87            created_at: value.created_at,
88            updated_at: value.updated_at,
89        }
90    }
91}
92
93/// String representing the object's type. Objects of the same type share the same value.
94#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
95pub enum Object {
96    #[serde(rename = "client")]
97    Client,
98}
99
100impl From<models::schemas_client_client::Object> for Object {
101    fn from(value: models::schemas_client_client::Object) -> Self {
102        match value {
103            models::schemas_client_client::Object::Client => Object::Client,
104        }
105    }
106}
107
108impl Default for Object {
109    fn default() -> Object {
110        Self::Client
111    }
112}