use crate::client::Scope;
use crate::error::Error;
use crate::generated::routes;
use crate::generated::types::*;
pub struct StepsService<'a> {
scope: Scope<'a>,
}
impl<'a> StepsService<'a> {
pub(crate) fn new(scope: Scope<'a>) -> Self {
Self { scope }
}
pub fn scope(&self) -> &Scope<'a> {
&self.scope
}
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
}
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
}
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
}
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
}
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
}
}