1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
use serde::{Deserialize, Serialize};

use crate::{
    error::Error,
    types::{
        AllStatus, AnimeKind, AnimeStatus, DramaStatus, MaterialDataField, MppaRating, ReleaseType,
        TranslationType,
    },
    util::serialize_into_query_parts,
    Client,
};

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct CountryResult {
    // Name of the country
    pub title: String,

    /// The number of materials with this voice acting
    pub count: i32,
}

/// A struct containing countries results and other information about the countries
#[derive(Deserialize, Debug, Clone)]
pub struct CountryResponse {
    pub time: String,
    pub total: i32,
    pub prev_page: Option<String>,
    pub next_page: Option<String>,
    pub results: Vec<CountryResult>,
}

#[derive(Deserialize, Debug, Clone)]
#[serde(untagged)]
enum CountryResponseUnion {
    Result(CountryResponse),
    Error { error: String },
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub enum CountrySort {
    #[serde(rename = "title")]
    Title,
    #[serde(rename = "count")]
    Count,
}

#[derive(Debug, Serialize, Clone)]
pub struct CountryQuery<'a> {
    /// What field to sort materials by
    #[serde(skip_serializing_if = "Option::is_none")]
    sort: Option<CountrySort>,

    /// Maximum number of outputs
    #[serde(skip_serializing_if = "Option::is_none")]
    types: Option<&'a [ReleaseType]>,

    ///Filter materials by year If you set this parameter, only materials of the corresponding year will be displayed
    #[serde(skip_serializing_if = "Option::is_none")]
    year: Option<&'a [u32]>,

    /// Filtering materials by translation ID
    #[serde(skip_serializing_if = "Option::is_none")]
    translation_id: Option<&'a [u32]>,
    /// Filter content by translation type. Allows you to output only voice translation or only subtitles
    #[serde(skip_serializing_if = "Option::is_none")]
    translation_type: Option<&'a [TranslationType]>,

    /// Filtering materials based on the presence of a specific field. Materials that have at least one of the listed fields are shown. In order to show only materials that have all the listed fields
    #[serde(skip_serializing_if = "Option::is_none")]
    has_field: Option<&'a [MaterialDataField]>,
    /// Filtering materials based on the presence of a specific field. Materials that have all the listed fields are shown
    #[serde(skip_serializing_if = "Option::is_none")]
    has_field_and: Option<&'a [MaterialDataField]>,

    /// Filtering materials by country. You can specify a single value or multiple values, separated by commas (then materials with at least one of the listed countries will be displayed). The parameter is case sensitive
    #[serde(skip_serializing_if = "Option::is_none")]
    countries: Option<&'a [&'a str]>,

    /// Filtering by genre. You can specify either one value or several values separated by commas (then materials that have at least one of the specified genres will be displayed). You can search by Kinopoisk, Shikimori, MyDramaList or by all genres at once. The parameter is not case sensitive
    #[serde(skip_serializing_if = "Option::is_none")]
    genres: Option<&'a [&'a str]>,
    /// Filtering by genre. You can specify either one value or several values separated by commas (then materials that have at least one of the specified genres will be displayed). You can search by Kinopoisk, Shikimori, MyDramaList or by all genres at once. The parameter is not case sensitive
    #[serde(skip_serializing_if = "Option::is_none")]
    anime_genres: Option<&'a [&'a str]>,
    /// Filtering by genre. You can specify either one value or several values separated by commas (then materials that have at least one of the specified genres will be displayed). You can search by Kinopoisk, Shikimori, MyDramaList or by all genres at once. The parameter is not case sensitive
    #[serde(skip_serializing_if = "Option::is_none")]
    drama_genres: Option<&'a [&'a str]>,
    /// Filtering by genre. You can specify either one value or several values separated by commas (then materials that have at least one of the specified genres will be displayed). You can search by Kinopoisk, Shikimori, MyDramaList or by all genres at once. The parameter is not case sensitive
    #[serde(skip_serializing_if = "Option::is_none")]
    all_genres: Option<&'a [&'a str]>,

    /// Filtering by duration (in minutes). You can specify either a single value to search for the exact duration, or an interval.
    #[serde(skip_serializing_if = "Option::is_none")]
    duration: Option<&'a [&'a str]>,

    /// Filtering by Kinopoisk, IMDb, Shikimori, or MyDramaList ratings. You can specify either a single value to search for the exact rating, or an interval
    #[serde(skip_serializing_if = "Option::is_none")]
    kinopoisk_rating: Option<&'a [&'a str]>,
    /// Filtering by Kinopoisk, IMDb, Shikimori, or MyDramaList ratings. You can specify either a single value to search for the exact rating, or an interval
    #[serde(skip_serializing_if = "Option::is_none")]
    imdb_rating: Option<&'a [&'a str]>,
    /// Filtering by Kinopoisk, IMDb, Shikimori, or MyDramaList ratings. You can specify either a single value to search for the exact rating, or an interval
    #[serde(skip_serializing_if = "Option::is_none")]
    shikimori_rating: Option<&'a [&'a str]>,
    /// Filtering by Kinopoisk, IMDb, Shikimori, or MyDramaList ratings. You can specify either a single value to search for the exact rating, or an interval
    #[serde(skip_serializing_if = "Option::is_none")]
    mydramalist_rating: Option<&'a [&'a str]>,

    /// Filtering materials by personas. You can specify a single value or multiple values, separated by commas (then materials that have at least one of the specified personas will be displayed). This parameter is case-independent. You can specify filters for several professions at once
    #[serde(skip_serializing_if = "Option::is_none")]
    actors: Option<&'a [&'a str]>,
    /// Filtering materials by personas. You can specify a single value or multiple values, separated by commas (then materials that have at least one of the specified personas will be displayed). This parameter is case-independent. You can specify filters for several professions at once
    #[serde(skip_serializing_if = "Option::is_none")]
    directors: Option<&'a [&'a str]>,
    /// Filtering materials by personas. You can specify a single value or multiple values, separated by commas (then materials that have at least one of the specified personas will be displayed). This parameter is case-independent. You can specify filters for several professions at once
    #[serde(skip_serializing_if = "Option::is_none")]
    producers: Option<&'a [&'a str]>,
    /// Filtering materials by personas. You can specify a single value or multiple values, separated by commas (then materials that have at least one of the specified personas will be displayed). This parameter is case-independent. You can specify filters for several professions at once
    #[serde(skip_serializing_if = "Option::is_none")]
    writers: Option<&'a [&'a str]>,
    /// Filtering materials by personas. You can specify a single value or multiple values, separated by commas (then materials that have at least one of the specified personas will be displayed). This parameter is case-independent. You can specify filters for several professions at once
    #[serde(skip_serializing_if = "Option::is_none")]
    composers: Option<&'a [&'a str]>,
    /// Filtering materials by personas. You can specify a single value or multiple values, separated by commas (then materials that have at least one of the specified personas will be displayed). This parameter is case-independent. You can specify filters for several professions at once
    #[serde(skip_serializing_if = "Option::is_none")]
    editors: Option<&'a [&'a str]>,
    /// Filtering materials by personas. You can specify a single value or multiple values, separated by commas (then materials that have at least one of the specified personas will be displayed). This parameter is case-independent. You can specify filters for several professions at once
    #[serde(skip_serializing_if = "Option::is_none")]
    designers: Option<&'a [&'a str]>,
    /// Filtering materials by personas. You can specify a single value or multiple values, separated by commas (then materials that have at least one of the specified personas will be displayed). This parameter is case-independent. You can specify filters for several professions at once
    #[serde(skip_serializing_if = "Option::is_none")]
    operators: Option<&'a [&'a str]>,

    /// Filtering materials by age rating. You can specify a single value or multiple values, separated by commas. The parameter is case-insensitive
    #[serde(skip_serializing_if = "Option::is_none")]
    rating_mpaa: Option<&'a [MppaRating]>,

    /// Filter content by the minimum age from which it can be viewed. You can specify either a single value or a range of values
    #[serde(skip_serializing_if = "Option::is_none")]
    minimal_age: Option<&'a [&'a str]>,

    /// Filtering materials by anime type. You can specify one value or several values separated by commas (then materials with at least one of these types will be displayed)
    #[serde(skip_serializing_if = "Option::is_none")]
    anime_kind: Option<&'a [AnimeKind]>,

    /// Filters materials by MyDramaList tags. You can specify one value or several values separated by commas (then materials with at least one of these types will be displayed)
    #[serde(skip_serializing_if = "Option::is_none")]
    mydramalist_tags: Option<&'a [&'a str]>,

    /// Filter materials by Shikimori status, MyDramaList, or by all statuses. You can specify a single value or several values separated by commas (then materials that have at least one of the listed statuses will be displayed)
    #[serde(skip_serializing_if = "Option::is_none")]
    anime_status: Option<&'a [AnimeStatus]>,
    /// Filter materials by Shikimori status, MyDramaList, or by all statuses. You can specify a single value or several values separated by commas (then materials that have at least one of the listed statuses will be displayed)
    #[serde(skip_serializing_if = "Option::is_none")]
    drama_status: Option<&'a [DramaStatus]>,
    /// Filter materials by Shikimori status, MyDramaList, or by all statuses. You can specify a single value or several values separated by commas (then materials that have at least one of the listed statuses will be displayed)
    #[serde(skip_serializing_if = "Option::is_none")]
    all_status: Option<&'a [AllStatus]>,

    /// Filtering materials by anime studio. You can specify either one value or several values separated by commas (then materials with at least one of the listed studios will be displayed)
    #[serde(skip_serializing_if = "Option::is_none")]
    anime_studios: Option<&'a [&'a str]>,
    /// Filtering materials by license owner. You can specify a single value or several values separated by commas (then materials that have at least one of the listed owners will be displayed)
    #[serde(skip_serializing_if = "Option::is_none")]
    anime_licensed_by: Option<&'a [&'a str]>,
}

impl<'a> CountryQuery<'a> {
    pub fn new() -> CountryQuery<'a> {
        CountryQuery {
            sort: None,
            types: None,
            year: None,
            translation_id: None,
            translation_type: None,
            has_field: None,
            has_field_and: None,
            countries: None,
            genres: None,
            anime_genres: None,
            drama_genres: None,
            all_genres: None,
            duration: None,
            kinopoisk_rating: None,
            imdb_rating: None,
            shikimori_rating: None,
            mydramalist_rating: None,
            actors: None,
            directors: None,
            producers: None,
            writers: None,
            composers: None,
            editors: None,
            designers: None,
            operators: None,
            rating_mpaa: None,
            minimal_age: None,
            anime_kind: None,
            mydramalist_tags: None,
            anime_status: None,
            drama_status: None,
            all_status: None,
            anime_studios: None,
            anime_licensed_by: None,
        }
    }

    /// Maximum number of outputs
    pub fn with_types<'b>(&'b mut self, types: &'a [ReleaseType]) -> &'b mut CountryQuery<'a> {
        self.types = Some(types);
        self
    }

    ///Filter materials by year If you set this parameter, only materials of the corresponding year will be displayed

    pub fn with_year<'b>(&'b mut self, year: &'a [u32]) -> &'b mut CountryQuery<'a> {
        self.year = Some(year);
        self
    }

    /// Filtering materials by translation ID
    pub fn with_translation_id<'b>(
        &'b mut self,
        translation_id: &'a [u32],
    ) -> &'b mut CountryQuery<'a> {
        self.translation_id = Some(translation_id);
        self
    }
    /// Filter content by translation type. Allows you to output only voice translation or only subtitles
    pub fn with_translation_type<'b>(
        &'b mut self,
        translation_type: &'a [TranslationType],
    ) -> &'b mut CountryQuery<'a> {
        self.translation_type = Some(translation_type);
        self
    }

    /// Filtering materials based on the presence of a specific field. Materials that have at least one of the listed fields are shown. In order to show only materials that have all the listed fields
    pub fn with_has_field<'b>(
        &'b mut self,
        has_field: &'a [MaterialDataField],
    ) -> &'b mut CountryQuery<'a> {
        self.has_field = Some(has_field);
        self
    }
    /// Filtering materials based on the presence of a specific field. Materials that have all the listed fields are shown
    pub fn with_has_field_and<'b>(
        &'b mut self,
        has_field: &'a [MaterialDataField],
    ) -> &'b mut CountryQuery<'a> {
        self.has_field_and = Some(has_field);
        self
    }

    /// Filtering materials by country. You can specify a single value or multiple values, separated by commas (then materials with at least one of the listed countries will be displayed). The parameter is case sensitive
    pub fn with_countries<'b>(&'b mut self, countries: &'a [&'a str]) -> &'b mut CountryQuery<'a> {
        self.countries = Some(countries);
        self
    }

    /// Filtering by genre. You can specify either one value or several values separated by commas (then materials that have at least one of the specified genres will be displayed). You can search by Kinopoisk, Shikimori, MyDramaList or by all genres at once. The parameter is not case sensitive
    pub fn with_genres<'b>(&'b mut self, genres: &'a [&'a str]) -> &'b mut CountryQuery<'a> {
        self.genres = Some(genres);
        self
    }
    /// Filtering by genre. You can specify either one value or several values separated by commas (then materials that have at least one of the specified genres will be displayed). You can search by Kinopoisk, Shikimori, MyDramaList or by all genres at once. The parameter is not case sensitive
    pub fn with_anime_genres<'b>(
        &'b mut self,
        anime_genres: &'a [&'a str],
    ) -> &'b mut CountryQuery<'a> {
        self.anime_genres = Some(anime_genres);
        self
    }
    /// Filtering by genre. You can specify either one value or several values separated by commas (then materials that have at least one of the specified genres will be displayed). You can search by Kinopoisk, Shikimori, MyDramaList or by all genres at once. The parameter is not case sensitive
    pub fn with_drama_genres<'b>(
        &'b mut self,
        drama_genres: &'a [&'a str],
    ) -> &'b mut CountryQuery<'a> {
        self.drama_genres = Some(drama_genres);
        self
    }
    /// Filtering by genre. You can specify either one value or several values separated by commas (then materials that have at least one of the specified genres will be displayed). You can search by Kinopoisk, Shikimori, MyDramaList or by all genres at once. The parameter is not case sensitive
    pub fn with_all_genres<'b>(
        &'b mut self,
        all_genres: &'a [&'a str],
    ) -> &'b mut CountryQuery<'a> {
        self.all_genres = Some(all_genres);
        self
    }

    /// Filtering by duration (in minutes). You can specify either a single value to search for the exact duration, or an interval.
    pub fn with_duration<'b>(&'b mut self, duration: &'a [&'a str]) -> &'b mut CountryQuery<'a> {
        self.duration = Some(duration);
        self
    }

    /// Filtering by Kinopoisk, IMDb, Shikimori, or MyDramaList ratings. You can specify either a single value to search for the exact rating, or an interval
    pub fn with_kinopoisk_rating<'b>(
        &'b mut self,
        kinopoisk_rating: &'a [&'a str],
    ) -> &'b mut CountryQuery<'a> {
        self.kinopoisk_rating = Some(kinopoisk_rating);
        self
    }
    /// Filtering by Kinopoisk, IMDb, Shikimori, or MyDramaList ratings. You can specify either a single value to search for the exact rating, or an interval
    pub fn with_imdb_rating<'b>(
        &'b mut self,
        imdb_rating: &'a [&'a str],
    ) -> &'b mut CountryQuery<'a> {
        self.imdb_rating = Some(imdb_rating);
        self
    }
    /// Filtering by Kinopoisk, IMDb, Shikimori, or MyDramaList ratings. You can specify either a single value to search for the exact rating, or an interval
    pub fn with_shikimori_rating<'b>(
        &'b mut self,
        shikimori_rating: &'a [&'a str],
    ) -> &'b mut CountryQuery<'a> {
        self.shikimori_rating = Some(shikimori_rating);
        self
    }
    /// Filtering by Kinopoisk, IMDb, Shikimori, or MyDramaList ratings. You can specify either a single value to search for the exact rating, or an interval
    pub fn with_mydramalist_rating<'b>(
        &'b mut self,
        mydramalist_rating: &'a [&'a str],
    ) -> &'b mut CountryQuery<'a> {
        self.mydramalist_rating = Some(mydramalist_rating);
        self
    }

    /// Filtering materials by personas. You can specify a single value or multiple values, separated by commas (then materials that have at least one of the specified personas will be displayed). This parameter is case-independent. You can specify filters for several professions at once
    pub fn with_actors<'b>(&'b mut self, actors: &'a [&'a str]) -> &'b mut CountryQuery<'a> {
        self.actors = Some(actors);
        self
    }
    /// Filtering materials by personas. You can specify a single value or multiple values, separated by commas (then materials that have at least one of the specified personas will be displayed). This parameter is case-independent. You can specify filters for several professions at once
    pub fn with_directors<'b>(&'b mut self, directors: &'a [&'a str]) -> &'b mut CountryQuery<'a> {
        self.directors = Some(directors);
        self
    }
    /// Filtering materials by personas. You can specify a single value or multiple values, separated by commas (then materials that have at least one of the specified personas will be displayed). This parameter is case-independent. You can specify filters for several professions at once
    pub fn with_producers<'b>(&'b mut self, producers: &'a [&'a str]) -> &'b mut CountryQuery<'a> {
        self.producers = Some(producers);
        self
    }
    /// Filtering materials by personas. You can specify a single value or multiple values, separated by commas (then materials that have at least one of the specified personas will be displayed). This parameter is case-independent. You can specify filters for several professions at once
    pub fn with_writers<'b>(&'b mut self, writers: &'a [&'a str]) -> &'b mut CountryQuery<'a> {
        self.writers = Some(writers);
        self
    }
    /// Filtering materials by personas. You can specify a single value or multiple values, separated by commas (then materials that have at least one of the specified personas will be displayed). This parameter is case-independent. You can specify filters for several professions at once
    pub fn with_composers<'b>(&'b mut self, composers: &'a [&'a str]) -> &'b mut CountryQuery<'a> {
        self.composers = Some(composers);
        self
    }
    /// Filtering materials by personas. You can specify a single value or multiple values, separated by commas (then materials that have at least one of the specified personas will be displayed). This parameter is case-independent. You can specify filters for several professions at once
    pub fn with_editors<'b>(&'b mut self, editors: &'a [&'a str]) -> &'b mut CountryQuery<'a> {
        self.editors = Some(editors);
        self
    }
    /// Filtering materials by personas. You can specify a single value or multiple values, separated by commas (then materials that have at least one of the specified personas will be displayed). This parameter is case-independent. You can specify filters for several professions at once
    pub fn with_designers<'b>(&'b mut self, designers: &'a [&'a str]) -> &'b mut CountryQuery<'a> {
        self.designers = Some(designers);
        self
    }
    /// Filtering materials by personas. You can specify a single value or multiple values, separated by commas (then materials that have at least one of the specified personas will be displayed). This parameter is case-independent. You can specify filters for several professions at once
    pub fn with_operators<'b>(&'b mut self, operators: &'a [&'a str]) -> &'b mut CountryQuery<'a> {
        self.operators = Some(operators);
        self
    }

    /// Filtering materials by age rating. You can specify a single value or multiple values, separated by commas. The parameter is case-insensitive
    pub fn with_rating_mpaa<'b>(
        &'b mut self,
        rating_mpaa: &'a [MppaRating],
    ) -> &'b mut CountryQuery<'a> {
        self.rating_mpaa = Some(rating_mpaa);
        self
    }

    /// Filter content by the minimum age from which it can be viewed. You can specify either a single value or a range of values
    pub fn with_minimal_age<'b>(
        &'b mut self,
        minimal_age: &'a [&'a str],
    ) -> &'b mut CountryQuery<'a> {
        self.minimal_age = Some(minimal_age);
        self
    }

    /// Filtering materials by anime type. You can specify one value or several values separated by commas (then materials with at least one of these types will be displayed)
    pub fn with_anime_kind<'b>(
        &'b mut self,
        anime_kind: &'a [AnimeKind],
    ) -> &'b mut CountryQuery<'a> {
        self.anime_kind = Some(anime_kind);
        self
    }

    /// Filters materials by MyDramaList tags. You can specify one value or several values separated by commas (then materials with at least one of these types will be displayed)
    pub fn with_mydramalist_tags<'b>(
        &'b mut self,
        mydramalist_tags: &'a [&'a str],
    ) -> &'b mut CountryQuery<'a> {
        self.mydramalist_tags = Some(mydramalist_tags);
        self
    }

    /// Filter materials by Shikimori status, MyDramaList, or by all statuses. You can specify a single value or several values separated by commas (then materials that have at least one of the listed statuses will be displayed)
    pub fn with_anime_status<'b>(
        &'b mut self,
        anime_status: &'a [AnimeStatus],
    ) -> &'b mut CountryQuery<'a> {
        self.anime_status = Some(anime_status);
        self
    }
    /// Filter materials by Shikimori status, MyDramaList, or by all statuses. You can specify a single value or several values separated by commas (then materials that have at least one of the listed statuses will be displayed)
    pub fn with_drama_status<'b>(
        &'b mut self,
        drama_status: &'a [DramaStatus],
    ) -> &'b mut CountryQuery<'a> {
        self.drama_status = Some(drama_status);
        self
    }
    /// Filter materials by Shikimori status, MyDramaList, or by all statuses. You can specify a single value or several values separated by commas (then materials that have at least one of the listed statuses will be displayed)
    pub fn with_all_status<'b>(
        &'b mut self,
        all_status: &'a [AllStatus],
    ) -> &'b mut CountryQuery<'a> {
        self.all_status = Some(all_status);
        self
    }

    /// Filtering materials by anime studio. You can specify either one value or several values separated by commas (then materials with at least one of the listed studios will be displayed)
    pub fn with_anime_studios<'b>(
        &'b mut self,
        anime_studios: &'a [&'a str],
    ) -> &'b mut CountryQuery<'a> {
        self.anime_studios = Some(anime_studios);
        self
    }
    /// Filtering materials by license owner. You can specify a single value or several values separated by commas (then materials that have at least one of the listed owners will be displayed)
    pub fn with_anime_licensed_by<'b>(
        &'b mut self,
        anime_licensed_by: &'a [&'a str],
    ) -> &'b mut CountryQuery<'a> {
        self.anime_licensed_by = Some(anime_licensed_by);
        self
    }

    /// Execute the query and fetch the results.
    pub async fn execute<'b>(&'a self, client: &'b Client) -> Result<CountryResponse, Error> {
        let payload = serialize_into_query_parts(self)?;

        let response = client
            .init_post_request("/countries")
            .query(&payload)
            .send()
            .await
            .map_err(Error::HttpError)?;

        let result = response
            .json::<CountryResponseUnion>()
            .await
            .map_err(Error::HttpError)?;

        match result {
            CountryResponseUnion::Result(result) => Ok(result),
            CountryResponseUnion::Error { error } => Err(Error::KodikError(error)),
        }
    }
}

impl<'a> Default for CountryQuery<'a> {
    fn default() -> Self {
        Self::new()
    }
}