checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
---
2
2
SHA256:
3
- metadata.gz: 5bc312953451d463212c108da2b2557c60d6d3b96cbadb3a6f2d5b9479fef7d2
4
- data.tar.gz: daaf65eb95129d4cc7125f60f4fc084d542d4dc523445ecdec9405361449abf7
3
+ metadata.gz: a0603fe16b7652a523413e6d25e2384d25c7b24fa019a06f01faf942d2867251
4
+ data.tar.gz: a37a9df471df6171b84191114eb773ced11517062e47ab9c109225293fdc4a20
5
5
SHA512:
6
- metadata.gz: bf79f5372a6fdcecd3f80e33799a16605851836734d4ccc6cc1ced217476ae929860a01c55633d0189c5b1a52fa0c25ba8ab5b55ec10ee4062c9f9011c7ce517
7
- data.tar.gz: d3b30de222e2dc441158eeee36cacc88515f0097e215fcd313369169758118f2d33e9feda12aab1ea26cf802b4500758a4632e29fb0d568baec235ef64c70e3b
6
+ metadata.gz: 913153ddc8209455f3823f3b76dc0d8abdf71d0d829cda670de37ca961d2320dc852ea44d316785034a32475bd07021b296447375ffe153af863c3bdf8ab6830
7
+ data.tar.gz: 1b907623d421d6c92a76f54b00a2ea76634eb133542aa64dba0a9a7a00af944019df0f0d18645a8921a2127ccfbb1554eb6a53d26d2c62a766f53d86141882fd
data/.github/workflows/build.yml CHANGED
@@ -1,4 +1,6 @@
1
1
name: Build
2
+ env:
3
+ BREATHE_API_KEY: "some-api-key"
2
4
3
5
on: [push, pull_request]
4
6
data/.gitignore CHANGED
@@ -10,3 +10,4 @@
10
10
# rspec failure tracking
11
11
.rspec_status
12
12
/.env
13
+ /Gemfile.lock
data/CHANGELOG.md CHANGED
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
4
4
5
5
The format is based on [Keep a Changelog]
6
6
7
+ [0.1.2]
8
+
9
+ - Raise an error when API key is incorrect
10
+ - Fix a bug where the client passed the wrong variable to fetch a resource
11
+
7
12
[0.1.1]
8
13
9
14
- Fix typo on client that prevented absences from being returned
@@ -12,6 +17,7 @@ The format is based on [Keep a Changelog]
12
17
13
18
- Allow listing of absences
14
19
15
- [0.1.0]: https://github.com/dxw/breathe_ruby/releases/tag/0.1.0
20
+ [0.1.1]: https://github.com/dxw/breathe_ruby/releases/tag/0.1.2
16
21
[0.1.1]: https://github.com/dxw/breathe_ruby/releases/tag/0.1.1
22
+ [0.1.0]: https://github.com/dxw/breathe_ruby/releases/tag/0.1.0
17
23
[keep a changelog]: https://keepachangelog.com/en/1.0.0/
data/Gemfile.lock DELETED
@@ -1,82 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- breathe (0.1.0)
5
- faraday (~> 0.17.0)
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- addressable (2.7.0)
11
- public_suffix (>= 2.0.2, < 5.0)
12
- ast (2.4.0)
13
- coderay (1.1.2)
14
- crack (0.4.3)
15
- safe_yaml (~> 1.0.0)
16
- diff-lcs (1.3)
17
- dotenv (2.7.5)
18
- faraday (0.17.0)
19
- multipart-post (>= 1.2, < 3)
20
- hashdiff (1.0.0)
21
- jaro_winkler (1.5.4)
22
- method_source (0.9.2)
23
- multipart-post (2.1.1)
24
- parallel (1.18.0)
25
- parser (2.6.5.0)
26
- ast (~> 2.4.0)
27
- pry (0.12.2)
28
- coderay (~> 1.1.0)
29
- method_source (~> 0.9.0)
30
- public_suffix (4.0.1)
31
- rainbow (3.0.0)
32
- rake (10.5.0)
33
- rspec (3.9.0)
34
- rspec-core (~> 3.9.0)
35
- rspec-expectations (~> 3.9.0)
36
- rspec-mocks (~> 3.9.0)
37
- rspec-core (3.9.0)
38
- rspec-support (~> 3.9.0)
39
- rspec-expectations (3.9.0)
40
- diff-lcs (>= 1.2.0, < 2.0)
41
- rspec-support (~> 3.9.0)
42
- rspec-mocks (3.9.0)
43
- diff-lcs (>= 1.2.0, < 2.0)
44
- rspec-support (~> 3.9.0)
45
- rspec-support (3.9.0)
46
- rubocop (0.75.1)
47
- jaro_winkler (~> 1.5.1)
48
- parallel (~> 1.10)
49
- parser (>= 2.6)
50
- rainbow (>= 2.2.2, < 4.0)
51
- ruby-progressbar (~> 1.7)
52
- unicode-display_width (>= 1.4.0, < 1.7)
53
- rubocop-performance (1.5.0)
54
- rubocop (>= 0.71.0)
55
- ruby-progressbar (1.10.1)
56
- safe_yaml (1.0.5)
57
- standard (0.1.5)
58
- rubocop (~> 0.75.0)
59
- rubocop-performance (~> 1.5.0)
60
- unicode-display_width (1.6.0)
61
- vcr (5.0.0)
62
- webmock (3.7.6)
63
- addressable (>= 2.3.6)
64
- crack (>= 0.3.2)
65
- hashdiff (>= 0.4.0, < 2.0.0)
66
-
67
- PLATFORMS
68
- ruby
69
-
70
- DEPENDENCIES
71
- breathe!
72
- bundler (~> 2.0)
73
- dotenv (~> 2.7.5)
74
- pry (~> 0.12.2)
75
- rake (~> 10.0)
76
- rspec (~> 3.0)
77
- standard (~> 0.1.5)
78
- vcr (~> 5.0)
79
- webmock (~> 3.7.6)
80
-
81
- BUNDLED WITH
82
- 2.0.2
data/lib/breathe.rb CHANGED
@@ -6,5 +6,6 @@ require "breathe/absences"
6
6
7
7
module Breathe
8
8
class Error < StandardError; end
9
+ class AuthenticationError < StandardError; end
9
10
# Your code goes here...
10
11
end
data/lib/breathe/client.rb CHANGED
@@ -7,7 +7,7 @@ module Breathe
7
7
end
8
8
9
9
def absences
10
- @_absences ||= Absences.new(connection)
10
+ @_absences ||= Absences.new(self)
11
11
end
12
12
13
13
def get(url, url_opts = {})
@@ -20,6 +20,7 @@ module Breathe
20
20
21
21
def connection
22
22
Faraday.new(url: BASE_URL) do |faraday|
23
+ faraday.use Faraday::Response::RaiseError
23
24
faraday.adapter Faraday.default_adapter
24
25
end
25
26
end
@@ -30,6 +31,13 @@ module Breathe
30
31
req.headers["Content-Type"] = "application/json"
31
32
req.headers["X-Api-Key"] = api_key
32
33
end
34
+ rescue Faraday::ClientError => e
35
+ case e.message
36
+ when /401/
37
+ raise Breathe::AuthenticationError, "The BreatheHR API returned a 401 error - are you sure you've set the correct API key?"
38
+ else
39
+ raise e
40
+ end
33
41
end
34
42
end
35
43
end
data/lib/breathe/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
module Breathe
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
--- !ruby/object:Gem::Specification
2
2
name: breathe
3
3
version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
platform: ruby
6
6
authors:
7
7
- Stuart Harrison
@@ -151,7 +151,6 @@ files:
151
151
- CHANGELOG.md
152
152
- CODE_OF_CONDUCT.md
153
153
- Gemfile
154
- - Gemfile.lock
155
154
- LICENSE.txt
156
155
- README.md
157
156
- Rakefile