Skip to main content

fizzy_sdk/generated/services/
steps.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 `Steps` operations.
9pub struct StepsService<'a> {
10    scope: Scope<'a>,
11}
12
13impl<'a> StepsService<'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    /// `CreateStep` — `POST /{accountId}/cards/{cardNumber}/steps.json`.
24    ///
25    /// Sent once and never resent.
26    pub async fn create(
27        &self,
28        card_number: i32,
29        body: &CreateStepRequestContent,
30    ) -> Result<Step, Error> {
31        let mut operation = self
32            .scope
33            .operation(&routes::CREATE_STEP, &[&card_number])?;
34        operation.resource_id(card_number);
35        operation.json(body)?;
36        self.scope.client().send(operation).await
37    }
38
39    /// `DeleteStep` — `DELETE /{accountId}/cards/{cardNumber}/steps/{stepId}`.
40    ///
41    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
42    pub async fn delete(&self, card_number: i32, step_id: &str) -> Result<(), Error> {
43        let mut operation = self
44            .scope
45            .operation(&routes::DELETE_STEP, &[&card_number, &step_id])?;
46        operation.resource_id(step_id);
47        self.scope.client().send_unit(operation).await
48    }
49
50    /// `GetStep` — `GET /{accountId}/cards/{cardNumber}/steps/{stepId}`.
51    ///
52    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
53    pub async fn get(&self, card_number: i32, step_id: &str) -> Result<Step, Error> {
54        let mut operation = self
55            .scope
56            .operation(&routes::GET_STEP, &[&card_number, &step_id])?;
57        operation.resource_id(step_id);
58        self.scope.client().send(operation).await
59    }
60
61    /// `ListSteps` — `GET /{accountId}/cards/{cardNumber}/steps.json`.
62    ///
63    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
64    pub async fn list(&self, card_number: i32) -> Result<Vec<Step>, Error> {
65        let mut operation = self.scope.operation(&routes::LIST_STEPS, &[&card_number])?;
66        operation.resource_id(card_number);
67        self.scope.client().send(operation).await
68    }
69
70    /// `UpdateStep` — `PATCH /{accountId}/cards/{cardNumber}/steps/{stepId}`.
71    ///
72    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
73    pub async fn update(
74        &self,
75        card_number: i32,
76        step_id: &str,
77        body: &UpdateStepRequestContent,
78    ) -> Result<Step, Error> {
79        let mut operation = self
80            .scope
81            .operation(&routes::UPDATE_STEP, &[&card_number, &step_id])?;
82        operation.resource_id(step_id);
83        operation.json(body)?;
84        self.scope.client().send(operation).await
85    }
86}