class Mangadex::Manga
Public Class Methods
all_reading_status(status = nil)
click to toggle source
# File lib/mangadex/manga.rb, line 134 def self.all_reading_status(status = nil) args = { status: status } if status.present? Mangadex::Internal::Request.get( '/manga/status', Mangadex::Internal::Definition.validate(args, { status: { accepts: %w(reading on_hold dropped plan_to_read re_reading completed), converts: :to_s, }, }) ) end
attributes_to_inspect()
click to toggle source
# File lib/mangadex/manga.rb, line 202 def self.attributes_to_inspect [:id, :type, :title, :content_rating, :original_language, :year] end
create(**args)
click to toggle source
# File lib/mangadex/manga.rb, line 198 def self.create(**args) Mangadex::Internal::Request.post('/manga', payload: args) end
delete(id)
click to toggle source
# File lib/mangadex/manga.rb, line 190 def self.delete(id) Mangadex::Internal::Definition.must(id) Mangadex::Internal::Request.delete( '/manga/%{id}' % {id: id}, ) end
feed(id, **args)
click to toggle source
# File lib/mangadex/manga.rb, line 105 def self.feed(id, **args) Mangadex::Internal::Definition.must(id) Mangadex::Internal::Request.get( '/manga/%{id}/feed' % {id: id}, Mangadex::Internal::Definition.chapter_list(args), content_rating: true, ) end
follow(id)
click to toggle source
# File lib/mangadex/manga.rb, line 96 def self.follow(id) Mangadex::Internal::Definition.must(id) Mangadex::Internal::Request.post( '/manga/%{id}/follow' % {id: id}, ) end
list(**args)
click to toggle source
# File lib/mangadex/manga.rb, line 28 def self.list(**args) to_a = Mangadex::Internal::Definition.converts(:to_a) Mangadex::Internal::Request.get( '/manga', Mangadex::Internal::Definition.validate(args, { limit: { accepts: Integer }, offset: { accepts: Integer }, title: { accepts: String }, authors: { accepts: [String] }, artists: { accepts: [String] }, year: { accepts: Integer }, included_tags: { accepts: [String] }, included_tags_mode: { accepts: %w(OR AND), converts: to_a }, excluded_tags: { accepts: [String] }, excluded_tags_mode: { accepts: %w(OR AND), converts: to_a }, status: { accepts: %w(ongoing completed hiatus cancelled), converts: to_a }, original_language: { accepts: [String] }, excluded_original_language: { accepts: [String] }, available_translated_language: { accepts: [String] }, publication_demographic: { accepts: %w(shounen shoujo josei seinen none), converts: to_a }, ids: { accepts: Array }, content_rating: { accepts: %w(safe suggestive erotica pornographic), converts: to_a }, created_at_since: { accepts: %r{^\d{4}-[0-1]\d-([0-2]\d|3[0-1])T([0-1]\d|2[0-3]):[0-5]\d:[0-5]\d$} }, updated_at_since: { accepts: %r{^\d{4}-[0-1]\d-([0-2]\d|3[0-1])T([0-1]\d|2[0-3]):[0-5]\d:[0-5]\d$} }, order: { accepts: Hash }, includes: { accepts: Array, converts: to_a }, has_available_chapters: { accepts: ['0', '1', 'true', 'false'] }, group: { accepts: String }, }), content_rating: true, ) end
random(**args)
click to toggle source
# File lib/mangadex/manga.rb, line 116 def self.random(**args) Mangadex::Internal::Request.get( '/manga/random', Mangadex::Internal::Definition.validate(args, { includes: { accepts: Array }, content_rating: { accepts: %w(safe suggestive erotica pornographic), converts: to_a }, }) ) end
read_markers(id, grouped: false)
click to toggle source
# File lib/mangadex/manga.rb, line 173 def self.read_markers(id, grouped: false) Mangadex::Internal::Request.get( '/manga/read', { ids: Array(id), grouped: grouped }, auth: true, ) end
reading_status(id)
click to toggle source
# File lib/mangadex/manga.rb, line 149 def self.reading_status(id) Mangadex::Internal::Definition.must(id) Mangadex::Internal::Request.get( '/manga/%{id}/status' % {id: id}, ) end
tag_list()
click to toggle source
# File lib/mangadex/manga.rb, line 127 def self.tag_list Mangadex::Internal::Request.get( '/manga/tag' ) end
unfollow(id)
click to toggle source
# File lib/mangadex/manga.rb, line 87 def self.unfollow(id) Mangadex::Internal::Definition.must(id) Mangadex::Internal::Request.delete( '/manga/%{id}/follow' % {id: id}, ) end
update(id, **args)
click to toggle source
# File lib/mangadex/manga.rb, line 183 def self.update(id, **args) Mangadex::Internal::Definition.must(id) Mangadex::Internal::Request.put('/manga/%{id}' % {id: id}, payload: args) end
Also aliased as: edit
update_reading_status(id, status)
click to toggle source
# File lib/mangadex/manga.rb, line 158 def self.update_reading_status(id, status) Mangadex::Internal::Definition.must(id) Mangadex::Internal::Request.post( '/manga/%{id}/status' % {id: id}, payload: Mangadex::Internal::Definition.validate({status: status}, { status: { accepts: %w(reading on_hold dropped plan_to_read re_reading completed), required: true, }, }) ) end
view(id, **args)
click to toggle source
# File lib/mangadex/manga.rb, line 74 def self.view(id, **args) to_a = Mangadex::Internal::Definition.converts(:to_a) Mangadex::Internal::Definition.must(id) Mangadex::Internal::Request.get( '/manga/%{id}' % {id: id}, Mangadex::Internal::Definition.validate(args, { includes: { accepts: Array, converts: to_a }, }) ) end
Also aliased as: get
volumes_and_chapters(id, **args)
click to toggle source
# File lib/mangadex/manga.rb, line 63 def self.volumes_and_chapters(id, **args) Mangadex::Internal::Request.get( '/manga/%{id}/aggregate' % {id: id}, Mangadex::Internal::Definition.validate(args, { translated_language: { accepts: Array }, groups: { accepts: Array }, }), ) end
Also aliased as: aggregate
Public Instance Methods
chapters(**args)
click to toggle source
# File lib/mangadex/manga.rb, line 220 def chapters(**args) chapter_args = args.merge({manga: id}) Chapter.list(**chapter_args) end
content_rating()
click to toggle source
# File lib/mangadex/manga.rb, line 213 def content_rating return unless attributes&.content_rating.present? ContentRating.new(attributes.content_rating) end