shikimori-api 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +20 -0
  3. data/lib/shikimori/api/client.rb +34 -0
  4. data/lib/shikimori/api/errors.rb +21 -0
  5. data/lib/shikimori/api/rest.rb +115 -0
  6. data/lib/shikimori/api/uri.rb +18 -0
  7. data/lib/shikimori/api/v1/achievements.rb +32 -0
  8. data/lib/shikimori/api/v1/animes.rb +252 -0
  9. data/lib/shikimori/api/v1/appear.rb +40 -0
  10. data/lib/shikimori/api/v1/bans.rb +31 -0
  11. data/lib/shikimori/api/v1/calendars.rb +32 -0
  12. data/lib/shikimori/api/v1/characters.rb +52 -0
  13. data/lib/shikimori/api/v1/clubs.rb +329 -0
  14. data/lib/shikimori/api/v1/comments.rb +161 -0
  15. data/lib/shikimori/api/v1/constants.rb +107 -0
  16. data/lib/shikimori/api/v1/dialogs.rb +78 -0
  17. data/lib/shikimori/api/v1/favorites.rb +148 -0
  18. data/lib/shikimori/api/v1/forums.rb +31 -0
  19. data/lib/shikimori/api/v1/friends.rb +57 -0
  20. data/lib/shikimori/api/v1/genres.rb +31 -0
  21. data/lib/shikimori/api/v1/ignores.rb +62 -0
  22. data/lib/shikimori/api/v1/mangas.rb +211 -0
  23. data/lib/shikimori/api/v1/messages.rb +168 -0
  24. data/lib/shikimori/api/v1/people.rb +53 -0
  25. data/lib/shikimori/api/v1/publishers.rb +31 -0
  26. data/lib/shikimori/api/v1/ranobe.rb +206 -0
  27. data/lib/shikimori/api/v1/reviews.rb +89 -0
  28. data/lib/shikimori/api/v1/stats.rb +31 -0
  29. data/lib/shikimori/api/v1/studios.rb +31 -0
  30. data/lib/shikimori/api/v1/styles.rb +112 -0
  31. data/lib/shikimori/api/v1/topic_ignores.rb +63 -0
  32. data/lib/shikimori/api/v1/topics.rb +237 -0
  33. data/lib/shikimori/api/v1/user_images.rb +36 -0
  34. data/lib/shikimori/api/v1/user_rates.rb +194 -0
  35. data/lib/shikimori/api/v1/users.rb +310 -0
  36. data/lib/shikimori/api/v1/videos.rb +85 -0
  37. data/lib/shikimori/api/v1.rb +77 -0
  38. data/lib/shikimori/api/v2/abuse_requests.rb +103 -0
  39. data/lib/shikimori/api/v2/episode_notifications.rb +54 -0
  40. data/lib/shikimori/api/v2/topic_ignore.rb +54 -0
  41. data/lib/shikimori/api/v2/user_ignore.rb +54 -0
  42. data/lib/shikimori/api/v2/user_rates.rb +171 -0
  43. data/lib/shikimori/api/v2.rb +27 -0
  44. data/lib/shikimori/api/version.rb +8 -0
  45. data/lib/shikimori/api.rb +14 -0
  46. data/lib/shikimori-api.rb +3 -0
  47. data/shikimori-api.gemspec +40 -0
  48. data/sig/shikimori/api/client.rbs +12 -0
  49. data/sig/shikimori/api/rest.rbs +30 -0
  50. data/sig/shikimori/api/uri.rbs +10 -0
  51. data/sig/shikimori/api/v1/achievements.rbs +15 -0
  52. data/sig/shikimori/api/v1/animes.rbs +23 -0
  53. data/sig/shikimori/api/v1/appear.rbs +15 -0
  54. data/sig/shikimori/api/v1/bans.rbs +15 -0
  55. data/sig/shikimori/api/v1/calendars.rbs +15 -0
  56. data/sig/shikimori/api/v1/characters.rbs +16 -0
  57. data/sig/shikimori/api/v1/clubs.rbs +29 -0
  58. data/sig/shikimori/api/v1/comments.rbs +19 -0
  59. data/sig/shikimori/api/v1/constants.rbs +19 -0
  60. data/sig/shikimori/api/v1/dialogs.rbs +17 -0
  61. data/sig/shikimori/api/v1/favorites.rbs +23 -0
  62. data/sig/shikimori/api/v1/forums.rbs +15 -0
  63. data/sig/shikimori/api/v1/friends.rbs +16 -0
  64. data/sig/shikimori/api/v1/genres.rbs +15 -0
  65. data/sig/shikimori/api/v1/ignores.rbs +16 -0
  66. data/sig/shikimori/api/v1/mangas.rbs +23 -0
  67. data/sig/shikimori/api/v1/messages.rbs +20 -0
  68. data/sig/shikimori/api/v1/people.rbs +16 -0
  69. data/sig/shikimori/api/v1/publishers.rbs +15 -0
  70. data/sig/shikimori/api/v1/ranobe.rbs +23 -0
  71. data/sig/shikimori/api/v1/reviews.rbs +19 -0
  72. data/sig/shikimori/api/v1/stats.rbs +15 -0
  73. data/sig/shikimori/api/v1/studios.rbs +15 -0
  74. data/sig/shikimori/api/v1/styles.rbs +18 -0
  75. data/sig/shikimori/api/v1/topic_ignores.rbs +16 -0
  76. data/sig/shikimori/api/v1/topics.rbs +40 -0
  77. data/sig/shikimori/api/v1/user_images.rbs +15 -0
  78. data/sig/shikimori/api/v1/user_rates.rbs +44 -0
  79. data/sig/shikimori/api/v1/users.rbs +28 -0
  80. data/sig/shikimori/api/v1/videos.rbs +23 -0
  81. data/sig/shikimori/api/v1.rbs +41 -0
  82. data/sig/shikimori/api/v2/abuse_requests.rbs +18 -0
  83. data/sig/shikimori/api/v2/episode_notifications.rbs +25 -0
  84. data/sig/shikimori/api/v2/topic_ignore.rbs +16 -0
  85. data/sig/shikimori/api/v2/user_ignore.rbs +16 -0
  86. data/sig/shikimori/api/v2/user_rates.rbs +43 -0
  87. data/sig/shikimori/api/v2.rbs +16 -0
  88. data/sig/shikimori/api/version.rbs +5 -0
  89. data/sig/shikimori/api.rbs +18 -0
  90. metadata +137 -0
@@ -0,0 +1,168 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Shikimori
4
+ module API
5
+ class V1
6
+ # Methods for the Messages API
7
+ #
8
+ # @see https://shikimori.one/api/doc/1.0/messages Shikimori's API documentation
9
+ module Messages
10
+ # Get a message by id.
11
+ #
12
+ # Requires `messages` oauth scope
13
+ # @param id [#to_s] message id
14
+ # @param headers [Hash] Request headers
15
+ # @param query [Hash] Query string parameters for request
16
+ #
17
+ # @return [Hash] Hash representing message
18
+ #
19
+ # @see https://shikimori.one/api/doc/1.0/messages/show Shikimori's API documentation
20
+ # @example Get a message with id equal to 1
21
+ # client = Shikimori::API::Client.new(
22
+ # app_name: 'Api Test',
23
+ # aceess_token: '****',
24
+ # refresh_token: '****'
25
+ # )
26
+ # client.v1.message(1) #=> { id: 1, ... }
27
+ def message(id, headers: nil, **query)
28
+ rest.get base_url.join('messages', id.to_s).url, headers: headers, query: query
29
+ end
30
+
31
+ # Create a message
32
+ # Requires `messages` oauth scope
33
+ #
34
+ # @param message [Hash] Message data for creating
35
+ # @option message [String] :body message text
36
+ # @option message [Integer] :from_id user id, that sending a message
37
+ # @option message [Integer] :to_id user id, that receiving a message
38
+ # @option message ['Private'] :kind message type
39
+ # @param frontend ['false', 'true', 1, 0] Used by shikimori frontend code. Ignore it.
40
+ # @param headers [Hash] Request headers
41
+ # @param query [Hash] Query string parameters for request
42
+ #
43
+ # @return [Hash] Hash representing created message
44
+ #
45
+ # @see https://shikimori.one/api/doc/1.0/messages/create Shikimori's API documentation
46
+ # @example Send message by user with id 1 to user with 2
47
+ # client = Shikimori::API::Client.new(
48
+ # app_name: 'Api Test',
49
+ # aceess_token: '****',
50
+ # refresh_token: '****'
51
+ # )
52
+ # client.v1.create_message({ body: 'Hello, kitty! :)', from_id: 1, to_id: 2, kind: 'Private' })
53
+ def create_message(message, frontend: nil, headers: nil, **query)
54
+ rest.post(
55
+ base_url.join('messages').url,
56
+ { message: message, frontend: frontend }.compact,
57
+ headers: headers, query: query
58
+ )
59
+ end
60
+
61
+ # Update message.
62
+ # Requires `messages` oauth scope
63
+ #
64
+ # @param id [#to_s] message id
65
+ # @param message [Hash] message data for updating
66
+ # @option message [String] :body message text
67
+ # @param headers [Hash] Request headers
68
+ # @param query [Hash] Query string parameters for request
69
+ # @option query ['false', 'true', 1, 0] :frontend Used by shikimori frontend code. Ignore it.
70
+ #
71
+ # @return [Hash] Hash representing updated message
72
+ #
73
+ # @see https://shikimori.one/api/doc/1.0/messages/update Shikimori's API documentation
74
+ # @example Update a message's text with id equal to 1
75
+ # client = Shikimori::API::Client.new(
76
+ # app_name: 'Api Test',
77
+ # aceess_token: '****',
78
+ # refresh_token: '****'
79
+ # )
80
+ # client.v1.update_message(1, { body: "new text!" })
81
+ def update_message(id, message, headers: nil, **query)
82
+ rest.put(
83
+ base_url.join('messages', id.to_s).url,
84
+ { message: message, frontend: query.delete(:frontend) }.compact,
85
+ headers: headers, query: query
86
+ )
87
+ end
88
+
89
+ # Delete message.
90
+ # Requires `messages` oauth scope
91
+ #
92
+ # @param id [String, Integer] message id
93
+ # @param headers [Hash] Request headers
94
+ # @param query [Hash] Query string parameters for request
95
+ #
96
+ # @return [Boolean] True if deletion successful, false otherwise.
97
+ #
98
+ # @see https://shikimori.one/api/doc/1.0/messages/destroy Shikimori's API documentation
99
+ # @example Delete a message with id equal to 1
100
+ # client = Shikimori::API::Client.new(
101
+ # app_name: 'Api Test',
102
+ # aceess_token: '****',
103
+ # refresh_token: '****'
104
+ # )
105
+ # client.v1.delete_message(1)
106
+ def delete_message(id, headers: nil, **query)
107
+ rest.delete base_url.join('messages', id.to_s).url, headers: headers, query: query
108
+ end
109
+
110
+ # Mark all messages as read by type
111
+ # Requires `messages` oauth scope
112
+ #
113
+ # @param type ['news', 'notifications'] Type of messages to read
114
+ # @param frontend ['false', 'true', 1, 0] Used by shikimori frontend code. Ignore it.
115
+ # @param headers [Hash] Request headers
116
+ # @param query [Hash] Query string parameters for request
117
+ #
118
+ # @return [Hash] Hash representing of readed messages
119
+ #
120
+ # @see https://shikimori.one/api/doc/1.0/messages/read_all Shikimori's API documentation
121
+ # @example Read all notifications
122
+ # client = Shikimori::API::Client.new(
123
+ # app_name: 'Api Test',
124
+ # aceess_token: '****',
125
+ # refresh_token: '****'
126
+ # )
127
+ # client.v1.read_all_messages(type: 'notifications')
128
+ def read_all_messages(type:, frontend: nil, headers: nil, **query)
129
+ rest.post(
130
+ base_url.join('messages', 'read_all').url,
131
+ { type: type, frontend: frontend }.compact,
132
+ headers: headers, query: query
133
+ )
134
+
135
+ true
136
+ end
137
+
138
+ # Delete all messages by type
139
+ # Requires `messages` oauth scope
140
+ #
141
+ # @param type ['news', 'notifications'] Type of messages to delete
142
+ # @param frontend ['false', 'true', 1, 0] Used by shikimori frontend code. Ignore it.
143
+ # @param headers [Hash] Request headers
144
+ # @param query [Hash] Query string parameters for request
145
+ #
146
+ # @return [Hash] Hash representing of deleted messages
147
+ #
148
+ # @see https://shikimori.one/api/doc/1.0/messages/delete_all Shikimori's API documentation
149
+ # @example Delete all notifications
150
+ # client = Shikimori::API::Client.new(
151
+ # app_name: 'Api Test',
152
+ # aceess_token: '****',
153
+ # refresh_token: '****'
154
+ # )
155
+ # client.v1.delete_all_messages(type: 'notifications')
156
+ def delete_all_messages(type:, frontend: nil, headers: nil, **query)
157
+ rest.post(
158
+ base_url.join('messages', 'delete_all').url,
159
+ { type: type, frontend: frontend }.compact,
160
+ headers: headers, query: query
161
+ )
162
+
163
+ true
164
+ end
165
+ end
166
+ end
167
+ end
168
+ end
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Shikimori
4
+ module API
5
+ class V1
6
+ # Methods for the People API
7
+ #
8
+ # @see https://shikimori.one/api/doc/1.0/people Shikimori's API documentation
9
+ module People
10
+ # Get list of People
11
+ #
12
+ # @param headers [Hash] Request headers
13
+ # @param query [Hash] Query string parameters for request
14
+ # @option query [String] :search Filter by person name
15
+ # @option query ['seyu', 'mangaka', 'producer'] :kind Filter by person type
16
+ #
17
+ # @return [Array<Hash>] Array of hashes representing people
18
+ #
19
+ # @see https://shikimori.one/api/doc/1.0/people/index Shikimori's API documentation
20
+ # @example Search a Hayao Miyazaki at mangakas list
21
+ # client = Shikimori::API::Client.new(
22
+ # app_name: 'Api Test',
23
+ # aceess_token: '****',
24
+ # refresh_token: '****'
25
+ # )
26
+ # client.v1.people(search: 'Hayao Miyazaki', kind: 'mangaka')
27
+ def people(headers: nil, **query)
28
+ rest.get base_url.join('people', 'search').url, headers: headers, query: query
29
+ end
30
+
31
+ # Get an person by id
32
+ #
33
+ # @param id [String, Integer] Person id
34
+ # @param headers [Hash] Request headers
35
+ # @param query [Hash] Query string parameters for request
36
+ #
37
+ # @return [Hash] Hash representing person
38
+ #
39
+ # @see https://shikimori.one/api/doc/1.0/people/show Shikimori's API documentation
40
+ # @example Get a person with id equal to 1
41
+ # client = Shikimori::API::Client.new(
42
+ # app_name: 'Api Test',
43
+ # aceess_token: '****',
44
+ # refresh_token: '****'
45
+ # )
46
+ # client.v1.person(1)
47
+ def person(id, headers: nil, **query)
48
+ rest.get base_url.join('people', id.to_s).url, headers: headers, query: query
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Shikimori
4
+ module API
5
+ class V1
6
+ # Methods for the Publishers API
7
+ #
8
+ # @see https://shikimori.one/api/doc/1.0/publishers Shikimori's API documentation
9
+ module Publishers
10
+ # Get list of publishers
11
+ #
12
+ # @param headers [Hash] Request headers
13
+ # @param query [Hash] Query string parameters for request
14
+ #
15
+ # @return [Hash] Array of hashes representing publishers
16
+ #
17
+ # @see https://shikimori.one/api/doc/1.0/publishers/index Shikimori's API documentation
18
+ # @example Get list of publishers
19
+ # client = Shikimori::API::Client.new(
20
+ # app_name: 'Api Test',
21
+ # aceess_token: '****',
22
+ # refresh_token: '****'
23
+ # )
24
+ # client.v1.publishers #=> [{ id: 1, ... }, ...]
25
+ def publishers(headers: nil, **query)
26
+ rest.get base_url.join('publishers').url, headers: headers, query: query
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,206 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Shikimori
4
+ module API
5
+ class V1
6
+ # Methods for the Ranobes API
7
+ #
8
+ # @see https://shikimori.one/api/doc/1.0/ranobe Shikimori's API documentation
9
+ module Ranobe
10
+ # Get list of ranobe titles
11
+ #
12
+ # @param headers [Hash] Request headers
13
+ # @param query [Hash] Filters and pagination for ranobes
14
+ # @option query [Integer] :page Number of page. Must be between 1 and 100000
15
+ # @option query [Integer] :limit Number of titles per page. Must be a lower or equal that 50
16
+ # @option query ["id", "id_desc", "ranked", "chapters",
17
+ # "kind", "popularity", "name",
18
+ # "aired_on", "volumes", "status",
19
+ # "random", "ranked_random",
20
+ # "ranked_shiki", "created_at", "created_at_desc"] :order Sorting type.
21
+ # @option query ["anons", "ongoing", "released", "paused", "discontinued"] :status Ranobe title status
22
+ # @option query [String] :season Ranobe season. Examples: "summer_2017", "2016", "2014_2016", "199x"
23
+ # @option query [Integer] :score Minimal ranobe score
24
+ # @option query [String] :genre List of genre ids separated by comma
25
+ # @option query [String] :publisher List of publisher ids separated by comma
26
+ # @option query [String] :franchise List of franchises separated by comma
27
+ # @option query [TrueClass, FalseClass] :censored Set to false to allow hentai, yaoi and yuri
28
+ # @option query ["planned", "watching", "rewatching",
29
+ # "completed", "on_hold", "dropped"] :mylist Status of anime in current user list
30
+ # @option query [String] :ids List of anime ids separated by comma
31
+ # @option query [String] :exclude_ids List of anime ids separated by comma
32
+ # @option query [String] :search Search phrase to filter ranobes by name
33
+ #
34
+ # @return [Array<Hash>] Array of hashes representing ranobes
35
+ #
36
+ # @see https://shikimori.one/api/doc/1.0/ranobe/index Shikimori's API documentation
37
+ # @example Get 20 ranobe titles on second page
38
+ # client = Shikimori::API::Client.new(
39
+ # app_name: 'Api Test',
40
+ # aceess_token: '****',
41
+ # refresh_token: '****'
42
+ # )
43
+ # client.v1.ranobes(page: 2, limit: 20) #=> [{ id: 1, ... }, { id: 2, ... }, ...]
44
+ # @example Get top 50 ongoing ranobe titles
45
+ # client = Shikimori::API::Client.new(
46
+ # app_name: 'Api Test',
47
+ # aceess_token: '****',
48
+ # refresh_token: '****'
49
+ # )
50
+ # client.v1.ranobes(limit: 50, status: 'ongoing', order: 'ranked') #=> [{ id: 1, ... }, { id: 2, ... }, ...]
51
+ # @example Get 10 random ranobe titles released in the 90s
52
+ # client = Shikimori::API::Client.new(
53
+ # app_name: 'Api Test',
54
+ # aceess_token: '****',
55
+ # refresh_token: '****'
56
+ # )
57
+ # client.v1.ranobes(limit: 10, order: 'random', season: '199x') #=> [{ id: 1, ... }, { id: 2, ... }, ...]
58
+ def ranobes(headers: nil, **query)
59
+ rest.get base_url.join('ranobe').url, headers: headers, query: query
60
+ end
61
+
62
+ # Get an ranobe by id
63
+ #
64
+ # @param id [#to_s] ranobe id
65
+ # @param headers [Hash] Request headers
66
+ # @param query [Hash] Query string parameters for request
67
+ #
68
+ # @return [Hash] Hash representing ranobe
69
+ #
70
+ # @see https://shikimori.one/api/doc/1.0/ranobe/show Shikimori's API documentation
71
+ # @example Get ranobe with id equal to 1
72
+ # client = Shikimori::API::Client.new(
73
+ # app_name: 'Api Test',
74
+ # aceess_token: '****',
75
+ # refresh_token: '****'
76
+ # )
77
+ # client.v1.ranobe(1) #=> { id: 1, ... }
78
+ def ranobe(id, headers: nil, **query)
79
+ rest.get base_url.join('ranobe', id.to_s).url, headers: headers, query: query
80
+ end
81
+
82
+ # Get an ranobe roles
83
+ #
84
+ # @param id [#to_s] ranobe id
85
+ # @param headers [Hash] Request headers
86
+ # @param query [Hash] Query string parameters for request
87
+ #
88
+ # @return [Hash] Hash representing ranobe roles
89
+ #
90
+ # @see https://shikimori.one/api/doc/1.0/ranobe/roles Shikimori's API documentation
91
+ # @example Get a first ranobe roles
92
+ # client = Shikimori::API::Client.new(
93
+ # app_name: 'Api Test',
94
+ # aceess_token: '****',
95
+ # refresh_token: '****'
96
+ # )
97
+ # client.v1.ranobe_roles(1) #=> { roles: [...], roles_russian: [...], character: {...}, person: {...} }
98
+ def ranobe_roles(id, headers: nil, **query)
99
+ rest.get base_url.join('ranobe', id.to_s, 'roles').url, headers: headers, query: query
100
+ end
101
+
102
+ # Get an ranobe similar
103
+ #
104
+ # @param id [#to_s] ranobe id
105
+ # @param headers [Hash] Request headers
106
+ # @param query [Hash] Query string parameters for request
107
+ #
108
+ # @return [Array<Hash>] Array of hashes representing similar ranobes
109
+ #
110
+ # @see https://shikimori.one/api/doc/1.0/ranobe/similar Shikimori's API documentation
111
+ # @example Get a similar ranobe titles for ranobe with id equal to 1
112
+ # client = Shikimori::API::Client.new(
113
+ # app_name: 'Api Test',
114
+ # aceess_token: '****',
115
+ # refresh_token: '****'
116
+ # )
117
+ # client.v1.ranobe_similar(1) #=> { id: 2, ... }
118
+ def ranobe_similar(id, headers: nil, **query)
119
+ rest.get base_url.join('ranobe', id.to_s, 'similar').url, headers: headers, query: query
120
+ end
121
+
122
+ # Get an related ranobes
123
+ #
124
+ # @param id [#to_s] ranobe id
125
+ # @param headers [Hash] Request headers
126
+ # @param query [Hash] Query string parameters for request
127
+ #
128
+ # @return [Array<Hash>] Array of hashes representing related ranobes
129
+ #
130
+ # @see https://shikimori.one/api/doc/1.0/ranobe/related Shikimori's API documentation
131
+ # @example Get a related anime, manga and ranobe titles for anime with id equal to 1
132
+ # client = Shikimori::API::Client.new(
133
+ # app_name: 'Api Test',
134
+ # aceess_token: '****',
135
+ # refresh_token: '****'
136
+ # )
137
+ # client.v1.ranobe_related(1)
138
+ # #=> [{ relation: "...", relation_russian: "...", anime: { id: 3, ... }, ranobe: { id: 1, ... } }]
139
+ def ranobe_related(id, headers: nil, **query)
140
+ rest.get base_url.join('ranobe', id.to_s, 'related').url, headers: headers, query: query
141
+ end
142
+
143
+ # Get an ranobe franchise
144
+ #
145
+ # @param id [#to_s] ranobe id
146
+ # @param headers [Hash] Request headers
147
+ # @param query [Hash] Query string parameters for request
148
+ #
149
+ # @return [Hash] Hash representing of ranobe's franchise tree
150
+ #
151
+ # @see https://shikimori.one/api/doc/1.0/ranobe/franchise Shikimori's API documentation
152
+ # @example Get ranobe franchise tree for ranobe with id equal to 1
153
+ # client = Shikimori::API::Client.new(
154
+ # app_name: 'Api Test',
155
+ # aceess_token: '****',
156
+ # refresh_token: '****'
157
+ # )
158
+ # client.v1.ranobe_franchise(1) #=> { links: [{ id: 1, ... }], nodes: [{ id: 1, ... }], current_id: 1 }
159
+ def ranobe_franchise(id, headers: nil, **query)
160
+ rest.get base_url.join('ranobe', id.to_s, 'franchise').url, headers: headers, query: query
161
+ end
162
+
163
+ # Get an ranobe external links
164
+ #
165
+ # @param id [#to_s] ranobe id
166
+ # @param headers [Hash] Request headers
167
+ # @param query [Hash] Query string parameters for request
168
+ #
169
+ # @return [Array<Hash>] Array of hashes representing ranobe's extenal links
170
+ #
171
+ # @see https://shikimori.one/api/doc/1.0/ranobe/external_links Shikimori's API documentation
172
+ # @example Get related external links for ranobe with id equal 1
173
+ # client = Shikimori::API::Client.new(
174
+ # app_name: 'Api Test',
175
+ # aceess_token: '****',
176
+ # refresh_token: '****'
177
+ # )
178
+ # client.v1.ranobe_external_links(1) #=> [{ id: 1, ... }, { id: nil, ... }]
179
+ def ranobe_external_links(id, headers: nil, **query)
180
+ rest.get base_url.join('ranobe', id.to_s, 'external_links').url, headers: headers, query: query
181
+ end
182
+
183
+ # Get an ranobe topics
184
+ #
185
+ # @param id [#to_s] ranobe id
186
+ # @param headers [Hash] Request headers
187
+ # @param query [Hash] Query string parameters for request
188
+ # @option query [Integer] :page Number of page. Must be between 1 and 100000
189
+ # @option query [Integer] :limit Number of titles per page. Must be a lower or equal that 50
190
+ # @return [Array<Hash>] Array of hashes representing ranobe's topics
191
+ #
192
+ # @see https://shikimori.one/api/doc/1.0/ranobe/topics Shikimori's API documentation
193
+ # @example Get topics for ranobe with id equal 1
194
+ # client = Shikimori::API::Client.new(
195
+ # app_name: 'Api Test',
196
+ # aceess_token: '****',
197
+ # refresh_token: '****'
198
+ # )
199
+ # client.v1.ranobe_topics(1) #=> [{ id: 1, ... }]
200
+ def ranobe_topics(id, headers: nil, **query)
201
+ rest.get base_url.join('ranobe', id.to_s, 'topics').url, headers: headers, query: query
202
+ end
203
+ end
204
+ end
205
+ end
206
+ end
@@ -0,0 +1,89 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Shikimori
4
+ module API
5
+ class V1
6
+ # Methods for the Reviews API
7
+ #
8
+ # @see https://shikimori.one/api/doc/1.0/reviews Shikimori's API documentation
9
+ module Reviews
10
+ # Create a anime's review
11
+ #
12
+ # @param review [Hash] Review data for creating
13
+ # @option review [String] :body Review text
14
+ # @option review [Integer] :anime_id Anime's ID
15
+ # @option review ['positive', 'neutral', 'negative'] :opinion Review's opinion
16
+ # @param frontend ['false', 'true', 1, 0] Used by shikimori frontend code. Ignore it.
17
+ # @param headers [Hash] Request headers
18
+ # @param query [Hash] Query string parameters for request
19
+ #
20
+ # @return [Hash] Hash representing created comment
21
+ #
22
+ # @see https://shikimori.one/api/doc/1.0/reviews/create Shikimori's API documentation
23
+ # @example Create a comment for topic with id equal to 1
24
+ # client = Shikimori::API::Client.new(
25
+ # app_name: 'Api Test',
26
+ # aceess_token: '****',
27
+ # refresh_token: '****'
28
+ # )
29
+ # client.v1.create_review({ body: 'Good!', anime_id: 1, opinion: 'positive' })
30
+ def create_review(review, frontend: nil, headers: nil, **query)
31
+ rest.post(
32
+ base_url.join('reviews').url,
33
+ { review: review, frontend: frontend }.compact,
34
+ headers: headers, query: query
35
+ )
36
+ end
37
+
38
+ # Update anime's review by id
39
+ #
40
+ # @param id [Hash] Review's id
41
+ # @param review [Hash] Review data for updating
42
+ # @option review [String] :body Review text
43
+ # @option review ['positive', 'neutral', 'negative'] :opinion Review's opinion
44
+ # @param frontend ['false', 'true', 1, 0] Used by shikimori frontend code. Ignore it.
45
+ # @param headers [Hash] Request headers
46
+ # @param query [Hash] Query string parameters for request
47
+ #
48
+ # @return [Hash] Hash representing updated review
49
+ #
50
+ # @see https://shikimori.one/api/doc/1.0/reviews/update Shikimori's API documentation
51
+ # @example Change review opinion
52
+ # client = Shikimori::API::Client.new(
53
+ # app_name: 'Api Test',
54
+ # aceess_token: '****',
55
+ # refresh_token: '****'
56
+ # )
57
+ #
58
+ # client.v1.update_review(1, { opinion: 'negative' })
59
+ def update_review(id, review, frontend: nil, headers: nil, **query)
60
+ rest.put(
61
+ base_url.join('reviews', id.to_s).url,
62
+ { review: review, frontend: frontend }.compact,
63
+ headers: headers, query: query
64
+ )
65
+ end
66
+
67
+ # Delete anime's review
68
+ #
69
+ # @param id [String, Integer] Review id
70
+ # @param headers [Hash] Request headers
71
+ # @param query [Hash] Query string parameters for request
72
+ #
73
+ # @return [Boolean] True if deletion successful, false otherwise.
74
+ #
75
+ # @see https://shikimori.one/api/doc/1.0/reviews/destroy
76
+ # @example Delete review with id equal to 1
77
+ # client = Shikimori::API::Client.new(
78
+ # app_name: 'Api Test',
79
+ # aceess_token: '****',
80
+ # refresh_token: '****'
81
+ # )
82
+ # client.v1.delete_review(1)
83
+ def delete_review(id, headers: nil, **query)
84
+ rest.delete base_url.join('reviews', id.to_s).url, headers: headers, query: query
85
+ end
86
+ end
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Shikimori
4
+ module API
5
+ class V1
6
+ # Methods for the Stats API
7
+ #
8
+ # @see https://shikimori.one/api/doc/1.0/stats Shikimori's API documentation
9
+ module Stats
10
+ # Get list of active users
11
+ #
12
+ # @param headers [Hash] Request headers
13
+ # @param query [Hash] Query string parameters for request
14
+ #
15
+ # @return [Array<Integer>] Array of ids of active users
16
+ #
17
+ # @see https://shikimori.one/api/doc/1.0/stats/active_users Shikimori's API documentation
18
+ # @example Get list of active users
19
+ # client = Shikimori::API::Client.new(
20
+ # app_name: 'Api Test',
21
+ # aceess_token: '****',
22
+ # refresh_token: '****'
23
+ # )
24
+ # client.v1.active_users #=> [1, 2, 3, ...]
25
+ def active_users(headers: nil, **query)
26
+ rest.get base_url.join('stats', 'active_users').url, headers: headers, query: query
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Shikimori
4
+ module API
5
+ class V1
6
+ # Methods for the Studios API
7
+ #
8
+ # @see https://shikimori.one/api/doc/1.0/studios Shikimori's API documentation
9
+ module Studios
10
+ # Get list of studios
11
+ #
12
+ # @param headers [Hash] Request headers
13
+ # @param query [Hash] Query string parameters for request
14
+ #
15
+ # @return [Array<Hash>] Array of hashes representing studios
16
+ #
17
+ # @see https://shikimori.one/api/doc/1.0/studios/index Shikimori's API documentation
18
+ # @example Get list of studios
19
+ # client = Shikimori::API::Client.new(
20
+ # app_name: 'Api Test',
21
+ # aceess_token: '****',
22
+ # refresh_token: '****'
23
+ # )
24
+ # client.v1.studios #=> [{ id: 1, ... }, ...]
25
+ def studios(headers: nil, **query)
26
+ rest.get base_url.join('studios').url, headers: headers, query: query
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end