class OAuthRubytter
must use oauth library.
Public Class Methods
new(access_token, options = {})
click to toggle source
access_token: must be instance of OAuth::AccessToken
Calls superclass method
Rubytter.new
# File lib/rubytter/oauth_rubytter.rb, line 4 def initialize(access_token, options = {}) super(nil, nil, options) @access_token = access_token end
Public Instance Methods
delete(path, params = {})
click to toggle source
# File lib/rubytter/oauth_rubytter.rb, line 26 def delete(path, params = {}) path = path_prefix + path + '.json' param_str = to_param_str(params) path = path + '?' + param_str unless param_str.empty? parse_response(@access_token.delete(path, @header)) end
get(path, params = {})
click to toggle source
# File lib/rubytter/oauth_rubytter.rb, line 9 def get(path, params = {}) path = path_prefix + path + '.json' param_str = to_param_str(params) path = path + '?' + param_str unless param_str.empty? parse_response(@access_token.get(path, @header)) end
parse_response(res)
click to toggle source
# File lib/rubytter/oauth_rubytter.rb, line 33 def parse_response(res) json_data = JSON.parse(res.body) case res.code when "200" structize(json_data) else raise APIError.new(json_data['error'], res) end end
post(path, params = {})
click to toggle source
# File lib/rubytter/oauth_rubytter.rb, line 16 def post(path, params = {}) path = path_prefix + path + '.json' parse_response(@access_token.post(path, params.stringify_keys, @header)) end
put(path, params = {})
click to toggle source
# File lib/rubytter/oauth_rubytter.rb, line 21 def put(path, params = {}) path = path_prefix + path + '.json' parse_response(@access_token.put(path, params.stringify_keys, @header)) end