apralib 0.0.1 → 0.0.2
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 +4 -4
- data/README.md +5 -0
- data/lib/apralib/apra_service.rb +9 -5
- data/lib/apralib/response.rb +4 -2
- data/lib/apralib/version.rb +1 -1
- data/spec/lib/apra_service_spec.rb +10 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 224a37c92a5d6d226dc47de0b91306afea784f2b
|
4
|
+
data.tar.gz: d51148502133e9c5dd52597c85ef56482076f85f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9fbad13674a88ea3fe41e72b247a2d92cf5647b3714220fdffa81d36d9977865f3dabbf7cfcc78d8fc55932e690812d360fb226ec6535b7a56240758cc1639d0
|
7
|
+
data.tar.gz: 873b94bd5cc2a74753a97f84ae5f8d51dbc48f1bca7aed0ce83e5c806e4efe71d182ceaf223e392574e697e92f5ccc54e6f9b6ffb1710547c2e5287069743202
|
data/README.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# Apralib
|
2
2
|
|
3
|
+
|
4
|
+
[](https://travis-ci.org/nessche/apralib)
|
5
|
+
[](http://badge.fury.io/rb/apralib)
|
6
|
+
|
7
|
+
|
3
8
|
A Ruby library to submit documents to the Apra Service run by [Maatalousyrittäjien eläkelaitos](http://www.mela.fi)
|
4
9
|
|
5
10
|
## Installation
|
data/lib/apralib/apra_service.rb
CHANGED
@@ -17,11 +17,15 @@ module ApraService
|
|
17
17
|
raise ArgumentError, 'notifications object must be either a Notification object or an array of Notification objects' unless
|
18
18
|
(notifications.is_a? Notification or (notifications.is_a? Array and notifications.detect {|n| !n.is_a? Notification}.nil?))
|
19
19
|
notifications = [notifications] unless notifications.is_a? Array
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
if notifications.count > 0
|
21
|
+
message = {}
|
22
|
+
message[:arg0] = notifications.map {|notification| notification.to_hash}
|
23
|
+
response = @client.call(:lisaa_apurahat, :message => message)
|
24
|
+
raise RuntimeError, 'An error occurred while submitting the notification' unless response.success?
|
25
|
+
Response.from_hash(response.body)
|
26
|
+
else
|
27
|
+
Response.new
|
28
|
+
end
|
25
29
|
end
|
26
30
|
|
27
31
|
|
data/lib/apralib/response.rb
CHANGED
@@ -4,6 +4,10 @@ module ApraService
|
|
4
4
|
|
5
5
|
attr_accessor :failed_notifications
|
6
6
|
|
7
|
+
def initialize
|
8
|
+
@failed_notifications = []
|
9
|
+
end
|
10
|
+
|
7
11
|
|
8
12
|
def self.from_hash(hash)
|
9
13
|
puts hash.inspect
|
@@ -13,8 +17,6 @@ module ApraService
|
|
13
17
|
if failures
|
14
18
|
failures = [failures] unless failures.is_a? Array
|
15
19
|
response.failed_notifications = failures.map {|notification| NotificationResponse.from_hash(notification) }
|
16
|
-
else
|
17
|
-
response.failed_notifications = []
|
18
20
|
end
|
19
21
|
response
|
20
22
|
end
|
data/lib/apralib/version.rb
CHANGED
@@ -25,6 +25,10 @@ module ApraService
|
|
25
25
|
|
26
26
|
end
|
27
27
|
|
28
|
+
end
|
29
|
+
|
30
|
+
describe 'send_notifications' do
|
31
|
+
|
28
32
|
it 'should send the notification to the server' do
|
29
33
|
|
30
34
|
service = get_client
|
@@ -71,7 +75,12 @@ module ApraService
|
|
71
75
|
expect(notification_response.notification.reference).to eq(notification.reference)
|
72
76
|
end
|
73
77
|
|
74
|
-
|
78
|
+
it 'should return an empty response when an empty array is passed' do
|
79
|
+
service = get_client
|
80
|
+
response = service.send_notifications([])
|
81
|
+
expect(response).not_to be_nil
|
82
|
+
expect(response.failed_notifications.count).to eq(0)
|
83
|
+
end
|
75
84
|
|
76
85
|
|
77
86
|
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.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marco Sandrini
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|