dhs 1.4.0 → 1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dhs/concerns/record/request.rb +3 -3
- data/lib/dhs/pagination/next_offset.rb +1 -1
- data/lib/dhs/problems/errors.rb +1 -1
- data/lib/dhs/version.rb +1 -1
- data/spec/concerns/record/request_spec.rb +4 -4
- data/spec/pagination/next_offset_spec.rb +2 -4
- data/spec/record/endpoint_options_spec.rb +6 -6
- data/spec/record/includes_spec.rb +4 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 690186fffb1221bbc432b5a502bdfecb895b1f117e42602e6bef6b2c55cd7bd1
|
4
|
+
data.tar.gz: 7f544c63db8a4db092a6c3980b3cb2f437879876db145a6ac7d8c6cfc7647a05
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '087dacf286f24b6860419759c5ea7cd443d69e2cd8f4900b2ee17fdf93d2d9f55918534ec0aff8294e6a4906c2dad51d3c4eb2b6ad8b3f19111a4133ed15f6c5'
|
7
|
+
data.tar.gz: f14b0dad8dffb72c65cd6b785469a59c590a99187639e554865e99bcf8e696434f262c4e95d64b1241bfd997180ef278ce2f0f0f5b91c6e5f11a673466f7eff8
|
@@ -204,7 +204,7 @@ class DHS::Record
|
|
204
204
|
end
|
205
205
|
|
206
206
|
def load_and_merge_not_paginated_collection!(data, options)
|
207
|
-
return if data.
|
207
|
+
return if data.empty?
|
208
208
|
options = options.is_a?(Hash) ? options : {}
|
209
209
|
limit = options.dig(:params, limit_key(:parameter)) || pagination_class::DEFAULT_LIMIT
|
210
210
|
offset = options.dig(:params, pagination_key(:parameter)) || pagination_class::DEFAULT_OFFSET
|
@@ -230,7 +230,7 @@ class DHS::Record
|
|
230
230
|
end
|
231
231
|
|
232
232
|
def load_and_merge_paginated_collection!(data, options)
|
233
|
-
set_nested_data(data._raw, limit_key(:body), data.length) if data._raw.dig(*limit_key(:body)).blank? && !data.
|
233
|
+
set_nested_data(data._raw, limit_key(:body), data.length) if data._raw.dig(*limit_key(:body)).blank? && !data.empty?
|
234
234
|
pagination = data._record.pagination(data)
|
235
235
|
return data unless pagination.pages_left?
|
236
236
|
record = data._record
|
@@ -256,7 +256,7 @@ class DHS::Record
|
|
256
256
|
page_data = if next_value.is_a?(String) && next_value.match(/^http/)
|
257
257
|
record.request(options.except(:all).merge(url: next_value))
|
258
258
|
else
|
259
|
-
record.request(options.except(:all).merge(params: (options.dig(:params) || {}).merge(next_value)
|
259
|
+
record.request(options.except(:all).merge(params: (options.dig(:params) || {}).merge(next_value)))
|
260
260
|
end
|
261
261
|
next_value = pagination.next(page_data._raw)
|
262
262
|
merge_batch_data_with_parent!(page_data, data, pagination)
|
data/lib/dhs/problems/errors.rb
CHANGED
@@ -54,7 +54,7 @@ module DHS::Problems
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def messages_from_response(response = nil)
|
57
|
-
return {} if !response || !response.body.is_a?(String) || response.body.
|
57
|
+
return {} if !response || !response.body.is_a?(String) || response.body.empty?
|
58
58
|
json = JSON.parse(response.body)
|
59
59
|
parse_messages(json)
|
60
60
|
end
|
data/lib/dhs/version.rb
CHANGED
@@ -19,15 +19,15 @@ describe DHS::Record::Request do
|
|
19
19
|
|
20
20
|
it 'calls correct prepare method for a Hash' do
|
21
21
|
expect(subject).to receive(:prepare_option_for_include_all_request!)
|
22
|
-
.with(abc: 'def').and_return('ignore')
|
23
|
-
expect(subject.send(:prepare_options_for_include_all_request!, abc: 'def')).to eq(abc: 'def')
|
22
|
+
.with({ abc: 'def' }).and_return('ignore')
|
23
|
+
expect(subject.send(:prepare_options_for_include_all_request!, { abc: 'def' })).to eq(abc: 'def')
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'calls correct prepare method for a Hash (collection)' do
|
27
27
|
expect(subject).to receive(:prepare_option_for_include_all_request!)
|
28
|
-
.with(abc: 'def').and_return('ignore')
|
28
|
+
.with({ abc: 'def' }).and_return('ignore')
|
29
29
|
expect(subject).to receive(:prepare_option_for_include_all_request!)
|
30
|
-
.with(hij: 'kel').and_return('ignore')
|
30
|
+
.with({ hij: 'kel' }).and_return('ignore')
|
31
31
|
expect(subject.send(:prepare_options_for_include_all_request!, [{ abc: 'def' }, { hij: 'kel' }]))
|
32
32
|
.to eq([{ abc: 'def' }, { hij: 'kel' }])
|
33
33
|
end
|
@@ -3,11 +3,9 @@
|
|
3
3
|
require 'rails_helper'
|
4
4
|
|
5
5
|
describe DHS::Record do
|
6
|
-
|
7
6
|
context 'pagination' do
|
8
|
-
|
9
|
-
|
10
|
-
stub_request(:get, ["http://depay.fi/v2/transactions?limit=100", offset ? "offset=#{offset}" : nil].compact.join('&'))
|
7
|
+
def stub_api_request(next_offset:, items: [], offset: nil)
|
8
|
+
stub_request(:get, ['http://depay.fi/v2/transactions?limit=100', offset ? "offset=#{offset}" : nil].compact.join('&'))
|
11
9
|
.to_return(body: { items: items, next_offset: next_offset }.to_json)
|
12
10
|
end
|
13
11
|
|
@@ -16,12 +16,12 @@ describe DHS::Record do
|
|
16
16
|
|
17
17
|
it 'uses the options that are configured for an endpoint' do
|
18
18
|
expect(DHC).to receive(:request)
|
19
|
-
.with(
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
19
|
+
.with({
|
20
|
+
cache_expires_in: 1.day,
|
21
|
+
retry: 2,
|
22
|
+
cache: true,
|
23
|
+
url: 'backend/v2/feedbacks/1'
|
24
|
+
}).and_call_original
|
25
25
|
|
26
26
|
stub_request(:get, 'http://backend/v2/feedbacks/1').to_return(status: 200)
|
27
27
|
Record.find(1)
|
@@ -214,12 +214,12 @@ describe DHS::Record do
|
|
214
214
|
|
215
215
|
it 'overwrites existing pagination paramters if they are already contained in a string' do
|
216
216
|
expect(DHC).to receive(:request)
|
217
|
-
.with(url: 'http://datastore/customers/1').and_call_original
|
217
|
+
.with({ url: 'http://datastore/customers/1' }).and_call_original
|
218
218
|
|
219
219
|
expect(DHC).to receive(:request)
|
220
|
-
.with(url: 'http://datastore/customers/1/contracts',
|
221
|
-
|
222
|
-
|
220
|
+
.with({ url: 'http://datastore/customers/1/contracts',
|
221
|
+
all: true,
|
222
|
+
params: { limit: 100 } }).and_call_original
|
223
223
|
|
224
224
|
expect(DHC).to receive(:request)
|
225
225
|
.with([{ url: 'http://datastore/customers/1/contracts',
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dhs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- https://github.com/DePayFi/dhs/graphs/contributors
|
@@ -580,7 +580,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
580
580
|
version: '0'
|
581
581
|
requirements:
|
582
582
|
- Ruby >= 2.7.2
|
583
|
-
rubygems_version: 3.2.
|
583
|
+
rubygems_version: 3.2.3
|
584
584
|
signing_key:
|
585
585
|
specification_version: 4
|
586
586
|
summary: 'REST services accelerator: Rails gem providing an easy, active-record-like
|