Class: Idnow::RawResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/idnow/raw_response.rb

Direct Known Subclasses

JsonResponse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_response) ⇒ RawResponse

Returns a new instance of RawResponse.



7
8
9
# File 'lib/idnow/raw_response.rb', line 7

def initialize(raw_response)
  @raw = raw_response.nil? ? raw_response.to_s : raw_response
end

Instance Attribute Details

#rawObject (readonly)

Returns the value of attribute raw.



5
6
7
# File 'lib/idnow/raw_response.rb', line 5

def raw
  @raw
end

Instance Method Details

#errorsObject

IDNow API always returns JSON-formatted errors, even if a successful response is raw text



13
14
15
16
17
18
# File 'lib/idnow/raw_response.rb', line 13

def errors
  if valid_json?(@raw)
    json_data = JSON.parse(@raw)
    json_data['errors'] if json_data.instance_of?(Hash)
  end
end

#errors?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/idnow/raw_response.rb', line 20

def errors?
  !errors.nil?
end