Class: InoreaderApi::Helper
- Inherits:
-
Object
- Object
- InoreaderApi::Helper
- Includes:
- HTTParty
- Defined in:
- lib/inoreader/api/helper.rb
Constant Summary collapse
- @@return_httparty_response =
option: use httparty respqnse if set true
false
Instance Attribute Summary collapse
-
#ret ⇒ Object
Returns the value of attribute ret.
Class Method Summary collapse
-
.auth_request(un, pw) ⇒ Object
auth request to Inoreader.
-
.request(path, query = nil, method = :get) ⇒ Object
send request.
- .return_httparty_response=(bool) ⇒ Object
Instance Attribute Details
#ret ⇒ Object
Returns the value of attribute ret.
10 11 12 |
# File 'lib/inoreader/api/helper.rb', line 10 def ret @ret end |
Class Method Details
.auth_request(un, pw) ⇒ Object
auth request to Inoreader
66 67 68 69 70 71 72 73 74 |
# File 'lib/inoreader/api/helper.rb', line 66 def auth_request(un, pw) response = self.post('/accounts/ClientLogin', {:body => {:Email => un, :Passwd => pw}}) if response.response.code == '200' # request fail (ex. 500, 401...) response.body else raise InoreaderApiError.new response.response. end end |
.request(path, query = nil, method = :get) ⇒ Object
send request
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/inoreader/api/helper.rb', line 35 def request(path, query=nil, method=:get) begin response = self.send(method, path, query) rescue => e #request fail (ex. timeout) raise InoreaderApiError.new e. end if response.response.code == '200' if @@return_httparty_response response else begin #return to hashie Hashie::Mash.new MultiJson.decode(response.body) rescue # its not JSON, return body directly. response.body end end else # request fail (ex. 500, 401...) raise InoreaderApiError.new response.response. end end |
.return_httparty_response=(bool) ⇒ Object
25 26 27 |
# File 'lib/inoreader/api/helper.rb', line 25 def return_httparty_response=(bool) @@return_httparty_response = bool end |