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