apralib 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 59af58d7a0d079dec4dca4c1532b86e2663ac9e1
4
- data.tar.gz: d6d076636dbf8ecff1f567fdb7a9415e5ae4fb80
3
+ metadata.gz: 224a37c92a5d6d226dc47de0b91306afea784f2b
4
+ data.tar.gz: d51148502133e9c5dd52597c85ef56482076f85f
5
5
  SHA512:
6
- metadata.gz: ddac87c831ebb1de2e417075b17c3d43f253af1bbbce7a609418a192311ed3cd562fec65b4319920ff88131d51c01cfaab656f74546fc063529b34d3e017bad2
7
- data.tar.gz: f01b555e830993def27fcf61ea97e3add099707b84517777bb17d2047e8d0ed5aa1bed9bb38d5a72a74193bd42b7e0fe9a93c7fc6f6d4cd098800091bd7c3f98
6
+ metadata.gz: 9fbad13674a88ea3fe41e72b247a2d92cf5647b3714220fdffa81d36d9977865f3dabbf7cfcc78d8fc55932e690812d360fb226ec6535b7a56240758cc1639d0
7
+ data.tar.gz: 873b94bd5cc2a74753a97f84ae5f8d51dbc48f1bca7aed0ce83e5c806e4efe71d182ceaf223e392574e697e92f5ccc54e6f9b6ffb1710547c2e5287069743202
data/README.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Apralib
2
2
 
3
+
4
+ [![Build Status](https://travis-ci.org/nessche/apralib.svg?branch=master)](https://travis-ci.org/nessche/apralib)
5
+ [![Gem Version](https://badge.fury.io/rb/apralib.svg)](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
@@ -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
- message = {}
21
- message[:arg0] = notifications.map {|notification| notification.to_hash}
22
- response = @client.call(:lisaa_apurahat, :message => message)
23
- raise RuntimeError, 'An error occurred while submitting the notification' unless response.success?
24
- Response.from_hash(response.body)
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
 
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Apralib
2
- VERSION = "0.0.1"
2
+ VERSION = '0.0.2'
3
3
  end
@@ -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.1
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-02 00:00:00.000000000 Z
11
+ date: 2014-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler