Class: Cloudsight::Util
- Inherits:
-
Object
- Object
- Cloudsight::Util
- Defined in:
- lib/cloudsight.rb
Class Method Summary collapse
- .authorization_header(http_method, url, params = {}) ⇒ Object
- .get(url, headers = {}) ⇒ Object
- .post(url, params, headers = {}) ⇒ Object
Class Method Details
.authorization_header(http_method, url, params = {}) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/cloudsight.rb', line 57 def self.(http_method, url, params = {}) if Cloudsight.api_key "CloudSight #{Cloudsight.api_key}" else # Exclude image file when generating OAuth header filtered_payload = params.dup filtered_payload.delete('image_request[image]') oauth = SimpleOAuth::Header.new(http_method, url, filtered_payload, Cloudsight. || {}) oauth.to_s end end |
.get(url, headers = {}) ⇒ Object
50 51 52 53 54 55 |
# File 'lib/cloudsight.rb', line 50 def self.get(url, headers = {}) headers['Authorization'] = (:get, url) RestClient.get(url, headers) rescue RestClient::Exception => e e.response end |
.post(url, params, headers = {}) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/cloudsight.rb', line 43 def self.post(url, params, headers = {}) headers['Authorization'] = (:post, url, params) RestClient.post(url, params, headers) rescue RestClient::Exception => e e.response end |