class Thron::Response
Constants
- ERROR_KEY
- ID_REGEX
Attributes
body[RW]
error[R]
http_code[R]
other_results[R]
result_code[R]
sso_code[R]
total[R]
Public Class Methods
new(raw_data)
click to toggle source
# File lib/thron/response.rb, line 12 def initialize(raw_data) @http_code = raw_data.code @body = fetch(raw_data) @result_code = @body.delete('resultCode') @sso_code = @body.delete('ssoCode') @total = @body.delete('totalResults') @other_results = @body.delete('otherResults') { false } @error = @body.delete(ERROR_KEY) end
Public Instance Methods
extra(options = {})
click to toggle source
# File lib/thron/response.rb, line 22 def extra(options = {}) attribute = options[:attribute].to_s name = attribute.snakecase self.class.send(:attr_reader, name) instance_variable_set(:"@#{name}", body.delete(attribute)) end
is_200?()
click to toggle source
# File lib/thron/response.rb, line 29 def is_200? (@http_code.to_i / 100) == 2 end
Private Instance Methods
fetch(raw_data)
click to toggle source
# File lib/thron/response.rb, line 35 def fetch(raw_data) case(parsed = raw_data.parsed_response) when Hash parsed when ID_REGEX { id: parsed } when String { ERROR_KEY => parsed } else {} end end