apralib 0.0.2 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +3 -0
- data/.travis.yml +6 -6
- data/apralib.gemspec +6 -4
- data/lib/apralib/apra_service.rb +4 -2
- data/lib/apralib/grantee.rb +10 -6
- data/lib/apralib/version.rb +1 -1
- data/spec/lib/apra_service_spec.rb +5 -3
- data/spec/lib/grantee_spec.rb +22 -0
- metadata +15 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c82771315862534107fdf877581a8acc4b834d57b3b162b4248784fc0476ea8f
|
4
|
+
data.tar.gz: 63cbc93ef71202087e605373b254da69cfee60bf072f3143e5c47f6f4ea43018
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3b976bd086d348a024924fef2c9846910a842f1c39cd0892ec3a0d84bf89fd1f381d0b850b89119b106f138a4a437540e2a689be5c74491b97d41859b5df248
|
7
|
+
data.tar.gz: d54037f2eaf19b88077336da847dd3e7331fdf201be8f9a5ff841b434d95b198baf77cfef29f503248141cc436fea4101235304e309da552b09fc5fa04177fd0
|
data/.rubocop.yml
ADDED
data/.travis.yml
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
- 2.
|
4
|
-
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
- 2.7.2
|
4
|
+
- 2.4.0
|
5
|
+
deploy:
|
6
|
+
provider: rubygems
|
7
|
+
edge: true
|
8
|
+
|
data/apralib.gemspec
CHANGED
@@ -17,10 +17,12 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ['lib']
|
20
|
+
spec.required_ruby_version = '>= 2.4.0'
|
20
21
|
|
21
|
-
spec.add_development_dependency 'bundler', '~> 1
|
22
|
-
spec.add_development_dependency 'rake'
|
23
|
-
spec.add_development_dependency 'rspec', '~> 3.
|
22
|
+
spec.add_development_dependency 'bundler', '~> 2.1'
|
23
|
+
spec.add_development_dependency 'rake', '~> 13.0.0'
|
24
|
+
spec.add_development_dependency 'rspec', '~> 3.10.0'
|
24
25
|
spec.add_development_dependency 'yard'
|
25
|
-
spec.add_dependency 'savon', '~> 2.
|
26
|
+
spec.add_dependency 'savon', '~> 2.12.0'
|
27
|
+
|
26
28
|
end
|
data/lib/apralib/apra_service.rb
CHANGED
@@ -6,10 +6,12 @@ module ApraService
|
|
6
6
|
|
7
7
|
class Client
|
8
8
|
|
9
|
-
def initialize(username, password)
|
9
|
+
def initialize(username, password, proxy = nil)
|
10
|
+
|
10
11
|
@client = Savon.client(wsdl: 'https://palvelu.mela.fi/Apurahailmoitukset/ws/apurahanSyottoWS?wsdl',
|
11
12
|
wsse_auth: [username, password],
|
12
|
-
endpoint: 'https://palvelu.mela.fi/Apurahailmoitukset/ws/apurahanSyottoWS'
|
13
|
+
endpoint: 'https://palvelu.mela.fi/Apurahailmoitukset/ws/apurahanSyottoWS',
|
14
|
+
proxy: proxy)
|
13
15
|
end
|
14
16
|
|
15
17
|
def send_notifications(notifications)
|
data/lib/apralib/grantee.rb
CHANGED
@@ -2,8 +2,8 @@ module ApraService
|
|
2
2
|
|
3
3
|
class Grantee
|
4
4
|
|
5
|
-
SSN_REGEX = /(\d{6})([-+A])(\d{3})([0-9ABCDEFHJKLMNPRSTUVWXY])
|
6
|
-
CHECK_DIGITS = %w
|
5
|
+
SSN_REGEX = /(\d{6})([-+A])(\d{3})([0-9ABCDEFHJKLMNPRSTUVWXY])/.freeze
|
6
|
+
CHECK_DIGITS = %w[0 1 2 3 4 5 6 7 8 9 A B C D E F H J K L M N P R S T U V W X Y].freeze
|
7
7
|
|
8
8
|
attr_accessor :first_names, :last_name, :ssn, :address, :zip
|
9
9
|
|
@@ -26,16 +26,20 @@ module ApraService
|
|
26
26
|
grantee.address = hash[:apurahansaajanosoite]
|
27
27
|
grantee.zip = hash[:apurahansaajanpostinumero]
|
28
28
|
grantee.first_names = [hash[:etunimi1]]
|
29
|
-
grantee.
|
30
|
-
grantee.
|
29
|
+
grantee.first_names << hash[:etunimi2] if hash[:etunimi2]
|
30
|
+
grantee.first_names << hash[:etunimi3] if hash[:etunimi3]
|
31
31
|
grantee.ssn = hash[:henkilotunnus]
|
32
32
|
grantee.last_name = hash[:sukunimi]
|
33
33
|
grantee
|
34
34
|
end
|
35
35
|
|
36
36
|
def ssn=(ssn)
|
37
|
-
|
38
|
-
|
37
|
+
if ssn
|
38
|
+
Grantee.verify_ssn!(ssn.upcase)
|
39
|
+
self.instance_variable_set('@ssn', ssn.upcase)
|
40
|
+
else
|
41
|
+
self.instance_variable_set('@ssn', nil)
|
42
|
+
end
|
39
43
|
end
|
40
44
|
|
41
45
|
def self.verify_ssn!(ssn)
|
data/lib/apralib/version.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'apralib'
|
3
|
+
require 'securerandom'
|
3
4
|
|
4
5
|
module ApraService
|
5
6
|
|
@@ -9,10 +10,11 @@ module ApraService
|
|
9
10
|
def get_client
|
10
11
|
credentials = {}
|
11
12
|
credentials_file = File.join(File.dirname(__FILE__), 'apra_credentials.yml')
|
12
|
-
credentials = YAML.load(File.read(credentials_file)) if File.
|
13
|
+
credentials = YAML.load(File.read(credentials_file)) if File.exist?(credentials_file)
|
13
14
|
user = credentials['user'] || ENV['APRA_USER']
|
14
15
|
password = credentials['password'] || ENV['APRA_PASSWORD']
|
15
|
-
|
16
|
+
proxy = credentials['proxy'] || ENV['PROXY_URL']
|
17
|
+
Client.new(user, password, proxy)
|
16
18
|
end
|
17
19
|
|
18
20
|
|
@@ -20,7 +22,7 @@ module ApraService
|
|
20
22
|
|
21
23
|
it 'should create a valid object' do
|
22
24
|
|
23
|
-
service = Client.new('user','password')
|
25
|
+
service = Client.new('user', 'password')
|
24
26
|
expect(service).not_to be_nil
|
25
27
|
|
26
28
|
end
|
data/spec/lib/grantee_spec.rb
CHANGED
@@ -22,6 +22,28 @@ module ApraService
|
|
22
22
|
|
23
23
|
end
|
24
24
|
|
25
|
+
describe 'ssn=' do
|
26
|
+
|
27
|
+
it 'should convert the code to uppercase' do
|
28
|
+
|
29
|
+
grantee = Grantee.new
|
30
|
+
grantee.ssn = '111111-111c'
|
31
|
+
expect(grantee.ssn).to eq('111111-111C')
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should set the value to nil when passed a nil value' do
|
36
|
+
|
37
|
+
grantee = Grantee.new
|
38
|
+
grantee.ssn = '111111-111C'
|
39
|
+
grantee.ssn = nil
|
40
|
+
expect(grantee.ssn).to be_nil
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
end
|
46
|
+
|
25
47
|
end
|
26
48
|
|
27
49
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apralib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marco Sandrini
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,42 +16,42 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1
|
19
|
+
version: '2.1'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1
|
26
|
+
version: '2.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 13.0.0
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 13.0.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 3.
|
47
|
+
version: 3.10.0
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 3.
|
54
|
+
version: 3.10.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: yard
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 2.
|
75
|
+
version: 2.12.0
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 2.
|
82
|
+
version: 2.12.0
|
83
83
|
description: A Ruby client for the Apra Service
|
84
84
|
email:
|
85
85
|
- nessche@gmail.com
|
@@ -88,6 +88,7 @@ extensions: []
|
|
88
88
|
extra_rdoc_files: []
|
89
89
|
files:
|
90
90
|
- ".gitignore"
|
91
|
+
- ".rubocop.yml"
|
91
92
|
- ".travis.yml"
|
92
93
|
- Gemfile
|
93
94
|
- LICENSE.txt
|
@@ -116,15 +117,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
116
117
|
requirements:
|
117
118
|
- - ">="
|
118
119
|
- !ruby/object:Gem::Version
|
119
|
-
version:
|
120
|
+
version: 2.4.0
|
120
121
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
122
|
requirements:
|
122
123
|
- - ">="
|
123
124
|
- !ruby/object:Gem::Version
|
124
125
|
version: '0'
|
125
126
|
requirements: []
|
126
|
-
|
127
|
-
rubygems_version: 2.2.2
|
127
|
+
rubygems_version: 3.0.8
|
128
128
|
signing_key:
|
129
129
|
specification_version: 4
|
130
130
|
summary: A Ruby library to submit documents to the Apra Service run by Maatalousyrittäjien
|
@@ -133,4 +133,3 @@ test_files:
|
|
133
133
|
- spec/lib/apra_service_spec.rb
|
134
134
|
- spec/lib/grantee_spec.rb
|
135
135
|
- spec/spec_helper.rb
|
136
|
-
has_rdoc:
|