shikimori-api 1.0.0 → 1.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 47e86dd12c49f262d518820a7c3572c8de8a73a2d7047891819a2c6be46daf83
4
- data.tar.gz: 1b2872e10096765da94493d387061870757a041405fbd54a4baf76e5da19c04b
3
+ metadata.gz: 012cbdff8dba5946e47672d2d8646bf7cfc93df8dfabb0e3e2eec95d28e49c3a
4
+ data.tar.gz: '0596c4b458a7d474727f6b006e97f1ece1875c2cf5a57a69f1c72c600079c5db'
5
5
  SHA512:
6
- metadata.gz: acfec6a1d8fdf30813debd7fe2dbf423f4c531a48e2c57c8ee43b7b243e69824de8c7a30aa40e1ec64bb48d94497725077ac84811a27f3f1d6f28cad4b589cc3
7
- data.tar.gz: d253b3dc0191aec63c8aaca69ea258c9f63cdaf5d2cc31f140d628acfbec18abf1bf65dcfb5bccccd2025373fe8f867a8723b05ee4399d0a02353fd1611b34a6
6
+ metadata.gz: 3ce0a04dfab2c91dee236bb9a2580b33293ea87f6f619ab5c1000e46709d8f8d36948b4f584af708c0573b08acf077da5b1510a2ebdc84a02210700d084cf112
7
+ data.tar.gz: 2796b2ad37e1066c50974882765a657c1c1d46e7bb0d0965fb64c100a0f0efefa769387055e1e2872671226edcd386892ca8c4efcb25fe61948b5ee69b2123ba
data/README.md CHANGED
@@ -1,20 +1,293 @@
1
- [![CI](https://github.com/iwdt/shikikit/actions/workflows/main.yml/badge.svg)](https://github.com/iwdt/shikikit/actions/workflows/main.yml) [![codecov](https://codecov.io/gh/iwdt/shikikit/graph/badge.svg)](https://codecov.io/gh/iwdt/shikikit)
2
-
3
1
  # Shikikit
4
- Ruby toolkit for the [Shikimori API](https://shikimori.one)
5
-
6
- ## TODO:
7
- - logger
8
- - #as_app
9
- - proxy config
10
- - oauth methods on API
11
- - optional auto refresh token
12
- - more information at errors
13
- - more tests
14
- - entities for responses
15
- - contracts for requests (client-side validations)
16
- - better documentation
17
- - mutator
18
- - CI/CD
19
- - auto version increment on main branch pushing
20
- - deploy to rubygems
2
+ Ruby toolkit for the [Shikimori](https://shikimori.one)
3
+
4
+ [![Shikimori Profile](https://img.shields.io/badge/shikimori_profile-gray?logo=shikimori)](https://shikimori.one/io.human) [![Codecov](https://img.shields.io/codecov/c/gh/iwdt/shikikit?logo=codecov)](https://codecov.io/gh/iwdt/shikikit) [![CI](https://img.shields.io/github/actions/workflow/status/iwdt/shikikit/main.yml?label=CI&logo=github)](https://github.com/iwdt/shikikit/actions/workflows/main.yml) [![GitHub Discussions](https://img.shields.io/github/discussions/iwdt/shikikit?logo=github)](https://github.com/iwdt/shikikit/discussions)
5
+
6
+
7
+ ## Table of Contents
8
+ 1. [API Documentation](#api-documentation)
9
+ 2. [Omniauth Strategy](#omniauth-shikimori-strategy)
10
+ 1. [Installation](#installation)
11
+ 2. [Configuration](#configuration)
12
+ 3. [Usage](#usage-examples)
13
+ 3. [OAuth2](#shikimori-oauth-2)
14
+ 1. [Installation](#installation-1)
15
+ 2. [Configuration](#configuration-1)
16
+ 3. [Usage](#usage)
17
+ 4. [API Client](#shikimori-api)
18
+ 1. [Installation](#installation-2)
19
+ 3. [Usage](#usage-1)
20
+ 5. [Supported Ruby Versions](#supported-ruby-versions)
21
+ 6. [Versioning](#versioning)
22
+ 7. [Contributing](/CONTRIBUTING.md)
23
+ 8. [Code of conduct](/CODE_OF_CONDUCT.md)
24
+ 9. [License](/LICENSE.txt)
25
+
26
+ ## API Documentation
27
+
28
+ * [Shikimori API](https://www.rubydoc.info/gems/shikimori-api)
29
+ * [Shikimori OAuth2](https://www.rubydoc.info/gems/shikimori-oauth2)
30
+ * [Omniauth Shikimori Strategy](https://www.rubydoc.info/gems/omniauth-shikimori-oauth2)
31
+
32
+ ## Omniauth Shikimori Strategy
33
+
34
+ Strategy to authenticate with Shikimori via OAuth2 in OmniAuth. To use it, you'll need to sign up for an OAuth2 Application ID and Secret on the [Shikimori OAuth Apps Page](https://shikimori.one/oauth/applications).
35
+
36
+ Shikimori's official guide to using OAuth2: https://shikimori.one/oauth
37
+
38
+ [![Gem Version](https://img.shields.io/gem/v/omniauth-shikimori-oauth2?logo=rubygems&label=RubyGems)](https://rubygems.org/gems/omniauth-shikimori-oauth2)
39
+
40
+ ### Installation
41
+
42
+ Add to your `Gemfile`:
43
+
44
+ ```ruby
45
+ gem 'omniauth-shikimori-oauth2', '~> 1.0'
46
+ ```
47
+
48
+ Then `bundle install`
49
+
50
+ ### Configuration
51
+
52
+ You can configure several options, which you pass in to the `provider` method via a `Hash`:
53
+
54
+ * `app_name`: the name of the registered OAuth application at https://shikimori.one/oauth/applications
55
+ > **⚠ WARNING!**
56
+ > This is an important option that must be specified, as otherwise your IP may be banned for further requests to Shikimori.
57
+
58
+ * `scope`: required list of access permissions you want to request from the user. Available values:
59
+ - `user_rates` - modify your list of anime and manga.
60
+ - `messages` - read your personal messages, send personal messages on your behalf.
61
+ - `comments` - comment on behalf of you.
62
+ - `topics` - create topics and reviews on your behalf.
63
+ - `content` - modify the website's database.
64
+ - `clubs` - join and leave clubs.
65
+ - `friends` - add and remove people as friends.
66
+ - `ignores` - add and remove people to ignore.
67
+
68
+ * `client_options`: optional `Hash` of client options. Available options:
69
+ - `site` - the OAuth2 provider site host. Default: `https://shikimori.one`
70
+ - `redirect_uri` - the absolute URI to the Redirection Endpoint for use in authorization grants and token exchange.
71
+ - `authorize_url` - absolute or relative URL path to the Authorization endpoint. Default: `/oauth/authorize`
72
+ - `token_url` - absolute or relative URL path to the Token endpoint. Default: `/oauth/token`
73
+ - `token_method` - HTTP method to use to request token (`:get`, `:post`, `:post_with_query_string`). Default: `:post`
74
+ - `auth_scheme` - HTTP method to use to authorize request (`:basic_auth` or `:request_body`). Default: `:basic_auth`
75
+ - `connection_opts` - `Hash` of connection options to pass to initialize `Faraday` with. Default: `{}`
76
+ - `max_redirects` - maximum number of redirects to follow. Default: `5`
77
+ - `raise_errors` - whether or not to raise an `OAuth2::Error` on responses with 400+ status codes. Default: `true`
78
+ - `logger` - which logger to use when `OAUTH_DEBUG` is enabled. Default: `::Logger.new($stdout)`
79
+
80
+ Here's an example of a possible configuration:
81
+
82
+ ```ruby
83
+ provider :shikimori, ENV['SHIKIMORI_KEY'], ENV['SHIKIMORI_KEY'],
84
+ scope: %w[user_rates messages comments topics content clubs friends ignores],
85
+ app_name: 'My awesome site',
86
+ client_options: {
87
+ site: 'https://shikimori.org',
88
+ redirect_url: 'https://my-awesome-site.example/auth/shikimori/callback',
89
+ logger: Rails.logger
90
+ }
91
+ ```
92
+
93
+ ### Usage examples
94
+ #### Rails usage
95
+ In `config/initializers/omniauth.rb`
96
+
97
+ ```ruby
98
+ Rails.application.config.middleware.use OmniAuth::Builder do
99
+ provider :shikimori, ENV['SHIKIMORI_KEY'], ENV['SHIKIMORI_KEY'],
100
+ scope: %w[user_rates comments topics],
101
+ app_name: ENV['SHIKIMORI_APP_NAME'],
102
+ client_options: {
103
+ redirect_url: 'https://my-awesome-site.example/auth/shikimori/callback',
104
+ logger: Rails.logger
105
+ }
106
+ end
107
+ ```
108
+
109
+ #### Non-rails usage
110
+ Add middleware to your rack-based application:
111
+
112
+ ```ruby
113
+ use OmniAuth::Builder do
114
+ provider :shikimori, ENV['SHIKIMORI_KEY'], ENV['SHIKIMORI_SECRET'],
115
+ scope: %w[user_rates comments topics],
116
+ app_name: ENV['SHIKIMORI_APP_NAME'],
117
+ client_options: {
118
+ redirect_url: 'https://my-awesome-site.example/auth/shikimori/callback'
119
+ }
120
+ end
121
+ ```
122
+
123
+ ## Shikimori OAuth 2
124
+
125
+ A Ruby wrapper for the [Shikimori's OAuth 2](https://shikimori.one/oauth)
126
+
127
+ [![Gem Version](https://img.shields.io/gem/v/shikimori-oauth2?logo=rubygems&label=RubyGems)](https://rubygems.org/gems/shikimori-oauth2)
128
+
129
+
130
+ ### Installation
131
+
132
+ Install via Rubygems
133
+
134
+ ```bash
135
+ gem install shikimori-oauth2
136
+ ```
137
+
138
+ ... or add to your Gemfile
139
+
140
+ ```ruby
141
+ gem 'shikimori-oauth2', '~> 1.0'
142
+ ```
143
+
144
+ Access the library in Ruby:
145
+
146
+ ```ruby
147
+ require 'shikimori-oauth2'
148
+ ```
149
+
150
+ ### Configuration
151
+
152
+ While `Shikimori::OAuth2::Client` accepts a range of options when creating a new client instance, Shikimori's configuration API allows you to set your configuration options at the module level. This is particularly handy if you're creating a number of client instances based on some shared defaults. Changing options affects new instances only and will not modify existing `Shikimori::OAuth2::Client` instances created with previous options.
153
+
154
+ Configuring module defaults
155
+
156
+ Every writable attribute in `Shikimori::OAuth2::Config` can be set in batch:
157
+
158
+ ```ruby
159
+ Shikimori::Oauth2.configure do |c|
160
+ c.site = 'https://shikimori.one/'
161
+ c.app_name = 'My awesome site'
162
+ c.options = {
163
+ redirect_uri: 'https://my-awesome-site.example/auth/shikimori/callback',
164
+ authorize_url: '/oauth/authorize',
165
+ token_url: '/oauth/token',
166
+ token_method: :post,
167
+ auth_scheme: :basic_auth,
168
+ connection_opts: {},
169
+ max_redirects: 5,
170
+ raise_errors: true,
171
+ logger: ::Logger.new($stdout),
172
+ }
173
+ end
174
+ ```
175
+
176
+ Also available global options from [OAuth2 gem](https://gitlab.com/oauth-xx/oauth2#global-configuration).
177
+
178
+ ### Usage
179
+
180
+ To get access and refresh tokens, follow this example:
181
+
182
+ ```ruby
183
+ require 'shikimori-oauth2'
184
+
185
+ client = Shikimori::OAuth2::Client.new('client_id', 'client_secret', app_name: 'Api test')
186
+ client.auth_code.authorize_url(scope: 'user_rates+comments+topics', redirect_uri: 'urn:ietf:wg:oauth:2.0:oob')
187
+ #=> https://shikimori.one/oauth/authorize?client_id=client_id&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&response_type=code&scope=user_rates+comments+topics
188
+ #=> Open this link at browser and copy code
189
+
190
+ access = client.auth_code.get_token('authorization_code_value', redirect_uri: 'urn:ietf:wg:oauth:2.0:oob')
191
+
192
+ access.token #=> Access token
193
+ access.refresh_token #=> Refresh token
194
+ access.expires_in #=> 86400
195
+ access.expires_at #=> 1708887613
196
+ ```
197
+
198
+ ## Shikimori API
199
+
200
+ Simple wrapper for the Shikimori API
201
+
202
+ [![Gem Version](https://img.shields.io/gem/v/shikimori-api?logo=rubygems&label=RubyGems)](https://rubygems.org/gems/shikimori-api)
203
+
204
+ ### Installation
205
+
206
+ Install via Rubygems
207
+
208
+ ```bash
209
+ gem install shikimori-api
210
+ ```
211
+
212
+ ... or add to your Gemfile
213
+
214
+ ```ruby
215
+ gem 'shikimori-api', '~> 1.0'
216
+ ```
217
+
218
+ Access the library in Ruby:
219
+
220
+ ```ruby
221
+ require 'shikimori-api'
222
+ ```
223
+
224
+ ### Usage
225
+
226
+ API methods are accessible as instance methods of the `Shikimori::API::Client`. Documentation is available at RubyDoc.info:
227
+ * [V1 methods](https://www.rubydoc.info/gems/shikimori-api/Shikimori/API/V1)
228
+ * [V2 methods](https://www.rubydoc.info/gems/shikimori-api/Shikimori/API/V2)
229
+
230
+ ### Examples
231
+
232
+ Basic example to get 10 random anime titles released in the 90s
233
+
234
+ ```ruby
235
+ client = Shikimori::API::Client.new
236
+ client.v1.animes(limit: 10, order: 'random', season: '199x') # call /api/animes
237
+ ```
238
+
239
+ To provide authentication credentials, you can pass them as arguments during client initialization:
240
+
241
+ ```ruby
242
+ access_token = 'access_token' #=> User's access token
243
+ refresh_token = 'refresh_token' #=> User's refresh token
244
+ oauth_app_name = 'Api Test' #=> OAuth2 application name
245
+
246
+ client = Shikimori::API::Client.new(app_name: oauth_app_name, access_token: access_token, refresh_token: refresh_token)
247
+ client.v1.whoami
248
+ ```
249
+
250
+ For passing additional query parameters to request use the following syntax:
251
+
252
+ ```ruby
253
+ client.v1.animes(limit: 10, page: 2, another_param: 'Param')
254
+ client.v1.anime_videos(anime_id, first_param: 1, second_param: 2)
255
+ ```
256
+
257
+ ... and for request headers use the following syntax:
258
+
259
+ ```ruby
260
+ client.v1.animes(headers: { 'X-Header-Name' => 'My header value' })
261
+ ```
262
+
263
+ For configuring a connection through proxy, you can pass `proxy_host`, `proxy_port`, `proxy_user` and `proxy_password` as arguments during client initialization:
264
+
265
+ ```ruby
266
+ client = Shikimori::API::Client.new(proxy_host: 'http://my-proxy', proxy_port: 8080, proxy_user: 'my_proxy_user', proxy_password: 'my_proxy_password')
267
+ ```
268
+
269
+ You can also using client as application:
270
+
271
+ ```ruby
272
+ Shikimori::API::Client.as_app(access_token: 'access-token') do |client|
273
+ animes = client.animes
274
+ mangas = client.mangas
275
+ # some logic ...
276
+ end
277
+ ```
278
+
279
+ ## Supported Ruby Versions
280
+ This library aims to support and is tested against the following Ruby implementations:
281
+ * Ruby 3.0
282
+ * Ruby 3.1
283
+ * Ruby 3.2
284
+ * Ruby 3.3
285
+
286
+ If something doesn't work on one of these Ruby versions, it's a bug.
287
+
288
+ This library may inadvertently work (or seem to work) on other Ruby implementations, but support will only be provided for the versions listed above.
289
+
290
+ If you would like this library to support another Ruby version, you may volunteer to be a maintainer. Being a maintainer entails making sure all tests run and pass on that implementation. When something breaks on your implementation, you will be responsible for providing patches in a timely fashion. If critical issues for a particular implementation exist at the time of a major release, support for that Ruby version may be dropped.
291
+
292
+ ## Versioning
293
+ This library aims to adhere to [Semantic Versioning 2.0.0](http://semver.org/). Violations of this scheme should be reported as bugs. Specifically, if a minor or patch version is released that breaks backward compatibility, that version should be immediately yanked and/or a new version should be immediately released that restores compatibility. Breaking changes to the public API will only be introduced with new major versions. As a result of this policy, you can (and should) specify a dependency on this gem using the Pessimistic Version Constraint with two digits of precision.
@@ -14,20 +14,42 @@ module Shikimori
14
14
 
15
15
  attr_reader :v1, :v2
16
16
 
17
- def initialize(site = DEFAULT_SITE_URL, app_name:, access_token:, refresh_token:)
18
- rest = REST.new(
19
- access_token: access_token,
20
- refresh_token: refresh_token,
21
- app_name: app_name
22
- )
23
- @v1 = V1.new(
24
- base_url: URI.new(site).join('api/'),
25
- rest: rest
26
- )
27
- @v2 = V2.new(
28
- base_url: URI.new(site).join('api/v2/'),
29
- rest: rest
30
- )
17
+ # Initialize a Shikimori's API Client
18
+ #
19
+ # @param site [String] Shikimori's base url
20
+ # @param options [Hash] Additional options to making requests to shikimori
21
+ # @option options [String] :app_name OAuth2 application name
22
+ # @option options [String] :access_token User's access token from OAuth2
23
+ # @option options [String] :refresh_token User's refresh token from OAuth2
24
+ # @option options [String] :proxy_host Proxy hostname
25
+ # @option options [Integer] :proxy_port Proxy port
26
+ # @option options [String] :proxy_user Proxy username
27
+ # @option options [String] :proxy_password Proxy password
28
+ def initialize(site = DEFAULT_SITE_URL, **options)
29
+ rest = REST.new(**options)
30
+ base_uri = URI.new(site)
31
+
32
+ @v1 = V1.new(base_url: base_uri.join('api/'), rest: rest)
33
+ @v2 = V2.new(base_url: base_uri.join('api/v2/'), rest: rest)
34
+ end
35
+
36
+ # Using shikimori client as application
37
+ #
38
+ # @yield [Client] client instance
39
+ # @example Usage example
40
+ # Shikimori::API::Client.as_app(access_token: 'my-access-token') do |client|
41
+ # animes = client.v1.animes
42
+ # mangas = client.v1.mangas
43
+ # # some logic ...
44
+ # end
45
+ #
46
+ # @see #initialize
47
+ def self.as_app(site = DEFAULT_SITE_URL, **options)
48
+ client = new(site, **options)
49
+
50
+ yield client
51
+
52
+ client
31
53
  end
32
54
  end
33
55
  end
@@ -3,19 +3,8 @@
3
3
  module Shikimori
4
4
  module API
5
5
  class RequestError < StandardError; end
6
-
7
6
  class NotFoundError < RequestError; end
8
7
  class ForbiddenError < RequestError; end
9
-
10
- # Error, when request is bad
11
- class BadRequestError < RequestError
12
- attr_reader :errors
13
-
14
- def initialize(errors)
15
- @errors = errors.is_a?(Hash) ? errors['errors'] : errors
16
-
17
- super("Bad request. Errors:\n\t#{@errors.join("\n\t")}")
18
- end
19
- end
8
+ class BadRequestError < RequestError; end
20
9
  end
21
10
  end
@@ -4,10 +4,14 @@ module Shikimori
4
4
  module API
5
5
  # Helpers to make requests
6
6
  class REST
7
- def initialize(app_name:, access_token:, refresh_token:)
7
+ def initialize(app_name: nil, access_token: nil, refresh_token: nil, **options)
8
8
  @app_name = app_name
9
9
  @access_token = access_token
10
10
  @refresh_token = refresh_token
11
+ @proxy_host = options.fetch(:proxy_host, nil)
12
+ @proxy_port = options.fetch(:proxy_port, nil)
13
+ @proxy_user = options.fetch(:proxy_user, nil)
14
+ @proxy_password = options.fetch(:proxy_password, nil)
11
15
  end
12
16
 
13
17
  def get(uri, **options)
@@ -67,7 +71,7 @@ module Shikimori
67
71
 
68
72
  Net::HTTP.start(
69
73
  uri.hostname.to_s, uri.port,
70
- :ENV, nil, nil, nil,
74
+ @proxy_host, @proxy_port, @proxy_user, @proxy_password,
71
75
  use_ssl: uri.scheme == 'https'
72
76
  ) do |http|
73
77
  http.request(request)
@@ -76,8 +80,6 @@ module Shikimori
76
80
 
77
81
  def parse_response(response)
78
82
  case response
79
- when Net::HTTPNoContent
80
- {}
81
83
  when Net::HTTPSuccess, Net::HTTPCreated
82
84
  json_parse_response_body(response.body)
83
85
  when Net::HTTPForbidden
@@ -85,12 +87,22 @@ module Shikimori
85
87
  when Net::HTTPNotFound
86
88
  raise NotFoundError
87
89
  when Net::HTTPUnprocessableEntity, Net::HTTPBadRequest
88
- raise BadRequestError, json_parse_response_body(response.body)
90
+ raise BadRequestError, json_parse_response_errors(response.body)
91
+ end
92
+ end
93
+
94
+ def json_parse_response_errors(body)
95
+ error = json_parse_response_body(body)
96
+
97
+ if error.is_a?(Array)
98
+ error.join(', ')
99
+ elsif error.is_a?(Hash) && error.key?('errors')
100
+ error['errors']
89
101
  end
90
102
  end
91
103
 
92
104
  def json_parse_response_body(body)
93
- JSON.parse(body&.empty? ? '{}' : body)
105
+ JSON.parse(body.nil? || body.empty? ? '{}' : body)
94
106
  rescue JSON::ParserError
95
107
  {}
96
108
  end
@@ -100,7 +112,7 @@ module Shikimori
100
112
  'Content-Type' => 'application/json',
101
113
  'Authorization' => "Bearer #{@access_token}",
102
114
  'User-Agent' => @app_name
103
- )
115
+ ).compact
104
116
  end
105
117
 
106
118
  def query_params_from(uri, options)
@@ -16,7 +16,7 @@ module Shikimori
16
16
  #
17
17
  # @return [Array<Hash>] Array of hashes representing people
18
18
  #
19
- # @see https://shikimori.one/api/doc/1.0/people/index Shikimori's API documentation
19
+ # @see https://shikimori.one/api/doc/1.0/people/search Shikimori's API documentation
20
20
  # @example Search a Hayao Miyazaki at mangakas list
21
21
  # client = Shikimori::API::Client.new(
22
22
  # app_name: 'Api Test',
@@ -3,6 +3,6 @@
3
3
  module Shikimori
4
4
  module API
5
5
  # @return [String] Semantic version of library
6
- VERSION = '1.0.0'
6
+ VERSION = '1.0.2'
7
7
  end
8
8
  end
@@ -14,11 +14,9 @@ Gem::Specification.new do |spec|
14
14
  spec.license = 'MIT'
15
15
  spec.required_ruby_version = '>= 3.0'
16
16
 
17
- spec.metadata['homepage_uri'] = spec.homepage
18
17
  spec.metadata['allowed_push_host'] = 'https://rubygems.org'
19
18
  spec.metadata['source_code_uri'] = 'https://github.com/iwdt/shikikit'
20
19
  spec.metadata['bug_tracker_uri'] = 'https://github.com/iwdt/shikikit/issues'
21
- spec.metadata['changelog_uri'] = 'https://github.com/iwdt/shikikit/blob/main/CHANGELOG.md'
22
20
  spec.metadata['rubygems_mfa_required'] = 'true'
23
21
 
24
22
  spec.files = Dir[
@@ -6,7 +6,9 @@ module Shikimori
6
6
  attr_reader v1: V1
7
7
  attr_reader v2: V2
8
8
 
9
- def initialize: (?String site, app_name: String, access_token: String, refresh_token: String) -> void
9
+ def initialize: (?String site, **untyped) -> void
10
+
11
+ def self.as_app: (?String site, **untyped) { (Shikimori::API::Client) -> void } -> Shikimori::API::Client
10
12
  end
11
13
  end
12
14
  end
@@ -5,24 +5,29 @@ module Shikimori
5
5
  type request = Net::HTTP::Delete | Net::HTTP::Get | Net::HTTP::Post | Net::HTTP::Put
6
6
  type body = Hash[_ToS, Object] | nil
7
7
 
8
- @app_name: String
9
- @access_token: String
10
- @refresh_token: String
8
+ @app_name: String | nil
9
+ @access_token: String | nil
10
+ @refresh_token: String | nil
11
+ @proxy_host: String | :ENV | nil
12
+ @proxy_port: Integer | nil
13
+ @proxy_user: String | nil
14
+ @proxy_password: String | nil
11
15
 
12
- def initialize: (app_name: String, access_token: String, refresh_token: String) -> void
16
+ def initialize: (?app_name: String | nil, ?access_token: String | nil, ?refresh_token: String | nil, **untyped) -> void
13
17
 
14
18
  def get: (::URI::Generic, **untyped) -> untyped
15
19
  def post: (::URI::Generic, Hash[_ToS, untyped] data, **untyped) -> untyped
16
- def put: (::URI::Generic, Hash[_ToS, Object] data, **untyped) -> untyped
20
+ def put: (::URI::Generic, Hash[_ToS, untyped] data, **untyped) -> untyped
17
21
  def delete: (::URI::Generic, **untyped) -> bool
18
22
 
19
23
  private
20
24
 
21
- def request: (request_method, ::URI::Generic, ?body, **untyped) -> [Net::HTTPResponse, (::Hash[_ToS, Object] | nil)]
25
+ def request: (request_method, ::URI::Generic, ?body, **untyped) -> [Net::HTTPResponse, (::Hash[_ToS, Object] | nil | Array[untyped])]
22
26
  def build_request: (request_method, ::URI::Generic, **untyped) -> request
23
27
  def start_request: (::URI::Generic, request, ?body, **untyped) -> Net::HTTPResponse
24
- def parse_response: (Net::HTTPResponse response) -> (::Hash[_ToS, untyped] | nil)
25
- def json_parse_response_body: (String) -> (::Hash[_ToS, untyped] | nil)
28
+ def parse_response: (Net::HTTPResponse response) -> (::Hash[_ToS, untyped] | Array[untyped] | nil)
29
+ def json_parse_response_errors: (String) -> (String | nil)
30
+ def json_parse_response_body: (String) -> (::Hash[_ToS, untyped] | Array[untyped] | nil)
26
31
  def headers_from: (Hash[untyped, untyped]) -> Hash[String, String]
27
32
  def query_params_from: (::URI::Generic, Hash[untyped, untyped]) -> untyped
28
33
  end
@@ -10,9 +10,6 @@ module Shikimori
10
10
  end
11
11
 
12
12
  class BadRequestError < RequestError
13
- attr_reader errors: Array[String]
14
-
15
- def initialize: (Array[String] | { "errors" => Array[String] }) -> void
16
13
  end
17
14
  end
18
15
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shikimori-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Naumov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-22 00:00:00.000000000 Z
11
+ date: 2025-08-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Ruby toolkit for working with the Shikimori API
14
14
  email:
@@ -109,11 +109,9 @@ homepage: https://github.com/iwdt/shikikit
109
109
  licenses:
110
110
  - MIT
111
111
  metadata:
112
- homepage_uri: https://github.com/iwdt/shikikit
113
112
  allowed_push_host: https://rubygems.org
114
113
  source_code_uri: https://github.com/iwdt/shikikit
115
114
  bug_tracker_uri: https://github.com/iwdt/shikikit/issues
116
- changelog_uri: https://github.com/iwdt/shikikit/blob/main/CHANGELOG.md
117
115
  rubygems_mfa_required: 'true'
118
116
  post_install_message:
119
117
  rdoc_options: []
@@ -130,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
128
  - !ruby/object:Gem::Version
131
129
  version: '0'
132
130
  requirements: []
133
- rubygems_version: 3.0.3.1
131
+ rubygems_version: 3.2.33
134
132
  signing_key:
135
133
  specification_version: 4
136
134
  summary: Simple wrapper for the Shikimori API