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 `Steps` operations.
pub struct StepsService<'a> {
    scope: Scope<'a>,
}

impl<'a> StepsService<'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
    }

    /// `CreateStep` — `POST /{accountId}/cards/{cardNumber}/steps.json`.
    ///
    /// Sent once and never resent.
    pub async fn create(
        &self,
        card_number: i32,
        body: &CreateStepRequestContent,
    ) -> Result<Step, Error> {
        let mut operation = self
            .scope
            .operation(&routes::CREATE_STEP, &[&card_number])?;
        operation.resource_id(card_number);
        operation.json(body)?;
        self.scope.client().send(operation).await
    }

    /// `DeleteStep` — `DELETE /{accountId}/cards/{cardNumber}/steps/{stepId}`.
    ///
    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
    pub async fn delete(&self, card_number: i32, step_id: &str) -> Result<(), Error> {
        let mut operation = self
            .scope
            .operation(&routes::DELETE_STEP, &[&card_number, &step_id])?;
        operation.resource_id(step_id);
        self.scope.client().send_unit(operation).await
    }

    /// `GetStep` — `GET /{accountId}/cards/{cardNumber}/steps/{stepId}`.
    ///
    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
    pub async fn get(&self, card_number: i32, step_id: &str) -> Result<Step, Error> {
        let mut operation = self
            .scope
            .operation(&routes::GET_STEP, &[&card_number, &step_id])?;
        operation.resource_id(step_id);
        self.scope.client().send(operation).await
    }

    /// `ListSteps` — `GET /{accountId}/cards/{cardNumber}/steps.json`.
    ///
    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
    pub async fn list(&self, card_number: i32) -> Result<Vec<Step>, Error> {
        let mut operation = self.scope.operation(&routes::LIST_STEPS, &[&card_number])?;
        operation.resource_id(card_number);
        self.scope.client().send(operation).await
    }

    /// `UpdateStep` — `PATCH /{accountId}/cards/{cardNumber}/steps/{stepId}`.
    ///
    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
    pub async fn update(
        &self,
        card_number: i32,
        step_id: &str,
        body: &UpdateStepRequestContent,
    ) -> Result<Step, Error> {
        let mut operation = self
            .scope
            .operation(&routes::UPDATE_STEP, &[&card_number, &step_id])?;
        operation.resource_id(step_id);
        operation.json(body)?;
        self.scope.client().send(operation).await
    }
}