trulioo 0.1.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a255bcac10cd99492b2f008bd7b182435b29376b
4
+ data.tar.gz: '08c61063bc7a9c77391cf2076602b1ffe737a5b0'
5
+ SHA512:
6
+ metadata.gz: 4678a9116c8e69966ea9f5560fe265c914492b6d994593b17c7e90378a6342612e058940c35c5eaeaf4c6d9002746f5a1e4ab0fa2892d3493f68d63fe718978e
7
+ data.tar.gz: dafc67619a0e3544a3be2c0d7998a7d1616740896f62d8b65bb744a04924e257547bafdb24aae8533b283591fbbdd638c17fa00064410ecbc4de9631452721da
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 FundAmerica, LLC
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
9
+ of the Software, and to permit persons to whom the Software is furnished to do
10
+ so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,157 @@
1
+ # Trulioo
2
+
3
+ This gem provides access to [Trulioo](https://www.trulioo.com/)'s GlobalGateway
4
+ API. For detailed information regarding the API, check out their [API
5
+ docs](https://api.globaldatacompany.com/docs).
6
+
7
+ ## Getting Started
8
+
9
+ ### Installation
10
+
11
+ Add `trulioo` to your Gemfile and run `bundle install`:
12
+
13
+ ```ruby
14
+ gem 'trulioo`
15
+ ```
16
+
17
+ Or install it manually:
18
+
19
+ ```console
20
+ $ gem install httparty
21
+ $ gem install trulioo
22
+ ```
23
+
24
+ ### Configure
25
+
26
+ Settings can be configured as so:
27
+
28
+ ```ruby
29
+ require 'trulioo'
30
+
31
+ Trulioo.configure do |config|
32
+ config.username = 'username'
33
+ config.password = 'password'
34
+ end
35
+ ```
36
+
37
+ ### Usage
38
+
39
+ You'll want to try the `say_hello` to make sure the URL is correct and the
40
+ `test_authentication` endpoint to make sure your credentials are correct.
41
+
42
+ ```ruby
43
+ client = Trulioo::Client.new
44
+ client.say_hello # => "Hello World"
45
+ client.test_authentication # => "Hello Company_Username"
46
+ ```
47
+
48
+ ## API Endpoints
49
+
50
+ ### Connection
51
+
52
+ Used to test your connection.
53
+
54
+ #### `say_hello`
55
+
56
+ This is the only endpoint that does not require authentication. It takes in an
57
+ optional param that will be displayed in the greeting.
58
+
59
+ ```ruby
60
+ client.connection.say_hello # => "Hello World"
61
+ client.connection.say_hello 'Company' # => "Hello Company"
62
+ ```
63
+
64
+ #### `test_authentication`
65
+
66
+ If the provided username and password are correct, this will return the username
67
+ of your account in the greeting.
68
+
69
+ ```ruby
70
+ client.connection.test_authentication # => "Hello Company_Username"
71
+ ```
72
+
73
+ ### Verifications
74
+
75
+ Accesses version 1 of their Normalized API.
76
+
77
+ #### `transaction_record`
78
+
79
+ Retrieves the information of an existing verification. This takes an optional
80
+ param if you would like more information. The options available:
81
+
82
+ - `:withaddress`: If your account includes address cleansing.
83
+ - `:verbose`: If your account includes address cleansing and watchlist details.
84
+
85
+ ```ruby
86
+ client.verifications.transaction_record(transaction_id)
87
+ client.verifications.transaction_record(transaction_id, :withaddress)
88
+ client.verifications.transaction_record(transaction_id, :verbose)
89
+ ```
90
+
91
+ #### `verify`
92
+
93
+ Performs a verification. Accepts a hash for the data. You do not need to include
94
+ the key `AcceptTruliooTermsAndConditions` as it is already included.
95
+
96
+ ```ruby
97
+ client.verifications.verify({ CountryCode: 'US', ... })
98
+ ```
99
+
100
+ ### Configuration
101
+
102
+ Information regarding how your account is configured.
103
+
104
+ #### `consents`
105
+
106
+ Consents required for the provided country. Accepts a string or symbol.
107
+
108
+ ```ruby
109
+ client.configuration.consents('US')
110
+ ```
111
+
112
+ #### `country_codes`
113
+
114
+ Returns countries configured for your account.
115
+
116
+ ```ruby
117
+ client.configuration.consents
118
+ ```
119
+
120
+ #### `country_subdivisions`
121
+
122
+ Gets the provinces states or other subdivisions for a country, mostly matches
123
+ ISO 3166-2.
124
+
125
+ ```ruby
126
+ client.configuration.country_subdivisions('US')
127
+ ```
128
+
129
+ #### `document_types`
130
+
131
+ Get available document verification types.
132
+
133
+ ```ruby
134
+ client.configuration.document_types('US')
135
+ ```
136
+
137
+ #### `fields`
138
+
139
+ Generates json schema for the API, which can be used to format your `data`
140
+ object when performing a verification.
141
+
142
+ ```ruby
143
+ client.configuration.fields('US')
144
+ ```
145
+
146
+ ## Testing
147
+
148
+ ### Development
149
+
150
+ Tests are run using MiniTest. To run tests, first copy `test/env.yml.example` to
151
+ `test/env.yml`. Update the variables in the file and then run `rake test` (or
152
+ just `rake`). The `env.yml` file is necessary to test against any endpoints that
153
+ require authentication. The `TestConnection#say_hello` should work fine without
154
+ it.
155
+
156
+ Each endpoint has its own test suite to make it easier to run tests for that API
157
+ endpoint.
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'trulioo/settings'
4
+ require 'trulioo/client'
5
+
6
+ # Trulioo holds the settings and allows them to be set using Trulioo.configure.
7
+ module Trulioo
8
+ class << self
9
+ def configure
10
+ yield(settings)
11
+ end
12
+
13
+ def settings
14
+ @_settings ||= Settings.new
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'trulioo/api/base'
4
+ require 'trulioo/api/configuration'
5
+ require 'trulioo/api/connection'
6
+ require 'trulioo/api/verifications'
7
+
8
+ module Trulioo
9
+ # Trulioo::API is where the endpoints will be handled.
10
+ module API
11
+ end
12
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Trulioo
4
+ module API
5
+ # Trulioo::API::Base has information for the API classes to call the
6
+ # endpoint correctly.
7
+ class Base
8
+ attr_reader :client
9
+
10
+ def initialize(client)
11
+ @client = client
12
+ end
13
+
14
+ private
15
+
16
+ def get(*params)
17
+ client.connector.get(namespace, *params)
18
+ end
19
+
20
+ def namespace
21
+ @_namespace ||= self.class.name.split('::').last
22
+ end
23
+
24
+ def post(*params)
25
+ client.connector.post(namespace, *params)
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Trulioo
4
+ module API
5
+ # Trulioo::Configuration manages the "Configuration" API endpoints. This
6
+ # will tell you how your account is configured.
7
+ class Configuration < Trulioo::API::Base
8
+ def consents(country)
9
+ configuration_namespace
10
+ get("consents/#{configuration_name}/#{country}", auth: true)
11
+ end
12
+
13
+ def country_codes
14
+ configuration_namespace
15
+ get("countrycodes/#{configuration_name}", auth: true)
16
+ end
17
+
18
+ def country_subdivisions(country)
19
+ configuration_namespace
20
+ get("countrysubdivisions/#{country}", auth: true)
21
+ end
22
+
23
+ def document_types(country)
24
+ configuration_namespace
25
+ get("documentTypes/#{country}", auth: true)
26
+ end
27
+
28
+ def fields(country)
29
+ configuration_namespace
30
+ get("fields/#{configuration_name}/#{country}", auth: true)
31
+ end
32
+
33
+ private
34
+
35
+ def configuration_name
36
+ 'Identity Verification'
37
+ end
38
+
39
+ def configuration_namespace
40
+ @namespace = 'configuration'
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Trulioo
4
+ module API
5
+ # Trulioo::Connection manages the "Connection" API endpoints. These are used
6
+ # to test your connection to the Trulioo servers.
7
+ class Connection < Trulioo::API::Base
8
+ def say_hello(name = 'World')
9
+ connection_namespace
10
+ get("sayhello/#{name}")
11
+ end
12
+
13
+ def test_authentication
14
+ connection_namespace
15
+ get('testauthentication', auth: true)
16
+ end
17
+
18
+ private
19
+
20
+ def connection_namespace
21
+ @namespace = 'connection'
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Trulioo
4
+ module API
5
+ # Trulioo::Verifications manages the "Verifications" API endpoints. This
6
+ # accesses the Normalized API.
7
+ class Verifications < Trulioo::API::Base
8
+ def transaction_record(transaction_id, option = nil)
9
+ action = "transactionrecord/#{transaction_id}"
10
+ action += "/#{option}" if option.try(:to_sym).in?(options)
11
+ get(action, auth: true)
12
+ end
13
+
14
+ def verify(data)
15
+ post('verify', auth: true, body: data)
16
+ end
17
+
18
+ private
19
+
20
+ def options
21
+ %i[verbose withaddress]
22
+ end
23
+
24
+ def verifications_namespace
25
+ @namespace = 'verifications'
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'trulioo/api'
4
+ require 'trulioo/connector'
5
+
6
+ module Trulioo
7
+ # Trulioo::Client handles the Connector and the different API endpoints for
8
+ # easy access.
9
+ class Client
10
+ attr_reader :connector, :configuration, :connection, :verifications
11
+
12
+ def initialize(settings = Trulioo.settings)
13
+ @connector = Trulioo::Connector.new(settings)
14
+ @configuration = Trulioo::API::Configuration.new(self)
15
+ @connection = Trulioo::API::Connection.new(self)
16
+ @verifications = Trulioo::API::Verifications.new(self)
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'json'
4
+ require 'httparty'
5
+
6
+ module Trulioo
7
+ # Trulioo::Connector manages the calls to the API.
8
+ class Connector
9
+ attr_reader :settings
10
+
11
+ def initialize(settings)
12
+ @settings = settings
13
+ end
14
+
15
+ %i[get post].each do |verb|
16
+ define_method(verb) do |namespace, action, options = {}|
17
+ HTTParty.send(verb, url(namespace, action), params(options))
18
+ end
19
+ end
20
+
21
+ private
22
+
23
+ def auth_params
24
+ {
25
+ basic_auth: {
26
+ username: settings.username,
27
+ password: settings.password
28
+ }
29
+ }
30
+ end
31
+
32
+ def params(options)
33
+ params = {
34
+ headers: {
35
+ 'Content-Type' => 'application/json'
36
+ }
37
+ }
38
+ params.merge!(auth_params) if options[:auth]
39
+ params[:body] = params_body(options[:body]) if options[:body]
40
+ params
41
+ end
42
+
43
+ def params_body(body)
44
+ { AcceptTruliooTermsAndConditions: true }.merge(body).to_json
45
+ end
46
+
47
+ def url(namespace, action)
48
+ URI.encode(
49
+ "#{settings.base_uri}/#{namespace}/#{settings.api_version}/#{action}"
50
+ )
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Trulioo
4
+ # Trulioo::Settings holds the variables used to connect to Trulioo's servers.
5
+ class Settings
6
+ attr_accessor :api_version, :base_uri, :password, :url, :username
7
+
8
+ def initialize
9
+ @api_version = 'v1'
10
+ @base_uri = 'https://api.globaldatacompany.com'
11
+ end
12
+ end
13
+ end
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: trulioo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Dave Nguyen
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-07-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description:
28
+ email: d@fundamerica.com
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - LICENSE
34
+ - README.md
35
+ - lib/trulioo.rb
36
+ - lib/trulioo/api.rb
37
+ - lib/trulioo/api/base.rb
38
+ - lib/trulioo/api/configuration.rb
39
+ - lib/trulioo/api/connection.rb
40
+ - lib/trulioo/api/verifications.rb
41
+ - lib/trulioo/client.rb
42
+ - lib/trulioo/connector.rb
43
+ - lib/trulioo/settings.rb
44
+ homepage: https://github.com/fundamerica/trulioo
45
+ licenses:
46
+ - MIT
47
+ metadata: {}
48
+ post_install_message:
49
+ rdoc_options: []
50
+ require_paths:
51
+ - lib
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ requirements: []
63
+ rubyforge_project:
64
+ rubygems_version: 2.6.11
65
+ signing_key:
66
+ specification_version: 4
67
+ summary: A Ruby wrapper for Trulioo's GlobalGateway API
68
+ test_files: []