rest-client-wrapper 3.2.1 → 4.0.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.
- checksums.yaml +4 -4
- data/lib/rest_client_wrapper/authenticators/basic.rb +3 -3
- data/lib/rest_client_wrapper/authenticators/custom.rb +3 -3
- data/lib/rest_client_wrapper/authenticators/oauth.rb +2 -2
- data/lib/rest_client_wrapper/paginators/echo_paginator.rb +1 -1
- data/lib/rest_client_wrapper/request.rb +9 -9
- data/lib/rest_client_wrapper/rest_client.rb +4 -4
- data/lib/rest_client_wrapper/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b402585e6034813c0b9d3fa1af05e943ca106f7cdcae0b0f6e205e822250304
|
4
|
+
data.tar.gz: 64390499b6848d1dab15c57a723b9b02bded8eedf2b5f3650e8f3f8ed789f3f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8769b420a7bfe481450e0665a3f4899564dff302769bf050f7d512564b828479529a5a3859dd8fb581d714e8b4452601e102a0d28226771bc57ece9f16b4cc88
|
7
|
+
data.tar.gz: 46a6573d732840fe66240d6773db7f07ecd274d70b3a7b794b44d1bb31eca85fe514a050726571afe47538b8b4a16b260013c872b20283eb52c515df47829d6f
|
@@ -29,9 +29,9 @@ module RestClientWrapper
|
|
29
29
|
|
30
30
|
include Auth
|
31
31
|
|
32
|
-
def initialize(
|
33
|
-
@username = username
|
34
|
-
@password = password
|
32
|
+
def initialize(**config)
|
33
|
+
@username = config[:username]
|
34
|
+
@password = config[:password]
|
35
35
|
end
|
36
36
|
|
37
37
|
def generate_auth
|
@@ -32,9 +32,9 @@ module RestClientWrapper
|
|
32
32
|
|
33
33
|
TYPE = %i[header query_param].freeze
|
34
34
|
|
35
|
-
def initialize(
|
36
|
-
self.type = type
|
37
|
-
self.auth_param = auth_param
|
35
|
+
def initialize(**config)
|
36
|
+
self.type = config[:type]
|
37
|
+
self.auth_param = config[:auth_param]
|
38
38
|
end
|
39
39
|
|
40
40
|
def generate_auth
|
@@ -36,9 +36,9 @@ module RestClientWrapper
|
|
36
36
|
|
37
37
|
@@api_client = {} # rubocop:disable Style/ClassVars
|
38
38
|
|
39
|
-
def initialize(
|
39
|
+
def initialize(client_id:, **config)
|
40
40
|
@client_id = client_id
|
41
|
-
@@api_client[client_id] = { lock: Mutex.new, settings:
|
41
|
+
@@api_client[client_id] = { lock: Mutex.new, settings: config, access_token: nil, refresh_token: nil }
|
42
42
|
end
|
43
43
|
|
44
44
|
def tokens
|
@@ -55,7 +55,7 @@ module RestClientWrapper
|
|
55
55
|
private
|
56
56
|
|
57
57
|
def _pagination_links(response)
|
58
|
-
next_l = response&.body.
|
58
|
+
next_l = response&.body.instance_of?(Hash) ? response&.body&.[](:next) || "" : ""
|
59
59
|
next_h = Rack::Utils.parse_query(URI.parse(next_l)&.query)
|
60
60
|
return next_h.symbolize_keys!
|
61
61
|
end
|
@@ -21,20 +21,20 @@ module RestClientWrapper
|
|
21
21
|
# Request
|
22
22
|
class Request
|
23
23
|
|
24
|
-
|
25
|
-
|
24
|
+
attr_accessor :uri
|
25
|
+
attr_reader :headers, :http_method, :payload, :segment_params, :query_params
|
26
26
|
|
27
27
|
DEFAULT_CONTENT_TYPE = { content_type: :json, accept: :json }.freeze # default content type for post and put requests
|
28
28
|
VALID_HTTP_METHODS = %i[get post put patch delete connect options trace].freeze
|
29
29
|
HTTP_METHOD_FOR_JSON = %i[post put patch].freeze
|
30
30
|
|
31
|
-
def initialize(
|
32
|
-
@uri = uri
|
33
|
-
self.headers = headers
|
34
|
-
self.http_method = http_method
|
35
|
-
self.segment_params = segment_params
|
36
|
-
self.payload = payload
|
37
|
-
self.query_params = query_params
|
31
|
+
def initialize(**params)
|
32
|
+
@uri = params[:uri]
|
33
|
+
self.headers = params[:headers].nil? ? {} : params[:headers]
|
34
|
+
self.http_method = params[:http_method]
|
35
|
+
self.segment_params = params[:segment_params].nil? ? {} : params[:segment_params]
|
36
|
+
self.payload = params[:payload].nil? ? {} : params[:payload]
|
37
|
+
self.query_params = params[:query_params].nil? ? {} : params[:query_params]
|
38
38
|
end
|
39
39
|
|
40
40
|
def http_method=(http_method)
|
@@ -41,7 +41,7 @@ module RestClientWrapper
|
|
41
41
|
}
|
42
42
|
}.freeze
|
43
43
|
|
44
|
-
def initialize(host:, config
|
44
|
+
def initialize(host:, **config)
|
45
45
|
@host = host
|
46
46
|
@config = config
|
47
47
|
@retry_configs = {}.reverse_merge(DEFAULT_CONFIG[:retries])
|
@@ -129,7 +129,7 @@ module RestClientWrapper
|
|
129
129
|
|
130
130
|
def _validate_request(request)
|
131
131
|
# Regex to find segments in uri with the pattern <segment_param>
|
132
|
-
url_segments = request.uri.scan(
|
132
|
+
url_segments = request.uri.scan(/<(.*?)>/).flatten
|
133
133
|
url_segments.each do |url_segment|
|
134
134
|
raise ArgumentError, "Segment parameter not provided for #{ url_segment }. URI #{ request.uri }" unless request.segment_params.include? url_segment.to_sym
|
135
135
|
end
|
@@ -156,8 +156,8 @@ module RestClientWrapper
|
|
156
156
|
return { ok: true } if response.body == "ok".to_json # Handle special case for Echo delete responses
|
157
157
|
|
158
158
|
return JSON.parse(response.body, { object_class: Hash, symbolize_names: true })
|
159
|
-
rescue StandardError
|
160
|
-
|
159
|
+
rescue StandardError
|
160
|
+
return response.body
|
161
161
|
end
|
162
162
|
|
163
163
|
def _reset_retries
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rest-client-wrapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- University of Adelaide
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -195,7 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
195
195
|
- !ruby/object:Gem::Version
|
196
196
|
version: '0'
|
197
197
|
requirements: []
|
198
|
-
rubygems_version: 3.0.
|
198
|
+
rubygems_version: 3.0.9
|
199
199
|
signing_key:
|
200
200
|
specification_version: 4
|
201
201
|
summary: Rest client wrapper
|