proxycurl_linkedin_rs/apis/
people_api.rs1use reqwest;
12
13use super::{configuration, Error};
14use crate::apis::ResponseContent;
15
16#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum PersonLookupEndpointError {
20 Status400(),
21 Status401(),
22 Status403(),
23 Status404(),
24 Status429(),
25 Status500(),
26 Status503(),
27 UnknownValue(serde_json::Value),
28}
29
30#[derive(Debug, Clone, Serialize, Deserialize)]
32#[serde(untagged)]
33pub enum PersonProfileEndpointError {
34 Status400(),
35 Status401(),
36 Status403(),
37 Status404(),
38 Status429(),
39 Status500(),
40 Status503(),
41 UnknownValue(serde_json::Value),
42}
43
44#[derive(Debug, Clone, Serialize, Deserialize)]
46#[serde(untagged)]
47pub enum PersonProfilePictureEndpointError {
48 Status400(),
49 Status401(),
50 Status403(),
51 Status404(),
52 Status429(),
53 Status500(),
54 Status503(),
55 UnknownValue(serde_json::Value),
56}
57
58#[derive(Debug, Clone, Serialize, Deserialize)]
60#[serde(untagged)]
61pub enum RoleLookupEndpointError {
62 Status400(),
63 Status401(),
64 Status403(),
65 Status404(),
66 Status429(),
67 Status500(),
68 Status503(),
69 UnknownValue(serde_json::Value),
70}
71
72pub async fn person_lookup_endpoint(
74 configuration: &configuration::Configuration,
75 company_domain: &str,
76 first_name: &str,
77 enrich_profile: Option<&str>,
78 location: Option<&str>,
79 title: Option<&str>,
80 last_name: Option<&str>,
81) -> Result<crate::models::PersonLookupUrlEnrichResult, Error<PersonLookupEndpointError>> {
82 let local_var_configuration = configuration;
83
84 let local_var_client = &local_var_configuration.client;
85
86 let local_var_uri_str = format!(
87 "{}/api/linkedin/profile/resolve",
88 local_var_configuration.base_path
89 );
90 let mut local_var_req_builder =
91 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
92
93 if let Some(ref local_var_str) = enrich_profile {
94 local_var_req_builder =
95 local_var_req_builder.query(&[("enrich_profile", &local_var_str.to_string())]);
96 }
97 local_var_req_builder =
98 local_var_req_builder.query(&[("company_domain", &company_domain.to_string())]);
99 if let Some(ref local_var_str) = location {
100 local_var_req_builder =
101 local_var_req_builder.query(&[("location", &local_var_str.to_string())]);
102 }
103 if let Some(ref local_var_str) = title {
104 local_var_req_builder =
105 local_var_req_builder.query(&[("title", &local_var_str.to_string())]);
106 }
107 if let Some(ref local_var_str) = last_name {
108 local_var_req_builder =
109 local_var_req_builder.query(&[("last_name", &local_var_str.to_string())]);
110 }
111 local_var_req_builder = local_var_req_builder.query(&[("first_name", &first_name.to_string())]);
112 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
113 local_var_req_builder =
114 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
115 }
116 if let Some(ref local_var_token) = local_var_configuration.api_key {
117 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
118 };
119
120 let local_var_req = local_var_req_builder.build()?;
121 let local_var_resp = local_var_client.execute(local_var_req).await?;
122
123 let local_var_status = local_var_resp.status();
124 let local_var_content = local_var_resp.text().await?;
125
126 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
127 serde_json::from_str(&local_var_content).map_err(Error::from)
128 } else {
129 let local_var_entity: Option<PersonLookupEndpointError> =
130 serde_json::from_str(&local_var_content).ok();
131 let local_var_error = ResponseContent {
132 status: local_var_status,
133 content: local_var_content,
134 entity: local_var_entity,
135 };
136 Err(Error::ResponseError(local_var_error))
137 }
138}
139
140#[allow(clippy::too_many_arguments)]
142pub async fn person_profile_endpoint(
143 configuration: &configuration::Configuration,
144 url: &str,
145 fallback_to_cache: &str,
146 use_cache: Option<&str>,
147 skills: Option<&str>,
148 inferred_salary: Option<&str>,
149 personal_email: Option<&str>,
150 personal_contact_number: Option<&str>,
151 twitter_profile_id: Option<&str>,
152 facebook_profile_id: Option<&str>,
153 github_profile_id: Option<&str>,
154 extra: Option<&str>,
155) -> Result<crate::models::PersonEndpointResponse, Error<PersonProfileEndpointError>> {
156 let local_var_configuration = configuration;
157
158 let local_var_client = &local_var_configuration.client;
159
160 let local_var_uri_str = format!("{}/api/v2/linkedin", local_var_configuration.base_path);
161 let mut local_var_req_builder =
162 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
163
164 local_var_req_builder = local_var_req_builder.query(&[("url", &url.to_string())]);
165 local_var_req_builder =
166 local_var_req_builder.query(&[("fallback_to_cache", &fallback_to_cache.to_string())]);
167 if let Some(ref local_var_str) = use_cache {
168 local_var_req_builder =
169 local_var_req_builder.query(&[("use_cache", &local_var_str.to_string())]);
170 }
171 if let Some(ref local_var_str) = skills {
172 local_var_req_builder =
173 local_var_req_builder.query(&[("skills", &local_var_str.to_string())]);
174 }
175 if let Some(ref local_var_str) = inferred_salary {
176 local_var_req_builder =
177 local_var_req_builder.query(&[("inferred_salary", &local_var_str.to_string())]);
178 }
179 if let Some(ref local_var_str) = personal_email {
180 local_var_req_builder =
181 local_var_req_builder.query(&[("personal_email", &local_var_str.to_string())]);
182 }
183 if let Some(ref local_var_str) = personal_contact_number {
184 local_var_req_builder =
185 local_var_req_builder.query(&[("personal_contact_number", &local_var_str.to_string())]);
186 }
187 if let Some(ref local_var_str) = twitter_profile_id {
188 local_var_req_builder =
189 local_var_req_builder.query(&[("twitter_profile_id", &local_var_str.to_string())]);
190 }
191 if let Some(ref local_var_str) = facebook_profile_id {
192 local_var_req_builder =
193 local_var_req_builder.query(&[("facebook_profile_id", &local_var_str.to_string())]);
194 }
195 if let Some(ref local_var_str) = github_profile_id {
196 local_var_req_builder =
197 local_var_req_builder.query(&[("github_profile_id", &local_var_str.to_string())]);
198 }
199 if let Some(ref local_var_str) = extra {
200 local_var_req_builder =
201 local_var_req_builder.query(&[("extra", &local_var_str.to_string())]);
202 }
203 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
204 local_var_req_builder =
205 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
206 }
207 if let Some(ref local_var_token) = local_var_configuration.api_key {
208 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
209 };
210
211 let local_var_req = local_var_req_builder.build()?;
212 let local_var_resp = local_var_client.execute(local_var_req).await?;
213
214 let local_var_status = local_var_resp.status();
215 let local_var_content = local_var_resp.text().await?;
216
217 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
218 serde_json::from_str(&local_var_content).map_err(Error::from)
219 } else {
220 let local_var_entity: Option<PersonProfileEndpointError> =
221 serde_json::from_str(&local_var_content).ok();
222 let local_var_error = ResponseContent {
223 status: local_var_status,
224 content: local_var_content,
225 entity: local_var_entity,
226 };
227 Err(Error::ResponseError(local_var_error))
228 }
229}
230
231pub async fn person_profile_picture_endpoint(
233 configuration: &configuration::Configuration,
234 linkedin_person_profile_url: &str,
235) -> Result<crate::models::ProfilePicture, Error<PersonProfilePictureEndpointError>> {
236 let local_var_configuration = configuration;
237
238 let local_var_client = &local_var_configuration.client;
239
240 let local_var_uri_str = format!(
241 "{}/api/linkedin/person/profile-picture",
242 local_var_configuration.base_path
243 );
244 let mut local_var_req_builder =
245 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
246
247 local_var_req_builder = local_var_req_builder.query(&[(
248 "linkedin_person_profile_url",
249 &linkedin_person_profile_url.to_string(),
250 )]);
251 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
252 local_var_req_builder =
253 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
254 }
255 if let Some(ref local_var_token) = local_var_configuration.api_key {
256 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
257 };
258
259 let local_var_req = local_var_req_builder.build()?;
260 let local_var_resp = local_var_client.execute(local_var_req).await?;
261
262 let local_var_status = local_var_resp.status();
263 let local_var_content = local_var_resp.text().await?;
264
265 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
266 serde_json::from_str(&local_var_content).map_err(Error::from)
267 } else {
268 let local_var_entity: Option<PersonProfilePictureEndpointError> =
269 serde_json::from_str(&local_var_content).ok();
270 let local_var_error = ResponseContent {
271 status: local_var_status,
272 content: local_var_content,
273 entity: local_var_entity,
274 };
275 Err(Error::ResponseError(local_var_error))
276 }
277}
278
279pub async fn role_lookup_endpoint(
281 configuration: &configuration::Configuration,
282 role: &str,
283 company_name: &str,
284 enrich_profile: Option<&str>,
285) -> Result<crate::models::RoleSearchErichedResult, Error<RoleLookupEndpointError>> {
286 let local_var_configuration = configuration;
287
288 let local_var_client = &local_var_configuration.client;
289
290 let local_var_uri_str = format!(
291 "{}/api/find/company/role/",
292 local_var_configuration.base_path
293 );
294 let mut local_var_req_builder =
295 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
296
297 if let Some(ref local_var_str) = enrich_profile {
298 local_var_req_builder =
299 local_var_req_builder.query(&[("enrich_profile", &local_var_str.to_string())]);
300 }
301 local_var_req_builder = local_var_req_builder.query(&[("role", &role.to_string())]);
302 local_var_req_builder =
303 local_var_req_builder.query(&[("company_name", &company_name.to_string())]);
304 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
305 local_var_req_builder =
306 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
307 }
308 if let Some(ref local_var_token) = local_var_configuration.api_key {
309 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
310 };
311
312 let local_var_req = local_var_req_builder.build()?;
313 let local_var_resp = local_var_client.execute(local_var_req).await?;
314
315 let local_var_status = local_var_resp.status();
316 let local_var_content = local_var_resp.text().await?;
317
318 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
319 serde_json::from_str(&local_var_content).map_err(Error::from)
320 } else {
321 let local_var_entity: Option<RoleLookupEndpointError> =
322 serde_json::from_str(&local_var_content).ok();
323 let local_var_error = ResponseContent {
324 status: local_var_status,
325 content: local_var_content,
326 entity: local_var_entity,
327 };
328 Err(Error::ResponseError(local_var_error))
329 }
330}