outreach 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/outreach/errors.rb +19 -6
- data/lib/outreach/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da55563df785b1204ed54eabcde0a439974921b2
|
4
|
+
data.tar.gz: 072ba7af6dc2ee11b8930f5c5f0f5d053b38637e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1aeac8b32d5830d361918c78d54738caac25920254645592cbd8e52351c5a43c6eed213982aedb47242d5d74680785e28cc0e8da018144a102916b45c5f032db
|
7
|
+
data.tar.gz: 5e3209835678d1232d2af908e8fdc70938f3c1a0d69a6808d335020a966c065994a5d3a1e569993f480857fda29d0a2f496c0ef9192498717678c32afc931710
|
data/lib/outreach/errors.rb
CHANGED
@@ -5,16 +5,29 @@ module Outreach
|
|
5
5
|
class Unauthorized < StandardError; end
|
6
6
|
|
7
7
|
def check_for_error(status_code, response_body)
|
8
|
+
response_hash = JSON.parse(response_body)
|
9
|
+
if response_hash['errors'].present? &&
|
10
|
+
response_hash['errors']['status'].present?
|
11
|
+
status_code = response_hash['errors']['status']
|
12
|
+
end
|
13
|
+
|
8
14
|
# raise error if status code isn't 200
|
9
15
|
case status_code.to_i
|
10
16
|
when 401
|
11
|
-
|
12
|
-
JSON.parse(response_body).fetch("error_description")
|
13
|
-
rescue
|
14
|
-
"Unauthorized"
|
15
|
-
end
|
16
|
-
raise Unauthorized.new(description)
|
17
|
+
unauthorized_error(response_body)
|
17
18
|
end
|
18
19
|
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def unauthorized_error(response_body)
|
24
|
+
description = begin
|
25
|
+
JSON.parse(response_body).fetch("error_description")
|
26
|
+
rescue
|
27
|
+
"Unauthorized"
|
28
|
+
end
|
29
|
+
raise Unauthorized.new(description)
|
30
|
+
end
|
31
|
+
|
19
32
|
end
|
20
33
|
end
|
data/lib/outreach/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: outreach
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris O'Sullivan
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|