Class: SsciInc::Request

Inherits:
Object
  • Object
show all
Includes:
DSL
Defined in:
lib/ssci_inc/request.rb

Constant Summary collapse

COURT_TYPES =
{
    bankruptcy: "Bankruptcy",
    federal: "Federal",
    felony: "Felony",
    felony_misdemeanor: "Felony Misdemeanor",
    lower_civil: "Lower Civil",
    property_search: "Property Search",
    upper_civil: "Upper Civil",
    upper_lower_civil: "Upper and Lower Civil"
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from DSL

#alias, #person_name, #screen

Constructor Details

#initialize(h = {}) ⇒ Request

Returns a new instance of Request.



61
62
63
64
65
66
67
68
69
70
# File 'lib/ssci_inc/request.rb', line 61

def initialize(h={})
  init_defaults
  h.each do |k,v|
    send("#{k}=", v) if respond_to?("#{k}=")
  end

  county =

  yield self if block_given?
end

Instance Attribute Details

#actionObject

BackgroundSearchPackage



24
25
26
# File 'lib/ssci_inc/request.rb', line 24

def action
  @action
end

#address_lineObject

PostalAddress



40
41
42
# File 'lib/ssci_inc/request.rb', line 40

def address_line
  @address_line
end

#affixObject

PersonName



30
31
32
# File 'lib/ssci_inc/request.rb', line 30

def affix
  @affix
end

#aliasesObject (readonly)

Returns the value of attribute aliases.



59
60
61
# File 'lib/ssci_inc/request.rb', line 59

def aliases
  @aliases
end

#base_uriObject

BackgroundCheck



18
19
20
# File 'lib/ssci_inc/request.rb', line 18

def base_uri
  @base_uri
end

#configObject

BackgroundCheck



18
19
20
# File 'lib/ssci_inc/request.rb', line 18

def config
  @config
end

#country_codeObject

PostalAddress



40
41
42
# File 'lib/ssci_inc/request.rb', line 40

def country_code
  @country_code
end

#countyObject

PostalAddress



40
41
42
# File 'lib/ssci_inc/request.rb', line 40

def county
  @county
end

#date_of_birthObject

DemographicDetail



36
37
38
# File 'lib/ssci_inc/request.rb', line 36

def date_of_birth
  @date_of_birth
end

#districtObject

PostalAddress



40
41
42
# File 'lib/ssci_inc/request.rb', line 40

def district
  @district
end

#email_addressObject

SpecialRequestInfo



50
51
52
# File 'lib/ssci_inc/request.rb', line 50

def email_address
  @email_address
end

#extra_identifierObject

SpecialRequestInfo



50
51
52
# File 'lib/ssci_inc/request.rb', line 50

def extra_identifier
  @extra_identifier
end

#family_nameObject

PersonName



30
31
32
# File 'lib/ssci_inc/request.rb', line 30

def family_name
  @family_name
end

#given_nameObject

PersonName



30
31
32
# File 'lib/ssci_inc/request.rb', line 30

def given_name
  @given_name
end

#middle_nameObject

PersonName



30
31
32
# File 'lib/ssci_inc/request.rb', line 30

def middle_name
  @middle_name
end

#municipalityObject

PostalAddress



40
41
42
# File 'lib/ssci_inc/request.rb', line 40

def municipality
  @municipality
end

#ordernotesObject

SpecialRequestInfo



50
51
52
# File 'lib/ssci_inc/request.rb', line 50

def ordernotes
  @ordernotes
end

#passwordObject

BackgroundCheck



18
19
20
# File 'lib/ssci_inc/request.rb', line 18

def password
  @password
end

#postal_codeObject

PostalAddress



40
41
42
# File 'lib/ssci_inc/request.rb', line 40

def postal_code
  @postal_code
end

#referenceObject

BackgroundSearchPackage



24
25
26
# File 'lib/ssci_inc/request.rb', line 24

def reference
  @reference
end

#reference_idObject

BackgroundSearchPackage



24
25
26
# File 'lib/ssci_inc/request.rb', line 24

def reference_id
  @reference_id
end

#regionObject

PostalAddress



40
41
42
# File 'lib/ssci_inc/request.rb', line 40

def region
  @region
end

#screeningsObject (readonly)

Screenings



56
57
58
# File 'lib/ssci_inc/request.rb', line 56

def screenings
  @screenings
end

#ssnObject

DemographicDetail



36
37
38
# File 'lib/ssci_inc/request.rb', line 36

def ssn
  @ssn
end

#street_nameObject

PostalAddress



40
41
42
# File 'lib/ssci_inc/request.rb', line 40

def street_name
  @street_name
end

#telephoneObject

SpecialRequestInfo



50
51
52
# File 'lib/ssci_inc/request.rb', line 50

def telephone
  @telephone
end

#typeObject

BackgroundSearchPackage



24
25
26
# File 'lib/ssci_inc/request.rb', line 24

def type
  @type
end

#use_defaultsObject

Returns the value of attribute use_defaults.



57
58
59
# File 'lib/ssci_inc/request.rb', line 57

def use_defaults
  @use_defaults
end

#user_nameObject

BackgroundCheck



18
19
20
# File 'lib/ssci_inc/request.rb', line 18

def user_name
  @user_name
end

Instance Method Details

#account_codeObject



163
164
165
# File 'lib/ssci_inc/request.rb', line 163

def 
  @account_code || config.
end

#as_xmlObject



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/ssci_inc/request.rb', line 72

def as_xml
  Nokogiri::XML::Builder.new do |xml|
    xml.BackgroundCheck(:userId => user_name, :password => password) {
      xml.BatchData {
        xml.DestSiteIdentifier "SOUTHEASTERN"
        xml.SourceSiteIdentifier site_identifier
        xml.AcctCode 
        xml.BatchID 1
        xml.RecordCount 1
      }
      xml.BackgroundSearchPackage {
        xml.PersonalData {
          xml.PersonName {
            xml.GivenName given_name
            xml.MiddleName middle_name if middle_name.present?
            xml.FamilyName family_name
            xml.Affix affix if affix.present?
          }
          if aliases.any?
            xml.AliasNames {
              aliases.each do |a|
                xml.parent << a.as_xml
              end
            }
          end
          xml.DemographicDetail {
            xml.Ssn ssn
            xml.DateOfBirth date_of_birth
          } # DemographicDetail
          xml.AddressSummary {
            xml.CountryCode country_code == "Canada" ? "CA" : "US"
            xml.PostalCode postal_code
            xml.Region region
            xml.Municipality municipality
            xml.AddressLine street_name
          } # AddressSummary
          xml.RequestIdData {
            xml.ReferenceID reference_id
          }
          xml.SpecialRequestInfo {
            xml.OtherInfo ordernotes
            xml.ApplicantPhone telephone
            xml.ApplicantEmail email_address
            xml.ExtraIdentifier extra_identifier
          }
        } # PersonalData
        xml.Screenings {
          init_default_screenings if use_defaults
          @screenings.each do |s|
            xml.parent << s.as_xml
          end
        } # Screenings
      } # BackgroundSearchPackage
    } # BackgroundCheck
  end
end

#build_requestObject



141
142
143
# File 'lib/ssci_inc/request.rb', line 141

def build_request
  HTTParty::Request.new(Net::HTTP::Post, base_uri, request_options)
end

#init_default_screeningsObject



189
190
191
192
# File 'lib/ssci_inc/request.rb', line 189

def init_default_screenings
  @screenings = [Screening::Social.new,
                 Screening::Other.new(qualifier: 'US Crim / Sex Offender Search')]
end

#request_optionsObject



133
134
135
136
137
138
139
# File 'lib/ssci_inc/request.rb', line 133

def request_options
  {
    body: to_xml,
    basic_auth: { username: user_name, password: password },
    headers: { "Content-Type" => "text/xml"}
  }
end

#site_identifierObject



159
160
161
# File 'lib/ssci_inc/request.rb', line 159

def site_identifier
  @site_identifier || config.site_identifier
end

#submitObject



145
146
147
148
149
# File 'lib/ssci_inc/request.rb', line 145

def submit
  response = build_request.perform
  data = response.parsed_response
  SsciInc::Response.new(data)
end

#to_xmlObject



129
130
131
# File 'lib/ssci_inc/request.rb', line 129

def to_xml
  as_xml.to_xml
end