artifacts/apis/
raids_api.rs1use super::{configuration, Error};
2use crate::{apis::ResponseContent, models};
3use reqwest::StatusCode;
4use serde::{de, Deserialize, Deserializer, Serialize};
5
6#[derive(Clone, Debug)]
8pub struct GetAllRaidsParams {
9 pub name: Option<String>,
11 pub active: Option<bool>,
13 pub page: Option<u32>,
15 pub size: Option<u32>,
17}
18
19impl GetAllRaidsParams {
20 pub fn new(
21 name: Option<String>,
22 active: Option<bool>,
23 page: Option<u32>,
24 size: Option<u32>,
25 ) -> Self {
26 Self {
27 name,
28 active,
29 page,
30 size,
31 }
32 }
33}
34
35#[derive(Clone, Debug)]
37pub struct GetRaidParams {
38 pub code: String,
40}
41
42impl GetRaidParams {
43 pub fn new(code: String) -> Self {
44 Self { code }
45 }
46}
47
48#[derive(Clone, Debug)]
50pub struct GetRaidLeaderboardParams {
51 pub code: String,
53 pub page: Option<u32>,
55 pub size: Option<u32>,
57}
58
59impl GetRaidLeaderboardParams {
60 pub fn new(code: String, page: Option<u32>, size: Option<u32>) -> Self {
61 Self { code, page, size }
62 }
63}
64
65#[derive(Debug, Clone, Serialize)]
67#[serde(untagged)]
68pub enum GetAllRaidsError {}
69
70impl<'de> Deserialize<'de> for GetAllRaidsError {
71 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
72 where
73 D: Deserializer<'de>,
74 {
75 let raw = models::ErrorResponseSchema::deserialize(deserializer)?;
76 Err(de::Error::custom(format!(
77 "Unexpected error code: {}",
78 raw.error.code
79 )))
80 }
81}
82
83#[derive(Debug, Clone, Serialize)]
85#[serde(untagged)]
86pub enum GetRaidError {
87 Status404(models::ErrorResponseSchema),
89}
90
91impl<'de> Deserialize<'de> for GetRaidError {
92 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
93 where
94 D: Deserializer<'de>,
95 {
96 let raw = models::ErrorResponseSchema::deserialize(deserializer)?;
97 match raw.error.code {
98 404 => Ok(Self::Status404(raw)),
99 _ => Err(de::Error::custom(format!(
100 "Unexpected error code: {}",
101 raw.error.code
102 ))),
103 }
104 }
105}
106
107#[derive(Debug, Clone, Serialize)]
109#[serde(untagged)]
110pub enum GetRaidLeaderboardError {}
111
112impl<'de> Deserialize<'de> for GetRaidLeaderboardError {
113 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
114 where
115 D: Deserializer<'de>,
116 {
117 let raw = models::ErrorResponseSchema::deserialize(deserializer)?;
118 Err(de::Error::custom(format!(
119 "Unexpected error code: {}",
120 raw.error.code
121 )))
122 }
123}
124
125pub async fn get_all_raids(
127 configuration: &configuration::Configuration,
128 params: GetAllRaidsParams,
129) -> Result<models::StaticDataPageRaidSchema, Error<GetAllRaidsError>> {
130 let local_var_configuration = configuration;
131
132 let name = params.name;
134 let active = params.active;
136 let page = params.page;
138 let size = params.size;
140
141 let local_var_client = &local_var_configuration.client;
142
143 let local_var_uri_str = format!("{}/raids", local_var_configuration.base_path);
144 let mut local_var_req_builder =
145 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
146
147 if let Some(ref local_var_str) = name {
148 local_var_req_builder =
149 local_var_req_builder.query(&[("name", &local_var_str.to_string())]);
150 }
151 if let Some(ref local_var_str) = active {
152 local_var_req_builder =
153 local_var_req_builder.query(&[("active", &local_var_str.to_string())]);
154 }
155 if let Some(ref local_var_str) = page {
156 local_var_req_builder =
157 local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
158 }
159 if let Some(ref local_var_str) = size {
160 local_var_req_builder =
161 local_var_req_builder.query(&[("size", &local_var_str.to_string())]);
162 }
163 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
164 local_var_req_builder =
165 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
166 }
167
168 let local_var_req = local_var_req_builder.build()?;
169 let local_var_resp = local_var_client.execute(local_var_req).await?;
170
171 let local_var_status = local_var_resp.status();
172 let local_var_content = local_var_resp.text().await?;
173
174 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
175 serde_json::from_str(&local_var_content).map_err(Error::from)
176 } else {
177 let local_var_entity: Option<GetAllRaidsError> =
178 serde_json::from_str(&local_var_content).ok();
179 let local_var_error = ResponseContent {
180 status: local_var_status,
181 content: local_var_content,
182 entity: local_var_entity,
183 };
184 Err(Error::ResponseError(local_var_error))
185 }
186}
187
188pub async fn get_raid(
190 configuration: &configuration::Configuration,
191 params: GetRaidParams,
192) -> Result<models::RaidResponseSchema, Error<GetRaidError>> {
193 let local_var_configuration = configuration;
194
195 let code = params.code;
197
198 let local_var_client = &local_var_configuration.client;
199
200 let local_var_uri_str = format!(
201 "{}/raids/{code}",
202 local_var_configuration.base_path,
203 code = crate::apis::urlencode(code)
204 );
205 let mut local_var_req_builder =
206 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
207
208 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
209 local_var_req_builder =
210 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
211 }
212
213 let local_var_req = local_var_req_builder.build()?;
214 let local_var_resp = local_var_client.execute(local_var_req).await?;
215
216 let local_var_status = local_var_resp.status();
217 let local_var_content = local_var_resp.text().await?;
218
219 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
220 serde_json::from_str(&local_var_content).map_err(Error::from)
221 } else {
222 let local_var_entity: Option<GetRaidError> = serde_json::from_str(&local_var_content).ok();
223 let local_var_error = ResponseContent {
224 status: local_var_status,
225 content: local_var_content,
226 entity: local_var_entity,
227 };
228 Err(Error::ResponseError(local_var_error))
229 }
230}
231
232pub async fn get_raid_leaderboard(
234 configuration: &configuration::Configuration,
235 params: GetRaidLeaderboardParams,
236) -> Result<models::DataPageRaidLeaderboardEntrySchema, Error<GetRaidLeaderboardError>> {
237 let local_var_configuration = configuration;
238
239 let code = params.code;
241 let page = params.page;
243 let size = params.size;
245
246 let local_var_client = &local_var_configuration.client;
247
248 let local_var_uri_str = format!(
249 "{}/raids/{code}/leaderboard",
250 local_var_configuration.base_path,
251 code = crate::apis::urlencode(code)
252 );
253 let mut local_var_req_builder =
254 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
255
256 if let Some(ref local_var_str) = page {
257 local_var_req_builder =
258 local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
259 }
260 if let Some(ref local_var_str) = size {
261 local_var_req_builder =
262 local_var_req_builder.query(&[("size", &local_var_str.to_string())]);
263 }
264 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
265 local_var_req_builder =
266 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
267 }
268
269 let local_var_req = local_var_req_builder.build()?;
270 let local_var_resp = local_var_client.execute(local_var_req).await?;
271
272 let local_var_status = local_var_resp.status();
273 let local_var_content = local_var_resp.text().await?;
274
275 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
276 serde_json::from_str(&local_var_content).map_err(Error::from)
277 } else {
278 let local_var_entity: Option<GetRaidLeaderboardError> =
279 serde_json::from_str(&local_var_content).ok();
280 let local_var_error = ResponseContent {
281 status: local_var_status,
282 content: local_var_content,
283 entity: local_var_entity,
284 };
285 Err(Error::ResponseError(local_var_error))
286 }
287}