Class: Renren2::Interface::Base
- Inherits:
-
Object
- Object
- Renren2::Interface::Base
show all
- Defined in:
- lib/renren2/interface/base.rb
Overview
Direct Known Subclasses
Admin, Blog, Checkins, Feed, Friends, Invitations, Like, Notifications, Pages, Pay, Photos, Places, Requests, Share, Status, Users
Instance Method Summary
collapse
Constructor Details
#initialize(client) ⇒ Base
Returns a new instance of Base.
6
7
8
|
# File 'lib/renren2/interface/base.rb', line 6
def initialize(client)
@client = client
end
|
Instance Method Details
#check_scope(scope_name) ⇒ Object
10
11
12
13
14
|
# File 'lib/renren2/interface/base.rb', line 10
def check_scope(scope_name)
unless @client.include_scope? scope_name
raise "You haven't got the scope " + scope_name
end
end
|
#get(path, opts = {}, &block) ⇒ Object
37
38
39
|
# File 'lib/renren2/interface/base.rb', line 37
def get(path, opts={}, &block)
request(:get, path, opts, &block)
end
|
#post(path, opts = {}, &block) ⇒ Object
41
42
43
|
# File 'lib/renren2/interface/base.rb', line 41
def post(path, opts={}, &block)
request(:post, path, opts, &block)
end
|
#request(verb, path, opts = {}, &block) ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/renren2/interface/base.rb', line 16
def request(verb, path, opts={}, &block)
unless @client.is_authorized?
raise "I can't find a valid access_token. Forgot to get it or expired?"
end
params = {:access_token => @client.token.token,
:method => path,
:v => "1.0",
:format => "JSON"}.merge(opts.delete(:body) || {})
.merge(opts.delete(:params) || {})
opts.merge!(:body => params.merge(:sig => compute_sig(params)), :parse => :json)
path = "http://api.renren.com/restserver.do"
@client.token.request(verb, path, opts, &block)
end
|