Class: Upkey::Chatterly::Urls::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/upkey/chatterly/urls/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(chatterly_response) ⇒ Response

Returns a new instance of Response.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/upkey/chatterly/urls/response.rb', line 7

def initialize(chatterly_response)
  @status = chatterly_response.status

  case status
  when 200
    @contents = JSON.parse(chatterly_response.body)
  when 404
    @contents = { message: 'Requested URL not found.' }
  when 422
    @contents = { message: JSON.parse(chatterly_response.body) }
  when 401
    @contents = { message: 'You are unauthorized to access this. Please check your access credentials and try again.' }
  else
    raise ChatterlyError
  end
end

Instance Attribute Details

#contentsObject (readonly)

Returns the value of attribute contents.



5
6
7
# File 'lib/upkey/chatterly/urls/response.rb', line 5

def contents
  @contents
end

#statusObject (readonly)

Returns the value of attribute status.



5
6
7
# File 'lib/upkey/chatterly/urls/response.rb', line 5

def status
  @status
end