fulfil_api 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6f8ba18240c4cbc9a772505388ca2cc1c86a5afbe6b68e28c2244d622cc2d827
4
- data.tar.gz: a6c6864e7b9753cfb0e92c72940effc3b6b9d14845616941e63ea909c2ffe042
3
+ metadata.gz: cb30711ccea7942e991ecf77dcc3c25290752c09d83674c822c018d4d8c7fcde
4
+ data.tar.gz: 82e58d3494b0b0a8d73d7ff3c4bd2d96fb79b599f3588bda3b1c4035fd22fcf0
5
5
  SHA512:
6
- metadata.gz: 1a6942e7212111fc5a0f62aed933a9b290c21d495588894487271623f6f2fcb767fbaaf5ccca4aa941063903934d676207af00b56ea705c32c2ee59d542f5e68
7
- data.tar.gz: 94a91fc36310e2ad898605972262f94762c075754c74c3711762fc83400ba111b19585bd97c655dc9092dd5ab1e9d6bce6c6d465d882cbc308c20af1d0818895
6
+ metadata.gz: 4f2ac1b0f4d06d7d55cbf0a2f69cf5fd566ad514439a983270d0f14e1235c38a2c258b3f97dccd4589c81d4f1942309fa4eae5ce9e5c719b29ee104555e2692a
7
+ data.tar.gz: ca9fd568544fb12b16d8a656667c7ca09d8c1583d8e29324fa8d9ed924a5d380fee2ff7fd7a435b987f744c561a278bea657f5f538331a461c8288265c7f4430
@@ -21,6 +21,18 @@ module FulfilApi
21
21
  where(conditions).limit(1).first
22
22
  end
23
23
 
24
+ # Finds the first resource that matches the given conditions and raises
25
+ # when no resource is found.
26
+ #
27
+ # @see .find_by
28
+ #
29
+ # @param conditions [Array<String, String, String>] The filter conditions as required by Fulfil.
30
+ # @return [FulfilApi::Resource] The first resource that matches the conditions
31
+ # @raise [FulfilApi::Resource::NotFound]
32
+ def find_by!(conditions)
33
+ find_by(conditions) || raise(NotFound, "Unable to find #{model_name} where #{conditions}")
34
+ end
35
+
24
36
  # Limits the number of resources returned by Fulfil's API. This is useful when only
25
37
  # a specific number of resources are needed.
26
38
  #
@@ -8,6 +8,7 @@ module FulfilApi
8
8
  include Persistable
9
9
 
10
10
  class ModelNameMissing < Error; end
11
+ class NotFound < Error; end
11
12
 
12
13
  def initialize(attributes = {})
13
14
  attributes.deep_stringify_keys!
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FulfilApi
4
- VERSION = "0.1.4"
4
+ VERSION = "0.1.5"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fulfil_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Vermaas
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-11-05 00:00:00.000000000 Z
11
+ date: 2024-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -121,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
121
  - !ruby/object:Gem::Version
122
122
  version: '0'
123
123
  requirements: []
124
- rubygems_version: 3.5.11
124
+ rubygems_version: 3.5.18
125
125
  signing_key:
126
126
  specification_version: 4
127
127
  summary: A HTTP client to interact the Fulfil.io API