modrinth_api/apis/
users_api.rs

1/*
2 * Labrinth
3 *
4 * This documentation doesn't provide a way to test our API. In order to facilitate testing, we recommend the following tools:  - [cURL](https://curl.se/) (recommended, command-line) - [ReqBIN](https://reqbin.com/) (recommended, online) - [Postman](https://www.postman.com/downloads/) - [Insomnia](https://insomnia.rest/) - Your web browser, if you don't need to send headers or a request body  Once you have a working client, you can test that it works by making a `GET` request to `https://staging-api.modrinth.com/`:  ```json {   \"about\": \"Welcome traveler!\",   \"documentation\": \"https://docs.modrinth.com\",   \"name\": \"modrinth-labrinth\",   \"version\": \"2.7.0\" } ```  If you got a response similar to the one above, you can use the Modrinth API! When you want to go live using the production API, use `api.modrinth.com` instead of `staging-api.modrinth.com`.  ## Authentication This API has two options for authentication: personal access tokens and [OAuth2](https://en.wikipedia.org/wiki/OAuth). All tokens are tied to a Modrinth user and use the `Authorization` header of the request.  Example: ``` Authorization: mrp_RNtLRSPmGj2pd1v1ubi52nX7TJJM9sznrmwhAuj511oe4t1jAqAQ3D6Wc8Ic ```  You do not need a token for most requests. Generally speaking, only the following types of requests require a token: - those which create data (such as version creation) - those which modify data (such as editing a project) - those which access private data (such as draft projects, notifications, emails, and payout data)  Each request requiring authentication has a certain scope. For example, to view the email of the user being requested, the token must have the `USER_READ_EMAIL` scope. You can find the list of available scopes [on GitHub](https://github.com/modrinth/labrinth/blob/master/src/models/pats.rs#L15). Making a request with an invalid scope will return a 401 error.  Please note that certain scopes and requests cannot be completed with a personal access token or using OAuth. For example, deleting a user account can only be done through Modrinth's frontend.  ### OAuth2 Applications interacting with the authenticated API should create an OAuth2 application. You can do this in [the developer settings](https://modrinth.com/settings/applications).  Once you have created a client, use the following URL to have a user authorize your client: ``` https://modrinth.com/auth/authorize?client_id=<CLIENT_ID>&redirect_uri=<CALLBACK_URL>&scope=<SCOPE_ONE>+<SCOPE_TWO>+<SCOPE_THREE> ```  Then, use the following URL to get the token: ``` https://api.modrinth.com/_internal/oauth/token ```  This route will be changed in the future to move the `_internal` part to `v3`.  ### Personal access tokens Personal access tokens (PATs) can be generated in from [the user settings](https://modrinth.com/settings/account).  ### GitHub tokens For backwards compatibility purposes, some types of GitHub tokens also work for authenticating a user with Modrinth's API, granting all scopes. **We urge any application still using GitHub tokens to start using personal access tokens for security and reliability purposes.** GitHub tokens will cease to function to authenticate with Modrinth's API as soon as version 3 of the API is made generally available.  ## Cross-Origin Resource Sharing This API features Cross-Origin Resource Sharing (CORS) implemented in compliance with the [W3C spec](https://www.w3.org/TR/cors/). This allows for cross-domain communication from the browser. All responses have a wildcard same-origin which makes them completely public and accessible to everyone, including any code on any site.  ## Identifiers The majority of items you can interact with in the API have a unique eight-digit base62 ID. Projects, versions, users, threads, teams, and reports all use this same way of identifying themselves. Version files use the sha1 or sha512 file hashes as identifiers.  Each project and user has a friendlier way of identifying them; slugs and usernames, respectively. While unique IDs are constant, slugs and usernames can change at any moment. If you want to store something in the long term, it is recommended to use the unique ID.  ## Ratelimits The API has a ratelimit defined per IP. Limits and remaining amounts are given in the response headers. - `X-Ratelimit-Limit`: the maximum number of requests that can be made in a minute - `X-Ratelimit-Remaining`: the number of requests remaining in the current ratelimit window - `X-Ratelimit-Reset`: the time in seconds until the ratelimit window resets  Ratelimits are the same no matter whether you use a token or not. The ratelimit is currently 300 requests per minute. If you have a use case requiring a higher limit, please [contact us](mailto:admin@modrinth.com).  ## User Agents To access the Modrinth API, you **must** use provide a uniquely-identifying `User-Agent` header. Providing a user agent that only identifies your HTTP client library (such as \"okhttp/4.9.3\") increases the likelihood that we will block your traffic. It is recommended, but not required, to include contact information in your user agent. This allows us to contact you if we would like a change in your application's behavior without having to block your traffic. - Bad: `User-Agent: okhttp/4.9.3` - Good: `User-Agent: project_name` - Better: `User-Agent: github_username/project_name/1.56.0` - Best: `User-Agent: github_username/project_name/1.56.0 (launcher.com)` or `User-Agent: github_username/project_name/1.56.0 (contact@launcher.com)`  ## Versioning Modrinth follows a simple pattern for its API versioning. In the event of a breaking API change, the API version in the URL path is bumped, and migration steps will be published below.  When an API is no longer the current one, it will immediately be considered deprecated. No more support will be provided for API versions older than the current one. It will be kept for some time, but this amount of time is not certain.  We will exercise various tactics to get people to update their implementation of our API. One example is by adding something like `STOP USING THIS API` to various data returned by the API.  Once an API version is completely deprecated, it will permanently return a 410 error. Please ensure your application handles these 410 errors.  ### Migrations Inside the following spoiler, you will be able to find all changes between versions of the Modrinth API, accompanied by tips and a guide to migrate applications to newer versions.  Here, you can also find changes for [Minotaur](https://github.com/modrinth/minotaur), Modrinth's official Gradle plugin. Major versions of Minotaur directly correspond to major versions of the Modrinth API.  <details><summary>API v1 to API v2</summary>  These bullet points cover most changes in the v2 API, but please note that fields containing `mod` in most contexts have been shifted to `project`.  For example, in the search route, the field `mod_id` was renamed to `project_id`.  - The search route has been moved from `/api/v1/mod` to `/v2/search` - New project fields: `project_type` (may be `mod` or `modpack`), `moderation_message` (which has a `message` and `body`), `gallery` - New search facet: `project_type` - Alphabetical sort removed (it didn't work and is not possible due to limits in MeiliSearch) - New search fields: `project_type`, `gallery`   - The gallery field is an array of URLs to images that are part of the project's gallery - The gallery is a new feature which allows the user to upload images showcasing their mod to the CDN which will be displayed on their mod page - Internal change: Any project file uploaded to Modrinth is now validated to make sure it's a valid Minecraft mod, Modpack, etc.   - For example, a Forge 1.17 mod with a JAR not containing a mods.toml will not be allowed to be uploaded to Modrinth - In project creation, projects may not upload a mod with no versions to review, however they can be saved as a draft   - Similarly, for version creation, a version may not be uploaded without any files - Donation URLs have been enabled - New project status: `archived`. Projects with this status do not appear in search - Tags (such as categories, loaders) now have icons (SVGs) and specific project types attached - Dependencies have been wiped and replaced with a new system - Notifications now have a `type` field, such as `project_update`  Along with this, project subroutes (such as `/v2/project/{id}/version`) now allow the slug to be used as the ID. This is also the case with user routes.  </details><details><summary>Minotaur v1 to Minotaur v2</summary>  Minotaur 2.x introduced a few breaking changes to how your buildscript is formatted.  First, instead of registering your own `publishModrinth` task, Minotaur now automatically creates a `modrinth` task. As such, you can replace the `task publishModrinth(type: TaskModrinthUpload) {` line with just `modrinth {`.  To declare supported Minecraft versions and mod loaders, the `gameVersions` and `loaders` arrays must now be used. The syntax for these are pretty self-explanatory.  Instead of using `releaseType`, you must now use `versionType`. This was actually changed in v1.2.0, but very few buildscripts have moved on from v1.1.0.  Dependencies have been changed to a special DSL. Create a `dependencies` block within the `modrinth` block, and then use `scope.type(\"project/version\")`. For example, `required.project(\"fabric-api\")` adds a required project dependency on Fabric API.  You may now use the slug anywhere that a project ID was previously required.  </details> 
5 *
6 * The version of the OpenAPI document: v2.7.0/15cf3fc
7 * Contact: support@modrinth.com
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 [`change_user_icon`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum ChangeUserIconError {
22    Status400(models::InvalidInputError),
23    Status404(),
24    UnknownValue(serde_json::Value),
25}
26
27/// struct for typed errors of method [`get_followed_projects`]
28#[derive(Debug, Clone, Serialize, Deserialize)]
29#[serde(untagged)]
30pub enum GetFollowedProjectsError {
31    Status401(models::AuthError),
32    Status404(),
33    UnknownValue(serde_json::Value),
34}
35
36/// struct for typed errors of method [`get_payout_history`]
37#[derive(Debug, Clone, Serialize, Deserialize)]
38#[serde(untagged)]
39pub enum GetPayoutHistoryError {
40    Status401(models::AuthError),
41    Status404(),
42    UnknownValue(serde_json::Value),
43}
44
45/// struct for typed errors of method [`get_user`]
46#[derive(Debug, Clone, Serialize, Deserialize)]
47#[serde(untagged)]
48pub enum GetUserError {
49    Status404(),
50    UnknownValue(serde_json::Value),
51}
52
53/// struct for typed errors of method [`get_user_from_auth`]
54#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum GetUserFromAuthError {
57    Status401(models::AuthError),
58    UnknownValue(serde_json::Value),
59}
60
61/// struct for typed errors of method [`get_user_projects`]
62#[derive(Debug, Clone, Serialize, Deserialize)]
63#[serde(untagged)]
64pub enum GetUserProjectsError {
65    Status404(),
66    UnknownValue(serde_json::Value),
67}
68
69/// struct for typed errors of method [`get_users`]
70#[derive(Debug, Clone, Serialize, Deserialize)]
71#[serde(untagged)]
72pub enum GetUsersError {
73    UnknownValue(serde_json::Value),
74}
75
76/// struct for typed errors of method [`modify_user`]
77#[derive(Debug, Clone, Serialize, Deserialize)]
78#[serde(untagged)]
79pub enum ModifyUserError {
80    Status401(models::AuthError),
81    Status404(),
82    UnknownValue(serde_json::Value),
83}
84
85/// struct for typed errors of method [`withdraw_payout`]
86#[derive(Debug, Clone, Serialize, Deserialize)]
87#[serde(untagged)]
88pub enum WithdrawPayoutError {
89    Status401(models::AuthError),
90    Status404(),
91    UnknownValue(serde_json::Value),
92}
93
94
95/// The new avatar may be up to 2MiB in size.
96pub async fn change_user_icon(configuration: &configuration::Configuration, id_pipe_username: &str, body: Option<std::path::PathBuf>) -> Result<(), Error<ChangeUserIconError>> {
97    let local_var_configuration = configuration;
98
99    let local_var_client = &local_var_configuration.client;
100
101    let local_var_uri_str = format!("{}/user/{term_2}/icon", local_var_configuration.base_path, term_2=crate::apis::urlencode(id_pipe_username));
102    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str());
103
104    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
105        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
106    }
107    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
108        let local_var_key = local_var_apikey.key.clone();
109        let local_var_value = match local_var_apikey.prefix {
110            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
111            None => local_var_key,
112        };
113        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
114    };
115    local_var_req_builder = local_var_req_builder.json(&body);
116
117    let local_var_req = local_var_req_builder.build()?;
118    let local_var_resp = local_var_client.execute(local_var_req).await?;
119
120    let local_var_status = local_var_resp.status();
121    let local_var_content = local_var_resp.text().await?;
122
123    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
124        Ok(())
125    } else {
126        let local_var_entity: Option<ChangeUserIconError> = serde_json::from_str(&local_var_content).ok();
127        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
128        Err(Error::ResponseError(local_var_error))
129    }
130}
131
132pub async fn get_followed_projects(configuration: &configuration::Configuration, id_pipe_username: &str) -> Result<Vec<models::Project>, Error<GetFollowedProjectsError>> {
133    let local_var_configuration = configuration;
134
135    let local_var_client = &local_var_configuration.client;
136
137    let local_var_uri_str = format!("{}/user/{term_2}/follows", local_var_configuration.base_path, term_2=crate::apis::urlencode(id_pipe_username));
138    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
139
140    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
141        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
142    }
143    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
144        let local_var_key = local_var_apikey.key.clone();
145        let local_var_value = match local_var_apikey.prefix {
146            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
147            None => local_var_key,
148        };
149        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
150    };
151
152    let local_var_req = local_var_req_builder.build()?;
153    let local_var_resp = local_var_client.execute(local_var_req).await?;
154
155    let local_var_status = local_var_resp.status();
156    let local_var_content = local_var_resp.text().await?;
157
158    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
159        serde_json::from_str(&local_var_content).map_err(Error::from)
160    } else {
161        let local_var_entity: Option<GetFollowedProjectsError> = serde_json::from_str(&local_var_content).ok();
162        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
163        Err(Error::ResponseError(local_var_error))
164    }
165}
166
167pub async fn get_payout_history(configuration: &configuration::Configuration, id_pipe_username: &str) -> Result<models::UserPayoutHistory, Error<GetPayoutHistoryError>> {
168    let local_var_configuration = configuration;
169
170    let local_var_client = &local_var_configuration.client;
171
172    let local_var_uri_str = format!("{}/user/{term_2}/payouts", local_var_configuration.base_path, term_2=crate::apis::urlencode(id_pipe_username));
173    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
174
175    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
176        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
177    }
178    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
179        let local_var_key = local_var_apikey.key.clone();
180        let local_var_value = match local_var_apikey.prefix {
181            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
182            None => local_var_key,
183        };
184        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
185    };
186
187    let local_var_req = local_var_req_builder.build()?;
188    let local_var_resp = local_var_client.execute(local_var_req).await?;
189
190    let local_var_status = local_var_resp.status();
191    let local_var_content = local_var_resp.text().await?;
192
193    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
194        serde_json::from_str(&local_var_content).map_err(Error::from)
195    } else {
196        let local_var_entity: Option<GetPayoutHistoryError> = serde_json::from_str(&local_var_content).ok();
197        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
198        Err(Error::ResponseError(local_var_error))
199    }
200}
201
202pub async fn get_user(configuration: &configuration::Configuration, id_pipe_username: &str) -> Result<models::User, Error<GetUserError>> {
203    let local_var_configuration = configuration;
204
205    let local_var_client = &local_var_configuration.client;
206
207    let local_var_uri_str = format!("{}/user/{term_2}", local_var_configuration.base_path, term_2=crate::apis::urlencode(id_pipe_username));
208    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
209
210    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
211        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
212    }
213
214    let local_var_req = local_var_req_builder.build()?;
215    let local_var_resp = local_var_client.execute(local_var_req).await?;
216
217    let local_var_status = local_var_resp.status();
218    let local_var_content = local_var_resp.text().await?;
219
220    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
221        serde_json::from_str(&local_var_content).map_err(Error::from)
222    } else {
223        let local_var_entity: Option<GetUserError> = serde_json::from_str(&local_var_content).ok();
224        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
225        Err(Error::ResponseError(local_var_error))
226    }
227}
228
229pub async fn get_user_from_auth(configuration: &configuration::Configuration, ) -> Result<models::User, Error<GetUserFromAuthError>> {
230    let local_var_configuration = configuration;
231
232    let local_var_client = &local_var_configuration.client;
233
234    let local_var_uri_str = format!("{}/user", local_var_configuration.base_path);
235    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
236
237    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
238        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
239    }
240    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
241        let local_var_key = local_var_apikey.key.clone();
242        let local_var_value = match local_var_apikey.prefix {
243            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
244            None => local_var_key,
245        };
246        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
247    };
248
249    let local_var_req = local_var_req_builder.build()?;
250    let local_var_resp = local_var_client.execute(local_var_req).await?;
251
252    let local_var_status = local_var_resp.status();
253    let local_var_content = local_var_resp.text().await?;
254
255    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
256        serde_json::from_str(&local_var_content).map_err(Error::from)
257    } else {
258        let local_var_entity: Option<GetUserFromAuthError> = serde_json::from_str(&local_var_content).ok();
259        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
260        Err(Error::ResponseError(local_var_error))
261    }
262}
263
264pub async fn get_user_projects(configuration: &configuration::Configuration, id_pipe_username: &str) -> Result<Vec<models::Project>, Error<GetUserProjectsError>> {
265    let local_var_configuration = configuration;
266
267    let local_var_client = &local_var_configuration.client;
268
269    let local_var_uri_str = format!("{}/user/{term_2}/projects", local_var_configuration.base_path, term_2=crate::apis::urlencode(id_pipe_username));
270    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
271
272    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
273        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
274    }
275
276    let local_var_req = local_var_req_builder.build()?;
277    let local_var_resp = local_var_client.execute(local_var_req).await?;
278
279    let local_var_status = local_var_resp.status();
280    let local_var_content = local_var_resp.text().await?;
281
282    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
283        serde_json::from_str(&local_var_content).map_err(Error::from)
284    } else {
285        let local_var_entity: Option<GetUserProjectsError> = serde_json::from_str(&local_var_content).ok();
286        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
287        Err(Error::ResponseError(local_var_error))
288    }
289}
290
291pub async fn get_users(configuration: &configuration::Configuration, ids: &str) -> Result<Vec<models::User>, Error<GetUsersError>> {
292    let local_var_configuration = configuration;
293
294    let local_var_client = &local_var_configuration.client;
295
296    let local_var_uri_str = format!("{}/users", local_var_configuration.base_path);
297    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
298
299    local_var_req_builder = local_var_req_builder.query(&[("ids", &ids.to_string())]);
300    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
301        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
302    }
303
304    let local_var_req = local_var_req_builder.build()?;
305    let local_var_resp = local_var_client.execute(local_var_req).await?;
306
307    let local_var_status = local_var_resp.status();
308    let local_var_content = local_var_resp.text().await?;
309
310    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
311        serde_json::from_str(&local_var_content).map_err(Error::from)
312    } else {
313        let local_var_entity: Option<GetUsersError> = serde_json::from_str(&local_var_content).ok();
314        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
315        Err(Error::ResponseError(local_var_error))
316    }
317}
318
319pub async fn modify_user(configuration: &configuration::Configuration, id_pipe_username: &str, editable_user: Option<models::EditableUser>) -> Result<(), Error<ModifyUserError>> {
320    let local_var_configuration = configuration;
321
322    let local_var_client = &local_var_configuration.client;
323
324    let local_var_uri_str = format!("{}/user/{term_2}", local_var_configuration.base_path, term_2=crate::apis::urlencode(id_pipe_username));
325    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str());
326
327    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
328        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
329    }
330    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
331        let local_var_key = local_var_apikey.key.clone();
332        let local_var_value = match local_var_apikey.prefix {
333            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
334            None => local_var_key,
335        };
336        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
337    };
338    local_var_req_builder = local_var_req_builder.json(&editable_user);
339
340    let local_var_req = local_var_req_builder.build()?;
341    let local_var_resp = local_var_client.execute(local_var_req).await?;
342
343    let local_var_status = local_var_resp.status();
344    let local_var_content = local_var_resp.text().await?;
345
346    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
347        Ok(())
348    } else {
349        let local_var_entity: Option<ModifyUserError> = serde_json::from_str(&local_var_content).ok();
350        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
351        Err(Error::ResponseError(local_var_error))
352    }
353}
354
355/// Warning: certain amounts get withheld for fees. Please do not call this API endpoint without first acknowledging the warnings on the corresponding frontend page.
356pub async fn withdraw_payout(configuration: &configuration::Configuration, id_pipe_username: &str, amount: i32) -> Result<(), Error<WithdrawPayoutError>> {
357    let local_var_configuration = configuration;
358
359    let local_var_client = &local_var_configuration.client;
360
361    let local_var_uri_str = format!("{}/user/{term_2}/payouts", local_var_configuration.base_path, term_2=crate::apis::urlencode(id_pipe_username));
362    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
363
364    local_var_req_builder = local_var_req_builder.query(&[("amount", &amount.to_string())]);
365    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
366        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
367    }
368    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
369        let local_var_key = local_var_apikey.key.clone();
370        let local_var_value = match local_var_apikey.prefix {
371            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
372            None => local_var_key,
373        };
374        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
375    };
376
377    let local_var_req = local_var_req_builder.build()?;
378    let local_var_resp = local_var_client.execute(local_var_req).await?;
379
380    let local_var_status = local_var_resp.status();
381    let local_var_content = local_var_resp.text().await?;
382
383    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
384        Ok(())
385    } else {
386        let local_var_entity: Option<WithdrawPayoutError> = serde_json::from_str(&local_var_content).ok();
387        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
388        Err(Error::ResponseError(local_var_error))
389    }
390}
391