my_api_client 0.22.0 → 0.23.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.
data/Gemfile CHANGED
@@ -4,8 +4,6 @@ source 'https://rubygems.org'
4
4
 
5
5
  git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
6
 
7
- gem 'activesupport', '~> 6.1' # TODO: Remove this line at the end of Ruby 2.6 support
8
-
9
7
  group :integrations, optional: true do
10
8
  gem 'bugsnag', '>= 6.11.0'
11
9
  end
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- my_api_client (0.22.0)
4
+ my_api_client (0.23.0)
5
5
  activesupport (>= 5.2.0)
6
6
  faraday (>= 0.17.1)
7
7
  jsonpath
@@ -10,54 +10,37 @@ PATH
10
10
  GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
- activesupport (6.1.4.4)
13
+ activesupport (7.0.3)
14
14
  concurrent-ruby (~> 1.0, >= 1.0.2)
15
15
  i18n (>= 1.6, < 2)
16
16
  minitest (>= 5.1)
17
17
  tzinfo (~> 2.0)
18
- zeitwerk (~> 2.3)
19
18
  addressable (2.8.0)
20
19
  public_suffix (>= 2.0.2, < 5.0)
21
20
  ast (2.4.2)
22
- bugsnag (6.24.1)
21
+ bugsnag (6.24.2)
23
22
  concurrent-ruby (~> 1.0)
24
23
  byebug (11.1.3)
25
24
  coderay (1.1.3)
26
- concurrent-ruby (1.1.9)
25
+ concurrent-ruby (1.1.10)
27
26
  crack (0.4.5)
28
27
  rexml
29
28
  diff-lcs (1.5.0)
30
29
  docile (1.4.0)
31
- faraday (1.8.0)
32
- faraday-em_http (~> 1.0)
33
- faraday-em_synchrony (~> 1.0)
34
- faraday-excon (~> 1.1)
35
- faraday-httpclient (~> 1.0.1)
36
- faraday-net_http (~> 1.0)
37
- faraday-net_http_persistent (~> 1.1)
38
- faraday-patron (~> 1.0)
39
- faraday-rack (~> 1.0)
40
- multipart-post (>= 1.2, < 3)
30
+ faraday (2.3.0)
31
+ faraday-net_http (~> 2.0)
41
32
  ruby2_keywords (>= 0.0.4)
42
- faraday-em_http (1.0.0)
43
- faraday-em_synchrony (1.0.0)
44
- faraday-excon (1.1.0)
45
- faraday-httpclient (1.0.1)
46
- faraday-net_http (1.0.1)
47
- faraday-net_http_persistent (1.2.0)
48
- faraday-patron (1.0.0)
49
- faraday-rack (1.0.0)
33
+ faraday-net_http (2.0.3)
50
34
  hashdiff (1.0.1)
51
- i18n (1.8.11)
35
+ i18n (1.10.0)
52
36
  concurrent-ruby (~> 1.0)
53
- jsonpath (1.1.0)
37
+ jsonpath (1.1.2)
54
38
  multi_json
55
39
  method_source (1.0.0)
56
40
  minitest (5.15.0)
57
41
  multi_json (1.15.0)
58
- multipart-post (2.1.1)
59
- parallel (1.21.0)
60
- parser (3.0.3.2)
42
+ parallel (1.22.1)
43
+ parser (3.1.2.0)
61
44
  ast (~> 2.4.1)
62
45
  pry (0.13.1)
63
46
  coderay (~> 1.1)
@@ -65,53 +48,53 @@ GEM
65
48
  pry-byebug (3.9.0)
66
49
  byebug (~> 11.0)
67
50
  pry (~> 0.13.0)
68
- public_suffix (4.0.6)
69
- rainbow (3.0.0)
51
+ public_suffix (4.0.7)
52
+ rainbow (3.1.1)
70
53
  rake (13.0.6)
71
- regexp_parser (2.2.0)
54
+ regexp_parser (2.5.0)
72
55
  rexml (3.2.5)
73
- rspec (3.10.0)
74
- rspec-core (~> 3.10.0)
75
- rspec-expectations (~> 3.10.0)
76
- rspec-mocks (~> 3.10.0)
77
- rspec-core (3.10.1)
78
- rspec-support (~> 3.10.0)
79
- rspec-expectations (3.10.1)
56
+ rspec (3.11.0)
57
+ rspec-core (~> 3.11.0)
58
+ rspec-expectations (~> 3.11.0)
59
+ rspec-mocks (~> 3.11.0)
60
+ rspec-core (3.11.0)
61
+ rspec-support (~> 3.11.0)
62
+ rspec-expectations (3.11.0)
80
63
  diff-lcs (>= 1.2.0, < 2.0)
81
- rspec-support (~> 3.10.0)
82
- rspec-mocks (3.10.2)
64
+ rspec-support (~> 3.11.0)
65
+ rspec-mocks (3.11.1)
83
66
  diff-lcs (>= 1.2.0, < 2.0)
84
- rspec-support (~> 3.10.0)
85
- rspec-support (3.10.3)
86
- rspec_junit_formatter (0.4.1)
67
+ rspec-support (~> 3.11.0)
68
+ rspec-support (3.11.0)
69
+ rspec_junit_formatter (0.5.1)
87
70
  rspec-core (>= 2, < 4, != 2.12.0)
88
- rubocop (1.24.0)
71
+ rubocop (1.30.1)
89
72
  parallel (~> 1.10)
90
- parser (>= 3.0.0.0)
73
+ parser (>= 3.1.0.0)
91
74
  rainbow (>= 2.2.2, < 4.0)
92
75
  regexp_parser (>= 1.8, < 3.0)
93
- rexml
94
- rubocop-ast (>= 1.15.0, < 2.0)
76
+ rexml (>= 3.2.5, < 4.0)
77
+ rubocop-ast (>= 1.18.0, < 2.0)
95
78
  ruby-progressbar (~> 1.7)
96
79
  unicode-display_width (>= 1.4.0, < 3.0)
97
- rubocop-ast (1.15.0)
98
- parser (>= 3.0.1.1)
99
- rubocop-performance (1.13.0)
80
+ rubocop-ast (1.18.0)
81
+ parser (>= 3.1.1.0)
82
+ rubocop-performance (1.14.2)
100
83
  rubocop (>= 1.7.0, < 2.0)
101
84
  rubocop-ast (>= 0.4.0)
102
- rubocop-rspec (2.6.0)
85
+ rubocop-rspec (2.11.1)
103
86
  rubocop (~> 1.19)
104
87
  ruby-progressbar (1.11.0)
105
88
  ruby2_keywords (0.0.5)
106
- sawyer (0.8.2)
89
+ sawyer (0.9.2)
107
90
  addressable (>= 2.3.5)
108
- faraday (> 0.8, < 2.0)
91
+ faraday (>= 0.17.3, < 3)
109
92
  simplecov (0.21.2)
110
93
  docile (~> 1.1)
111
94
  simplecov-html (~> 0.11)
112
95
  simplecov_json_formatter (~> 0.1)
113
96
  simplecov-html (0.12.3)
114
- simplecov_json_formatter (0.1.3)
97
+ simplecov_json_formatter (0.1.4)
115
98
  tzinfo (2.0.4)
116
99
  concurrent-ruby (~> 1.0)
117
100
  unicode-display_width (2.1.0)
@@ -120,15 +103,13 @@ GEM
120
103
  crack (>= 0.3.2)
121
104
  hashdiff (>= 0.4.0, < 2.0.0)
122
105
  webrick (1.7.0)
123
- yard (0.9.27)
106
+ yard (0.9.28)
124
107
  webrick (~> 1.7.0)
125
- zeitwerk (2.5.1)
126
108
 
127
109
  PLATFORMS
128
110
  ruby
129
111
 
130
112
  DEPENDENCIES
131
- activesupport (~> 6.1)
132
113
  bugsnag (>= 6.11.0)
133
114
  bundler (>= 2.0)
134
115
  my_api_client!
@@ -144,4 +125,4 @@ DEPENDENCIES
144
125
  yard
145
126
 
146
127
  BUNDLED WITH
147
- 2.2.22
128
+ 2.3.11
data/README.jp.md CHANGED
@@ -12,8 +12,8 @@ MyApiClient は API リクエストクラスを作成するための汎用的な
12
12
 
13
13
  ## Supported Versions
14
14
 
15
- * Ruby 2.6, 2.7, 3.0
16
- * Rails 5.2, 6.0, 6.1, 7.0
15
+ - Ruby 2.7, 3.0, 3.1
16
+ - Rails 5.2, 6.0, 6.1, 7.0
17
17
 
18
18
  ## Installation
19
19
 
@@ -116,7 +116,7 @@ end
116
116
  {
117
117
  "links": {
118
118
  "next": "https://example.com/pagination?page=3",
119
- "previous": "https://example.com/pagination?page=1",
119
+ "previous": "https://example.com/pagination?page=1"
120
120
  },
121
121
  "page": 2
122
122
  }
@@ -200,7 +200,7 @@ error_handling status_code: 500..599, raise: MyApiClient::ServerError do |_param
200
200
  end
201
201
  ```
202
202
 
203
- 上記の例であれば、ステータスコードが `500..599` の場合に `MyApiClient::ServerError` を発生させる前に `block` の内容が実行れます。引数の `params` にはリクエスト情報とレスポンス情報が含まれています。`logger` はログ出力用インスタンスですが、このインスタンスを使ってログ出力すると、以下のようにリクエスト情報がログ出力に含まれるようになり、デバッグの際に便利です。
203
+ 上記の例であれば、ステータスコードが `500..599` の場合に `MyApiClient::ServerError` を発生させる前に `block` の内容が実行れます。引数の `params` にはリクエスト情報とレスポンス情報が含まれています。`logger` はログ出力用インスタンスですが、このインスタンスを使ってログ出力すると、以下のようにリクエスト情報がログ出力に含まれるようになり、デバッグの際に便利です。
204
204
 
205
205
  ```text
206
206
  API request `GET https://example.com/path/to/resouce`: "Server error occurred."
@@ -214,10 +214,10 @@ error_handling json: { '$.errors.code': 10..19 }, with: :my_error_handling
214
214
 
215
215
  ```json
216
216
  {
217
- "erros": {
218
- "code": 10,
219
- "message": "Some error has occurred."
220
- }
217
+ "erros": {
218
+ "code": 10,
219
+ "message": "Some error has occurred."
220
+ }
221
221
  }
222
222
  ```
223
223
 
@@ -253,10 +253,10 @@ error_handling json: { '$.errors.code': :negative? }
253
253
 
254
254
  ```json
255
255
  {
256
- "erros": {
257
- "code": -1,
258
- "message": "Some error has occurred."
259
- }
256
+ "erros": {
257
+ "code": -1,
258
+ "message": "Some error has occurred."
259
+ }
260
260
  }
261
261
  ```
262
262
 
@@ -344,8 +344,8 @@ error_handling json: { '$.errors.code': 20 },
344
344
 
345
345
  `retry` オプションを使用する際は以下の点に注意が必要です。
346
346
 
347
- * `error_handling` に `raise` オプションの指定が必須となります。
348
- * Block を使った `error_handling` の定義は禁止されます。
347
+ - `error_handling` に `raise` オプションの指定が必須となります。
348
+ - Block を使った `error_handling` の定義は禁止されます。
349
349
 
350
350
  #### MyApiClient::NetworkError
351
351
 
@@ -654,7 +654,7 @@ end
654
654
 
655
655
  #### `pageable` option
656
656
 
657
- `#pageable_get` (`#pget`) を使った実装用に `pageable` というオプションが利用できます。
657
+ `#pageable_get` (`#pget`) を使った実装用に `pageable` というオプションが利用できます。
658
658
  `pageable` に設定する値は `Enumerable` である必要があります。
659
659
 
660
660
  ```ruby
@@ -692,7 +692,6 @@ stub_api_client_all(
692
692
 
693
693
  また、 `Enumerator` を使えば無限に続くページネーションを定義することもできます。
694
694
 
695
-
696
695
  ```ruby
697
696
  stub_api_client_all(
698
697
  MyPaginationApiClient,
@@ -742,10 +741,10 @@ $ gem_comet release {VERSION}
742
741
 
743
742
  実行すると、 https://github.com/ryz310/my_api_client/pulls に以下のような PR が作成されます。
744
743
 
745
- * [Update v0\.16\.1](https://github.com/ryz310/my_api_client/pull/297)
746
- * [Release v0\.16\.1](https://github.com/ryz310/my_api_client/pull/298)
744
+ - [Update v0\.16\.1](https://github.com/ryz310/my_api_client/pull/297)
745
+ - [Release v0\.16\.1](https://github.com/ryz310/my_api_client/pull/298)
747
746
 
748
- まず、 `Update v{VERSION}` という PR から merge に取り掛かります。
747
+ まず、 `Update v{VERSION}` という PR から merge に取り掛かります。
749
748
 
750
749
  PR のコメントにも TODO が記載されていますが、まず、バージョン番号が正しく採番されているかを確認します。
751
750
 
@@ -755,12 +754,12 @@ See: [314a4c0](https://github.com/ryz310/my_api_client/pull/297/commits/314a4c06
755
754
 
756
755
  See: [33a2d17](https://github.com/ryz310/my_api_client/pull/297/commits/33a2d1703c773813c837e74ee3181906b2f2e502)
757
756
 
758
- これらが整ったら、 `Update v{VERSION}` を merge します。
757
+ これらが整ったら、 `Update v{VERSION}` を merge します。
759
758
 
760
- これでリリース準備が整ったので、`Release v{VERSION}` の merge に取り掛かります。
759
+ これでリリース準備が整ったので、`Release v{VERSION}` の merge に取り掛かります。
761
760
 
762
761
  この PR にこれからリリースする gem に対する変更が全て載っています。
763
- 変更内容の最終確認をして、 CI も通ったことを確認したら `Release v{VERSION}` を merge します。
762
+ 変更内容の最終確認をして、 CI も通ったことを確認したら `Release v{VERSION}` を merge します。
764
763
 
765
764
  あとは Circle CI 側で gem のリリースが自動実行されるので、暫く待ちましょう。
766
765
 
data/README.md CHANGED
@@ -12,8 +12,8 @@ It is supposed to be used in Ruby on Rails, but it is made to work in other envi
12
12
 
13
13
  ## Supported Versions
14
14
 
15
- * Ruby 2.6, 2.7, 3.0
16
- * Rails 5.2, 6.0, 6.1, 7.0
15
+ - Ruby 2.7, 3.0, 3.1
16
+ - Rails 5.2, 6.0, 6.1, 7.0
17
17
 
18
18
  ## Installation
19
19
 
@@ -83,7 +83,7 @@ The `endpoint` defines the intersection of the request URL. Each method describe
83
83
 
84
84
  Next, define `#initialize`. Suppose you want to set an Access Token, API Key, etc. as in the example above. You can omit the definition if you don't need it.
85
85
 
86
- Then define `# get_users` and` # post_user`. It's a good idea to give the method name the title of the API. I'm calling `# get` and` # post` inside the method, which is the HTTP Method at the time of the request. You can also use `#patch`` #put` `#delete`.
86
+ Then define `#get_users` and `#post_user`. It's a good idea to give the method name the title of the API. I'm calling `#get` and `#post` inside the method, which is the HTTP Method at the time of the request. You can also use `#patch` `#put` `#delete`.
87
87
 
88
88
  ### Pagination
89
89
 
@@ -116,7 +116,7 @@ For example, in the following response, `$.link.next` indicates `"https://exampl
116
116
  {
117
117
  "links": {
118
118
  "next": "https://example.com/pagination?page=3",
119
- "previous": "https://example.com/pagination?page=1",
119
+ "previous": "https://example.com/pagination?page=1"
120
120
  },
121
121
  "page": 2
122
122
  }
@@ -216,10 +216,10 @@ In the above case, it matches JSON as below:
216
216
 
217
217
  ```json
218
218
  {
219
- "erros": {
220
- "code": 10,
221
- "message": "Some error has occurred."
222
- }
219
+ "erros": {
220
+ "code": 10,
221
+ "message": "Some error has occurred."
222
+ }
223
223
  }
224
224
  ```
225
225
 
@@ -335,8 +335,8 @@ error_handling json: { '$.errors.code': 20 },
335
335
 
336
336
  Keep the following in mind when using the `retry` option:
337
337
 
338
- * The `raise` option must be specified for `error_handling`
339
- * Definition of `error_handling` using `block` is prohibited
338
+ - The `raise` option must be specified for `error_handling`
339
+ - Definition of `error_handling` using `block` is prohibited
340
340
 
341
341
  #### MyApiClient::NetworkError
342
342
 
@@ -405,7 +405,6 @@ class ExampleApiClient < MyApiClient::Base
405
405
  end
406
406
  ```
407
407
 
408
-
409
408
  WIP
410
409
 
411
410
  ### Stubbing
@@ -4,7 +4,7 @@ require_relative 'my_errors'
4
4
 
5
5
  # An usage example of the `my_api_client`.
6
6
  class ApplicationApiClient < MyApiClient::Base
7
- endpoint ENV['MY_API_ENDPOINT']
7
+ endpoint ENV.fetch('MY_API_ENDPOINT', nil)
8
8
 
9
9
  self.logger = ::Logger.new(nil)
10
10
 
@@ -21,9 +21,9 @@ module MyApiClient
21
21
  # The request and response parameters
22
22
  # @param original_error [StandardError]
23
23
  # Some network error
24
- def initialize(params, original_error)
24
+ def initialize(params = nil, original_error = nil)
25
25
  @original_error = original_error
26
- super params, original_error.message
26
+ super params, original_error&.message
27
27
  end
28
28
 
29
29
  # Returns contents as string for to be readable for human
@@ -37,7 +37,7 @@ module MyApiClient
37
37
  #
38
38
  # @return [Hash] Metadata for bugsnag
39
39
  def metadata
40
- super.merge(original_error: original_error.inspect)
40
+ super&.merge(original_error: original_error&.inspect)
41
41
  end
42
42
  end
43
43
  end
@@ -5,7 +5,7 @@ module MyApiClient
5
5
  class Error < StandardError
6
6
  attr_reader :params
7
7
 
8
- delegate :metadata, to: :params
8
+ delegate :metadata, to: :params, allow_nil: true
9
9
  alias to_bugsnag metadata
10
10
 
11
11
  # Initialize the error class
@@ -14,7 +14,7 @@ module MyApiClient
14
14
  # The request and response parameters
15
15
  # @param error_message [String]
16
16
  # The error description
17
- def initialize(params, error_message = nil)
17
+ def initialize(params = nil, error_message = nil)
18
18
  @params = params
19
19
  super error_message
20
20
  end
@@ -6,12 +6,12 @@ module MyApiClient
6
6
  alias _original_initialize initialize
7
7
 
8
8
  # Override MyApiClient::Error#initialize
9
- def initialize(params, error_message = nil)
9
+ def initialize(params = nil, error_message = nil)
10
10
  _original_initialize(params, error_message)
11
11
 
12
12
  Bugsnag.leave_breadcrumb(
13
13
  "#{self.class.name} occurred",
14
- metadata.transform_values(&:inspect),
14
+ metadata&.transform_values(&:inspect),
15
15
  Bugsnag::Breadcrumbs::ERROR_BREADCRUMB_TYPE
16
16
  )
17
17
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MyApiClient
4
- VERSION = '0.22.0'
4
+ VERSION = '0.23.0'
5
5
  end
data/my_api/Gemfile CHANGED
@@ -7,7 +7,7 @@ gem 'jets'
7
7
  gem 'dynomite'
8
8
 
9
9
  # See: https://github.com/boltops-tools/jets/issues/523
10
- gem 'nokogiri', '~> 1.12.5'
10
+ gem 'nokogiri', '~> 1.13.6'
11
11
 
12
12
  # development and test groups are not bundled as part of the deployment
13
13
  group :development, :test do