highlevel_api/apis/opportunities/
client.rs1use super::types::*;
2use crate::{error::Result, http::HttpClient};
3use std::sync::Arc;
4
5pub struct OpportunitiesApi {
6 http: Arc<HttpClient>,
7}
8
9impl OpportunitiesApi {
10 pub fn new(http: Arc<HttpClient>) -> Self {
11 Self { http }
12 }
13
14 pub async fn search(
15 &self,
16 params: &SearchOpportunitiesParams,
17 ) -> Result<SearchOpportunitiesResponse> {
18 self.http
19 .get_with_query("/opportunities/search", params)
20 .await
21 }
22
23 pub async fn get(&self, opportunity_id: &str) -> Result<GetOpportunityResponse> {
24 self.http
25 .get(&format!("/opportunities/{opportunity_id}"))
26 .await
27 }
28
29 pub async fn create(&self, params: &CreateOpportunityParams) -> Result<GetOpportunityResponse> {
30 self.http.post("/opportunities", params).await
31 }
32
33 pub async fn update(
34 &self,
35 opportunity_id: &str,
36 params: &UpdateOpportunityParams,
37 ) -> Result<GetOpportunityResponse> {
38 self.http
39 .put(&format!("/opportunities/{opportunity_id}"), params)
40 .await
41 }
42
43 pub async fn delete(&self, opportunity_id: &str) -> Result<DeleteOpportunityResponse> {
44 self.http
45 .delete(&format!("/opportunities/{opportunity_id}"))
46 .await
47 }
48
49 pub async fn update_status(
50 &self,
51 opportunity_id: &str,
52 params: &UpdateOpportunityStatusParams,
53 ) -> Result<GetOpportunityResponse> {
54 self.http
55 .put(&format!("/opportunities/{opportunity_id}/status"), params)
56 .await
57 }
58}