highlevel_api/apis/workflows/
client.rs1use super::types::*;
2use crate::{error::Result, http::HttpClient};
3use std::sync::Arc;
4
5pub struct WorkflowsApi {
6 http: Arc<HttpClient>,
7}
8
9impl WorkflowsApi {
10 pub fn new(http: Arc<HttpClient>) -> Self {
11 Self { http }
12 }
13
14 pub async fn list(&self, location_id: &str) -> Result<GetWorkflowsResponse> {
15 #[derive(serde::Serialize)]
16 struct Q<'a> {
17 #[serde(rename = "locationId")]
18 location_id: &'a str,
19 }
20 self.http
21 .get_with_query("/workflows", &Q { location_id })
22 .await
23 }
24
25 pub async fn subscribe_contact(
26 &self,
27 workflow_id: &str,
28 params: &WorkflowSubscribeParams,
29 ) -> Result<serde_json::Value> {
30 self.http
31 .post(&format!("/workflows/{workflow_id}/subscribe"), params)
32 .await
33 }
34
35 pub async fn unsubscribe_contact(
36 &self,
37 workflow_id: &str,
38 params: &WorkflowSubscribeParams,
39 ) -> Result<serde_json::Value> {
40 self.http
41 .delete_with_body(&format!("/workflows/{workflow_id}/subscribe"), params)
42 .await
43 }
44}