class Mangadex::CustomList
Public Class Methods
add_manga(id, list_id:)
click to toggle source
# File lib/mangadex/custom_list.rb, line 70 def self.add_manga(id, list_id:) Mangadex::Internal::Definition.must(id) response = Mangadex::Internal::Request.post( '/manga/%{id}/list/%{list_id}' % {id: id, list_id: list_id}, ) if response.is_a?(Hash) response['result'] == 'ok' else !response.errored? end end
create(**args)
click to toggle source
# File lib/mangadex/custom_list.rb, line 12 def self.create(**args) Mangadex::Internal::Request.post( '/list', payload: Mangadex::Internal::Definition.validate(args, { name: { accepts: String, required: true }, visibility: { accepts: %w(public private), converts: :to_s }, manga: { accepts: String }, version: { accepts: Integer }, }), auth: true, ) end
delete(id)
click to toggle source
# File lib/mangadex/custom_list.rb, line 50 def self.delete(id) Mangadex::Internal::Definition.must(id) Mangadex::Internal::Request.delete( '/list/%{id}' % {id: id}, ) end
feed(id, **args)
click to toggle source
# File lib/mangadex/custom_list.rb, line 59 def self.feed(id, **args) Mangadex::Internal::Definition.must(id) Mangadex::Internal::Request.get( '/list/%{id}/feed' % {id: id}, Mangadex::Internal::Definition.chapter_list(args), content_rating: true, ) end
get(id)
click to toggle source
# File lib/mangadex/custom_list.rb, line 26 def self.get(id) Mangadex::Internal::Definition.must(id) Mangadex::Internal::Request.get( '/list/%{id}' % {id: id}, ) end
Also aliased as: view
inspect_attributes()
click to toggle source
# File lib/mangadex/custom_list.rb, line 143 def self.inspect_attributes [:name, :visibility] end
list(**args)
click to toggle source
# File lib/mangadex/custom_list.rb, line 98 def self.list(**args) Mangadex::Internal::Request.get( '/user/list', Mangadex::Internal::Definition.validate(args, { limit: { accepts: Integer }, offset: { accepts: Integer }, }), ) end
remove_manga(id, list_id:)
click to toggle source
# File lib/mangadex/custom_list.rb, line 84 def self.remove_manga(id, list_id:) Mangadex::Internal::Definition.must(id) response = Mangadex::Internal::Request.delete( '/manga/%{id}/list/%{list_id}' % {id: id, list_id: list_id}, ) if response.is_a?(Hash) response['result'] == 'ok' else !response.errored? end end
update(id, **args)
click to toggle source
# File lib/mangadex/custom_list.rb, line 35 def self.update(id, **args) Mangadex::Internal::Definition.must(id) Mangadex::Internal::Request.put( '/list/%{id}' % {id: id}, payload: Mangadex::Internal::Definition.validate(args, { name: { accepts: String }, visibility: { accepts: %w(private public) }, manga: { accepts: String }, version: { accepts: Integer, required: true }, }) ) end
Also aliased as: edit
user_list(user_id, **args)
click to toggle source
# File lib/mangadex/custom_list.rb, line 109 def self.user_list(user_id, **args) Mangadex::Internal::Definition.must(user_id) Mangadex::Internal::Request.get( '/user/%{id}/list' % {id: user_id}, Mangadex::Internal::Definition.validate(args, { limit: { accepts: Integer }, offset: { accepts: Integer }, }), ) end
Public Instance Methods
add_manga(id)
click to toggle source
# File lib/mangadex/custom_list.rb, line 127 def add_manga(id) Mangadex::CustomList.add_manga(id, list_id: self.id) end
manga_details(**args)
click to toggle source
# File lib/mangadex/custom_list.rb, line 137 def manga_details(**args) custom_list = Mangadex::CustomList.get(id).data ids = custom_list.mangas.map(&:id) ids.any? ? Mangadex::Manga.list(**args.merge(ids: ids)) : nil end
remove_manga(id)
click to toggle source
# File lib/mangadex/custom_list.rb, line 132 def remove_manga(id) Mangadex::CustomList.remove_manga(id, list_id: self.id) end