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
//! Scanlation group endpoint handler.
//!
//! <https://api.mangadex.org/swagger.html#/ScanlationGroup>

mod create;
mod delete;
mod follow;
mod get;
pub(crate) mod list;
mod unfollow;
mod update;

use crate::v5::scanlation_group::create::CreateGroupBuilder;
use crate::v5::scanlation_group::delete::DeleteGroupBuilder;
use crate::v5::scanlation_group::follow::FollowGroupBuilder;
use crate::v5::scanlation_group::get::GetGroupBuilder;
use crate::v5::scanlation_group::list::ListGroupBuilder;
use crate::v5::scanlation_group::unfollow::UnfollowGroupBuilder;
use crate::v5::scanlation_group::update::UpdateGroupBuilder;
use crate::v5::user::followed_groups::FollowedGroupsBuilder;
use crate::HttpClientRef;

/// Scanlation group endpoint handler builder.
#[derive(Debug)]
pub struct ScanlationGroupBuilder {
    http_client: HttpClientRef,
}

impl ScanlationGroupBuilder {
    #[doc(hidden)]
    pub(crate) fn new(http_client: HttpClientRef) -> Self {
        Self { http_client }
    }

    /// Search a list of scanlation groups.
    ///
    /// <https://api.mangadex.org/swagger.html#/ScanlationGroup/get-search-group>
    pub fn list(&self) -> ListGroupBuilder {
        ListGroupBuilder::default().http_client(self.http_client.clone())
    }

    /// Search a list of scanlation groups.
    ///
    /// <https://api.mangadex.org/swagger.html#/ScanlationGroup/get-search-group>
    ///
    /// This is an alias for the [`Self::list()`] function.
    pub fn search(&self) -> ListGroupBuilder {
        self.list()
    }

    /// View a single scanlation group.
    ///
    /// <https://api.mangadex.org/swagger.html#/ScanlationGroup/get-group-id>
    pub fn get(&self) -> GetGroupBuilder {
        GetGroupBuilder::default().http_client(self.http_client.clone())
    }

    /// View a single scanlation group.
    ///
    /// <https://api.mangadex.org/swagger.html#/ScanlationGroup/get-group-id>
    ///
    /// This is an alias for [`Self::get()`] to maintain backwards-compatibility.
    pub fn view(&self) -> GetGroupBuilder {
        self.get()
    }

    /// Create a new scanlation group.
    ///
    /// <https://api.mangadex.org/swagger.html#/ScanlationGroup/post-group>
    pub fn create(&self) -> CreateGroupBuilder {
        CreateGroupBuilder::default().http_client(self.http_client.clone())
    }

    /// Update a scanlation group.
    ///
    /// <https://api.mangadex.org/swagger.html#/ScanlationGroup/put-group-id>
    pub fn update(&self) -> UpdateGroupBuilder {
        UpdateGroupBuilder::default().http_client(self.http_client.clone())
    }

    /// Delete a scanlation group.
    ///
    /// <https://api.mangadex.org/swagger.html#/ScanlationGroup/delete-group-id>
    pub fn delete(&self) -> DeleteGroupBuilder {
        DeleteGroupBuilder::default().http_client(self.http_client.clone())
    }

    /// Follow a scanlation group.
    ///
    /// <https://api.mangadex.org/swagger.html#/ScanlationGroup/post-group-id-follow>
    pub fn follow(&self) -> FollowGroupBuilder {
        FollowGroupBuilder::default().http_client(self.http_client.clone())
    }

    /// Unfollow a scanlation group.
    ///
    /// <https://api.mangadex.org/swagger.html#/ScanlationGroup/delete-group-id-follow>
    pub fn unfollow(&self) -> UnfollowGroupBuilder {
        UnfollowGroupBuilder::default().http_client(self.http_client.clone())
    }

    /// Get the followed scanlation groups for the logged-in user.
    ///
    /// <https://api.mangadex.org/swagger.html#/ScanlationGroup/get-user-follows-group>
    pub fn get_followed(&self) -> FollowedGroupsBuilder {
        FollowedGroupsBuilder::default().http_client(self.http_client.clone())
    }
}