shikimori-api 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +20 -0
- data/lib/shikimori/api/client.rb +34 -0
- data/lib/shikimori/api/errors.rb +21 -0
- data/lib/shikimori/api/rest.rb +115 -0
- data/lib/shikimori/api/uri.rb +18 -0
- data/lib/shikimori/api/v1/achievements.rb +32 -0
- data/lib/shikimori/api/v1/animes.rb +252 -0
- data/lib/shikimori/api/v1/appear.rb +40 -0
- data/lib/shikimori/api/v1/bans.rb +31 -0
- data/lib/shikimori/api/v1/calendars.rb +32 -0
- data/lib/shikimori/api/v1/characters.rb +52 -0
- data/lib/shikimori/api/v1/clubs.rb +329 -0
- data/lib/shikimori/api/v1/comments.rb +161 -0
- data/lib/shikimori/api/v1/constants.rb +107 -0
- data/lib/shikimori/api/v1/dialogs.rb +78 -0
- data/lib/shikimori/api/v1/favorites.rb +148 -0
- data/lib/shikimori/api/v1/forums.rb +31 -0
- data/lib/shikimori/api/v1/friends.rb +57 -0
- data/lib/shikimori/api/v1/genres.rb +31 -0
- data/lib/shikimori/api/v1/ignores.rb +62 -0
- data/lib/shikimori/api/v1/mangas.rb +211 -0
- data/lib/shikimori/api/v1/messages.rb +168 -0
- data/lib/shikimori/api/v1/people.rb +53 -0
- data/lib/shikimori/api/v1/publishers.rb +31 -0
- data/lib/shikimori/api/v1/ranobe.rb +206 -0
- data/lib/shikimori/api/v1/reviews.rb +89 -0
- data/lib/shikimori/api/v1/stats.rb +31 -0
- data/lib/shikimori/api/v1/studios.rb +31 -0
- data/lib/shikimori/api/v1/styles.rb +112 -0
- data/lib/shikimori/api/v1/topic_ignores.rb +63 -0
- data/lib/shikimori/api/v1/topics.rb +237 -0
- data/lib/shikimori/api/v1/user_images.rb +36 -0
- data/lib/shikimori/api/v1/user_rates.rb +194 -0
- data/lib/shikimori/api/v1/users.rb +310 -0
- data/lib/shikimori/api/v1/videos.rb +85 -0
- data/lib/shikimori/api/v1.rb +77 -0
- data/lib/shikimori/api/v2/abuse_requests.rb +103 -0
- data/lib/shikimori/api/v2/episode_notifications.rb +54 -0
- data/lib/shikimori/api/v2/topic_ignore.rb +54 -0
- data/lib/shikimori/api/v2/user_ignore.rb +54 -0
- data/lib/shikimori/api/v2/user_rates.rb +171 -0
- data/lib/shikimori/api/v2.rb +27 -0
- data/lib/shikimori/api/version.rb +8 -0
- data/lib/shikimori/api.rb +14 -0
- data/lib/shikimori-api.rb +3 -0
- data/shikimori-api.gemspec +40 -0
- data/sig/shikimori/api/client.rbs +12 -0
- data/sig/shikimori/api/rest.rbs +30 -0
- data/sig/shikimori/api/uri.rbs +10 -0
- data/sig/shikimori/api/v1/achievements.rbs +15 -0
- data/sig/shikimori/api/v1/animes.rbs +23 -0
- data/sig/shikimori/api/v1/appear.rbs +15 -0
- data/sig/shikimori/api/v1/bans.rbs +15 -0
- data/sig/shikimori/api/v1/calendars.rbs +15 -0
- data/sig/shikimori/api/v1/characters.rbs +16 -0
- data/sig/shikimori/api/v1/clubs.rbs +29 -0
- data/sig/shikimori/api/v1/comments.rbs +19 -0
- data/sig/shikimori/api/v1/constants.rbs +19 -0
- data/sig/shikimori/api/v1/dialogs.rbs +17 -0
- data/sig/shikimori/api/v1/favorites.rbs +23 -0
- data/sig/shikimori/api/v1/forums.rbs +15 -0
- data/sig/shikimori/api/v1/friends.rbs +16 -0
- data/sig/shikimori/api/v1/genres.rbs +15 -0
- data/sig/shikimori/api/v1/ignores.rbs +16 -0
- data/sig/shikimori/api/v1/mangas.rbs +23 -0
- data/sig/shikimori/api/v1/messages.rbs +20 -0
- data/sig/shikimori/api/v1/people.rbs +16 -0
- data/sig/shikimori/api/v1/publishers.rbs +15 -0
- data/sig/shikimori/api/v1/ranobe.rbs +23 -0
- data/sig/shikimori/api/v1/reviews.rbs +19 -0
- data/sig/shikimori/api/v1/stats.rbs +15 -0
- data/sig/shikimori/api/v1/studios.rbs +15 -0
- data/sig/shikimori/api/v1/styles.rbs +18 -0
- data/sig/shikimori/api/v1/topic_ignores.rbs +16 -0
- data/sig/shikimori/api/v1/topics.rbs +40 -0
- data/sig/shikimori/api/v1/user_images.rbs +15 -0
- data/sig/shikimori/api/v1/user_rates.rbs +44 -0
- data/sig/shikimori/api/v1/users.rbs +28 -0
- data/sig/shikimori/api/v1/videos.rbs +23 -0
- data/sig/shikimori/api/v1.rbs +41 -0
- data/sig/shikimori/api/v2/abuse_requests.rbs +18 -0
- data/sig/shikimori/api/v2/episode_notifications.rbs +25 -0
- data/sig/shikimori/api/v2/topic_ignore.rbs +16 -0
- data/sig/shikimori/api/v2/user_ignore.rbs +16 -0
- data/sig/shikimori/api/v2/user_rates.rbs +43 -0
- data/sig/shikimori/api/v2.rbs +16 -0
- data/sig/shikimori/api/version.rbs +5 -0
- data/sig/shikimori/api.rbs +18 -0
- metadata +137 -0
@@ -0,0 +1,329 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Shikimori
|
4
|
+
module API
|
5
|
+
class V1
|
6
|
+
# Methods for the Clubs API
|
7
|
+
#
|
8
|
+
# @see https://shikimori.one/api/doc/1.0/clubs Shikimori's API documentation
|
9
|
+
module Clubs
|
10
|
+
# Get list of clubs
|
11
|
+
#
|
12
|
+
# @param headers [Hash] Request headers
|
13
|
+
# @param query [Hash] Query string parameters for request
|
14
|
+
# @option query [Integer] :page Number of page. Must be between 1 and 100000
|
15
|
+
# @option query [Integer] :limit Number of clubs per page. Must be a lower or equal that 30
|
16
|
+
# @option query [String] :search Filter by name of club
|
17
|
+
#
|
18
|
+
# @return [Array<Hash>] Array of hashes representing clubs
|
19
|
+
#
|
20
|
+
# @see https://shikimori.one/api/doc/1.0/clubs/index Shikimori's API documentation
|
21
|
+
# @example Search a 20 clubs with name equal to 'yuri'
|
22
|
+
# client = Shikimori::API::Client.new(
|
23
|
+
# app_name: 'Api Test',
|
24
|
+
# aceess_token: '****',
|
25
|
+
# refresh_token: '****'
|
26
|
+
# )
|
27
|
+
# client.v1.clubs(search: 'yuri')
|
28
|
+
def clubs(headers: nil, **query)
|
29
|
+
rest.get base_url.join('clubs').url, headers: headers, query: query
|
30
|
+
end
|
31
|
+
|
32
|
+
# Get a club by id
|
33
|
+
#
|
34
|
+
# @param id [#to_s] Club id
|
35
|
+
# @param headers [Hash] Request headers
|
36
|
+
# @param query [Hash] Query string parameters for request
|
37
|
+
#
|
38
|
+
# @return [Hash] Hash representing club
|
39
|
+
#
|
40
|
+
# @raise [Shikimori::API::NotFoundError] if club not exists
|
41
|
+
#
|
42
|
+
# @see https://shikimori.one/api/doc/1.0/clubs/show Shikimori's API documentation
|
43
|
+
# @example Get a club with id equal to 1
|
44
|
+
# client = Shikimori::API::Client.new(
|
45
|
+
# app_name: 'Api Test',
|
46
|
+
# aceess_token: '****',
|
47
|
+
# refresh_token: '****'
|
48
|
+
# )
|
49
|
+
# client.v1.club(1)
|
50
|
+
def club(id, headers: nil, **query)
|
51
|
+
rest.get base_url.join('clubs', id.to_s).url, headers: headers, query: query
|
52
|
+
end
|
53
|
+
|
54
|
+
# Update Club.
|
55
|
+
# Requires `clubs` oauth scope
|
56
|
+
#
|
57
|
+
# @param id [#to_s] Club id
|
58
|
+
# @param club [Hash] Club data for updating
|
59
|
+
# @option club [String] :name Club's name
|
60
|
+
# @option club [String] :description Club's description
|
61
|
+
# @option club ['true', 'false', 1, 0] :display_images Display club's images?
|
62
|
+
# @option club ["free", "members", "admins"] :comment_policy Club's comments policy
|
63
|
+
# @option club ["members", "admins"] :topic_policy Club's topics policy
|
64
|
+
# @option club ["members", "admins"] :image_upload_policy Club's uploading images policy
|
65
|
+
# @param headers [Hash] Request headers
|
66
|
+
# @param query [Hash] Query string parameters for request
|
67
|
+
#
|
68
|
+
# @return [Hash] Hash representing updated club
|
69
|
+
#
|
70
|
+
# @raise [Shikimori::API::ForbiddenError] if user authorized without `clubs` scope
|
71
|
+
# @raise [Shikimori::API::NotFoundError] if club not exists
|
72
|
+
#
|
73
|
+
# @see https://shikimori.one/api/doc/1.0/clubs/update Shikimori's API documentation
|
74
|
+
# @example Update club's name and topic policy
|
75
|
+
# client = Shikimori::API::Client.new(
|
76
|
+
# app_name: 'Api Test',
|
77
|
+
# aceess_token: '****',
|
78
|
+
# refresh_token: '****'
|
79
|
+
# )
|
80
|
+
# client.v1.update_club(1, { name: "Best of the best", topic_policy: "admins" }) #=> { id: 1, ... }
|
81
|
+
def update_club(id, club, headers: nil, **query)
|
82
|
+
rest.put base_url.join('clubs', id.to_s).url, { club: club }, headers: headers, query: query
|
83
|
+
end
|
84
|
+
|
85
|
+
# Get list of club's animes
|
86
|
+
#
|
87
|
+
# @param id [#to_s] Club's id
|
88
|
+
# @param headers [Hash] Request headers
|
89
|
+
# @param query [Hash] Query string parameters for request
|
90
|
+
# @option query [Integer] :page Number of page. Must be between 1 and 100000
|
91
|
+
# @option query [Integer] :limit Number of clubs per page. Must be a lower or equal that 20
|
92
|
+
#
|
93
|
+
# @return [Array<Hash>] Array of hashes representing club animes
|
94
|
+
#
|
95
|
+
# @raise [Shikimori::API::NotFoundError] if club not exists
|
96
|
+
#
|
97
|
+
# @see https://shikimori.one/api/doc/1.0/clubs/animes Shikimori's API documentation
|
98
|
+
# @example First 20 club animes
|
99
|
+
# client = Shikimori::API::Client.new(
|
100
|
+
# app_name: 'Api Test',
|
101
|
+
# aceess_token: '****',
|
102
|
+
# refresh_token: '****'
|
103
|
+
# )
|
104
|
+
# client.v1.club_animes(limit: 20) #=> [{ id: 1, ...}, ...]
|
105
|
+
def club_animes(id, headers: nil, **query)
|
106
|
+
rest.get base_url.join('clubs', id.to_s, 'animes').url, headers: headers, query: query
|
107
|
+
end
|
108
|
+
|
109
|
+
# Get list of club's mangas
|
110
|
+
#
|
111
|
+
# @param id [#to_s] Club's id
|
112
|
+
# @param headers [Hash] Request headers
|
113
|
+
# @param query [Hash] Query string parameters for request
|
114
|
+
# @option query [Integer] :page Number of page. Must be between 1 and 100000
|
115
|
+
# @option query [Integer] :limit Number of clubs per page. Must be a lower or equal that 20
|
116
|
+
#
|
117
|
+
# @return [Array<Hash>] Array of hashes representing club mangas
|
118
|
+
#
|
119
|
+
# @raise [Shikimori::API::NotFoundError] if club not exists
|
120
|
+
#
|
121
|
+
# @see https://shikimori.one/api/doc/1.0/clubs/mangas Shikimori's API documentation
|
122
|
+
# @example First 20 club mangas
|
123
|
+
# client = Shikimori::API::Client.new(
|
124
|
+
# app_name: 'Api Test',
|
125
|
+
# aceess_token: '****',
|
126
|
+
# refresh_token: '****'
|
127
|
+
# )
|
128
|
+
# client.v1.club_mangas(limit: 20) #=> [{ id: 1, ...}, ...]
|
129
|
+
def club_mangas(id, headers: nil, **query)
|
130
|
+
rest.get base_url.join('clubs', id.to_s, 'mangas').url, headers: headers, query: query
|
131
|
+
end
|
132
|
+
|
133
|
+
# Get list of club's ranobe
|
134
|
+
#
|
135
|
+
# @param id [#to_s] Club's id
|
136
|
+
# @param headers [Hash] Request headers
|
137
|
+
# @param query [Hash] Query string parameters for request
|
138
|
+
# @option query [Integer] :page Number of page. Must be between 1 and 100000
|
139
|
+
# @option query [Integer] :limit Number of clubs per page. Must be a lower or equal that 20
|
140
|
+
#
|
141
|
+
# @return [Array<Hash>] Array of hashes representing club ranobe
|
142
|
+
#
|
143
|
+
# @raise [Shikimori::API::NotFoundError] if club not exists
|
144
|
+
#
|
145
|
+
# @see https://shikimori.one/api/doc/1.0/clubs/ranobe Shikimori's API documentation
|
146
|
+
# @example First 20 club ranobe
|
147
|
+
# client = Shikimori::API::Client.new(
|
148
|
+
# app_name: 'Api Test',
|
149
|
+
# aceess_token: '****',
|
150
|
+
# refresh_token: '****'
|
151
|
+
# )
|
152
|
+
# client.v1.club_ranobe(limit: 20) #=> [{ id: 1, ...}, ...]
|
153
|
+
def club_ranobe(id, headers: nil, **query)
|
154
|
+
rest.get base_url.join('clubs', id.to_s, 'ranobe').url, headers: headers, query: query
|
155
|
+
end
|
156
|
+
|
157
|
+
# Get list of club's characters
|
158
|
+
#
|
159
|
+
# @param id [#to_s] Club's id
|
160
|
+
# @param headers [Hash] Request headers
|
161
|
+
# @param query [Hash] Query string parameters for request
|
162
|
+
# @option query [Integer] :page Number of page. Must be between 1 and 100000
|
163
|
+
# @option query [Integer] :limit Number of clubs per page. Must be a lower or equal that 20
|
164
|
+
#
|
165
|
+
# @return [Array<Hash>] Array of hashes representing club characters
|
166
|
+
#
|
167
|
+
# @raise [Shikimori::API::NotFoundError] if club not exists
|
168
|
+
#
|
169
|
+
# @see https://shikimori.one/api/doc/1.0/clubs/characters Shikimori's API documentation
|
170
|
+
# @example First 20 club characters
|
171
|
+
# client = Shikimori::API::Client.new(
|
172
|
+
# app_name: 'Api Test',
|
173
|
+
# aceess_token: '****',
|
174
|
+
# refresh_token: '****'
|
175
|
+
# )
|
176
|
+
# client.v1.club_characters(limit: 20) #=> [{ id: 1, ...}, ...]
|
177
|
+
def club_characters(id, headers: nil, **query)
|
178
|
+
rest.get base_url.join('clubs', id.to_s, 'characters').url, headers: headers, query: query
|
179
|
+
end
|
180
|
+
|
181
|
+
# Get list of club's collections
|
182
|
+
#
|
183
|
+
# @param id [#to_s] Club's id
|
184
|
+
# @param headers [Hash] Request headers
|
185
|
+
# @param query [Hash] Query string parameters for request
|
186
|
+
# @option query [Integer] :page Number of page. Must be between 1 and 100000
|
187
|
+
# @option query [Integer] :limit Number of clubs per page. Must be a lower or equal that 20
|
188
|
+
#
|
189
|
+
# @return [Array<Hash>] Array of hashes representing club collections
|
190
|
+
#
|
191
|
+
# @raise [Shikimori::API::NotFoundError] if club not exists
|
192
|
+
#
|
193
|
+
# @see https://shikimori.one/api/doc/1.0/clubs/collections Shikimori's API documentation
|
194
|
+
# @example First 20 club collections
|
195
|
+
# client = Shikimori::API::Client.new(
|
196
|
+
# app_name: 'Api Test',
|
197
|
+
# aceess_token: '****',
|
198
|
+
# refresh_token: '****'
|
199
|
+
# )
|
200
|
+
# client.v1.club_collections(limit: 20) #=> [{ id: 1, ...}, ...]
|
201
|
+
def club_collections(id, headers: nil, **query)
|
202
|
+
rest.get base_url.join('clubs', id.to_s, 'collections').url, headers: headers, query: query
|
203
|
+
end
|
204
|
+
|
205
|
+
# Get list of club's clubs
|
206
|
+
#
|
207
|
+
# @param id [#to_s] Club's id
|
208
|
+
# @param headers [Hash] Request headers
|
209
|
+
# @param query [Hash] Query string parameters for request
|
210
|
+
# @option query [Integer] :page Number of page. Must be between 1 and 100000
|
211
|
+
# @option query [Integer] :limit Number of clubs per page. Must be a lower or equal that 20
|
212
|
+
#
|
213
|
+
# @return [Array<Hash>] Array of hashes representing club clubs
|
214
|
+
#
|
215
|
+
# @raise [Shikimori::API::NotFoundError] if club not exists
|
216
|
+
#
|
217
|
+
# @see https://shikimori.one/api/doc/1.0/clubs/clubs Shikimori's API documentation
|
218
|
+
# @example First 20 club clubs
|
219
|
+
# client = Shikimori::API::Client.new(
|
220
|
+
# app_name: 'Api Test',
|
221
|
+
# aceess_token: '****',
|
222
|
+
# refresh_token: '****'
|
223
|
+
# )
|
224
|
+
# client.v1.club_clubs(limit: 20) #=> [{ id: 1, ...}, ...]
|
225
|
+
def club_clubs(id, headers: nil, **query)
|
226
|
+
rest.get base_url.join('clubs', id.to_s, 'clubs').url, headers: headers, query: query
|
227
|
+
end
|
228
|
+
|
229
|
+
# Get list of club's members
|
230
|
+
#
|
231
|
+
# @param id [#to_s] Club's id
|
232
|
+
# @param headers [Hash] Request headers
|
233
|
+
# @param query [Hash] Query string parameters for request
|
234
|
+
# @option query [Integer] :page Number of page. Must be between 1 and 100000
|
235
|
+
# @option query [Integer] :limit Number of clubs per page. Must be a lower or equal that 20
|
236
|
+
#
|
237
|
+
# @return [Array<Hash>] Array of hashes representing club members
|
238
|
+
#
|
239
|
+
# @raise [Shikimori::API::NotFoundError] if club not exists
|
240
|
+
#
|
241
|
+
# @see https://shikimori.one/api/doc/1.0/clubs/members Shikimori's API documentation
|
242
|
+
# @example First 20 club members
|
243
|
+
# client = Shikimori::API::Client.new(
|
244
|
+
# app_name: 'Api Test',
|
245
|
+
# aceess_token: '****',
|
246
|
+
# refresh_token: '****'
|
247
|
+
# )
|
248
|
+
# client.v1.club_members(limit: 20) #=> [{ id: 1, ...}, ...]
|
249
|
+
def club_members(id, headers: nil, **query)
|
250
|
+
rest.get base_url.join('clubs', id.to_s, 'members').url, headers: headers, query: query
|
251
|
+
end
|
252
|
+
|
253
|
+
# Get list of club's images
|
254
|
+
#
|
255
|
+
# @param id [#to_s] Club's id
|
256
|
+
# @param headers [Hash] Request headers
|
257
|
+
# @param query [Hash] Query string parameters for request
|
258
|
+
# @option query [Integer] :page Number of page. Must be between 1 and 100000
|
259
|
+
# @option query [Integer] :limit Number of clubs per page. Must be a lower or equal that 100
|
260
|
+
#
|
261
|
+
# @return [Array<Hash>] Array of hashes representing club images
|
262
|
+
#
|
263
|
+
# @raise [Shikimori::API::NotFoundError] if club not exists
|
264
|
+
#
|
265
|
+
# @see https://shikimori.one/api/doc/1.0/clubs/images Shikimori's API documentation
|
266
|
+
# @example First 20 club images
|
267
|
+
# client = Shikimori::API::Client.new(
|
268
|
+
# app_name: 'Api Test',
|
269
|
+
# aceess_token: '****',
|
270
|
+
# refresh_token: '****'
|
271
|
+
# )
|
272
|
+
# client.v1.club_images(limit: 20) #=> [{ id: 1, ...}, ...]
|
273
|
+
def club_images(id, headers: nil, **query)
|
274
|
+
rest.get base_url.join('clubs', id.to_s, 'images').url, headers: headers, query: query
|
275
|
+
end
|
276
|
+
|
277
|
+
# Join to club.
|
278
|
+
# Requires `clubs` oauth scope
|
279
|
+
# @param id [String] Club's id
|
280
|
+
# @param headers [Hash] Request headers
|
281
|
+
# @param query [Hash] Query string parameters for request
|
282
|
+
#
|
283
|
+
# @return [Boolean] True if join successful, error otherwise.
|
284
|
+
#
|
285
|
+
# @raise [Shikimori::API::ForbiddenError] if user authorized without `clubs` scope
|
286
|
+
# @raise [Shikimori::API::NotFoundError] if club not exists
|
287
|
+
#
|
288
|
+
# @see https://shikimori.one/api/doc/1.0/clubs/join Shikimori's API documentation
|
289
|
+
# @example Join to club with id equal to 1
|
290
|
+
# client = Shikimori::API::Client.new(
|
291
|
+
# app_name: 'Api Test',
|
292
|
+
# aceess_token: '****',
|
293
|
+
# refresh_token: '****'
|
294
|
+
# )
|
295
|
+
# client.v1.join_club(1)
|
296
|
+
def join_club(id, headers: nil, **query)
|
297
|
+
rest.post base_url.join('clubs', id.to_s, 'join').url, {}, headers: headers, query: query
|
298
|
+
|
299
|
+
true
|
300
|
+
end
|
301
|
+
|
302
|
+
# Leave from club.
|
303
|
+
# Requires `clubs` oauth scope
|
304
|
+
# @param id [String] Club's id
|
305
|
+
# @param headers [Hash] Request headers
|
306
|
+
# @param query [Hash] Query string parameters for request
|
307
|
+
#
|
308
|
+
# @return [Boolean] True if leave successful, error otherwise.
|
309
|
+
#
|
310
|
+
# @raise [Shikimori::API::ForbiddenError] if user authorized without `clubs` scope
|
311
|
+
# @raise [Shikimori::API::NotFoundError] if club not exists
|
312
|
+
#
|
313
|
+
# @see https://shikimori.one/api/doc/1.0/clubs/leave Shikimori's API documentation
|
314
|
+
# @example Leave from club with id equal to 1
|
315
|
+
# client = Shikimori::API::Client.new(
|
316
|
+
# app_name: 'Api Test',
|
317
|
+
# aceess_token: '****',
|
318
|
+
# refresh_token: '****'
|
319
|
+
# )
|
320
|
+
# client.v1.leave_club(1)
|
321
|
+
def leave_club(id, headers: nil, **query)
|
322
|
+
rest.post base_url.join('clubs', id.to_s, 'leave').url, {}, headers: headers, query: query
|
323
|
+
|
324
|
+
true
|
325
|
+
end
|
326
|
+
end
|
327
|
+
end
|
328
|
+
end
|
329
|
+
end
|
@@ -0,0 +1,161 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Shikimori
|
4
|
+
module API
|
5
|
+
class V1
|
6
|
+
# Methods for the Comments API
|
7
|
+
#
|
8
|
+
# @see https://shikimori.one/api/doc/1.0/comments Shikimori's API documentation
|
9
|
+
module Comments
|
10
|
+
# Get list of comments
|
11
|
+
#
|
12
|
+
# @param headers [Hash] Request headers
|
13
|
+
# @param query [Hash] Query string parameters for request
|
14
|
+
# @option query [Integer] :page Number of page. Must be between 1 and 100000
|
15
|
+
# @option query [Integer] :limit Number of comments per page. Must be a lower or equal that 30
|
16
|
+
# @option query [1, 0] :desc Sorting direction
|
17
|
+
# @option query [Integer] :commentable_id ID of object to comments requested
|
18
|
+
# @option query ['Topic', 'User'] :commentable_type Type of object to comments requested
|
19
|
+
#
|
20
|
+
# @return [Array<Hash>] Array of hashes representing comments
|
21
|
+
#
|
22
|
+
# @raise [Shikimori::API::NotFoundError] if commentable not exists
|
23
|
+
# @raise [Shikimori::API::RequestError] if commentable not sended
|
24
|
+
#
|
25
|
+
# @see https://shikimori.one/api/doc/1.0/comments/index Shikimori's API documentation
|
26
|
+
# @example Get a 10 comments for topic with id equal to 1
|
27
|
+
# client = Shikimori::API::Client.new(
|
28
|
+
# app_name: 'Api Test',
|
29
|
+
# aceess_token: '****',
|
30
|
+
# refresh_token: '****'
|
31
|
+
# )
|
32
|
+
# client.v1.comments(commentable_id: 1, commentable_type: 'Topic', limit: 10) #=> [{ id: 1, ... }, ...
|
33
|
+
def comments(headers: nil, **query)
|
34
|
+
rest.get base_url.join('comments').url, headers: headers, query: query
|
35
|
+
end
|
36
|
+
|
37
|
+
# Get a comment by id
|
38
|
+
#
|
39
|
+
# @param id [#to_s] Comment id
|
40
|
+
# @param headers [Hash] Request headers
|
41
|
+
# @param query [Hash] Query string parameters for request
|
42
|
+
#
|
43
|
+
# @return [Hash] Hash representing comment
|
44
|
+
#
|
45
|
+
# @raise [Shikimori::API::NotFoundError] if comment not exists
|
46
|
+
#
|
47
|
+
# @see https://shikimori.one/api/doc/1.0/comments/show Shikimori's API documentation
|
48
|
+
# @example Get a comment with id equal to 1
|
49
|
+
# client = Shikimori::API::Client.new(
|
50
|
+
# app_name: 'Api Test',
|
51
|
+
# aceess_token: '****',
|
52
|
+
# refresh_token: '****'
|
53
|
+
# )
|
54
|
+
# client.v1.comment(1) #=> { id: 1, ... }
|
55
|
+
def comment(id, headers: nil, **query)
|
56
|
+
rest.get base_url.join('comments', id.to_s).url, headers: headers, query: query
|
57
|
+
end
|
58
|
+
|
59
|
+
# Create a comment
|
60
|
+
# Requires `comments` oauth scope
|
61
|
+
#
|
62
|
+
# @param comment [Hash] Comment data for creating
|
63
|
+
# @option comment [String] :body Comment text
|
64
|
+
# @option comment [Integer] :commentable_id ID of object to comment
|
65
|
+
# @option comment ['Topic', 'User', 'Anime',
|
66
|
+
# 'Manga', 'Character', 'Person',
|
67
|
+
# 'Article', 'Club', 'ClubPage',
|
68
|
+
# 'Collection', 'Critique', 'Review'] :commentable_type Type of object to comment
|
69
|
+
# @option comment ['true', 'false', 1, 0] :is_offtopic Mark comment as offtopic
|
70
|
+
# @param broadcast ['false', 'true', 1, 0] Used to broadcast
|
71
|
+
# comment in club’s topic. Only club admins can broadcast.
|
72
|
+
# @param frontend ['false', 'true', 1, 0] Used by shikimori frontend code. Ignore it.
|
73
|
+
# @param headers [Hash] Request headers
|
74
|
+
# @param query [Hash] Query string parameters for request
|
75
|
+
#
|
76
|
+
# @return [Hash] Hash representing created comment
|
77
|
+
#
|
78
|
+
# @raise [Shikimori::API::RequestError] if bad request data
|
79
|
+
# @raise [Shikimori::API::NotFoundError] if commentable not exists
|
80
|
+
#
|
81
|
+
# @see https://shikimori.one/api/doc/1.0/comments/create Shikimori's API documentation
|
82
|
+
# @example Create a comment for topic with id equal to 1
|
83
|
+
# client = Shikimori::API::Client.new(
|
84
|
+
# app_name: 'Api Test',
|
85
|
+
# aceess_token: '****',
|
86
|
+
# refresh_token: '****'
|
87
|
+
# )
|
88
|
+
# client.v1.create_comment({ body: 'Hello, kitty! :)', commentable_type: 'Topic', commentable_id: 1 })
|
89
|
+
def create_comment(comment, broadcast: nil, frontend: nil, headers: nil, **query)
|
90
|
+
rest.post(
|
91
|
+
base_url.join('comments').url,
|
92
|
+
{ broadcast: broadcast, comment: comment, frontend: frontend }.compact,
|
93
|
+
headers: headers, query: query
|
94
|
+
)
|
95
|
+
end
|
96
|
+
|
97
|
+
# Update Comment.
|
98
|
+
# Requires `comments` oauth scope.
|
99
|
+
# Use {Shikimori::API::V2::AbuseRequests#abuse_offtopic_request} to change is_offtopic field.
|
100
|
+
#
|
101
|
+
# @param id [#to_s] Comment id
|
102
|
+
# @param comment [Hash] Comment data for updating
|
103
|
+
# @option comment [String] :body Comment text
|
104
|
+
# @option comment [Integer] :commentable_id ID of object to comment
|
105
|
+
# @option comment ['Topic', 'User', 'Anime',
|
106
|
+
# 'Manga', 'Character', 'Person',
|
107
|
+
# 'Article', 'Club', 'ClubPage',
|
108
|
+
# 'Collection', 'Critique', 'Review'] :commentable_type Type of object to comment
|
109
|
+
# @param headers [Hash] Request headers
|
110
|
+
# @param query [Hash] Query string parameters for request
|
111
|
+
# @option query ['false', 'true', 1, 0] :broadcast Used to broadcast
|
112
|
+
# comment in club’s topic. Only club admins can broadcast.
|
113
|
+
# @option query ['false', 'true', 1, 0] :frontend Used by shikimori frontend code. Ignore it.
|
114
|
+
#
|
115
|
+
# @return [Hash] Hash representing updated comment
|
116
|
+
#
|
117
|
+
# @raise [Shikimori::API::RequestError] if bad request data
|
118
|
+
# @raise [Shikimori::API::NotFoundError] if comment not exists
|
119
|
+
#
|
120
|
+
# @see https://shikimori.one/api/doc/1.0/comments/update Shikimori's API documentation
|
121
|
+
# @example Update a comment's text with id equal to 1
|
122
|
+
# client = Shikimori::API::Client.new(
|
123
|
+
# app_name: 'Api Test',
|
124
|
+
# aceess_token: '****',
|
125
|
+
# refresh_token: '****'
|
126
|
+
# )
|
127
|
+
# client.v1.update_comment(1, { body: "new text!" })
|
128
|
+
def update_comment(id, comment, headers: nil, **query)
|
129
|
+
rest.put(
|
130
|
+
base_url.join('comments', id.to_s).url,
|
131
|
+
{ broadcast: query.delete(:broadcast), comment: comment, frontend: query.delete(:frontend) }.compact,
|
132
|
+
headers: headers, query: query
|
133
|
+
)
|
134
|
+
end
|
135
|
+
|
136
|
+
# Delete Comment.
|
137
|
+
# Requires `comments` oauth scope
|
138
|
+
#
|
139
|
+
# @param id [String, Integer] Comment id
|
140
|
+
# @param headers [Hash] Request headers
|
141
|
+
# @param query [Hash] Query string parameters for request
|
142
|
+
#
|
143
|
+
# @return [Boolean] True if deletion successful, false otherwise.
|
144
|
+
#
|
145
|
+
# @raise [Shikimori::API::NotFoundError] if comment not exists
|
146
|
+
#
|
147
|
+
# @see https://shikimori.one/api/doc/1.0/comments/destroy Shikimori's API documentation
|
148
|
+
# @example Delete a comment with id equal to 1
|
149
|
+
# client = Shikimori::API::Client.new(
|
150
|
+
# app_name: 'Api Test',
|
151
|
+
# aceess_token: '****',
|
152
|
+
# refresh_token: '****'
|
153
|
+
# )
|
154
|
+
# client.v1.delete_comment(1)
|
155
|
+
def delete_comment(id, headers: nil, **query)
|
156
|
+
rest.delete base_url.join('comments', id.to_s).url, headers: headers, query: query
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Shikimori
|
4
|
+
module API
|
5
|
+
class V1
|
6
|
+
# Methods for the Constants API
|
7
|
+
#
|
8
|
+
# @see https://shikimori.one/api/doc/1.0/constants Shikimori's API documentation
|
9
|
+
module Constants
|
10
|
+
# Get anime constants
|
11
|
+
#
|
12
|
+
# @param headers [Hash] Request headers
|
13
|
+
# @param query [Hash] Query string parameters for request
|
14
|
+
#
|
15
|
+
# @return [Hash] Hash representing constants
|
16
|
+
#
|
17
|
+
# @see https://shikimori.one/api/doc/1.0/constants/anime Shikimori's API documentation
|
18
|
+
# @example Get anime constants
|
19
|
+
# client = Shikimori::API::Client.new(
|
20
|
+
# app_name: 'Api Test',
|
21
|
+
# aceess_token: '****',
|
22
|
+
# refresh_token: '****'
|
23
|
+
# )
|
24
|
+
# client.v1.anime_constants #=> { kind: [...], status: [...] }
|
25
|
+
def anime_constants(headers: nil, **query)
|
26
|
+
rest.get base_url.join('constants', 'anime').url, headers: headers, query: query
|
27
|
+
end
|
28
|
+
|
29
|
+
# Get manga constants
|
30
|
+
#
|
31
|
+
# @param headers [Hash] Request headers
|
32
|
+
# @param query [Hash] Query string parameters for request
|
33
|
+
#
|
34
|
+
# @return [Hash] Hash representing constants
|
35
|
+
#
|
36
|
+
# @see https://shikimori.one/api/doc/1.0/constants/manga Shikimori's API documentation
|
37
|
+
# @example Get manga constants
|
38
|
+
# client = Shikimori::API::Client.new(
|
39
|
+
# app_name: 'Api Test',
|
40
|
+
# aceess_token: '****',
|
41
|
+
# refresh_token: '****'
|
42
|
+
# )
|
43
|
+
# client.v1.manga_constants #=> { kind: [...], status: [...] }
|
44
|
+
def manga_constants(headers: nil, **query)
|
45
|
+
rest.get base_url.join('constants', 'manga').url, headers: headers, query: query
|
46
|
+
end
|
47
|
+
|
48
|
+
# Get user rate constants
|
49
|
+
#
|
50
|
+
# @param headers [Hash] Request headers
|
51
|
+
# @param query [Hash] Query string parameters for request
|
52
|
+
#
|
53
|
+
# @return [Hash] Hash representing constants
|
54
|
+
#
|
55
|
+
# @see https://shikimori.one/api/doc/1.0/constants/user_rate Shikimori's API documentation
|
56
|
+
# @example Get user_rate constants
|
57
|
+
# client = Shikimori::API::Client.new(
|
58
|
+
# app_name: 'Api Test',
|
59
|
+
# aceess_token: '****',
|
60
|
+
# refresh_token: '****'
|
61
|
+
# )
|
62
|
+
# client.v1.user_rate_constants #=> { status: [...] }
|
63
|
+
def user_rate_constants(headers: nil, **query)
|
64
|
+
rest.get base_url.join('constants', 'user_rate').url, headers: headers, query: query
|
65
|
+
end
|
66
|
+
|
67
|
+
# Get club constants
|
68
|
+
#
|
69
|
+
# @param headers [Hash] Request headers
|
70
|
+
# @param query [Hash] Query string parameters for request
|
71
|
+
#
|
72
|
+
# @return [Hash] Hash representing constants
|
73
|
+
#
|
74
|
+
# @see https://shikimori.one/api/doc/1.0/constants/club Shikimori's API documentation
|
75
|
+
# @example Get club constants
|
76
|
+
# client = Shikimori::API::Client.new(
|
77
|
+
# app_name: 'Api Test',
|
78
|
+
# aceess_token: '****',
|
79
|
+
# refresh_token: '****'
|
80
|
+
# )
|
81
|
+
# client.v1.club_constants #=> { join_policy: [...], comment_policy: [...], image_upload_policy: [...] }
|
82
|
+
def club_constants(headers: nil, **query)
|
83
|
+
rest.get base_url.join('constants', 'club').url, headers: headers, query: query
|
84
|
+
end
|
85
|
+
|
86
|
+
# Get list of smileys constants
|
87
|
+
#
|
88
|
+
# @param headers [Hash] Request headers
|
89
|
+
# @param query [Hash] Query string parameters for request
|
90
|
+
#
|
91
|
+
# @return [Array<Hash>] Array of hashes representing constants
|
92
|
+
#
|
93
|
+
# @see https://shikimori.one/api/doc/1.0/constants/smileys Shikimori's API documentation
|
94
|
+
# @example Get smileys constants
|
95
|
+
# client = Shikimori::API::Client.new(
|
96
|
+
# app_name: 'Api Test',
|
97
|
+
# aceess_token: '****',
|
98
|
+
# refresh_token: '****'
|
99
|
+
# )
|
100
|
+
# client.v1.smileys_constants #=> [{ bbcode: '...', path: '...' }, ...]
|
101
|
+
def smileys_constants(headers: nil, **query)
|
102
|
+
rest.get base_url.join('constants', 'smileys').url, headers: headers, query: query
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Shikimori
|
4
|
+
module API
|
5
|
+
class V1
|
6
|
+
# Methods for the Dialogs API
|
7
|
+
#
|
8
|
+
# @see https://shikimori.one/api/doc/1.0/dialogs Shikimori's API documentation
|
9
|
+
module Dialogs
|
10
|
+
# Get list of Dialogs.
|
11
|
+
# Requires `messages` oauth scope
|
12
|
+
#
|
13
|
+
# @param headers [Hash] Request headers
|
14
|
+
# @param query [Hash] Query string parameters for request
|
15
|
+
# @option query [Integer] :page Number of page. Must be between 1 and 100000
|
16
|
+
# @option query [Integer] :limit Number of dialogs per page. Must be a lower or equal that 20
|
17
|
+
#
|
18
|
+
# @return [Array<Hash>] Array of hashes representing dialogs
|
19
|
+
#
|
20
|
+
# @see https://shikimori.one/api/doc/1.0/dialogs/index Shikimori's API documentation
|
21
|
+
# @example Get list of dialogs
|
22
|
+
# client = Shikimori::API::Client.new(
|
23
|
+
# app_name: 'Api Test',
|
24
|
+
# aceess_token: '****',
|
25
|
+
# refresh_token: '****'
|
26
|
+
# )
|
27
|
+
# client.v1.dialogs
|
28
|
+
def dialogs(headers: nil, **query)
|
29
|
+
rest.get base_url.join('dialogs').url, headers: headers, query: query
|
30
|
+
end
|
31
|
+
|
32
|
+
# Get a dialog by username.
|
33
|
+
# Requires `messages` oauth scope
|
34
|
+
#
|
35
|
+
# @param username [#to_s] Dialog's username
|
36
|
+
# @param headers [Hash] Request headers
|
37
|
+
# @param query [Hash] Query string parameters for request
|
38
|
+
# @option query [Integer] :page Number of page. Must be between 1 and 100000
|
39
|
+
# @option query [Integer] :limit Number of dialogs per page. Must be a lower or equal that 20
|
40
|
+
#
|
41
|
+
# @return [Hash] Hash representing dialog
|
42
|
+
#
|
43
|
+
# @see https://shikimori.one/api/doc/1.0/dialogs/show Shikimori's API documentation
|
44
|
+
# @example Get dialog with username equal to 1
|
45
|
+
# client = Shikimori::API::Client.new(
|
46
|
+
# app_name: 'Api Test',
|
47
|
+
# aceess_token: '****',
|
48
|
+
# refresh_token: '****'
|
49
|
+
# )
|
50
|
+
# client.v1.dialog('user_12') #=> [{ id: 1, ... }]
|
51
|
+
def dialog(username, headers: nil, **query)
|
52
|
+
rest.get base_url.join('dialogs', username.to_s).url, headers: headers, query: query
|
53
|
+
end
|
54
|
+
|
55
|
+
# Delete Dialog.
|
56
|
+
# Requires `messages` oauth scope
|
57
|
+
#
|
58
|
+
# @param username [#to_s] Dialog's username
|
59
|
+
# @param headers [Hash] Request headers
|
60
|
+
# @param query [Hash] Query string parameters for request
|
61
|
+
#
|
62
|
+
# @return [Boolean] True if deletion successful, false otherwise.
|
63
|
+
#
|
64
|
+
# @see https://shikimori.one/api/doc/1.0/dialogs/destroy Shikimori's API documentation
|
65
|
+
# @example Delete dialog with id equal to 1
|
66
|
+
# client = Shikimori::API::Client.new(
|
67
|
+
# app_name: 'Api Test',
|
68
|
+
# aceess_token: '****',
|
69
|
+
# refresh_token: '****'
|
70
|
+
# )
|
71
|
+
# client.v1.delete_dialog('user_12') #=> true
|
72
|
+
def delete_dialog(username, headers: nil, **query)
|
73
|
+
rest.delete base_url.join('dialogs', username.to_s).url, headers: headers, query: query
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|