my_api_client 1.0.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +6 -6
  3. data/.rubocop.yml +4 -3
  4. data/.ruby-version +1 -0
  5. data/CHANGELOG.md +58 -0
  6. data/Gemfile.lock +66 -65
  7. data/README.jp.md +2 -2
  8. data/README.md +2 -2
  9. data/example/api_clients/my_error_api_client.rb +1 -1
  10. data/example/api_clients/my_header_api_client.rb +1 -1
  11. data/example/api_clients/my_pagination_api_client.rb +2 -2
  12. data/example/api_clients/my_rest_api_client.rb +10 -10
  13. data/example/api_clients/my_status_api_client.rb +1 -1
  14. data/gemfiles/rails_7.1.gemfile +15 -0
  15. data/gemfiles/rails_7.2.gemfile +15 -0
  16. data/lib/my_api_client/error_handling/generator.rb +1 -1
  17. data/lib/my_api_client/error_handling.rb +1 -1
  18. data/lib/my_api_client/errors/network_error.rb +1 -1
  19. data/lib/my_api_client/errors.rb +1 -1
  20. data/lib/my_api_client/exceptions.rb +12 -1
  21. data/lib/my_api_client/params/params.rb +1 -1
  22. data/lib/my_api_client/params/request.rb +8 -8
  23. data/lib/my_api_client/request/basic.rb +2 -2
  24. data/lib/my_api_client/request/executor.rb +1 -1
  25. data/lib/my_api_client/request/pagination.rb +1 -3
  26. data/lib/my_api_client/request.rb +5 -5
  27. data/lib/my_api_client/rspec/matcher_helper.rb +3 -3
  28. data/lib/my_api_client/rspec/matchers/request_to.rb +1 -1
  29. data/lib/my_api_client/version.rb +1 -1
  30. data/my_api/Gemfile +1 -1
  31. data/my_api/Gemfile.lock +55 -51
  32. data/my_api/app/controllers/error_controller.rb +1 -1
  33. data/my_api/app/controllers/pagination_controller.rb +1 -1
  34. data/my_api/app/controllers/rest_controller.rb +4 -4
  35. data/my_api/app/controllers/status_controller.rb +1 -1
  36. data/my_api/spec/controllers/error_controller_spec.rb +4 -4
  37. data/my_api/spec/controllers/status_controller_spec.rb +3 -3
  38. data/my_api_client.gemspec +2 -1
  39. data/rails_app/rails_6.1/Gemfile.lock +73 -71
  40. data/rails_app/rails_7.0/Gemfile.lock +78 -76
  41. data/rails_app/rails_7.1/.dockerignore +31 -0
  42. data/rails_app/rails_7.1/.rspec +1 -0
  43. data/rails_app/rails_7.1/Dockerfile +55 -0
  44. data/rails_app/rails_7.1/Gemfile +16 -0
  45. data/rails_app/rails_7.1/Gemfile.lock +241 -0
  46. data/rails_app/rails_7.1/README.md +24 -0
  47. data/rails_app/rails_7.1/Rakefile +8 -0
  48. data/rails_app/rails_7.1/app/controllers/application_controller.rb +4 -0
  49. data/rails_app/rails_7.1/app/controllers/concerns/.keep +0 -0
  50. data/rails_app/rails_7.1/app/models/application_record.rb +5 -0
  51. data/rails_app/rails_7.1/app/models/concerns/.keep +0 -0
  52. data/rails_app/rails_7.1/bin/bundle +122 -0
  53. data/rails_app/rails_7.1/bin/docker-entrypoint +8 -0
  54. data/rails_app/rails_7.1/bin/rails +6 -0
  55. data/rails_app/rails_7.1/bin/rake +6 -0
  56. data/rails_app/rails_7.1/bin/setup +35 -0
  57. data/rails_app/rails_7.1/config/application.rb +46 -0
  58. data/rails_app/rails_7.1/config/boot.rb +5 -0
  59. data/rails_app/rails_7.1/config/credentials.yml.enc +1 -0
  60. data/rails_app/rails_7.1/config/database.yml +25 -0
  61. data/rails_app/rails_7.1/config/environment.rb +7 -0
  62. data/rails_app/rails_7.1/config/environments/development.rb +58 -0
  63. data/rails_app/rails_7.1/config/environments/production.rb +74 -0
  64. data/rails_app/rails_7.1/config/environments/test.rb +56 -0
  65. data/rails_app/rails_7.1/config/initializers/cors.rb +17 -0
  66. data/rails_app/rails_7.1/config/initializers/filter_parameter_logging.rb +10 -0
  67. data/rails_app/rails_7.1/config/initializers/inflections.rb +17 -0
  68. data/rails_app/rails_7.1/config/locales/en.yml +31 -0
  69. data/rails_app/rails_7.1/config/puma.rb +46 -0
  70. data/rails_app/rails_7.1/config/routes.rb +12 -0
  71. data/rails_app/rails_7.1/config.ru +8 -0
  72. data/rails_app/rails_7.1/db/seeds.rb +10 -0
  73. data/rails_app/rails_7.1/lib/tasks/.keep +0 -0
  74. data/rails_app/rails_7.1/public/robots.txt +2 -0
  75. data/rails_app/rails_7.1/spec/rails_helper.rb +13 -0
  76. data/rails_app/rails_7.1/spec/spec_helper.rb +13 -0
  77. data/rails_app/rails_7.1/storage/.keep +0 -0
  78. data/rails_app/rails_7.1/tmp/.keep +0 -0
  79. data/rails_app/rails_7.1/tmp/pids/.keep +0 -0
  80. data/rails_app/rails_7.1/tmp/storage/.keep +0 -0
  81. data/rails_app/rails_7.1/vendor/.keep +0 -0
  82. data/rails_app/rails_7.2/.dockerignore +42 -0
  83. data/rails_app/rails_7.2/.github/dependabot.yml +12 -0
  84. data/rails_app/rails_7.2/.github/workflows/ci.yml +55 -0
  85. data/rails_app/rails_7.2/.rspec +1 -0
  86. data/rails_app/rails_7.2/Dockerfile +62 -0
  87. data/rails_app/rails_7.2/Gemfile +15 -0
  88. data/rails_app/rails_7.2/Gemfile.lock +240 -0
  89. data/rails_app/rails_7.2/README.md +24 -0
  90. data/rails_app/rails_7.2/Rakefile +8 -0
  91. data/rails_app/rails_7.2/app/controllers/application_controller.rb +4 -0
  92. data/rails_app/rails_7.2/app/controllers/concerns/.keep +0 -0
  93. data/rails_app/rails_7.2/app/models/application_record.rb +5 -0
  94. data/rails_app/rails_7.2/app/models/concerns/.keep +0 -0
  95. data/rails_app/rails_7.2/bin/brakeman +9 -0
  96. data/rails_app/rails_7.2/bin/bundle +122 -0
  97. data/rails_app/rails_7.2/bin/docker-entrypoint +13 -0
  98. data/rails_app/rails_7.2/bin/rails +6 -0
  99. data/rails_app/rails_7.2/bin/rake +6 -0
  100. data/rails_app/rails_7.2/bin/rubocop +10 -0
  101. data/rails_app/rails_7.2/bin/setup +39 -0
  102. data/rails_app/rails_7.2/config/application.rb +46 -0
  103. data/rails_app/rails_7.2/config/boot.rb +5 -0
  104. data/rails_app/rails_7.2/config/credentials.yml.enc +1 -0
  105. data/rails_app/rails_7.2/config/database.yml +32 -0
  106. data/rails_app/rails_7.2/config/environment.rb +7 -0
  107. data/rails_app/rails_7.2/config/environments/development.rb +59 -0
  108. data/rails_app/rails_7.2/config/environments/production.rb +77 -0
  109. data/rails_app/rails_7.2/config/environments/test.rb +53 -0
  110. data/rails_app/rails_7.2/config/initializers/cors.rb +18 -0
  111. data/rails_app/rails_7.2/config/initializers/filter_parameter_logging.rb +10 -0
  112. data/rails_app/rails_7.2/config/initializers/inflections.rb +18 -0
  113. data/rails_app/rails_7.2/config/locales/en.yml +31 -0
  114. data/rails_app/rails_7.2/config/puma.rb +36 -0
  115. data/rails_app/rails_7.2/config/routes.rb +12 -0
  116. data/rails_app/rails_7.2/config.ru +8 -0
  117. data/rails_app/rails_7.2/db/seeds.rb +11 -0
  118. data/rails_app/rails_7.2/lib/tasks/.keep +0 -0
  119. data/rails_app/rails_7.2/public/robots.txt +3 -0
  120. data/rails_app/rails_7.2/spec/rails_helper.rb +13 -0
  121. data/rails_app/rails_7.2/spec/spec_helper.rb +13 -0
  122. data/rails_app/rails_7.2/storage/.keep +0 -0
  123. data/rails_app/rails_7.2/tmp/.keep +0 -0
  124. data/rails_app/rails_7.2/tmp/pids/.keep +0 -0
  125. data/rails_app/rails_7.2/tmp/storage/.keep +0 -0
  126. data/rails_app/rails_7.2/vendor/.keep +0 -0
  127. metadata +107 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9a7c0e59912fcb57831b996cda5b2d18d6488e33609eac9c1cc227b8d2699177
4
- data.tar.gz: 6cf555c678a2537db8fe85dfe2c6a98385c61d00b92bc4d931c3bfdfdf04442b
3
+ metadata.gz: 4f2745bef6aa2f95a58e0659bba49daa138d81e49378ff9d987fdd06084ee0aa
4
+ data.tar.gz: f0f60c9b581486f00b58a8f1cb204aa081460ae680f4a6d58a572017506d25d4
5
5
  SHA512:
6
- metadata.gz: 289f20431d12e8c625e15da365c85607da2324cb4990f8ad100ef8fd31b1c1acd5dae6e964b20191ef4be3b98518b77c792e5a5616d4e506cf01407f5038f822
7
- data.tar.gz: 61b0c21d3b43b5492d84bd6eb5107efcf4b7f6b8573685c9f85097276ae86c97ca27beb988d7482b864b17f18a8655a1e43251bb827de36e23a1aa46e314365f
6
+ metadata.gz: a88a53ab7b3f39f50725baba06db050946a6123e4bd39a26e7b8f49ae7618f37f7c49b9d31fbf5de94a35aaa3893e867ed017d551a1e5954cc126913e4edb56a
7
+ data.tar.gz: 493aaf7b296b8964d1a00307c1a1dc41730d894cc896fa4c6a6aa7d8c2fa5c5b15bf2c32ec6b55d15853bfe0fb34158e98db4763bbddd6ffe30e8bd86c6573f4
data/.circleci/config.yml CHANGED
@@ -12,13 +12,13 @@ references:
12
12
  - &ruby_version
13
13
  ruby_version:
14
14
  type: enum
15
- enum: &ruby_version_enum ["3.0", "3.1", "3.2"]
16
- default: "3.2"
15
+ enum: &ruby_version_enum ["3.1", "3.2", "3.3"]
16
+ default: "3.3"
17
17
  - &rails_version
18
18
  rails_version:
19
19
  type: enum
20
- enum: &rails_version_enum ["6.1", "7.0"]
21
- default: "7.0"
20
+ enum: &rails_version_enum ["6.1", "7.0", "7.1", "7.2"]
21
+ default: "7.2"
22
22
  - &bundler_options
23
23
  bundler_options:
24
24
  type: string
@@ -252,7 +252,7 @@ jobs:
252
252
  - code-climate/install
253
253
  - code-climate/sum-coverage:
254
254
  input: codeclimate.*.json
255
- parts: 12
255
+ parts: 24
256
256
  - code-climate/upload-coverage
257
257
  rubocop:
258
258
  executor: gem_executor
@@ -294,7 +294,7 @@ workflows:
294
294
  ruby_version: *ruby_version_enum
295
295
  rails_version: *rails_version_enum
296
296
  - test_api:
297
- ruby_version: "3.2"
297
+ ruby_version: "3.2" # Ruby on Jets requires Ruby 2.5, 2.7 or 3.2
298
298
  - rubocop
299
299
  - yardoc
300
300
  - upload-coverage:
data/.rubocop.yml CHANGED
@@ -2,11 +2,12 @@ require:
2
2
  - rubocop-performance
3
3
  - rubocop-rake
4
4
  - rubocop-rspec
5
+ - rubocop-rspec_rails
5
6
 
6
7
  inherit_from: .rubocop_todo.yml
7
8
 
8
9
  AllCops:
9
- TargetRubyVersion: 3.0
10
+ TargetRubyVersion: 3.1
10
11
  NewCops: enable
11
12
  Exclude:
12
13
  - rails_app/**/*
@@ -49,7 +50,7 @@ RSpec/DescribeClass:
49
50
  RSpec/ExampleLength:
50
51
  Max: 10
51
52
 
52
- RSpec/FilePath:
53
+ RSpec/SpecFilePathFormat:
53
54
  Exclude:
54
55
  - "spec/lib/my_api_client/integrations/**/*"
55
56
  - "spec/lib/my_api_client/errors/**/*"
@@ -64,6 +65,6 @@ RSpec/NestedGroups:
64
65
  RSpec/MultipleExpectations:
65
66
  Max: 4
66
67
 
67
- RSpec/Rails/HaveHttpStatus:
68
+ RSpecRails/HaveHttpStatus:
68
69
  Exclude:
69
70
  - "my_api/spec/controllers/**/*"
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.1.6
data/CHANGELOG.md CHANGED
@@ -1,5 +1,63 @@
1
1
  # Change log
2
2
 
3
+ ## v1.2.0 (Sep 06, 2024)
4
+
5
+ ### Feature
6
+
7
+ - [#1048](https://github.com/ryz310/my_api_client/pull/1048) Support lazy evaluation for request headers and body parameters ([@ryz310](https://github.com/ryz310))
8
+ The API client allows lazy evaluation for request headers and body parameters.
9
+ For example, a time-limited token can be issued immediately before the request.
10
+
11
+ ```rb
12
+ class ExampleApiClient < MyApiClient::Base
13
+ def get_users
14
+ get 'users', headers: headers, query: { key: 'value' }
15
+ end
16
+
17
+ private
18
+
19
+ def headers
20
+ lambda do
21
+ new_access_token = issue_new_access_token!
22
+ {
23
+ 'Content-Type': 'application/json;charset=UTF-8',
24
+ 'Authorization': "Bearer #{new_access_token}",
25
+ }
26
+ end
27
+ end
28
+ end
29
+ ```
30
+
31
+ ### Misc
32
+
33
+ - [#1049](https://github.com/ryz310/my_api_client/pull/1049) Update supporting ruby and rails versions ([@ryz310](https://github.com/ryz310))
34
+ Support Ruby 3.3, Rails 7.1 and 7.2
35
+ End of supporting Ruby 3.0 :wave:
36
+
37
+ ### Dependabot
38
+
39
+ - [#982](https://github.com/ryz310/my_api_client/pull/982) Bump rspec from 3.12.0 to 3.13.0 ([@ryz310](https://github.com/ryz310))
40
+ - [#1006](https://github.com/ryz310/my_api_client/pull/1006) Bump rake from 13.2.0 to 13.2.1 ([@ryz310](https://github.com/ryz310))
41
+ - [#1018](https://github.com/ryz310/my_api_client/pull/1018) Bump bugsnag from 6.26.4 to 6.27.0 ([@ryz310](https://github.com/ryz310))
42
+ - [#1020](https://github.com/ryz310/my_api_client/pull/1020) Bump webmock from 3.23.0 to 3.23.1 ([@ryz310](https://github.com/ryz310))
43
+ - [#1031](https://github.com/ryz310/my_api_client/pull/1031) Bump rubocop-performance from 1.21.0 to 1.21.1 ([@ryz310](https://github.com/ryz310))
44
+ - [#1032](https://github.com/ryz310/my_api_client/pull/1032) Bump bugsnag from 6.27.0 to 6.27.1 ([@ryz310](https://github.com/ryz310))
45
+ - [#1043](https://github.com/ryz310/my_api_client/pull/1043) Bump rexml from 3.3.3 to 3.3.6 ([@ryz310](https://github.com/ryz310))
46
+ - [#1045](https://github.com/ryz310/my_api_client/pull/1045) Bump activesupport from 7.1.3.4 to 7.1.4 ([@ryz310](https://github.com/ryz310))
47
+ - [#1046](https://github.com/ryz310/my_api_client/pull/1046) Bump faraday from 2.10.1 to 2.11.0 ([@ryz310](https://github.com/ryz310))
48
+ - [#1047](https://github.com/ryz310/my_api_client/pull/1047) Bump yard from 0.9.36 to 0.9.37 ([@ryz310](https://github.com/ryz310))
49
+
50
+ ## v1.1.0 (Jan 09, 2024)
51
+
52
+ ### Bugfix
53
+
54
+ - [#970](https://github.com/ryz310/my_api_client/pull/970) Fix handling when the error changes after a retry ([@ashimomura](https://github.com/ashimomura))
55
+
56
+ ### Dependabot
57
+
58
+ - [#965](https://github.com/ryz310/my_api_client/pull/965) Bump faraday from 2.7.12 to 2.8.1 ([@ryz310](https://github.com/ryz310))
59
+ - [#972](https://github.com/ryz310/my_api_client/pull/972) Bump rubocop-performance from 1.19.1 to 1.20.2 ([@ryz310](https://github.com/ryz310))
60
+
3
61
  ## v1.0.0 (Dec 07, 2023)
4
62
 
5
63
  ### Feature
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- my_api_client (1.0.0)
4
+ my_api_client (1.2.0)
5
5
  activesupport (>= 6.1.0)
6
6
  faraday (>= 0.17.1)
7
7
  jsonpath
@@ -10,51 +10,54 @@ PATH
10
10
  GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
- activesupport (7.1.2)
13
+ activesupport (7.2.1)
14
14
  base64
15
15
  bigdecimal
16
- concurrent-ruby (~> 1.0, >= 1.0.2)
16
+ concurrent-ruby (~> 1.0, >= 1.3.1)
17
17
  connection_pool (>= 2.2.5)
18
18
  drb
19
19
  i18n (>= 1.6, < 2)
20
+ logger (>= 1.4.2)
20
21
  minitest (>= 5.1)
21
- mutex_m
22
- tzinfo (~> 2.0)
23
- addressable (2.8.5)
24
- public_suffix (>= 2.0.2, < 6.0)
22
+ securerandom (>= 0.3)
23
+ tzinfo (~> 2.0, >= 2.0.5)
24
+ addressable (2.8.7)
25
+ public_suffix (>= 2.0.2, < 7.0)
25
26
  ast (2.4.2)
26
27
  base64 (0.2.0)
27
- bigdecimal (3.1.4)
28
- bugsnag (6.26.0)
28
+ bigdecimal (3.1.8)
29
+ bugsnag (6.27.1)
29
30
  concurrent-ruby (~> 1.0)
30
31
  byebug (11.1.3)
31
32
  coderay (1.1.3)
32
- concurrent-ruby (1.2.2)
33
+ concurrent-ruby (1.3.4)
33
34
  connection_pool (2.4.1)
34
- crack (0.4.5)
35
+ crack (1.0.0)
36
+ bigdecimal
35
37
  rexml
36
- diff-lcs (1.5.0)
37
- docile (1.4.0)
38
- drb (2.2.0)
39
- ruby2_keywords
40
- faraday (2.7.12)
41
- base64
42
- faraday-net_http (>= 2.0, < 3.1)
43
- ruby2_keywords (>= 0.0.4)
44
- faraday-net_http (3.0.2)
45
- hashdiff (1.0.1)
46
- i18n (1.14.1)
38
+ diff-lcs (1.5.1)
39
+ docile (1.4.1)
40
+ drb (2.2.1)
41
+ faraday (2.11.0)
42
+ faraday-net_http (>= 2.0, < 3.4)
43
+ logger
44
+ faraday-net_http (3.3.0)
45
+ net-http
46
+ hashdiff (1.1.1)
47
+ i18n (1.14.5)
47
48
  concurrent-ruby (~> 1.0)
48
- json (2.7.1)
49
+ json (2.7.2)
49
50
  jsonpath (1.1.5)
50
51
  multi_json
51
52
  language_server-protocol (3.17.0.3)
52
- method_source (1.0.0)
53
- minitest (5.20.0)
53
+ logger (1.6.1)
54
+ method_source (1.1.0)
55
+ minitest (5.25.1)
54
56
  multi_json (1.15.0)
55
- mutex_m (0.2.0)
56
- parallel (1.23.0)
57
- parser (3.2.2.4)
57
+ net-http (0.4.1)
58
+ uri
59
+ parallel (1.26.3)
60
+ parser (3.3.5.0)
58
61
  ast (~> 2.4.1)
59
62
  racc
60
63
  pry (0.14.2)
@@ -63,58 +66,54 @@ GEM
63
66
  pry-byebug (3.10.1)
64
67
  byebug (~> 11.0)
65
68
  pry (>= 0.13, < 0.15)
66
- public_suffix (5.0.4)
67
- racc (1.7.3)
69
+ public_suffix (6.0.1)
70
+ racc (1.8.1)
68
71
  rainbow (3.1.1)
69
- rake (13.1.0)
70
- regexp_parser (2.8.3)
71
- rexml (3.2.6)
72
- rspec (3.12.0)
73
- rspec-core (~> 3.12.0)
74
- rspec-expectations (~> 3.12.0)
75
- rspec-mocks (~> 3.12.0)
76
- rspec-core (3.12.2)
77
- rspec-support (~> 3.12.0)
78
- rspec-expectations (3.12.3)
72
+ rake (13.2.1)
73
+ regexp_parser (2.9.2)
74
+ rexml (3.3.7)
75
+ rspec (3.13.0)
76
+ rspec-core (~> 3.13.0)
77
+ rspec-expectations (~> 3.13.0)
78
+ rspec-mocks (~> 3.13.0)
79
+ rspec-core (3.13.1)
80
+ rspec-support (~> 3.13.0)
81
+ rspec-expectations (3.13.2)
79
82
  diff-lcs (>= 1.2.0, < 2.0)
80
- rspec-support (~> 3.12.0)
81
- rspec-mocks (3.12.6)
83
+ rspec-support (~> 3.13.0)
84
+ rspec-mocks (3.13.1)
82
85
  diff-lcs (>= 1.2.0, < 2.0)
83
- rspec-support (~> 3.12.0)
84
- rspec-support (3.12.1)
86
+ rspec-support (~> 3.13.0)
87
+ rspec-support (3.13.1)
85
88
  rspec_junit_formatter (0.6.0)
86
89
  rspec-core (>= 2, < 4, != 2.12.0)
87
- rubocop (1.58.0)
90
+ rubocop (1.66.1)
88
91
  json (~> 2.3)
89
92
  language_server-protocol (>= 3.17.0)
90
93
  parallel (~> 1.10)
91
- parser (>= 3.2.2.4)
94
+ parser (>= 3.3.0.2)
92
95
  rainbow (>= 2.2.2, < 4.0)
93
- regexp_parser (>= 1.8, < 3.0)
94
- rexml (>= 3.2.5, < 4.0)
95
- rubocop-ast (>= 1.30.0, < 2.0)
96
+ regexp_parser (>= 2.4, < 3.0)
97
+ rubocop-ast (>= 1.32.2, < 2.0)
96
98
  ruby-progressbar (~> 1.7)
97
99
  unicode-display_width (>= 2.4.0, < 3.0)
98
- rubocop-ast (1.30.0)
99
- parser (>= 3.2.1.0)
100
- rubocop-capybara (2.19.0)
101
- rubocop (~> 1.41)
102
- rubocop-factory_bot (2.24.0)
103
- rubocop (~> 1.33)
104
- rubocop-performance (1.19.1)
105
- rubocop (>= 1.7.0, < 2.0)
106
- rubocop-ast (>= 0.4.0)
100
+ rubocop-ast (1.32.3)
101
+ parser (>= 3.3.1.0)
102
+ rubocop-performance (1.21.1)
103
+ rubocop (>= 1.48.1, < 2.0)
104
+ rubocop-ast (>= 1.31.1, < 2.0)
107
105
  rubocop-rake (0.6.0)
108
106
  rubocop (~> 1.0)
109
- rubocop-rspec (2.25.0)
110
- rubocop (~> 1.40)
111
- rubocop-capybara (~> 2.17)
112
- rubocop-factory_bot (~> 2.22)
107
+ rubocop-rspec (3.0.4)
108
+ rubocop (~> 1.61)
109
+ rubocop-rspec_rails (2.30.0)
110
+ rubocop (~> 1.61)
111
+ rubocop-rspec (~> 3, >= 3.0.1)
113
112
  ruby-progressbar (1.13.0)
114
- ruby2_keywords (0.0.5)
115
113
  sawyer (0.9.2)
116
114
  addressable (>= 2.3.5)
117
115
  faraday (>= 0.17.3, < 3)
116
+ securerandom (0.3.1)
118
117
  simplecov (0.22.0)
119
118
  docile (~> 1.1)
120
119
  simplecov-html (~> 0.11)
@@ -124,11 +123,12 @@ GEM
124
123
  tzinfo (2.0.6)
125
124
  concurrent-ruby (~> 1.0)
126
125
  unicode-display_width (2.5.0)
127
- webmock (3.19.1)
126
+ uri (0.13.1)
127
+ webmock (3.23.1)
128
128
  addressable (>= 2.8.0)
129
129
  crack (>= 0.3.2)
130
130
  hashdiff (>= 0.4.0, < 2.0.0)
131
- yard (0.9.34)
131
+ yard (0.9.37)
132
132
 
133
133
  PLATFORMS
134
134
  ruby
@@ -145,6 +145,7 @@ DEPENDENCIES
145
145
  rubocop-performance
146
146
  rubocop-rake
147
147
  rubocop-rspec
148
+ rubocop-rspec_rails
148
149
  simplecov (= 0.22.0)
149
150
  webmock
150
151
  yard
data/README.jp.md CHANGED
@@ -12,8 +12,8 @@ MyApiClient は API リクエストクラスを作成するための汎用的な
12
12
 
13
13
  ## Supported Versions
14
14
 
15
- - Ruby 3.0, 3.1, 3.2
16
- - Rails 6.1, 7.0
15
+ - Ruby 3.1, 3.2, 3.3
16
+ - Rails 6.1, 7.0, 7.1, 7.2
17
17
 
18
18
  ## Installation
19
19
 
data/README.md CHANGED
@@ -16,8 +16,8 @@ It is supposed to be used in Ruby on Rails, but it is made to work in other envi
16
16
 
17
17
  ## Supported Versions
18
18
 
19
- - Ruby 3.0, 3.1, 3.2
20
- - Rails 6.1, 7.0
19
+ - Ruby 3.1, 3.2, 3.3
20
+ - Rails 6.1, 7.0, 7.1, 7.2
21
21
 
22
22
  ## Installation
23
23
 
@@ -23,7 +23,7 @@ class MyErrorApiClient < ApplicationApiClient
23
23
 
24
24
  # GET error/:code
25
25
  def get_error(code:)
26
- get "error/#{code}", headers: headers
26
+ get "error/#{code}", headers:
27
27
  end
28
28
 
29
29
  private
@@ -24,7 +24,7 @@ class MyHeaderApiClient < ApplicationApiClient
24
24
  # @param second_header [String] X-Second-Header
25
25
  # @return [Sawyer::Resource]
26
26
  def get_header(first_header:, second_header:)
27
- get 'header', headers: headers, query: {
27
+ get 'header', headers:, query: {
28
28
  'X-First-Header': first_header,
29
29
  'X-Second-Header': second_header,
30
30
  }.compact
@@ -8,13 +8,13 @@ class MyPaginationApiClient < ApplicationApiClient
8
8
  # Paging with JSONPath
9
9
  # GET pagination?page=1
10
10
  def paging_with_jsonpath
11
- pget 'pagination', headers: headers, query: { page: 1 }, paging: '$.links.next'
11
+ pget 'pagination', headers:, query: { page: 1 }, paging: '$.links.next'
12
12
  end
13
13
 
14
14
  # Paging with Proc
15
15
  # GET pagination?page=1
16
16
  def paging_with_proc
17
- pget 'pagination', headers: headers, query: { page: 1 }, paging: lambda { |response|
17
+ pget 'pagination', headers:, query: { page: 1 }, paging: lambda { |response|
18
18
  response.data.links.next
19
19
  }
20
20
  end
@@ -8,36 +8,36 @@ class MyRestApiClient < ApplicationApiClient
8
8
  # GET rest
9
9
  def get_posts(order: :asc)
10
10
  order = :desc unless order == :asc
11
- query = { order: order }
12
- get 'rest', query: query, headers: headers
11
+ query = { order: }
12
+ get 'rest', query:, headers:
13
13
  end
14
14
 
15
15
  # GET rest/:id
16
16
  def get_post(id:)
17
- get "rest/#{id}", headers: headers
17
+ get "rest/#{id}", headers:
18
18
  end
19
19
 
20
20
  # POST rest
21
21
  def post_post(title:)
22
- body = { title: title }
23
- post 'rest', body: body, headers: headers
22
+ body = { title: }
23
+ post 'rest', body:, headers:
24
24
  end
25
25
 
26
26
  # PUT rest/:id
27
27
  def put_post(id:, title:)
28
- body = { title: title }
29
- put "rest/#{id}", body: body, headers: headers
28
+ body = { title: }
29
+ put "rest/#{id}", body:, headers:
30
30
  end
31
31
 
32
32
  # PATCH rest/:id
33
33
  def patch_post(id:, title:)
34
- body = { title: title }
35
- patch "rest/#{id}", body: body, headers: headers
34
+ body = { title: }
35
+ patch "rest/#{id}", body:, headers:
36
36
  end
37
37
 
38
38
  # DELETE rest/:id
39
39
  def delete_post(id:)
40
- delete "rest/#{id}", headers: headers
40
+ delete "rest/#{id}", headers:
41
41
  end
42
42
 
43
43
  private
@@ -11,7 +11,7 @@ class MyStatusApiClient < ApplicationApiClient
11
11
 
12
12
  # GET status/:status
13
13
  def get_status(status:)
14
- get "status/#{status}", headers: headers
14
+ get "status/#{status}", headers:
15
15
  end
16
16
 
17
17
  private
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file was generated by Appraisal
4
+
5
+ source 'https://rubygems.org'
6
+
7
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
8
+
9
+ gem 'activesupport', '~> 7.1.0'
10
+
11
+ group :integrations, optional: true do
12
+ gem 'bugsnag', '>= 6.11.0'
13
+ end
14
+
15
+ gemspec
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file was generated by Appraisal
4
+
5
+ source 'https://rubygems.org'
6
+
7
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
8
+
9
+ gem 'activesupport', '~> 7.2.0'
10
+
11
+ group :integrations, optional: true do
12
+ gem 'bugsnag', '>= 6.11.0'
13
+ end
14
+
15
+ gemspec
@@ -84,7 +84,7 @@ module MyApiClient
84
84
  "You can use options that: #{ARGUMENTS}"
85
85
  end
86
86
 
87
- instance_variable_set("@_#{k}", v)
87
+ instance_variable_set(:"@_#{k}", v)
88
88
  end
89
89
  end
90
90
 
@@ -50,7 +50,7 @@ module MyApiClient
50
50
 
51
51
  new_error_handlers = error_handlers.dup
52
52
  new_error_handlers << lambda { |instance, response|
53
- Generator.call(**options.merge(instance: instance, response: response))
53
+ Generator.call(**options.merge(instance:, response:))
54
54
  }
55
55
  self.error_handlers = new_error_handlers
56
56
  end
@@ -30,7 +30,7 @@ module MyApiClient
30
30
  #
31
31
  # @return [String] Contents as string
32
32
  def inspect
33
- { error: original_error, params: params }.inspect
33
+ { error: original_error, params: }.inspect
34
34
  end
35
35
 
36
36
  # Generate metadata for bugsnag.
@@ -23,7 +23,7 @@ module MyApiClient
23
23
  #
24
24
  # @return [String] Contents as string
25
25
  def inspect
26
- { error: super, params: params }.inspect
26
+ { error: super, params: }.inspect
27
27
  end
28
28
  end
29
29
  end
@@ -51,9 +51,20 @@ module MyApiClient
51
51
  end
52
52
 
53
53
  def retry_calling(wait)
54
- Sleeper.call(wait: wait)
54
+ Sleeper.call(wait:)
55
55
  @retry_count += 1
56
56
  @retry_result = call(*args)
57
57
  end
58
+
59
+ # call the handler for exception
60
+ #
61
+ # @note
62
+ # To avoid handling the exception of the retry origin on the second and subsequent retries,
63
+ # make exception.cause visited.
64
+ # @override ActiveSupport::Rescuable#rescue_with_handler
65
+ # @param exception [Exception] Target exception
66
+ def rescue_with_handler(exception)
67
+ self.class.rescue_with_handler(exception, object: self, visited_exceptions: [exception.cause])
68
+ end
58
69
  end
59
70
  end
@@ -29,7 +29,7 @@ module MyApiClient
29
29
  #
30
30
  # @return [String] Contents as string
31
31
  def inspect
32
- { request: request, response: response }.inspect
32
+ { request:, response: }.inspect
33
33
  end
34
34
 
35
35
  private
@@ -10,20 +10,20 @@ module MyApiClient
10
10
  #
11
11
  # @param method [Symbol] describe_method_here
12
12
  # @param uri [URI] describe_uri_here
13
- # @param headers [Hash, nil] describe_headers_here
14
- # @param body [Hash, nil] describe_body_here
13
+ # @param headers [Hash, Proc<Hash>, nil] describe_headers_here
14
+ # @param body [Hash, Proc<Hash>, nil] describe_body_here
15
15
  def initialize(method, uri, headers, body)
16
16
  @method = method
17
17
  @uri = uri
18
- @headers = headers
19
- @body = body
18
+ @headers = headers.is_a?(Proc) ? headers.call : headers
19
+ @body = body.is_a?(Proc) ? body.call : body
20
20
  end
21
21
 
22
22
  # Description of #to_sawyer_args
23
23
  #
24
24
  # @return [Array<Object>] Arguments for Sawyer::Agent#call
25
25
  def to_sawyer_args
26
- [method, uri.to_s, body, { headers: headers }]
26
+ [method, uri.to_s, body, { headers: }]
27
27
  end
28
28
 
29
29
  # Generate metadata for bugsnag.
@@ -33,8 +33,8 @@ module MyApiClient
33
33
  def metadata
34
34
  {
35
35
  line: "#{method.upcase} #{uri}",
36
- headers: headers,
37
- body: body,
36
+ headers:,
37
+ body:,
38
38
  }.compact
39
39
  end
40
40
  alias to_bugsnag metadata
@@ -43,7 +43,7 @@ module MyApiClient
43
43
  #
44
44
  # @return [String] Contents as string
45
45
  def inspect
46
- { method: method, uri: uri.to_s, headers: headers, body: body }.inspect
46
+ { method:, uri: uri.to_s, headers:, body: }.inspect
47
47
  end
48
48
  end
49
49
  end
@@ -13,11 +13,11 @@ module MyApiClient
13
13
  # @param pathname [String]
14
14
  # Pathname of the request target URL.
15
15
  # It's joined with the defined by `endpoint`.
16
- # @param headers [Hash, nil]
16
+ # @param headers [Hash, Proc<Hash>, nil]
17
17
  # Request headers.
18
18
  # @param query [Hash, nil]
19
19
  # Query string.
20
- # @param body [Hash, nil]
20
+ # @param body [Hash, Proc<Hash>, nil]
21
21
  # Request body. You should not specify it when use GET method.
22
22
  # @return [Sawyer::Resource]
23
23
  # Response body instance if the block is not given.
@@ -22,7 +22,7 @@ module MyApiClient
22
22
  @request_params = request_params
23
23
  @request_logger = request_logger
24
24
  faraday = Faraday.new(nil, faraday_options)
25
- @agent = Sawyer::Agent.new('', faraday: faraday)
25
+ @agent = Sawyer::Agent.new('', faraday:)
26
26
  end
27
27
 
28
28
  private
@@ -11,12 +11,10 @@ module MyApiClient
11
11
  # Pathname of the request target URL. It's joined with the defined by `endpoint`.
12
12
  # @param paging [String, Proc]
13
13
  # Specify the pagination link path included in the response body as JsonPath expression
14
- # @param headers [Hash, nil]
14
+ # @param headers [Hash, Proc<Hash>, nil]
15
15
  # Request headers.
16
16
  # @param query [Hash, nil]
17
17
  # Query string.
18
- # @param body [Hash, nil]
19
- # Request body. You should not specify it when use GET method.
20
18
  # @return [Enumerator::Lazy]
21
19
  # Yields the pagination API response.
22
20
  def pageable_get(pathname, paging:, headers: nil, query: nil)