highlevel-api 0.2.0

Unofficial Rust SDK for the GoHighLevel (HighLevel) API
Documentation
use super::types::*;
use crate::{error::Result, http::HttpClient};
use std::sync::Arc;

pub struct SocialPlannerApi {
    http: Arc<HttpClient>,
}

impl SocialPlannerApi {
    pub fn new(http: Arc<HttpClient>) -> Self {
        Self { http }
    }

    pub async fn list_posts(&self, params: &GetPostsParams) -> Result<GetPostsResponse> {
        self.http
            .get_with_query("/social-media-posting/posts", params)
            .await
    }

    pub async fn get_post(&self, post_id: &str) -> Result<GetPostResponse> {
        self.http
            .get(&format!("/social-media-posting/posts/{post_id}"))
            .await
    }

    pub async fn delete_post(&self, post_id: &str) -> Result<()> {
        self.http
            .delete_no_content(&format!("/social-media-posting/posts/{post_id}"))
            .await
    }

    pub async fn get_accounts(&self, location_id: &str) -> Result<GetAccountsResponse> {
        #[derive(serde::Serialize)]
        struct Q<'a> {
            #[serde(rename = "locationId")]
            location_id: &'a str,
        }
        self.http
            .get_with_query(
                "/social-media-posting/oauth/facebook/accounts",
                &Q { location_id },
            )
            .await
    }
}