facebook_client 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/graph.rb +15 -3
  2. metadata +14 -3
data/lib/graph.rb CHANGED
@@ -2,6 +2,8 @@ require 'faraday'
2
2
 
3
3
  module FacebookClient
4
4
 
5
+ class ResponseError < StandardError; end
6
+
5
7
  class Graph
6
8
 
7
9
  attr_reader :access_token
@@ -18,12 +20,22 @@ module FacebookClient
18
20
  def get(path, params={})
19
21
  params = params.stringify_keys
20
22
  params['access_token'] = @access_token
21
- resp = connection.run_request(:get, path, nil, {}) do |request|
23
+ response = connection.run_request(:get, path, nil, {}) do |request|
22
24
  request.params.update(params)
23
25
  end
24
- resp.body
26
+ response = parse_response(response)
27
+ return response
25
28
  end
26
-
29
+
30
+ # {"error"=>{"message"=>"Error processing access token.", "type"=>"OAuthException"}}
31
+ def parse_response(response)
32
+ body = response.body
33
+ if body.is_a?(Hash) and body.has_key?('error')
34
+ raise ResponseError, "#{body['error']['message']}"
35
+ end
36
+ return body
37
+ end
38
+
27
39
  def connection
28
40
  @connection ||= Faraday::Connection.new(:url => Base::GRAPH_URL) do |builder|
29
41
  builder.adapter :net_http
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: facebook_client
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 27
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 0
8
- - 1
9
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
10
11
  platform: ruby
11
12
  authors:
12
13
  - David Crockett
@@ -21,9 +22,11 @@ dependencies:
21
22
  name: faraday
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - "="
26
28
  - !ruby/object:Gem::Version
29
+ hash: 5
27
30
  segments:
28
31
  - 0
29
32
  - 4
@@ -35,9 +38,11 @@ dependencies:
35
38
  name: yajl-ruby
36
39
  prerelease: false
37
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
38
42
  requirements:
39
43
  - - "="
40
44
  - !ruby/object:Gem::Version
45
+ hash: 15
41
46
  segments:
42
47
  - 0
43
48
  - 7
@@ -49,9 +54,11 @@ dependencies:
49
54
  name: rack
50
55
  prerelease: false
51
56
  requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
52
58
  requirements:
53
59
  - - "="
54
60
  - !ruby/object:Gem::Version
61
+ hash: 21
55
62
  segments:
56
63
  - 1
57
64
  - 0
@@ -83,23 +90,27 @@ rdoc_options: []
83
90
  require_paths:
84
91
  - lib
85
92
  required_ruby_version: !ruby/object:Gem::Requirement
93
+ none: false
86
94
  requirements:
87
95
  - - ">="
88
96
  - !ruby/object:Gem::Version
97
+ hash: 3
89
98
  segments:
90
99
  - 0
91
100
  version: "0"
92
101
  required_rubygems_version: !ruby/object:Gem::Requirement
102
+ none: false
93
103
  requirements:
94
104
  - - ">="
95
105
  - !ruby/object:Gem::Version
106
+ hash: 3
96
107
  segments:
97
108
  - 0
98
109
  version: "0"
99
110
  requirements: []
100
111
 
101
112
  rubyforge_project:
102
- rubygems_version: 1.3.6
113
+ rubygems_version: 1.3.7
103
114
  signing_key:
104
115
  specification_version: 3
105
116
  summary: Facebook Client