1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
//! Settings endpoint handler.
//!
//! <https://api.mangadex.org/swagger.html#/Settings>

mod create_or_update_user_settings;
mod create_template;
mod get_latest_template;
mod get_template_by_version_id;
mod get_user_settings;

use crate::v5::settings::create_or_update_user_settings::CreateOrUpdateUserSettingsBuilder;
use crate::v5::settings::create_template::CreateSettingsTemplateBuilder;
use crate::v5::settings::get_latest_template::GetLatestSettingsTemplateBuilder;
use crate::v5::settings::get_template_by_version_id::GetSettingsTemplateByVersionIdBuilder;
use crate::v5::settings::get_user_settings::GetUserSettingsBuilder;
use crate::HttpClientRef;

/// Settings endpoint handler builder.
#[derive(Debug)]
pub struct SettingsBuilder {
    #[allow(unused)]
    http_client: HttpClientRef,
}

impl SettingsBuilder {
    #[doc(hidden)]
    pub(crate) fn new(http_client: HttpClientRef) -> Self {
        Self { http_client }
    }

    /// Create or update a user's Settings template.
    ///
    /// <https://api.mangadex.org/swagger.html#/Settings/post-settings>
    ///
    /// # Examples
    ///
    /// ```ignore
    /// use mangadex_api::v5::MangaDexClient;
    ///
    /// # async fn run() -> anyhow::Result<()> {
    /// let client = MangaDexClient::default();
    ///
    /// let res = client
    ///     .settings()
    ///     .create_or_update_user_settings()
    ///     .build()?
    ///     .send()
    ///     .await?;
    ///
    /// println!("results: {:?}", res);
    /// # Ok(())
    /// # }
    /// ```
    #[allow(unused)]
    fn create_or_update_user_settings(&self) -> CreateOrUpdateUserSettingsBuilder {
        CreateOrUpdateUserSettingsBuilder::default().http_client(self.http_client.clone())
    }

    /// Create a Settings template.
    ///
    /// <https://api.mangadex.org/swagger.html#/Settings/post-settings-template>
    ///
    /// # Examples
    ///
    /// ```ignore
    /// use mangadex_api::v5::MangaDexClient;
    ///
    /// # async fn run() -> anyhow::Result<()> {
    /// let client = MangaDexClient::default();
    ///
    /// let res = client
    ///     .settings()
    ///     .create_template()
    ///     .build()?
    ///     .send()
    ///     .await?;
    ///
    /// println!("results: {:?}", res);
    /// # Ok(())
    /// # }
    /// ```
    #[allow(unused)]
    fn create_template(&self) -> CreateSettingsTemplateBuilder {
        CreateSettingsTemplateBuilder::default().http_client(self.http_client.clone())
    }

    /// Get the latest Settings template.
    ///
    /// <https://api.mangadex.org/swagger.html#/Settings/get-settings-template>
    ///
    /// # Examples
    ///
    /// ```ignore
    /// use mangadex_api::v5::MangaDexClient;
    /// use uuid::Uuid;
    ///
    /// # async fn run() -> anyhow::Result<()> {
    /// let client = MangaDexClient::default();
    ///
    /// let res = client
    ///     .settings()
    ///     .get_latest_template()
    ///     .build()?
    ///     .send()
    ///     .await?;
    ///
    /// println!("res: {:?}", res);
    /// # Ok(())
    /// # }
    /// ```
    #[allow(unused)]
    fn get_latest_template(&self) -> GetLatestSettingsTemplateBuilder {
        GetLatestSettingsTemplateBuilder::default().http_client(self.http_client.clone())
    }

    /// Get a Settings template by version ID.
    ///
    /// <https://api.mangadex.org/swagger.html#/Settings/get-settings-template-version>
    ///
    /// # Examples
    ///
    /// ```ignore
    /// use mangadex_api::v5::MangaDexClient;
    /// use uuid::Uuid;
    ///
    /// # async fn run() -> anyhow::Result<()> {
    /// let client = MangaDexClient::default();
    ///
    /// let version_id = Uuid::new_v4();
    /// let res = client
    ///     .settings()
    ///     .get_template_by_version_id()
    ///     .version(&version_id)
    ///     .build()?
    ///     .send()
    ///     .await?;
    ///
    /// println!("res: {:?}", res);
    /// # Ok(())
    /// # }
    /// ```
    #[allow(unused)]
    fn get_template_by_version_id(&self) -> GetSettingsTemplateByVersionIdBuilder {
        GetSettingsTemplateByVersionIdBuilder::default().http_client(self.http_client.clone())
    }

    /// Get a user's Settings.
    ///
    /// <https://api.mangadex.org/swagger.html#/Settings/get-settings>
    ///
    /// # Examples
    ///
    /// ```ignore
    /// use mangadex_api::v5::MangaDexClient;
    /// use uuid::Uuid;
    ///
    /// # async fn run() -> anyhow::Result<()> {
    /// let client = MangaDexClient::default();
    ///
    /// let version_id = Uuid::new_v4();
    /// let res = client
    ///     .settings()
    ///     .get_user_settings()
    ///     .build()?
    ///     .send()
    ///     .await?;
    ///
    /// println!("res: {:?}", res);
    /// # Ok(())
    /// # }
    /// ```
    #[allow(unused)]
    fn get_user_settings(&self) -> GetUserSettingsBuilder {
        GetUserSettingsBuilder::default().http_client(self.http_client.clone())
    }
}