fmrest 0.4.0 → 0.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: 7eb7073bb86836108750364857226e2ce6eaac9c88348c74b0c82ecb446f5d4e
4
- data.tar.gz: 7e5d6bee538d00fce9feea4f0666014853fe4feba67ea11ff1841809a7d6c577
3
+ metadata.gz: 368ed06195288490b1388c451b00bb33f5c19e526348422a3760a14902459d76
4
+ data.tar.gz: a445ef1bd8ef708b6aea2c5f8c2362f77e8c1afbd80bb6ef1d354c669ef8c9f6
5
5
  SHA512:
6
- metadata.gz: 2e59d89d5829d94566be859060c10e88c875b3298bdd15dbc61b289df64b69534f3d294528b6b3a697b1583cf149472030fcc370eee97ddd0af0d03804520bec
7
- data.tar.gz: 057a8bca299892de5d4415b2c67bec71a15778c8e80567726e44c9413bd7b75cf7d422bf86626b24a0021b2c5ca9eb7e43cf4eb486217e176133c19d3a509554
6
+ metadata.gz: 1d2e8cb78c9a232f8ec13dde7ad3407f5dbfc14c49c0e5aadeb7a940c1fe07f14e919832b53841e4ac054f81c74a64fb7721614218c342835a2274c3b187aa96
7
+ data.tar.gz: 9695ef91a8eef005420c0003e62eb1712eda8f11667e87f345c311b008c712113b4ff52be31e1fc207237efc7e7279d5952b2d0b2ed3b4a26a2a8aa55ad38638
@@ -1,5 +1,11 @@
1
1
  ## Changelog
2
2
 
3
+ ### 0.4.1
4
+
5
+ * Prevent raising an exception when a /\_find request yields no results
6
+ ([#33](https://github.com/beezwax/fmrest-ruby/issues/33) and
7
+ [#34](https://github.com/beezwax/fmrest-ruby/issues/34))
8
+
3
9
  ### 0.4.0
4
10
 
5
11
  * Implement ability to set limit and offset for portals
@@ -18,6 +18,7 @@ module FmRest
18
18
  class APIError::AccountError < APIError; end # error codes 200..299
19
19
  class APIError::LockError < APIError; end # error codes 300..399
20
20
  class APIError::ParameterError < APIError; end # error codes 400..499
21
+ class APIError::NoMatchingRecordsError < APIError::ParameterError; end
21
22
  class APIError::ValidationError < APIError; end # error codes 500..599
22
23
  class APIError::SystemError < APIError; end # error codes 800..899
23
24
  class APIError::ScriptError < APIError; end # error codes 1200..1299
@@ -13,6 +13,10 @@ module FmRest
13
13
  class_attribute :default_limit, instance_accessor: false, instance_predicate: false
14
14
 
15
15
  class_attribute :default_sort, instance_accessor: false, instance_predicate: false
16
+
17
+ # Whether to raise an FmRest::APIError::NoMatchingRecordsError when a
18
+ # _find request has no results
19
+ class_attribute :raise_on_no_matching_records, instance_accessor: false, instance_predicate: false
16
20
  end
17
21
 
18
22
  class_methods do
@@ -42,7 +46,16 @@ module FmRest
42
46
  end
43
47
 
44
48
  previous, self.current_scope = current_scope, scope
45
- current_scope.has_query? ? scoped_request(:post) : super
49
+
50
+ # The DAPI returns a 401 "No records match the request" error when
51
+ # nothing matches a _find request, so we need to catch it in order
52
+ # to provide sane behavior (i.e. return an empty resultset)
53
+ begin
54
+ current_scope.has_query? ? scoped_request(:post) : super
55
+ rescue FmRest::APIError::NoMatchingRecordsError => e
56
+ raise e if raise_on_no_matching_records
57
+ ::Spyke::Result.new({})
58
+ end
46
59
  ensure
47
60
  self.current_scope = previous
48
61
  end
@@ -18,7 +18,9 @@ module FmRest
18
18
  102..199 => APIError::ResourceMissingError,
19
19
  200..299 => APIError::AccountError,
20
20
  300..399 => APIError::LockError,
21
- 400..499 => APIError::ParameterError,
21
+ 400 => APIError::ParameterError,
22
+ 401 => APIError::NoMatchingRecordsError,
23
+ 402..499 => APIError::ParameterError,
22
24
  500..599 => APIError::ValidationError,
23
25
  800..899 => APIError::SystemError,
24
26
  1200..1299 => APIError::ScriptError,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FmRest
4
- VERSION = "0.4.0"
4
+ VERSION = "0.4.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fmrest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pedro Carbajal
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-10-10 00:00:00.000000000 Z
11
+ date: 2019-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday