Class: Authy::Response
- Inherits:
-
Hash
- Object
- Hash
- Authy::Response
show all
- Defined in:
- lib/authy/response.rb
Direct Known Subclasses
User
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(response) ⇒ Response
Returns a new instance of Response.
4
5
6
7
|
# File 'lib/authy/response.rb', line 4
def initialize(response)
@raw_response = response
parse_body
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
34
35
36
37
38
39
40
|
# File 'lib/authy/response.rb', line 34
def method_missing(name, *args, &block)
if self.include?(name.to_s)
self[name.to_s]
else
super(name, *args, &block)
end
end
|
Instance Attribute Details
#raw_response ⇒ Object
Returns the value of attribute raw_response.
3
4
5
|
# File 'lib/authy/response.rb', line 3
def raw_response
@raw_response
end
|
Instance Method Details
#body ⇒ Object
17
18
19
|
# File 'lib/authy/response.rb', line 17
def body
@raw_response.body
end
|
#code ⇒ Object
21
22
23
|
# File 'lib/authy/response.rb', line 21
def code
@raw_response.code
end
|
#error_msg ⇒ Object
25
26
27
|
# File 'lib/authy/response.rb', line 25
def error_msg
(@raw_response.curl_error_message == "No error" && self.empty?) ? self.body : @raw_response.curl_error_message
end
|
#errors ⇒ Object
29
30
31
|
# File 'lib/authy/response.rb', line 29
def errors
self['errors'] || {}
end
|
#id ⇒ Object
9
10
11
|
# File 'lib/authy/response.rb', line 9
def id
self["id"]
end
|
#ok? ⇒ Boolean
13
14
15
|
# File 'lib/authy/response.rb', line 13
def ok?
@raw_response.code == 200
end
|