Skip to content

Commit 7b934d3

Browse files
committed
Tested Upload 🎉
2 parents dcf1096 + 6f20c4e commit 7b934d3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1536
-38
lines changed

‎mangadex-api-params-types/src/lib.rs

+8
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,11 @@ pub mod forums;
1111
pub mod legacy;
1212
pub mod manga;
1313
pub mod oauth;
14+
pub mod rating;
15+
pub mod read_marker;
16+
pub mod report;
17+
pub mod scanlation_group;
18+
pub mod settings;
19+
pub mod statistics;
20+
pub mod upload;
21+
pub mod user;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub mod create_or_update;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#[cfg(feature = "mangadex-api-resolver")]
2+
use mangadex_api::{v5::rating::manga_id::post::CreateUpdateMangaRatingBuilder, MangaDexClient};
3+
4+
use serde::{Deserialize, Serialize};
5+
use specta::Type;
6+
use uuid::Uuid;
7+
8+
#[derive(Debug, Clone, Type, Serialize, Deserialize)]
9+
pub struct CreateUpdateRating {
10+
pub manga_id: Uuid,
11+
12+
/// `[ 1 .. 10 ]`.
13+
///
14+
/// Numbers below `1` will be set at `1` and numbers above `10` will be set at `10`.
15+
pub rating: u8,
16+
}
17+
18+
#[cfg(feature = "mangadex-api-resolver")]
19+
impl From<CreateUpdateRating> for CreateUpdateMangaRatingBuilder {
20+
fn from(value: CreateUpdateRating) -> Self {
21+
let mut builder = Self::default();
22+
builder.manga_id(value.manga_id);
23+
builder.rating(value.rating);
24+
builder
25+
}
26+
}
27+
28+
#[cfg(feature = "mangadex-api-resolver")]
29+
impl CreateUpdateRating {
30+
pub async fn send(self, client: &MangaDexClient) -> mangadex_api_types::error::Result<()> {
31+
<CreateUpdateMangaRatingBuilder as From<Self>>::from(self)
32+
.http_client(client.get_http_client().clone())
33+
.send()
34+
.await?;
35+
Ok(())
36+
}
37+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pub mod batch_read_marker;
2+
pub mod read_markers;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#[cfg(feature = "mangadex-api-resolver")]
2+
use mangadex_api::{v5::manga::id::read::post::MarkChapterBatchBuilder, MangaDexClient};
3+
4+
use serde::{Deserialize, Serialize};
5+
use specta::Type;
6+
use uuid::Uuid;
7+
8+
#[derive(Debug, Clone, Type, Serialize, Deserialize)]
9+
pub struct MarkChapterBatchParam {
10+
pub manga_id: Uuid,
11+
#[serde(default)]
12+
pub chapter_ids_read: Vec<Uuid>,
13+
#[serde(default)]
14+
pub chapter_ids_unread: Vec<Uuid>,
15+
#[serde(default)]
16+
pub update_history: bool,
17+
}
18+
19+
#[cfg(feature = "mangadex-api-resolver")]
20+
impl From<MarkChapterBatchParam> for MarkChapterBatchBuilder {
21+
fn from(value: MarkChapterBatchParam) -> Self {
22+
let mut builder = Self::default();
23+
builder.manga_id(value.manga_id);
24+
builder.chapter_ids_read(value.chapter_ids_read);
25+
builder.chapter_ids_unread(value.chapter_ids_unread);
26+
builder.update_history(value.update_history);
27+
builder
28+
}
29+
}
30+
31+
#[cfg(feature = "mangadex-api-resolver")]
32+
impl MarkChapterBatchParam {
33+
pub async fn send(self, client: &MangaDexClient) -> mangadex_api_types::error::Result<()> {
34+
<MarkChapterBatchBuilder as From<Self>>::from(self)
35+
.http_client(client.get_http_client().clone())
36+
.send()
37+
.await?;
38+
Ok(())
39+
}
40+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#[cfg(feature = "mangadex-api-resolver")]
2+
use mangadex_api::{v5::manga::read::get::GetReadChaptersBuilder, MangaDexClient};
3+
4+
use serde::{Deserialize, Serialize};
5+
use specta::Type;
6+
use uuid::Uuid;
7+
8+
#[derive(Debug, Clone, Type, Serialize, Deserialize)]
9+
pub struct ChapterReadMarkersParam {
10+
pub manga_ids: Vec<Uuid>,
11+
#[serde(default)]
12+
pub grouped: bool,
13+
}
14+
15+
#[cfg(feature = "mangadex-api-resolver")]
16+
impl From<ChapterReadMarkersParam> for GetReadChaptersBuilder {
17+
fn from(value: ChapterReadMarkersParam) -> Self {
18+
let mut builder = Self::default();
19+
builder.manga_ids(value.manga_ids);
20+
builder.grouped(value.grouped);
21+
builder
22+
}
23+
}
24+
25+
#[cfg(feature = "mangadex-api-resolver")]
26+
impl ChapterReadMarkersParam {
27+
pub async fn send(
28+
self,
29+
client: &MangaDexClient,
30+
) -> mangadex_api_schema::v5::MangaReadMarkersResponse {
31+
<GetReadChaptersBuilder as From<Self>>::from(self)
32+
.http_client(client.get_http_client().clone())
33+
.send()
34+
.await
35+
}
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pub mod create;
2+
pub mod list;
3+
pub mod list_by_category;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#[cfg(feature = "mangadex-api-resolver")]
2+
use mangadex_api::{v5::report::post::CreateReportBuilder, MangaDexClient};
3+
4+
use mangadex_api_types::ReportCategory;
5+
use serde::{Deserialize, Serialize};
6+
use specta::Type;
7+
use uuid::Uuid;
8+
9+
#[derive(Debug, Clone, Type, Serialize, Deserialize)]
10+
pub struct CreateReportParam {
11+
pub category: ReportCategory,
12+
/// The report reason ID for sub-categorization.
13+
///
14+
/// For example, if a manga was being reported for being a troll entry, the specific reason ID should be used, obtained from the [list report reasons endpoint](crate::v5::report::list).
15+
pub reason: Uuid,
16+
/// The ID from the category type.
17+
///
18+
/// For example, if the category is "manga", this should be a manga UUID.
19+
pub object_id: Uuid,
20+
/// Optional notes about why this is being reported.
21+
#[serde(default)]
22+
pub details: Option<String>,
23+
}
24+
25+
#[cfg(feature = "mangadex-api-resolver")]
26+
impl From<CreateReportParam> for CreateReportBuilder {
27+
fn from(value: CreateReportParam) -> Self {
28+
let mut builder = Self::default();
29+
builder.category(value.category);
30+
builder.reason(value.reason);
31+
builder.object_id(value.object_id);
32+
if let Some(details) = value.details {
33+
builder.details(details);
34+
}
35+
builder
36+
}
37+
}
38+
39+
#[cfg(feature = "mangadex-api-resolver")]
40+
impl CreateReportParam {
41+
pub async fn send(
42+
self,
43+
client: &MangaDexClient,
44+
) -> mangadex_api_types::error::Result<mangadex_api_schema::Limited<()>> {
45+
let res = <CreateReportBuilder as From<Self>>::from(self)
46+
.http_client(client.get_http_client().clone())
47+
.send()
48+
.await?;
49+
Ok(mangadex_api_schema::Limited {
50+
rate_limit: res.rate_limit,
51+
body: (),
52+
})
53+
}
54+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#[cfg(feature = "mangadex-api-resolver")]
2+
use mangadex_api::{v5::report::get::ListReportsByUserBuilder, MangaDexClient};
3+
4+
#[cfg(feature = "mangadex-api-resolver")]
5+
use mangadex_api_schema::{v5::UserReportsCollection, Limited};
6+
#[cfg(feature = "mangadex-api-resolver")]
7+
use mangadex_api_types::error::Result;
8+
9+
use mangadex_api_types::{
10+
ReferenceExpansionResource, ReportCategory, ReportSortOrder, ReportStatus,
11+
};
12+
use serde::{Deserialize, Serialize};
13+
use specta::Type;
14+
use uuid::Uuid;
15+
16+
#[derive(Debug, Clone, Type, Serialize, Deserialize, Default)]
17+
#[serde(default)]
18+
pub struct ListReportParams {
19+
pub limit: Option<u32>,
20+
pub offset: Option<u32>,
21+
pub category: Option<ReportCategory>,
22+
pub object_id: Option<Uuid>,
23+
pub reason_id: Option<Uuid>,
24+
pub status: Option<ReportStatus>,
25+
pub order: Option<ReportSortOrder>,
26+
pub includes: Vec<ReferenceExpansionResource>,
27+
}
28+
29+
#[cfg(feature = "mangadex-api-resolver")]
30+
impl From<ListReportParams> for ListReportsByUserBuilder {
31+
fn from(value: ListReportParams) -> Self {
32+
let mut builder = Self::default();
33+
if let Some(limit) = value.limit {
34+
builder.limit(limit);
35+
}
36+
if let Some(offset) = value.offset {
37+
builder.offset(offset);
38+
}
39+
if let Some(category) = value.category {
40+
builder.category(category);
41+
}
42+
if let Some(object_id) = value.object_id {
43+
builder.object_id(object_id);
44+
}
45+
if let Some(reason_id) = value.reason_id {
46+
builder.reason_id(reason_id);
47+
}
48+
if let Some(status) = value.status {
49+
builder.status(status);
50+
}
51+
if let Some(order) = value.order {
52+
builder.order(order);
53+
}
54+
builder.includes(value.includes);
55+
builder
56+
}
57+
}
58+
59+
#[cfg(feature = "mangadex-api-resolver")]
60+
impl ListReportParams {
61+
pub async fn send(self, client: &MangaDexClient) -> Result<Limited<UserReportsCollection>> {
62+
<ListReportsByUserBuilder as From<Self>>::from(self)
63+
.http_client(client.get_http_client().clone())
64+
.send()
65+
.await
66+
}
67+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#[cfg(feature = "mangadex-api-resolver")]
2+
use mangadex_api::{v5::report::reasons::category::get::ListReasonsBuilder, MangaDexClient};
3+
4+
use mangadex_api_types::ReportCategory;
5+
use serde::{Deserialize, Serialize};
6+
use specta::Type;
7+
8+
#[derive(Debug, Clone, Type, Serialize, Deserialize)]
9+
pub struct ListReasonsByCategory {
10+
pub category: ReportCategory,
11+
}
12+
13+
#[cfg(feature = "mangadex-api-resolver")]
14+
impl From<ListReasonsByCategory> for ListReasonsBuilder {
15+
fn from(value: ListReasonsByCategory) -> Self {
16+
let mut builder = Self::default();
17+
builder.category(value.category);
18+
builder
19+
}
20+
}
21+
22+
#[cfg(feature = "mangadex-api-resolver")]
23+
impl ListReasonsByCategory {
24+
pub async fn send(
25+
self,
26+
client: &MangaDexClient,
27+
) -> mangadex_api_schema::v5::ReportReasonListResponse {
28+
<ListReasonsBuilder as From<ListReasonsByCategory>>::from(self)
29+
.http_client(client.get_http_client().clone())
30+
.send()
31+
.await
32+
}
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
pub mod create;
2+
pub mod edit;
3+
pub mod get_unique;
4+
pub mod list;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#[cfg(feature = "mangadex-api-resolver")]
2+
use mangadex_api::{v5::scanlation_group::post::CreateGroupBuilder, MangaDexClient};
3+
4+
#[cfg(feature = "mangadex-api-resolver")]
5+
use mangadex_api_schema::{v5::GroupData, Limited};
6+
#[cfg(feature = "mangadex-api-resolver")]
7+
use mangadex_api_types::error::Result;
8+
9+
use mangadex_api_types::MangaDexDuration;
10+
use serde::{Deserialize, Serialize};
11+
use specta::Type;
12+
use url::Url;
13+
14+
#[derive(Debug, Clone, Type, Serialize, Deserialize)]
15+
pub struct CreateScalantionGroupParam {
16+
pub name: String,
17+
/// Nullable.
18+
#[serde(default)]
19+
pub website: Option<String>,
20+
/// Nullable.
21+
#[serde(default)]
22+
pub irc_server: Option<String>,
23+
/// Nullable.
24+
#[serde(default)]
25+
pub irc_channel: Option<String>,
26+
/// Nullable.
27+
#[serde(default)]
28+
pub discord: Option<String>,
29+
/// Nullable.
30+
#[serde(default)]
31+
pub contact_email: Option<String>,
32+
/// Nullable.
33+
#[serde(default)]
34+
pub description: Option<String>,
35+
/// Nullable.
36+
#[serde(default)]
37+
pub twitter: Option<Url>,
38+
/// Regex: [^https:/\/www\.mangaupdates\.com\/(?:groups|publishers)\.html\?id=\d+](https://www.mangaupdates.com)
39+
///
40+
/// Nullable.
41+
#[serde(default)]
42+
pub manga_updates: Option<Url>,
43+
#[serde(default)]
44+
pub inactive: Option<bool>,
45+
/// Nullable.
46+
#[serde(default)]
47+
pub publish_delay: Option<MangaDexDuration>,
48+
}
49+
50+
#[cfg(feature = "mangadex-api-resolver")]
51+
impl From<CreateScalantionGroupParam> for CreateGroupBuilder {
52+
fn from(value: CreateScalantionGroupParam) -> Self {
53+
let mut builder = Self::default();
54+
builder.name(value.name);
55+
if let Some(website) = value.website {
56+
builder.website(website);
57+
}
58+
if let Some(irc_server) = value.irc_server {
59+
builder.irc_server(irc_server);
60+
}
61+
if let Some(irc_channel) = value.irc_channel {
62+
builder.irc_channel(irc_channel);
63+
}
64+
if let Some(discord) = value.discord {
65+
builder.discord(discord);
66+
}
67+
if let Some(contact_email) = value.contact_email {
68+
builder.contact_email(contact_email);
69+
}
70+
if let Some(description) = value.description {
71+
builder.description(description);
72+
}
73+
if let Some(twitter) = value.twitter {
74+
builder.twitter(twitter);
75+
}
76+
if let Some(manga_updates) = value.manga_updates {
77+
builder.manga_updates(manga_updates);
78+
}
79+
if let Some(inactive) = value.inactive {
80+
builder.inactive(inactive);
81+
}
82+
if let Some(publish_delay) = value.publish_delay {
83+
builder.publish_delay(publish_delay);
84+
}
85+
builder
86+
}
87+
}
88+
89+
#[cfg(feature = "mangadex-api-resolver")]
90+
impl CreateScalantionGroupParam {
91+
pub async fn send(self, client: &MangaDexClient) -> Result<Limited<GroupData>> {
92+
<CreateGroupBuilder as From<Self>>::from(self)
93+
.http_client(client.get_http_client().clone())
94+
.send()
95+
.await
96+
}
97+
}

0 commit comments

Comments
 (0)