proxycurl_linkedin_rs/apis/
meta_api.rs1use reqwest;
12
13use super::{configuration, Error};
14use crate::apis::ResponseContent;
15
16#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum ViewCreditBalanceEndpointError {
20 Status400(),
21 Status401(),
22 Status403(),
23 Status404(),
24 Status429(),
25 Status500(),
26 Status503(),
27 UnknownValue(serde_json::Value),
28}
29
30pub async fn view_credit_balance_endpoint(
32 configuration: &configuration::Configuration,
33) -> Result<crate::models::CreditBalance, Error<ViewCreditBalanceEndpointError>> {
34 let local_var_configuration = configuration;
35
36 let local_var_client = &local_var_configuration.client;
37
38 let local_var_uri_str = format!("{}/api/credit-balance", local_var_configuration.base_path);
39 let mut local_var_req_builder =
40 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
41
42 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
43 local_var_req_builder =
44 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
45 }
46 if let Some(ref local_var_token) = local_var_configuration.api_key {
47 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
48 };
49
50 let local_var_req = local_var_req_builder.build()?;
51 let local_var_resp = local_var_client.execute(local_var_req).await?;
52
53 let local_var_status = local_var_resp.status();
54 let local_var_content = local_var_resp.text().await?;
55
56 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
57 serde_json::from_str(&local_var_content).map_err(Error::from)
58 } else {
59 let local_var_entity: Option<ViewCreditBalanceEndpointError> =
60 serde_json::from_str(&local_var_content).ok();
61 let local_var_error = ResponseContent {
62 status: local_var_status,
63 content: local_var_content,
64 entity: local_var_entity,
65 };
66 Err(Error::ResponseError(local_var_error))
67 }
68}