osym 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/osym.rb +18 -0
- data/lib/osym/request.rb +82 -0
- metadata +59 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6be6e8f35955094d17eb1b4a6d4e5a7e59a3fa70
|
4
|
+
data.tar.gz: 982820285fa21fa7d91eadfb626b28f384aab9e8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ac6d5a0c20264ad089984df210e99d39845d7689bd397200f7419390ba366ed1440884ebdf6ad86cce5eb0f4f035028d1f11ba0e03856d069f61b9f370f68482
|
7
|
+
data.tar.gz: d62f67badddb49e48303dcb8db96edcb0c2faffc8c25de7f977ce38ab86dbf256d5ea33cf89d26616597843cf8e8b997e420eaa41ff17d3b2e78e845bf328a7f
|
data/lib/osym.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
class Osym
|
4
|
+
# Most basic usage:
|
5
|
+
# Osym.sorgula("username", "password", "id_number", "13", "2013", "S1")
|
6
|
+
# Advanced usage:
|
7
|
+
# Osym.sorgula(username = "username", password = "password", id_number = "id_number", exam_id = "13", exam_year = "2013", exam_period = "S1")
|
8
|
+
# Osym.sorgula(username = "username", password = "password", id_number = "id_number", exam_id = "13", exam_year = "2013", exam_period = "S1", version = 1)
|
9
|
+
|
10
|
+
def self.sorgula(username, password, id_number, exam_id, exam_year, exam_period,
|
11
|
+
version = 2, open_timeout = 60, read_timeout = 60, log = true,
|
12
|
+
wsdl = "https://sonucservis.osym.gov.tr/service.asmx?WSDL")
|
13
|
+
response = Request.new(username, password, id_number, exam_id, exam_year, exam_period, version, open_timeout, read_timeout, log, wsdl)
|
14
|
+
response.sorgula
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
require 'osym/request'
|
data/lib/osym/request.rb
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'savon'
|
4
|
+
|
5
|
+
class Request
|
6
|
+
# Initialize params.
|
7
|
+
def initialize(
|
8
|
+
username, password,
|
9
|
+
id_number, exam_id, exam_year, exam_period,
|
10
|
+
version, open_timeout, read_timeout, log, wsdl
|
11
|
+
)
|
12
|
+
|
13
|
+
# Authentication params
|
14
|
+
@username = username
|
15
|
+
@password = password
|
16
|
+
|
17
|
+
# Examination params
|
18
|
+
@id_number = id_number
|
19
|
+
@exam_id = exam_id
|
20
|
+
@exam_year = exam_year
|
21
|
+
@exam_period = exam_period
|
22
|
+
|
23
|
+
# SOAP params
|
24
|
+
@version = version
|
25
|
+
@open_timeout = open_timeout
|
26
|
+
@read_timeout = read_timeout
|
27
|
+
@log = log
|
28
|
+
@wsdl = wsdl
|
29
|
+
end
|
30
|
+
|
31
|
+
# Initialize the SOAP client
|
32
|
+
def sorgula
|
33
|
+
osym_client = Savon.client(
|
34
|
+
wsdl: "https://sonucservis.osym.gov.tr/service.asmx?WSDL",
|
35
|
+
soap_version: @version,
|
36
|
+
open_timeout: @open_timeout,
|
37
|
+
read_timeout: @read_timeout,
|
38
|
+
log: @log,
|
39
|
+
encoding: "UTF-8",
|
40
|
+
soap_header: {
|
41
|
+
"AuthenticationHeader" =>
|
42
|
+
{
|
43
|
+
"KullaniciAdi" => @username,
|
44
|
+
"Sifre" => @password
|
45
|
+
},
|
46
|
+
:attributes! => {
|
47
|
+
"AuthenticationHeader" =>
|
48
|
+
{
|
49
|
+
:xmlns => 'https://sonucservis.osym.gov.tr/'
|
50
|
+
}
|
51
|
+
}
|
52
|
+
}
|
53
|
+
)
|
54
|
+
|
55
|
+
# Create message pattern
|
56
|
+
message = {
|
57
|
+
"SinavId" => @exam_id.to_s,
|
58
|
+
"SinavYili" => @exam_year.to_s,
|
59
|
+
"SinavDonemi" => @exam_period.to_s,
|
60
|
+
"TcKimlikNo" => @id_number.to_s
|
61
|
+
}
|
62
|
+
|
63
|
+
# Make the SOAP request and handle errors.
|
64
|
+
begin
|
65
|
+
response = osym_client.call(:sonuc_getir, message: message)
|
66
|
+
rescue Savon::SOAPFault => error
|
67
|
+
puts "SOAP fault. Error: #{error}"
|
68
|
+
rescue Savon::HTTPError => error
|
69
|
+
puts "HTTP connection error. Error: #{error}"
|
70
|
+
end
|
71
|
+
|
72
|
+
# Get the SOAP response and handle errors.
|
73
|
+
begin
|
74
|
+
response_root = response.body[:sonuc_getir_response][:sonuc_getir_result]
|
75
|
+
return response_root
|
76
|
+
rescue NoMethodError => error
|
77
|
+
response.nil? ? (puts "Errors occured. Response is nil! Error: #{error}") : (puts "There is an error with the response. Error: #{error}")
|
78
|
+
rescue Savon::InvalidResponseError => error
|
79
|
+
puts "Not a valid response! Error: #{error}"
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
metadata
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: osym
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mustafa Serhat Dündar
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-11-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: savon
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.7.2
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.7.2
|
27
|
+
description: SOAP client GEM for ÖSYM services.
|
28
|
+
email: msdundars@gmail.com
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- lib/osym.rb
|
34
|
+
- lib/osym/request.rb
|
35
|
+
homepage: https://github.com/msdundar/osym
|
36
|
+
licenses:
|
37
|
+
- MIT
|
38
|
+
metadata: {}
|
39
|
+
post_install_message:
|
40
|
+
rdoc_options: []
|
41
|
+
require_paths:
|
42
|
+
- lib
|
43
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
requirements: []
|
54
|
+
rubyforge_project:
|
55
|
+
rubygems_version: 2.2.2
|
56
|
+
signing_key:
|
57
|
+
specification_version: 4
|
58
|
+
summary: SOAP client GEM for ÖSYM services.
|
59
|
+
test_files: []
|