fizzy_sdk/generated/services/
sessions.rs1use crate::client::Scope;
4use crate::error::Error;
5use crate::generated::routes;
6use crate::generated::types::*;
7
8pub 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 pub fn scope(&self) -> &Scope<'a> {
20 &self.scope
21 }
22
23 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 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 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 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 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}