Class: BitlyOAuth::Response
- Inherits:
-
Object
- Object
- BitlyOAuth::Response
- Defined in:
- lib/bitly_oauth/response.rb
Constant Summary collapse
- REASONS =
{ "OK" => "OK", "INVALID_URI" => "Invalid URI" }.freeze
Instance Method Summary collapse
- #body ⇒ Object
-
#initialize(response) ⇒ Response
constructor
A new instance of Response.
- #reason ⇒ Object
- #status ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(response) ⇒ Response
Returns a new instance of Response.
6 7 8 |
# File 'lib/bitly_oauth/response.rb', line 6 def initialize(response) @response = response end |
Instance Method Details
#body ⇒ Object
23 24 25 |
# File 'lib/bitly_oauth/response.rb', line 23 def body parsed['data'] end |
#reason ⇒ Object
18 19 20 21 |
# File 'lib/bitly_oauth/response.rb', line 18 def reason status = parsed['status_txt'] REASONS[ status ] || status.split('_').map(&:capitalize) * ' ' end |
#status ⇒ Object
14 15 16 |
# File 'lib/bitly_oauth/response.rb', line 14 def status parsed['status_code'] end |
#success? ⇒ Boolean
10 11 12 |
# File 'lib/bitly_oauth/response.rb', line 10 def success? parsed['status_code'] == 200 end |