proxycurl_linkedin_rs/apis/
school_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 [`school_profile_endpoint`]
17#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum SchoolProfileEndpointError {
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 [`student_listing_endpoint`]
31#[derive(Debug, Clone, Serialize, Deserialize)]
32#[serde(untagged)]
33pub enum StudentListingEndpointError {
34    Status400(),
35    Status401(),
36    Status403(),
37    Status404(),
38    Status429(),
39    Status500(),
40    Status503(),
41    UnknownValue(serde_json::Value),
42}
43
44/// Cost: 1 credit / successful request. Get structured data of a LinkedIn School Profile
45pub async fn school_profile_endpoint(
46    configuration: &configuration::Configuration,
47    url: &str,
48    use_cache: Option<&str>,
49) -> Result<crate::models::LinkedinSchool, Error<SchoolProfileEndpointError>> {
50    let local_var_configuration = configuration;
51
52    let local_var_client = &local_var_configuration.client;
53
54    let local_var_uri_str = format!("{}/api/linkedin/school", local_var_configuration.base_path);
55    let mut local_var_req_builder =
56        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
57
58    local_var_req_builder = local_var_req_builder.query(&[("url", &url.to_string())]);
59    if let Some(ref local_var_str) = use_cache {
60        local_var_req_builder =
61            local_var_req_builder.query(&[("use_cache", &local_var_str.to_string())]);
62    }
63    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
64        local_var_req_builder =
65            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
66    }
67    if let Some(ref local_var_token) = local_var_configuration.api_key {
68        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
69    };
70
71    let local_var_req = local_var_req_builder.build()?;
72    let local_var_resp = local_var_client.execute(local_var_req).await?;
73
74    let local_var_status = local_var_resp.status();
75    let local_var_content = local_var_resp.text().await?;
76
77    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
78        serde_json::from_str(&local_var_content).map_err(Error::from)
79    } else {
80        let local_var_entity: Option<SchoolProfileEndpointError> =
81            serde_json::from_str(&local_var_content).ok();
82        let local_var_error = ResponseContent {
83            status: local_var_status,
84            content: local_var_content,
85            entity: local_var_entity,
86        };
87        Err(Error::ResponseError(local_var_error))
88    }
89}
90
91/// Cost: 3 credits / student returned. Get a list of students of a school or university.
92#[allow(clippy::too_many_arguments)]
93pub async fn student_listing_endpoint(
94    configuration: &configuration::Configuration,
95    linkedin_school_url: &str,
96    country: Option<&str>,
97    enrich_profiles: Option<&str>,
98    search_keyword: Option<&str>,
99    page_size: Option<&str>,
100    student_status: Option<&str>,
101    sort_by: Option<&str>,
102    resolve_numeric_id: Option<&str>,
103) -> Result<crate::models::StudentList, Error<StudentListingEndpointError>> {
104    let local_var_configuration = configuration;
105
106    let local_var_client = &local_var_configuration.client;
107
108    let local_var_uri_str = format!(
109        "{}/api/linkedin/school/students/",
110        local_var_configuration.base_path
111    );
112    let mut local_var_req_builder =
113        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
114
115    if let Some(ref local_var_str) = country {
116        local_var_req_builder =
117            local_var_req_builder.query(&[("country", &local_var_str.to_string())]);
118    }
119    if let Some(ref local_var_str) = enrich_profiles {
120        local_var_req_builder =
121            local_var_req_builder.query(&[("enrich_profiles", &local_var_str.to_string())]);
122    }
123    if let Some(ref local_var_str) = search_keyword {
124        local_var_req_builder =
125            local_var_req_builder.query(&[("search_keyword", &local_var_str.to_string())]);
126    }
127    if let Some(ref local_var_str) = page_size {
128        local_var_req_builder =
129            local_var_req_builder.query(&[("page_size", &local_var_str.to_string())]);
130    }
131    if let Some(ref local_var_str) = student_status {
132        local_var_req_builder =
133            local_var_req_builder.query(&[("student_status", &local_var_str.to_string())]);
134    }
135    if let Some(ref local_var_str) = sort_by {
136        local_var_req_builder =
137            local_var_req_builder.query(&[("sort_by", &local_var_str.to_string())]);
138    }
139    if let Some(ref local_var_str) = resolve_numeric_id {
140        local_var_req_builder =
141            local_var_req_builder.query(&[("resolve_numeric_id", &local_var_str.to_string())]);
142    }
143    local_var_req_builder =
144        local_var_req_builder.query(&[("linkedin_school_url", &linkedin_school_url.to_string())]);
145    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
146        local_var_req_builder =
147            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
148    }
149    if let Some(ref local_var_token) = local_var_configuration.api_key {
150        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
151    };
152
153    let local_var_req = local_var_req_builder.build()?;
154    let local_var_resp = local_var_client.execute(local_var_req).await?;
155
156    let local_var_status = local_var_resp.status();
157    let local_var_content = local_var_resp.text().await?;
158
159    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
160        serde_json::from_str(&local_var_content).map_err(Error::from)
161    } else {
162        let local_var_entity: Option<StudentListingEndpointError> =
163            serde_json::from_str(&local_var_content).ok();
164        let local_var_error = ResponseContent {
165            status: local_var_status,
166            content: local_var_content,
167            entity: local_var_entity,
168        };
169        Err(Error::ResponseError(local_var_error))
170    }
171}