artifacts/apis/
my_account_api.rs

1use super::{configuration, Error};
2use crate::{apis::ResponseContent, models};
3use reqwest::StatusCode;
4use serde::{de, Deserialize, Deserializer, Serialize};
5
6/// struct for passing parameters to the method [`change_password`]
7#[derive(Clone, Debug)]
8pub struct ChangePasswordParams {
9    pub change_password: models::ChangePassword,
10}
11
12impl ChangePasswordParams {
13    pub fn new(change_password: models::ChangePassword) -> Self {
14        Self { change_password }
15    }
16}
17
18/// struct for passing parameters to the method [`get_bank_items`]
19#[derive(Clone, Debug)]
20pub struct GetBankItemsParams {
21    /// Item to search in your bank.
22    pub item_code: Option<String>,
23    /// Page number
24    pub page: Option<u32>,
25    /// Page size
26    pub size: Option<u32>,
27}
28
29impl GetBankItemsParams {
30    pub fn new(item_code: Option<String>, page: Option<u32>, size: Option<u32>) -> Self {
31        Self {
32            item_code,
33            page,
34            size,
35        }
36    }
37}
38
39/// struct for passing parameters to the method [`get_ge_sell_history`]
40#[derive(Clone, Debug)]
41pub struct GetGeSellHistoryParams {
42    /// Order ID to search in your history.
43    pub id: Option<String>,
44    /// Item to search in your history.
45    pub code: Option<String>,
46    /// Page number
47    pub page: Option<u32>,
48    /// Page size
49    pub size: Option<u32>,
50}
51
52impl GetGeSellHistoryParams {
53    pub fn new(
54        id: Option<String>,
55        code: Option<String>,
56        page: Option<u32>,
57        size: Option<u32>,
58    ) -> Self {
59        Self {
60            id,
61            code,
62            page,
63            size,
64        }
65    }
66}
67
68/// struct for passing parameters to the method [`get_ge_sell_orders`]
69#[derive(Clone, Debug)]
70pub struct GetGeSellOrdersParams {
71    /// The code of the item.
72    pub code: Option<String>,
73    /// Page number
74    pub page: Option<u32>,
75    /// Page size
76    pub size: Option<u32>,
77}
78
79impl GetGeSellOrdersParams {
80    pub fn new(code: Option<String>, page: Option<u32>, size: Option<u32>) -> Self {
81        Self { code, page, size }
82    }
83}
84
85/// struct for typed errors of method [`change_password`]
86#[derive(Debug, Clone, Serialize)]
87#[serde(untagged)]
88pub enum ChangePasswordError {
89    /// Please use a different password.
90    Status458(models::ErrorResponseSchema),
91    /// The current password you entered is invalid.
92    Status459(models::ErrorResponseSchema),
93    /// Request could not be processed due to an invalid payload.
94    Status422(models::ErrorResponseSchema),
95}
96
97impl<'de> Deserialize<'de> for ChangePasswordError {
98    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
99    where
100        D: Deserializer<'de>,
101    {
102        let raw = models::ErrorResponseSchema::deserialize(deserializer)?;
103        match raw.error.code {
104            458 => Ok(Self::Status458(raw)),
105            459 => Ok(Self::Status459(raw)),
106            422 => Ok(Self::Status422(raw)),
107            _ => Err(de::Error::custom(format!(
108                "Unexpected error code: {}",
109                raw.error.code
110            ))),
111        }
112    }
113}
114
115/// struct for typed errors of method [`get_account_details`]
116#[derive(Debug, Clone, Serialize)]
117#[serde(untagged)]
118pub enum GetAccountDetailsError {}
119
120impl<'de> Deserialize<'de> for GetAccountDetailsError {
121    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
122    where
123        D: Deserializer<'de>,
124    {
125        let raw = models::ErrorResponseSchema::deserialize(deserializer)?;
126        Err(de::Error::custom(format!(
127            "Unexpected error code: {}",
128            raw.error.code
129        )))
130    }
131}
132
133/// struct for typed errors of method [`get_bank_details`]
134#[derive(Debug, Clone, Serialize)]
135#[serde(untagged)]
136pub enum GetBankDetailsError {}
137
138impl<'de> Deserialize<'de> for GetBankDetailsError {
139    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
140    where
141        D: Deserializer<'de>,
142    {
143        let raw = models::ErrorResponseSchema::deserialize(deserializer)?;
144        Err(de::Error::custom(format!(
145            "Unexpected error code: {}",
146            raw.error.code
147        )))
148    }
149}
150
151/// struct for typed errors of method [`get_bank_items`]
152#[derive(Debug, Clone, Serialize)]
153#[serde(untagged)]
154pub enum GetBankItemsError {}
155
156impl<'de> Deserialize<'de> for GetBankItemsError {
157    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
158    where
159        D: Deserializer<'de>,
160    {
161        let raw = models::ErrorResponseSchema::deserialize(deserializer)?;
162        Err(de::Error::custom(format!(
163            "Unexpected error code: {}",
164            raw.error.code
165        )))
166    }
167}
168
169/// struct for typed errors of method [`get_ge_sell_history`]
170#[derive(Debug, Clone, Serialize)]
171#[serde(untagged)]
172pub enum GetGeSellHistoryError {}
173
174impl<'de> Deserialize<'de> for GetGeSellHistoryError {
175    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
176    where
177        D: Deserializer<'de>,
178    {
179        let raw = models::ErrorResponseSchema::deserialize(deserializer)?;
180        Err(de::Error::custom(format!(
181            "Unexpected error code: {}",
182            raw.error.code
183        )))
184    }
185}
186
187/// struct for typed errors of method [`get_ge_sell_orders`]
188#[derive(Debug, Clone, Serialize)]
189#[serde(untagged)]
190pub enum GetGeSellOrdersError {}
191
192impl<'de> Deserialize<'de> for GetGeSellOrdersError {
193    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
194    where
195        D: Deserializer<'de>,
196    {
197        let raw = models::ErrorResponseSchema::deserialize(deserializer)?;
198        Err(de::Error::custom(format!(
199            "Unexpected error code: {}",
200            raw.error.code
201        )))
202    }
203}
204
205/// Change your account password. Changing the password reset the account token.
206pub async fn change_password(
207    configuration: &configuration::Configuration,
208    params: ChangePasswordParams,
209) -> Result<models::ResponseSchema, Error<ChangePasswordError>> {
210    let local_var_configuration = configuration;
211
212    // unbox the parameters
213    let change_password = params.change_password;
214
215    let local_var_client = &local_var_configuration.client;
216
217    let local_var_uri_str = format!("{}/my/change_password", local_var_configuration.base_path);
218    let mut local_var_req_builder =
219        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
220
221    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
222        local_var_req_builder =
223            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
224    }
225    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
226        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
227    };
228    local_var_req_builder = local_var_req_builder.json(&change_password);
229
230    let local_var_req = local_var_req_builder.build()?;
231    let local_var_resp = local_var_client.execute(local_var_req).await?;
232
233    let local_var_status = local_var_resp.status();
234    let local_var_content = local_var_resp.text().await?;
235
236    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
237        serde_json::from_str(&local_var_content).map_err(Error::from)
238    } else {
239        let local_var_entity: Option<ChangePasswordError> =
240            serde_json::from_str(&local_var_content).ok();
241        let local_var_error = ResponseContent {
242            status: local_var_status,
243            content: local_var_content,
244            entity: local_var_entity,
245        };
246        Err(Error::ResponseError(local_var_error))
247    }
248}
249
250/// Fetch account details.
251pub async fn get_account_details(
252    configuration: &configuration::Configuration,
253) -> Result<models::MyAccountDetailsSchema, Error<GetAccountDetailsError>> {
254    let local_var_configuration = configuration;
255
256    let local_var_client = &local_var_configuration.client;
257
258    let local_var_uri_str = format!("{}/my/details", local_var_configuration.base_path);
259    let mut local_var_req_builder =
260        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
261
262    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
263        local_var_req_builder =
264            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
265    }
266    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
267        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
268    };
269
270    let local_var_req = local_var_req_builder.build()?;
271    let local_var_resp = local_var_client.execute(local_var_req).await?;
272
273    let local_var_status = local_var_resp.status();
274    let local_var_content = local_var_resp.text().await?;
275
276    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
277        serde_json::from_str(&local_var_content).map_err(Error::from)
278    } else {
279        let local_var_entity: Option<GetAccountDetailsError> =
280            serde_json::from_str(&local_var_content).ok();
281        let local_var_error = ResponseContent {
282            status: local_var_status,
283            content: local_var_content,
284            entity: local_var_entity,
285        };
286        Err(Error::ResponseError(local_var_error))
287    }
288}
289
290/// Fetch bank details.
291pub async fn get_bank_details(
292    configuration: &configuration::Configuration,
293) -> Result<models::BankResponseSchema, Error<GetBankDetailsError>> {
294    let local_var_configuration = configuration;
295
296    let local_var_client = &local_var_configuration.client;
297
298    let local_var_uri_str = format!("{}/my/bank", local_var_configuration.base_path);
299    let mut local_var_req_builder =
300        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
301
302    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
303        local_var_req_builder =
304            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
305    }
306    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
307        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
308    };
309
310    let local_var_req = local_var_req_builder.build()?;
311    let local_var_resp = local_var_client.execute(local_var_req).await?;
312
313    let local_var_status = local_var_resp.status();
314    let local_var_content = local_var_resp.text().await?;
315
316    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
317        serde_json::from_str(&local_var_content).map_err(Error::from)
318    } else {
319        let local_var_entity: Option<GetBankDetailsError> =
320            serde_json::from_str(&local_var_content).ok();
321        let local_var_error = ResponseContent {
322            status: local_var_status,
323            content: local_var_content,
324            entity: local_var_entity,
325        };
326        Err(Error::ResponseError(local_var_error))
327    }
328}
329
330/// Fetch all items in your bank.
331pub async fn get_bank_items(
332    configuration: &configuration::Configuration,
333    params: GetBankItemsParams,
334) -> Result<models::DataPageSimpleItemSchema, Error<GetBankItemsError>> {
335    let local_var_configuration = configuration;
336
337    // unbox the parameters
338    let item_code = params.item_code;
339    // unbox the parameters
340    let page = params.page;
341    // unbox the parameters
342    let size = params.size;
343
344    let local_var_client = &local_var_configuration.client;
345
346    let local_var_uri_str = format!("{}/my/bank/items", local_var_configuration.base_path);
347    let mut local_var_req_builder =
348        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
349
350    if let Some(ref local_var_str) = item_code {
351        local_var_req_builder =
352            local_var_req_builder.query(&[("item_code", &local_var_str.to_string())]);
353    }
354    if let Some(ref local_var_str) = page {
355        local_var_req_builder =
356            local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
357    }
358    if let Some(ref local_var_str) = size {
359        local_var_req_builder =
360            local_var_req_builder.query(&[("size", &local_var_str.to_string())]);
361    }
362    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
363        local_var_req_builder =
364            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
365    }
366    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
367        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
368    };
369
370    let local_var_req = local_var_req_builder.build()?;
371    let local_var_resp = local_var_client.execute(local_var_req).await?;
372
373    let local_var_status = local_var_resp.status();
374    let local_var_content = local_var_resp.text().await?;
375
376    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
377        serde_json::from_str(&local_var_content).map_err(Error::from)
378    } else {
379        let local_var_entity: Option<GetBankItemsError> =
380            serde_json::from_str(&local_var_content).ok();
381        let local_var_error = ResponseContent {
382            status: local_var_status,
383            content: local_var_content,
384            entity: local_var_entity,
385        };
386        Err(Error::ResponseError(local_var_error))
387    }
388}
389
390/// Fetch your sales history of the last 7 days.
391pub async fn get_ge_sell_history(
392    configuration: &configuration::Configuration,
393    params: GetGeSellHistoryParams,
394) -> Result<models::DataPageGeOrderHistorySchema, Error<GetGeSellHistoryError>> {
395    let local_var_configuration = configuration;
396
397    // unbox the parameters
398    let id = params.id;
399    // unbox the parameters
400    let code = params.code;
401    // unbox the parameters
402    let page = params.page;
403    // unbox the parameters
404    let size = params.size;
405
406    let local_var_client = &local_var_configuration.client;
407
408    let local_var_uri_str = format!(
409        "{}/my/grandexchange/history",
410        local_var_configuration.base_path
411    );
412    let mut local_var_req_builder =
413        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
414
415    if let Some(ref local_var_str) = id {
416        local_var_req_builder = local_var_req_builder.query(&[("id", &local_var_str.to_string())]);
417    }
418    if let Some(ref local_var_str) = code {
419        local_var_req_builder =
420            local_var_req_builder.query(&[("code", &local_var_str.to_string())]);
421    }
422    if let Some(ref local_var_str) = page {
423        local_var_req_builder =
424            local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
425    }
426    if let Some(ref local_var_str) = size {
427        local_var_req_builder =
428            local_var_req_builder.query(&[("size", &local_var_str.to_string())]);
429    }
430    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
431        local_var_req_builder =
432            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
433    }
434    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
435        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
436    };
437
438    let local_var_req = local_var_req_builder.build()?;
439    let local_var_resp = local_var_client.execute(local_var_req).await?;
440
441    let local_var_status = local_var_resp.status();
442    let local_var_content = local_var_resp.text().await?;
443
444    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
445        serde_json::from_str(&local_var_content).map_err(Error::from)
446    } else {
447        let local_var_entity: Option<GetGeSellHistoryError> =
448            serde_json::from_str(&local_var_content).ok();
449        let local_var_error = ResponseContent {
450            status: local_var_status,
451            content: local_var_content,
452            entity: local_var_entity,
453        };
454        Err(Error::ResponseError(local_var_error))
455    }
456}
457
458/// Fetch your sell orders details.
459pub async fn get_ge_sell_orders(
460    configuration: &configuration::Configuration,
461    params: GetGeSellOrdersParams,
462) -> Result<models::DataPageGeOrderSchema, Error<GetGeSellOrdersError>> {
463    let local_var_configuration = configuration;
464
465    // unbox the parameters
466    let code = params.code;
467    // unbox the parameters
468    let page = params.page;
469    // unbox the parameters
470    let size = params.size;
471
472    let local_var_client = &local_var_configuration.client;
473
474    let local_var_uri_str = format!(
475        "{}/my/grandexchange/orders",
476        local_var_configuration.base_path
477    );
478    let mut local_var_req_builder =
479        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
480
481    if let Some(ref local_var_str) = code {
482        local_var_req_builder =
483            local_var_req_builder.query(&[("code", &local_var_str.to_string())]);
484    }
485    if let Some(ref local_var_str) = page {
486        local_var_req_builder =
487            local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
488    }
489    if let Some(ref local_var_str) = size {
490        local_var_req_builder =
491            local_var_req_builder.query(&[("size", &local_var_str.to_string())]);
492    }
493    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
494        local_var_req_builder =
495            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
496    }
497    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
498        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
499    };
500
501    let local_var_req = local_var_req_builder.build()?;
502    let local_var_resp = local_var_client.execute(local_var_req).await?;
503
504    let local_var_status = local_var_resp.status();
505    let local_var_content = local_var_resp.text().await?;
506
507    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
508        serde_json::from_str(&local_var_content).map_err(Error::from)
509    } else {
510        let local_var_entity: Option<GetGeSellOrdersError> =
511            serde_json::from_str(&local_var_content).ok();
512        let local_var_error = ResponseContent {
513            status: local_var_status,
514            content: local_var_content,
515            entity: local_var_entity,
516        };
517        Err(Error::ResponseError(local_var_error))
518    }
519}