openapi_github/apis/
emojis_api.rs

1/*
2 * GitHub's official OpenAPI spec + Octokit extension
3 *
4 * OpenAPI specs from https://github.com/github/rest-api-description with the 'x-octokit' extension required by the Octokit SDKs
5 *
6 * The version of the OpenAPI document: 16.6.0
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration};
16
17
18/// struct for typed errors of method [`emojis_slash_get`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum EmojisSlashGetError {
22    UnknownValue(serde_json::Value),
23}
24
25
26/// Lists all the emojis available to use on GitHub.
27pub async fn emojis_slash_get(configuration: &configuration::Configuration, ) -> Result<std::collections::HashMap<String, String>, Error<EmojisSlashGetError>> {
28    let local_var_configuration = configuration;
29
30    let local_var_client = &local_var_configuration.client;
31
32    let local_var_uri_str = format!("{}/emojis", local_var_configuration.base_path);
33    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
34
35    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
36        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
37    }
38
39    let local_var_req = local_var_req_builder.build()?;
40    let local_var_resp = local_var_client.execute(local_var_req).await?;
41
42    let local_var_status = local_var_resp.status();
43    let local_var_content = local_var_resp.text().await?;
44
45    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
46        serde_json::from_str(&local_var_content).map_err(Error::from)
47    } else {
48        let local_var_entity: Option<EmojisSlashGetError> = serde_json::from_str(&local_var_content).ok();
49        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
50        Err(Error::ResponseError(local_var_error))
51    }
52}
53