Class: Trulioo::API::Verifications

Inherits:
Base
  • Object
show all
Defined in:
lib/trulioo/api/verifications.rb,
lib/trulioo/api/verifications/result.rb,
lib/trulioo/api/verifications/datasource.rb,
lib/trulioo/api/verifications/transaction_record.rb

Overview

Trulioo::Verifications manages the “Verifications” API endpoints. This accesses the Normalized API.

Defined Under Namespace

Classes: Datasource, Result, TransactionRecord

Instance Attribute Summary

Attributes inherited from Base

#client

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Trulioo::API::Base

Class Method Details

.format_value(value) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/trulioo/api/verifications.rb', line 9

def format_value(value)
  if /true/i.match value
    true
  elsif /false/i.match value
    false
  else
    value
  end
end

.parse_fields(fields, value_field) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/trulioo/api/verifications.rb', line 19

def parse_fields(fields, value_field)
  return [] unless fields
  fields.each_with_object({}) do |field, h|
    key = field['FieldName'].gsub(/([a-z\d])([A-Z])/, '\1_\2').downcase
    h[key] = format_value(field[value_field])
  end
end

Instance Method Details

#transaction_record(transaction_id, option = nil) ⇒ Object



28
29
30
31
32
# File 'lib/trulioo/api/verifications.rb', line 28

def transaction_record(transaction_id, option = nil)
  action = "transactionrecord/#{transaction_id}"
  action += "/#{option}" if option && option.to_sym.in?(options)
  Result.new(get(action, auth: true))
end

#verify(data) ⇒ Object



34
35
36
# File 'lib/trulioo/api/verifications.rb', line 34

def verify(data)
  Result.new(post('verify', auth: true, body: data))
end