checkr-official 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +5 -0
- data/.travis.yml +16 -0
- data/Gemfile +8 -0
- data/History.txt +4 -0
- data/README.md +58 -0
- data/Rakefile +14 -0
- data/VERSION +1 -0
- data/bin/checkr-console +7 -0
- data/checkr-official.gemspec +28 -0
- data/gemfiles/default-with-activesupport.gemfile +10 -0
- data/gemfiles/json.gemfile +12 -0
- data/gemfiles/yajl.gemfile +12 -0
- data/lib/checkr.rb +241 -0
- data/lib/checkr/api_class.rb +395 -0
- data/lib/checkr/api_list.rb +78 -0
- data/lib/checkr/api_resource.rb +18 -0
- data/lib/checkr/api_singleton.rb +5 -0
- data/lib/checkr/candidate.rb +35 -0
- data/lib/checkr/county_criminal_search.rb +19 -0
- data/lib/checkr/document.rb +13 -0
- data/lib/checkr/document_list.rb +25 -0
- data/lib/checkr/errors/api_connection_error.rb +4 -0
- data/lib/checkr/errors/api_error.rb +10 -0
- data/lib/checkr/errors/authentication_error.rb +4 -0
- data/lib/checkr/errors/checkr_error.rb +20 -0
- data/lib/checkr/errors/invalid_request_error.rb +10 -0
- data/lib/checkr/geo.rb +19 -0
- data/lib/checkr/motor_vehicle_report.rb +31 -0
- data/lib/checkr/national_criminal_search.rb +17 -0
- data/lib/checkr/report.rb +43 -0
- data/lib/checkr/report_list.rb +27 -0
- data/lib/checkr/sex_offender_search.rb +18 -0
- data/lib/checkr/ssn_trace.rb +18 -0
- data/lib/checkr/subscription.rb +27 -0
- data/lib/checkr/terrorist_watchlist_search.rb +17 -0
- data/lib/checkr/util.rb +91 -0
- data/lib/checkr/version.rb +3 -0
- data/mclovin.jpg +0 -0
- data/tasks/api_test.rb +192 -0
- data/test/checkr/api_class_test.rb +426 -0
- data/test/checkr/api_list_test.rb +27 -0
- data/test/checkr/api_resource_test.rb +28 -0
- data/test/checkr/api_singleton_test.rb +12 -0
- data/test/checkr/authentication_test.rb +50 -0
- data/test/checkr/candidate_test.rb +164 -0
- data/test/checkr/county_criminal_search_test.rb +82 -0
- data/test/checkr/document_test.rb +90 -0
- data/test/checkr/geo_test.rb +73 -0
- data/test/checkr/motor_vehicle_report_test.rb +130 -0
- data/test/checkr/national_criminal_search_test.rb +74 -0
- data/test/checkr/report_test.rb +124 -0
- data/test/checkr/sex_offender_search_test.rb +75 -0
- data/test/checkr/ssn_trace_test.rb +78 -0
- data/test/checkr/status_codes_test.rb +63 -0
- data/test/checkr/subscription_test.rb +96 -0
- data/test/checkr/terrorist_watchlist_search_test.rb +74 -0
- data/test/checkr/util_test.rb +50 -0
- data/test/mock_resource.rb +88 -0
- data/test/test_data.rb +413 -0
- data/test/test_helper.rb +43 -0
- metadata +230 -0
@@ -0,0 +1,78 @@
|
|
1
|
+
module Checkr
|
2
|
+
class APIList < APIClass
|
3
|
+
include Enumerable
|
4
|
+
|
5
|
+
attribute :object
|
6
|
+
attribute :data
|
7
|
+
attr_accessor :api_list_klass
|
8
|
+
|
9
|
+
def [](k)
|
10
|
+
data[k]
|
11
|
+
end
|
12
|
+
|
13
|
+
def []=(k, v)
|
14
|
+
data[k]=v
|
15
|
+
end
|
16
|
+
|
17
|
+
def last
|
18
|
+
data.last
|
19
|
+
end
|
20
|
+
|
21
|
+
def length
|
22
|
+
data.length
|
23
|
+
end
|
24
|
+
|
25
|
+
def each(&blk)
|
26
|
+
data.each(&blk)
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.constructor(klass)
|
30
|
+
lambda do |json|
|
31
|
+
klass = Util.constantize(klass) unless klass.is_a?(Class)
|
32
|
+
|
33
|
+
instance = self.new
|
34
|
+
instance.api_list_klass = klass
|
35
|
+
instance.refresh_from(json)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def refresh_from(json)
|
40
|
+
self.object = "list"
|
41
|
+
self.data ||= []
|
42
|
+
self.json = Util.sorta_deep_clone(json)
|
43
|
+
|
44
|
+
if json.is_a?(Hash)
|
45
|
+
self.refresh_from_hash(json)
|
46
|
+
elsif json.is_a?(Array)
|
47
|
+
self.refresh_from_array(json)
|
48
|
+
else
|
49
|
+
self.clear_changed_attributes
|
50
|
+
self
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def refresh_from_hash(json={})
|
55
|
+
klass = api_list_klass
|
56
|
+
|
57
|
+
json.each do |k, v|
|
58
|
+
if self.class.attribute_writer_names.include?(k.to_sym)
|
59
|
+
if k.to_sym == :data
|
60
|
+
self.send("#{k}=", v.map{ |i| klass.construct(i) })
|
61
|
+
else
|
62
|
+
self.send("#{k}=", v)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
self
|
67
|
+
end
|
68
|
+
|
69
|
+
def refresh_from_array(array=[])
|
70
|
+
klass = api_list_klass
|
71
|
+
json = {
|
72
|
+
:object => "list",
|
73
|
+
:data => array
|
74
|
+
}
|
75
|
+
refresh_from_hash(json)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Checkr
|
2
|
+
class APIResource < APIClass
|
3
|
+
attribute :id
|
4
|
+
attribute :object
|
5
|
+
attribute :uri
|
6
|
+
attribute :created_at
|
7
|
+
|
8
|
+
api_instance_method :refresh, :get, :constructor => :self
|
9
|
+
|
10
|
+
def path(base=self.class.path)
|
11
|
+
unless id
|
12
|
+
raise InvalidRequestError.new("Could not determine which URL to request: #{self.class} instance has an invalid ID: #{id.inspect}", 'id')
|
13
|
+
end
|
14
|
+
"#{base}/#{id}"
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Checkr
|
2
|
+
class Candidate < APIResource
|
3
|
+
|
4
|
+
attribute :first_name
|
5
|
+
attribute :middle_name
|
6
|
+
attribute :last_name
|
7
|
+
attribute :email
|
8
|
+
attribute :phone
|
9
|
+
attribute :zipcode
|
10
|
+
attribute :dob
|
11
|
+
attribute :ssn
|
12
|
+
attribute :driver_license_number
|
13
|
+
attribute :driver_license_state
|
14
|
+
attribute :previous_driver_license_number
|
15
|
+
attribute :previous_driver_license_state
|
16
|
+
attribute :copy_requested
|
17
|
+
attribute :custom_id
|
18
|
+
attribute :reports, :ReportList, :nested => true
|
19
|
+
attribute_writer_alias :report_ids, :reports
|
20
|
+
attribute :geos, APIList.constructor(:Geo)
|
21
|
+
attribute_writer_alias :geo_ids, :geos
|
22
|
+
attribute :adjudication
|
23
|
+
attribute :documents, :DocumentList, :nested => true, :default => {}
|
24
|
+
|
25
|
+
api_class_method :all, :get, :constructor => APIList.constructor(:Candidate)
|
26
|
+
api_class_method :create, :post
|
27
|
+
api_class_method :retrieve, :get, ":path/:id", :arguments => [:id]
|
28
|
+
|
29
|
+
def self.path
|
30
|
+
"/v1/candidates"
|
31
|
+
end
|
32
|
+
|
33
|
+
APIClass.register_subclass(self, "candidate")
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Checkr
|
2
|
+
class CountyCriminalSearch < APIResource
|
3
|
+
|
4
|
+
attribute :status
|
5
|
+
attribute :completed_at
|
6
|
+
attribute :turnaround_time
|
7
|
+
attribute :county
|
8
|
+
attribute :state
|
9
|
+
attribute :records
|
10
|
+
|
11
|
+
api_class_method :retrieve, :get, ":path/:id", :arguments => [:id]
|
12
|
+
|
13
|
+
def self.path
|
14
|
+
"/v1/county_criminal_searches"
|
15
|
+
end
|
16
|
+
|
17
|
+
APIClass.register_subclass(self, "county_criminal_search")
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Checkr
|
2
|
+
class Document < APIResource
|
3
|
+
|
4
|
+
attribute :download_uri
|
5
|
+
attribute :filesize
|
6
|
+
attribute :filename
|
7
|
+
attribute :content_type
|
8
|
+
|
9
|
+
# Method #create and #all are all on the Candidate instance
|
10
|
+
|
11
|
+
APIClass.register_subclass(self, "document")
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Checkr
|
2
|
+
class DocumentList < APIList
|
3
|
+
|
4
|
+
attribute :next_href
|
5
|
+
attribute :previous_href
|
6
|
+
attribute :count
|
7
|
+
attr_accessor :parent
|
8
|
+
|
9
|
+
api_instance_method :all, :get
|
10
|
+
api_instance_method :create, :post, :constructor => :Document
|
11
|
+
|
12
|
+
def self.construct(json, parent=nil)
|
13
|
+
lambda = constructor(:Document)
|
14
|
+
instance = lambda.call(json)
|
15
|
+
instance.parent = parent if parent
|
16
|
+
instance.clear_changed_attributes
|
17
|
+
instance
|
18
|
+
end
|
19
|
+
|
20
|
+
def path
|
21
|
+
parent.path + "/documents"
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Checkr
|
2
|
+
class CheckrError < StandardError
|
3
|
+
attr_reader :message
|
4
|
+
attr_reader :http_status
|
5
|
+
attr_reader :http_body
|
6
|
+
attr_reader :json_body
|
7
|
+
|
8
|
+
def initialize(message=nil, http_status=nil, http_body=nil, json_body=nil)
|
9
|
+
@message = message
|
10
|
+
@http_status = http_status
|
11
|
+
@http_body = http_body
|
12
|
+
@json_body = json_body
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_s
|
16
|
+
status_string = @http_status.nil? ? "" : "(Status #{@http_status}) "
|
17
|
+
"#{status_string}#{@message}"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/checkr/geo.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
module Checkr
|
2
|
+
class Geo < APIResource
|
3
|
+
|
4
|
+
attribute :name
|
5
|
+
attribute :state
|
6
|
+
|
7
|
+
api_class_method :all, :get, :constructor => APIList.constructor(:Geo)
|
8
|
+
api_class_method :retrieve, :get, ":path/:id", :arguments => [:id]
|
9
|
+
api_class_method :create, :post
|
10
|
+
|
11
|
+
api_instance_method :delete, :delete
|
12
|
+
|
13
|
+
def self.path
|
14
|
+
"/v1/geos"
|
15
|
+
end
|
16
|
+
|
17
|
+
APIClass.register_subclass(self, "geo")
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Checkr
|
2
|
+
class MotorVehicleReport < APIResource
|
3
|
+
|
4
|
+
attribute :status
|
5
|
+
attribute :completed_at
|
6
|
+
attribute :turnaround_time
|
7
|
+
attribute :full_name
|
8
|
+
attribute :license_number
|
9
|
+
attribute :license_state
|
10
|
+
attribute :previous_license_number
|
11
|
+
attribute :previous_license_state
|
12
|
+
attribute :license_status
|
13
|
+
attribute :license_type
|
14
|
+
attribute :license_class
|
15
|
+
attribute :expiration_date
|
16
|
+
attribute :issued_date
|
17
|
+
attribute :first_issued_date
|
18
|
+
attribute :inferred_issued_date
|
19
|
+
attribute :restrictions
|
20
|
+
attribute :accidents
|
21
|
+
attribute :violations
|
22
|
+
|
23
|
+
api_class_method :retrieve, :get, ":path/:id", :arguments => [:id]
|
24
|
+
|
25
|
+
def self.path
|
26
|
+
"/v1/motor_vehicle_reports"
|
27
|
+
end
|
28
|
+
|
29
|
+
APIClass.register_subclass(self, "motor_vehicle_report")
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Checkr
|
2
|
+
class NationalCriminalSearch < APIResource
|
3
|
+
|
4
|
+
attribute :status
|
5
|
+
attribute :completed_at
|
6
|
+
attribute :turnaround_time
|
7
|
+
attribute :records
|
8
|
+
|
9
|
+
api_class_method :retrieve, :get, ":path/:id", :arguments => [:id]
|
10
|
+
|
11
|
+
def self.path
|
12
|
+
"/v1/national_criminal_searches"
|
13
|
+
end
|
14
|
+
|
15
|
+
APIClass.register_subclass(self, "national_criminal_search")
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Checkr
|
2
|
+
class Report < APIResource
|
3
|
+
|
4
|
+
attribute :status
|
5
|
+
attribute :values
|
6
|
+
attribute :completed_at
|
7
|
+
attribute :turnaround_time
|
8
|
+
attribute :package
|
9
|
+
attribute :values
|
10
|
+
attribute :candidate, :Candidate
|
11
|
+
attribute_writer_alias :candidate_id, :candidate
|
12
|
+
|
13
|
+
attribute :ssn_trace, :SSNTrace
|
14
|
+
attribute_writer_alias :ssn_trace_id, :ssn_trace
|
15
|
+
|
16
|
+
attribute :sex_offender_search, :SexOffenderSearch
|
17
|
+
attribute_writer_alias :sex_offender_search_id, :sex_offender_search
|
18
|
+
|
19
|
+
attribute :national_criminal_search, :NationalCriminalSearch
|
20
|
+
attribute_writer_alias :national_criminal_search_id, :national_criminal_search
|
21
|
+
|
22
|
+
attribute :terrorist_watchlist_search, :TerroristWatchlistSearch
|
23
|
+
attribute_writer_alias :terrorist_watchlist_search_id, :terrorist_watchlist_search
|
24
|
+
|
25
|
+
attribute :county_criminal_searches, APIList.constructor(:CountyCriminalSearch)
|
26
|
+
attribute_writer_alias :county_criminal_search_ids, :county_criminal_searches
|
27
|
+
|
28
|
+
attribute :motor_vehicle_report, :MotorVehicleReport
|
29
|
+
attribute_writer_alias :motor_vehicle_report_id, :motor_vehicle_report
|
30
|
+
|
31
|
+
|
32
|
+
api_class_method :retrieve, :get, ":path/:id", :arguments => [:id]
|
33
|
+
api_class_method :create, :post
|
34
|
+
|
35
|
+
api_instance_method :save, :post, :default_params => :changed_attributes
|
36
|
+
|
37
|
+
def self.path
|
38
|
+
"/v1/reports"
|
39
|
+
end
|
40
|
+
|
41
|
+
APIClass.register_subclass(self, "report")
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Checkr
|
2
|
+
class ReportList < APIList
|
3
|
+
|
4
|
+
attr_accessor :parent
|
5
|
+
|
6
|
+
api_instance_method :create, :post, :constructor => :Report, :default_params => :create_defaults, :arguments => [:package]
|
7
|
+
|
8
|
+
def self.construct(json, parent=nil)
|
9
|
+
lambda = constructor(:Report)
|
10
|
+
instance = lambda.call(json)
|
11
|
+
instance.parent = parent if parent
|
12
|
+
instance.clear_changed_attributes
|
13
|
+
instance
|
14
|
+
end
|
15
|
+
|
16
|
+
def path
|
17
|
+
"/v1/reports"
|
18
|
+
end
|
19
|
+
|
20
|
+
def create_defaults
|
21
|
+
{
|
22
|
+
:candidate_id => parent.id
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Checkr
|
2
|
+
class SexOffenderSearch < APIResource
|
3
|
+
|
4
|
+
attribute :status
|
5
|
+
attribute :values
|
6
|
+
attribute :completed_at
|
7
|
+
attribute :turnaround_time
|
8
|
+
attribute :records
|
9
|
+
|
10
|
+
api_class_method :retrieve, :get, ":path/:id", :arguments => [:id]
|
11
|
+
|
12
|
+
def self.path
|
13
|
+
"/v1/sex_offender_searches"
|
14
|
+
end
|
15
|
+
|
16
|
+
APIClass.register_subclass(self, "sex_offender_search")
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Checkr
|
2
|
+
class SSNTrace < APIResource
|
3
|
+
|
4
|
+
attribute :status
|
5
|
+
attribute :completed_at
|
6
|
+
attribute :turnaround_time
|
7
|
+
attribute :ssn
|
8
|
+
attribute :addresses
|
9
|
+
|
10
|
+
api_class_method :retrieve, :get, ":path/:id", :arguments => [:id]
|
11
|
+
|
12
|
+
def self.path
|
13
|
+
"/v1/ssn_traces"
|
14
|
+
end
|
15
|
+
|
16
|
+
APIClass.register_subclass(self, "ssn_trace")
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Checkr
|
2
|
+
class Subscription < APIResource
|
3
|
+
|
4
|
+
attribute :status
|
5
|
+
attribute :values
|
6
|
+
attribute :canceled_at
|
7
|
+
attribute :package
|
8
|
+
attribute :values
|
9
|
+
attribute :interval_count
|
10
|
+
attribute :interval_unit
|
11
|
+
attribute :values
|
12
|
+
attribute :start_date
|
13
|
+
attribute :candidate, :Candidate
|
14
|
+
attribute_writer_alias :candidate_id, :candidate
|
15
|
+
|
16
|
+
api_class_method :retrieve, :get, ":path/:id", :arguments => [:id]
|
17
|
+
api_class_method :create, :post
|
18
|
+
|
19
|
+
api_instance_method :cancel, :delete
|
20
|
+
|
21
|
+
def self.path
|
22
|
+
"/v1/subscriptions"
|
23
|
+
end
|
24
|
+
|
25
|
+
APIClass.register_subclass(self, "subscription")
|
26
|
+
end
|
27
|
+
end
|