Class: Devcenter::Client::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/devcenter/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Response

Returns a new instance of Response.



10
11
12
# File 'lib/devcenter/client.rb', line 10

def initialize(response)
  @status, @body, @headers = response.status, response.body, response.headers
end

Instance Method Details

#access_denied?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/devcenter/client.rb', line 26

def access_denied?
  @status == 401
end

#bodyObject



30
31
32
# File 'lib/devcenter/client.rb', line 30

def body
  JSON.parse(@body)
end

#locationObject



34
35
36
# File 'lib/devcenter/client.rb', line 34

def location
  @headers['Location']
end

#not_found?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/devcenter/client.rb', line 22

def not_found?
  @status == 404
end

#ok?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/devcenter/client.rb', line 14

def ok?
  [200, 201].include?(@status)
end

#redirect?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/devcenter/client.rb', line 18

def redirect?
  [301, 302].include?(@status)
end