julianus 1.0

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.
@@ -0,0 +1,2 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="https://www.krediidiregister.ee/importer/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:finishUploadResponse><return xsi:type="xsd:int">0</return></ns1:finishUploadResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
@@ -0,0 +1,2 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="https://www.krediidiregister.ee/importer/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:startUploadResponse><return xsi:type="xsd:int">53</return></ns1:startUploadResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
@@ -0,0 +1,2 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="https://www.krediidiregister.ee/importer/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:uploadChunkResponse><return xsi:nil="true"/></ns1:uploadChunkResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
@@ -0,0 +1,65 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="https://test.krediidihaldus.ee/export/" targetNamespace="https://test.krediidihaldus.ee/export/">
3
+ <wsdl:types>
4
+ <s:schema targetNamespace="https://test.krediidihaldus.ee/export/">
5
+ <s:complexType name="WsdlClaimExporterClientType">
6
+ <s:sequence>
7
+ <s:element minOccurs="1" maxOccurs="1" nillable="false" name="username" type="s:string" />
8
+ <s:element minOccurs="1" maxOccurs="1" nillable="false" name="password" type="s:string" />
9
+ <s:element minOccurs="1" maxOccurs="1" nillable="false" name="code" type="s:string" />
10
+ </s:sequence>
11
+ </s:complexType>
12
+ <s:complexType name="WsdlClaimExporterClientResultType">
13
+ <s:sequence>
14
+ <s:element minOccurs="1" maxOccurs="1" nillable="false" name="code" type="s:string" />
15
+ <s:element minOccurs="1" maxOccurs="1" nillable="true" name="claims" type="tns:WsdlClaimExporterClientResultClaimTypeArray" />
16
+ </s:sequence>
17
+ </s:complexType>
18
+ <s:complexType name="WsdlClaimExporterClientResultClaimType">
19
+ <s:sequence>
20
+ <s:element minOccurs="1" maxOccurs="1" nillable="false" name="claimant" type="s:string" />
21
+ <s:element minOccurs="1" maxOccurs="1" nillable="false" name="startDate" type="s:string" />
22
+ <s:element minOccurs="1" maxOccurs="1" nillable="true" name="endDate" type="s:string" />
23
+ <s:element minOccurs="1" maxOccurs="1" nillable="false" name="amount" type="s:float" />
24
+ <s:element minOccurs="1" maxOccurs="1" nillable="false" name="status" type="s:string" />
25
+ </s:sequence>
26
+ </s:complexType>
27
+ <s:complexType name="WsdlClaimExporterClientResultClaimTypeArray">
28
+ <s:complexContent>
29
+ <s:restriction base="soapenc:Array">
30
+ <s:attribute ref="soapenc:arrayType" wsdl:arrayType="tns:WsdlClaimExporterClientResultClaimType[]" />
31
+ </s:restriction>
32
+ </s:complexContent>
33
+ </s:complexType>
34
+ </s:schema>
35
+ </wsdl:types>
36
+ <wsdl:message name="getByCodeSoapIn">
37
+ <wsdl:part name="customerData" type="tns:WsdlClaimExporterClientType" />
38
+ </wsdl:message>
39
+ <wsdl:message name="getByCodeSoapOut">
40
+ <wsdl:part name="return" type="tns:WsdlClaimExporterClientResultType" />
41
+ </wsdl:message>
42
+ <wsdl:portType name="ExporterSoap">
43
+ <wsdl:operation name="getByCode">
44
+ <wsdl:input message="tns:getByCodeSoapIn" />
45
+ <wsdl:output message="tns:getByCodeSoapOut" />
46
+ </wsdl:operation>
47
+ </wsdl:portType>
48
+ <wsdl:binding name="ExporterSoap" type="tns:ExporterSoap">
49
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc" />
50
+ <wsdl:operation name="getByCode">
51
+ <soap:operation soapAction="https://test.krediidihaldus.ee/export/getByCode" />
52
+ <wsdl:input>
53
+ <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="https://test.krediidihaldus.ee/export/" parts="customerData" />
54
+ </wsdl:input>
55
+ <wsdl:output>
56
+ <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="https://test.krediidihaldus.ee/export/" parts="return" />
57
+ </wsdl:output>
58
+ </wsdl:operation>
59
+ </wsdl:binding>
60
+ <wsdl:service name="Exporter">
61
+ <wsdl:port name="ExporterSoap" binding="tns:ExporterSoap">
62
+ <soap:address location="https://test.krediidihaldus.ee/export/wsdl-claim.php" />
63
+ </wsdl:port>
64
+ </wsdl:service>
65
+ </wsdl:definitions>
@@ -0,0 +1,10 @@
1
+ <SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="https://test.krediidihaldus.ee/export/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
2
+ <SOAP-ENV:Body>
3
+ <ns1:getByCodeResponse>
4
+ <return xsi:type="SOAP-ENC:Struct">
5
+ <code xsi:type="xsd:string">random</code>
6
+ <claims SOAP-ENC:arrayType="xsd:ur-type[0]" xsi:type="SOAP-ENC:Array"/>
7
+ </return>
8
+ </ns1:getByCodeResponse>
9
+ </SOAP-ENV:Body>
10
+ </SOAP-ENV:Envelope>
@@ -0,0 +1,18 @@
1
+ <SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="https://test.krediidihaldus.ee/export/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
2
+ <SOAP-ENV:Body>
3
+ <ns1:getByCodeResponse>
4
+ <return xsi:type="SOAP-ENC:Struct">
5
+ <code xsi:type="xsd:string">38109212722</code>
6
+ <claims SOAP-ENC:arrayType="SOAP-ENC:Struct[1]" xsi:type="SOAP-ENC:Array">
7
+ <item xsi:type="SOAP-ENC:Struct">
8
+ <claimant xsi:type="xsd:string">Vendor Lietuva UAB</claimant>
9
+ <startDate xsi:type="xsd:string">2013-03-01</startDate>
10
+ <endDate xsi:nil="true"/>
11
+ <amount xsi:type="xsd:float">1047.2</amount>
12
+ <status xsi:type="xsd:string">Avalikustatud</status>
13
+ </item>
14
+ </claims>
15
+ </return>
16
+ </ns1:getByCodeResponse>
17
+ </SOAP-ENV:Body>
18
+ </SOAP-ENV:Envelope>
@@ -0,0 +1,25 @@
1
+ <SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="https://test.krediidihaldus.ee/export/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
2
+ <SOAP-ENV:Body>
3
+ <ns1:getByCodeResponse>
4
+ <return xsi:type="SOAP-ENC:Struct">
5
+ <code xsi:type="xsd:string">38911066514</code>
6
+ <claims SOAP-ENC:arrayType="SOAP-ENC:Struct[1]" xsi:type="SOAP-ENC:Array">
7
+ <item xsi:type="SOAP-ENC:Struct">
8
+ <claimant xsi:type="xsd:string">Vendor Lietuva UAB</claimant>
9
+ <startDate xsi:type="xsd:string">2013-03-01</startDate>
10
+ <endDate xsi:nil="true"/>
11
+ <amount xsi:type="xsd:float">1047.2</amount>
12
+ <status xsi:type="xsd:string">Avalikustatud</status>
13
+ </item>
14
+ <item xsi:type="SOAP-ENC:Struct">
15
+ <claimant xsi:type="xsd:string">Inkassokeskus OÜ</claimant>
16
+ <startDate xsi:type="xsd:string">2012-02-17</startDate>
17
+ <endDate xsi:type="xsd:string">2012-06-29 13:41:00</endDate>
18
+ <amount xsi:type="xsd:float">127.83</amount>
19
+ <status xsi:type="xsd:string">Lahendatud</status>
20
+ </item>
21
+ </claims>
22
+ </return>
23
+ </ns1:getByCodeResponse>
24
+ </SOAP-ENV:Body>
25
+ </SOAP-ENV:Envelope>
@@ -0,0 +1,10 @@
1
+ <SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="https://test.krediidihaldus.ee/export/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
2
+ <SOAP-ENV:Body>
3
+ <ns1:getByCodeResponse>
4
+ <return xsi:type="SOAP-ENC:Struct">
5
+ <code xsi:type="xsd:string">47101010033</code>
6
+ <claims SOAP-ENC:arrayType="xsd:ur-type[0]" xsi:type="SOAP-ENC:Array"/>
7
+ </return>
8
+ </ns1:getByCodeResponse>
9
+ </SOAP-ENV:Body>
10
+ </SOAP-ENV:Envelope>
@@ -0,0 +1,110 @@
1
+ require "savon/mock/spec_helper"
2
+ require 'spec_helper'
3
+ require 'julianus'
4
+ require 'base64'
5
+
6
+ require 'savon'
7
+
8
+ describe 'julianus service' do
9
+ include Savon::SpecHelper
10
+
11
+ # set Savon in and out of mock mode
12
+ before(:all) { savon.mock!
13
+ Julianus.configure(
14
+ username: 'username',
15
+ password: 'password',
16
+ live: false
17
+ )
18
+ }
19
+ after(:all) { savon.unmock! }
20
+
21
+ let(:source) {
22
+ "spec/fixtures/"
23
+ }
24
+ let(:kr_source) {
25
+ "spec/fixtures/Krediidiregister/"
26
+ }
27
+ let(:wsdl) {
28
+ "spec/fixtures/get_by_code.wsdl"
29
+ }
30
+ let(:message) {
31
+ {
32
+ :customerData => {
33
+ :username => Julianus.config[:username],
34
+ :password => Julianus.config[:password],
35
+ :code => nil
36
+ }
37
+ }
38
+ }
39
+
40
+ it 'configures julianus' do
41
+ Julianus.configure do |c|
42
+ c.username = 'username'
43
+ c.password = 'password'
44
+ end
45
+ end
46
+
47
+ it 'receives result with item' do
48
+ xml = File.read("#{source}with_item.xml")
49
+ id = "38109212722"
50
+ message[:customerData][:code] = id
51
+ savon.expects(:get_by_code).with(message: message).returns(xml)
52
+ report = Julianus.report(id)
53
+ end
54
+
55
+ it 'receives result without item' do
56
+ xml = File.read("#{source}without_items.xml")
57
+ id = "47101010033"
58
+ message[:customerData][:code] = id
59
+ savon.expects(:get_by_code).with(message: message).returns(xml)
60
+ report = Julianus.report(id)
61
+ end
62
+
63
+ it 'receives multiple items' do
64
+ xml = File.read("#{source}with_multiple_items.xml")
65
+ id = "38911066514"
66
+ message[:customerData][:code] = id
67
+ savon.expects(:get_by_code).with(message: message).returns(xml)
68
+ report = Julianus.report(id)
69
+ end
70
+
71
+ it 'insert random thing, get no items' do
72
+ xml = File.read("#{source}without_items.xml")
73
+ id = "random"
74
+ message[:customerData][:code] = id
75
+ savon.expects(:get_by_code).with(message: message).returns(xml)
76
+ report = Julianus.report(id)
77
+ end
78
+
79
+ it 'sends credit report' do
80
+ zip = "#{kr_source}file.zip"
81
+ file_name = "file.zip"
82
+ startResponse = file("#{kr_source}startuploadresponse.xml")
83
+ uploadResponse = file("#{kr_source}uploadChunkResponse.xml")
84
+ finishResponse = file("#{kr_source}finishuploadResponse.xml")
85
+
86
+ response =
87
+ savon.expects(:start_upload).with(
88
+ message: {
89
+ file_name: file_name
90
+ }
91
+ ).returns(startResponse)
92
+
93
+ id = to_xml(response)
94
+
95
+ savon.expects(:upload_chunk).with(
96
+ message: {
97
+ doc_id: id,
98
+ chunk: Base64.strict_encode64(File.read(zip))
99
+ }
100
+ ).returns(uploadResponse)
101
+
102
+ savon.expects(:finish_upload).with(message: {
103
+ doc_id: id,
104
+ md5: Digest::MD5.hexdigest(File.read(zip))
105
+ }
106
+ ).returns(finishResponse)
107
+
108
+ response = Julianus.send_report(zip)
109
+ end
110
+ end
@@ -0,0 +1,27 @@
1
+ require 'active_support/core_ext/hash/conversions'
2
+ # This file was generated by the `rspec --init` command. Conventionally, all
3
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
4
+ # Require this file using `require "spec_helper"` to ensure that it is only
5
+ # loaded once.
6
+ #
7
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
8
+ RSpec.configure do |config|
9
+ config.treat_symbols_as_metadata_keys_with_true_values = true
10
+ config.run_all_when_everything_filtered = true
11
+ config.filter_run :focus
12
+
13
+ # Run specs in random order to surface order dependencies. If you find an
14
+ # order dependency and want to debug it, you can fix the order by providing
15
+ # the seed, which is printed after each run.
16
+ # --seed 1234
17
+ config.order = 'random'
18
+ end
19
+
20
+ def to_xml str
21
+ Hash.from_xml(str.response!.raw_body
22
+ .gsub('\n', ''))['Envelope']['Body']['startUploadResponse']['return'].to_i
23
+ end
24
+
25
+ def file(source)
26
+ File.read(source)
27
+ end
data/test.rb ADDED
@@ -0,0 +1,21 @@
1
+ # encoding: UTF-8
2
+ require 'savon'
3
+
4
+ puts 'hello world'
5
+
6
+ realm = Base64.strict_encode64("cofif:Cof1F1nance")
7
+ @client = Savon.client(
8
+ ssl_verify_mode: :none,
9
+ wsdl: 'https://www.krediidiregister.ee/importer/wsdl-krediidiinfo.php?WSDL',
10
+ endpoint: 'https://www.krediidiregister.ee/importer/wsdl-krediidiinfo.php',
11
+ headers: { 'Authorization' => "Basic #{realm}"}
12
+ )
13
+
14
+ file = '/Users/liisu/Documents/WorkProjects/julianus/spec/fixtures/cofi_krediidihaldus_1.zip'
15
+
16
+ @client.call(
17
+ :upload_chunk,
18
+ :message => {
19
+ :doc_id => 1, :chunk => "abc"
20
+ }
21
+ )
metadata ADDED
@@ -0,0 +1,146 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: julianus
3
+ version: !ruby/object:Gem::Version
4
+ version: '1.0'
5
+ platform: ruby
6
+ authors:
7
+ - Mai-Liis
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-10-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: savon
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '2.11'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '2.11'
55
+ - !ruby/object:Gem::Dependency
56
+ name: nokogiri
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: ''
70
+ email:
71
+ - mailiish@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - .DS_Store
77
+ - .gitignore
78
+ - .rspec
79
+ - .ruby-gemset
80
+ - .ruby-version
81
+ - Gemfile
82
+ - LICENSE.txt
83
+ - README.md
84
+ - Rakefile
85
+ - julianus.gemspec
86
+ - lib/.DS_Store
87
+ - lib/julianus.rb
88
+ - lib/julianus/claim.rb
89
+ - lib/julianus/item.rb
90
+ - lib/julianus/report.rb
91
+ - lib/julianus/version.rb
92
+ - lib/krediidiregister.rb
93
+ - spec/.DS_Store
94
+ - spec/fixtures/Krediidiregister/cofi_krediidihaldus_1393889413.xml
95
+ - spec/fixtures/Krediidiregister/cofi_krediidihaldus_24.zip
96
+ - spec/fixtures/Krediidiregister/file.zip
97
+ - spec/fixtures/Krediidiregister/finishuploadresponse.xml
98
+ - spec/fixtures/Krediidiregister/startuploadresponse.xml
99
+ - spec/fixtures/Krediidiregister/uploadChunkResponse.xml
100
+ - spec/fixtures/get_by_code.wsdl
101
+ - spec/fixtures/random_id.xml
102
+ - spec/fixtures/with_item.xml
103
+ - spec/fixtures/with_multiple_items.xml
104
+ - spec/fixtures/without_items.xml
105
+ - spec/julianus_spec.rb
106
+ - spec/spec_helper.rb
107
+ - test.rb
108
+ homepage: ''
109
+ licenses:
110
+ - MIT
111
+ metadata: {}
112
+ post_install_message:
113
+ rdoc_options: []
114
+ require_paths:
115
+ - lib
116
+ required_ruby_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ! '>='
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ required_rubygems_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ requirements: []
127
+ rubyforge_project:
128
+ rubygems_version: 2.4.6
129
+ signing_key:
130
+ specification_version: 4
131
+ summary: ''
132
+ test_files:
133
+ - spec/.DS_Store
134
+ - spec/fixtures/Krediidiregister/cofi_krediidihaldus_1393889413.xml
135
+ - spec/fixtures/Krediidiregister/cofi_krediidihaldus_24.zip
136
+ - spec/fixtures/Krediidiregister/file.zip
137
+ - spec/fixtures/Krediidiregister/finishuploadresponse.xml
138
+ - spec/fixtures/Krediidiregister/startuploadresponse.xml
139
+ - spec/fixtures/Krediidiregister/uploadChunkResponse.xml
140
+ - spec/fixtures/get_by_code.wsdl
141
+ - spec/fixtures/random_id.xml
142
+ - spec/fixtures/with_item.xml
143
+ - spec/fixtures/with_multiple_items.xml
144
+ - spec/fixtures/without_items.xml
145
+ - spec/julianus_spec.rb
146
+ - spec/spec_helper.rb