Class: BitlyOAuth::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/bitly_oauth/response.rb

Constant Summary collapse

REASONS =
{ "OK"          => "OK",
"INVALID_URI" => "Invalid URI" }.freeze

Instance Method Summary collapse

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

#bodyObject



23
24
25
# File 'lib/bitly_oauth/response.rb', line 23

def body
  parsed['data']
end

#reasonObject



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

#statusObject



14
15
16
# File 'lib/bitly_oauth/response.rb', line 14

def status
  parsed['status_code']
end

#success?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/bitly_oauth/response.rb', line 10

def success?
  parsed['status_code'] == 200
end