space_traders/apis/
mod.rs

1//! API endpoints for SpaceTraders.
2//!
3//! Generated by: <https://openapi-generator.tech>
4//!
5//! Version of specification: `2.0.0`
6
7/// Content of a response.
8#[derive(Debug, Clone)]
9pub struct ResponseContent<T> {
10    /// The status of the response.
11    ///
12    /// The response enums for each endpoint function are already split up
13    /// by status code so this shouldn't really be needed in practice.
14    pub status: reqwest::StatusCode,
15
16    /// The raw response body as text.
17    ///
18    /// This can be used to extract information from the response if the schema
19    /// does not include the data.
20    pub response_body: String,
21
22    /// The deserialized content of the response.
23    pub content: T,
24}
25
26/// Error from interacting with an API endpoint.
27#[derive(thiserror::Error, Debug)]
28pub enum Error<T> {
29    /// Error from `request`.
30    #[error("error performing request: {0}")]
31    Reqwest(#[from] reqwest::Error),
32
33    /// Error from `serde_json`.
34    #[error("error deserializing: {0}")]
35    Serde(#[from] serde_json::Error),
36
37    /// Error response from the endpoint.
38    #[error("got error response: {} - {}", .0.status, .0.response_body)]
39    ResponseError(ResponseContent<T>),
40
41    /// An unknown response was received.
42    ///
43    /// This response was not defined by the schema.
44    #[error("got unknown response: {status} - {response_body}")]
45    UnknownResponse {
46        is_error: bool,
47        status: reqwest::StatusCode,
48        response_body: String,
49    },
50}
51
52fn urlencode<T: AsRef<str>>(s: T) -> String {
53    ::url::form_urlencoded::byte_serialize(s.as_ref().as_bytes()).collect()
54}
55
56pub mod agents_api;
57pub mod contracts_api;
58pub mod default_api;
59pub mod factions_api;
60pub mod fleet_api;
61pub mod systems_api;
62
63mod configuration;
64pub use configuration::*;