outreach 0.0.1 → 0.0.2

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: 72f658d033d57bbdbf06abb68f300d63f660260a
4
- data.tar.gz: 698a2d0171428bb54be9e047761540ef44544b20
3
+ metadata.gz: 896ed42c45cb4f5764a88236b9fe427e3b1a0aa5
4
+ data.tar.gz: a957060f07a0a383da1c757ffff61d4ad11d15b6
5
5
  SHA512:
6
- metadata.gz: 2b3be014ee575b6e5f3f682171c8fd14f41ab74ddb7bd9e364fe29bbedb18b9c73ed4dc7c32e1a462df012cdcc4e6c7a0fcd8b933ad172d5dd54282dc49e0a61
7
- data.tar.gz: 43918793ef5f573a5bae628231880f7db7a817644c743b4abe84f3085b48c3219c45411c54b28e91255af2343750a1c67014a6d8303cfaaee4ef77a1791b9fd5
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[:access_token]
11
- @refresh_token = attrs[:refresh_token]
12
- @expires_in = attrs[:expires_in]
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
 
@@ -14,4 +14,4 @@ module Outreach
14
14
  Request.new(@api_token)
15
15
  end
16
16
  end
17
- end
17
+ end
@@ -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
- raise Unauthorized.new("Authorization failed")
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
@@ -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)
@@ -1,3 +1,3 @@
1
1
  module Outreach
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
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.0.1
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-04 00:00:00.000000000 Z
11
+ date: 2016-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler