proxycurl_linkedin_rs/apis/
jobs_api.rs

1/*
2 * Proxycurl API
3 *
4 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 *
6 * The version of the OpenAPI document: 1.0.0
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use reqwest;
12
13use super::{configuration, Error};
14use crate::apis::ResponseContent;
15
16/// struct for typed errors of method [`job_profile_endpoint`]
17#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum JobProfileEndpointError {
20    Status400(),
21    Status401(),
22    Status403(),
23    Status404(),
24    Status429(),
25    Status500(),
26    Status503(),
27    UnknownValue(serde_json::Value),
28}
29
30/// struct for typed errors of method [`jobs_listing_count_endpoint`]
31#[derive(Debug, Clone, Serialize, Deserialize)]
32#[serde(untagged)]
33pub enum JobsListingCountEndpointError {
34    Status400(),
35    Status401(),
36    Status403(),
37    Status404(),
38    Status429(),
39    Status500(),
40    Status503(),
41    UnknownValue(serde_json::Value),
42}
43
44/// struct for typed errors of method [`jobs_listing_endpoint`]
45#[derive(Debug, Clone, Serialize, Deserialize)]
46#[serde(untagged)]
47pub enum JobsListingEndpointError {
48    Status400(),
49    Status401(),
50    Status403(),
51    Status404(),
52    Status429(),
53    Status500(),
54    Status503(),
55    UnknownValue(serde_json::Value),
56}
57
58/// Cost: 2 credits / successful request. Get structured data of a LinkedIn Job Profile
59pub async fn job_profile_endpoint(
60    configuration: &configuration::Configuration,
61    url: &str,
62) -> Result<crate::models::JobProfile, Error<JobProfileEndpointError>> {
63    let local_var_configuration = configuration;
64
65    let local_var_client = &local_var_configuration.client;
66
67    let local_var_uri_str = format!("{}/api/linkedin/job", local_var_configuration.base_path);
68    let mut local_var_req_builder =
69        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
70
71    local_var_req_builder = local_var_req_builder.query(&[("url", &url.to_string())]);
72    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
73        local_var_req_builder =
74            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
75    }
76    if let Some(ref local_var_token) = local_var_configuration.api_key {
77        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
78    };
79
80    let local_var_req = local_var_req_builder.build()?;
81    let local_var_resp = local_var_client.execute(local_var_req).await?;
82
83    let local_var_status = local_var_resp.status();
84    let local_var_content = local_var_resp.text().await?;
85
86    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
87        serde_json::from_str(&local_var_content).map_err(Error::from)
88    } else {
89        let local_var_entity: Option<JobProfileEndpointError> =
90            serde_json::from_str(&local_var_content).ok();
91        let local_var_error = ResponseContent {
92            status: local_var_status,
93            content: local_var_content,
94            entity: local_var_entity,
95        };
96        Err(Error::ResponseError(local_var_error))
97    }
98}
99
100/// Cost: 2 credits / successful request. Count number of jobs posted by a company on LinkedIn
101#[allow(clippy::too_many_arguments)]
102pub async fn jobs_listing_count_endpoint(
103    configuration: &configuration::Configuration,
104    job_type: Option<&str>,
105    experience_level: Option<&str>,
106    when: Option<&str>,
107    flexibility: Option<&str>,
108    geo_id: Option<&str>,
109    keyword: Option<&str>,
110    search_id: Option<&str>,
111) -> Result<crate::models::JobListCount, Error<JobsListingCountEndpointError>> {
112    let local_var_configuration = configuration;
113
114    let local_var_client = &local_var_configuration.client;
115
116    let local_var_uri_str = format!(
117        "{}/api/v2/linkedin/company/job/count",
118        local_var_configuration.base_path
119    );
120    let mut local_var_req_builder =
121        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
122
123    if let Some(ref local_var_str) = job_type {
124        local_var_req_builder =
125            local_var_req_builder.query(&[("job_type", &local_var_str.to_string())]);
126    }
127    if let Some(ref local_var_str) = experience_level {
128        local_var_req_builder =
129            local_var_req_builder.query(&[("experience_level", &local_var_str.to_string())]);
130    }
131    if let Some(ref local_var_str) = when {
132        local_var_req_builder =
133            local_var_req_builder.query(&[("when", &local_var_str.to_string())]);
134    }
135    if let Some(ref local_var_str) = flexibility {
136        local_var_req_builder =
137            local_var_req_builder.query(&[("flexibility", &local_var_str.to_string())]);
138    }
139    if let Some(ref local_var_str) = geo_id {
140        local_var_req_builder =
141            local_var_req_builder.query(&[("geo_id", &local_var_str.to_string())]);
142    }
143    if let Some(ref local_var_str) = keyword {
144        local_var_req_builder =
145            local_var_req_builder.query(&[("keyword", &local_var_str.to_string())]);
146    }
147    if let Some(ref local_var_str) = search_id {
148        local_var_req_builder =
149            local_var_req_builder.query(&[("search_id", &local_var_str.to_string())]);
150    }
151    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
152        local_var_req_builder =
153            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
154    }
155    if let Some(ref local_var_token) = local_var_configuration.api_key {
156        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
157    };
158
159    let local_var_req = local_var_req_builder.build()?;
160    let local_var_resp = local_var_client.execute(local_var_req).await?;
161
162    let local_var_status = local_var_resp.status();
163    let local_var_content = local_var_resp.text().await?;
164
165    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
166        serde_json::from_str(&local_var_content).map_err(Error::from)
167    } else {
168        let local_var_entity: Option<JobsListingCountEndpointError> =
169            serde_json::from_str(&local_var_content).ok();
170        let local_var_error = ResponseContent {
171            status: local_var_status,
172            content: local_var_content,
173            entity: local_var_entity,
174        };
175        Err(Error::ResponseError(local_var_error))
176    }
177}
178
179/// Cost: 2 credits / successful request. List jobs posted by a company on LinkedIn
180#[allow(clippy::too_many_arguments)]
181pub async fn jobs_listing_endpoint(
182    configuration: &configuration::Configuration,
183    job_type: Option<&str>,
184    experience_level: Option<&str>,
185    when: Option<&str>,
186    flexibility: Option<&str>,
187    geo_id: Option<&str>,
188    keyword: Option<&str>,
189    search_id: Option<&str>,
190) -> Result<crate::models::JobListPage, Error<JobsListingEndpointError>> {
191    let local_var_configuration = configuration;
192
193    let local_var_client = &local_var_configuration.client;
194
195    let local_var_uri_str = format!(
196        "{}/api/v2/linkedin/company/job",
197        local_var_configuration.base_path
198    );
199    let mut local_var_req_builder =
200        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
201
202    if let Some(ref local_var_str) = job_type {
203        local_var_req_builder =
204            local_var_req_builder.query(&[("job_type", &local_var_str.to_string())]);
205    }
206    if let Some(ref local_var_str) = experience_level {
207        local_var_req_builder =
208            local_var_req_builder.query(&[("experience_level", &local_var_str.to_string())]);
209    }
210    if let Some(ref local_var_str) = when {
211        local_var_req_builder =
212            local_var_req_builder.query(&[("when", &local_var_str.to_string())]);
213    }
214    if let Some(ref local_var_str) = flexibility {
215        local_var_req_builder =
216            local_var_req_builder.query(&[("flexibility", &local_var_str.to_string())]);
217    }
218    if let Some(ref local_var_str) = geo_id {
219        local_var_req_builder =
220            local_var_req_builder.query(&[("geo_id", &local_var_str.to_string())]);
221    }
222    if let Some(ref local_var_str) = keyword {
223        local_var_req_builder =
224            local_var_req_builder.query(&[("keyword", &local_var_str.to_string())]);
225    }
226    if let Some(ref local_var_str) = search_id {
227        local_var_req_builder =
228            local_var_req_builder.query(&[("search_id", &local_var_str.to_string())]);
229    }
230    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
231        local_var_req_builder =
232            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
233    }
234    if let Some(ref local_var_token) = local_var_configuration.api_key {
235        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
236    };
237
238    let local_var_req = local_var_req_builder.build()?;
239    let local_var_resp = local_var_client.execute(local_var_req).await?;
240
241    let local_var_status = local_var_resp.status();
242    let local_var_content = local_var_resp.text().await?;
243
244    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
245        serde_json::from_str(&local_var_content).map_err(Error::from)
246    } else {
247        let local_var_entity: Option<JobsListingEndpointError> =
248            serde_json::from_str(&local_var_content).ok();
249        let local_var_error = ResponseContent {
250            status: local_var_status,
251            content: local_var_content,
252            entity: local_var_entity,
253        };
254        Err(Error::ResponseError(local_var_error))
255    }
256}