fizzy-sdk 0.2.4

Official Fizzy API client, generated from the Smithy model in spec/
Documentation
// Generated by fizzy-sdk-generator from openapi.json and behavior-model.json. DO NOT EDIT.

use crate::client::Scope;
use crate::error::Error;
use crate::generated::routes;
use crate::generated::types::*;

/// The `Sessions` operations.
pub struct SessionsService<'a> {
    scope: Scope<'a>,
}

impl<'a> SessionsService<'a> {
    pub(crate) fn new(scope: Scope<'a>) -> Self {
        Self { scope }
    }

    /// The client and account these operations send through.
    pub fn scope(&self) -> &Scope<'a> {
        &self.scope
    }

    /// `CompleteJoin` — `POST /users/joins.json`.
    ///
    /// Sent once and never resent.
    pub async fn complete_join(&self, body: &CompleteJoinRequestContent) -> Result<(), Error> {
        let mut operation = self.scope.operation(&routes::COMPLETE_JOIN, &[])?;
        operation.json(body)?;
        self.scope.client().send_unit(operation).await
    }

    /// `CompleteSignup` — `POST /signup/completion.json`.
    ///
    /// Sent once and never resent.
    pub async fn complete_signup(&self, body: &CompleteSignupRequestContent) -> Result<(), Error> {
        let mut operation = self.scope.operation(&routes::COMPLETE_SIGNUP, &[])?;
        operation.json(body)?;
        self.scope.client().send_unit(operation).await
    }

    /// `CreateSession` — `POST /session.json`.
    ///
    /// Sent once and never resent.
    pub async fn create(
        &self,
        body: &CreateSessionRequestContent,
    ) -> Result<PendingAuthentication, Error> {
        let mut operation = self.scope.operation(&routes::CREATE_SESSION, &[])?;
        operation.json(body)?;
        self.scope.client().send(operation).await
    }

    /// `DestroySession` — `DELETE /session.json`.
    ///
    /// Sent once and never resent.
    pub async fn destroy(&self) -> Result<(), Error> {
        let operation = self.scope.operation(&routes::DESTROY_SESSION, &[])?;
        self.scope.client().send_unit(operation).await
    }

    /// `RedeemMagicLink` — `POST /session/magic_link.json`.
    ///
    /// Sent once and never resent.
    pub async fn redeem_magic_link(
        &self,
        body: &RedeemMagicLinkRequestContent,
    ) -> Result<SessionAuthorization, Error> {
        let mut operation = self.scope.operation(&routes::REDEEM_MAGIC_LINK, &[])?;
        operation.json(body)?;
        self.scope.client().send(operation).await
    }
}