Skip to main content

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_history`]
40#[derive(Clone, Debug)]
41pub struct GetGeHistoryParams {
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 GetGeHistoryParams {
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_orders`]
69#[derive(Clone, Debug)]
70pub struct GetGeOrdersParams {
71    /// The code of the item.
72    pub code: Option<String>,
73    /// Filter by order type (sell or buy).
74    pub r#type: Option<models::GeOrderType>,
75    /// Page number
76    pub page: Option<u32>,
77    /// Page size
78    pub size: Option<u32>,
79}
80
81impl GetGeOrdersParams {
82    pub fn new(
83        code: Option<String>,
84        r#type: Option<models::GeOrderType>,
85        page: Option<u32>,
86        size: Option<u32>,
87    ) -> Self {
88        Self {
89            code,
90            r#type,
91            page,
92            size,
93        }
94    }
95}
96
97/// struct for passing parameters to the method [`get_pending_items`]
98#[derive(Clone, Debug)]
99pub struct GetPendingItemsParams {
100    /// Page number
101    pub page: Option<u32>,
102    /// Page size
103    pub size: Option<u32>,
104}
105
106impl GetPendingItemsParams {
107    pub fn new(page: Option<u32>, size: Option<u32>) -> Self {
108        Self { page, size }
109    }
110}
111
112/// struct for typed errors of method [`change_password`]
113#[derive(Debug, Clone, Serialize)]
114#[serde(untagged)]
115pub enum ChangePasswordError {
116    /// Please use a different password.
117    Status458(models::ErrorResponseSchema),
118    /// The current password you entered is invalid.
119    Status459(models::ErrorResponseSchema),
120    /// Request could not be processed due to an invalid payload.
121    Status422(models::ErrorResponseSchema),
122}
123
124impl<'de> Deserialize<'de> for ChangePasswordError {
125    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
126    where
127        D: Deserializer<'de>,
128    {
129        let raw = models::ErrorResponseSchema::deserialize(deserializer)?;
130        match raw.error.code {
131            458 => Ok(Self::Status458(raw)),
132            459 => Ok(Self::Status459(raw)),
133            422 => Ok(Self::Status422(raw)),
134            _ => Err(de::Error::custom(format!(
135                "Unexpected error code: {}",
136                raw.error.code
137            ))),
138        }
139    }
140}
141
142/// struct for typed errors of method [`get_account_details`]
143#[derive(Debug, Clone, Serialize)]
144#[serde(untagged)]
145pub enum GetAccountDetailsError {}
146
147impl<'de> Deserialize<'de> for GetAccountDetailsError {
148    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
149    where
150        D: Deserializer<'de>,
151    {
152        let raw = models::ErrorResponseSchema::deserialize(deserializer)?;
153        Err(de::Error::custom(format!(
154            "Unexpected error code: {}",
155            raw.error.code
156        )))
157    }
158}
159
160/// struct for typed errors of method [`get_bank_details`]
161#[derive(Debug, Clone, Serialize)]
162#[serde(untagged)]
163pub enum GetBankDetailsError {}
164
165impl<'de> Deserialize<'de> for GetBankDetailsError {
166    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
167    where
168        D: Deserializer<'de>,
169    {
170        let raw = models::ErrorResponseSchema::deserialize(deserializer)?;
171        Err(de::Error::custom(format!(
172            "Unexpected error code: {}",
173            raw.error.code
174        )))
175    }
176}
177
178/// struct for typed errors of method [`get_bank_items`]
179#[derive(Debug, Clone, Serialize)]
180#[serde(untagged)]
181pub enum GetBankItemsError {}
182
183impl<'de> Deserialize<'de> for GetBankItemsError {
184    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
185    where
186        D: Deserializer<'de>,
187    {
188        let raw = models::ErrorResponseSchema::deserialize(deserializer)?;
189        Err(de::Error::custom(format!(
190            "Unexpected error code: {}",
191            raw.error.code
192        )))
193    }
194}
195
196/// struct for typed errors of method [`get_ge_history`]
197#[derive(Debug, Clone, Serialize)]
198#[serde(untagged)]
199pub enum GetGeHistoryError {}
200
201impl<'de> Deserialize<'de> for GetGeHistoryError {
202    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
203    where
204        D: Deserializer<'de>,
205    {
206        let raw = models::ErrorResponseSchema::deserialize(deserializer)?;
207        Err(de::Error::custom(format!(
208            "Unexpected error code: {}",
209            raw.error.code
210        )))
211    }
212}
213
214/// struct for typed errors of method [`get_ge_orders`]
215#[derive(Debug, Clone, Serialize)]
216#[serde(untagged)]
217pub enum GetGeOrdersError {}
218
219impl<'de> Deserialize<'de> for GetGeOrdersError {
220    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
221    where
222        D: Deserializer<'de>,
223    {
224        let raw = models::ErrorResponseSchema::deserialize(deserializer)?;
225        Err(de::Error::custom(format!(
226            "Unexpected error code: {}",
227            raw.error.code
228        )))
229    }
230}
231
232/// struct for typed errors of method [`get_pending_items`]
233#[derive(Debug, Clone, Serialize)]
234#[serde(untagged)]
235pub enum GetPendingItemsError {}
236
237impl<'de> Deserialize<'de> for GetPendingItemsError {
238    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
239    where
240        D: Deserializer<'de>,
241    {
242        let raw = models::ErrorResponseSchema::deserialize(deserializer)?;
243        Err(de::Error::custom(format!(
244            "Unexpected error code: {}",
245            raw.error.code
246        )))
247    }
248}
249
250/// Change your account password. Changing the password reset the account token.
251pub async fn change_password(
252    configuration: &configuration::Configuration,
253    params: ChangePasswordParams,
254) -> Result<models::ResponseSchema, Error<ChangePasswordError>> {
255    let local_var_configuration = configuration;
256
257    // unbox the parameters
258    let change_password = params.change_password;
259
260    let local_var_client = &local_var_configuration.client;
261
262    let local_var_uri_str = format!("{}/my/change_password", local_var_configuration.base_path);
263    let mut local_var_req_builder =
264        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
265
266    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
267        local_var_req_builder =
268            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
269    }
270    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
271        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
272    };
273    local_var_req_builder = local_var_req_builder.json(&change_password);
274
275    let local_var_req = local_var_req_builder.build()?;
276    let local_var_resp = local_var_client.execute(local_var_req).await?;
277
278    let local_var_status = local_var_resp.status();
279    let local_var_content = local_var_resp.text().await?;
280
281    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
282        serde_json::from_str(&local_var_content).map_err(Error::from)
283    } else {
284        let local_var_entity: Option<ChangePasswordError> =
285            serde_json::from_str(&local_var_content).ok();
286        let local_var_error = ResponseContent {
287            status: local_var_status,
288            content: local_var_content,
289            entity: local_var_entity,
290        };
291        Err(Error::ResponseError(local_var_error))
292    }
293}
294
295/// Fetch account details.
296pub async fn get_account_details(
297    configuration: &configuration::Configuration,
298) -> Result<models::MyAccountDetailsSchema, Error<GetAccountDetailsError>> {
299    let local_var_configuration = configuration;
300
301    let local_var_client = &local_var_configuration.client;
302
303    let local_var_uri_str = format!("{}/my/details", local_var_configuration.base_path);
304    let mut local_var_req_builder =
305        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
306
307    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
308        local_var_req_builder =
309            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
310    }
311    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
312        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
313    };
314
315    let local_var_req = local_var_req_builder.build()?;
316    let local_var_resp = local_var_client.execute(local_var_req).await?;
317
318    let local_var_status = local_var_resp.status();
319    let local_var_content = local_var_resp.text().await?;
320
321    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
322        serde_json::from_str(&local_var_content).map_err(Error::from)
323    } else {
324        let local_var_entity: Option<GetAccountDetailsError> =
325            serde_json::from_str(&local_var_content).ok();
326        let local_var_error = ResponseContent {
327            status: local_var_status,
328            content: local_var_content,
329            entity: local_var_entity,
330        };
331        Err(Error::ResponseError(local_var_error))
332    }
333}
334
335/// Fetch bank details.
336pub async fn get_bank_details(
337    configuration: &configuration::Configuration,
338) -> Result<models::BankResponseSchema, Error<GetBankDetailsError>> {
339    let local_var_configuration = configuration;
340
341    let local_var_client = &local_var_configuration.client;
342
343    let local_var_uri_str = format!("{}/my/bank", local_var_configuration.base_path);
344    let mut local_var_req_builder =
345        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
346
347    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
348        local_var_req_builder =
349            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
350    }
351    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
352        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
353    };
354
355    let local_var_req = local_var_req_builder.build()?;
356    let local_var_resp = local_var_client.execute(local_var_req).await?;
357
358    let local_var_status = local_var_resp.status();
359    let local_var_content = local_var_resp.text().await?;
360
361    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
362        serde_json::from_str(&local_var_content).map_err(Error::from)
363    } else {
364        let local_var_entity: Option<GetBankDetailsError> =
365            serde_json::from_str(&local_var_content).ok();
366        let local_var_error = ResponseContent {
367            status: local_var_status,
368            content: local_var_content,
369            entity: local_var_entity,
370        };
371        Err(Error::ResponseError(local_var_error))
372    }
373}
374
375/// Fetch all items in your bank.
376pub async fn get_bank_items(
377    configuration: &configuration::Configuration,
378    params: GetBankItemsParams,
379) -> Result<models::DataPageSimpleItemSchema, Error<GetBankItemsError>> {
380    let local_var_configuration = configuration;
381
382    // unbox the parameters
383    let item_code = params.item_code;
384    // unbox the parameters
385    let page = params.page;
386    // unbox the parameters
387    let size = params.size;
388
389    let local_var_client = &local_var_configuration.client;
390
391    let local_var_uri_str = format!("{}/my/bank/items", local_var_configuration.base_path);
392    let mut local_var_req_builder =
393        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
394
395    if let Some(ref local_var_str) = item_code {
396        local_var_req_builder =
397            local_var_req_builder.query(&[("item_code", &local_var_str.to_string())]);
398    }
399    if let Some(ref local_var_str) = page {
400        local_var_req_builder =
401            local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
402    }
403    if let Some(ref local_var_str) = size {
404        local_var_req_builder =
405            local_var_req_builder.query(&[("size", &local_var_str.to_string())]);
406    }
407    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
408        local_var_req_builder =
409            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
410    }
411    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
412        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
413    };
414
415    let local_var_req = local_var_req_builder.build()?;
416    let local_var_resp = local_var_client.execute(local_var_req).await?;
417
418    let local_var_status = local_var_resp.status();
419    let local_var_content = local_var_resp.text().await?;
420
421    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
422        serde_json::from_str(&local_var_content).map_err(Error::from)
423    } else {
424        let local_var_entity: Option<GetBankItemsError> =
425            serde_json::from_str(&local_var_content).ok();
426        let local_var_error = ResponseContent {
427            status: local_var_status,
428            content: local_var_content,
429            entity: local_var_entity,
430        };
431        Err(Error::ResponseError(local_var_error))
432    }
433}
434
435/// Fetch your transaction history of the last 7 days (buy and sell orders).
436pub async fn get_ge_history(
437    configuration: &configuration::Configuration,
438    params: GetGeHistoryParams,
439) -> Result<models::DataPageGeOrderHistorySchema, Error<GetGeHistoryError>> {
440    let local_var_configuration = configuration;
441
442    // unbox the parameters
443    let id = params.id;
444    // unbox the parameters
445    let code = params.code;
446    // unbox the parameters
447    let page = params.page;
448    // unbox the parameters
449    let size = params.size;
450
451    let local_var_client = &local_var_configuration.client;
452
453    let local_var_uri_str = format!(
454        "{}/my/grandexchange/history",
455        local_var_configuration.base_path
456    );
457    let mut local_var_req_builder =
458        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
459
460    if let Some(ref local_var_str) = id {
461        local_var_req_builder = local_var_req_builder.query(&[("id", &local_var_str.to_string())]);
462    }
463    if let Some(ref local_var_str) = code {
464        local_var_req_builder =
465            local_var_req_builder.query(&[("code", &local_var_str.to_string())]);
466    }
467    if let Some(ref local_var_str) = page {
468        local_var_req_builder =
469            local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
470    }
471    if let Some(ref local_var_str) = size {
472        local_var_req_builder =
473            local_var_req_builder.query(&[("size", &local_var_str.to_string())]);
474    }
475    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
476        local_var_req_builder =
477            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
478    }
479    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
480        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
481    };
482
483    let local_var_req = local_var_req_builder.build()?;
484    let local_var_resp = local_var_client.execute(local_var_req).await?;
485
486    let local_var_status = local_var_resp.status();
487    let local_var_content = local_var_resp.text().await?;
488
489    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
490        serde_json::from_str(&local_var_content).map_err(Error::from)
491    } else {
492        let local_var_entity: Option<GetGeHistoryError> =
493            serde_json::from_str(&local_var_content).ok();
494        let local_var_error = ResponseContent {
495            status: local_var_status,
496            content: local_var_content,
497            entity: local_var_entity,
498        };
499        Err(Error::ResponseError(local_var_error))
500    }
501}
502
503/// Fetch your orders details (sell and buy orders).
504pub async fn get_ge_orders(
505    configuration: &configuration::Configuration,
506    params: GetGeOrdersParams,
507) -> Result<models::DataPageGeOrderSchema, Error<GetGeOrdersError>> {
508    let local_var_configuration = configuration;
509
510    // unbox the parameters
511    let code = params.code;
512    // unbox the parameters
513    let r#type = params.r#type;
514    // unbox the parameters
515    let page = params.page;
516    // unbox the parameters
517    let size = params.size;
518
519    let local_var_client = &local_var_configuration.client;
520
521    let local_var_uri_str = format!(
522        "{}/my/grandexchange/orders",
523        local_var_configuration.base_path
524    );
525    let mut local_var_req_builder =
526        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
527
528    if let Some(ref local_var_str) = code {
529        local_var_req_builder =
530            local_var_req_builder.query(&[("code", &local_var_str.to_string())]);
531    }
532    if let Some(ref local_var_str) = r#type {
533        local_var_req_builder =
534            local_var_req_builder.query(&[("type", &local_var_str.to_string())]);
535    }
536    if let Some(ref local_var_str) = page {
537        local_var_req_builder =
538            local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
539    }
540    if let Some(ref local_var_str) = size {
541        local_var_req_builder =
542            local_var_req_builder.query(&[("size", &local_var_str.to_string())]);
543    }
544    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
545        local_var_req_builder =
546            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
547    }
548    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
549        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
550    };
551
552    let local_var_req = local_var_req_builder.build()?;
553    let local_var_resp = local_var_client.execute(local_var_req).await?;
554
555    let local_var_status = local_var_resp.status();
556    let local_var_content = local_var_resp.text().await?;
557
558    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
559        serde_json::from_str(&local_var_content).map_err(Error::from)
560    } else {
561        let local_var_entity: Option<GetGeOrdersError> =
562            serde_json::from_str(&local_var_content).ok();
563        let local_var_error = ResponseContent {
564            status: local_var_status,
565            content: local_var_content,
566            entity: local_var_entity,
567        };
568        Err(Error::ResponseError(local_var_error))
569    }
570}
571
572/// Retrieve all unclaimed pending items for your account.  These are items from various sources (achievements, grand exchange, events, etc.) that can be claimed by any character on your account using /my/{name}/action/claim/{id}.
573pub async fn get_pending_items(
574    configuration: &configuration::Configuration,
575    params: GetPendingItemsParams,
576) -> Result<models::DataPagePendingItemSchema, Error<GetPendingItemsError>> {
577    let local_var_configuration = configuration;
578
579    // unbox the parameters
580    let page = params.page;
581    // unbox the parameters
582    let size = params.size;
583
584    let local_var_client = &local_var_configuration.client;
585
586    let local_var_uri_str = format!("{}/my/pending-items", local_var_configuration.base_path);
587    let mut local_var_req_builder =
588        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
589
590    if let Some(ref local_var_str) = page {
591        local_var_req_builder =
592            local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
593    }
594    if let Some(ref local_var_str) = size {
595        local_var_req_builder =
596            local_var_req_builder.query(&[("size", &local_var_str.to_string())]);
597    }
598    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
599        local_var_req_builder =
600            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
601    }
602    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
603        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
604    };
605
606    let local_var_req = local_var_req_builder.build()?;
607    let local_var_resp = local_var_client.execute(local_var_req).await?;
608
609    let local_var_status = local_var_resp.status();
610    let local_var_content = local_var_resp.text().await?;
611
612    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
613        serde_json::from_str(&local_var_content).map_err(Error::from)
614    } else {
615        let local_var_entity: Option<GetPendingItemsError> =
616            serde_json::from_str(&local_var_content).ok();
617        let local_var_error = ResponseContent {
618            status: local_var_status,
619            content: local_var_content,
620            entity: local_var_entity,
621        };
622        Err(Error::ResponseError(local_var_error))
623    }
624}