Skip to main content

highlevel_api/apis/social_planner/
client.rs

1use super::types::*;
2use crate::{error::Result, http::HttpClient};
3use std::sync::Arc;
4
5pub struct SocialPlannerApi {
6    http: Arc<HttpClient>,
7}
8
9impl SocialPlannerApi {
10    pub fn new(http: Arc<HttpClient>) -> Self {
11        Self { http }
12    }
13
14    pub async fn list_posts(&self, params: &GetPostsParams) -> Result<GetPostsResponse> {
15        self.http
16            .get_with_query("/social-media-posting/posts", params)
17            .await
18    }
19
20    pub async fn get_post(&self, post_id: &str) -> Result<GetPostResponse> {
21        self.http
22            .get(&format!("/social-media-posting/posts/{post_id}"))
23            .await
24    }
25
26    pub async fn delete_post(&self, post_id: &str) -> Result<()> {
27        self.http
28            .delete_no_content(&format!("/social-media-posting/posts/{post_id}"))
29            .await
30    }
31
32    pub async fn get_accounts(&self, location_id: &str) -> Result<GetAccountsResponse> {
33        #[derive(serde::Serialize)]
34        struct Q<'a> {
35            #[serde(rename = "locationId")]
36            location_id: &'a str,
37        }
38        self.http
39            .get_with_query(
40                "/social-media-posting/oauth/facebook/accounts",
41                &Q { location_id },
42            )
43            .await
44    }
45}