Module: TcValidator

Defined in:
lib/tc_validator.rb,
lib/tc_validator/version.rb

Constant Summary collapse

VERSION =
"0.1.2"

Class Method Summary collapse

Class Method Details

.check_tc_id(tc_id, name, surname, year) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/tc_validator.rb', line 12

def self.check_tc_id(tc_id, name, surname, year)
  client = Savon.client(wsdl: 'https://tckimlik.nvi.gov.tr/Service/KPSPublic.asmx?WSDL')
  begin
    response = client.call(:tc_kimlik_no_dogrula, message: {
                                                  'TCKimlikNo' => tc_id,
                                                  'Ad' => name.replace_and_upcase,
                                                  'Soyad' => surname.replace_and_upcase,
                                                  'DogumYili' => year.to_s
                                                })
    response.body[:tc_kimlik_no_dogrula_response][:tc_kimlik_no_dogrula_result]
  rescue Savon::SOAPFault
    return false
  end
end