dealve-core 1.0.2

Core models and types for Dealve - a game deals finder
Documentation
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
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
use serde::{Deserialize, Serialize};

/// Supported countries for deal filtering (ISO 3166-1 alpha-2 codes)
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
pub enum Region {
    // Europe
    AT,
    BE,
    BG,
    CH,
    CZ,
    DE,
    DK,
    EE,
    ES,
    FI,
    #[default]
    FR,
    GB,
    GR,
    HR,
    HU,
    IE,
    IT,
    LT,
    LV,
    NL,
    NO,
    PL,
    PT,
    RO,
    SE,
    SK,
    // Americas
    AR,
    BR,
    CA,
    CL,
    CO,
    MX,
    US,
    // Asia-Pacific
    AU,
    CN,
    HK,
    ID,
    IN,
    JP,
    KR,
    NZ,
    PH,
    SG,
    TH,
    TW,
    // Middle East & Africa
    AE,
    IL,
    SA,
    TR,
    ZA,
}

impl Region {
    pub fn name(&self) -> &str {
        match self {
            // Europe
            Region::AT => "Austria",
            Region::BE => "Belgium",
            Region::BG => "Bulgaria",
            Region::CH => "Switzerland",
            Region::CZ => "Czechia",
            Region::DE => "Germany",
            Region::DK => "Denmark",
            Region::EE => "Estonia",
            Region::ES => "Spain",
            Region::FI => "Finland",
            Region::FR => "France",
            Region::GB => "United Kingdom",
            Region::GR => "Greece",
            Region::HR => "Croatia",
            Region::HU => "Hungary",
            Region::IE => "Ireland",
            Region::IT => "Italy",
            Region::LT => "Lithuania",
            Region::LV => "Latvia",
            Region::NL => "Netherlands",
            Region::NO => "Norway",
            Region::PL => "Poland",
            Region::PT => "Portugal",
            Region::RO => "Romania",
            Region::SE => "Sweden",
            Region::SK => "Slovakia",
            // Americas
            Region::AR => "Argentina",
            Region::BR => "Brazil",
            Region::CA => "Canada",
            Region::CL => "Chile",
            Region::CO => "Colombia",
            Region::MX => "Mexico",
            Region::US => "United States",
            // Asia-Pacific
            Region::AU => "Australia",
            Region::CN => "China",
            Region::HK => "Hong Kong",
            Region::ID => "Indonesia",
            Region::IN => "India",
            Region::JP => "Japan",
            Region::KR => "South Korea",
            Region::NZ => "New Zealand",
            Region::PH => "Philippines",
            Region::SG => "Singapore",
            Region::TH => "Thailand",
            Region::TW => "Taiwan",
            // Middle East & Africa
            Region::AE => "United Arab Emirates",
            Region::IL => "Israel",
            Region::SA => "Saudi Arabia",
            Region::TR => "Turkey",
            Region::ZA => "South Africa",
        }
    }

    pub fn code(&self) -> &str {
        match self {
            Region::AT => "AT",
            Region::BE => "BE",
            Region::BG => "BG",
            Region::CH => "CH",
            Region::CZ => "CZ",
            Region::DE => "DE",
            Region::DK => "DK",
            Region::EE => "EE",
            Region::ES => "ES",
            Region::FI => "FI",
            Region::FR => "FR",
            Region::GB => "GB",
            Region::GR => "GR",
            Region::HR => "HR",
            Region::HU => "HU",
            Region::IE => "IE",
            Region::IT => "IT",
            Region::LT => "LT",
            Region::LV => "LV",
            Region::NL => "NL",
            Region::NO => "NO",
            Region::PL => "PL",
            Region::PT => "PT",
            Region::RO => "RO",
            Region::SE => "SE",
            Region::SK => "SK",
            Region::AR => "AR",
            Region::BR => "BR",
            Region::CA => "CA",
            Region::CL => "CL",
            Region::CO => "CO",
            Region::MX => "MX",
            Region::US => "US",
            Region::AU => "AU",
            Region::CN => "CN",
            Region::HK => "HK",
            Region::ID => "ID",
            Region::IN => "IN",
            Region::JP => "JP",
            Region::KR => "KR",
            Region::NZ => "NZ",
            Region::PH => "PH",
            Region::SG => "SG",
            Region::TH => "TH",
            Region::TW => "TW",
            Region::AE => "AE",
            Region::IL => "IL",
            Region::SA => "SA",
            Region::TR => "TR",
            Region::ZA => "ZA",
        }
    }

    pub fn continent(&self) -> &str {
        match self {
            Region::AT
            | Region::BE
            | Region::BG
            | Region::CH
            | Region::CZ
            | Region::DE
            | Region::DK
            | Region::EE
            | Region::ES
            | Region::FI
            | Region::FR
            | Region::GB
            | Region::GR
            | Region::HR
            | Region::HU
            | Region::IE
            | Region::IT
            | Region::LT
            | Region::LV
            | Region::NL
            | Region::NO
            | Region::PL
            | Region::PT
            | Region::RO
            | Region::SE
            | Region::SK => "Europe",

            Region::AR
            | Region::BR
            | Region::CA
            | Region::CL
            | Region::CO
            | Region::MX
            | Region::US => "Americas",

            Region::AU
            | Region::CN
            | Region::HK
            | Region::ID
            | Region::IN
            | Region::JP
            | Region::KR
            | Region::NZ
            | Region::PH
            | Region::SG
            | Region::TH
            | Region::TW => "Asia-Pacific",

            Region::AE | Region::IL | Region::SA | Region::TR | Region::ZA => {
                "Middle East & Africa"
            }
        }
    }

    /// All regions, ordered by continent then alphabetically by name
    pub const ALL: &'static [Region] = &[
        // Europe
        Region::AT,
        Region::BE,
        Region::BG,
        Region::HR,
        Region::CZ,
        Region::DK,
        Region::EE,
        Region::FI,
        Region::FR,
        Region::DE,
        Region::GR,
        Region::HU,
        Region::IE,
        Region::IT,
        Region::LV,
        Region::LT,
        Region::NL,
        Region::NO,
        Region::PL,
        Region::PT,
        Region::RO,
        Region::SK,
        Region::ES,
        Region::SE,
        Region::CH,
        Region::GB,
        // Americas
        Region::AR,
        Region::BR,
        Region::CA,
        Region::CL,
        Region::CO,
        Region::MX,
        Region::US,
        // Asia-Pacific
        Region::AU,
        Region::CN,
        Region::HK,
        Region::IN,
        Region::ID,
        Region::JP,
        Region::NZ,
        Region::PH,
        Region::SG,
        Region::KR,
        Region::TW,
        Region::TH,
        // Middle East & Africa
        Region::AE,
        Region::IL,
        Region::SA,
        Region::ZA,
        Region::TR,
    ];

    pub fn from_code(code: &str) -> Option<Region> {
        match code {
            "AT" => Some(Region::AT),
            "BE" => Some(Region::BE),
            "BG" => Some(Region::BG),
            "CH" => Some(Region::CH),
            "CZ" => Some(Region::CZ),
            "DE" => Some(Region::DE),
            "DK" => Some(Region::DK),
            "EE" => Some(Region::EE),
            "ES" => Some(Region::ES),
            "FI" => Some(Region::FI),
            "FR" => Some(Region::FR),
            "GB" => Some(Region::GB),
            "GR" => Some(Region::GR),
            "HR" => Some(Region::HR),
            "HU" => Some(Region::HU),
            "IE" => Some(Region::IE),
            "IT" => Some(Region::IT),
            "LT" => Some(Region::LT),
            "LV" => Some(Region::LV),
            "NL" => Some(Region::NL),
            "NO" => Some(Region::NO),
            "PL" => Some(Region::PL),
            "PT" => Some(Region::PT),
            "RO" => Some(Region::RO),
            "SE" => Some(Region::SE),
            "SK" => Some(Region::SK),
            "AR" => Some(Region::AR),
            "BR" => Some(Region::BR),
            "CA" => Some(Region::CA),
            "CL" => Some(Region::CL),
            "CO" => Some(Region::CO),
            "MX" => Some(Region::MX),
            "US" => Some(Region::US),
            "AU" => Some(Region::AU),
            "CN" => Some(Region::CN),
            "HK" => Some(Region::HK),
            "ID" => Some(Region::ID),
            "IN" => Some(Region::IN),
            "JP" => Some(Region::JP),
            "KR" => Some(Region::KR),
            "NZ" => Some(Region::NZ),
            "PH" => Some(Region::PH),
            "SG" => Some(Region::SG),
            "TH" => Some(Region::TH),
            "TW" => Some(Region::TW),
            "AE" => Some(Region::AE),
            "IL" => Some(Region::IL),
            "SA" => Some(Region::SA),
            "TR" => Some(Region::TR),
            "ZA" => Some(Region::ZA),
            // Handle old config values
            "EU1" => Some(Region::FR),
            "EU2" => Some(Region::PL),
            "UK" => Some(Region::GB),
            _ => None,
        }
    }
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Platform {
    All,
    AllYouPlay,
    Blizzard,
    DLGamer,
    Dreamgame,
    EAStore,
    EpicGames,
    Fanatical,
    FireFlower,
    GameBillet,
    GamersGate,
    Gamesload,
    GamesPlanetDE,
    GamesPlanetFR,
    GamesPlanetUK,
    GamesPlanetUS,
    Gog,
    GreenManGaming,
    HumbleStore,
    IndieGala,
    JoyBuggy,
    MacGameStore,
    MicrosoftStore,
    Newegg,
    Nuuvem,
    PlanetPlay,
    PlayerLand,
    Playsum,
    Steam,
    UbisoftStore,
    WinGameStore,
    ZoomPlatform,
}

impl Platform {
    pub fn name(&self) -> &str {
        match self {
            Platform::All => "All Platforms",
            Platform::AllYouPlay => "AllYouPlay",
            Platform::Blizzard => "Blizzard",
            Platform::DLGamer => "DLGamer",
            Platform::Dreamgame => "Dreamgame",
            Platform::EAStore => "EA Store",
            Platform::EpicGames => "Epic Game Store",
            Platform::Fanatical => "Fanatical",
            Platform::FireFlower => "FireFlower",
            Platform::GameBillet => "GameBillet",
            Platform::GamersGate => "GamersGate",
            Platform::Gamesload => "Gamesload",
            Platform::GamesPlanetDE => "GamesPlanet DE",
            Platform::GamesPlanetFR => "GamesPlanet FR",
            Platform::GamesPlanetUK => "GamesPlanet UK",
            Platform::GamesPlanetUS => "GamesPlanet US",
            Platform::Gog => "GOG",
            Platform::GreenManGaming => "GreenManGaming",
            Platform::HumbleStore => "Humble Store",
            Platform::IndieGala => "IndieGala Store",
            Platform::JoyBuggy => "JoyBuggy",
            Platform::MacGameStore => "MacGameStore",
            Platform::MicrosoftStore => "Microsoft Store",
            Platform::Newegg => "Newegg",
            Platform::Nuuvem => "Nuuvem",
            Platform::PlanetPlay => "PlanetPlay",
            Platform::PlayerLand => "PlayerLand",
            Platform::Playsum => "Playsum",
            Platform::Steam => "Steam",
            Platform::UbisoftStore => "Ubisoft Store",
            Platform::WinGameStore => "WinGameStore",
            Platform::ZoomPlatform => "ZOOM Platform",
        }
    }

    pub fn shop_id(&self) -> Option<u32> {
        match self {
            Platform::All => None,
            Platform::AllYouPlay => Some(2),
            Platform::Blizzard => Some(4),
            Platform::DLGamer => Some(13),
            Platform::Dreamgame => Some(15),
            Platform::EAStore => Some(52),
            Platform::EpicGames => Some(16),
            Platform::Fanatical => Some(6),
            Platform::FireFlower => Some(17),
            Platform::GameBillet => Some(20),
            Platform::GamersGate => Some(24),
            Platform::Gamesload => Some(25),
            Platform::GamesPlanetDE => Some(27),
            Platform::GamesPlanetFR => Some(28),
            Platform::GamesPlanetUK => Some(26),
            Platform::GamesPlanetUS => Some(29),
            Platform::Gog => Some(35),
            Platform::GreenManGaming => Some(36),
            Platform::HumbleStore => Some(37),
            Platform::IndieGala => Some(42),
            Platform::JoyBuggy => Some(65),
            Platform::MacGameStore => Some(47),
            Platform::MicrosoftStore => Some(48),
            Platform::Newegg => Some(49),
            Platform::Nuuvem => Some(50),
            Platform::PlanetPlay => Some(73),
            Platform::PlayerLand => Some(74),
            Platform::Playsum => Some(70),
            Platform::Steam => Some(61),
            Platform::UbisoftStore => Some(62),
            Platform::WinGameStore => Some(64),
            Platform::ZoomPlatform => Some(72),
        }
    }

    pub const ALL: &'static [Platform] = &[
        Platform::All,
        Platform::AllYouPlay,
        Platform::Blizzard,
        Platform::DLGamer,
        Platform::Dreamgame,
        Platform::EAStore,
        Platform::EpicGames,
        Platform::Fanatical,
        Platform::FireFlower,
        Platform::GameBillet,
        Platform::GamersGate,
        Platform::Gamesload,
        Platform::GamesPlanetDE,
        Platform::GamesPlanetFR,
        Platform::GamesPlanetUK,
        Platform::GamesPlanetUS,
        Platform::Gog,
        Platform::GreenManGaming,
        Platform::HumbleStore,
        Platform::IndieGala,
        Platform::JoyBuggy,
        Platform::MacGameStore,
        Platform::MicrosoftStore,
        Platform::Newegg,
        Platform::Nuuvem,
        Platform::PlanetPlay,
        Platform::PlayerLand,
        Platform::Playsum,
        Platform::Steam,
        Platform::UbisoftStore,
        Platform::WinGameStore,
        Platform::ZoomPlatform,
    ];
}

/// Represents a game deal from IsThereAnyDeal
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Deal {
    pub id: String,
    pub title: String,
    pub shop: Shop,
    pub price: Price,
    pub regular_price: f64,
    pub url: String,
    pub history_low: Option<f64>,
}

/// Detailed game information
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct GameInfo {
    pub id: String,
    pub title: String,
    pub release_date: Option<String>,
    pub developers: Vec<String>,
    pub publishers: Vec<String>,
    pub tags: Vec<String>,
}

/// Price history data point for charts
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PriceHistoryPoint {
    pub timestamp: i64,
    pub price: f64,
    pub shop_name: String,
}

/// Store/shop information
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct Shop {
    pub id: String,
    pub name: String,
}

/// Price information with discount
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Price {
    pub amount: f64,
    pub currency: String,
    pub discount: u8,
}

/// Filter options for deal queries
#[derive(Debug, Clone, Default)]
pub struct DealFilter {
    pub shop_ids: Option<Vec<String>>,
    pub country: String,
    pub limit: usize,
}

impl Default for Price {
    fn default() -> Self {
        Self {
            amount: 0.0,
            currency: "USD".to_string(),
            discount: 0,
        }
    }
}