use super::types::*;
use crate::{error::Result, http::HttpClient};
use std::sync::Arc;
pub struct WorkflowsApi {
http: Arc<HttpClient>,
}
impl WorkflowsApi {
pub fn new(http: Arc<HttpClient>) -> Self {
Self { http }
}
pub async fn list(&self, location_id: &str) -> Result<GetWorkflowsResponse> {
#[derive(serde::Serialize)]
struct Q<'a> {
#[serde(rename = "locationId")]
location_id: &'a str,
}
self.http
.get_with_query("/workflows", &Q { location_id })
.await
}
pub async fn subscribe_contact(
&self,
workflow_id: &str,
params: &WorkflowSubscribeParams,
) -> Result<serde_json::Value> {
self.http
.post(&format!("/workflows/{workflow_id}/subscribe"), params)
.await
}
pub async fn unsubscribe_contact(
&self,
workflow_id: &str,
params: &WorkflowSubscribeParams,
) -> Result<serde_json::Value> {
self.http
.delete_with_body(&format!("/workflows/{workflow_id}/subscribe"), params)
.await
}
}