tckimlikdogrulama 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/tckimlikdogrulama/version.rb +1 -1
- data/lib/tckimlikdogrulama.rb +40 -2
- metadata +1 -1
data/lib/tckimlikdogrulama.rb
CHANGED
@@ -1,6 +1,44 @@
|
|
1
1
|
require "tckimlikdogrulama/version"
|
2
|
-
require "tckimlikdogrulama/tckimliknodogrula"
|
3
2
|
|
4
3
|
module Tckimlikdogrulama
|
5
|
-
|
4
|
+
module Tckimliknodogrula
|
5
|
+
module ClassMethods
|
6
|
+
def tckimlikno_dogrula(options = {})
|
7
|
+
begin
|
8
|
+
cattr_accessor :first_name, :identification_number, :last_name, :birth_year
|
9
|
+
|
10
|
+
first_name = options[:first_name]
|
11
|
+
last_name = options[:last_name]
|
12
|
+
identification_number = options[:identification_number]
|
13
|
+
birth_year = options[:birth_year]
|
14
|
+
|
15
|
+
client = Savon::Client.new("https://tckimlik.nvi.gov.tr/Service/KPSPublic.asmx?WSDL")
|
16
|
+
res = client.request(:tc_kimlik_no_dogrula)
|
17
|
+
{
|
18
|
+
soap.body =
|
19
|
+
{
|
20
|
+
"TCKimlikNo" => identification_number,
|
21
|
+
"Ad" => UnicodeUtils.upcase(first_name, :tr) ,
|
22
|
+
"Soyad" => UnicodeUtils.upcase(last_name, :tr),
|
23
|
+
"DogumYili" => birth_year
|
24
|
+
}
|
25
|
+
}
|
26
|
+
unless res.body[:tc_kimlik_no_dogrula_response][:tc_kimlik_no_dogrula_result]
|
27
|
+
self.errors.add(:identification_number, "Doğrulanamadı. Lütfen bilgilerinizi kontrol edip, tekrar deneyiniz.")
|
28
|
+
end
|
29
|
+
rescue
|
30
|
+
self.errors.add(:identification_number, "Doğrulanamadı. Lütfen bilgilerinizi kontrol edip, tekrar deneyiniz.")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
module InstanceMethods
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.included(receiver)
|
40
|
+
receiver.extend ClassMethods
|
41
|
+
receiver.send :include, InstanceMethods
|
42
|
+
end
|
43
|
+
end
|
6
44
|
end
|