android_sms_gateway/types/
auth.rs1use chrono::{DateTime, Utc};
2use serde::{Deserialize, Serialize};
3
4#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
9#[serde(transparent)]
10pub struct JwtScope(pub String);
11
12impl JwtScope {
13 pub const DEVICES_LIST: &'static str = "devices:list";
14 pub const DEVICES_DELETE: &'static str = "devices:delete";
15 pub const INBOX_LIST: &'static str = "inbox:list";
16 pub const INBOX_REFRESH: &'static str = "inbox:refresh";
17 pub const LOGS_READ: &'static str = "logs:read";
18 pub const MESSAGES_CANCEL: &'static str = "messages:cancel";
19 pub const MESSAGES_SEND: &'static str = "messages:send";
20 pub const MESSAGES_READ: &'static str = "messages:read";
21 pub const MESSAGES_LIST: &'static str = "messages:list";
22 pub const MESSAGES_EXPORT: &'static str = "messages:export";
23 pub const SETTINGS_READ: &'static str = "settings:read";
24 pub const SETTINGS_WRITE: &'static str = "settings:write";
25 pub const TOKENS_MANAGE: &'static str = "tokens:manage";
26 pub const WEBHOOKS_LIST: &'static str = "webhooks:list";
27 pub const WEBHOOKS_WRITE: &'static str = "webhooks:write";
28 pub const WEBHOOKS_DELETE: &'static str = "webhooks:delete";
29
30 pub fn new(s: impl Into<String>) -> Self {
32 Self(s.into())
33 }
34
35 pub fn as_str(&self) -> &str {
37 &self.0
38 }
39}
40
41#[derive(Debug, Clone, Serialize, Deserialize)]
43#[serde(rename_all = "camelCase")]
44pub struct TokenRequest {
45 #[serde(default, skip_serializing_if = "Option::is_none")]
47 pub ttl: Option<u64>,
48 #[serde(default)]
50 pub scopes: Vec<JwtScope>,
51}
52
53#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(rename_all = "camelCase")]
56pub struct TokenResponse {
57 pub id: String,
59 pub token_type: String,
61 pub access_token: String,
63 #[serde(default, skip_serializing_if = "Option::is_none")]
65 pub refresh_token: Option<String>,
66 pub expires_at: DateTime<Utc>,
68}