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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a10c78843683a030051a42d197d7aa67c4059fd4
4
- data.tar.gz: 5045736b7b892177fe963064c0957992a63393a3
3
+ metadata.gz: da55563df785b1204ed54eabcde0a439974921b2
4
+ data.tar.gz: 072ba7af6dc2ee11b8930f5c5f0f5d053b38637e
5
5
  SHA512:
6
- metadata.gz: 3adb9d073c6ed0b4e6aebff27166430e4975e25d107e8549adf98192ff46a82cafd8c83432b73d4752470d688883a92f3fcb14c7d15560271015e0ca3cd27371
7
- data.tar.gz: d8902b4f3a053bfc7b3c957c0f4cacb044b55770fd31bb22a6a5ab99c13383dee65f55ab647736732ec914afcc7630e077317bef8ffdd5572da6648542843456
6
+ metadata.gz: 1aeac8b32d5830d361918c78d54738caac25920254645592cbd8e52351c5a43c6eed213982aedb47242d5d74680785e28cc0e8da018144a102916b45c5f032db
7
+ data.tar.gz: 5e3209835678d1232d2af908e8fdc70938f3c1a0d69a6808d335020a966c065994a5d3a1e569993f480857fda29d0a2f496c0ef9192498717678c32afc931710
@@ -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
- description = begin
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
@@ -1,3 +1,3 @@
1
1
  module Outreach
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
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.2
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-22 00:00:00.000000000 Z
11
+ date: 2016-09-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler