1use crate::{
2 client::{Client, ClientConfig},
3 error::Result,
4 services::Service,
5 types::*,
6};
7use std::time::Duration;
8
9pub struct CufinderSDK {
11 client: Client,
12 service: Service,
13}
14
15impl CufinderSDK {
16 pub fn new(api_key: String) -> Result<Self> {
18 let config = ClientConfig {
19 api_key,
20 base_url: "https://api.cufinder.io/v2".to_string(),
21 timeout: Duration::from_secs(30),
22 max_retries: 3,
23 };
24
25 Self::with_config(config)
26 }
27
28 pub fn with_config(config: ClientConfig) -> Result<Self> {
30 let client = Client::new(config)?;
31 let service = Service::new(client.clone());
32
33 Ok(Self { client, service })
34 }
35
36 pub fn client(&self) -> &Client {
38 &self.client
39 }
40
41 pub async fn cuf(&self, company_name: &str, country_code: &str) -> Result<CufResponse> {
45 self.service.get_domain(CufParams {
46 company_name: company_name.to_string(),
47 country_code: country_code.to_string(),
48 }).await
49 }
50
51 pub async fn lcuf(&self, company_name: &str) -> Result<LcufResponse> {
53 self.service.get_linkedin_url(LcufParams {
54 company_name: company_name.to_string(),
55 }).await
56 }
57
58 pub async fn dtc(&self, company_website: &str) -> Result<DtcResponse> {
60 self.service.get_company_name(DtcParams {
61 company_website: company_website.to_string(),
62 }).await
63 }
64
65 pub async fn dte(&self, company_website: &str) -> Result<DteResponse> {
67 self.service.get_emails(DteParams {
68 company_website: company_website.to_string(),
69 }).await
70 }
71
72 pub async fn ntp(&self, company_name: &str) -> Result<NtpResponse> {
74 self.service.get_phones(NtpParams {
75 company_name: company_name.to_string(),
76 }).await
77 }
78
79 pub async fn epp(&self, linkedin_url: &str) -> Result<EppResponse> {
83 self.service.enrich_profile(EppParams {
84 linkedin_url: linkedin_url.to_string(),
85 }).await
86 }
87
88 pub async fn rel(&self, email: &str) -> Result<RelResponse> {
90 self.service.reverse_email_lookup(RelParams {
91 email: email.to_string(),
92 }).await
93 }
94
95 pub async fn fwe(&self, linkedin_url: &str) -> Result<FweResponse> {
97 self.service.get_email_from_profile(FweParams {
98 linkedin_url: linkedin_url.to_string(),
99 }).await
100 }
101
102 pub async fn tep(&self, full_name: &str, company: &str) -> Result<TepResponse> {
104 self.service.enrich_person(TepParams {
105 full_name: full_name.to_string(),
106 company: company.to_string(),
107 }).await
108 }
109
110 pub async fn fcl(&self, query: &str) -> Result<FclResponse> {
114 self.service.get_lookalikes(FclParams {
115 query: query.to_string(),
116 }).await
117 }
118
119 pub async fn elf(&self, query: &str) -> Result<ElfResponse> {
121 self.service.get_fundraising(ElfParams {
122 query: query.to_string(),
123 }).await
124 }
125
126 pub async fn car(&self, query: &str) -> Result<CarResponse> {
128 self.service.get_revenue(CarParams {
129 query: query.to_string(),
130 }).await
131 }
132
133 pub async fn fcc(&self, query: &str) -> Result<FccResponse> {
135 self.service.get_subsidiaries(FccParams {
136 query: query.to_string(),
137 }).await
138 }
139
140 pub async fn fts(&self, query: &str) -> Result<FtsResponse> {
142 self.service.get_tech_stack(FtsParams {
143 query: query.to_string(),
144 }).await
145 }
146
147 pub async fn enc(&self, query: &str) -> Result<EncResponse> {
149 self.service.enrich_company(EncParams {
150 query: query.to_string(),
151 }).await
152 }
153
154 pub async fn cec(&self, query: &str) -> Result<CecResponse> {
156 self.service.get_employee_countries(CecParams {
157 query: query.to_string(),
158 }).await
159 }
160
161 pub async fn clo(&self, query: &str) -> Result<CloResponse> {
163 self.service.get_locations(CloParams {
164 query: query.to_string(),
165 }).await
166 }
167
168 pub async fn cse(&self, params: CseParams) -> Result<CseResponse> {
172 self.service.search_companies(params).await
173 }
174
175 pub async fn pse(&self, params: PseParams) -> Result<PseResponse> {
177 self.service.search_people(params).await
178 }
179
180 pub async fn lbs(&self, params: LbsParams) -> Result<LbsResponse> {
182 self.service.search_local_businesses(params).await
183 }
184}