checkr 0.0.1 → 0.0.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 +4 -4
- data/README.md +82 -3
- data/checkr.gemspec +5 -10
- data/lib/checkr.rb +11 -1
- data/lib/checkr/base.rb +24 -0
- data/lib/checkr/candidate.rb +39 -0
- data/lib/checkr/core_ext.rb +35 -0
- data/lib/checkr/county_criminal_search.rb +5 -0
- data/lib/checkr/motor_vehicle_report.rb +25 -0
- data/lib/checkr/national_criminal_search.rb +5 -0
- data/lib/checkr/report.rb +35 -0
- data/lib/checkr/report_charge.rb +6 -0
- data/lib/checkr/report_record.rb +17 -0
- data/lib/checkr/sex_offender search.rb +5 -0
- data/lib/checkr/ssn_trace.rb +5 -0
- data/lib/checkr/subaccount.rb +19 -0
- data/lib/checkr/terrorist_watchlist_search.rb +6 -0
- data/lib/checkr/version.rb +1 -1
- data/test/cassettes/test_0001_should_create_candidate.yml +41 -0
- data/test/cassettes/test_0001_should_create_candidate_for_the_subaccount.yml +41 -0
- data/test/cassettes/test_0001_should_create_report.yml +41 -0
- data/test/cassettes/test_0001_should_create_subaccount.yml +44 -0
- data/test/cassettes/test_0001_should_return_candidate_object.yml +41 -0
- data/test/cassettes/test_0001_should_return_motor_vehicle_report_object.yml +41 -0
- data/test/cassettes/test_0001_should_return_report_object.yml +41 -0
- data/test/cassettes/test_0002_returns_candidate_object_with_checkr_parameters.yml +41 -0
- data/test/cassettes/test_0002_returns_motor_vehicle_report_object_with_parameters.yml +41 -0
- data/test/cassettes/test_0002_returns_report_object_with_parameters.yml +41 -0
- data/test/cassettes/test_0002_should_respond_to_candidate_parameters_belongs_to_subaccount.yml +41 -0
- data/test/cassettes/test_0002_should_respond_to_parameters.yml +41 -0
- data/test/cassettes/test_0002_should_respond_to_report_parameters.yml +41 -0
- data/test/cassettes/test_0002_should_respond_to_subaccount_parameters.yml +44 -0
- data/test/checkr_test.rb +18 -0
- data/test/lib/checkr/candidate_test.rb +66 -0
- data/test/lib/checkr/motor_vehicle_report_test.rb +23 -0
- data/test/lib/checkr/report_test.rb +39 -0
- data/test/lib/checkr/subaccount_test.rb +24 -0
- data/test/test_helper.rb +15 -0
- metadata +59 -103
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cac7f51aa90e16e28b2a21ca48b7317ab897ce23
|
4
|
+
data.tar.gz: 198a3b605c9a344093adcd510528902cc0325871
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: deb8e18304ddf84b96606bb17b1d9ed6250bf3ecb4b2739529207e3655019bba9bd8e5cf3bca7ed7f7be62a747c071dede3b72bc72801e586c18e48b0ccd8b99
|
7
|
+
data.tar.gz: ccd3ffb562cf1e7c5ef5b0b163f9887e8af6e01f254a552280a40a269eda42d5cfd61c6d7494081feb904159b959e6ea7cd19883ba855bba5e5ddd25a9bab402
|
data/README.md
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
# Checkr
|
2
2
|
|
3
|
-
|
3
|
+
Ruby wrapper for checkr.io API (https://checkr.io/docs)
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
7
|
Add this line to your application's Gemfile:
|
8
8
|
|
9
9
|
```ruby
|
10
|
-
gem 'checkr'
|
10
|
+
gem 'checkr', git: 'https://github.com/vijendra/checkr.git'
|
11
11
|
```
|
12
12
|
|
13
13
|
And then execute:
|
@@ -20,8 +20,87 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
-
|
23
|
+
**Configure authentication keys**
|
24
24
|
|
25
|
+
```Ruby
|
26
|
+
Checkr.configure do |c|
|
27
|
+
c.api_key = "83ebeabdec09f6670863766f792ead24d61fe3f9" #Test token from checkr api document
|
28
|
+
end
|
29
|
+
```
|
30
|
+
|
31
|
+
**Create subaccount**
|
32
|
+
|
33
|
+
```Ruby
|
34
|
+
subaccount = Checkr::Subaccount.create(:name => 'Checkr', :entity_name => 'My Company', :tax_id => 'XXXXX', :representative_title => 'CEO', :representative_name => 'John Smith', :representative_email => 'john.smith@company.org', :phone => '3101111111',
|
35
|
+
:incorporation_date => '2010-02-02', :incorporation_type => 'llc', :incorporation_state => 'DE', 'address[street]' => '3230 3rd street', 'address[city]' => 'San Francisco',
|
36
|
+
'address[state]' => 'CA', 'address[zipcode]'=> '94110')
|
37
|
+
|
38
|
+
#Subaccount attributes
|
39
|
+
subaccount_id = subaccount.id
|
40
|
+
```
|
41
|
+
|
42
|
+
**Create candidate for subaccount**
|
43
|
+
|
44
|
+
```Ruby
|
45
|
+
candidate = Checkr::Subaccount.create(:subaccount_id => '8168372aac5a952b90eb9acb', :first_name => 'John', :last_name => 'Smith', :dob => '1970-01-22', :ssn => '111-11-2000', :phone => '5555555555', :email => 'john@smith.org')
|
46
|
+
|
47
|
+
#candidate attributes
|
48
|
+
candidate_id = candidate.id
|
49
|
+
```
|
50
|
+
|
51
|
+
**Create candidate**
|
52
|
+
|
53
|
+
```Ruby
|
54
|
+
candidate = Checkr::Subaccount.create(:first_name => 'John', :last_name => 'Smith', :dob => '1970-01-22', :ssn => '111-11-2000', :phone => '5555555555', :email => 'john@smith.org')
|
55
|
+
|
56
|
+
#candidate attributes
|
57
|
+
candidate_id = candidate.id
|
58
|
+
```
|
59
|
+
|
60
|
+
**Find candidate**
|
61
|
+
|
62
|
+
```Ruby
|
63
|
+
candidate = Checkr::Candidate.find('e44aa283528e6fde7d542194')
|
64
|
+
candidate.id #Returns checkr id of the candidate
|
65
|
+
candidate.first_name #Returns first_name of the candidate
|
66
|
+
```
|
67
|
+
|
68
|
+
**Get all reports belongs to candidate, if exists**
|
69
|
+
|
70
|
+
```Ruby
|
71
|
+
candidate = Checkr::Subaccount.find('e44aa283528e6fde7d542194')
|
72
|
+
candidate.reports #Returns array of Checkr::Report objects
|
73
|
+
```
|
74
|
+
**Create report**
|
75
|
+
|
76
|
+
```Ruby
|
77
|
+
report = Checkr::Report.create(:package => 'driver_plus', :candidate_id => 'e44aa283528e6fde7d542194')
|
78
|
+
report.id #Returns the checkr id of the created report
|
79
|
+
```
|
80
|
+
|
81
|
+
**Find report**
|
82
|
+
|
83
|
+
```Ruby
|
84
|
+
report = Checkr::Report.find("5878551b3ee1eacae5a2c558")
|
85
|
+
report.id #Returns the checkr id of the created report
|
86
|
+
report.status #Returns the status of the report
|
87
|
+
```
|
88
|
+
**Find individual reports**
|
89
|
+
|
90
|
+
```Ruby
|
91
|
+
report = Checkr::MotorVehicleReport.find("5878551b3ee1eacae5a2c558")
|
92
|
+
report = Checkr::CountryCriminalSearch.find("5878551b3ee1eacae5a2c558")
|
93
|
+
report = Checkr::NationalCriminalSearch.find("5878551b3ee1eacae5a2c558")
|
94
|
+
report = Checkr::SexOffenderSearch.find("5878551b3ee1eacae5a2c558")
|
95
|
+
report = Checkr::SsnTrace.find("5878551b3ee1eacae5a2c558")
|
96
|
+
report = Checkr::TerroristWatchlistSearch.find("5878551b3ee1eacae5a2c558")
|
97
|
+
|
98
|
+
report.status #Returns the status of the report
|
99
|
+
report.records #Returns array of ReportRecord objects, if report has records
|
100
|
+
report.records.first.charges #Returns array of ReportCharge objects, if report has charges
|
101
|
+
report.accidents #In case of motor vehicle report
|
102
|
+
report.voilations #In case of motor vehicle report
|
103
|
+
```
|
25
104
|
## Contributing
|
26
105
|
|
27
106
|
1. Fork it ( https://github.com/[my-github-username]/checkr/fork )
|
data/checkr.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
lib = File.expand_path('../lib', __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'checkr
|
4
|
+
require 'checkr'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "checkr"
|
@@ -9,26 +9,21 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Vijendra Rao"]
|
10
10
|
spec.email = ["vijendrakarkala@gmail.com"]
|
11
11
|
spec.summary = %q{checkr API Ruby wrapper}
|
12
|
-
spec.description = %q{Automated background screenings and driving records}
|
13
|
-
spec.homepage = ""
|
12
|
+
spec.description = %q{checkr.io API wrapper: Automated background screenings and driving records}
|
13
|
+
spec.homepage = "https://github.com/vijendra/checkr"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = Dir["README.md","Gemfile","Rakefile", "test/*", "lib/**/*"]
|
19
|
+
#spec.require_paths = Dir["README.md","Gemfile","Rakefile", "test/*", "lib/**/*"]
|
20
|
+
spec.require_paths = %w(lib)
|
20
21
|
|
21
22
|
spec.add_dependency "httparty"
|
22
|
-
spec.add_dependency "active_attr"
|
23
|
-
spec.add_dependency "multi_json"
|
24
|
-
spec.add_dependency "hashie"
|
25
23
|
|
26
24
|
spec.add_development_dependency "bundler", "~> 1.7"
|
27
25
|
spec.add_development_dependency "rake", "~> 10.0"
|
28
|
-
spec.add_development_dependency "guard"
|
29
26
|
spec.add_development_dependency "vcr"
|
30
27
|
spec.add_development_dependency "webmock"
|
31
|
-
spec.add_development_dependency "faker"
|
32
|
-
spec.add_development_dependency "shoulda-matchers"
|
33
28
|
spec.add_development_dependency "codeclimate-test-reporter"
|
34
29
|
end
|
data/lib/checkr.rb
CHANGED
@@ -1,15 +1,25 @@
|
|
1
|
+
require "checkr/base"
|
1
2
|
require "checkr/version"
|
2
3
|
require "checkr/core_ext"
|
3
4
|
require "checkr/candidate"
|
4
5
|
require "checkr/subaccount"
|
5
6
|
require "checkr/report"
|
7
|
+
require "checkr/motor_vehicle_report"
|
8
|
+
require "checkr/sex_offender search"
|
9
|
+
require "checkr/ssn_trace"
|
10
|
+
require "checkr/terrorist_watchlist_search"
|
11
|
+
require "checkr/national_criminal_search"
|
12
|
+
require "checkr/county_criminal_search"
|
13
|
+
require "checkr/report_charge"
|
14
|
+
require "checkr/report_record"
|
6
15
|
|
7
16
|
module Checkr
|
8
17
|
class << self
|
9
|
-
attr_accessor :api_key, :
|
18
|
+
attr_accessor :api_key, :api_version
|
10
19
|
|
11
20
|
def configure
|
12
21
|
yield self
|
22
|
+
api_version = 'v1' if api_version.nil? || api_version.empty?
|
13
23
|
raise Checkr::Error.new(':api_key cannot be blank') if api_key.nil? || api_key.empty?
|
14
24
|
end
|
15
25
|
|
data/lib/checkr/base.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require 'ostruct'
|
3
|
+
|
4
|
+
module Checkr
|
5
|
+
class Base < OpenStruct
|
6
|
+
include HTTParty
|
7
|
+
base_uri "https://api.checkr.io/v1"
|
8
|
+
|
9
|
+
def self.construct(params)
|
10
|
+
new(params)
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def self.handle_response(response)
|
16
|
+
case response.code.to_i
|
17
|
+
when 200...300 then self.construct(response.parsed_response)
|
18
|
+
when 401 then raise Checkr::AuthenticationError, "#{response.body}: Verify your api token."
|
19
|
+
else
|
20
|
+
raise Checkr::UnexpectedError, response.body
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
module Checkr
|
3
|
+
class Candidate < Checkr::Base
|
4
|
+
|
5
|
+
def self.create(params={})
|
6
|
+
if valid?(params)
|
7
|
+
uri = "/subaccounts/#{params[:subaccount_id]}" unless params[:subaccount_id].nil?
|
8
|
+
uri = "#{uri}/candidates"
|
9
|
+
response = self.post(uri, :body => params, :basic_auth => Checkr.auth )
|
10
|
+
handle_response(response)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.find(id)
|
15
|
+
response = self.get("/candidates/#{id}?include=reports", :basic_auth => {:username => Checkr.api_key } )
|
16
|
+
handle_response(response)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.construct(params)
|
20
|
+
reports = params["reports"]
|
21
|
+
candidate = self.new(params.except_key('reports'))
|
22
|
+
candidate.reports = []
|
23
|
+
unless reports.nil? || reports.empty?
|
24
|
+
reports.each do |report_attributes|
|
25
|
+
candidate.reports << Checkr::Report.new(report_attributes)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
return candidate
|
30
|
+
end
|
31
|
+
|
32
|
+
protected
|
33
|
+
|
34
|
+
def self.valid?(params)
|
35
|
+
return true #TODO implement validation
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
class Hash
|
2
|
+
def except_key(which)
|
3
|
+
self.tap{ |h| h.delete(which) }
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
class Object
|
8
|
+
#From rails/Object/try
|
9
|
+
def try(*a, &b)
|
10
|
+
if a.empty? && block_given?
|
11
|
+
yield self
|
12
|
+
else
|
13
|
+
public_send(*a, &b) if respond_to?(a.first)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class String
|
19
|
+
def underscored_class_name
|
20
|
+
self.split("::")[1].
|
21
|
+
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
22
|
+
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
23
|
+
tr("-", "_").
|
24
|
+
downcase
|
25
|
+
end
|
26
|
+
|
27
|
+
def pluralize
|
28
|
+
#TODO this is wrong. But works for now
|
29
|
+
"#{self}s"
|
30
|
+
end
|
31
|
+
|
32
|
+
def tablelize
|
33
|
+
self.underscored_class_name.pluralize
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Checkr
|
2
|
+
class MotorVehicleReport < Checkr::Report
|
3
|
+
def self.construct(params)
|
4
|
+
accidents = params["accidents"]
|
5
|
+
violations = params["violations"]
|
6
|
+
report = self.new(params.except_key('accidents').except_key('violations'))
|
7
|
+
|
8
|
+
report.accidents = []
|
9
|
+
unless accidents.nil? || accidents.empty?
|
10
|
+
accidents.each do |accident_attributes|
|
11
|
+
report.accidents << Checkr::ReportRecord.construct(accident_attributes)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
report.violations = []
|
16
|
+
unless violations.nil? || violations.empty?
|
17
|
+
violations.each do |violation_attributes|
|
18
|
+
report.violations << Checkr::ReportRecord.construct(violation_attributes)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
return report
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
module Checkr
|
3
|
+
class Report < Checkr::Base
|
4
|
+
def self.create(params={})
|
5
|
+
if valid?(params)
|
6
|
+
response = self.post("/#{self.to_s.tablelize}", :body => params, :basic_auth => Checkr.auth )
|
7
|
+
handle_response(response)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.find(id)
|
12
|
+
response = self.get("/#{self.to_s.tablelize}/#{id}", :basic_auth => Checkr.auth )
|
13
|
+
handle_response(response)
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.construct(params)
|
17
|
+
records = params["records"]
|
18
|
+
report = self.new(params.except_key('records'))
|
19
|
+
report.records = []
|
20
|
+
unless records.nil? || records.empty?
|
21
|
+
records.each do |record_attributes|
|
22
|
+
report.records << Checkr::ReportRecord.construct(record_attributes)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
return report
|
27
|
+
end
|
28
|
+
|
29
|
+
protected
|
30
|
+
|
31
|
+
def self.valid?(params)
|
32
|
+
return true #TODO implement validation
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
module Checkr
|
3
|
+
class ReportRecord < Checkr::Base
|
4
|
+
def self.construct(params)
|
5
|
+
charges = params["charges"]
|
6
|
+
record = self.new(params.except_key('charges'))
|
7
|
+
record.charges = []
|
8
|
+
unless charges.nil? || charges.empty?
|
9
|
+
charges.each do |charge_attributes|
|
10
|
+
record.charges << Checkr::ReportCharge.construct(record_attributes)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
return record
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
module Checkr
|
3
|
+
class Subaccount < Checkr::Base
|
4
|
+
|
5
|
+
def self.create(params={})
|
6
|
+
if valid?(params)
|
7
|
+
response = self.post("/subaccounts", :body => params, :basic_auth => Checkr.auth )
|
8
|
+
handle_response(response)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
protected
|
13
|
+
|
14
|
+
def self.valid?(params)
|
15
|
+
true #TODO implement validation
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
data/lib/checkr/version.rb
CHANGED
@@ -0,0 +1,41 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://83ebeabdec09f6670863766f792ead24d61fe3f9:@api.checkr.io/v1/candidates
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: first_name=John&last_name=Smith&dob=1970-01-22&ssn=111-11-2000&phone=5555555555&email=john%40smith.org
|
9
|
+
headers: {}
|
10
|
+
response:
|
11
|
+
status:
|
12
|
+
code: 201
|
13
|
+
message: Created
|
14
|
+
headers:
|
15
|
+
Server:
|
16
|
+
- Cowboy
|
17
|
+
Connection:
|
18
|
+
- keep-alive
|
19
|
+
Date:
|
20
|
+
- Sun, 12 Oct 2014 16:07:25 GMT
|
21
|
+
Status:
|
22
|
+
- 201 Created
|
23
|
+
Strict-Transport-Security:
|
24
|
+
- max-age=31536000
|
25
|
+
Content-Type:
|
26
|
+
- application/json
|
27
|
+
Content-Length:
|
28
|
+
- '375'
|
29
|
+
X-Content-Type-Options:
|
30
|
+
- nosniff
|
31
|
+
Set-Cookie:
|
32
|
+
- checkr.production=BAh7CEkiD3Nlc3Npb25faWQGOgZFVEkiRTg5ZjVlZmE4ODBmODU0Mzk0ZWJk%0AOTIxNzAwZWI4MDJkN2YzMjAyMzdiMDliOGVmMjYxY2MzZDY2MjFjZmVhMmEG%0AOwBGSSIJY3NyZgY7AEZJIiUxYzg4MGI1NzQ4MGYyNzAzYjFmNTNhZTI2M2E0%0AZDg5MwY7AEZJIg10cmFja2luZwY7AEZ7B0kiFEhUVFBfVVNFUl9BR0VOVAY7%0AAFRJIi1kYTM5YTNlZTVlNmI0YjBkMzI1NWJmZWY5NTYwMTg5MGFmZDgwNzA5%0ABjsARkkiGUhUVFBfQUNDRVBUX0xBTkdVQUdFBjsAVEkiLWRhMzlhM2VlNWU2%0AYjRiMGQzMjU1YmZlZjk1NjAxODkwYWZkODA3MDkGOwBG%0A--f84a5c0327e8d8d8fb706f9410e08e0330caae86;
|
33
|
+
path=/; HttpOnly; secure
|
34
|
+
Via:
|
35
|
+
- 1.1 vegur
|
36
|
+
body:
|
37
|
+
encoding: UTF-8
|
38
|
+
string: '{"id":"75c62b8845bee2df0752b009","object":"test_candidate","uri":"/v1/candidates/75c62b8845bee2df0752b009","created_at":"2014-10-12T16:07:25Z","first_name":"John","last_name":"Smith","middle_name":null,"dob":"1970-01-22","ssn":"XXX-XX-2000","email":"john@smith.org","zipcode":null,"phone":"5555555555","driver_license_state":null,"driver_license_number":null,"report_ids":[]}'
|
39
|
+
http_version:
|
40
|
+
recorded_at: Sun, 12 Oct 2014 16:07:25 GMT
|
41
|
+
recorded_with: VCR 2.9.3
|