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.
//! `email-isv` — typed methods for all 1 API v2 operations
//! in this module.
//!
//! Access via [`Ghl::email_isv`](crate::Ghl::email_isv).
//!
//! Request and response types come from [`ghl_models::v2::email_isv`](https://docs.rs/ghl-models/latest/ghl_models/v2/email_isv/); every endpoint is also documented in the
//! [`email-isv` API reference](https://github.com/Shahroz/ghl-rs/blob/main/docs/api/email-isv.md).
//!
//! Enable with `features = ["email-isv"]`.

#![allow(clippy::too_many_arguments)]

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

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

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

/// Query parameters for [`EmailIsvService::email_verification`].
#[derive(Debug, Clone, Default)]
pub struct EmailVerificationParams {
    /// Location Id, The email verification charges will be deducted from this location (if
    /// rebilling is enabled) / company wallet
    /// Required by the API.
    pub location_id: String,
}

impl EmailVerificationParams {
    /// 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 EmailIsvService {
    /// Email Verification
    ///
    /// Verify Email
    ///
    /// `POST /email/verify`
    pub async fn email_verification(
        &self,
        params: &EmailVerificationParams,
        body: &models::VerificationBodyDto,
    ) -> Result<serde_json::Value> {
        let query = params.to_query();
        self.client
            .send_versioned(
                reqwest::Method::POST,
                "/email/verify",
                &query,
                Some(body),
                Some("2021-07-28"),
            )
            .await
    }
}