Class: LiveEnsure::SetupResponse
Instance Method Summary
collapse
Methods inherited from Response
#initialize
Instance Method Details
#parse_response ⇒ Object
10
11
12
13
14
|
# File 'lib/live_ensure/setup_response.rb', line 10
def parse_response
raise InvalidResponse unless vars.size > 0
parse_response_code
end
|
#parse_response_code ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/live_ensure/setup_response.rb', line 16
def parse_response_code
response_code = vars[0].split(':')
@hash['code'] = response_code[0].to_i
case @hash['code']
when 0
raise AuthSessionError
when 1
@hash['base_url'] = LiveEnsure::HOST
@hash['launch_url'] = "#{HOST}/launcher?sessionToken=#{response_code[1]}"
@hash['token'] = response_code[1]
when 2
raise ServiceDown
when 4
@hash['base_url'] = @vars[1]
@hash['launch_url'] = "#{@vars[1]}/launcher?sessionToken=#{response_code[1]}"
@hash['token'] = response_code[1]
end
end
|
#vars ⇒ Object
37
38
39
|
# File 'lib/live_ensure/setup_response.rb', line 37
def vars
@vars ||= @response.split("\n")
end
|