tosho-nids 0.1.1

An asynchronous client for NI by DS
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
//! A module containing information related to some others response models.
//!
//! If something is missing, please [open an issue](https://github.com/noaione/tosho-mango/issues/new/choose) or a [pull request](https://github.com/noaione/tosho-mango/compare).

use serde::{Deserialize, Serialize};
use tosho_macros::AutoGetter;

use crate::models::TokenData;

/// Response for publishers list
#[derive(Debug, Clone, AutoGetter, Serialize, Deserialize)]
pub struct PublishersList {
    /// Total pages available using the current page size
    #[serde(rename = "pages_count")]
    pages: u32,
    /// Total publishers available
    #[serde(rename = "total_count")]
    count: u64,
    /// List of publishers
    #[serde(rename = "publishers")]
    data: Vec<super::common::Publisher>,
}

/// Response for publisher imprints list
#[derive(Debug, Clone, AutoGetter, Serialize, Deserialize)]
pub struct ImprintsList {
    /// Total pages available using the current page size
    #[serde(rename = "pages_count")]
    pages: u32,
    /// Total imprints available
    #[serde(rename = "total_count")]
    count: u64,
    /// List of imprints
    #[serde(rename = "publisher_imprints")]
    data: Vec<super::common::Imprint>,
}

/// Response for genres list
#[derive(Debug, Clone, AutoGetter, Serialize, Deserialize)]
pub struct GenresList {
    /// Total pages available using the current page size
    #[serde(rename = "pages_count")]
    pages: u32,
    /// Total genres available
    #[serde(rename = "total_count")]
    count: u64,
    /// List of genres
    #[serde(rename = "genres")]
    data: Vec<super::common::Genre>,
}

/// Response for creators list
#[derive(Debug, Clone, AutoGetter, Serialize, Deserialize)]
pub struct CreatorsList {
    /// Total pages available using the current page size
    #[serde(rename = "pages_count")]
    pages: u32,
    /// Total creators available
    #[serde(rename = "total_count")]
    count: u64,
    /// List of creators
    #[serde(rename = "creators")]
    data: Vec<super::common::Creator>,
}

/// Marketplace books information
#[derive(Debug, Clone, AutoGetter, Serialize, Deserialize)]
pub struct MarketplaceBook {
    /// Issue ID
    id: u32,
    /// Issue UUID
    uuid: String,
    /// The series title
    title: String,
    /// The series + issue full title
    full_title: String,
    /// The issue URL slug
    slug: String,
    /// The publisher information
    publisher: super::common::Publisher,
    /// The imprint information
    #[serde(rename = "publisher_imprint")]
    imprint: Option<super::common::Imprint>,
    /// The issue cover image URLs
    cover: super::common::ImageUrl,
    /// The issue release date in ISO 8601 format
    #[serde(with = "super::datetime")]
    release_date: chrono::DateTime<chrono::FixedOffset>,
    /// The minimum price of the issue in USD
    #[serde(rename = "edition_price_min")]
    minimum_price: u64,
    /// The maximum price of the issue in USD
    #[serde(rename = "edition_price_max")]
    maximum_price: u64,
    /// Total available editions of this issue
    total_editions: u32,
    /// Total editions available in marketplace
    #[serde(rename = "editions_count_in_marketplace")]
    marketplace_count: u32,
    /// Total editions available in marketplace which is remarque
    #[serde(rename = "editions_count_in_marketplace_with_rmq")]
    marketplace_remarque_count: u32,
    /// When is this issue was added to marketplace
    #[serde(rename = "marketplace_added_date", with = "super::datetime")]
    created_at: chrono::DateTime<chrono::FixedOffset>,
}

/// Response for marketplace books list
#[derive(Debug, Clone, AutoGetter, Serialize, Deserialize)]
pub struct MarketplaceBooksList {
    /// Total pages available using the current page size
    #[serde(rename = "pages_count")]
    pages: u32,
    /// Total books available in marketplace
    #[serde(rename = "total_count")]
    count: u64,
    /// List of books in marketplace
    #[serde(rename = "books")]
    data: Vec<MarketplaceBook>,
}

/// Marketplace edition seller information
#[derive(Debug, Clone, AutoGetter, Serialize, Deserialize)]
pub struct MarketplaceSeller {
    /// User ID of the seller
    uuid: String,
    /// The username of the seller
    username: String,
    /// The email of the seller (why is this even here???)
    email: String,
    /// The seller first name
    first_name: Option<String>,
    /// The seller last name
    last_name: Option<String>,
    // TODO: image cover (but it's an empty object in response)
}

/// Marketplace edition information
#[derive(Debug, Clone, AutoGetter, Serialize, Deserialize)]
pub struct MarketplaceEdition {
    /// Marketplace edition ID
    id: String,
    /// The issue UUID
    #[serde(rename = "book_id")]
    issue_uuid: String,
    /// The issue index number
    #[serde(rename = "book_index")]
    index: u32,
    /// The price of the edition in USD
    #[serde(rename = "marketplace_price")]
    price_usd: u64,
    /// Marketplace creation date in ISO 8601 format
    #[serde(rename = "marketplace_created_at", with = "super::datetime")]
    created_at: chrono::DateTime<chrono::FixedOffset>,
    /// The seller information
    #[serde(rename = "owner")]
    seller: MarketplaceSeller,
    /// Seller notes
    #[serde(rename = "seller_notes")]
    notes: Option<String>,
    /// Has signature/remarque
    #[serde(rename = "sig")]
    signature: bool,
    /// The cover URL with the signature/remarque + watermarking
    #[serde(rename = "remarqued_watermark_cover_url")]
    remarque_cover: Option<String>,
}

/// Marketplace issue information
#[derive(Debug, Clone, AutoGetter, Serialize, Deserialize)]
pub struct MarketplaceIssue {
    /// Issue ID
    id: u32,
    /// Issue UUID
    uuid: String,
    /// The series title
    title: String,
    /// The series + issue full title
    full_title: String,
    /// The issue URL slug
    slug: String,
    /// The publisher information
    publisher: super::common::Publisher,
    /// The issue cover URL
    cover: super::common::ImageUrl,
}

/// Marketplace detailed edition information
#[derive(Debug, Clone, AutoGetter, Serialize, Deserialize)]
pub struct MarketplaceDetailedEdition {
    /// Marketplace edition ID
    id: String,
    /// The issue information
    #[serde(rename = "book")]
    issue: MarketplaceIssue,
    /// The issue index number
    #[serde(rename = "book_index")]
    index: u32,
    /// The price of the edition in USD
    #[serde(rename = "marketplace_price")]
    price_usd: u64,
    /// Marketplace creation date in ISO 8601 format
    #[serde(rename = "marketplace_created_at", with = "super::datetime")]
    created_at: chrono::DateTime<chrono::FixedOffset>,
    /// The seller information
    #[serde(rename = "owner")]
    seller: MarketplaceSeller,
    /// Seller notes
    #[serde(rename = "seller_notes")]
    notes: Option<String>,
    /// Has signature/remarque
    #[serde(rename = "sig")]
    signature: bool,
    /// The cover URL with the signature/remarque + watermarking
    #[serde(rename = "remarqued_watermark_cover_url")]
    remarque_cover: Option<String>,
}

/// Response for marketplace edition list
#[derive(Debug, Clone, AutoGetter, Serialize, Deserialize)]
pub struct MarketplaceEditionsList {
    /// Total pages available using the current page size
    #[serde(rename = "pages_count")]
    pages: u32,
    /// Total editions available in marketplace
    #[serde(rename = "total_count")]
    count: u64,
    /// List of editions in marketplace
    #[serde(rename = "editions")]
    data: Vec<MarketplaceEdition>,
}

/// Response for marketplace edition list
#[derive(Debug, Clone, AutoGetter, Serialize, Deserialize)]
pub struct MarketplaceDetailedEditionsList {
    /// Total pages available using the current page size
    #[serde(rename = "pages_count")]
    pages: u32,
    /// Total editions available in marketplace
    #[serde(rename = "total_count")]
    count: u64,
    /// List of editions in marketplace
    #[serde(rename = "editions")]
    data: Vec<MarketplaceDetailedEdition>,
}

/// The collected editions information
#[derive(Debug, Clone, AutoGetter, Serialize, Deserialize)]
pub struct CollectedEdition {
    /// The edition ID
    id: String,
    /// The book index
    #[serde(rename = "book_index")]
    index: u32,
    /// Is in marketplace?
    in_marketplace: bool,
    /// Does have signature/remarque?
    #[serde(rename = "sig")]
    has_signature: bool,
    // TODO: `rmq_plate_url` and `remarqued_watermark_cover_url` fields
}

/// The paginated response for collected editions listing.
#[derive(Debug, Clone, AutoGetter, Serialize, Deserialize)]
pub struct CollectedEditionList {
    /// Total pages available using the current page size
    #[serde(rename = "pages_count")]
    pages: u32,
    /// Total editions owned
    #[serde(rename = "total_count")]
    count: u64,
    /// List of collected editions
    #[serde(rename = "editions")]
    data: Vec<CollectedEdition>,
    /// The issue information of these editions
    issue: super::issues::IssueDetail,
}

/// The response for publisher detail request
#[derive(Debug, Clone, AutoGetter, Serialize, Deserialize)]
pub struct PublisherDetailResponse {
    /// The actual publisher information
    #[serde(rename = "publisher")]
    #[deref_clone]
    data: super::common::Publisher,
}

/// Customer payment method information
#[derive(Debug, Clone, AutoGetter, Serialize, Deserialize)]
pub struct CustomerPaymentMethod {
    /// The payment method ID
    id: String,
    /// Stripe payment method ID
    pm_id: String,
    /// Stripe payment method type (e.g. "card")
    pm_type: String,
    /// The card brand (e.g. "visa", "mastercard", etc.)
    brand: String,
    /// The last 4 digits of the card
    last4: String,
    /// Expiry month of the card
    exp_month: String,
    /// Expiry year of the card
    exp_year: String,
    /// Country of the card
    country: Option<String>,
}

/// Customer detailed information
#[derive(Debug, Clone, AutoGetter, Serialize, Deserialize)]
pub struct CustomerDetail {
    /// The customer ID
    #[serde(rename = "uuid")]
    id: String,
    /// The customer email
    email: String,
    /// The customer user name
    username: Option<String>,
    /// The customer first name
    first_name: Option<String>,
    /// The customer last name
    last_name: Option<String>,
    /// The customer waitlist position
    place_number: u64,
    /// The customer referral code
    referral_code: String,
    /// The customer referral code usage count
    #[serde(rename = "referrals_count")]
    referral_uses: u64,
    /// The customer payment method
    payment_method: Option<CustomerPaymentMethod>,
    /// The customer balance in USD
    ///
    /// Stripe normalizeds balance to cents
    balance: u64,
    /// The customer role (e.g. "Beta")
    roles: String,
    // TODO: `image` field (but it's an empty object in response)
}

/// The response for customer detail request
#[derive(Debug, Clone, AutoGetter, Serialize, Deserialize)]
pub struct CustomerDetailResponse {
    /// The actual customer information
    #[serde(rename = "customer")]
    #[deref_clone]
    data: CustomerDetail,
}

/// The collected editions information
#[derive(Debug, Clone, AutoGetter, Serialize, Deserialize)]
pub struct CollectedEditionDetailed {
    /// The edition ID
    id: String,
    /// The book index
    #[serde(rename = "book_index")]
    index: u32,
    /// The issue UUID
    book_id: String,
    /// The issue full title
    full_title: String,
    /// Is in marketplace?
    in_marketplace: bool,
    /// The original cover image URL
    original_url: String,
    /// The mobile cover image URL
    mobile_url: String,
    /// The thumbnail cover image URL
    thumbnail_url: String,
    /// Variant identifier (e.g. "standard", "variant-1", "A", etc.)
    #[serde(rename = "variant_identifier")]
    variant_id: Option<String>,
    /// Variant description (e.g. "Standard Edition", "Variant Cover A", etc.)
    variant_description: String,
    /// Is this edition signable/remarqueable?
    signable: bool,
    /// Is this edition resellable in marketplace?
    resellable: bool,
    /// Is this edition downloadable?
    downloadable: bool,
    /// The age rating of the issue (e.g. "13+")
    age_rating: String,
    /// The language of the issue (e.g. "eng", "jpn", etc.)
    language: String,
    /// The release date of the issue in ISO 8601 format
    #[serde(with = "super::datetime")]
    release_date: chrono::DateTime<chrono::FixedOffset>,
    /// Total pages in the issue
    total_pages: u32,
    /// The genres/tags associated with this issue
    #[serde(default, rename = "categories")]
    genres: Vec<super::common::Genre>,
    /// The creators involved in this issue
    #[serde(default)]
    creators: Vec<super::issues::IssueCreator>,
    /// Does this edition have signature/remarque?
    #[serde(rename = "sig")]
    has_signature: bool,
    // TODO: `rmq_plate_url` and `remarqued_watermark_cover_url` fields
}

/// An information about an series run from reading history
#[derive(Debug, Clone, AutoGetter, Serialize, Deserialize)]
pub struct ReadingHistorySeries {
    /// The series UUID
    id: String,
    /// The series title
    title: String,
    /// The series description
    description: Option<String>,
    /// The series URL slug
    slug: String,
    /// The series creation time in the system
    #[serde(with = "super::datetime")]
    created_at: chrono::DateTime<chrono::FixedOffset>,
}

/// The information for user reading history
#[derive(Debug, Clone, AutoGetter, Serialize, Deserialize)]
pub struct ReadingHistory {
    /// The issue ID
    id: String,
    /// The issue UUID
    uuid: String,
    /// The series title
    title: String,
    /// The issue full title
    full_title: String,
    /// The issue URL slug
    slug: String,
    /// The issue description
    description: Option<String>,
    /// The issue cover image original URL
    original_url: String,
    /// The issue cover image mobile URL
    mobile_url: String,
    /// The issue cover image thumbnail URL
    thumbnail_url: String,
    /// The series run information for this issue
    series_run: ReadingHistorySeries,
    /// The list of owned editions of this issue
    #[serde(rename = "owned_editions")]
    editions: Vec<CollectedEditionDetailed>,
    /// Total pages in this issue
    total_pages: u32,
    /// The currently read page number if any
    #[serde(default)]
    bookmark_page: Option<u32>,
    /// The timestamp of the last time this issue was read/viewed
    #[serde(
        default,
        rename = "bookmark_timestamp",
        serialize_with = "super::datetime::serialize_opt",
        deserialize_with = "super::datetime::deserialize_opt"
    )]
    last_read: Option<chrono::DateTime<chrono::FixedOffset>>,
}

/// The paginated response for user reading history listing.
#[derive(Debug, Clone, AutoGetter, Serialize, Deserialize)]
pub struct ReadingHistoryList {
    /// Total pages available using the current page size
    #[serde(rename = "pages_count")]
    pages: u32,
    // /// Total history items available
    // #[serde(rename = "total_count")]
    // count: u64,
    /// List of reading history items
    #[serde(rename = "books")]
    data: Vec<ReadingHistory>,
}

/// Login data with user info and tokens
#[derive(Debug, Clone, AutoGetter, Serialize, Deserialize)]
pub struct LoginData {
    /// The user information
    user: CustomerDetail,
    /// The access token
    tokens: TokenData,
}

/// Login response
#[derive(Debug, Clone, AutoGetter, Serialize, Deserialize)]
pub struct LoginResponse {
    /// The actual login data
    #[serde(rename = "data")]
    #[deref_clone]
    data: LoginData,
}