class SterlingApi::BackgroundCheck
Public Class Methods
all_ids(mode)
click to toggle source
# File lib/sterling_api/background_check.rb, line 9 def self.all_ids(mode) mode.to_s =~ /prod/ ? [25212, 25213, 25214, 25750, 25751, 25752, 25753, 25911] : [19432, 19439, 19440, 19442, 19443, 19444, 19445, 19437] end
for_package(package_id, options)
click to toggle source
combos
19432 = Package 1 = PRI-FIM, PRINCRF, PRINCRP, SSNV 19439 = Package 2 = PRI-FAM, PRINCRP, SSNV 19440 = Package 3 = MVR, PRINCRP, SSNV
ala carte
19442 = Package 5 = MVR only 19443 = Package 6 = PRINCRP 19444 = Package 7 = PRI-FFM, SSNV 19445 = Package 9 = PRI-FFM 19437 = Package 14 = PRI-FAM 2011-02-22: Package 1 can logically be ordered with 5,9 & 14 Package 2 can logically be ordered with 5 & 9 Package 3 can logically be ordered with 9 & 14 Any combination of 5,6,7,9 & 14 could be ordered.
# File lib/sterling_api/background_check.rb, line 54 def self.for_package(package_id, options) package_id = package_id.to_i background_check = self.new(options.merge(:package_id => package_id)) background_check.add_ssnv # required for one-step orders background_check.add_name_and_address if all_ids(options[:mode]).include?(package_id) background_check.add_mvr if mvr_ids(options[:mode]).include?(package_id) background_check end
mvr_ids(mode)
click to toggle source
# File lib/sterling_api/background_check.rb, line 13 def self.mvr_ids(mode) mode.to_s =~ /prod/ ? [25214, 25750] : [19440, 19442] end
new(options={})
click to toggle source
# File lib/sterling_api/background_check.rb, line 67 def initialize(options={}) @options = options @xml = create_root self end
Public Instance Methods
add_mvr()
click to toggle source
Contains 0* //BackgroundCheck/BackgroundSearchPackage/Screenings/Screening/SearchLicense
options should contain:
licenses: an array of license info hashes
license info hash:
:license_number AN 1..20 :license_region 2 char State/Region
# File lib/sterling_api/background_check.rb, line 157 def add_mvr builder = Nokogiri::XML::Builder.with(screening_node) do |xml| @options[:licenses].each do |hash| # xml.SearchLicense(:validFrom => ymd(hash[:valid_from]), :validTo => ymd(hash[:valid_to])) { xml.Region hash[:license_region] # State xml.SearchLicense { xml.License { xml.LicenseNumber(hash[:license_number]) xml.LicenseName 'mvr' xml.LicenseDescription 'mvr' xml.LicensingAgency } } end end @xml = builder.to_xml end
add_name_and_address()
click to toggle source
expects an array of :person_names in @options expects an array of :postal_addresses in @options
<PersonName type="subject|alias"> <GivenName>Kevin</GivenName> <MiddleName>Fred</MiddleName> <FamilyName>Test</FamilyName> </PersonName> <PostalAddress type="current|prior" validFrom="2009-01-01"> <Municipality>Madison</Municipality> <Region>WI</Region> <PostalCode>53711</PostalCode> <CountryCode>US</CountryCode> <DeliveryAddress> <AddressLine>1234 Main Rd</AddressLine> </DeliveryAddress> </PostalAddress>
# File lib/sterling_api/background_check.rb, line 194 def add_name_and_address builder = Nokogiri::XML::Builder.with(personal_data_node) do |xml| @options[:person_names].each do |hash| xml.PersonName(:type => hash[:type]){ xml.GivenName hash[:first_name] xml.MiddleName hash[:middle_name] xml.FamilyName hash[:last_name] } end if @options[:person_names] @options[:postal_addresses].each do |hash| xml.PostalAddress(:type => hash[:type], :validFrom => ymd(hash[:valid_from]), :validTo => ymd(hash[:valid_to])){ xml.Municipality hash[:municipality] xml.Region hash[:region] xml.PostalCode hash[:postal_code] xml.CountryCode hash[:country_code] xml.DeliveryAddress{ xml.AddressLine hash[:address1] xml.AddressLine(hash[:address2]) if hash[:address2].present? } } end if @options[:postal_addresses] end @xml = builder.to_xml end
add_ssnv()
click to toggle source
<DemographicDetail>
<GovernmentId issuingAuthority="SSN">123456789</GovernmentId> <DateOfBirth>1950-01-01</DateOfBirth>
</DemographicDetail>
# File lib/sterling_api/background_check.rb, line 226 def add_ssnv builder = Nokogiri::XML::Builder.with(personal_data_node) do |xml| xml.DemographicDetail{ xml.GovernmentId(@options[:ssn], :issuingAuthority => 'SSN') xml.DateOfBirth(ymd(@options[:date_of_birth])) } end @xml = builder.to_xml end
create_root()
click to toggle source
<BackgroundCheck
userId="#{@order_as_user_id}" account="#{@account}" password="#{@password}"> <BackgroundSearchPackage> <PersonalData> <ContactMethod> <InternetEmailAddress></InternetEmailAddress> </ContactMethod> </PersonalData> <Screenings> <PackageID>#{@package_id}</PackageID> <UserArea> <UserAreaContent> <PositionTitle>#{@position_applied_for}</PositionTitle> </UserAreaContent> </UserArea> (if non-MVR) <Screening type="abuse"> (if MVR) <Screening type="license", qualifer="mvPersonal"> </Screenings> </BackgroundSearchPackage> <UserArea> <UserAreaContent> <OnlineAddress> <InternetWebAddress>#{AppSettings[:sterling_return_url]}</InternetWebAddress> </OnlineAddress> <ReturnOrderNumber>Y</ReturnOrderNumber> </UserAreaContent> </UserArea>
</BackgroundCheck>
# File lib/sterling_api/background_check.rb, line 106 def create_root builder = Nokogiri::XML::Builder.new do |xml| xml.BackgroundCheck( :userId => @options[:order_as_user_id], :account => @options[:account], :password => @options[:password] ){ xml.BackgroundSearchPackage{ xml.PersonalData{ xml.ContactMethod{ xml.InternetEmailAddress @options[:contact_email] } } xml.Screenings{ xml.PackageID @options[:package_id] xml.UserArea { xml.userAreaContent{ xml.PositionTitle @options[:position_applied_for] } } if self.class.mvr_ids(@options[:mode]).include?(@options[:package_id]) xml.Screening(:type => "license", :qualifier => "mvPersonal") else xml.Screening(:type => "abuse") end } } xml.UserArea{ xml.UserAreaContent{ xml.OnlineAddress{ xml.InternetWebAddress AppSettings[:sterling_return_url] } xml.ReturnOrderNumber "Y" } } } end builder.to_xml end
to_xml()
click to toggle source
# File lib/sterling_api/background_check.rb, line 237 def to_xml self.class.xml_rpc_wrapper(@xml) end
Protected Instance Methods
doc()
click to toggle source
# File lib/sterling_api/background_check.rb, line 243 def doc Nokogiri::XML(@xml) end
personal_data_node()
click to toggle source
# File lib/sterling_api/background_check.rb, line 247 def personal_data_node doc.at('//BackgroundCheck/BackgroundSearchPackage/PersonalData') end
screening_node()
click to toggle source
# File lib/sterling_api/background_check.rb, line 251 def screening_node doc.at('//BackgroundCheck/BackgroundSearchPackage/Screenings/Screening') end
ymd(date)
click to toggle source
expects a Time or DateTime
# File lib/sterling_api/background_check.rb, line 256 def ymd(date) return date if date.is_a?(String) date.strftime("%Y-%m-%d") if date end