Sha256: adea9751931dab158e211f4e59e07650a51fd2eb8389531dd8137de5bc84ab76
Contents?: true
Size: 862 Bytes
Versions: 3
Compression:
Stored size: 862 Bytes
Contents
module Onfido class ResponseHandler attr_reader :response def initialize(response) @response = response end def parse! if Onfido.throws_exceptions && parsed_response["error"] raise request_error else parsed_response end end private def parsed_response @parsed_response ||= begin JSON.parse(response) rescue JSON::ParserError { 'error' => {"message" => "Unparseable response: #{response}"} } end end def request_error RequestError.new(parsed_response['error']['message']).tap do |error| error.type = parsed_response['error']["type"] error.fields = parsed_response['error']["fields"] error.response_code = response.code if response.respond_to?(:code) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
onfido-0.0.3 | lib/onfido/response_handler.rb |
onfido-0.0.2 | lib/onfido/response_handler.rb |
onfido-0.0.1 | lib/onfido/response_handler.rb |