outreach 0.0.1 → 0.0.2
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 +4 -4
- data/lib/outreach/authorization.rb +4 -4
- data/lib/outreach/client.rb +1 -1
- data/lib/outreach/errors.rb +7 -2
- data/lib/outreach/request.rb +1 -1
- 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: 896ed42c45cb4f5764a88236b9fe427e3b1a0aa5
|
4
|
+
data.tar.gz: a957060f07a0a383da1c757ffff61d4ad11d15b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 08d825b753f669009e5bd3ffc1952e8bc4bacd894e754f00a2ed7cc41ee874b8646bf72ef2974ca7fa1030b3a12a664c9fdce0c503b92caf1bc822ecaae0fae0
|
7
|
+
data.tar.gz: ba92fcf9533e4e3689d612692dd4b97d9d5c8f6fd8f030e933f5840d361932ced90f6a1134097440081d5ff4775d1f48a926e2c5790bd6c2ee2866d0143eecee
|
@@ -7,9 +7,9 @@ module Outreach
|
|
7
7
|
attr_reader :token, :refresh_token, :expires_in
|
8
8
|
|
9
9
|
def initialize(attrs)
|
10
|
-
@token = attrs[
|
11
|
-
@refresh_token = attrs[
|
12
|
-
@expires_in = attrs[
|
10
|
+
@token = attrs['access_token']
|
11
|
+
@refresh_token = attrs['refresh_token']
|
12
|
+
@expires_in = attrs['expires_in']
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.authorization_url
|
@@ -31,7 +31,7 @@ module Outreach
|
|
31
31
|
grant_type: 'authorization_code',
|
32
32
|
code: authorization_code
|
33
33
|
}
|
34
|
-
response = Request.new.post(API_URL, params)
|
34
|
+
response = Outreach::Request.new.post(API_URL, params)
|
35
35
|
new(response)
|
36
36
|
end
|
37
37
|
|
data/lib/outreach/client.rb
CHANGED
data/lib/outreach/errors.rb
CHANGED
@@ -4,11 +4,16 @@ module Outreach
|
|
4
4
|
module Errors
|
5
5
|
class Unauthorized < StandardError; end
|
6
6
|
|
7
|
-
def check_for_error(status_code)
|
7
|
+
def check_for_error(status_code, response_body)
|
8
8
|
# raise error if status code isn't 200
|
9
9
|
case status_code.to_i
|
10
10
|
when 401
|
11
|
-
|
11
|
+
description = begin
|
12
|
+
JSON.parse(response_body).fetch("error_description")
|
13
|
+
rescue
|
14
|
+
"Unauthorized"
|
15
|
+
end
|
16
|
+
raise Unauthorized.new(description)
|
12
17
|
end
|
13
18
|
end
|
14
19
|
end
|
data/lib/outreach/request.rb
CHANGED
@@ -31,7 +31,7 @@ module Outreach
|
|
31
31
|
private
|
32
32
|
|
33
33
|
def parse_response(response, response_format=:json)
|
34
|
-
check_for_error(response.response.code)
|
34
|
+
check_for_error(response.response.code, response.body)
|
35
35
|
display_debug(response.body)
|
36
36
|
if response_format == :json
|
37
37
|
JSON.parse(response.body.to_s)
|
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.0.
|
4
|
+
version: 0.0.2
|
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-04-
|
11
|
+
date: 2016-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|