trulioo 0.1.1 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a255bcac10cd99492b2f008bd7b182435b29376b
4
- data.tar.gz: '08c61063bc7a9c77391cf2076602b1ffe737a5b0'
3
+ metadata.gz: 191257b3e8b433aa2199e63afeb709d4eee059bd
4
+ data.tar.gz: b614d15602b4bae2a18e6fff86b3deef208d3068
5
5
  SHA512:
6
- metadata.gz: 4678a9116c8e69966ea9f5560fe265c914492b6d994593b17c7e90378a6342612e058940c35c5eaeaf4c6d9002746f5a1e4ab0fa2892d3493f68d63fe718978e
7
- data.tar.gz: dafc67619a0e3544a3be2c0d7998a7d1616740896f62d8b65bb744a04924e257547bafdb24aae8533b283591fbbdd638c17fa00064410ecbc4de9631452721da
6
+ metadata.gz: d72e2038291a957836ca323a1a570a93f72b26ecf10974b2383f8c993dce42b315802ad05e418e8d8a9fcb34dba60ab7072d654695ffce84b8057abd0704ac0a
7
+ data.tar.gz: 9421437ebc7bea4e39bc3233a1c7a160d0efbfe0c4330ae5b6d88f6ab7f2f2cce4cd92fee85333886e539a1026f0645999e60d8ce7e676c83b1c4f002d22ca63
data/README.md CHANGED
@@ -97,6 +97,17 @@ the key `AcceptTruliooTermsAndConditions` as it is already included.
97
97
  client.verifications.verify({ CountryCode: 'US', ... })
98
98
  ```
99
99
 
100
+ #### Result
101
+
102
+ These two endpoints return a `Trulioo::API::Verifications::Result` instance.
103
+ This makes it easy to navigate through the response. For example, use the
104
+ following to get the TransactionRecordID:
105
+
106
+ ```ruby
107
+ result = client.verifications.verify({ ... })
108
+ result.transaction_record.id
109
+ ```
110
+
100
111
  ### Configuration
101
112
 
102
113
  Information regarding how your account is configured.
@@ -4,6 +4,9 @@ require 'trulioo/api/base'
4
4
  require 'trulioo/api/configuration'
5
5
  require 'trulioo/api/connection'
6
6
  require 'trulioo/api/verifications'
7
+ require 'trulioo/api/verifications/datasource'
8
+ require 'trulioo/api/verifications/transaction_record'
9
+ require 'trulioo/api/verifications/result'
7
10
 
8
11
  module Trulioo
9
12
  # Trulioo::API is where the endpoints will be handled.
@@ -5,14 +5,34 @@ module Trulioo
5
5
  # Trulioo::Verifications manages the "Verifications" API endpoints. This
6
6
  # accesses the Normalized API.
7
7
  class Verifications < Trulioo::API::Base
8
+ class << self
9
+ def format_value(value)
10
+ if /true/i.match value
11
+ true
12
+ elsif /false/i.match value
13
+ false
14
+ else
15
+ value
16
+ end
17
+ end
18
+
19
+ def parse_fields(fields, value_field)
20
+ return [] unless fields
21
+ fields.each_with_object({}) do |field, h|
22
+ key = field['FieldName'].gsub(/([a-z\d])([A-Z])/, '\1_\2').downcase
23
+ h[key] = format_value(field[value_field])
24
+ end
25
+ end
26
+ end
27
+
8
28
  def transaction_record(transaction_id, option = nil)
9
29
  action = "transactionrecord/#{transaction_id}"
10
- action += "/#{option}" if option.try(:to_sym).in?(options)
11
- get(action, auth: true)
30
+ action += "/#{option}" if option && option.to_sym.in?(options)
31
+ Result.new(get(action, auth: true))
12
32
  end
13
33
 
14
34
  def verify(data)
15
- post('verify', auth: true, body: data)
35
+ Result.new(post('verify', auth: true, body: data))
16
36
  end
17
37
 
18
38
  private
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Trulioo
4
+ module API
5
+ class Verifications
6
+ # Trulioo::API:Verifications:Datasource is the result of an individual
7
+ # datasource.
8
+ class Datasource
9
+ attr_reader :appended_fields,
10
+ :datasource_fields,
11
+ :errors,
12
+ :field_groups,
13
+ :name
14
+
15
+ def initialize(datasource)
16
+ @name = datasource['DatasourceName']
17
+ @datasource_fields = Verifications.parse_fields(
18
+ datasource['DatasourceFields'],
19
+ 'Status'
20
+ )
21
+ @appended_fields = Verifications.parse_fields(
22
+ datasource['AppendedFields'],
23
+ 'Data'
24
+ )
25
+ @errors = datasource['Errors']
26
+ @field_groups = datasource['FieldGroups']
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Trulioo
4
+ module API
5
+ class Verifications
6
+ # Trulioo::API:Verifications:Result is a wrapper for the verifications
7
+ # endpoints' response.
8
+ class Result
9
+ attr_reader :code,
10
+ :errors,
11
+ :input_fields,
12
+ :response,
13
+ :transaction_id,
14
+ :transaction_record,
15
+ :uploaded_at
16
+
17
+ def initialize(response)
18
+ @code = response.code
19
+ @response = response
20
+ parse_response(response.parsed_response) if code == 200
21
+ end
22
+
23
+ private
24
+
25
+ def parse_response(r)
26
+ @transaction_id = r['TransactionID']
27
+ @uploaded_at = Time.parse(r['UploadedDt'])
28
+ @input_fields = Verifications.parse_fields(r['InputFields'], 'Value')
29
+ @errors = r['Errors']
30
+ @transaction_record = TransactionRecord.new(r['Record'])
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Trulioo
4
+ module API
5
+ class Verifications
6
+ # Trulioo::API:Verifications:TransactionRecord holds the information of
7
+ # the transaction record.
8
+ class TransactionRecord
9
+ attr_reader :datasources, :errors, :id, :rule, :status
10
+
11
+ def initialize(record)
12
+ @id = record['TransactionRecordID']
13
+ @datasources = parse_datasources(record['DatasourceResults'])
14
+ @status = record['RecordStatus']
15
+ @errors = record['Errors']
16
+ @rule = { record['Rule']['RuleName'] => record['Rule']['Note'] }
17
+ end
18
+
19
+ private
20
+
21
+ def parse_datasources(results)
22
+ results.each_with_object([]) { |ds, ary| ary << Datasource.new(ds) }
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trulioo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dave Nguyen
@@ -14,16 +14,16 @@ dependencies:
14
14
  name: httparty
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '0.15'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '0.15'
27
27
  description:
28
28
  email: d@fundamerica.com
29
29
  executables: []
@@ -38,6 +38,9 @@ files:
38
38
  - lib/trulioo/api/configuration.rb
39
39
  - lib/trulioo/api/connection.rb
40
40
  - lib/trulioo/api/verifications.rb
41
+ - lib/trulioo/api/verifications/datasource.rb
42
+ - lib/trulioo/api/verifications/result.rb
43
+ - lib/trulioo/api/verifications/transaction_record.rb
41
44
  - lib/trulioo/client.rb
42
45
  - lib/trulioo/connector.rb
43
46
  - lib/trulioo/settings.rb