Class: Weeter::Plugins::Net::OauthHttp
- Inherits:
-
Object
- Object
- Weeter::Plugins::Net::OauthHttp
- Defined in:
- lib/weeter/plugins/lib/oauth_http.rb
Class Method Summary collapse
- .delete(config, url, params = {}) ⇒ Object
- .get(config, url, params = {}) ⇒ Object
- .oauth_header(config, uri, params, http_method) ⇒ Object
- .post(config, url, params = {}) ⇒ Object
- .put(config, url, params = {}) ⇒ Object
- .request(config, method, url, params = {}) ⇒ Object
Class Method Details
.delete(config, url, params = {}) ⇒ Object
20 21 22 |
# File 'lib/weeter/plugins/lib/oauth_http.rb', line 20 def self.delete(config, url, params = {}) request(config, :delete, url, params) end |
.get(config, url, params = {}) ⇒ Object
8 9 10 |
# File 'lib/weeter/plugins/lib/oauth_http.rb', line 8 def self.get(config, url, params = {}) request(config, :get, url, params) end |
.oauth_header(config, uri, params, http_method) ⇒ Object
34 35 36 |
# File 'lib/weeter/plugins/lib/oauth_http.rb', line 34 def self.oauth_header(config, uri, params, http_method) ::SimpleOAuth::Header.new(http_method, uri, params, config.oauth).to_s end |
.post(config, url, params = {}) ⇒ Object
16 17 18 |
# File 'lib/weeter/plugins/lib/oauth_http.rb', line 16 def self.post(config, url, params = {}) request(config, :post, url, params) end |
.put(config, url, params = {}) ⇒ Object
12 13 14 |
# File 'lib/weeter/plugins/lib/oauth_http.rb', line 12 def self.put(config, url, params = {}) request(config, :put, url, params) end |
.request(config, method, url, params = {}) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/weeter/plugins/lib/oauth_http.rb', line 24 def self.request(config, method, url, params = {}) if method == :post = {:body => params} else = {:query => params} end .merge!(:head => {"Authorization" => oauth_header(config, url, params, method.to_s.upcase)}) if config.oauth EM::HttpRequest.new(url).send(method, ) end |