highlevel-api 0.1.0

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

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

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

    pub async fn me(&self) -> Result<GetUserResponse> {
        self.http.get("/users/me").await
    }

    pub async fn get(&self, user_id: &str) -> Result<GetUserResponse> {
        self.http.get(&format!("/users/{user_id}")).await
    }

    pub async fn search(&self, params: &SearchUsersParams) -> Result<SearchUsersResponse> {
        self.http.get_with_query("/users/search", params).await
    }

    pub async fn create(&self, params: &CreateUserParams) -> Result<GetUserResponse> {
        self.http.post("/users", params).await
    }

    pub async fn update(
        &self,
        user_id: &str,
        params: &UpdateUserParams,
    ) -> Result<GetUserResponse> {
        self.http.put(&format!("/users/{user_id}"), params).await
    }

    pub async fn delete(&self, user_id: &str) -> Result<DeleteUserResponse> {
        self.http.delete(&format!("/users/{user_id}")).await
    }
}