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
use chrono::NaiveDateTime;
use serde::{Deserialize, Serialize};

use crate::dmm::{ApiResult, ElementVec};

#[derive(Serialize, Debug, Default)]
pub struct ItemListParams {
    pub site: SiteValue,
    pub service: Option<String>,
    pub floor: Option<String>,
    pub hits: Option<i64>,
    pub offset: Option<i64>,
    pub sort: Option<SortValue>,
    pub keyword: Option<String>,
    pub cid: Option<String>,
    pub article: Option<ArticleValue>,
    pub article_id: Option<String>,
    pub gte_date: Option<NaiveDateTime>,
    pub lte_date: Option<NaiveDateTime>,
    pub mono_stock: Option<MonoStockValue>,
}

#[derive(Serialize, Debug)]
#[serde(rename_all = "lowercase")]
pub enum SortValue {
    Rank,
    Price,
    #[serde(rename = "-price")]
    PriceDesc,
    Date,
    Review,
    Match,
}

#[derive(Serialize, Debug)]
#[serde(rename_all = "lowercase")]
pub enum ArticleValue {
    Actress,
    Author,
    Genre,
    Series,
    Maker,
}

#[derive(Serialize, Debug)]
#[serde(rename_all = "snake_case")]
pub enum MonoStockValue {
    Stock,
    Reserve,
    ReserveEmpty,
    Mono,
    Dmp,
}

#[derive(Serialize, Debug, Default)]
pub enum SiteValue {
    #[serde(rename = "FANZA")]
    Fanza,
    #[default]
    #[serde(rename = "DMM.com")]
    Dmm,
}

#[derive(Deserialize, Debug)]
pub struct ItemListResult {
    pub status: i64,
    pub result_count: i64,
    pub total_count: i64,
    pub first_position: i64,
    pub items: ElementVec<Item>,
}
impl ApiResult for ItemListResult {}

#[derive(Deserialize, Debug)]
// #[serde(deny_unknown_fields)]
pub struct Item {
    pub service_code: String,
    pub service_name: String,
    pub floor_code: String,
    pub floor_name: String,
    pub category_name: String,
    pub content_id: String,
    pub product_id: String,
    pub title: String,
    pub volume: Option<String>,
    pub number: Option<String>,
    pub review: Option<Review>,
    #[serde(rename = "URL")]
    pub url: String,
    #[serde(rename = "affiliateURL")]
    pub affiliate_url: Option<String>,
    #[serde(rename = "imageURL")]
    pub image_url: ImageUrl,
    pub tachiyomi: Option<Tachiyomi>,
    #[serde(rename = "sampleImageURL")]
    pub sample_image_url: Option<SampleImageUrl>,
    #[serde(rename = "sampleMovieURL")]
    pub sample_movie_url: Option<SampleMovieUrl>,
    pub prices: Prices,
    pub date: String, // datetime?
    pub iteminfo: Iteminfo,
    pub cdinfo: Option<Cdinfo>,
    pub jancode: Option<String>,
    pub maker_product: Option<String>,
    pub isbn: Option<String>,
    pub stock: Option<StockValue>,
    pub directory: Option<ElementVec<Directory>>,
    pub campaign: Option<Campaign>,
}

#[derive(Deserialize, Debug)]
#[serde(rename_all = "snake_case")]
pub enum StockValue {
    Stock,
    Reserve,
    ReserveEmpty,
    Mono,
    Dmp,
    Empty,
}

#[derive(Deserialize, Debug)]
pub struct Review {
    pub count: i64,
    pub average: f64,
}

#[derive(Deserialize, Debug)]
pub struct ImageUrl {
    pub list: String,
    pub small: String,
    pub large: String,
}

#[derive(Deserialize, Debug)]
pub struct Tachiyomi {
    #[serde(rename = "URL")]
    pub url: String,
    #[serde(rename = "affiliateURL")]
    pub affiliate_url: String,
}

#[derive(Deserialize, Debug)]
pub struct SampleImageUrl {
    pub sample_s: SampleS,
    pub sample_l: Option<SampleL>,
}

#[derive(Deserialize, Debug)]
pub struct SampleS {
    pub image: ElementVec<String>,
}
#[derive(Deserialize, Debug)]
pub struct SampleL {
    pub image: ElementVec<String>,
}

#[derive(Deserialize, Debug)]
pub struct SampleMovieUrl {
    pub size_476_306: String,
    pub size_560_360: String,
    pub size_644_414: String,
    pub size_720_480: String,
    pub pc_flag: i64,
    pub sp_flag: i64,
}

#[derive(Deserialize, Debug)]
pub struct Prices {
    pub price: String,
    pub list_price: Option<String>,
}

#[derive(Deserialize, Debug)]
pub struct Deliveries {
    pub delivery: ElementVec<Delivery>,
}

#[derive(Deserialize, Debug)]
pub struct Delivery {
    pub r#type: String,
    pub price: String,
}

#[derive(Deserialize, Debug)]
pub struct Iteminfo {
    pub genre: Option<ElementVec<Genre>>,
    pub series: Option<ElementVec<Series>>,
    pub maker: Option<ElementVec<Maker>>,
    pub actor: Option<ElementVec<Actor>>,
    pub actress: Option<ElementVec<Actress>>,
    pub director: Option<ElementVec<Director>>,
    pub author: Option<ElementVec<Author>>,
    pub label: Option<ElementVec<Label>>,
    pub r#type: Option<ElementVec<Type>>,
    pub color: Option<ElementVec<Color>>,
    pub size: Option<ElementVec<Size>>,
}

#[derive(Deserialize, Debug)]
pub struct Genre {
    pub name: String,
    pub id: String,
}
#[derive(Deserialize, Debug)]
pub struct Series {
    pub name: String,
    pub id: String,
}
#[derive(Deserialize, Debug)]
pub struct Maker {
    pub name: String,
    pub id: String,
}
#[derive(Deserialize, Debug)]
pub struct Actor {
    pub name: String,
    pub id: String,
}
#[derive(Deserialize, Debug)]
pub struct Actress {
    pub name: String,
    pub id: String,
}
#[derive(Deserialize, Debug)]
pub struct Director {
    pub name: String,
    pub id: String,
}
#[derive(Deserialize, Debug)]
pub struct Author {
    pub name: String,
    pub id: String,
}
#[derive(Deserialize, Debug)]
pub struct Label {
    pub name: String,
    pub id: String,
}
#[derive(Deserialize, Debug)]
pub struct Type {
    pub name: String,
    pub id: String,
}
#[derive(Deserialize, Debug)]
pub struct Color {
    pub name: String,
    pub id: String,
}
#[derive(Deserialize, Debug)]
pub struct Size {
    pub name: String,
    pub id: String,
}

#[derive(Deserialize, Debug)]
pub struct Cdinfo {
    pub king: String,
}

#[derive(Deserialize, Debug)]
pub struct Directory {
    pub id: String,
    pub name: String,
}

#[derive(Deserialize, Debug)]
pub struct Campaign {
    pub date_begin: NaiveDateTime,
    pub date_end: NaiveDateTime,
    pub title: String,
}