highlevel_api/apis/workflows/
client.rs1use std::sync::Arc;
2use crate::{error::Result, http::HttpClient};
3use super::types::*;
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.get_with_query("/workflows", &Q { location_id }).await
21 }
22
23 pub async fn subscribe_contact(
24 &self,
25 workflow_id: &str,
26 params: &WorkflowSubscribeParams,
27 ) -> Result<serde_json::Value> {
28 self.http
29 .post(&format!("/workflows/{workflow_id}/subscribe"), params)
30 .await
31 }
32
33 pub async fn unsubscribe_contact(
34 &self,
35 workflow_id: &str,
36 params: &WorkflowSubscribeParams,
37 ) -> Result<serde_json::Value> {
38 self.http
39 .delete_with_body(&format!("/workflows/{workflow_id}/subscribe"), params)
40 .await
41 }
42}