ghl-models 0.3.0

Rust data models (DTOs) for the GoHighLevel (HighLevel) API v2 and v3, generated from the official OpenAPI specifications
Documentation
// @generated by xtask/generate_models.py — do not edit by hand.
// Source: https://github.com/GoHighLevel/highlevel-api-docs
// Doc comments are HighLevel's own field descriptions, reflowed verbatim, so
// they aren't held to rustdoc's markdown conventions.
#![allow(
    missing_docs,
    clippy::doc_lazy_continuation,
    clippy::doc_overindented_list_items
)]

use serde::{Deserialize, Serialize};

/// `AipErrorBodyDto` from the GoHighLevel OpenAPI spec.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct AipErrorBodyDto {
    /// Machine-readable error code (see AipErrorCode enum in @platform-core/aip-framework)
    /// Required by the API.
    pub code: String,
    /// Human-readable error message
    /// Required by the API.
    pub message: String,
    /// Additional error context (field name, identifier, etc.)
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub details: Option<serde_json::Value>,
    /// Suggested resolution for the caller
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub resolution: Option<String>,
}

/// `AipErrorResponseDto` from the GoHighLevel OpenAPI spec.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct AipErrorResponseDto {
    /// AIP-compliant error envelope
    /// Required by the API.
    pub error: AipErrorBodyDto,
}

/// `GetAccessTokenBodyDto` from the GoHighLevel OpenAPI spec.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct GetAccessTokenBodyDto {
    /// The ID provided by CRM for your integration
    /// Required by the API.
    #[serde(rename = "clientId")]
    pub client_id: String,
    /// The client secret provided by CRM for your integration
    /// Required by the API.
    #[serde(rename = "clientSecret")]
    pub client_secret: String,
    /// The OAuth2 grant type — authorization_code, refresh_token, or client_credentials
    /// Allowed values: `authorization_code`, `refresh_token`, `client_credentials`.
    /// Required by the API.
    #[serde(rename = "grantType")]
    pub grant_type: String,
    /// The authorization code received from the authorization endpoint (required for
    /// authorization_code grant)
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub code: Option<String>,
    /// The refresh token used to obtain a new access token (required for refresh_token grant)
    #[serde(
        rename = "refreshToken",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub refresh_token: Option<String>,
    /// The type of token to be requested
    /// Allowed values: `Company`, `Location`.
    #[serde(rename = "userType", default, skip_serializing_if = "Option::is_none")]
    pub user_type: Option<String>,
    /// The redirect URI for your application
    #[serde(
        rename = "redirectUri",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub redirect_uri: Option<String>,
}

/// `GetAccessTokenSuccessfulResponseDto` from the GoHighLevel OpenAPI spec.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct GetAccessTokenSuccessfulResponseDto {
    /// The OAuth2 access token
    #[serde(
        rename = "accessToken",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub access_token: Option<String>,
    /// The token type (always Bearer)
    #[serde(rename = "tokenType", default, skip_serializing_if = "Option::is_none")]
    pub token_type: Option<String>,
    /// Time in seconds until the access token expires
    #[serde(rename = "expiresIn", default, skip_serializing_if = "Option::is_none")]
    pub expires_in: Option<f64>,
    /// The OAuth2 refresh token used to obtain a new access token
    #[serde(
        rename = "refreshToken",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub refresh_token: Option<String>,
    /// Space-separated list of scopes the access token has access to
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub scope: Option<String>,
    /// The user type associated with the token (Location or Company)
    #[serde(rename = "userType", default, skip_serializing_if = "Option::is_none")]
    pub user_type: Option<String>,
    /// Location ID - Present only for Sub-Account Access Token
    #[serde(
        rename = "locationId",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub location_id: Option<String>,
    /// Company ID
    #[serde(rename = "companyId", default, skip_serializing_if = "Option::is_none")]
    pub company_id: Option<String>,
    /// Approved locations to generate location access token
    #[serde(
        rename = "approvedLocations",
        default,
        skip_serializing_if = "Vec::is_empty"
    )]
    pub approved_locations: Vec<String>,
    /// USER ID - Represent user id of person who performed installation
    /// Required by the API.
    #[serde(rename = "userId")]
    pub user_id: String,
    /// Plan Id of the subscribed plan in paid apps.
    #[serde(rename = "planId", default, skip_serializing_if = "Option::is_none")]
    pub plan_id: Option<String>,
    /// Indicates whether the installation was performed as a bulk installation
    #[serde(
        rename = "isBulkInstallation",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub is_bulk_installation: Option<bool>,
    /// Boolean to control if user wants app to be automatically installed to future locations
    /// (only for company tokens)
    #[serde(
        rename = "installToFutureLocations",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub install_to_future_locations: Option<bool>,
    /// Boolean indicating if user approved all locations during bulk installation (only for
    /// company tokens)
    #[serde(
        rename = "approveAllLocations",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub approve_all_locations: Option<bool>,
}

/// `GetInstalledLocationsSuccessfulResponseDto` from the GoHighLevel OpenAPI spec.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct GetInstalledLocationsSuccessfulResponseDto {
    /// List of locations with their installation status for the requested app
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub locations: Vec<InstalledLocationSchema>,
    /// Total location count under the company
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub count: Option<f64>,
    /// Boolean to control if user wants app to be automatically installed to future locations
    #[serde(
        rename = "installToFutureLocations",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub install_to_future_locations: Option<bool>,
}

/// `GetInstalledLocationsV3SuccessfulResponseDto` from the GoHighLevel OpenAPI spec.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct GetInstalledLocationsV3SuccessfulResponseDto {
    /// List of locations with their installation status for the requested app
    /// Required by the API.
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub items: Vec<InstalledLocationSchema>,
    /// Pagination metadata (AIP-158)
    /// Required by the API.
    pub pagination: V3PaginationMetaDto,
    /// Query metadata (filters and sort applied)
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub metadata: Option<V3InstalledLocationsListMetadataDto>,
    /// Boolean to control if user wants app to be automatically installed to future locations
    #[serde(
        rename = "installToFutureLocations",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub install_to_future_locations: Option<bool>,
}

/// `GetLocationAccessCodeBodyDto` from the GoHighLevel OpenAPI spec.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct GetLocationAccessCodeBodyDto {
    /// Company Id of location you want to request token for
    /// Required by the API.
    #[serde(rename = "companyId")]
    pub company_id: String,
    /// The location ID for which you want to obtain accessToken
    /// Required by the API.
    #[serde(rename = "locationId")]
    pub location_id: String,
}

/// `GetLocationAccessTokenSuccessfulResponseDto` from the GoHighLevel OpenAPI spec.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct GetLocationAccessTokenSuccessfulResponseDto {
    /// Location access token which can be used to authenticate & authorize API under following
    /// scope
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub access_token: Option<String>,
    /// The token type (always Bearer)
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub token_type: Option<String>,
    /// Time in seconds remaining for token to expire
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub expires_in: Option<f64>,
    /// Scopes the following accessToken have access to
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub scope: Option<String>,
    /// Location ID - Present only for Sub-Account Access Token
    #[serde(
        rename = "locationId",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub location_id: Option<String>,
    /// Plan Id of the subscribed plan in paid apps.
    #[serde(rename = "planId", default, skip_serializing_if = "Option::is_none")]
    pub plan_id: Option<String>,
    /// USER ID - Represent user id of person who performed installation
    /// Required by the API.
    #[serde(rename = "userId")]
    pub user_id: String,
    /// App ID of the installed application
    #[serde(rename = "appId", default, skip_serializing_if = "Option::is_none")]
    pub app_id: Option<String>,
    /// Version ID of the installed app version
    #[serde(rename = "versionId", default, skip_serializing_if = "Option::is_none")]
    pub version_id: Option<String>,
    /// The OAuth2 refresh token used to obtain a new access token for this specific location
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub refresh_token: Option<String>,
}

/// `GetLocationAccessTokenV3SuccessfulResponseDto` from the GoHighLevel OpenAPI spec.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct GetLocationAccessTokenV3SuccessfulResponseDto {
    /// Location access token which can be used to authenticate & authorize API under following
    /// scope
    #[serde(
        rename = "accessToken",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub access_token: Option<String>,
    /// The token type (always Bearer)
    #[serde(rename = "tokenType", default, skip_serializing_if = "Option::is_none")]
    pub token_type: Option<String>,
    /// Time in seconds remaining for token to expire
    #[serde(rename = "expiresIn", default, skip_serializing_if = "Option::is_none")]
    pub expires_in: Option<f64>,
    /// Scopes the following accessToken have access to
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub scope: Option<String>,
    /// Location ID - Present only for Sub-Account Access Token
    #[serde(
        rename = "locationId",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub location_id: Option<String>,
    /// Plan Id of the subscribed plan in paid apps.
    #[serde(rename = "planId", default, skip_serializing_if = "Option::is_none")]
    pub plan_id: Option<String>,
    /// USER ID - Represent user id of person who performed installation
    /// Required by the API.
    #[serde(rename = "userId")]
    pub user_id: String,
    /// App ID of the installed application
    #[serde(rename = "appId", default, skip_serializing_if = "Option::is_none")]
    pub app_id: Option<String>,
    /// Version ID of the installed app version
    #[serde(rename = "versionId", default, skip_serializing_if = "Option::is_none")]
    pub version_id: Option<String>,
    /// The OAuth2 refresh token used to obtain a new access token for this specific location.
    #[serde(
        rename = "refreshToken",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub refresh_token: Option<String>,
}

/// `InstalledLocationSchema` from the GoHighLevel OpenAPI spec.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct InstalledLocationSchema {
    /// Location ID
    /// Required by the API.
    #[serde(rename = "_id")]
    pub id: String,
    /// Name of the location
    /// Required by the API.
    pub name: String,
    /// Address linked to location
    /// Required by the API.
    pub address: String,
    /// Check if the requested app is installed for following location
    #[serde(
        rename = "isInstalled",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub is_installed: Option<bool>,
    /// Version ID of the installed app version for this location
    #[serde(rename = "versionId", default, skip_serializing_if = "Option::is_none")]
    pub version_id: Option<String>,
    /// Timestamp when the app was installed on this location
    /// Format: date-time (ISO-8601 string).
    #[serde(
        rename = "installedAt",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub installed_at: Option<String>,
}

/// `V3InstalledLocationsListMetadataDto` from the GoHighLevel OpenAPI spec.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct V3InstalledLocationsListMetadataDto {
    /// Filters that were applied to the query
    #[serde(
        rename = "filterApplied",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub filter_applied: Option<serde_json::Value>,
    /// Sort order that was applied to the query
    #[serde(
        rename = "sortApplied",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub sort_applied: Option<serde_json::Value>,
}

/// `V3PaginationMetaDto` from the GoHighLevel OpenAPI spec.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct V3PaginationMetaDto {
    /// Total number of records matching the query across all pages
    #[serde(
        rename = "totalRecords",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub total_records: Option<f64>,
    /// True when a next page is available
    /// Required by the API.
    #[serde(rename = "hasNextPage")]
    pub has_next_page: bool,
    /// True when a previous page is available
    /// Required by the API.
    #[serde(rename = "hasPrevPage")]
    pub has_prev_page: bool,
    /// Opaque token to fetch the next page
    #[serde(
        rename = "nextPageToken",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub next_page_token: Option<String>,
    /// Opaque token to fetch the previous page
    #[serde(
        rename = "prevPageToken",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub prev_page_token: Option<String>,
    /// Number of items returned in the current page
    /// Required by the API.
    #[serde(rename = "currentPageSize")]
    pub current_page_size: f64,
    /// Estimated total records; present when exact total is unknown
    #[serde(
        rename = "estimatedTotalRecords",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub estimated_total_records: Option<f64>,
}