svix_webhook_with_clone/api/
authentication.rs

1use super::PostOptions;
2use crate::{apis::authentication_api, error::Result, models::*, Configuration};
3
4pub struct Authentication<'a> {
5    cfg: &'a Configuration,
6}
7
8impl<'a> Authentication<'a> {
9    pub(super) fn new(cfg: &'a Configuration) -> Self {
10        Self { cfg }
11    }
12
13    pub async fn dashboard_access(
14        &self,
15        app_id: String,
16        options: Option<PostOptions>,
17    ) -> Result<DashboardAccessOut> {
18        let options = options.unwrap_or_default();
19        authentication_api::v1_period_authentication_period_dashboard_access(
20            self.cfg,
21            authentication_api::V1PeriodAuthenticationPeriodDashboardAccessParams {
22                app_id,
23                idempotency_key: options.idempotency_key,
24            },
25        )
26        .await
27    }
28
29    /// Use this function to get magic links (and authentication codes) for
30    /// connecting your users to the Consumer Application Portal.
31    pub async fn app_portal_access(
32        &self,
33        app_id: String,
34        app_portal_access_in: AppPortalAccessIn,
35        options: Option<PostOptions>,
36    ) -> Result<AppPortalAccessOut> {
37        let PostOptions { idempotency_key } = options.unwrap_or_default();
38
39        authentication_api::v1_period_authentication_period_app_portal_access(
40            self.cfg,
41            authentication_api::V1PeriodAuthenticationPeriodAppPortalAccessParams {
42                app_id,
43                app_portal_access_in,
44                idempotency_key,
45            },
46        )
47        .await
48    }
49
50    /// Logout an app token.
51    ///
52    /// Trying to log out other tokens will fail.
53    pub async fn logout(&self, options: Option<PostOptions>) -> Result<()> {
54        let PostOptions { idempotency_key } = options.unwrap_or_default();
55
56        authentication_api::v1_period_authentication_period_logout(
57            self.cfg,
58            authentication_api::V1PeriodAuthenticationPeriodLogoutParams { idempotency_key },
59        )
60        .await
61    }
62}