fulfil-io 0.4.2 → 0.4.3

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: 35c4c9a9a5c6e89dc1963296ecb2d2bef838a93fe67f4d16b2cc6d1234870787
4
- data.tar.gz: 54030ba2a9cffd08d0f720a195cb29196a8bc38d6860fc7ff30e59b3328f97a9
3
+ metadata.gz: d1e18bf38ef0d20058704b439d3b633cd2a2d6c36d6eb3498764473ecdc18542
4
+ data.tar.gz: ef37d25469b610f6d1d7ef4e1ef41e681b514f39d147e652338464fd9a2fb977
5
5
  SHA512:
6
- metadata.gz: 1b73ec09fc10b8183ed80d0f60bfe8911394c8d8e624a28e8d4aa77889a2912673876faf5af204ada89ba87ee9fff32796fb8b43a2b6825c1eb91eaf3773fb47
7
- data.tar.gz: a0251fe789efa3744c331e5b590f64a0ce6dd100b204e0413b98d925733c99fda0be8ba2d5e8fb7e7fc2793a1f26b25030b58bdab61ee69bf3b68c59154c9582
6
+ metadata.gz: d33dc2d8553c14c08284d6823bd0285c28bb168785e9c9885cfd9718e8233d804860348cd7ea2bcec56141de976153bd605dfabab4ce73ce958a4935abc9a17d
7
+ data.tar.gz: 634d58e4e9780873f4ff9c1823ab8fb1a08de125e6906ed48d50773b838015e7ea4cf8abd65ee3df26f035eab6a1131ab75a56511b3f55400e2b67f17a7b42f0
@@ -1,3 +1,8 @@
1
+ ## 0.4.3
2
+
3
+ * Add Client errors for more granular handling.
4
+ * Send along info when a `NotAuthorizedError` is raised.
5
+
1
6
  ## 0.4.2
2
7
 
3
8
  * Raise an `UnhandledTypeError` and reveal the offender.
@@ -6,7 +11,8 @@
6
11
 
7
12
  ## 0.4.1
8
13
 
9
- * @cdmwebs screwed up the release process, so this is a tiny bump to fix. No code changes.
14
+ * @cdmwebs screwed up the release process, so this is a tiny bump to fix. No
15
+ code changes.
10
16
 
11
17
  ## 0.4.0
12
18
 
@@ -18,18 +24,16 @@
18
24
 
19
25
  ## 0.2.0
20
26
 
21
- - Make token optional and allow specifying headers at least for enabling authentication via 'X-API-KEY' header
22
- , because initially implemented in 0.1.0 bearer auth isn't working.
23
-
24
- - Fix Query `build_search_term` and `build_exclude_term` to be compatible with Ruby < 2.4, analyzing value for 'Fixnum
25
- ' class.
26
-
27
- - Fix the gem's name in gemspec to 'fulfil-io', as registered at RubyGems.
28
-
29
- - Remove Rake version constraint from gemspec.
30
-
31
- - Add Gemfile.lock to .gitignore and remove it from git-tree - it shouldn't be stored in git for a gem.
27
+ * Make token optional and allow specifying headers at least for enabling
28
+ authentication via 'X-API-KEY' header , because initially implemented in
29
+ 0.1.0 bearer auth isn't working.
30
+ * Fix Query `build_search_term` and `build_exclude_term` to be compatible with
31
+ Ruby < 2.4, analyzing value for 'Fixnum ' class.
32
+ * Fix the gem's name in gemspec to 'fulfil-io', as registered at RubyGems.
33
+ * Remove Rake version constraint from gemspec.
34
+ * Add Gemfile.lock to .gitignore and remove it from git-tree - it shouldn't be
35
+ stored in git for a gem.
32
36
 
33
37
  ## 0.1.0
34
38
 
35
- * Initial gem release
39
+ * Initial gem release.
@@ -10,6 +10,11 @@ module Fulfil
10
10
  OAUTH_TOKEN = ENV['FULFIL_TOKEN']
11
11
 
12
12
  class Client
13
+ class NotAuthorizedError < StandardError; end
14
+ class UnknownHTTPError < StandardError; end
15
+ class ConnectionError < StandardError; end
16
+ class ResponseError < StandardError; end
17
+
13
18
  def initialize(subdomain: SUBDOMAIN, token: OAUTH_TOKEN, headers: { 'X-API-KEY' => API_KEY }, debug: false)
14
19
  @subdomain = subdomain
15
20
  @token = token
@@ -105,19 +110,20 @@ module Fulfil
105
110
  if response.status.ok? || response.status.created?
106
111
  response.parse
107
112
  elsif response.code == 401
108
- raise StandardError, 'Not authorized'
113
+ error = response.parse
114
+ raise NotAuthorizedError, "Not authorized: #{error['error']}: #{error['error_description']}"
109
115
  else
110
116
  puts response.body.to_s
111
117
  raise Error, 'Error encountered while processing response:'
112
118
  end
113
119
  rescue HTTP::Error => e
114
120
  puts e
115
- raise Error, 'Unhandled HTTP error encountered'
121
+ raise UnknownHTTPError, 'Unhandled HTTP error encountered'
116
122
  rescue HTTP::ConnectionError => e
117
123
  puts "Couldn't connect"
118
- raise Error, "Can't connect to #{base_url}"
124
+ raise ConnectionError, "Can't connect to #{base_url}"
119
125
  rescue HTTP::ResponseError => ex
120
- raise Error, "Can't process response: #{ex}"
126
+ raise ResponseError, "Can't process response: #{ex}"
121
127
  []
122
128
  end
123
129
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Fulfil
4
- VERSION = '0.4.2'
4
+ VERSION = '0.4.3'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fulfil-io
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Moore
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-11-29 00:00:00.000000000 Z
12
+ date: 2020-11-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: http