1use super::{configuration, Error};
2use crate::{apis::ResponseContent, models};
3use reqwest::StatusCode;
4use serde::{de, Deserialize, Deserializer, Serialize};
5
6#[derive(Clone, Debug)]
8pub struct GetAllMapsParams {
9 pub layer: Option<models::MapLayer>,
11 pub content_type: Option<models::MapContentType>,
13 pub content_code: Option<String>,
15 pub hide_blocked_maps: Option<bool>,
17 pub hide_event: Option<bool>,
19 pub transition: Option<bool>,
21 pub page: Option<u32>,
23 pub size: Option<u32>,
25}
26
27impl GetAllMapsParams {
28 pub fn new(
29 layer: Option<models::MapLayer>,
30 content_type: Option<models::MapContentType>,
31 content_code: Option<String>,
32 hide_blocked_maps: Option<bool>,
33 hide_event: Option<bool>,
34 transition: Option<bool>,
35 page: Option<u32>,
36 size: Option<u32>,
37 ) -> Self {
38 Self {
39 layer,
40 content_type,
41 content_code,
42 hide_blocked_maps,
43 hide_event,
44 transition,
45 page,
46 size,
47 }
48 }
49}
50
51#[derive(Clone, Debug)]
53pub struct GetLayerMapsParams {
54 pub layer: models::MapLayer,
56 pub content_type: Option<models::MapContentType>,
58 pub content_code: Option<String>,
60 pub hide_blocked_maps: Option<bool>,
62 pub hide_event: Option<bool>,
64 pub transition: Option<bool>,
66 pub page: Option<u32>,
68 pub size: Option<u32>,
70}
71
72impl GetLayerMapsParams {
73 pub fn new(
74 layer: models::MapLayer,
75 content_type: Option<models::MapContentType>,
76 content_code: Option<String>,
77 hide_blocked_maps: Option<bool>,
78 hide_event: Option<bool>,
79 transition: Option<bool>,
80 page: Option<u32>,
81 size: Option<u32>,
82 ) -> Self {
83 Self {
84 layer,
85 content_type,
86 content_code,
87 hide_blocked_maps,
88 hide_event,
89 transition,
90 page,
91 size,
92 }
93 }
94}
95
96#[derive(Clone, Debug)]
98pub struct GetMapByIdParams {
99 pub map_id: i32,
101}
102
103impl GetMapByIdParams {
104 pub fn new(map_id: i32) -> Self {
105 Self { map_id }
106 }
107}
108
109#[derive(Clone, Debug)]
111pub struct GetMapByPositionParams {
112 pub layer: models::MapLayer,
114 pub x: i32,
116 pub y: i32,
118}
119
120impl GetMapByPositionParams {
121 pub fn new(layer: models::MapLayer, x: i32, y: i32) -> Self {
122 Self { layer, x, y }
123 }
124}
125
126#[derive(Debug, Clone, Serialize)]
128#[serde(untagged)]
129pub enum GetAllMapsError {}
130
131impl<'de> Deserialize<'de> for GetAllMapsError {
132 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
133 where
134 D: Deserializer<'de>,
135 {
136 let raw = models::ErrorResponseSchema::deserialize(deserializer)?;
137 Err(de::Error::custom(format!(
138 "Unexpected error code: {}",
139 raw.error.code
140 )))
141 }
142}
143
144#[derive(Debug, Clone, Serialize)]
146#[serde(untagged)]
147pub enum GetLayerMapsError {}
148
149impl<'de> Deserialize<'de> for GetLayerMapsError {
150 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
151 where
152 D: Deserializer<'de>,
153 {
154 let raw = models::ErrorResponseSchema::deserialize(deserializer)?;
155 Err(de::Error::custom(format!(
156 "Unexpected error code: {}",
157 raw.error.code
158 )))
159 }
160}
161
162#[derive(Debug, Clone, Serialize)]
164#[serde(untagged)]
165pub enum GetMapByIdError {
166 Status404(models::ErrorResponseSchema),
168}
169
170impl<'de> Deserialize<'de> for GetMapByIdError {
171 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
172 where
173 D: Deserializer<'de>,
174 {
175 let raw = models::ErrorResponseSchema::deserialize(deserializer)?;
176 match raw.error.code {
177 404 => Ok(Self::Status404(raw)),
178 _ => Err(de::Error::custom(format!(
179 "Unexpected error code: {}",
180 raw.error.code
181 ))),
182 }
183 }
184}
185
186#[derive(Debug, Clone, Serialize)]
188#[serde(untagged)]
189pub enum GetMapByPositionError {
190 Status404(models::ErrorResponseSchema),
192}
193
194impl<'de> Deserialize<'de> for GetMapByPositionError {
195 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
196 where
197 D: Deserializer<'de>,
198 {
199 let raw = models::ErrorResponseSchema::deserialize(deserializer)?;
200 match raw.error.code {
201 404 => Ok(Self::Status404(raw)),
202 _ => Err(de::Error::custom(format!(
203 "Unexpected error code: {}",
204 raw.error.code
205 ))),
206 }
207 }
208}
209
210pub async fn get_all_maps(
212 configuration: &configuration::Configuration,
213 params: GetAllMapsParams,
214) -> Result<models::StaticDataPageMapSchema, Error<GetAllMapsError>> {
215 let local_var_configuration = configuration;
216
217 let layer = params.layer;
219 let content_type = params.content_type;
221 let content_code = params.content_code;
223 let hide_blocked_maps = params.hide_blocked_maps;
225 let hide_event = params.hide_event;
227 let transition = params.transition;
229 let page = params.page;
231 let size = params.size;
233
234 let local_var_client = &local_var_configuration.client;
235
236 let local_var_uri_str = format!("{}/maps", local_var_configuration.base_path);
237 let mut local_var_req_builder =
238 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
239
240 if let Some(ref local_var_str) = layer {
241 local_var_req_builder =
242 local_var_req_builder.query(&[("layer", &local_var_str.to_string())]);
243 }
244 if let Some(ref local_var_str) = content_type {
245 local_var_req_builder =
246 local_var_req_builder.query(&[("content_type", &local_var_str.to_string())]);
247 }
248 if let Some(ref local_var_str) = content_code {
249 local_var_req_builder =
250 local_var_req_builder.query(&[("content_code", &local_var_str.to_string())]);
251 }
252 if let Some(ref local_var_str) = hide_blocked_maps {
253 local_var_req_builder =
254 local_var_req_builder.query(&[("hide_blocked_maps", &local_var_str.to_string())]);
255 }
256 if let Some(ref local_var_str) = hide_event {
257 local_var_req_builder =
258 local_var_req_builder.query(&[("hide_event", &local_var_str.to_string())]);
259 }
260 if let Some(ref local_var_str) = transition {
261 local_var_req_builder =
262 local_var_req_builder.query(&[("transition", &local_var_str.to_string())]);
263 }
264 if let Some(ref local_var_str) = page {
265 local_var_req_builder =
266 local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
267 }
268 if let Some(ref local_var_str) = size {
269 local_var_req_builder =
270 local_var_req_builder.query(&[("size", &local_var_str.to_string())]);
271 }
272 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
273 local_var_req_builder =
274 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
275 }
276
277 let local_var_req = local_var_req_builder.build()?;
278 let local_var_resp = local_var_client.execute(local_var_req).await?;
279
280 let local_var_status = local_var_resp.status();
281 let local_var_content = local_var_resp.text().await?;
282
283 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
284 serde_json::from_str(&local_var_content).map_err(Error::from)
285 } else {
286 let local_var_entity: Option<GetAllMapsError> =
287 serde_json::from_str(&local_var_content).ok();
288 let local_var_error = ResponseContent {
289 status: local_var_status,
290 content: local_var_content,
291 entity: local_var_entity,
292 };
293 Err(Error::ResponseError(local_var_error))
294 }
295}
296
297pub async fn get_layer_maps(
299 configuration: &configuration::Configuration,
300 params: GetLayerMapsParams,
301) -> Result<models::StaticDataPageMapSchema, Error<GetLayerMapsError>> {
302 let local_var_configuration = configuration;
303
304 let layer = params.layer;
306 let content_type = params.content_type;
308 let content_code = params.content_code;
310 let hide_blocked_maps = params.hide_blocked_maps;
312 let hide_event = params.hide_event;
314 let transition = params.transition;
316 let page = params.page;
318 let size = params.size;
320
321 let local_var_client = &local_var_configuration.client;
322
323 let local_var_uri_str = format!(
324 "{}/maps/{layer}",
325 local_var_configuration.base_path,
326 layer = layer
327 );
328 let mut local_var_req_builder =
329 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
330
331 if let Some(ref local_var_str) = content_type {
332 local_var_req_builder =
333 local_var_req_builder.query(&[("content_type", &local_var_str.to_string())]);
334 }
335 if let Some(ref local_var_str) = content_code {
336 local_var_req_builder =
337 local_var_req_builder.query(&[("content_code", &local_var_str.to_string())]);
338 }
339 if let Some(ref local_var_str) = hide_blocked_maps {
340 local_var_req_builder =
341 local_var_req_builder.query(&[("hide_blocked_maps", &local_var_str.to_string())]);
342 }
343 if let Some(ref local_var_str) = hide_event {
344 local_var_req_builder =
345 local_var_req_builder.query(&[("hide_event", &local_var_str.to_string())]);
346 }
347 if let Some(ref local_var_str) = transition {
348 local_var_req_builder =
349 local_var_req_builder.query(&[("transition", &local_var_str.to_string())]);
350 }
351 if let Some(ref local_var_str) = page {
352 local_var_req_builder =
353 local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
354 }
355 if let Some(ref local_var_str) = size {
356 local_var_req_builder =
357 local_var_req_builder.query(&[("size", &local_var_str.to_string())]);
358 }
359 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
360 local_var_req_builder =
361 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
362 }
363
364 let local_var_req = local_var_req_builder.build()?;
365 let local_var_resp = local_var_client.execute(local_var_req).await?;
366
367 let local_var_status = local_var_resp.status();
368 let local_var_content = local_var_resp.text().await?;
369
370 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
371 serde_json::from_str(&local_var_content).map_err(Error::from)
372 } else {
373 let local_var_entity: Option<GetLayerMapsError> =
374 serde_json::from_str(&local_var_content).ok();
375 let local_var_error = ResponseContent {
376 status: local_var_status,
377 content: local_var_content,
378 entity: local_var_entity,
379 };
380 Err(Error::ResponseError(local_var_error))
381 }
382}
383
384pub async fn get_map_by_id(
386 configuration: &configuration::Configuration,
387 params: GetMapByIdParams,
388) -> Result<models::MapResponseSchema, Error<GetMapByIdError>> {
389 let local_var_configuration = configuration;
390
391 let map_id = params.map_id;
393
394 let local_var_client = &local_var_configuration.client;
395
396 let local_var_uri_str = format!(
397 "{}/maps/id/{map_id}",
398 local_var_configuration.base_path,
399 map_id = map_id
400 );
401 let mut local_var_req_builder =
402 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
403
404 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
405 local_var_req_builder =
406 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
407 }
408
409 let local_var_req = local_var_req_builder.build()?;
410 let local_var_resp = local_var_client.execute(local_var_req).await?;
411
412 let local_var_status = local_var_resp.status();
413 let local_var_content = local_var_resp.text().await?;
414
415 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
416 serde_json::from_str(&local_var_content).map_err(Error::from)
417 } else {
418 let local_var_entity: Option<GetMapByIdError> =
419 serde_json::from_str(&local_var_content).ok();
420 let local_var_error = ResponseContent {
421 status: local_var_status,
422 content: local_var_content,
423 entity: local_var_entity,
424 };
425 Err(Error::ResponseError(local_var_error))
426 }
427}
428
429pub async fn get_map_by_position(
431 configuration: &configuration::Configuration,
432 params: GetMapByPositionParams,
433) -> Result<models::MapResponseSchema, Error<GetMapByPositionError>> {
434 let local_var_configuration = configuration;
435
436 let layer = params.layer;
438 let x = params.x;
440 let y = params.y;
442
443 let local_var_client = &local_var_configuration.client;
444
445 let local_var_uri_str = format!(
446 "{}/maps/{layer}/{x}/{y}",
447 local_var_configuration.base_path,
448 layer = layer,
449 x = x,
450 y = y
451 );
452 let mut local_var_req_builder =
453 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
454
455 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
456 local_var_req_builder =
457 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
458 }
459
460 let local_var_req = local_var_req_builder.build()?;
461 let local_var_resp = local_var_client.execute(local_var_req).await?;
462
463 let local_var_status = local_var_resp.status();
464 let local_var_content = local_var_resp.text().await?;
465
466 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
467 serde_json::from_str(&local_var_content).map_err(Error::from)
468 } else {
469 let local_var_entity: Option<GetMapByPositionError> =
470 serde_json::from_str(&local_var_content).ok();
471 let local_var_error = ResponseContent {
472 status: local_var_status,
473 content: local_var_content,
474 entity: local_var_entity,
475 };
476 Err(Error::ResponseError(local_var_error))
477 }
478}