10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/disqussed/api.rb', line 10
def request(method, endpoint, action, opts = {}, authenticate_as_self = false, user = {})
throw "Missing API Key" if Disqussed::defaults[:api_key].nil?
opts[:api_key] = Disqussed::defaults[:api_key]
opts[:api_secret] = Disqussed::defaults[:secret_key]
if authenticate_as_self
opts[:access_token] = Disqussed::defaults[:access_token]
elsif Disqussed::defaults[:sso]
throw "Missing API Secret" if Disqussed::defaults[:secret_key].nil?
user.slice!(:id, :username, :email, :avatar, :url)
opts[:remote_auth] = remote_auth_s3(user)
end
if method === "post"
HTTParty.post([ROOT, API_VERSION, endpoint, action + '.json'].join('/'), { :body => opts })
elsif method === "get"
HTTParty.get([ROOT, API_VERSION, endpoint, action + '.json'].join('/'), { :query => opts })
end
end
|