blueline_services 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. data/.gitignore +3 -0
  2. data/Gemfile +3 -0
  3. data/Gemfile.lock +46 -0
  4. data/README.md +66 -0
  5. data/Rakefile +26 -0
  6. data/blueline_services.gemspec +31 -0
  7. data/lib/blueline_services.rb +19 -0
  8. data/lib/blueline_services/configuration.rb +54 -0
  9. data/lib/blueline_services/dsl.rb +30 -0
  10. data/lib/blueline_services/person_name.rb +29 -0
  11. data/lib/blueline_services/request.rb +155 -0
  12. data/lib/blueline_services/response.rb +43 -0
  13. data/lib/blueline_services/screening/civil_county.rb +17 -0
  14. data/lib/blueline_services/screening/credit.rb +16 -0
  15. data/lib/blueline_services/screening/criminal_county.rb +17 -0
  16. data/lib/blueline_services/screening/criminal_federal.rb +17 -0
  17. data/lib/blueline_services/screening/criminal_security.rb +12 -0
  18. data/lib/blueline_services/screening/criminal_state.rb +16 -0
  19. data/lib/blueline_services/screening/eviction.rb +16 -0
  20. data/lib/blueline_services/screening/model.rb +27 -0
  21. data/lib/blueline_services/screening/person_search.rb +16 -0
  22. data/lib/blueline_services/version.rb +3 -0
  23. data/test/integration/initial_request_test.rb +21 -0
  24. data/test/test-updated.xml +111 -0
  25. data/test/test_helper.rb +115 -0
  26. data/test/unit/request_test.rb +93 -0
  27. data/test/unit/response_test.rb +65 -0
  28. data/test/unit/screening/civil_county_test.rb +12 -0
  29. data/test/unit/screening/credit_test.rb +12 -0
  30. data/test/unit/screening/criminal_county_test.rb +12 -0
  31. data/test/unit/screening/criminal_federal_test.rb +12 -0
  32. data/test/unit/screening/criminal_security_test.rb +11 -0
  33. data/test/unit/screening/criminal_state_test.rb +12 -0
  34. data/test/unit/screening/eviction_test.rb +11 -0
  35. data/test/unit/screening/model_test.rb +37 -0
  36. data/test/unit/screening/person_search_test.rb +11 -0
  37. metadata +229 -0
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ *.gem
2
+ .bundle
3
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,46 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ blueline_services (0.1.5)
5
+ activesupport
6
+ httparty
7
+ i18n
8
+ nokogiri
9
+
10
+ GEM
11
+ remote: http://rubygems.org/
12
+ specs:
13
+ activesupport (3.0.10)
14
+ coderay (1.0.5)
15
+ httparty (0.8.1)
16
+ multi_json
17
+ multi_xml
18
+ i18n (0.5.0)
19
+ metaclass (0.0.1)
20
+ method_source (0.7.1)
21
+ mocha (0.10.4)
22
+ metaclass (~> 0.0.1)
23
+ multi_json (1.2.0)
24
+ multi_xml (0.4.2)
25
+ nokogiri (1.5.0)
26
+ pry (0.9.8.4)
27
+ coderay (~> 1.0.5)
28
+ method_source (~> 0.7.1)
29
+ slop (>= 2.4.4, < 3)
30
+ rake (0.9.2.2)
31
+ shoulda (3.0.1)
32
+ shoulda-context (~> 1.0.0)
33
+ shoulda-matchers (~> 1.0.0)
34
+ shoulda-context (1.0.0)
35
+ shoulda-matchers (1.0.0)
36
+ slop (2.4.4)
37
+
38
+ PLATFORMS
39
+ ruby
40
+
41
+ DEPENDENCIES
42
+ blueline_services!
43
+ mocha
44
+ pry
45
+ rake
46
+ shoulda
data/README.md ADDED
@@ -0,0 +1,66 @@
1
+ # BluelineServices
2
+
3
+ The blueline_services gem is a ruby gem used for submitted background check requests to
4
+ [Blueline Services](http://www.blueline-services.com/)
5
+
6
+ Using this API requires that you have an existing account with Blueline Services,
7
+ specifically a screening product, username, and password.
8
+
9
+ Install
10
+ --------
11
+
12
+ ```shell
13
+ gem install blueline_services
14
+ ```
15
+ or add the following line to Gemfile:
16
+
17
+ ```ruby
18
+ gem 'blueline_services'
19
+ ```
20
+ and run `bundle install` from your shell.
21
+
22
+ Usage
23
+ ---------------------------
24
+
25
+ To create a new background check and submit it.
26
+
27
+ ```ruby
28
+ request = BluelineServices::Request.new do |r|
29
+ r.user_name = "XML_TST",
30
+ r.password = "ScROLL447breaK",
31
+ r.type = "TST Media",
32
+ r.reference_id = 112233,
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 = BluelineServices::Request.new(hash)
51
+
52
+ # or initialize with nothing and build on the fly
53
+
54
+ request = BluelineServices::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 # => BluelineServices::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/blueline_services -r blueline_services.rb"
26
+ end
@@ -0,0 +1,31 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "blueline_services/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "blueline_services"
7
+ s.version = BluelineServices::VERSION
8
+ s.authors = ["Jon Karna", "Ed Lebert"]
9
+ s.email = ["jon.karna@tstmedia.com", "ed.lebert@tstmedia.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{Submit background checks to Blueline Services}
12
+ s.description = %q{The blueline_services gem is a ruby gem used for
13
+ submitting background check requests to Blueline Services}
14
+
15
+ s.rubyforge_project = "blueline_services"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+
22
+ s.add_runtime_dependency "httparty"
23
+ s.add_runtime_dependency "nokogiri"
24
+ s.add_runtime_dependency "activesupport"
25
+ s.add_runtime_dependency "i18n"
26
+
27
+ s.add_development_dependency "pry"
28
+ s.add_development_dependency "rake"
29
+ s.add_development_dependency "shoulda"
30
+ s.add_development_dependency "mocha"
31
+ end
@@ -0,0 +1,19 @@
1
+ require 'active_support/all'
2
+ require 'nokogiri'
3
+ require 'httparty'
4
+
5
+ require 'blueline_services/configuration'
6
+ require 'blueline_services/dsl'
7
+ require 'blueline_services/person_name'
8
+ require 'blueline_services/request'
9
+ require 'blueline_services/response'
10
+
11
+ require 'blueline_services/screening/model'
12
+ require 'blueline_services/screening/civil_county'
13
+ require 'blueline_services/screening/credit'
14
+ require 'blueline_services/screening/criminal_county'
15
+ require 'blueline_services/screening/criminal_federal'
16
+ require 'blueline_services/screening/criminal_security'
17
+ require 'blueline_services/screening/criminal_state'
18
+ require 'blueline_services/screening/eviction'
19
+ require 'blueline_services/screening/person_search'
@@ -0,0 +1,54 @@
1
+ module BluelineServices
2
+ class Configuration
3
+
4
+ attr_accessor :user_name,
5
+ :password,
6
+ :postback_url,
7
+ :postback_username,
8
+ :postback_password
9
+
10
+ end
11
+
12
+ class << self
13
+ attr_accessor :configuration
14
+
15
+ def configuration
16
+ @configuration ||= Configuration.new
17
+ end
18
+ end
19
+
20
+ # Public: Configure blueline services gem
21
+ #
22
+ # Examples
23
+ # BluelineServices.configure do |config|
24
+ # config.user_name = "***"
25
+ # config.password = "***"
26
+ # config.postback_url = "http://127.0.0.1/listen.php"
27
+ # config.postback_username = "user"
28
+ # config.postback_password = "secret"
29
+ # end
30
+ #
31
+ def self.configure
32
+ yield(configuration)
33
+ end
34
+
35
+ # Public: Configure blueline services gem with yaml file
36
+ #
37
+ # file - The name of the file to parse. (optional)
38
+ # Defaults to "config/blueline.yml".
39
+ #
40
+ # Examples
41
+ # BluelineServices.load_config("blueline.yml")
42
+ #
43
+ def self.load_config(file="config/blueline.yml")
44
+ if File.exists?(file)
45
+ h = YAML::load(IO.read(file))
46
+ configure do |config|
47
+ h.each do |k,v|
48
+ config.send("#{k}=", v) if config.respond_to?("#{k}=")
49
+ end
50
+ end
51
+ end
52
+ end
53
+
54
+ end
@@ -0,0 +1,30 @@
1
+ module BluelineServices
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 BluelineServices
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,155 @@
1
+ module BluelineServices
2
+ class Request
3
+ include DSL
4
+ include HTTParty
5
+ base_uri "https://www.bluelinebackgrounds.com/send/interchange"
6
+
7
+ ADDITIONAL_ITEMS = [:postback_url, :postback_username,
8
+ :postback_password, :embed_credentials, :ordernotes,
9
+ :interface, :monthly_income, :monthly_rent]
10
+
11
+ # BackgroundCheck
12
+ attr_accessor :user_name,
13
+ :password
14
+
15
+ # BackgroundSearchPackage
16
+ attr_accessor :action,
17
+ :type,
18
+ :reference_id
19
+
20
+ # PersonalData
21
+ attr_accessor :email_address,
22
+ :telephone
23
+
24
+ # PersonName
25
+ attr_accessor :given_name,
26
+ :middle_name,
27
+ :family_name,
28
+ :affix
29
+
30
+ # DemographicDetail
31
+ attr_accessor :government_id,
32
+ :country_code,
33
+ :issuing_authority,
34
+ :date_of_birth,
35
+ :postal_code,
36
+ :region,
37
+ :municipality,
38
+ :address_line,
39
+ :street_name
40
+
41
+ # Screenings
42
+ attr_reader :screenings
43
+ attr_accessor :use_defaults
44
+
45
+ # AdditionalItems
46
+ attr_accessor *ADDITIONAL_ITEMS
47
+
48
+ attr_reader :aliases
49
+
50
+ def initialize(h={})
51
+ init_defaults
52
+ h.each do |k,v|
53
+ send("#{k}=", v) if respond_to?("#{k}=")
54
+ end
55
+ yield self if block_given?
56
+ end
57
+
58
+ def additional_items
59
+ ADDITIONAL_ITEMS.inject({}) do |h,a|
60
+ v = send(a)
61
+ h[a] = send(a) unless v.nil?
62
+ h
63
+ end
64
+ end
65
+
66
+ def ssn=(new_ssn)
67
+ @government_id = new_ssn
68
+ @country_code = "US"
69
+ @issuing_authority = "SSN"
70
+ end
71
+
72
+ def name
73
+ person_name do |p|
74
+ p.given_name = given_name
75
+ p.middle_name = middle_name
76
+ p.family_name = family_name
77
+ p.affix = affix
78
+ end
79
+ end
80
+
81
+ def as_xml
82
+ Nokogiri::XML::Builder.new do |xml|
83
+ xml.BackgroundCheck(:userId => user_name, :password => password) {
84
+ xml.BackgroundSearchPackage(:type => type, :action => action) {
85
+ xml.ReferenceId reference_id
86
+ xml.PersonalData {
87
+ xml.EmailAddress email_address
88
+ xml.Telephone telephone
89
+ xml.parent << name.as_xml
90
+ if aliases.any?
91
+ xml.Aliases {
92
+ aliases.each do |a|
93
+ xml.parent << a.as_xml
94
+ end
95
+ }
96
+ end
97
+ xml.DemographicDetail {
98
+ xml.GovernmentId(government_id,
99
+ :countryCode => country_code,
100
+ :issuingAuthority => issuing_authority)
101
+ } # DemographicDetail
102
+ xml.PostalAddress {
103
+ xml.PostalCode postal_code
104
+ xml.Region region
105
+ xml.Municipality municipality
106
+ xml.DeliveryAddress {
107
+ xml.AddressLine address_line
108
+ xml.StreetName street_name
109
+ } # DeliveryAddress
110
+ } # PostalAddress
111
+ } # PersonalData
112
+ xml.Screenings(:useConfigurationDefaults => yes_or_no(use_defaults)) {
113
+ screenings.each do |s|
114
+ xml.parent << s.as_xml
115
+ end
116
+ additional_items.each do |k,v|
117
+ xml.AdditionalItems(:type => "x:#{k}") {
118
+ xml.Text v
119
+ }
120
+ end
121
+ } # Screenings
122
+ } # BackgroundSearchPackage
123
+ } # BackgroundCheck
124
+ end
125
+ end
126
+
127
+ def to_xml
128
+ as_xml.to_xml
129
+ end
130
+
131
+ def submit
132
+ response = self.class.post("", :body => {:request => to_xml})
133
+ data = response.parsed_response
134
+ BluelineServices::Response.new(data)
135
+ end
136
+
137
+ private
138
+ def init_defaults
139
+ config = BluelineServices.configuration
140
+ @user_name = config.user_name
141
+ @password = config.password
142
+ @postback_url = config.postback_url
143
+ @postback_username = config.postback_username
144
+ @postback_password = config.postback_password
145
+ @action = "submit"
146
+ @screenings = []
147
+ @aliases = []
148
+ end
149
+
150
+ def yes_or_no(v)
151
+ !!v ? "yes" : "no"
152
+ end
153
+
154
+ end
155
+ end