my_api_client 0.27.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a6c7a66724037e300c85085d014dbbe0c71771339c8de4d6c48743ae31dcd534
4
- data.tar.gz: eecb78a1be508ec4a84719686f1ae5895d6e86794d32ab9dd8753fbb2d7f6135
3
+ metadata.gz: 9a7c0e59912fcb57831b996cda5b2d18d6488e33609eac9c1cc227b8d2699177
4
+ data.tar.gz: 6cf555c678a2537db8fe85dfe2c6a98385c61d00b92bc4d931c3bfdfdf04442b
5
5
  SHA512:
6
- metadata.gz: 7f7dad661776f4147d0bfd860b0a353c97c14549329cc5e7cb1afd336acf8ebdee79467e7f66be264b016eebd3282ff0bd9283ffde8354c4309e47540cfcfa80
7
- data.tar.gz: bd1ca19ec238f00cc5ff2b1c3aafeb184f3126388c4de0485baf5c8e720cad48542db2bff100e345f09adf05e79a4f08eba197d907d12c85d327d61f40105b1b
6
+ metadata.gz: 289f20431d12e8c625e15da365c85607da2324cb4990f8ad100ef8fd31b1c1acd5dae6e964b20191ef4be3b98518b77c792e5a5616d4e506cf01407f5038f822
7
+ data.tar.gz: 61b0c21d3b43b5492d84bd6eb5107efcf4b7f6b8573685c9f85097276ae86c97ca27beb988d7482b864b17f18a8655a1e43251bb827de36e23a1aa46e314365f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Change log
2
2
 
3
+ ## v1.0.0 (Dec 07, 2023)
4
+
5
+ ### Feature
6
+
7
+ - [#955](https://github.com/ryz310/my_api_client/pull/955) Enable Dynamic URL Generation for `#pageable_get` via `Proc` Objects ([@ryz310](https://github.com/ryz310))
8
+
9
+ ```ruby
10
+ # Example of using a Proc with pageable_get
11
+ pget 'api/example', headers:, query:, paging: ->(response) {
12
+ # Custom logic to generate the next URL
13
+ }
14
+ ```
15
+
16
+ ### Dependabot
17
+
18
+ - [#950](https://github.com/ryz310/my_api_client/pull/950) Bump faraday from 2.7.11 to 2.7.12 ([@ryz310](https://github.com/ryz310))
19
+
3
20
  ## v0.27.0 (Nov 13, 2023)
4
21
 
5
22
  ### Feature
@@ -24,8 +41,6 @@ end
24
41
 
25
42
  - [#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
43
 
27
- ### Rubocop Challenge
28
-
29
44
  ### Dependabot
30
45
 
31
46
  - [#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))
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- my_api_client (0.27.0)
4
+ my_api_client (1.0.0)
5
5
  activesupport (>= 6.1.0)
6
6
  faraday (>= 0.17.1)
7
7
  jsonpath
@@ -37,7 +37,7 @@ GEM
37
37
  docile (1.4.0)
38
38
  drb (2.2.0)
39
39
  ruby2_keywords
40
- faraday (2.7.11)
40
+ faraday (2.7.12)
41
41
  base64
42
42
  faraday-net_http (>= 2.0, < 3.1)
43
43
  ruby2_keywords (>= 0.0.4)
@@ -45,7 +45,7 @@ GEM
45
45
  hashdiff (1.0.1)
46
46
  i18n (1.14.1)
47
47
  concurrent-ruby (~> 1.0)
48
- json (2.6.3)
48
+ json (2.7.1)
49
49
  jsonpath (1.1.5)
50
50
  multi_json
51
51
  language_server-protocol (3.17.0.3)
@@ -63,11 +63,11 @@ GEM
63
63
  pry-byebug (3.10.1)
64
64
  byebug (~> 11.0)
65
65
  pry (>= 0.13, < 0.15)
66
- public_suffix (5.0.3)
66
+ public_suffix (5.0.4)
67
67
  racc (1.7.3)
68
68
  rainbow (3.1.1)
69
69
  rake (13.1.0)
70
- regexp_parser (2.8.2)
70
+ regexp_parser (2.8.3)
71
71
  rexml (3.2.6)
72
72
  rspec (3.12.0)
73
73
  rspec-core (~> 3.12.0)
@@ -84,7 +84,7 @@ GEM
84
84
  rspec-support (3.12.1)
85
85
  rspec_junit_formatter (0.6.0)
86
86
  rspec-core (>= 2, < 4, != 2.12.0)
87
- rubocop (1.57.2)
87
+ rubocop (1.58.0)
88
88
  json (~> 2.3)
89
89
  language_server-protocol (>= 3.17.0)
90
90
  parallel (~> 1.10)
@@ -92,7 +92,7 @@ GEM
92
92
  rainbow (>= 2.2.2, < 4.0)
93
93
  regexp_parser (>= 1.8, < 3.0)
94
94
  rexml (>= 3.2.5, < 4.0)
95
- rubocop-ast (>= 1.28.1, < 2.0)
95
+ rubocop-ast (>= 1.30.0, < 2.0)
96
96
  ruby-progressbar (~> 1.7)
97
97
  unicode-display_width (>= 2.4.0, < 3.0)
98
98
  rubocop-ast (1.30.0)
@@ -5,9 +5,18 @@ require_relative 'application_api_client'
5
5
  # An usage example of the `my_api_client`.
6
6
  # See also: my_api/app/controllers/pagination_controller.rb
7
7
  class MyPaginationApiClient < ApplicationApiClient
8
+ # Paging with JSONPath
8
9
  # GET pagination?page=1
9
- def pagination
10
- pget 'pagination', paging: '$.links.next', headers: headers, query: { page: 1 }
10
+ def paging_with_jsonpath
11
+ pget 'pagination', headers: headers, query: { page: 1 }, paging: '$.links.next'
12
+ end
13
+
14
+ # Paging with Proc
15
+ # GET pagination?page=1
16
+ def paging_with_proc
17
+ pget 'pagination', headers: headers, query: { page: 1 }, paging: lambda { |response|
18
+ response.data.links.next
19
+ }
11
20
  end
12
21
 
13
22
  private
@@ -23,7 +23,7 @@ module MyApiClient
23
23
  # Some network error
24
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
@@ -16,7 +16,7 @@ module MyApiClient
16
16
  # The error description
17
17
  def initialize(params = nil, error_message = nil)
18
18
  @params = params
19
- super error_message
19
+ super(error_message)
20
20
  end
21
21
 
22
22
  # Returns contents as string for to be readable for human
@@ -9,7 +9,7 @@ module MyApiClient
9
9
  #
10
10
  # @param pathname [String]
11
11
  # Pathname of the request target URL. It's joined with the defined by `endpoint`.
12
- # @param paging [String]
12
+ # @param paging [String, Proc]
13
13
  # Specify the pagination link path included in the response body as JsonPath expression
14
14
  # @param headers [Hash, nil]
15
15
  # Request headers.
@@ -25,7 +25,7 @@ module MyApiClient
25
25
  loop do
26
26
  y << response.data
27
27
 
28
- next_uri = JsonPath.new(paging).first(response.body)
28
+ next_uri = get_next_url(paging, response)
29
29
  break if next_uri.blank?
30
30
 
31
31
  response = call(:_request_with_absolute_uri, :get, next_uri, headers, nil)
@@ -34,6 +34,27 @@ module MyApiClient
34
34
  end
35
35
 
36
36
  alias pget pageable_get
37
+
38
+ private
39
+
40
+ # Returns the next URL for pagination
41
+ #
42
+ # @param paging [String, Proc]
43
+ # Specify the pagination link path included in the response body as JsonPath expression
44
+ # @param response [MyApiClient::Response]
45
+ # The response object
46
+ # @return [String, nil]
47
+ # The next URL for pagination
48
+ def get_next_url(paging, response)
49
+ case paging
50
+ when String
51
+ JsonPath.new(paging).first(response.body)
52
+ when Proc
53
+ paging.call(response)
54
+ else
55
+ raise ArgumentError, "Invalid paging argument: #{paging}"
56
+ end
57
+ end
37
58
  end
38
59
  end
39
60
  end
@@ -144,6 +144,7 @@ module MyApiClient
144
144
  status: status_code.presence || 400,
145
145
  headers: {},
146
146
  data: stub_as_resource(params),
147
+ body: params.to_json,
147
148
  timing: 0.123
148
149
  )
149
150
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MyApiClient
4
- VERSION = '0.27.0'
4
+ VERSION = '1.0.0'
5
5
  end
data/my_api/Gemfile CHANGED
@@ -2,12 +2,12 @@
2
2
 
3
3
  source 'https://rubygems.org'
4
4
 
5
- gem 'jets', '~> 4.0.7'
5
+ gem 'jets', '~> 4.0.10'
6
6
 
7
7
  gem 'dynomite'
8
8
 
9
9
  # See: https://github.com/boltops-tools/jets/issues/523
10
- gem 'nokogiri', '~> 1.15.4'
10
+ gem 'nokogiri', '~> 1.15.5'
11
11
 
12
12
  # development and test groups are not bundled as part of the deployment
13
13
  group :development, :test do
data/my_api/Gemfile.lock CHANGED
@@ -37,7 +37,7 @@ GEM
37
37
  zeitwerk (~> 2.3)
38
38
  addressable (2.8.4)
39
39
  public_suffix (>= 2.0.2, < 6.0)
40
- aws-eventstream (1.2.0)
40
+ aws-eventstream (1.3.0)
41
41
  aws-mfa-secure (0.4.4)
42
42
  activesupport
43
43
  aws-sdk-core
@@ -46,47 +46,47 @@ GEM
46
46
  rainbow
47
47
  thor
48
48
  zeitwerk
49
- aws-partitions (1.839.0)
50
- aws-sdk-apigateway (1.88.0)
51
- aws-sdk-core (~> 3, >= 3.184.0)
49
+ aws-partitions (1.863.0)
50
+ aws-sdk-apigateway (1.90.0)
51
+ aws-sdk-core (~> 3, >= 3.188.0)
52
52
  aws-sigv4 (~> 1.1)
53
- aws-sdk-cloudformation (1.91.0)
54
- aws-sdk-core (~> 3, >= 3.184.0)
53
+ aws-sdk-cloudformation (1.96.0)
54
+ aws-sdk-core (~> 3, >= 3.188.0)
55
55
  aws-sigv4 (~> 1.1)
56
- aws-sdk-cloudwatchlogs (1.71.0)
57
- aws-sdk-core (~> 3, >= 3.184.0)
56
+ aws-sdk-cloudwatchlogs (1.75.0)
57
+ aws-sdk-core (~> 3, >= 3.188.0)
58
58
  aws-sigv4 (~> 1.1)
59
- aws-sdk-core (3.185.1)
60
- aws-eventstream (~> 1, >= 1.0.2)
59
+ aws-sdk-core (3.190.0)
60
+ aws-eventstream (~> 1, >= 1.3.0)
61
61
  aws-partitions (~> 1, >= 1.651.0)
62
- aws-sigv4 (~> 1.5)
62
+ aws-sigv4 (~> 1.8)
63
63
  jmespath (~> 1, >= 1.6.1)
64
- aws-sdk-dynamodb (1.96.0)
65
- aws-sdk-core (~> 3, >= 3.184.0)
64
+ aws-sdk-dynamodb (1.98.0)
65
+ aws-sdk-core (~> 3, >= 3.188.0)
66
66
  aws-sigv4 (~> 1.1)
67
- aws-sdk-kinesis (1.52.0)
68
- aws-sdk-core (~> 3, >= 3.184.0)
67
+ aws-sdk-kinesis (1.54.0)
68
+ aws-sdk-core (~> 3, >= 3.188.0)
69
69
  aws-sigv4 (~> 1.1)
70
- aws-sdk-kms (1.72.0)
71
- aws-sdk-core (~> 3, >= 3.184.0)
70
+ aws-sdk-kms (1.74.0)
71
+ aws-sdk-core (~> 3, >= 3.188.0)
72
72
  aws-sigv4 (~> 1.1)
73
- aws-sdk-lambda (1.106.0)
74
- aws-sdk-core (~> 3, >= 3.184.0)
73
+ aws-sdk-lambda (1.113.0)
74
+ aws-sdk-core (~> 3, >= 3.188.0)
75
75
  aws-sigv4 (~> 1.1)
76
- aws-sdk-s3 (1.136.0)
77
- aws-sdk-core (~> 3, >= 3.181.0)
76
+ aws-sdk-s3 (1.141.0)
77
+ aws-sdk-core (~> 3, >= 3.189.0)
78
78
  aws-sdk-kms (~> 1)
79
- aws-sigv4 (~> 1.6)
80
- aws-sdk-sns (1.67.0)
81
- aws-sdk-core (~> 3, >= 3.184.0)
79
+ aws-sigv4 (~> 1.8)
80
+ aws-sdk-sns (1.70.0)
81
+ aws-sdk-core (~> 3, >= 3.188.0)
82
82
  aws-sigv4 (~> 1.1)
83
- aws-sdk-sqs (1.64.0)
84
- aws-sdk-core (~> 3, >= 3.184.0)
83
+ aws-sdk-sqs (1.69.0)
84
+ aws-sdk-core (~> 3, >= 3.188.0)
85
85
  aws-sigv4 (~> 1.1)
86
- aws-sdk-ssm (1.159.0)
87
- aws-sdk-core (~> 3, >= 3.184.0)
86
+ aws-sdk-ssm (1.162.0)
87
+ aws-sdk-core (~> 3, >= 3.188.0)
88
88
  aws-sigv4 (~> 1.1)
89
- aws-sigv4 (1.6.0)
89
+ aws-sigv4 (1.8.0)
90
90
  aws-eventstream (~> 1, >= 1.0.2)
91
91
  aws_config (0.1.1)
92
92
  builder (3.2.4)
@@ -109,7 +109,7 @@ GEM
109
109
  cfn_response (0.2.0)
110
110
  concurrent-ruby (1.2.2)
111
111
  crass (1.0.6)
112
- date (3.3.3)
112
+ date (3.3.4)
113
113
  diff-lcs (1.5.0)
114
114
  dotenv (2.8.1)
115
115
  dynomite (1.2.7)
@@ -123,7 +123,7 @@ GEM
123
123
  hashie (5.0.0)
124
124
  i18n (1.14.1)
125
125
  concurrent-ruby (~> 1.0)
126
- jets (4.0.7)
126
+ jets (4.0.10)
127
127
  actionmailer (~> 6.1.0)
128
128
  actionpack (~> 6.1.0)
129
129
  actionview (~> 6.1.0)
@@ -166,7 +166,7 @@ GEM
166
166
  rexml
167
167
  launchy (2.5.2)
168
168
  addressable (~> 2.8)
169
- loofah (2.21.4)
169
+ loofah (2.22.0)
170
170
  crass (~> 1.0.2)
171
171
  nokogiri (>= 1.12.0)
172
172
  mail (2.8.1)
@@ -180,23 +180,23 @@ GEM
180
180
  mini_mime (1.1.5)
181
181
  mini_portile2 (2.8.5)
182
182
  minitest (5.20.0)
183
- net-imap (0.4.2)
183
+ net-imap (0.4.7)
184
184
  date
185
185
  net-protocol
186
186
  net-pop (0.1.2)
187
187
  net-protocol
188
- net-protocol (0.2.1)
188
+ net-protocol (0.2.2)
189
189
  timeout
190
190
  net-smtp (0.4.0)
191
191
  net-protocol
192
192
  nio4r (2.5.9)
193
- nokogiri (1.15.4)
193
+ nokogiri (1.15.5)
194
194
  mini_portile2 (~> 2.8.2)
195
195
  racc (~> 1.4)
196
196
  public_suffix (5.0.1)
197
197
  puma (6.4.0)
198
198
  nio4r (~> 2.0)
199
- racc (1.7.1)
199
+ racc (1.7.3)
200
200
  rack (2.2.8)
201
201
  rack-test (2.1.0)
202
202
  rack (>= 1.3)
@@ -214,7 +214,7 @@ GEM
214
214
  rake (>= 12.2)
215
215
  thor (~> 1.0)
216
216
  rainbow (3.1.1)
217
- rake (13.0.6)
217
+ rake (13.1.0)
218
218
  recursive-open-struct (1.1.3)
219
219
  regexp_parser (2.8.1)
220
220
  rexml (3.2.6)
@@ -241,7 +241,7 @@ GEM
241
241
  rack (>= 1.0)
242
242
  text-table (1.2.4)
243
243
  thor (1.3.0)
244
- timeout (0.4.0)
244
+ timeout (0.4.1)
245
245
  tzinfo (2.0.6)
246
246
  concurrent-ruby (~> 1.0)
247
247
  xpath (3.2.0)
@@ -255,9 +255,9 @@ DEPENDENCIES
255
255
  byebug
256
256
  capybara
257
257
  dynomite
258
- jets (~> 4.0.7)
258
+ jets (~> 4.0.10)
259
259
  launchy
260
- nokogiri (~> 1.15.4)
260
+ nokogiri (~> 1.15.5)
261
261
  puma
262
262
  rack
263
263
  rspec
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: my_api_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.27.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ryz310
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-11-13 00:00:00.000000000 Z
11
+ date: 2023-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport