Skip to main content

fizzy_sdk/generated/services/
sessions.rs

1// Generated by fizzy-sdk-generator from openapi.json and behavior-model.json. DO NOT EDIT.
2
3use crate::client::Scope;
4use crate::error::Error;
5use crate::generated::routes;
6use crate::generated::types::*;
7
8/// The `Sessions` operations.
9pub struct SessionsService<'a> {
10    scope: Scope<'a>,
11}
12
13impl<'a> SessionsService<'a> {
14    pub(crate) fn new(scope: Scope<'a>) -> Self {
15        Self { scope }
16    }
17
18    /// The client and account these operations send through.
19    pub fn scope(&self) -> &Scope<'a> {
20        &self.scope
21    }
22
23    /// `CompleteJoin` — `POST /users/joins.json`.
24    ///
25    /// Sent once and never resent.
26    pub async fn complete_join(&self, body: &CompleteJoinRequestContent) -> Result<(), Error> {
27        let mut operation = self.scope.operation(&routes::COMPLETE_JOIN, &[])?;
28        operation.json(body)?;
29        self.scope.client().send_unit(operation).await
30    }
31
32    /// `CompleteSignup` — `POST /signup/completion.json`.
33    ///
34    /// Sent once and never resent.
35    pub async fn complete_signup(&self, body: &CompleteSignupRequestContent) -> Result<(), Error> {
36        let mut operation = self.scope.operation(&routes::COMPLETE_SIGNUP, &[])?;
37        operation.json(body)?;
38        self.scope.client().send_unit(operation).await
39    }
40
41    /// `CreateSession` — `POST /session.json`.
42    ///
43    /// Sent once and never resent.
44    pub async fn create(
45        &self,
46        body: &CreateSessionRequestContent,
47    ) -> Result<PendingAuthentication, Error> {
48        let mut operation = self.scope.operation(&routes::CREATE_SESSION, &[])?;
49        operation.json(body)?;
50        self.scope.client().send(operation).await
51    }
52
53    /// `DestroySession` — `DELETE /session.json`.
54    ///
55    /// Sent once and never resent.
56    pub async fn destroy(&self) -> Result<(), Error> {
57        let operation = self.scope.operation(&routes::DESTROY_SESSION, &[])?;
58        self.scope.client().send_unit(operation).await
59    }
60
61    /// `RedeemMagicLink` — `POST /session/magic_link.json`.
62    ///
63    /// Sent once and never resent.
64    pub async fn redeem_magic_link(
65        &self,
66        body: &RedeemMagicLinkRequestContent,
67    ) -> Result<SessionAuthorization, Error> {
68        let mut operation = self.scope.operation(&routes::REDEEM_MAGIC_LINK, &[])?;
69        operation.json(body)?;
70        self.scope.client().send(operation).await
71    }
72}