Skip to main content

ghl_sdk/services/
workflows.rs

1// @generated by xtask/generate_services.py — do not edit by hand.
2//! `workflows` — typed methods for all 1 API v2 operations
3//! in this module.
4//!
5//! Access via [`Ghl::workflows`](crate::Ghl::workflows).
6//!
7//! 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
8//! [`workflows` API reference](https://github.com/Shahroz/ghl-rs/blob/main/docs/api/workflows.md).
9//!
10//! Enable with `features = ["workflows"]`.
11
12#![allow(clippy::too_many_arguments)]
13
14use crate::client::Ghl;
15use crate::error::Result;
16use ghl_models::v2::workflows as models;
17
18/// Typed access to the `workflows` API v2 surface (1 operations). Obtained via
19/// [`Ghl::workflows`](crate::Ghl::workflows).
20#[derive(Debug, Clone)]
21pub struct WorkflowsService {
22    pub(crate) client: Ghl,
23}
24
25impl WorkflowsService {
26    pub(crate) fn new(client: Ghl) -> Self {
27        Self { client }
28    }
29}
30
31/// Query parameters for [`WorkflowsService::get_workflow`].
32#[derive(Debug, Clone, Default)]
33pub struct GetWorkflowParams {
34    /// `locationId` query parameter.
35    /// Required by the API.
36    pub location_id: String,
37}
38
39impl GetWorkflowParams {
40    /// Start from the parameters the API requires.
41    pub fn new(location_id: impl Into<String>) -> Self {
42        Self {
43            location_id: location_id.into(),
44        }
45    }
46
47    fn to_query(&self) -> Vec<(String, String)> {
48        let q: Vec<(String, String)> = vec![("locationId".into(), self.location_id.clone())];
49        q
50    }
51}
52
53impl WorkflowsService {
54    /// Get Workflow
55    ///
56    /// `GET /workflows/`
57    ///
58    /// Requires scope: `workflows.readonly`.
59    pub async fn get_workflow(
60        &self,
61        params: &GetWorkflowParams,
62    ) -> Result<models::GetWorkflowSuccessfulResponseDto> {
63        let query = params.to_query();
64        self.client
65            .send_versioned(
66                reqwest::Method::GET,
67                "/workflows/",
68                &query,
69                None::<&()>,
70                Some("2021-07-28"),
71            )
72            .await
73    }
74}