Class: Mangadex::CustomList
Instance Attribute Summary
#attributes, #id, #relationships, #type
Class Method Summary
collapse
Instance Method Summary
collapse
attributes_to_inspect, #eq?, #hash, #initialize, #inspect
Class Method Details
.add_manga(id, list_id:) ⇒ Object
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/mangadex/custom_list.rb', line 61
def self.add_manga(id, list_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) ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
|
# 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) ⇒ Object
46
47
48
49
50
|
# File 'lib/mangadex/custom_list.rb', line 46
def self.delete(id)
Mangadex::Internal::Request.delete(
'/list/%{id}' % {id: id},
)
end
|
.feed(id, **args) ⇒ Object
.get(id) ⇒ Object
26
27
28
29
30
|
# File 'lib/mangadex/custom_list.rb', line 26
def self.get(id)
Mangadex::Internal::Request.get(
'/list/%{id}' % {id: id},
)
end
|
.inspect_attributes ⇒ Object
122
123
124
|
# File 'lib/mangadex/custom_list.rb', line 122
def self.inspect_attributes
[:name, :visibility]
end
|
.remove_manga(id, list_id:) ⇒ Object
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/mangadex/custom_list.rb', line 73
def self.remove_manga(id, list_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) ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/mangadex/custom_list.rb', line 33
def self.update(id, **args)
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
|
.user_list(user_id, **args) ⇒ Object
Instance Method Details
#manga_details(**args) ⇒ Object
117
118
119
120
|
# File 'lib/mangadex/custom_list.rb', line 117
def manga_details(**args)
ids = mangas.map(&:id)
ids.any? ? Mangadex::Manga.list(**args.merge(ids: ids)) : nil
end
|
#remove_manga(id) ⇒ Object