ssci_inc 0.1.0

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.
Files changed (42) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +26 -0
  3. data/.octopolo.yml +2 -0
  4. data/.ruby-gemset +1 -0
  5. data/.ruby-version +1 -0
  6. data/.travis.yml +22 -0
  7. data/CHANGELOG.markdown +0 -0
  8. data/Gemfile +3 -0
  9. data/README.md +66 -0
  10. data/Rakefile +26 -0
  11. data/lib/ssci_inc/configuration.rb +62 -0
  12. data/lib/ssci_inc/dsl.rb +30 -0
  13. data/lib/ssci_inc/person_name.rb +29 -0
  14. data/lib/ssci_inc/request.rb +196 -0
  15. data/lib/ssci_inc/response.rb +44 -0
  16. data/lib/ssci_inc/screening/civil_county.rb +17 -0
  17. data/lib/ssci_inc/screening/credit.rb +16 -0
  18. data/lib/ssci_inc/screening/criminal_county.rb +17 -0
  19. data/lib/ssci_inc/screening/criminal_federal.rb +17 -0
  20. data/lib/ssci_inc/screening/criminal_security.rb +12 -0
  21. data/lib/ssci_inc/screening/criminal_state.rb +16 -0
  22. data/lib/ssci_inc/screening/eviction.rb +16 -0
  23. data/lib/ssci_inc/screening/model.rb +27 -0
  24. data/lib/ssci_inc/screening/person_search.rb +16 -0
  25. data/lib/ssci_inc/version.rb +3 -0
  26. data/lib/ssci_inc.rb +19 -0
  27. data/ssci_inc.gemspec +32 -0
  28. data/test/integration/initial_request_test.rb +21 -0
  29. data/test/test-updated.xml +113 -0
  30. data/test/test_helper.rb +120 -0
  31. data/test/unit/request_test.rb +93 -0
  32. data/test/unit/response_test.rb +68 -0
  33. data/test/unit/screening/civil_county_test.rb +12 -0
  34. data/test/unit/screening/credit_test.rb +12 -0
  35. data/test/unit/screening/criminal_county_test.rb +12 -0
  36. data/test/unit/screening/criminal_federal_test.rb +12 -0
  37. data/test/unit/screening/criminal_security_test.rb +11 -0
  38. data/test/unit/screening/criminal_state_test.rb +12 -0
  39. data/test/unit/screening/eviction_test.rb +11 -0
  40. data/test/unit/screening/model_test.rb +37 -0
  41. data/test/unit/screening/person_search_test.rb +11 -0
  42. metadata +233 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: df8f76de6d18ea79119204dc67e777553af6a989
4
+ data.tar.gz: ae34bd28ec63ec2ae9a83a0ce39c61cef50a604a
5
+ SHA512:
6
+ metadata.gz: 47c824840d70d4a2a8372e83d530cd4b4627c1da2acc2382c81a95c16adbf120f7bdd69e0fa83fcea5b5e5299b2ff29b0a5a98ff088aefd23cbeea7668d26a5e
7
+ data.tar.gz: 5f8b1beddc9cf92735058638c64cdd39abc3147023707c64928124a316922b262c0ff6e40d29f4ab499841fec8382f4e579d4add252381d732848775c3d20489
data/.gitignore ADDED
@@ -0,0 +1,26 @@
1
+ *.gem
2
+ .bundle
3
+ pkg/*
4
+ Gemfile.lock
5
+
6
+ # Mac
7
+ .DS_Store
8
+
9
+ # NetBeans
10
+ nbproject
11
+
12
+ # Eclipse
13
+ .project
14
+
15
+ # Redcar
16
+ .redcar
17
+
18
+ # Rubinius
19
+ *.rbc
20
+
21
+ # Vim
22
+ *.swp
23
+ *.swo
24
+
25
+ # RubyMine
26
+ .idea
data/.octopolo.yml ADDED
@@ -0,0 +1,2 @@
1
+ deploy_branch: master
2
+ github_repo: sportngin/ssci_inc
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ ssci_inc
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.2.4
data/.travis.yml ADDED
@@ -0,0 +1,22 @@
1
+ sudo: false
2
+ branches:
3
+ only:
4
+ - master
5
+
6
+ notifications:
7
+ slack: sportngin:Yr24DXJUvIOegSPwKMG099D1
8
+
9
+ after_script:
10
+ - uptime && vmstat -S M
11
+
12
+ language: ruby
13
+ rvm:
14
+ - 1.9.3
15
+ - 2.0.0
16
+ - 2.1
17
+ - 2.2
18
+
19
+ cache: bundler
20
+
21
+ script:
22
+ - bundle exec rake test
File without changes
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
data/README.md ADDED
@@ -0,0 +1,66 @@
1
+ # SSCI Inc
2
+
3
+ The ssci_inc gem is a ruby gem used for submitted background check requests to
4
+ [SSCI](http://www.ssci2000.com/)
5
+
6
+ Using this API requires that you have an existing account with SSCI.
7
+
8
+ Install
9
+ --------
10
+
11
+ ```shell
12
+ gem install ssci_inc
13
+ ```
14
+ or add the following line to Gemfile:
15
+
16
+ ```ruby
17
+ gem 'ssci_inc'
18
+ ```
19
+ and run `bundle install` from your shell.
20
+
21
+ Usage
22
+ ---------------------------
23
+
24
+ To create a new background check and submit it.
25
+
26
+ ```ruby
27
+ request = SsciInc::Request.new do |r|
28
+ r.user_name = "XML_TST",
29
+ r.password = "ScROLL447breaK",
30
+ r.type = "TST Media",
31
+ r.reference_id = 112233,
32
+ r.reference = "ABC Company Inc.",
33
+ r.given_name = "HANK",
34
+ r.family_name = "MESS",
35
+ r.ssn = "333-22-1111",
36
+ r.date_of_birth = "1960-01-01",
37
+ r.postal_code = "60750",
38
+ r.region = "IL",
39
+ r.municipality = "FANTASY ISLAND",
40
+ r.address_line = 899,
41
+ r.street_name = "LINCOLN RD",
42
+ r.postback_url = "http://127.0.0.1/listen.php",
43
+ r.postback_username = "user",
44
+ r.postback_password = "secret",
45
+ r.use_defaults = true
46
+ end
47
+
48
+ # or initialize with a hash
49
+
50
+ request = SsciInc::Request.new(hash)
51
+
52
+ # or initialize with nothing and build on the fly
53
+
54
+ request = SsciInc::Request.new
55
+ request.user_name = "..."
56
+
57
+ # and then add some screens
58
+
59
+ request.criminal_county_screen do |screen|
60
+ screen.region "WA"
61
+ screen.county "KING"
62
+ end
63
+
64
+ request.submit # => SsciInc::Response
65
+ ```
66
+
data/Rakefile ADDED
@@ -0,0 +1,26 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rake/testtask'
3
+
4
+ task :default => :test
5
+
6
+ task :test => ["test:units","test:integration"]
7
+
8
+ namespace :test do
9
+
10
+ Rake::TestTask.new(:units) do |test|
11
+ test.libs << 'lib' << 'test'
12
+ test.test_files = FileList["test/unit/**/*_test.rb"]
13
+ test.verbose = true
14
+ end
15
+
16
+ Rake::TestTask.new(:integration) do |test|
17
+ test.libs << 'lib' << 'test'
18
+ test.test_files = FileList["test/integration/**/*_test.rb"]
19
+ test.verbose = true
20
+ end
21
+
22
+ end
23
+
24
+ task :console do
25
+ sh "pry -I lib/ssci_inc -r ssci_inc.rb"
26
+ end
@@ -0,0 +1,62 @@
1
+ module SsciInc
2
+ class Configuration
3
+
4
+ attr_accessor :base_uri,
5
+ :user_name,
6
+ :password,
7
+ :postback_url,
8
+ :postback_username,
9
+ :postback_password
10
+
11
+ def base_uri
12
+ @base_uri ||= 'http://localhost'
13
+ end
14
+
15
+ end
16
+
17
+ class << self
18
+ attr_accessor :configuration
19
+
20
+ def configuration
21
+ @configuration ||= Configuration.new
22
+ end
23
+ end
24
+
25
+ # Public: Configure ssci inc gem
26
+ #
27
+ # Examples
28
+ # SsciInc.configure do |config|
29
+ # bg_create_uri: ********
30
+ # bg_index_uri: ********
31
+ # site_identifier: ********
32
+ # account_code: ********
33
+ # username: ********
34
+ # password: ********
35
+ # postback_username: ********
36
+ # postback_password: ********
37
+ # end
38
+ #
39
+ def self.configure
40
+ yield(configuration)
41
+ end
42
+
43
+ # Public: Configure ssci inc gem with yaml file
44
+ #
45
+ # file - The name of the file to parse. (optional)
46
+ # Defaults to "config/ssci_inc.yml".
47
+ #
48
+ # Examples
49
+ # SsciInc.load_config("ssci_inc.yml")
50
+ #
51
+ def self.load_config(file="config/ssci_inc.yml")
52
+ if File.exists?(file)
53
+ h = YAML::load(IO.read(file))
54
+ configure do |config|
55
+ h.each do |k,v|
56
+ config.send("#{k}=", v) if config.respond_to?("#{k}=")
57
+ end
58
+ end
59
+ end
60
+ end
61
+
62
+ end
@@ -0,0 +1,30 @@
1
+ module SsciInc
2
+ module DSL
3
+
4
+ def screen(klass, h={}, &block)
5
+ s = klass.new(h)
6
+ yield s if block_given?
7
+ @screenings << s
8
+ end
9
+
10
+ %w[CivilCounty Credit CriminalCounty CriminalFederal CriminalSecurity
11
+ CriminalState PersonSearch].each do |class_name|
12
+ class_eval <<-eoruby, __FILE__, __LINE__ + 1
13
+ def #{class_name.underscore}_screen(*args, &block)
14
+ screen(Screening::#{class_name}, *args, &block)
15
+ end
16
+ eoruby
17
+ end
18
+
19
+ def alias(h={}, &block)
20
+ @aliases << person_name(h, &block)
21
+ end
22
+
23
+ def person_name(h={}, &block)
24
+ p = PersonName.new(h)
25
+ yield p if block_given?
26
+ p
27
+ end
28
+
29
+ end
30
+ end
@@ -0,0 +1,29 @@
1
+ module SsciInc
2
+ class PersonName
3
+
4
+ attr_accessor :given_name,
5
+ :middle_name,
6
+ :family_name,
7
+ :affix
8
+
9
+ def initialize(h={})
10
+ h.each {|k,v| send("#{k}=", v) if respond_to?("#{k}=") }
11
+ end
12
+
13
+ def as_xml
14
+ Nokogiri::XML::Builder.new do |xml|
15
+ xml.PersonName {
16
+ xml.GivenName given_name
17
+ xml.MiddleName middle_name
18
+ xml.FamilyName family_name
19
+ xml.Affix affix
20
+ }
21
+ end.parent.root
22
+ end
23
+
24
+ def to_xml
25
+ as_xml.to_xml
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,196 @@
1
+ module SsciInc
2
+ class Request
3
+ include DSL
4
+
5
+ ADDITIONAL_ITEMS = [:postback_url, :postback_username,
6
+ :postback_password, :embed_credentials, :ordernotes,
7
+ :interface, :monthly_income, :monthly_rent]
8
+
9
+ # BackgroundCheck
10
+ attr_accessor :config,
11
+ :base_uri,
12
+ :user_name,
13
+ :password
14
+
15
+ # BackgroundSearchPackage
16
+ attr_accessor :action,
17
+ :type,
18
+ :reference_id,
19
+ :reference
20
+
21
+ # PersonalData
22
+ attr_accessor :email_address,
23
+ :telephone
24
+
25
+ # PersonName
26
+ attr_accessor :given_name,
27
+ :middle_name,
28
+ :family_name,
29
+ :affix
30
+
31
+ # DemographicDetail
32
+ attr_accessor :government_id,
33
+ :ssn_country_code,
34
+ :issuing_authority,
35
+ :date_of_birth
36
+
37
+ # PostalAddress
38
+ attr_accessor :country_code,
39
+ :postal_code,
40
+ :region,
41
+ :municipality,
42
+ :address_line,
43
+ :street_name
44
+
45
+ # Screenings
46
+ attr_reader :screenings
47
+ attr_accessor :use_defaults
48
+
49
+ # AdditionalItems
50
+ attr_accessor *ADDITIONAL_ITEMS
51
+
52
+ attr_reader :aliases
53
+
54
+ def initialize(h={})
55
+ init_defaults
56
+ h.each do |k,v|
57
+ send("#{k}=", v) if respond_to?("#{k}=")
58
+ end
59
+ yield self if block_given?
60
+ end
61
+
62
+ def additional_items
63
+ ADDITIONAL_ITEMS.inject({}) do |h,a|
64
+ v = send(a)
65
+ h[a] = send(a) unless v.nil?
66
+ h
67
+ end
68
+ end
69
+
70
+ def ssn=(new_ssn)
71
+ @government_id = new_ssn
72
+ @ssn_country_code = "US"
73
+ @issuing_authority = "SSN"
74
+ end
75
+
76
+ def name
77
+ person_name do |p|
78
+ p.given_name = given_name
79
+ p.middle_name = middle_name
80
+ p.family_name = family_name
81
+ p.affix = affix
82
+ end
83
+ end
84
+
85
+ def as_xml
86
+ Nokogiri::XML::Builder.new do |xml|
87
+ xml.BackgroundCheck(:userId => user_name, :password => password) {
88
+ xml.BackgroundSearchPackage(:type => type, :action => action) {
89
+ xml.ReferenceId reference_id
90
+ xml.Reference reference
91
+ xml.PersonalData {
92
+ xml.EmailAddress email_address
93
+ xml.Telephone telephone
94
+ xml.parent << name.as_xml
95
+ if aliases.any?
96
+ xml.Aliases {
97
+ aliases.each do |a|
98
+ xml.parent << a.as_xml
99
+ end
100
+ }
101
+ end
102
+ xml.DemographicDetail {
103
+ xml.GovernmentId(government_id,
104
+ :countryCode => ssn_country_code,
105
+ :issuingAuthority => issuing_authority)
106
+ xml.DateOfBirth date_of_birth
107
+ } # DemographicDetail
108
+ xml.PostalAddress {
109
+ xml.CountryCode country_code == "Canada" ? "CA" : "US"
110
+ xml.PostalCode postal_code
111
+ xml.Region region
112
+ xml.Municipality municipality
113
+ xml.DeliveryAddress {
114
+ xml.AddressLine address_line
115
+ xml.StreetName street_name
116
+ } # DeliveryAddress
117
+ } # PostalAddress
118
+ } # PersonalData
119
+ xml.Screenings(:useConfigurationDefaults => yes_or_no(use_defaults)) {
120
+ screenings.each do |s|
121
+ xml.parent << s.as_xml
122
+ end
123
+ additional_items.each do |k,v|
124
+ xml.AdditionalItems(:type => "x:#{k}") {
125
+ xml.Text v
126
+ }
127
+ end
128
+ } # Screenings
129
+ } # BackgroundSearchPackage
130
+ } # BackgroundCheck
131
+ end
132
+ end
133
+
134
+ def to_xml
135
+ as_xml.to_xml
136
+ end
137
+
138
+ def request_options
139
+ {
140
+ body: { request: to_xml },
141
+ basic_auth: { username: user_name, password: password }
142
+ }
143
+ end
144
+
145
+ def build_request
146
+ HTTParty::Request.new(Net::HTTP::Post, base_uri, request_options)
147
+ end
148
+
149
+ def submit
150
+ response = build_request.perform
151
+ data = response.parsed_response
152
+ SsciInc::Response.new(data)
153
+ end
154
+
155
+ def config
156
+ @config || SsciInc.configuration
157
+ end
158
+
159
+ def base_uri
160
+ @base_uri || config.base_uri
161
+ end
162
+
163
+ def user_name
164
+ @user_name || config.user_name
165
+ end
166
+
167
+ def password
168
+ @password || config.password
169
+ end
170
+
171
+ def postback_url
172
+ @postback_url || config.postback_url
173
+ end
174
+
175
+ def postback_username
176
+ @postback_username || config.postback_username
177
+ end
178
+
179
+ def postback_password
180
+ @postback_password || config.postback_password
181
+ end
182
+
183
+ private
184
+
185
+ def init_defaults
186
+ @action = "submit"
187
+ @screenings = []
188
+ @aliases = []
189
+ end
190
+
191
+ def yes_or_no(v)
192
+ !!v ? "yes" : "no"
193
+ end
194
+
195
+ end
196
+ end
@@ -0,0 +1,44 @@
1
+ module SsciInc
2
+ class Response
3
+
4
+ attr_reader :user_id, :password, :reference_id, :reference, :order_id, :order_status
5
+ attr_reader :result_status
6
+
7
+ # ErrorReport
8
+ attr_reader :error_code, :error_description
9
+
10
+ # postback
11
+ attr_reader :result_status,
12
+ :order_status_flag,
13
+ :screening_results_type,
14
+ :screening_results_media_type,
15
+ :screening_results_result_type,
16
+ :result_url
17
+
18
+ attr_reader :data
19
+
20
+ def initialize(data)
21
+ @data = data
22
+ document = Nokogiri::XML.parse(data)
23
+ @user_id = document.at("//@userId").try(:value)
24
+ @password = document.at("//@password").try(:value)
25
+ @reference_id = document.at("//ReferenceId").try(:text)
26
+ @reference = document.at("//Reference").try(:text)
27
+ @order_id = document.at("//OrderId").try(:text)
28
+ @order_status = document.at("//OrderStatus").try(:text)
29
+
30
+ # errors
31
+ @error_code = document.at("//ErrorCode").try(:text)
32
+ @error_description = document.at("//ErrorDescription").try(:text)
33
+
34
+ # completed postback response
35
+ @result_status = document.at("//ResultStatus").try(:text)
36
+ @order_status_flag = document.at("//OrderStatus//@flag").try(:value)
37
+ @screening_results_type = document.at("//ScreeningResults//@type").try(:value)
38
+ @screening_results_media_type = document.at("//ScreeningResults//@mediaType").try(:value)
39
+ @screening_results_result_type = document.at("//ScreeningResults//@resultType").try(:value)
40
+ @result_url = document.at("//InternetWebAddress").try(:text)
41
+ end
42
+
43
+ end
44
+ end
@@ -0,0 +1,17 @@
1
+ module SsciInc
2
+ module Screening
3
+ class CivilCounty
4
+ include Screening::Model
5
+
6
+ attr_accessor :region, :county
7
+
8
+ def as_xml
9
+ builder(:type => "civil", :qualifier => "county") do |xml|
10
+ xml.Region region unless region.nil?
11
+ xml.County county unless county.nil?
12
+ end
13
+ end
14
+
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,16 @@
1
+ module SsciInc
2
+ module Screening
3
+ class Credit
4
+ include Screening::Model
5
+
6
+ attr_accessor :score, :fraud, :vendor
7
+
8
+ def as_xml
9
+ builder(:type => "credit") do |xml|
10
+ xml.Vendor(vendor, :score => score, :fraud => fraud)
11
+ end
12
+ end
13
+
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,17 @@
1
+ module SsciInc
2
+ module Screening
3
+ class CriminalCounty
4
+ include Screening::Model
5
+
6
+ attr_accessor :region, :county
7
+
8
+ def as_xml
9
+ builder(:type => "criminal", :qualifier => "county") do |xml|
10
+ xml.Region region unless region.nil?
11
+ xml.County county unless county.nil?
12
+ end
13
+ end
14
+
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ module SsciInc
2
+ module Screening
3
+ class CriminalFederal
4
+ include Screening::Model
5
+
6
+ attr_accessor :region, :district
7
+
8
+ def as_xml
9
+ builder(:type => "criminal", :qualifier => "federal") do |xml|
10
+ xml.Region region unless region.nil?
11
+ xml.District district unless district.nil?
12
+ end
13
+ end
14
+
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,12 @@
1
+ module SsciInc
2
+ module Screening
3
+ class CriminalSecurity
4
+ include Screening::Model
5
+
6
+ def as_xml
7
+ builder(:type => "criminal", :qualifier => "security")
8
+ end
9
+
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,16 @@
1
+ module SsciInc
2
+ module Screening
3
+ class CriminalState
4
+ include Screening::Model
5
+
6
+ attr_accessor :region
7
+
8
+ def as_xml
9
+ builder(:type => "criminal", :qualifier => "statewide") do |xml|
10
+ xml.Region region unless region.nil?
11
+ end
12
+ end
13
+
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ module SsciInc
2
+ module Screening
3
+ class Eviction
4
+ include Screening::Model
5
+
6
+ attr_accessor :region
7
+
8
+ def as_xml
9
+ builder(:type => "eviction", :qualifier => "statewide") do |xml|
10
+ xml.Region region unless region.nil?
11
+ end
12
+ end
13
+
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,27 @@
1
+ module SsciInc
2
+ module Screening
3
+ module Model
4
+
5
+ def initialize(h={})
6
+ h.each {|k,v| send("#{k}=", v) if respond_to?("#{k}=") }
7
+ end
8
+
9
+ def builder(attributes={})
10
+ Nokogiri::XML::Builder.new do |xml|
11
+ xml.send("Screening", attributes) {
12
+ yield xml if block_given?
13
+ }
14
+ end.parent.root
15
+ end
16
+
17
+ def as_xml
18
+ raise NotImplementedError
19
+ end
20
+
21
+ def to_xml
22
+ as_xml.to_xml
23
+ end
24
+
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,16 @@
1
+ module SsciInc
2
+ module Screening
3
+ class PersonSearch
4
+ include Screening::Model
5
+
6
+ attr_accessor :vendor
7
+
8
+ def as_xml
9
+ builder(:type => "personsearch") do |xml|
10
+ xml.Vendor vendor unless vendor.nil?
11
+ end
12
+ end
13
+
14
+ end
15
+ end
16
+ end