dhs 1.4.0 → 1.4.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c31dbca2778853f9bafb3a74e2c7ef830d3897c0caa78b66e5bb58203fc8bb11
4
- data.tar.gz: 8e5968134c395c0b4e6196506ef5502f5941f68754423bc885bc536a44c2ba33
3
+ metadata.gz: 690186fffb1221bbc432b5a502bdfecb895b1f117e42602e6bef6b2c55cd7bd1
4
+ data.tar.gz: 7f544c63db8a4db092a6c3980b3cb2f437879876db145a6ac7d8c6cfc7647a05
5
5
  SHA512:
6
- metadata.gz: 54e1c9ec3c0b71566a8b6831690250d0eecc00f00155617dc39873c20d49a26ef57051ae04d7d3a1bbb3733f75fc3ccc0024b96c3b4bd086dafe48a1634cb8cf
7
- data.tar.gz: 1bea7f70ccd0cba8dc488604d5f4a668d1bc602a2cb30d19058b195a17b2d9f1aaa5d72e21286e910570a89be0e78c25adac4bb45186a6f3f11ffcc81128b39c
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.length.zero?
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.length.zero?
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)
@@ -3,7 +3,7 @@
3
3
  class DHS::Pagination::NextOffset < DHS::Pagination::Base
4
4
 
5
5
  DEFAULT_OFFSET = 0
6
-
6
+
7
7
  def total
8
8
  data._raw.dig(*_record.items_key).count || 0
9
9
  end
@@ -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.length.zero?
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DHS
4
- VERSION = '1.4.0'
4
+ VERSION = '1.4.1'
5
5
  end
@@ -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
- def stub_api_request(items: [], offset: nil, next_offset:)
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
- cache_expires_in: 1.day,
21
- retry: 2,
22
- cache: true,
23
- url: 'backend/v2/feedbacks/1'
24
- ).and_call_original
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
- all: true,
222
- params: { limit: 100 }).and_call_original
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.0
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.33
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