rumour-ruby 0.0.7 → 0.0.8
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 +39 -10
- data/lib/rumour-ruby/client.rb +12 -4
- data/lib/rumour-ruby/configuration.rb +1 -1
- data/lib/rumour-ruby/version.rb +1 -1
- data/spec/client_spec.rb +20 -9
- data/spec/configuration_spec.rb +2 -2
- 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: 46ad17d4fb6cc20cecbfeb40245953061ff37a06
|
4
|
+
data.tar.gz: bf9cc35dab1c53b265ae2c589ef19744e59b2e11
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26faf381cd5daacbbe5da354afb79e989a69b98939105e76bc9266117f2d85724a232bbfb7b43187df42eff772a5995e1985ee1a005ff5c4f3e5d046ecef3fcc
|
7
|
+
data.tar.gz: 01cc7d2f3061ce0606b2f934fdde66515726c816d555e2ffc779445936b96d377a6cd50a05638f500513eb300bf3f19cbb18fbc633a7ee944e08f59e29a7a266
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# rumour-ruby
|
2
2
|
|
3
|
-
|
3
|
+
**rumour-ruby** is a Ruby wrapper to communicate with Rumour REST API.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -34,24 +34,53 @@ rumour = Rumour::Client.new(access_token)
|
|
34
34
|
Then, send a text message:
|
35
35
|
```ruby
|
36
36
|
from = '+15005550006'
|
37
|
-
|
37
|
+
recipients = '+15005550005'
|
38
38
|
|
39
|
-
rumour.send_text_message(from, recipient,
|
39
|
+
rumour.send_text_message(from, recipient, Hello from Rumour!')
|
40
40
|
#=> {'id' => '1', 'from' => '+15005550006', 'recipient' => '+15005550005', ... }
|
41
41
|
```
|
42
42
|
|
43
43
|
Or an Android Push Notification:
|
44
44
|
```ruby
|
45
|
-
|
46
|
-
|
47
|
-
rumour.send_push_notification(
|
45
|
+
recipients = ['android::Registration-Id-Here']
|
46
|
+
|
47
|
+
rumour.send_push_notification(
|
48
|
+
recipients,
|
49
|
+
title: 'Push Notification Title', # optional
|
50
|
+
text: 'Push Notification Text', # optional
|
51
|
+
additional_data: { ... } # optional
|
52
|
+
android: { data: { some_key: 'some_value'}}, # optional
|
53
|
+
)
|
54
|
+
#=> [{'id' => '2', 'platform' => 'android', 'recipient' => 'Registration-Id-Here', ...}]
|
48
55
|
```
|
49
56
|
|
50
57
|
Or even an iOS Push Notification:
|
51
58
|
```ruby
|
52
|
-
|
59
|
+
recipients = ['ios::Device-Token-Here']
|
60
|
+
|
61
|
+
rumour.send_push_notification(
|
62
|
+
recipients,
|
63
|
+
title: 'Push Notification Title', # optional
|
64
|
+
text: 'Push Notification Text', # optional
|
65
|
+
additional_data: { ... }, # optional
|
66
|
+
ios: { alert: { badge: 2 } } # optional
|
67
|
+
)
|
68
|
+
#=> [{'id' => '2', 'platform' => 'ios', 'recipient' => 'Device-Token-Here', ...}]
|
69
|
+
```
|
53
70
|
|
54
|
-
|
71
|
+
You can also send Push Notifications for multiple devices and platforms:
|
72
|
+
```ruby
|
73
|
+
recipients = ['android::Registration-Id-Here', 'ios::Device-Token-Here']
|
74
|
+
|
75
|
+
rumour.send_push_notification(
|
76
|
+
recipients,
|
77
|
+
title: 'Push Notification Title', # optional
|
78
|
+
text: 'Push Notification Text', # optional
|
79
|
+
additional_data: { ... }, # optional
|
80
|
+
android: { data: { some_key: 'some_value'}}, # optional
|
81
|
+
ios: { alert: { badge: 2 } } # optional
|
82
|
+
)
|
83
|
+
#=> [{'id' => '3', 'platform' => 'android', 'recipient' => 'Registration-Id-Here', ...}, {'id' => '4', 'platform' => 'ios', 'recipient' => 'Device-Token-Here', ...}]
|
55
84
|
```
|
56
85
|
|
57
86
|
### Interceptors
|
@@ -62,7 +91,7 @@ Intercept text messages and/or push notifications when you don't want to send st
|
|
62
91
|
|
63
92
|
Rumour.configure do |config|
|
64
93
|
config.intercept_text_message_recipient = 'your_mobile_phone_number'
|
65
|
-
config.
|
94
|
+
config.intercept_push_notification_recipients = ['android::your_registration_id']
|
66
95
|
end
|
67
96
|
```
|
68
97
|
|
data/lib/rumour-ruby/client.rb
CHANGED
@@ -16,13 +16,13 @@ module Rumour
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def send_text_message(sender, recipient, body)
|
19
|
-
recipient =
|
19
|
+
recipient = intercept_tm_recipient || recipient
|
20
20
|
post('/text_messages', text_message: { from: sender, recipient: recipient, body: body })
|
21
21
|
end
|
22
22
|
|
23
|
-
def send_push_notification(
|
24
|
-
|
25
|
-
post('/push_notifications', push_notification: {
|
23
|
+
def send_push_notification(recipients, options= {})
|
24
|
+
recipients = intercept_pn_recipients unless [intercept_pn_recipients].compact.empty?
|
25
|
+
post('/push_notifications', push_notification: { recipients: [recipients].flatten }.merge(options))
|
26
26
|
end
|
27
27
|
|
28
28
|
private
|
@@ -54,5 +54,13 @@ module Rumour
|
|
54
54
|
raise Rumour::Errors::AuthenticationError.new response_body['message']
|
55
55
|
end
|
56
56
|
end
|
57
|
+
|
58
|
+
def intercept_tm_recipient
|
59
|
+
Rumour.configuration.intercept_text_message_recipient
|
60
|
+
end
|
61
|
+
|
62
|
+
def intercept_pn_recipients
|
63
|
+
Rumour.configuration.intercept_push_notification_recipients
|
64
|
+
end
|
57
65
|
end
|
58
66
|
end
|
data/lib/rumour-ruby/version.rb
CHANGED
data/spec/client_spec.rb
CHANGED
@@ -35,7 +35,6 @@ RSpec.describe Rumour::Client do
|
|
35
35
|
it 'creates and retrieves a new message as a hash' do
|
36
36
|
rumour_client = Rumour::Client.new(RUMOUR_TEST_ACCESS_TOKEN)
|
37
37
|
text_message = rumour_client.send_text_message(TWILIO_TEST_SENDER_NUMBER, TWILIO_TEST_RECIPIENT_NUMBER, 'Hello from rumour-ruby!')
|
38
|
-
|
39
38
|
expect(text_message['id']).to_not be_nil
|
40
39
|
end
|
41
40
|
end
|
@@ -55,9 +54,9 @@ RSpec.describe Rumour::Client do
|
|
55
54
|
describe 'send with valid data' do
|
56
55
|
it 'creates and retrieves a new push notification as a hash' do
|
57
56
|
rumour_client = Rumour::Client.new(RUMOUR_TEST_ACCESS_TOKEN)
|
58
|
-
|
57
|
+
push_notifications = rumour_client.send_push_notification(['android::some_registration_id'], title: 'PN Title', body: 'PN Text', android: { data: { my_key: 'my_value'}})
|
59
58
|
|
60
|
-
expect(
|
59
|
+
expect(push_notifications[0]['id']).to_not be_nil
|
61
60
|
end
|
62
61
|
end
|
63
62
|
end
|
@@ -66,9 +65,21 @@ RSpec.describe Rumour::Client do
|
|
66
65
|
describe 'send with valid data' do
|
67
66
|
it 'creates and retrieves a new push notification as a hash' do
|
68
67
|
rumour_client = Rumour::Client.new(RUMOUR_TEST_ACCESS_TOKEN)
|
69
|
-
|
68
|
+
push_notifications = rumour_client.send_push_notification('ios::some_device_token', title: 'PN Title', body: 'PN Text', ios: { alert: { title: 'iOS Title'}})
|
69
|
+
|
70
|
+
expect(push_notifications[0]['id']).to_not be_nil
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe 'ios push_notifications' do
|
76
|
+
describe 'send for multiple recipients with valid data' do
|
77
|
+
it 'creates and retrieves a new push notification as a hash' do
|
78
|
+
rumour_client = Rumour::Client.new(RUMOUR_TEST_ACCESS_TOKEN)
|
79
|
+
push_notifications = rumour_client.send_push_notification(['ios::some_device_token', 'android::some_device_token'], title: 'PN Title', body: 'PN Text', ios: { alert: { title: 'iOS Title'}})
|
70
80
|
|
71
|
-
expect(
|
81
|
+
expect(push_notifications[0]['id']).to_not be_nil
|
82
|
+
expect(push_notifications[1]['id']).to_not be_nil
|
72
83
|
end
|
73
84
|
end
|
74
85
|
end
|
@@ -91,14 +102,14 @@ RSpec.describe Rumour::Client do
|
|
91
102
|
describe 'for push notifications' do
|
92
103
|
it 'sends the push notification to the interceptor' do
|
93
104
|
Rumour.configure do |config|
|
94
|
-
config.
|
105
|
+
config.intercept_push_notification_recipients = ['ios::push_recipient']
|
95
106
|
end
|
96
107
|
|
97
108
|
rumour_client = Rumour::Client.new(RUMOUR_TEST_ACCESS_TOKEN)
|
98
|
-
|
109
|
+
push_notifications = rumour_client.send_push_notification('ios::some_device_token', title: 'PN Title', body: 'PN Text', ios_alert: { title: 'iOS Title'})
|
99
110
|
|
100
|
-
expect(
|
101
|
-
expect(
|
111
|
+
expect(push_notifications[0]['id']).to_not be_nil
|
112
|
+
expect(push_notifications[0]['recipient']).to eq('push_recipient')
|
102
113
|
end
|
103
114
|
end
|
104
115
|
end
|
data/spec/configuration_spec.rb
CHANGED
@@ -7,7 +7,7 @@ RSpec.describe Rumour do
|
|
7
7
|
config.api_key = 'some_api_key'
|
8
8
|
config.access_token = 'some_access_token'
|
9
9
|
config.intercept_text_message_recipient = '+14108675309'
|
10
|
-
config.
|
10
|
+
config.intercept_push_notification_recipients = ['android::push_recipient']
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
@@ -15,7 +15,7 @@ RSpec.describe Rumour do
|
|
15
15
|
expect(described_class.configuration.api_key).to eq('some_api_key')
|
16
16
|
expect(described_class.configuration.access_token).to eq('some_access_token')
|
17
17
|
expect(described_class.configuration.intercept_text_message_recipient).to eq('+14108675309')
|
18
|
-
expect(described_class.configuration.
|
18
|
+
expect(described_class.configuration.intercept_push_notification_recipients).to eq(['android::push_recipient'])
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rumour-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joao Diogo Costa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|