scrapebadger 0.2.0

Async Rust SDK and CLI for the ScrapeBadger web-scraping API (Amazon, Google, Twitter/X, Reddit, Vinted, Web Scraping).
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
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
// @generated by `cargo run -p xtask -- gen` from specs/amazon.json — do not edit by hand.
#![allow(clippy::all)]
#![allow(
    dead_code,
    unused_imports,
    unused_variables,
    non_snake_case,
    rustdoc::all
)]

use crate::core::{Client, Error, Method, QueryParams, Result};
use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::collections::HashMap;

/// Handle for the `amazon` platform. Obtain via [`crate::ScrapeBadger::amazon`].
#[derive(Clone)]
pub struct Amazon {
    client: Client,
}

impl Amazon {
    pub(crate) fn new(client: Client) -> Self {
        Self { client }
    }

    /// Access the underlying transport client.
    pub fn client(&self) -> &Client {
        &self.client
    }

    /// Keyword Suggestions
    ///
    /// Get Amazon search autocomplete suggestions for keyword research.
    /// `GET /v1/amazon/autocomplete`
    pub async fn autocomplete(&self, params: AutocompleteParams) -> Result<AutocompleteResponse> {
        let path = "/v1/amazon/autocomplete".to_string();
        let mut q = QueryParams::new();
        q.opt("query", params.query.as_ref());
        q.opt("domain", params.domain.as_ref());
        let query = q.into_pairs();
        let body = None;
        self.client.send(Method::GET, &path, &query, body).await
    }

    /// Bestsellers
    ///
    /// Top-selling products for a category (browse node).
    /// `GET /v1/amazon/bestsellers`
    pub async fn get_bestsellers(
        &self,
        params: GetBestsellersParams,
    ) -> Result<GetBestsellersResponse> {
        let path = "/v1/amazon/bestsellers".to_string();
        let mut q = QueryParams::new();
        q.opt("domain", params.domain.as_ref());
        q.opt("category", params.category.as_ref());
        q.opt("page", params.page.as_ref());
        let query = q.into_pairs();
        let body = None;
        self.client.send(Method::GET, &path, &query, body).await
    }

    /// List Categories
    ///
    /// List common Amazon department/category aliases and bestseller nodes.
    /// `GET /v1/amazon/categories`
    pub async fn list_categories(
        &self,
        params: ListCategoriesParams,
    ) -> Result<ListCategoriesResponse> {
        let path = "/v1/amazon/categories".to_string();
        let mut q = QueryParams::new();
        q.opt("domain", params.domain.as_ref());
        let query = q.into_pairs();
        let body = None;
        self.client.send(Method::GET, &path, &query, body).await
    }

    /// Browse Category
    ///
    /// List products within an Amazon browse-node category.
    /// `GET /v1/amazon/category`
    pub async fn browse_category(
        &self,
        params: BrowseCategoryParams,
    ) -> Result<BrowseCategoryResponse> {
        let path = "/v1/amazon/category".to_string();
        let mut q = QueryParams::new();
        q.opt("node", params.node.as_ref());
        q.opt("domain", params.domain.as_ref());
        q.opt("page", params.page.as_ref());
        q.opt("sort_by", params.sort_by.as_ref());
        let query = q.into_pairs();
        let body = None;
        self.client.send(Method::GET, &path, &query, body).await
    }

    /// Today's Deals
    ///
    /// Current Amazon deals (lightning deals, best deals).
    /// `GET /v1/amazon/deals`
    pub async fn get_deals(&self, params: GetDealsParams) -> Result<GetDealsResponse> {
        let path = "/v1/amazon/deals".to_string();
        let mut q = QueryParams::new();
        q.opt("domain", params.domain.as_ref());
        q.opt("category", params.category.as_ref());
        q.opt("page", params.page.as_ref());
        let query = q.into_pairs();
        let body = None;
        self.client.send(Method::GET, &path, &query, body).await
    }

    /// List Markets
    ///
    /// List all supported Amazon marketplaces.
    /// `GET /v1/amazon/markets`
    pub async fn list_markets(&self, params: ListMarketsParams) -> Result<ListMarketsResponse> {
        let path = "/v1/amazon/markets".to_string();
        let query: Vec<(String, String)> = Vec::new();
        let body = None;
        self.client.send(Method::GET, &path, &query, body).await
    }

    /// New Releases
    ///
    /// Newly released products for a category (browse node).
    /// `GET /v1/amazon/new-releases`
    pub async fn get_new_releases(
        &self,
        params: GetNewReleasesParams,
    ) -> Result<GetNewReleasesResponse> {
        let path = "/v1/amazon/new-releases".to_string();
        let mut q = QueryParams::new();
        q.opt("domain", params.domain.as_ref());
        q.opt("category", params.category.as_ref());
        q.opt("page", params.page.as_ref());
        let query = q.into_pairs();
        let body = None;
        self.client.send(Method::GET, &path, &query, body).await
    }

    /// Get Product Detail
    ///
    /// Full product detail by ASIN (price, variants, badges, buybox, ranks, ...).
    /// `GET /v1/amazon/products/{asin}`
    pub async fn get_product(
        &self,
        asin: impl AsRef<str>,
        params: GetProductParams,
    ) -> Result<GetProductResponse> {
        let path = format!("/v1/amazon/products/{asin}", asin = asin.as_ref());
        let mut q = QueryParams::new();
        q.opt("domain", params.domain.as_ref());
        q.opt("zip", params.zip.as_ref());
        q.opt("language", params.language.as_ref());
        let query = q.into_pairs();
        let body = None;
        self.client.send(Method::GET, &path, &query, body).await
    }

    /// Get Offers
    ///
    /// All third-party offers for an ASIN, including the Buy Box winner.
    /// `GET /v1/amazon/products/{asin}/offers`
    pub async fn get_offers(
        &self,
        asin: impl AsRef<str>,
        params: GetOffersParams,
    ) -> Result<GetOffersResponse> {
        let path = format!("/v1/amazon/products/{asin}/offers", asin = asin.as_ref());
        let mut q = QueryParams::new();
        q.opt("domain", params.domain.as_ref());
        q.opt("zip", params.zip.as_ref());
        let query = q.into_pairs();
        let body = None;
        self.client.send(Method::GET, &path, &query, body).await
    }

    /// Get Reviews
    ///
    /// Customer reviews for an ASIN (featured + paginated, with filters).
    /// `GET /v1/amazon/products/{asin}/reviews`
    pub async fn get_reviews(
        &self,
        asin: impl AsRef<str>,
        params: GetReviewsParams,
    ) -> Result<GetReviewsResponse> {
        let path = format!("/v1/amazon/products/{asin}/reviews", asin = asin.as_ref());
        let mut q = QueryParams::new();
        q.opt("domain", params.domain.as_ref());
        q.opt("page", params.page.as_ref());
        q.opt("sort_by", params.sort_by.as_ref());
        q.opt("star", params.star.as_ref());
        q.opt("verified_only", params.verified_only.as_ref());
        q.opt("media_only", params.media_only.as_ref());
        let query = q.into_pairs();
        let body = None;
        self.client.send(Method::GET, &path, &query, body).await
    }

    /// Search Products
    ///
    /// Search the Amazon catalog with filters and sorting.
    /// `GET /v1/amazon/search`
    pub async fn search_products(
        &self,
        params: SearchProductsParams,
    ) -> Result<SearchProductsResponse> {
        let path = "/v1/amazon/search".to_string();
        let mut q = QueryParams::new();
        q.opt("query", params.query.as_ref());
        q.opt("domain", params.domain.as_ref());
        q.opt("page", params.page.as_ref());
        q.opt("sort_by", params.sort_by.as_ref());
        q.opt("category", params.category.as_ref());
        q.opt("min_price", params.min_price.as_ref());
        q.opt("max_price", params.max_price.as_ref());
        q.opt("zip", params.zip.as_ref());
        q.opt("language", params.language.as_ref());
        let query = q.into_pairs();
        let body = None;
        self.client.send(Method::GET, &path, &query, body).await
    }

    /// Get Seller
    ///
    /// Seller profile, ratings and feedback summary.
    /// `GET /v1/amazon/sellers/{seller_id}`
    pub async fn get_seller(
        &self,
        seller_id: impl AsRef<str>,
        params: GetSellerParams,
    ) -> Result<GetSellerResponse> {
        let path = format!(
            "/v1/amazon/sellers/{seller_id}",
            seller_id = seller_id.as_ref()
        );
        let mut q = QueryParams::new();
        q.opt("domain", params.domain.as_ref());
        let query = q.into_pairs();
        let body = None;
        self.client.send(Method::GET, &path, &query, body).await
    }

    /// Seller Feedback
    ///
    /// Buyer feedback entries for a seller.
    /// `GET /v1/amazon/sellers/{seller_id}/feedback`
    pub async fn get_seller_feedback(
        &self,
        seller_id: impl AsRef<str>,
        params: GetSellerFeedbackParams,
    ) -> Result<GetSellerFeedbackResponse> {
        let path = format!(
            "/v1/amazon/sellers/{seller_id}/feedback",
            seller_id = seller_id.as_ref()
        );
        let mut q = QueryParams::new();
        q.opt("domain", params.domain.as_ref());
        q.opt("page", params.page.as_ref());
        let query = q.into_pairs();
        let body = None;
        self.client.send(Method::GET, &path, &query, body).await
    }

    /// Seller Products
    ///
    /// Products listed in a seller's storefront.
    /// `GET /v1/amazon/sellers/{seller_id}/products`
    pub async fn get_seller_products(
        &self,
        seller_id: impl AsRef<str>,
        params: GetSellerProductsParams,
    ) -> Result<GetSellerProductsResponse> {
        let path = format!(
            "/v1/amazon/sellers/{seller_id}/products",
            seller_id = seller_id.as_ref()
        );
        let mut q = QueryParams::new();
        q.opt("domain", params.domain.as_ref());
        q.opt("page", params.page.as_ref());
        let query = q.into_pairs();
        let body = None;
        self.client.send(Method::GET, &path, &query, body).await
    }
}

// ===== Models =====

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default)]
pub struct AmazonPrice {
    /// ISO 4217 currency code.
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub currency: Option<String>,
    /// Price exactly as displayed on Amazon.
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub raw: Option<String>,
    /// Currency symbol (e.g. $, £, €).
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub symbol: Option<String>,
    /// Numeric price value.
    #[serde(default, deserialize_with = "crate::core::flex::opt_f64")]
    pub value: Option<f64>,
    /// Fields present in the response but not in the spec.
    #[serde(flatten)]
    pub extra: HashMap<String, Value>,
}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default)]
pub struct AutocompleteResponse {
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub domain: Option<String>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub query: Option<String>,
    pub suggestions: Vec<AutocompleteResponseSuggestionsItem>,
    /// Fields present in the response but not in the spec.
    #[serde(flatten)]
    pub extra: HashMap<String, Value>,
}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default)]
pub struct AutocompleteResponseSuggestionsItem {
    /// Department alias the suggestion is scoped to, if any.
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub alias: Option<String>,
    /// Suggested search phrase.
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub value: Option<String>,
    /// Fields present in the response but not in the spec.
    #[serde(flatten)]
    pub extra: HashMap<String, Value>,
}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default)]
pub struct Bestseller {
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub asin: Option<String>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub image: Option<String>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub link: Option<String>,
    /// Position on the page.
    #[serde(default, deserialize_with = "crate::core::flex::opt_i64")]
    pub position: Option<i64>,
    pub price: Option<AmazonPrice>,
    /// Best-seller / new-release rank.
    #[serde(default, deserialize_with = "crate::core::flex::opt_i64")]
    pub rank: Option<i64>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_f64")]
    pub rating: Option<f64>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_i64")]
    pub ratings_total: Option<i64>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub title: Option<String>,
    /// Fields present in the response but not in the spec.
    #[serde(flatten)]
    pub extra: HashMap<String, Value>,
}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default)]
pub struct BrowseCategoryResponse {
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub domain: Option<String>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub node: Option<String>,
    pub pagination: Option<Pagination>,
    pub results: Vec<SearchResult>,
    /// Fields present in the response but not in the spec.
    #[serde(flatten)]
    pub extra: HashMap<String, Value>,
}

/// Allowed values for a fixed-value query parameter.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[non_exhaustive]
pub enum BrowseCategorySortBy {
    /// `relevance`
    #[serde(rename = "relevance")]
    Relevance,
    /// `price_low_to_high`
    #[serde(rename = "price_low_to_high")]
    PriceLowToHigh,
    /// `price_high_to_low`
    #[serde(rename = "price_high_to_low")]
    PriceHighToLow,
    /// `avg_review`
    #[serde(rename = "avg_review")]
    AvgReview,
    /// `newest`
    #[serde(rename = "newest")]
    Newest,
}

impl std::fmt::Display for BrowseCategorySortBy {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(match self {
            BrowseCategorySortBy::Relevance => "relevance",
            BrowseCategorySortBy::PriceLowToHigh => "price_low_to_high",
            BrowseCategorySortBy::PriceHighToLow => "price_high_to_low",
            BrowseCategorySortBy::AvgReview => "avg_review",
            BrowseCategorySortBy::Newest => "newest",
        })
    }
}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default)]
pub struct Deal {
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub asin: Option<String>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub badge: Option<String>,
    pub deal_price: Option<AmazonPrice>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub deal_type: Option<String>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_i64")]
    pub discount_percent: Option<i64>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub ends_at: Option<String>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_f64")]
    pub ends_at_utc: Option<f64>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub image: Option<String>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_bool")]
    pub is_lightning_deal: Option<bool>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub link: Option<String>,
    pub list_price: Option<AmazonPrice>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_i64")]
    pub position: Option<i64>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub title: Option<String>,
    /// Fields present in the response but not in the spec.
    #[serde(flatten)]
    pub extra: HashMap<String, Value>,
}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default)]
pub struct GetBestsellersResponse {
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub category: Option<String>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub domain: Option<String>,
    pub results: Vec<Bestseller>,
    /// Fields present in the response but not in the spec.
    #[serde(flatten)]
    pub extra: HashMap<String, Value>,
}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default)]
pub struct GetDealsResponse {
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub category: Option<String>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub domain: Option<String>,
    pub results: Vec<Deal>,
    /// Fields present in the response but not in the spec.
    #[serde(flatten)]
    pub extra: HashMap<String, Value>,
}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default)]
pub struct GetNewReleasesResponse {
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub category: Option<String>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub domain: Option<String>,
    pub results: Vec<Bestseller>,
    /// Fields present in the response but not in the spec.
    #[serde(flatten)]
    pub extra: HashMap<String, Value>,
}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default)]
pub struct GetOffersResponse {
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub asin: Option<String>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub domain: Option<String>,
    pub offers: Vec<Offer>,
    /// Fields present in the response but not in the spec.
    #[serde(flatten)]
    pub extra: HashMap<String, Value>,
}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default)]
pub struct GetProductResponse {
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub domain: Option<String>,
    pub product: Option<Product>,
    /// Fields present in the response but not in the spec.
    #[serde(flatten)]
    pub extra: HashMap<String, Value>,
}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default)]
pub struct GetReviewsResponse {
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub asin: Option<String>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub domain: Option<String>,
    pub pagination: Option<Pagination>,
    /// Overall average product rating.
    #[serde(default, deserialize_with = "crate::core::flex::opt_f64")]
    pub rating: Option<f64>,
    pub rating_breakdown: Option<GetReviewsResponseRatingBreakdown>,
    /// Total number of ratings for the product.
    #[serde(default, deserialize_with = "crate::core::flex::opt_i64")]
    pub ratings_total: Option<i64>,
    pub reviews: Vec<Review>,
    /// Fields present in the response but not in the spec.
    #[serde(flatten)]
    pub extra: HashMap<String, Value>,
}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default)]
pub struct GetReviewsResponseRatingBreakdown {
    #[serde(default, deserialize_with = "crate::core::flex::opt_i64")]
    pub five_star: Option<i64>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_i64")]
    pub four_star: Option<i64>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_i64")]
    pub one_star: Option<i64>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_i64")]
    pub three_star: Option<i64>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_i64")]
    pub two_star: Option<i64>,
    /// Fields present in the response but not in the spec.
    #[serde(flatten)]
    pub extra: HashMap<String, Value>,
}

/// Allowed values for a fixed-value query parameter.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[non_exhaustive]
pub enum GetReviewsSortBy {
    /// `helpful`
    #[serde(rename = "helpful")]
    Helpful,
    /// `recent`
    #[serde(rename = "recent")]
    Recent,
}

impl std::fmt::Display for GetReviewsSortBy {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(match self {
            GetReviewsSortBy::Helpful => "helpful",
            GetReviewsSortBy::Recent => "recent",
        })
    }
}

/// Allowed values for a fixed-value query parameter.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[non_exhaustive]
pub enum GetReviewsStar {
    /// `one_star`
    #[serde(rename = "one_star")]
    OneStar,
    /// `two_star`
    #[serde(rename = "two_star")]
    TwoStar,
    /// `three_star`
    #[serde(rename = "three_star")]
    ThreeStar,
    /// `four_star`
    #[serde(rename = "four_star")]
    FourStar,
    /// `five_star`
    #[serde(rename = "five_star")]
    FiveStar,
    /// `positive`
    #[serde(rename = "positive")]
    Positive,
    /// `critical`
    #[serde(rename = "critical")]
    Critical,
}

impl std::fmt::Display for GetReviewsStar {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(match self {
            GetReviewsStar::OneStar => "one_star",
            GetReviewsStar::TwoStar => "two_star",
            GetReviewsStar::ThreeStar => "three_star",
            GetReviewsStar::FourStar => "four_star",
            GetReviewsStar::FiveStar => "five_star",
            GetReviewsStar::Positive => "positive",
            GetReviewsStar::Critical => "critical",
        })
    }
}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default)]
pub struct GetSellerFeedbackResponse {
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub domain: Option<String>,
    pub feedback: Vec<GetSellerFeedbackResponseFeedbackItem>,
    pub pagination: Option<Pagination>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub seller_id: Option<String>,
    /// Fields present in the response but not in the spec.
    #[serde(flatten)]
    pub extra: HashMap<String, Value>,
}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default)]
pub struct GetSellerFeedbackResponseFeedbackItem {
    /// Feedback comment text.
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub body: Option<String>,
    /// ISO 8601 timestamp of the feedback.
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub date_at: Option<String>,
    /// Raw date string as shown on Amazon.
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub date_raw: Option<String>,
    /// Buyer display name, if shown.
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub rater: Option<String>,
    /// Star rating left by the buyer (1-5).
    #[serde(default, deserialize_with = "crate::core::flex::opt_i64")]
    pub rating: Option<i64>,
    /// Fields present in the response but not in the spec.
    #[serde(flatten)]
    pub extra: HashMap<String, Value>,
}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default)]
pub struct GetSellerProductsResponse {
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub domain: Option<String>,
    pub pagination: Option<Pagination>,
    pub results: Vec<SearchResult>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub seller_id: Option<String>,
    /// Fields present in the response but not in the spec.
    #[serde(flatten)]
    pub extra: HashMap<String, Value>,
}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default)]
pub struct GetSellerResponse {
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub domain: Option<String>,
    pub seller: Option<Seller>,
    /// Fields present in the response but not in the spec.
    #[serde(flatten)]
    pub extra: HashMap<String, Value>,
}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default)]
pub struct ListCategoriesResponse {
    pub categories: Vec<ListCategoriesResponseCategoriesItem>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub domain: Option<String>,
    /// Fields present in the response but not in the spec.
    #[serde(flatten)]
    pub extra: HashMap<String, Value>,
}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default)]
pub struct ListCategoriesResponseCategoriesItem {
    /// Category alias usable in the search category parameter (the i= value).
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub alias: Option<String>,
    /// Browse-node slug usable with bestsellers / new-releases.
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub bestsellers_node: Option<String>,
    /// Human-readable department name.
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub name: Option<String>,
    /// Fields present in the response but not in the spec.
    #[serde(flatten)]
    pub extra: HashMap<String, Value>,
}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default)]
pub struct ListMarketsResponse {
    pub markets: Vec<ListMarketsResponseMarketsItem>,
    /// Fields present in the response but not in the spec.
    #[serde(flatten)]
    pub extra: HashMap<String, Value>,
}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default)]
pub struct ListMarketsResponseMarketsItem {
    /// Market code (e.g. US, UK, DE).
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub code: Option<String>,
    /// ISO country code used for proxy geo-targeting.
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub country_code: Option<String>,
    /// ISO 4217 currency code.
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub currency: Option<String>,
    /// Amazon domain TLD for this market (e.g. com, co.uk).
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub domain: Option<String>,
    /// Default locale for this market.
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub language: Option<String>,
    /// Marketplace country name.
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub name: Option<String>,
    /// Fields present in the response but not in the spec.
    #[serde(flatten)]
    pub extra: HashMap<String, Value>,
}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default)]
pub struct Offer {
    /// Whether this offer currently wins the Buy Box.
    #[serde(default, deserialize_with = "crate::core::flex::opt_bool")]
    pub buybox_winner: Option<bool>,
    /// is_new, title, comments.
    pub condition: HashMap<String, Value>,
    /// is_free, fulfilled_by_amazon, date, price.
    pub delivery: HashMap<String, Value>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_bool")]
    pub is_prime: Option<bool>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_i64")]
    pub maximum_order_quantity: Option<i64>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_i64")]
    pub minimum_order_quantity: Option<i64>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_i64")]
    pub position: Option<i64>,
    pub price: Option<AmazonPrice>,
    /// Seller summary: name, id, link, rating, ratings_total, ratings_percentage_positive.
    pub seller: HashMap<String, Value>,
    /// Fields present in the response but not in the spec.
    #[serde(flatten)]
    pub extra: HashMap<String, Value>,
}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default)]
pub struct Pagination {
    /// Current page number.
    #[serde(default, deserialize_with = "crate::core::flex::opt_i64")]
    pub current_page: Option<i64>,
    /// Total number of pages available.
    #[serde(default, deserialize_with = "crate::core::flex::opt_i64")]
    pub total_pages: Option<i64>,
    /// Total number of results across all pages.
    #[serde(default, deserialize_with = "crate::core::flex::opt_i64")]
    pub total_results: Option<i64>,
    /// Fields present in the response but not in the spec.
    #[serde(flatten)]
    pub extra: HashMap<String, Value>,
}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default)]
pub struct Product {
    pub also_bought: Vec<String>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_i64")]
    pub answered_questions: Option<i64>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub asin: Option<String>,
    pub attributes: HashMap<String, Value>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub availability: Option<String>,
    /// amazons_choice, amazons_choice_keyword, best_seller, prime, climate_pledge_friendly.
    pub badges: HashMap<String, Value>,
    /// Best-seller ranks with rank, category, link.
    pub bestsellers_rank: Vec<HashMap<String, Value>>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub bought_past_month: Option<String>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub brand: Option<String>,
    /// Buy Box winner: seller_name, seller_id, price, fulfillment.
    pub buybox: HashMap<String, Value>,
    /// Breadcrumb categories.
    pub categories: Vec<HashMap<String, Value>>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub country_of_origin: Option<String>,
    pub coupon: Option<HashMap<String, Value>>,
    pub deal: Option<HashMap<String, Value>>,
    pub delivery: Option<HashMap<String, Value>>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub description: Option<String>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub dimensions: Option<String>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_i64")]
    pub discount_percent: Option<i64>,
    pub feature_bullets: Vec<String>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub first_available: Option<String>,
    pub frequently_bought_together: Vec<String>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub fulfilled_by: Option<String>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_bool")]
    pub has_aplus_content: Option<bool>,
    pub images: Vec<String>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_i64")]
    pub images_count: Option<i64>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_bool")]
    pub in_stock: Option<bool>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_bool")]
    pub is_amazon_seller: Option<bool>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub link: Option<String>,
    pub list_price: Option<AmazonPrice>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub main_image: Option<String>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub manufacturer: Option<String>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub model_number: Option<String>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub parent_asin: Option<String>,
    pub price: Option<AmazonPrice>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_f64")]
    pub rating: Option<f64>,
    /// Percentage of ratings per star bucket (five_star ... one_star).
    pub rating_breakdown: HashMap<String, Value>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_i64")]
    pub ratings_total: Option<i64>,
    pub savings_amount: Option<AmazonPrice>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub scraped_at: Option<String>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_f64")]
    pub scraped_utc: Option<f64>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub ships_from: Option<String>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub sold_by: Option<String>,
    pub specifications: HashMap<String, Value>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub title: Option<String>,
    pub top_reviews: Vec<Review>,
    pub variant_asins: Vec<String>,
    /// Variation children with asin, attributes, price, is_current.
    pub variants: Vec<HashMap<String, Value>>,
    pub videos: Vec<String>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_i64")]
    pub videos_count: Option<i64>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub weight: Option<String>,
    /// Fields present in the response but not in the spec.
    #[serde(flatten)]
    pub extra: HashMap<String, Value>,
}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default)]
pub struct Review {
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub body: Option<String>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub date_at: Option<String>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub date_raw: Option<String>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_f64")]
    pub date_utc: Option<f64>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_i64")]
    pub helpful_votes: Option<i64>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub id: Option<String>,
    pub images: Vec<String>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_bool")]
    pub is_global_review: Option<bool>,
    /// Reviewer profile: name, link, id, image.
    pub profile: HashMap<String, Value>,
    /// Star rating left by the reviewer (1-5).
    #[serde(default, deserialize_with = "crate::core::flex::opt_i64")]
    pub rating: Option<i64>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub review_country: Option<String>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub title: Option<String>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub variant: Option<String>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_bool")]
    pub verified_purchase: Option<bool>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_bool")]
    pub vine_program: Option<bool>,
    /// Fields present in the response but not in the spec.
    #[serde(flatten)]
    pub extra: HashMap<String, Value>,
}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default)]
pub struct SearchProductsResponse {
    /// Marketplace domain that was searched.
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub domain: Option<String>,
    pub pagination: Option<Pagination>,
    /// The search query that was executed.
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub query: Option<String>,
    pub results: Vec<SearchResult>,
    /// Fields present in the response but not in the spec.
    #[serde(flatten)]
    pub extra: HashMap<String, Value>,
}

/// Allowed values for a fixed-value query parameter.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[non_exhaustive]
pub enum SearchProductsSortBy {
    /// `relevance`
    #[serde(rename = "relevance")]
    Relevance,
    /// `price_low_to_high`
    #[serde(rename = "price_low_to_high")]
    PriceLowToHigh,
    /// `price_high_to_low`
    #[serde(rename = "price_high_to_low")]
    PriceHighToLow,
    /// `avg_review`
    #[serde(rename = "avg_review")]
    AvgReview,
    /// `newest`
    #[serde(rename = "newest")]
    Newest,
}

impl std::fmt::Display for SearchProductsSortBy {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(match self {
            SearchProductsSortBy::Relevance => "relevance",
            SearchProductsSortBy::PriceLowToHigh => "price_low_to_high",
            SearchProductsSortBy::PriceHighToLow => "price_high_to_low",
            SearchProductsSortBy::AvgReview => "avg_review",
            SearchProductsSortBy::Newest => "newest",
        })
    }
}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default)]
pub struct SearchResult {
    /// Amazon Standard Identification Number.
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub asin: Option<String>,
    /// Availability/stock message.
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub availability: Option<String>,
    /// Purchase-volume hint (e.g. "5K+ bought in past month").
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub bought_past_month: Option<String>,
    /// Coupon text, if any.
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub coupon: Option<String>,
    /// Primary product image URL.
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub image: Option<String>,
    /// Whether the item has the Amazon's Choice badge.
    #[serde(default, deserialize_with = "crate::core::flex::opt_bool")]
    pub is_amazons_choice: Option<bool>,
    /// Whether the item has the Best Seller badge.
    #[serde(default, deserialize_with = "crate::core::flex::opt_bool")]
    pub is_best_seller: Option<bool>,
    /// Whether the item is Prime-eligible.
    #[serde(default, deserialize_with = "crate::core::flex::opt_bool")]
    pub is_prime: Option<bool>,
    /// Whether the result is a sponsored placement.
    #[serde(default, deserialize_with = "crate::core::flex::opt_bool")]
    pub is_sponsored: Option<bool>,
    /// Full URL to the product page.
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub link: Option<String>,
    pub list_price: Option<AmazonPrice>,
    /// Position of the result on the page (1-based).
    #[serde(default, deserialize_with = "crate::core::flex::opt_i64")]
    pub position: Option<i64>,
    pub price: Option<AmazonPrice>,
    /// Average star rating (0-5).
    #[serde(default, deserialize_with = "crate::core::flex::opt_f64")]
    pub rating: Option<f64>,
    /// Total number of ratings.
    #[serde(default, deserialize_with = "crate::core::flex::opt_i64")]
    pub ratings_total: Option<i64>,
    /// Product title.
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub title: Option<String>,
    /// Unit price string (e.g. "$0.50 / count").
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub unit_price: Option<String>,
    /// Fields present in the response but not in the spec.
    #[serde(flatten)]
    pub extra: HashMap<String, Value>,
}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default)]
pub struct Seller {
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub business_address: Option<String>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub business_name: Option<String>,
    /// Feedback windows (lifetime, 12mo, 90d, 30d) each with positive, neutral, negative, count.
    pub feedback: HashMap<String, Value>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub link: Option<String>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub member_since: Option<String>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub name: Option<String>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_f64")]
    pub rating: Option<f64>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_i64")]
    pub ratings_percentage_positive: Option<i64>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_i64")]
    pub ratings_total: Option<i64>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub seller_id: Option<String>,
    /// Fields present in the response but not in the spec.
    #[serde(flatten)]
    pub extra: HashMap<String, Value>,
}

/// Parameters for [`AutocompleteParams`]. All fields optional; required ones are noted per method.
#[derive(Debug, Clone, Default, Serialize)]
pub struct AutocompleteParams {
    /// Partial search term to expand into suggestions.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub query: Option<String>,
    /// Amazon marketplace TLD or code (com, co.uk, de, ...).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub domain: Option<String>,
}

/// Parameters for [`GetBestsellersParams`]. All fields optional; required ones are noted per method.
#[derive(Debug, Clone, Default, Serialize)]
pub struct GetBestsellersParams {
    /// Amazon marketplace TLD or code (com, co.uk, de, ...).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub domain: Option<String>,
    /// Bestsellers node id or category slug (e.g. electronics).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub category: Option<String>,
    /// Page number (each page covers 50 ranks; max 2).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub page: Option<i64>,
}

/// Parameters for [`ListCategoriesParams`]. All fields optional; required ones are noted per method.
#[derive(Debug, Clone, Default, Serialize)]
pub struct ListCategoriesParams {
    /// Amazon marketplace TLD or code. Category aliases are scoped per marketplace.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub domain: Option<String>,
}

/// Parameters for [`BrowseCategoryParams`]. All fields optional; required ones are noted per method.
#[derive(Debug, Clone, Default, Serialize)]
pub struct BrowseCategoryParams {
    /// Amazon browse-node id to list products from.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub node: Option<String>,
    /// Amazon marketplace TLD or code (com, co.uk, de, ...).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub domain: Option<String>,
    /// Page number for paginated results.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub page: Option<i64>,
    /// Sort order for results.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub sort_by: Option<BrowseCategorySortBy>,
}

/// Parameters for [`GetDealsParams`]. All fields optional; required ones are noted per method.
#[derive(Debug, Clone, Default, Serialize)]
pub struct GetDealsParams {
    /// Amazon marketplace TLD or code (com, co.uk, de, ...).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub domain: Option<String>,
    /// Category alias to scope the deals feed.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub category: Option<String>,
    /// Page number for paginated deals.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub page: Option<i64>,
}

/// Parameters for [`ListMarketsParams`]. All fields optional; required ones are noted per method.
#[derive(Debug, Clone, Default, Serialize)]
pub struct ListMarketsParams {}

/// Parameters for [`GetNewReleasesParams`]. All fields optional; required ones are noted per method.
#[derive(Debug, Clone, Default, Serialize)]
pub struct GetNewReleasesParams {
    /// Amazon marketplace TLD or code (com, co.uk, de, ...).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub domain: Option<String>,
    /// New-releases node id or category slug.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub category: Option<String>,
    /// Page number (each page covers 50 ranks; max 2).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub page: Option<i64>,
}

/// Parameters for [`GetProductParams`]. All fields optional; required ones are noted per method.
#[derive(Debug, Clone, Default, Serialize)]
pub struct GetProductParams {
    /// Amazon marketplace TLD or code (com, co.uk, de, ...).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub domain: Option<String>,
    /// Delivery postal/zip code for a localized buybox.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub zip: Option<String>,
    /// Locale for the product page, e.g. en_US, de_DE.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub language: Option<String>,
}

/// Parameters for [`GetOffersParams`]. All fields optional; required ones are noted per method.
#[derive(Debug, Clone, Default, Serialize)]
pub struct GetOffersParams {
    /// Amazon marketplace TLD or code (com, co.uk, de, ...).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub domain: Option<String>,
    /// Delivery postal/zip code for localized offers and delivery estimates.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub zip: Option<String>,
}

/// Parameters for [`GetReviewsParams`]. All fields optional; required ones are noted per method.
#[derive(Debug, Clone, Default, Serialize)]
pub struct GetReviewsParams {
    /// Amazon marketplace TLD or code (com, co.uk, de, ...).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub domain: Option<String>,
    /// Page number for paginated reviews.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub page: Option<i64>,
    /// Sort order for reviews.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub sort_by: Option<GetReviewsSortBy>,
    /// Filter reviews by star rating or sentiment.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub star: Option<GetReviewsStar>,
    /// Only return reviews from verified purchases.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub verified_only: Option<bool>,
    /// Only return reviews that include images or video.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub media_only: Option<bool>,
}

/// Parameters for [`SearchProductsParams`]. All fields optional; required ones are noted per method.
#[derive(Debug, Clone, Default, Serialize)]
pub struct SearchProductsParams {
    /// Search keywords.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub query: Option<String>,
    /// Amazon marketplace TLD or code (com, co.uk, de, fr, ...).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub domain: Option<String>,
    /// Page number for paginated results.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub page: Option<i64>,
    /// Sort order for results.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub sort_by: Option<SearchProductsSortBy>,
    /// Department/category alias to scope the search (the i= parameter).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub category: Option<String>,
    /// Minimum price filter in the marketplace's local currency.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub min_price: Option<f64>,
    /// Maximum price filter in the marketplace's local currency.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub max_price: Option<f64>,
    /// Delivery postal/zip code for localized pricing.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub zip: Option<String>,
    /// Locale for results, e.g. en_US, fr_FR.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub language: Option<String>,
}

/// Parameters for [`GetSellerParams`]. All fields optional; required ones are noted per method.
#[derive(Debug, Clone, Default, Serialize)]
pub struct GetSellerParams {
    /// Amazon marketplace TLD or code (com, co.uk, de, ...).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub domain: Option<String>,
}

/// Parameters for [`GetSellerFeedbackParams`]. All fields optional; required ones are noted per method.
#[derive(Debug, Clone, Default, Serialize)]
pub struct GetSellerFeedbackParams {
    /// Amazon marketplace TLD or code (com, co.uk, de, ...).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub domain: Option<String>,
    /// Page number for paginated feedback entries.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub page: Option<i64>,
}

/// Parameters for [`GetSellerProductsParams`]. All fields optional; required ones are noted per method.
#[derive(Debug, Clone, Default, Serialize)]
pub struct GetSellerProductsParams {
    /// Amazon marketplace TLD or code (com, co.uk, de, ...).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub domain: Option<String>,
    /// Page number for paginated storefront results.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub page: Option<i64>,
}