mogli 0.0.18 → 0.0.19
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/mogli.rb +1 -0
- data/lib/mogli/app_client.rb +27 -0
- data/lib/mogli/authenticator.rb +5 -1
- data/lib/mogli/client.rb +11 -3
- data/lib/mogli/model.rb +3 -0
- metadata +5 -4
data/lib/mogli.rb
CHANGED
@@ -0,0 +1,27 @@
|
|
1
|
+
require "mogli/client/event"
|
2
|
+
require "mogli/client/user"
|
3
|
+
|
4
|
+
module Mogli
|
5
|
+
class AppClient < Client
|
6
|
+
attr_accessor :application_id
|
7
|
+
|
8
|
+
def subscription_url
|
9
|
+
"https://graph.facebook.com/#{application_id}/subscriptions"
|
10
|
+
end
|
11
|
+
|
12
|
+
def subscribe_to_model(model,options)
|
13
|
+
options_to_send = options.dup
|
14
|
+
options_to_send[:fields] = Array(options[:fields]).join(",")
|
15
|
+
options_to_send[:object] = name_for_class(model)
|
16
|
+
self.class.post(subscription_url,:body=>default_params.merge(options_to_send))
|
17
|
+
end
|
18
|
+
|
19
|
+
def name_for_class(klass)
|
20
|
+
klass.name.split("::").last.downcase
|
21
|
+
end
|
22
|
+
|
23
|
+
def subscriptions
|
24
|
+
get_and_map_url(subscription_url,"Subscription")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/mogli/authenticator.rb
CHANGED
data/lib/mogli/client.rb
CHANGED
@@ -83,7 +83,9 @@ module Mogli
|
|
83
83
|
def self.create_and_authenticate_as_application(client_id, secret)
|
84
84
|
authenticator = Mogli::Authenticator.new(client_id, secret, nil)
|
85
85
|
access_data = authenticator.get_access_token_for_application
|
86
|
-
new(access_data)
|
86
|
+
client = AppClient.new(access_data)
|
87
|
+
client.application_id = client_id
|
88
|
+
client
|
87
89
|
end
|
88
90
|
|
89
91
|
def post(path,klass,body_args)
|
@@ -95,6 +97,11 @@ module Mogli
|
|
95
97
|
self.class.delete(api_path(path),:query=>default_params)
|
96
98
|
end
|
97
99
|
|
100
|
+
def subscribe_to_model(model,options)
|
101
|
+
options_to_send=options.dup
|
102
|
+
self.class.post("http://")
|
103
|
+
end
|
104
|
+
|
98
105
|
def fql_query(query,klass=nil,format="json")
|
99
106
|
data = self.class.post(fql_path,:body=>default_params.merge({:query=>query,:format=>format}))
|
100
107
|
return data unless format=="json"
|
@@ -103,12 +110,13 @@ module Mogli
|
|
103
110
|
|
104
111
|
def get_and_map(path,klass=nil,body_args = {})
|
105
112
|
data = self.class.get(api_path(path),:query=>default_params.merge(body_args))
|
113
|
+
debugger
|
106
114
|
data = data.values if body_args.key?(:ids) && !data.key?('error')
|
107
115
|
map_data(data,klass)
|
108
116
|
end
|
109
117
|
|
110
|
-
def get_and_map_url(url,klass=nil)
|
111
|
-
data = self.class.get(url)
|
118
|
+
def get_and_map_url(url,klass=nil,body_args = {})
|
119
|
+
data = self.class.get(url,:query=>default_params.merge(body_args))
|
112
120
|
map_data(data,klass)
|
113
121
|
end
|
114
122
|
|
data/lib/mogli/model.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mogli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 57
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 19
|
10
|
+
version: 0.0.19
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Mike Mangino
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-01-
|
18
|
+
date: 2011-01-13 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -63,6 +63,7 @@ files:
|
|
63
63
|
- lib/mogli/activity.rb
|
64
64
|
- lib/mogli/address.rb
|
65
65
|
- lib/mogli/album.rb
|
66
|
+
- lib/mogli/app_client.rb
|
66
67
|
- lib/mogli/application.rb
|
67
68
|
- lib/mogli/authenticator.rb
|
68
69
|
- lib/mogli/book.rb
|