lhs 15.2.3 → 15.2.4

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
  SHA1:
3
- metadata.gz: ab8ba71d671d0e6b04f578b81bd6988a3caa5b28
4
- data.tar.gz: 17222267f2563042bb2975fdc2c778662d1594db
3
+ metadata.gz: 065d4f6623803cb198313fad6600902190ee982a
4
+ data.tar.gz: f93e91649e7f464da69cdddb63e2ddd11f9ca204
5
5
  SHA512:
6
- metadata.gz: 79414764f2beed745b3dcaa21cd9d9f099c432715080a54cfa0463d9c2d91ea4ccc55ac098353df21234b60a2661463152c984669b0590154c62aab8ac010757
7
- data.tar.gz: 13cc0ab0000e9fde6e731835b8343a434dd4e2d64cd70f3a4a3c9ef6cdf5d707853e0dea6956b108297dfd804af5d7d98f99f317691fe5dea547c972dccbd9d0
6
+ metadata.gz: b3f6b6026982ef4b1582395758e536e2c01b0e7e987063ce1872a493466999d341bbe664717c41fea6c5de031c6731c29ce6c57b4f0cd68fce7ea2e0bdfc013d
7
+ data.tar.gz: 22c1b2e5d8b62fa1b570143ee8e532b523e38f7e425a0aca5dd5d14a3a2e5c61b207bab261d376ff0b0b75f6b82ec3b43bb63ff89c6e4b17f67088d191d30f0a
@@ -23,7 +23,7 @@ class LHS::Record
23
23
  def _find_by(params, options = {})
24
24
  raise(LHS::Unprocessable.new, 'Cannot find Record without an ID') if params.any? && params.all? { |_, value| value.blank? }
25
25
  options ||= {}
26
- params = params.dup.merge(limit: 1).merge(options.fetch(:params, {}))
26
+ params = params.dup.merge(limit_key(:parameter) => 1).merge(options.fetch(:params, {}))
27
27
  data = request(options.merge(params: params))
28
28
  if data && data._proxy.is_a?(LHS::Collection)
29
29
  data.first || raise(LHC::NotFound.new('No item was found.', data._request.response))
data/lib/lhs/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module LHS
2
- VERSION = '15.2.3'
2
+ VERSION = '15.2.4'
3
3
  end
@@ -3,7 +3,13 @@ require 'rails_helper'
3
3
  describe LHS::Record do
4
4
  before(:each) do
5
5
  class Business < LHS::Record
6
- configuration items_key: [:response, :businesses], limit_key: [:response, :max], pagination_key: [:response, :offset], total_key: [:response, :count], pagination_strategy: :offset
6
+ configuration(
7
+ items_key: [:response, :businesses],
8
+ total_key: [:response, :count],
9
+ limit_key: { body: [:response, :max] },
10
+ pagination_key: { body: [:response, :offset] },
11
+ pagination_strategy: :offset
12
+ )
7
13
  endpoint 'http://uberall/businesses'
8
14
  end
9
15
  end
@@ -42,6 +42,25 @@ describe LHS::Record do
42
42
  it 'returns nil if empty id' do
43
43
  expect { Record.find_by(id: '') }.to raise_error LHS::Unprocessable
44
44
  end
45
+
46
+ context 'when record has custom configurations for limit_key' do
47
+ before :each do
48
+ class Record < LHS::Record
49
+ endpoint '{+datastore}/feedbacks/{id}'
50
+ configuration(
51
+ limit_key: { body: %i[response max], parameter: :max }
52
+ )
53
+ end
54
+ end
55
+
56
+ it 'finds a single record with max parameter' do
57
+ stub_request(:get, "#{datastore}/feedbacks/z12f-3asm3ngals?max=1")
58
+ .to_return(status: 200, body: load_json(:feedback))
59
+ record = Record.find_by(id: 'z12f-3asm3ngals')
60
+ expect(record.source_id).to be_kind_of String
61
+ expect(record).to be_kind_of Record
62
+ end
63
+ end
45
64
  end
46
65
 
47
66
  context 'find_by!' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lhs
3
3
  version: !ruby/object:Gem::Version
4
- version: 15.2.3
4
+ version: 15.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - https://github.com/local-ch/lhs/graphs/contributors