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