my_api_client 0.25.0 → 0.27.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +5 -5
  3. data/.rubocop.yml +4 -1
  4. data/.rubocop_todo.yml +16 -4
  5. data/CHANGELOG.md +54 -0
  6. data/Gemfile.lock +51 -34
  7. data/README.jp.md +7 -7
  8. data/README.md +5 -5
  9. data/lib/generators/generator_helper.rb +4 -0
  10. data/lib/my_api_client/request/basic.rb +10 -2
  11. data/lib/my_api_client/service_abstract.rb +2 -2
  12. data/lib/my_api_client/version.rb +1 -1
  13. data/my_api/.ruby-version +1 -1
  14. data/my_api/Gemfile +2 -2
  15. data/my_api/Gemfile.lock +85 -83
  16. data/my_api/public/index.html +2 -2
  17. data/my_api_client.gemspec +2 -2
  18. data/rails_app/rails_6.1/Gemfile.lock +2 -2
  19. data/rails_app/rails_7.0/Gemfile.lock +3 -3
  20. metadata +6 -38
  21. data/gemfiles/rails_6.0.gemfile +0 -16
  22. data/rails_app/rails_6.0/.rspec +0 -3
  23. data/rails_app/rails_6.0/Gemfile +0 -18
  24. data/rails_app/rails_6.0/Gemfile.lock +0 -188
  25. data/rails_app/rails_6.0/README.md +0 -24
  26. data/rails_app/rails_6.0/Rakefile +0 -8
  27. data/rails_app/rails_6.0/app/controllers/application_controller.rb +0 -4
  28. data/rails_app/rails_6.0/app/jobs/application_job.rb +0 -9
  29. data/rails_app/rails_6.0/bin/rails +0 -6
  30. data/rails_app/rails_6.0/bin/rake +0 -6
  31. data/rails_app/rails_6.0/bin/setup +0 -27
  32. data/rails_app/rails_6.0/config/application.rb +0 -39
  33. data/rails_app/rails_6.0/config/boot.rb +0 -6
  34. data/rails_app/rails_6.0/config/credentials.yml.enc +0 -1
  35. data/rails_app/rails_6.0/config/environment.rb +0 -7
  36. data/rails_app/rails_6.0/config/environments/development.rb +0 -39
  37. data/rails_app/rails_6.0/config/environments/production.rb +0 -90
  38. data/rails_app/rails_6.0/config/environments/test.rb +0 -41
  39. data/rails_app/rails_6.0/config/initializers/application_controller_renderer.rb +0 -9
  40. data/rails_app/rails_6.0/config/initializers/backtrace_silencers.rb +0 -8
  41. data/rails_app/rails_6.0/config/initializers/cors.rb +0 -17
  42. data/rails_app/rails_6.0/config/initializers/filter_parameter_logging.rb +0 -6
  43. data/rails_app/rails_6.0/config/initializers/inflections.rb +0 -17
  44. data/rails_app/rails_6.0/config/initializers/mime_types.rb +0 -5
  45. data/rails_app/rails_6.0/config/initializers/wrap_parameters.rb +0 -11
  46. data/rails_app/rails_6.0/config/locales/en.yml +0 -33
  47. data/rails_app/rails_6.0/config/routes.rb +0 -5
  48. data/rails_app/rails_6.0/config/spring.rb +0 -8
  49. data/rails_app/rails_6.0/config.ru +0 -7
  50. data/rails_app/rails_6.0/public/robots.txt +0 -1
  51. data/rails_app/rails_6.0/spec/rails_helper.rb +0 -14
  52. data/rails_app/rails_6.0/spec/spec_helper.rb +0 -13
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c6c284685be8f55566beede15458b1a37dc948b09ce05bc264f23187fc266478
4
- data.tar.gz: 3cc7d5acf9b8d53fde96270b6ef63baca986ba459f819ad53c11d71744004049
3
+ metadata.gz: a6c7a66724037e300c85085d014dbbe0c71771339c8de4d6c48743ae31dcd534
4
+ data.tar.gz: eecb78a1be508ec4a84719686f1ae5895d6e86794d32ab9dd8753fbb2d7f6135
5
5
  SHA512:
6
- metadata.gz: 36ae22feafaddcab8f70f1c755c89d6cacd2bced91fe04c373c56d1e45c157c5c64188de9b1edd2f43eaa9ab1a50339e8c19ec94bd6a67802f83e28d6deb5228
7
- data.tar.gz: 980a73834aa0c2e5b0c95d111b19466c8918a8ab5e43fdfefc46f7e4e4bc033b206dca290cfb0c9d5122ff9d6e4fa02b441c180150ccc4e05b4cbb26cc4c3546
6
+ metadata.gz: 7f7dad661776f4147d0bfd860b0a353c97c14549329cc5e7cb1afd336acf8ebdee79467e7f66be264b016eebd3282ff0bd9283ffde8354c4309e47540cfcfa80
7
+ data.tar.gz: bd1ca19ec238f00cc5ff2b1c3aafeb184f3126388c4de0485baf5c8e720cad48542db2bff100e345f09adf05e79a4f08eba197d907d12c85d327d61f40105b1b
data/.circleci/config.yml CHANGED
@@ -12,12 +12,12 @@ references:
12
12
  - &ruby_version
13
13
  ruby_version:
14
14
  type: enum
15
- enum: &ruby_version_enum ["2.7", "3.0", "3.1", "3.2"]
15
+ enum: &ruby_version_enum ["3.0", "3.1", "3.2"]
16
16
  default: "3.2"
17
17
  - &rails_version
18
18
  rails_version:
19
19
  type: enum
20
- enum: &rails_version_enum ["6.0", "6.1", "7.0"]
20
+ enum: &rails_version_enum ["6.1", "7.0"]
21
21
  default: "7.0"
22
22
  - &bundler_options
23
23
  bundler_options:
@@ -153,7 +153,7 @@ commands:
153
153
  name: Install Bundler 2.x
154
154
  command: gem install bundler -v '~> 2.0'
155
155
  - ruby-orbs/bundle-install:
156
- cache_key_prefix: v2-dependencies-<< parameters.ruby_version >>
156
+ cache_key_prefix: v3-dependencies-<< parameters.ruby_version >>
157
157
  bundle_extra_args: << parameters.bundler_options >>
158
158
  restore_bundled_with: false
159
159
  test_and_deploy_for_api:
@@ -252,7 +252,7 @@ jobs:
252
252
  - code-climate/install
253
253
  - code-climate/sum-coverage:
254
254
  input: codeclimate.*.json
255
- parts: 24
255
+ parts: 12
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: "2.7" # Jets supports only Ruby 2.x
297
+ ruby_version: "3.2"
298
298
  - rubocop
299
299
  - yardoc
300
300
  - upload-coverage:
data/.rubocop.yml CHANGED
@@ -6,7 +6,7 @@ require:
6
6
  inherit_from: .rubocop_todo.yml
7
7
 
8
8
  AllCops:
9
- TargetRubyVersion: 2.7
9
+ TargetRubyVersion: 3.0
10
10
  NewCops: enable
11
11
  Exclude:
12
12
  - rails_app/**/*
@@ -55,6 +55,9 @@ RSpec/FilePath:
55
55
  - "spec/lib/my_api_client/errors/**/*"
56
56
  - "spec/lib/my_api_client/rspec/**/*"
57
57
 
58
+ RSpec/IndexedLet:
59
+ Max: 3
60
+
58
61
  RSpec/NestedGroups:
59
62
  Max: 5
60
63
 
data/.rubocop_todo.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2023-02-06 23:31:23 UTC using RuboCop version 1.41.1.
3
+ # on 2023-11-13 01:22:13 UTC using RuboCop version 1.57.2.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
@@ -14,7 +14,8 @@ Lint/EmptyBlock:
14
14
  - 'spec/support/complete_about.rb'
15
15
  - 'spec/support/complete_within.rb'
16
16
 
17
- # Offense count: 5
17
+ # Offense count: 6
18
+ # Configuration parameters: AllowedParentClasses.
18
19
  Lint/MissingSuper:
19
20
  Exclude:
20
21
  - 'lib/my_api_client/error_handling/generator.rb'
@@ -22,21 +23,32 @@ Lint/MissingSuper:
22
23
  - 'lib/my_api_client/integrations/bugsnag.rb'
23
24
  - 'lib/my_api_client/request/executor.rb'
24
25
  - 'lib/my_api_client/sleeper.rb'
26
+ - 'spec/lib/my_api_client/rspec/matchers/be_handled_as_an_error_spec.rb'
25
27
 
26
28
  # Offense count: 6
27
29
  # Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns.
28
30
  # SupportedStyles: snake_case, normalcase, non_integer
29
- # AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339
31
+ # AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339, x86_64
30
32
  Naming/VariableNumber:
31
33
  Exclude:
32
34
  - 'spec/lib/my_api_client/error_handling_spec.rb'
33
35
  - 'spec/lib/my_api_client/request/executor_spec.rb'
34
36
 
35
- # Offense count: 101
37
+ # Offense count: 103
36
38
  # Configuration parameters: AllowSubject.
37
39
  RSpec/MultipleMemoizedHelpers:
38
40
  Max: 15
39
41
 
42
+ # Offense count: 3
43
+ # Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata.
44
+ # Include: **/*_spec.rb
45
+ RSpec/SpecFilePathFormat:
46
+ Exclude:
47
+ - '**/spec/routing/**/*'
48
+ - 'spec/lib/my_api_client/errors/error_spec.rb'
49
+ - 'spec/lib/my_api_client/errors/network_error_spec.rb'
50
+ - 'spec/lib/my_api_client/rspec/stub_spec.rb'
51
+
40
52
  # Offense count: 3
41
53
  Style/DocumentDynamicEvalDefinition:
42
54
  Exclude:
data/CHANGELOG.md CHANGED
@@ -1,5 +1,59 @@
1
1
  # Change log
2
2
 
3
+ ## v0.27.0 (Nov 13, 2023)
4
+
5
+ ### Feature
6
+
7
+ - [#944](https://github.com/ryz310/my_api_client/pull/944) Add block to retrieve sawyer response ([@okumud](https://github.com/okumud))
8
+
9
+ ```rb
10
+ api_clinet = ExampleApiClient.new(access_token: 'access_token')
11
+
12
+ # You can retrieve sawyer response with return value
13
+ api_clinet.get_users #=> #<Sawyer::Resource>
14
+
15
+ # You can retrieve sawyer response with block
16
+ api_clinet.get_users do |response|
17
+ response #=> #<Sawyer::Response>
18
+ response.headers #=> #<Hash>
19
+ response.data #=> #<Sawyer::Resource>
20
+ end
21
+ ```
22
+
23
+ ### Breaking Change
24
+
25
+ - [#931](https://github.com/ryz310/my_api_client/pull/931) End of support for ruby 2.7 and rails 6.0 ([@ryz310](https://github.com/ryz310))
26
+
27
+ ### Rubocop Challenge
28
+
29
+ ### Dependabot
30
+
31
+ - [#919](https://github.com/ryz310/my_api_client/pull/919) Bump bugsnag from 6.25.2 to 6.26.0 ([@ryz310](https://github.com/ryz310))
32
+ - [#929](https://github.com/ryz310/my_api_client/pull/929) Bump webmock from 3.19.0 to 3.19.1 ([@ryz310](https://github.com/ryz310))
33
+ - [#934](https://github.com/ryz310/my_api_client/pull/934) Bump rubocop-performance from 1.19.0 to 1.19.1 ([@ryz310](https://github.com/ryz310))
34
+ - [#933](https://github.com/ryz310/my_api_client/pull/933) Bump faraday from 2.7.10 to 2.7.11 ([@ryz310](https://github.com/ryz310))
35
+ - [#939](https://github.com/ryz310/my_api_client/pull/939) Bump jsonpath from 1.1.4 to 1.1.5 ([@ryz310](https://github.com/ryz310))
36
+ - [#942](https://github.com/ryz310/my_api_client/pull/942) Bump rake from 13.0.6 to 13.1.0 ([@ryz310](https://github.com/ryz310))
37
+ - [#945](https://github.com/ryz310/my_api_client/pull/945) Bump activesupport from 7.1.1 to 7.1.2 ([@ryz310](https://github.com/ryz310))
38
+
39
+ ### Misc
40
+
41
+ - [#946](https://github.com/ryz310/my_api_client/pull/946) Fix a broken spec ([@ryz310](https://github.com/ryz310))
42
+
43
+ ## v0.26.0 (Jul 04, 2023)
44
+
45
+ ### Bugfix
46
+
47
+ - [#914](https://github.com/ryz310/my_api_client/pull/914) Fix error that generating api client failed on Rails 7 ([@ryz310](https://github.com/ryz310))
48
+
49
+ ### Dependabot
50
+
51
+ - [#889](https://github.com/ryz310/my_api_client/pull/889) Bump yard from 0.9.32 to 0.9.34 ([@ryz310](https://github.com/ryz310))
52
+ - [#893](https://github.com/ryz310/my_api_client/pull/893) Bump jsonpath from 1.1.2 to 1.1.3 ([@ryz310](https://github.com/ryz310))
53
+ - [#897](https://github.com/ryz310/my_api_client/pull/897) Bump rubocop-performance from 1.17.1 to 1.18.0 ([@ryz310](https://github.com/ryz310))
54
+ - [#912](https://github.com/ryz310/my_api_client/pull/912) Bump activesupport from 7.0.5.1 to 7.0.6 ([@ryz310](https://github.com/ryz310))
55
+ - [#913](https://github.com/ryz310/my_api_client/pull/913) Bump faraday from 2.7.8 to 2.7.9 ([@ryz310](https://github.com/ryz310))
56
+
3
57
  ## v0.25.0 (Feb 12, 2023)
4
58
 
5
59
  ### Breaking Change
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- my_api_client (0.25.0)
5
- activesupport (>= 6.0.0)
4
+ my_api_client (0.27.0)
5
+ activesupport (>= 6.1.0)
6
6
  faraday (>= 0.17.1)
7
7
  jsonpath
8
8
  sawyer (>= 0.8.2)
@@ -10,88 +10,107 @@ PATH
10
10
  GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
- activesupport (7.0.4.2)
13
+ activesupport (7.1.2)
14
+ base64
15
+ bigdecimal
14
16
  concurrent-ruby (~> 1.0, >= 1.0.2)
17
+ connection_pool (>= 2.2.5)
18
+ drb
15
19
  i18n (>= 1.6, < 2)
16
20
  minitest (>= 5.1)
21
+ mutex_m
17
22
  tzinfo (~> 2.0)
18
- addressable (2.8.1)
23
+ addressable (2.8.5)
19
24
  public_suffix (>= 2.0.2, < 6.0)
20
25
  ast (2.4.2)
21
- bugsnag (6.25.2)
26
+ base64 (0.2.0)
27
+ bigdecimal (3.1.4)
28
+ bugsnag (6.26.0)
22
29
  concurrent-ruby (~> 1.0)
23
30
  byebug (11.1.3)
24
31
  coderay (1.1.3)
25
- concurrent-ruby (1.2.0)
32
+ concurrent-ruby (1.2.2)
33
+ connection_pool (2.4.1)
26
34
  crack (0.4.5)
27
35
  rexml
28
36
  diff-lcs (1.5.0)
29
37
  docile (1.4.0)
30
- faraday (2.7.4)
38
+ drb (2.2.0)
39
+ ruby2_keywords
40
+ faraday (2.7.11)
41
+ base64
31
42
  faraday-net_http (>= 2.0, < 3.1)
32
43
  ruby2_keywords (>= 0.0.4)
33
44
  faraday-net_http (3.0.2)
34
45
  hashdiff (1.0.1)
35
- i18n (1.12.0)
46
+ i18n (1.14.1)
36
47
  concurrent-ruby (~> 1.0)
37
48
  json (2.6.3)
38
- jsonpath (1.1.2)
49
+ jsonpath (1.1.5)
39
50
  multi_json
51
+ language_server-protocol (3.17.0.3)
40
52
  method_source (1.0.0)
41
- minitest (5.17.0)
53
+ minitest (5.20.0)
42
54
  multi_json (1.15.0)
43
- parallel (1.22.1)
44
- parser (3.2.1.0)
55
+ mutex_m (0.2.0)
56
+ parallel (1.23.0)
57
+ parser (3.2.2.4)
45
58
  ast (~> 2.4.1)
59
+ racc
46
60
  pry (0.14.2)
47
61
  coderay (~> 1.1)
48
62
  method_source (~> 1.0)
49
63
  pry-byebug (3.10.1)
50
64
  byebug (~> 11.0)
51
65
  pry (>= 0.13, < 0.15)
52
- public_suffix (5.0.1)
66
+ public_suffix (5.0.3)
67
+ racc (1.7.3)
53
68
  rainbow (3.1.1)
54
- rake (13.0.6)
55
- regexp_parser (2.7.0)
56
- rexml (3.2.5)
69
+ rake (13.1.0)
70
+ regexp_parser (2.8.2)
71
+ rexml (3.2.6)
57
72
  rspec (3.12.0)
58
73
  rspec-core (~> 3.12.0)
59
74
  rspec-expectations (~> 3.12.0)
60
75
  rspec-mocks (~> 3.12.0)
61
- rspec-core (3.12.1)
76
+ rspec-core (3.12.2)
62
77
  rspec-support (~> 3.12.0)
63
- rspec-expectations (3.12.2)
78
+ rspec-expectations (3.12.3)
64
79
  diff-lcs (>= 1.2.0, < 2.0)
65
80
  rspec-support (~> 3.12.0)
66
- rspec-mocks (3.12.3)
81
+ rspec-mocks (3.12.6)
67
82
  diff-lcs (>= 1.2.0, < 2.0)
68
83
  rspec-support (~> 3.12.0)
69
- rspec-support (3.12.0)
84
+ rspec-support (3.12.1)
70
85
  rspec_junit_formatter (0.6.0)
71
86
  rspec-core (>= 2, < 4, != 2.12.0)
72
- rubocop (1.45.1)
87
+ rubocop (1.57.2)
73
88
  json (~> 2.3)
89
+ language_server-protocol (>= 3.17.0)
74
90
  parallel (~> 1.10)
75
- parser (>= 3.2.0.0)
91
+ parser (>= 3.2.2.4)
76
92
  rainbow (>= 2.2.2, < 4.0)
77
93
  regexp_parser (>= 1.8, < 3.0)
78
94
  rexml (>= 3.2.5, < 4.0)
79
- rubocop-ast (>= 1.24.1, < 2.0)
95
+ rubocop-ast (>= 1.28.1, < 2.0)
80
96
  ruby-progressbar (~> 1.7)
81
97
  unicode-display_width (>= 2.4.0, < 3.0)
82
- rubocop-ast (1.26.0)
98
+ rubocop-ast (1.30.0)
83
99
  parser (>= 3.2.1.0)
84
- rubocop-capybara (2.17.0)
100
+ rubocop-capybara (2.19.0)
85
101
  rubocop (~> 1.41)
86
- rubocop-performance (1.16.0)
102
+ rubocop-factory_bot (2.24.0)
103
+ rubocop (~> 1.33)
104
+ rubocop-performance (1.19.1)
87
105
  rubocop (>= 1.7.0, < 2.0)
88
106
  rubocop-ast (>= 0.4.0)
89
107
  rubocop-rake (0.6.0)
90
108
  rubocop (~> 1.0)
91
- rubocop-rspec (2.18.1)
92
- rubocop (~> 1.33)
109
+ rubocop-rspec (2.25.0)
110
+ rubocop (~> 1.40)
93
111
  rubocop-capybara (~> 2.17)
94
- ruby-progressbar (1.11.0)
112
+ rubocop-factory_bot (~> 2.22)
113
+ ruby-progressbar (1.13.0)
95
114
  ruby2_keywords (0.0.5)
96
115
  sawyer (0.9.2)
97
116
  addressable (>= 2.3.5)
@@ -104,14 +123,12 @@ GEM
104
123
  simplecov_json_formatter (0.1.4)
105
124
  tzinfo (2.0.6)
106
125
  concurrent-ruby (~> 1.0)
107
- unicode-display_width (2.4.2)
108
- webmock (3.18.1)
126
+ unicode-display_width (2.5.0)
127
+ webmock (3.19.1)
109
128
  addressable (>= 2.8.0)
110
129
  crack (>= 0.3.2)
111
130
  hashdiff (>= 0.4.0, < 2.0.0)
112
- webrick (1.7.0)
113
- yard (0.9.28)
114
- webrick (~> 1.7.0)
131
+ yard (0.9.34)
115
132
 
116
133
  PLATFORMS
117
134
  ruby
data/README.jp.md CHANGED
@@ -12,8 +12,8 @@ MyApiClient は API リクエストクラスを作成するための汎用的な
12
12
 
13
13
  ## Supported Versions
14
14
 
15
- - Ruby 2.7, 3.0, 3.1, 3.2
16
- - Rails 6.0, 6.1, 7.0
15
+ - Ruby 3.0, 3.1, 3.2
16
+ - Rails 6.1, 7.0
17
17
 
18
18
  ## Installation
19
19
 
@@ -52,7 +52,7 @@ class ExampleApiClient < MyApiClient::Base
52
52
 
53
53
  # GET https://example.com/v1/users
54
54
  #
55
- # @return [Sawyer::Response] HTTP response parameter
55
+ # @return [Sawyer::Resource] HTTP resource parameter
56
56
  def get_users
57
57
  get 'users', headers: headers, query: { key: 'value' }
58
58
  end
@@ -60,7 +60,7 @@ class ExampleApiClient < MyApiClient::Base
60
60
  # POST https://example.com/v1/users
61
61
  #
62
62
  # @param name [String] Username which want to create
63
- # @return [Sawyer::Response] HTTP response parameter
63
+ # @return [Sawyer::Resource] HTTP resource parameter
64
64
  def post_user(name:)
65
65
  post 'users', headers: headers, body: { name: name }
66
66
  end
@@ -76,7 +76,7 @@ class ExampleApiClient < MyApiClient::Base
76
76
  end
77
77
 
78
78
  api_clinet = ExampleApiClient.new(access_token: 'access_token')
79
- api_clinet.get_users #=> #<Sawyer::Response>
79
+ api_clinet.get_users #=> #<Sawyer::Resource>
80
80
  ```
81
81
 
82
82
  クラス定義の最初に記述される `endpoint` にはリクエスト URL の共通部分を定義します。後述の各メソッドで後続の path を定義しますが、上記の例だと `get 'users'` と定義すると、 `GET https://example.com/v1/users` というリクエストが実行されます。
@@ -416,7 +416,7 @@ class GetUsersApiClient < ExampleApiClient
416
416
 
417
417
  # GET https://example.com/users
418
418
  #
419
- # @return [Sawyer::Response] HTTP response parameter
419
+ # @return [Sawyer::Resource] HTTP resource parameter
420
420
  def request
421
421
  get 'users', query: { key: 'value' }, headers: headers
422
422
  end
@@ -428,7 +428,7 @@ class PostUserApiClient < ExampleApiClient
428
428
  # POST https://example.com/users
429
429
  #
430
430
  # @param name [String] Username which want to create
431
- # @return [Sawyer::Response] HTTP response parameter
431
+ # @return [Sawyer::Resource] HTTP resource parameter
432
432
  def request(name:)
433
433
  post 'users', headers: headers, body: { name: name }
434
434
  end
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 2.7, 3.0, 3.1, 3.2
20
- - Rails 6.0, 6.1, 7.0
19
+ - Ruby 3.0, 3.1, 3.2
20
+ - Rails 6.1, 7.0
21
21
 
22
22
  ## Installation
23
23
 
@@ -56,7 +56,7 @@ class ExampleApiClient < MyApiClient::Base
56
56
 
57
57
  # GET https://example.com/v1/users
58
58
  #
59
- # @return [Sawyer::Response] HTTP response parameter
59
+ # @return [Sawyer::Resource] HTTP resource parameter
60
60
  def get_users
61
61
  get 'users', headers: headers, query: { key: 'value' }
62
62
  end
@@ -64,7 +64,7 @@ class ExampleApiClient < MyApiClient::Base
64
64
  # POST https://example.com/v1/users
65
65
  #
66
66
  # @param name [String] Username which want to create
67
- # @return [Sawyer::Response] HTTP response parameter
67
+ # @return [Sawyer::Resource] HTTP resource parameter
68
68
  def post_user(name:)
69
69
  post 'users', headers: headers, body: { name: name }
70
70
  end
@@ -80,7 +80,7 @@ class ExampleApiClient < MyApiClient::Base
80
80
  end
81
81
 
82
82
  api_clinet = ExampleApiClient.new(access_token: 'access_token')
83
- api_clinet.get_users #=> #<Sawyer::Response>
83
+ api_clinet.get_users #=> #<Sawyer::Resource>
84
84
  ```
85
85
 
86
86
  The `endpoint` defines the intersection of the request URL. Each method described below defines a subsequent path. In the above example, `get 'users'` will request to `GET https://example.com/v1/users`.
@@ -3,6 +3,10 @@
3
3
  module MyApiClient
4
4
  # The helper module for source generators
5
5
  module GeneratorHelper
6
+ def self.included(base)
7
+ base.include(Rails::Generators::ResourceHelpers)
8
+ end
9
+
6
10
  def yeild_request_arguments
7
11
  requests.each do |request|
8
12
  http_method, pathname = request.split(':')
@@ -20,10 +20,18 @@ module MyApiClient
20
20
  # @param body [Hash, nil]
21
21
  # Request body. You should not specify it when use GET method.
22
22
  # @return [Sawyer::Resource]
23
- # Response body instance.
23
+ # Response body instance if the block is not given.
24
+ # @yield
25
+ # Process the response body with the given block.
26
+ # @yieldparam response [Sawyer::Response]
27
+ # Response instance.
28
+ # @yieldreturn [Object]
29
+ # The block result.
30
+ # @return [Object]
31
+ # Whatever the block returns if the block is given.
24
32
  def #{http_method}(pathname, headers: nil, query: nil, body: nil)
25
33
  response = call(:_request_with_relative_uri, :#{http_method}, pathname, headers, query, body)
26
- response.data
34
+ block_given? ? yield(response) : response.data
27
35
  end
28
36
  METHOD
29
37
  end
@@ -5,8 +5,8 @@ module MyApiClient
5
5
  class ServiceAbstract
6
6
  private_class_method :new
7
7
 
8
- def self.call(**args, &block)
9
- new(**args, &block).send(:call)
8
+ def self.call(...)
9
+ new(...).send(:call)
10
10
  end
11
11
 
12
12
  # private
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MyApiClient
4
- VERSION = '0.25.0'
4
+ VERSION = '0.27.0'
5
5
  end
data/my_api/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.7.2
1
+ 3.0.6
data/my_api/Gemfile CHANGED
@@ -2,12 +2,12 @@
2
2
 
3
3
  source 'https://rubygems.org'
4
4
 
5
- gem 'jets', '~> 3.2.0'
5
+ gem 'jets', '~> 4.0.7'
6
6
 
7
7
  gem 'dynomite'
8
8
 
9
9
  # See: https://github.com/boltops-tools/jets/issues/523
10
- gem 'nokogiri', '~> 1.14.1'
10
+ gem 'nokogiri', '~> 1.15.4'
11
11
 
12
12
  # development and test groups are not bundled as part of the deployment
13
13
  group :development, :test do