artifacts/apis/
my_account_api.rs

1use super::{configuration, Error};
2use crate::{apis::ResponseContent, models};
3use reqwest::StatusCode;
4use serde::{Deserialize, 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, Deserialize)]
87#[serde(untagged)]
88pub enum ChangePasswordError {
89    /// Please use a different password.
90    Status458,
91    /// The current password you entered is invalid.
92    Status459,
93}
94
95impl TryFrom<StatusCode> for ChangePasswordError {
96    type Error = &'static str;
97    #[allow(clippy::match_single_binding)]
98    fn try_from(status: StatusCode) -> Result<Self, Self::Error> {
99        match status.as_u16() {
100            458 => Ok(Self::Status458),
101            459 => Ok(Self::Status459),
102            _ => Err("status code not in spec"),
103        }
104    }
105}
106
107/// struct for typed errors of method [`get_account_details`]
108#[derive(Debug, Clone, Serialize, Deserialize)]
109#[serde(untagged)]
110pub enum GetAccountDetailsError {}
111
112impl TryFrom<StatusCode> for GetAccountDetailsError {
113    type Error = &'static str;
114    #[allow(clippy::match_single_binding)]
115    fn try_from(status: StatusCode) -> Result<Self, Self::Error> {
116        match status.as_u16() {
117            _ => Err("status code not in spec"),
118        }
119    }
120}
121
122/// struct for typed errors of method [`get_bank_details`]
123#[derive(Debug, Clone, Serialize, Deserialize)]
124#[serde(untagged)]
125pub enum GetBankDetailsError {}
126
127impl TryFrom<StatusCode> for GetBankDetailsError {
128    type Error = &'static str;
129    #[allow(clippy::match_single_binding)]
130    fn try_from(status: StatusCode) -> Result<Self, Self::Error> {
131        match status.as_u16() {
132            _ => Err("status code not in spec"),
133        }
134    }
135}
136
137/// struct for typed errors of method [`get_bank_items`]
138#[derive(Debug, Clone, Serialize, Deserialize)]
139#[serde(untagged)]
140pub enum GetBankItemsError {}
141
142impl TryFrom<StatusCode> for GetBankItemsError {
143    type Error = &'static str;
144    #[allow(clippy::match_single_binding)]
145    fn try_from(status: StatusCode) -> Result<Self, Self::Error> {
146        match status.as_u16() {
147            _ => Err("status code not in spec"),
148        }
149    }
150}
151
152/// struct for typed errors of method [`get_ge_sell_history`]
153#[derive(Debug, Clone, Serialize, Deserialize)]
154#[serde(untagged)]
155pub enum GetGeSellHistoryError {}
156
157impl TryFrom<StatusCode> for GetGeSellHistoryError {
158    type Error = &'static str;
159    #[allow(clippy::match_single_binding)]
160    fn try_from(status: StatusCode) -> Result<Self, Self::Error> {
161        match status.as_u16() {
162            _ => Err("status code not in spec"),
163        }
164    }
165}
166
167/// struct for typed errors of method [`get_ge_sell_orders`]
168#[derive(Debug, Clone, Serialize, Deserialize)]
169#[serde(untagged)]
170pub enum GetGeSellOrdersError {}
171
172impl TryFrom<StatusCode> for GetGeSellOrdersError {
173    type Error = &'static str;
174    #[allow(clippy::match_single_binding)]
175    fn try_from(status: StatusCode) -> Result<Self, Self::Error> {
176        match status.as_u16() {
177            _ => Err("status code not in spec"),
178        }
179    }
180}
181
182/// Change your account password. Changing the password reset the account token.
183pub async fn change_password(
184    configuration: &configuration::Configuration,
185    params: ChangePasswordParams,
186) -> Result<models::ResponseSchema, Error<ChangePasswordError>> {
187    let local_var_configuration = configuration;
188
189    // unbox the parameters
190    let change_password = params.change_password;
191
192    let local_var_client = &local_var_configuration.client;
193
194    let local_var_uri_str = format!("{}/my/change_password", local_var_configuration.base_path);
195    let mut local_var_req_builder =
196        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
197
198    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
199        local_var_req_builder =
200            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
201    }
202    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
203        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
204    };
205    local_var_req_builder = local_var_req_builder.json(&change_password);
206
207    let local_var_req = local_var_req_builder.build()?;
208    let local_var_resp = local_var_client.execute(local_var_req).await?;
209
210    let local_var_status = local_var_resp.status();
211    let local_var_content = local_var_resp.text().await?;
212
213    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
214        serde_json::from_str(&local_var_content).map_err(Error::from)
215    } else {
216        let local_var_entity: Option<ChangePasswordError> = local_var_status.try_into().ok();
217        let local_var_error = ResponseContent {
218            status: local_var_status,
219            content: local_var_content,
220            entity: local_var_entity,
221        };
222        Err(Error::ResponseError(local_var_error))
223    }
224}
225
226/// Fetch account details.
227pub async fn get_account_details(
228    configuration: &configuration::Configuration,
229) -> Result<models::MyAccountDetailsSchema, Error<GetAccountDetailsError>> {
230    let local_var_configuration = configuration;
231
232    let local_var_client = &local_var_configuration.client;
233
234    let local_var_uri_str = format!("{}/my/details", local_var_configuration.base_path);
235    let mut local_var_req_builder =
236        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
237
238    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
239        local_var_req_builder =
240            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
241    }
242    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
243        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
244    };
245
246    let local_var_req = local_var_req_builder.build()?;
247    let local_var_resp = local_var_client.execute(local_var_req).await?;
248
249    let local_var_status = local_var_resp.status();
250    let local_var_content = local_var_resp.text().await?;
251
252    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
253        serde_json::from_str(&local_var_content).map_err(Error::from)
254    } else {
255        let local_var_entity: Option<GetAccountDetailsError> = local_var_status.try_into().ok();
256        let local_var_error = ResponseContent {
257            status: local_var_status,
258            content: local_var_content,
259            entity: local_var_entity,
260        };
261        Err(Error::ResponseError(local_var_error))
262    }
263}
264
265/// Fetch bank details.
266pub async fn get_bank_details(
267    configuration: &configuration::Configuration,
268) -> Result<models::BankResponseSchema, Error<GetBankDetailsError>> {
269    let local_var_configuration = configuration;
270
271    let local_var_client = &local_var_configuration.client;
272
273    let local_var_uri_str = format!("{}/my/bank", local_var_configuration.base_path);
274    let mut local_var_req_builder =
275        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
276
277    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
278        local_var_req_builder =
279            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
280    }
281    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
282        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
283    };
284
285    let local_var_req = local_var_req_builder.build()?;
286    let local_var_resp = local_var_client.execute(local_var_req).await?;
287
288    let local_var_status = local_var_resp.status();
289    let local_var_content = local_var_resp.text().await?;
290
291    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
292        serde_json::from_str(&local_var_content).map_err(Error::from)
293    } else {
294        let local_var_entity: Option<GetBankDetailsError> = local_var_status.try_into().ok();
295        let local_var_error = ResponseContent {
296            status: local_var_status,
297            content: local_var_content,
298            entity: local_var_entity,
299        };
300        Err(Error::ResponseError(local_var_error))
301    }
302}
303
304/// Fetch all items in your bank.
305pub async fn get_bank_items(
306    configuration: &configuration::Configuration,
307    params: GetBankItemsParams,
308) -> Result<models::DataPageSimpleItemSchema, Error<GetBankItemsError>> {
309    let local_var_configuration = configuration;
310
311    // unbox the parameters
312    let item_code = params.item_code;
313    // unbox the parameters
314    let page = params.page;
315    // unbox the parameters
316    let size = params.size;
317
318    let local_var_client = &local_var_configuration.client;
319
320    let local_var_uri_str = format!("{}/my/bank/items", local_var_configuration.base_path);
321    let mut local_var_req_builder =
322        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
323
324    if let Some(ref local_var_str) = item_code {
325        local_var_req_builder =
326            local_var_req_builder.query(&[("item_code", &local_var_str.to_string())]);
327    }
328    if let Some(ref local_var_str) = page {
329        local_var_req_builder =
330            local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
331    }
332    if let Some(ref local_var_str) = size {
333        local_var_req_builder =
334            local_var_req_builder.query(&[("size", &local_var_str.to_string())]);
335    }
336    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
337        local_var_req_builder =
338            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
339    }
340    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
341        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
342    };
343
344    let local_var_req = local_var_req_builder.build()?;
345    let local_var_resp = local_var_client.execute(local_var_req).await?;
346
347    let local_var_status = local_var_resp.status();
348    let local_var_content = local_var_resp.text().await?;
349
350    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
351        serde_json::from_str(&local_var_content).map_err(Error::from)
352    } else {
353        let local_var_entity: Option<GetBankItemsError> = local_var_status.try_into().ok();
354        let local_var_error = ResponseContent {
355            status: local_var_status,
356            content: local_var_content,
357            entity: local_var_entity,
358        };
359        Err(Error::ResponseError(local_var_error))
360    }
361}
362
363/// Fetch your sales history of the last 7 days.
364pub async fn get_ge_sell_history(
365    configuration: &configuration::Configuration,
366    params: GetGeSellHistoryParams,
367) -> Result<models::DataPageGeOrderHistorySchema, Error<GetGeSellHistoryError>> {
368    let local_var_configuration = configuration;
369
370    // unbox the parameters
371    let id = params.id;
372    // unbox the parameters
373    let code = params.code;
374    // unbox the parameters
375    let page = params.page;
376    // unbox the parameters
377    let size = params.size;
378
379    let local_var_client = &local_var_configuration.client;
380
381    let local_var_uri_str = format!(
382        "{}/my/grandexchange/history",
383        local_var_configuration.base_path
384    );
385    let mut local_var_req_builder =
386        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
387
388    if let Some(ref local_var_str) = id {
389        local_var_req_builder = local_var_req_builder.query(&[("id", &local_var_str.to_string())]);
390    }
391    if let Some(ref local_var_str) = code {
392        local_var_req_builder =
393            local_var_req_builder.query(&[("code", &local_var_str.to_string())]);
394    }
395    if let Some(ref local_var_str) = page {
396        local_var_req_builder =
397            local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
398    }
399    if let Some(ref local_var_str) = size {
400        local_var_req_builder =
401            local_var_req_builder.query(&[("size", &local_var_str.to_string())]);
402    }
403    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
404        local_var_req_builder =
405            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
406    }
407    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
408        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
409    };
410
411    let local_var_req = local_var_req_builder.build()?;
412    let local_var_resp = local_var_client.execute(local_var_req).await?;
413
414    let local_var_status = local_var_resp.status();
415    let local_var_content = local_var_resp.text().await?;
416
417    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
418        serde_json::from_str(&local_var_content).map_err(Error::from)
419    } else {
420        let local_var_entity: Option<GetGeSellHistoryError> = local_var_status.try_into().ok();
421        let local_var_error = ResponseContent {
422            status: local_var_status,
423            content: local_var_content,
424            entity: local_var_entity,
425        };
426        Err(Error::ResponseError(local_var_error))
427    }
428}
429
430/// Fetch your sell orders details.
431pub async fn get_ge_sell_orders(
432    configuration: &configuration::Configuration,
433    params: GetGeSellOrdersParams,
434) -> Result<models::DataPageGeOrderSchema, Error<GetGeSellOrdersError>> {
435    let local_var_configuration = configuration;
436
437    // unbox the parameters
438    let code = params.code;
439    // unbox the parameters
440    let page = params.page;
441    // unbox the parameters
442    let size = params.size;
443
444    let local_var_client = &local_var_configuration.client;
445
446    let local_var_uri_str = format!(
447        "{}/my/grandexchange/orders",
448        local_var_configuration.base_path
449    );
450    let mut local_var_req_builder =
451        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
452
453    if let Some(ref local_var_str) = code {
454        local_var_req_builder =
455            local_var_req_builder.query(&[("code", &local_var_str.to_string())]);
456    }
457    if let Some(ref local_var_str) = page {
458        local_var_req_builder =
459            local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
460    }
461    if let Some(ref local_var_str) = size {
462        local_var_req_builder =
463            local_var_req_builder.query(&[("size", &local_var_str.to_string())]);
464    }
465    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
466        local_var_req_builder =
467            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
468    }
469    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
470        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
471    };
472
473    let local_var_req = local_var_req_builder.build()?;
474    let local_var_resp = local_var_client.execute(local_var_req).await?;
475
476    let local_var_status = local_var_resp.status();
477    let local_var_content = local_var_resp.text().await?;
478
479    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
480        serde_json::from_str(&local_var_content).map_err(Error::from)
481    } else {
482        let local_var_entity: Option<GetGeSellOrdersError> = local_var_status.try_into().ok();
483        let local_var_error = ResponseContent {
484            status: local_var_status,
485            content: local_var_content,
486            entity: local_var_entity,
487        };
488        Err(Error::ResponseError(local_var_error))
489    }
490}