clerk_rs/models/
session.rs1#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
12pub struct Session {
13 #[serde(rename = "object")]
15 pub object: Object,
16 #[serde(rename = "id")]
17 pub id: String,
18 #[serde(rename = "user_id")]
19 pub user_id: String,
20 #[serde(rename = "client_id")]
21 pub client_id: String,
22 #[serde(
23 rename = "actor",
24 default,
25 with = "::serde_with::rust::double_option",
26 skip_serializing_if = "Option::is_none"
27 )]
28 pub actor: Option<Option<serde_json::Value>>,
29 #[serde(rename = "status")]
30 pub status: Status,
31 #[serde(
32 rename = "last_active_organization_id",
33 default,
34 with = "::serde_with::rust::double_option",
35 skip_serializing_if = "Option::is_none"
36 )]
37 pub last_active_organization_id: Option<Option<String>>,
38 #[serde(rename = "last_active_at")]
39 pub last_active_at: i64,
40 #[serde(rename = "expire_at")]
41 pub expire_at: i64,
42 #[serde(rename = "abandon_at")]
43 pub abandon_at: i64,
44 #[serde(rename = "updated_at")]
46 pub updated_at: i64,
47 #[serde(rename = "created_at")]
49 pub created_at: i64,
50}
51
52impl Session {
53 pub fn new(
54 object: Object,
55 id: String,
56 user_id: String,
57 client_id: String,
58 status: Status,
59 last_active_at: i64,
60 expire_at: i64,
61 abandon_at: i64,
62 updated_at: i64,
63 created_at: i64,
64 ) -> Session {
65 Session {
66 object,
67 id,
68 user_id,
69 client_id,
70 actor: None,
71 status,
72 last_active_organization_id: None,
73 last_active_at,
74 expire_at,
75 abandon_at,
76 updated_at,
77 created_at,
78 }
79 }
80}
81
82#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
84pub enum Object {
85 #[serde(rename = "session")]
86 Session,
87}
88
89impl Default for Object {
90 fn default() -> Object {
91 Self::Session
92 }
93}
94#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
96pub enum Status {
97 #[serde(rename = "active")]
98 Active,
99 #[serde(rename = "revoked")]
100 Revoked,
101 #[serde(rename = "ended")]
102 Ended,
103 #[serde(rename = "expired")]
104 Expired,
105 #[serde(rename = "removed")]
106 Removed,
107 #[serde(rename = "abandoned")]
108 Abandoned,
109 #[serde(rename = "replaced")]
110 Replaced,
111}
112
113impl Default for Status {
114 fn default() -> Status {
115 Self::Active
116 }
117}