ghl-sdk 0.5.1

Unofficial async Rust SDK for the GoHighLevel (HighLevel) API 2.0 — OAuth 2.0, Private Integration Tokens, rate-limit-aware retries, paginated streams
Documentation
// @generated by xtask/generate_services.py — do not edit by hand.
//! `workflows` — typed methods for all 1 API v2 operations
//! in this module.
//!
//! Access via [`Ghl::workflows`](crate::Ghl::workflows).
//!
//! Request and response types come from [`ghl_models::v2::workflows`](https://docs.rs/ghl-models/latest/ghl_models/v2/workflows/); every endpoint is also documented in the
//! [`workflows` API reference](https://github.com/Shahroz/ghl-rs/blob/main/docs/api/workflows.md).
//!
//! Enable with `features = ["workflows"]`.

#![allow(clippy::too_many_arguments)]

use crate::client::Ghl;
use crate::error::Result;
use ghl_models::v2::workflows as models;

/// Typed access to the `workflows` API v2 surface (1 operations). Obtained via
/// [`Ghl::workflows`](crate::Ghl::workflows).
#[derive(Debug, Clone)]
pub struct WorkflowsService {
    pub(crate) client: Ghl,
}

impl WorkflowsService {
    pub(crate) fn new(client: Ghl) -> Self {
        Self { client }
    }
}

/// Query parameters for [`WorkflowsService::get_workflow`].
#[derive(Debug, Clone, Default)]
pub struct GetWorkflowParams {
    /// `locationId` query parameter.
    /// Required by the API.
    pub location_id: String,
}

impl GetWorkflowParams {
    /// Start from the parameters the API requires.
    pub fn new(location_id: impl Into<String>) -> Self {
        Self {
            location_id: location_id.into(),
        }
    }

    fn to_query(&self) -> Vec<(String, String)> {
        let q: Vec<(String, String)> = vec![("locationId".into(), self.location_id.clone())];
        q
    }
}

impl WorkflowsService {
    /// Get Workflow
    ///
    /// `GET /workflows/`
    ///
    /// Requires scope: `workflows.readonly`.
    pub async fn get_workflow(
        &self,
        params: &GetWorkflowParams,
    ) -> Result<models::GetWorkflowSuccessfulResponseDto> {
        let query = params.to_query();
        self.client
            .send_versioned(
                reqwest::Method::GET,
                "/workflows/",
                &query,
                None::<&()>,
                Some("2021-07-28"),
            )
            .await
    }
}