rumour-ruby 0.0.5 → 0.0.6
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 +13 -0
- data/lib/rumour-ruby/client.rb +2 -0
- data/lib/rumour-ruby/configuration.rb +3 -1
- data/lib/rumour-ruby/version.rb +1 -1
- data/spec/client_spec.rb +31 -1
- data/spec/configuration_spec.rb +4 -0
- 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: 49f003949d2ca887b9228df2d488458d79b6a2d6
|
4
|
+
data.tar.gz: e9ccb408e56391fc911d6886425c83c5a43219a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2dce1d00f96398960801fbaef36008edae1d0c0b10f58337550c1e79206885f2d947f1ad1dfa3efbca805cc5253414b417fe5956c525be359a547158c2cdd12d
|
7
|
+
data.tar.gz: 809460e200dac200bed010990e1f27a31a90afc719bb13aa6fff16e7e0bffc1af28506fdeebfc67592eb352702be8dc28799df961377b046a08149e6046e035e
|
data/README.md
CHANGED
@@ -54,6 +54,19 @@ recipient = 'Device-Token-Here'
|
|
54
54
|
rumour.send_push_notification('ios', recipient, alert: { ... })
|
55
55
|
```
|
56
56
|
|
57
|
+
### Interceptors
|
58
|
+
|
59
|
+
Intercept text messages and/or push notifications when you don't want to send stuff to real numbers. Every text message and/or push notification will be intercepted and sent to the recipients you might configure as interceptors:
|
60
|
+
```ruby
|
61
|
+
# config/initializers/rumour.rb
|
62
|
+
|
63
|
+
Rumour.configure do |config|
|
64
|
+
config.intercept_text_message_recipient = 'your_mobile_phone_number'
|
65
|
+
config.config.intercept_push_notification_recipient = 'your_device_token'
|
66
|
+
end
|
67
|
+
```
|
68
|
+
|
69
|
+
|
57
70
|
## Contributing
|
58
71
|
|
59
72
|
1. Fork it ( https://github.com/joaodiogocosta/rumour-ruby/fork )
|
data/lib/rumour-ruby/client.rb
CHANGED
@@ -16,10 +16,12 @@ module Rumour
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def send_text_message(sender, recipient, body)
|
19
|
+
recipient = Rumour.configuration.intercept_text_message_recipient || recipient
|
19
20
|
post('/text_messages', text_message: { from: sender, recipient: recipient, body: body })
|
20
21
|
end
|
21
22
|
|
22
23
|
def send_push_notification(platform, recipient, options= {})
|
24
|
+
recipient = Rumour.configuration.intercept_push_notification_recipient || recipient
|
23
25
|
post('/push_notifications', push_notification: { platform: platform, recipient: recipient }.merge(options))
|
24
26
|
end
|
25
27
|
|
data/lib/rumour-ruby/version.rb
CHANGED
data/spec/client_spec.rb
CHANGED
@@ -51,7 +51,7 @@ RSpec.describe Rumour::Client do
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
describe 'push_notifications' do
|
54
|
+
describe 'android push_notifications' do
|
55
55
|
describe 'send with valid data' do
|
56
56
|
it 'creates and retrieves a new push notification as a hash' do
|
57
57
|
rumour_client = Rumour::Client.new(RUMOUR_TEST_ACCESS_TOKEN)
|
@@ -72,4 +72,34 @@ RSpec.describe Rumour::Client do
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
end
|
75
|
+
|
76
|
+
describe 'interceptor' do
|
77
|
+
describe 'for text messages' do
|
78
|
+
it 'sends the message to the interceptor' do
|
79
|
+
Rumour.configure do |config|
|
80
|
+
config.intercept_text_message_recipient = '+14108675309'
|
81
|
+
end
|
82
|
+
|
83
|
+
rumour_client = Rumour::Client.new(RUMOUR_TEST_ACCESS_TOKEN)
|
84
|
+
text_message = rumour_client.send_text_message(TWILIO_TEST_SENDER_NUMBER, '+351912345678', 'Hello from rumour-ruby!')
|
85
|
+
|
86
|
+
expect(text_message['id']).to_not be_nil
|
87
|
+
expect(text_message['recipient']).to eq('+14108675309')
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe 'for push notifications' do
|
92
|
+
it 'sends the push notification to the interceptor' do
|
93
|
+
Rumour.configure do |config|
|
94
|
+
config.intercept_push_notification_recipient = 'push_recipient'
|
95
|
+
end
|
96
|
+
|
97
|
+
rumour_client = Rumour::Client.new(RUMOUR_TEST_ACCESS_TOKEN)
|
98
|
+
push_notification = rumour_client.send_push_notification('ios', 'some_registration_id', { alert: 'world'})
|
99
|
+
|
100
|
+
expect(push_notification['id']).to_not be_nil
|
101
|
+
expect(push_notification['recipient']).to eq('push_recipient')
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
75
105
|
end
|
data/spec/configuration_spec.rb
CHANGED
@@ -6,12 +6,16 @@ RSpec.describe Rumour do
|
|
6
6
|
described_class.configure do |config|
|
7
7
|
config.api_key = 'some_api_key'
|
8
8
|
config.access_token = 'some_access_token'
|
9
|
+
config.intercept_text_message_recipient = '+14108675309'
|
10
|
+
config.intercept_push_notification_recipient = 'push_recipient'
|
9
11
|
end
|
10
12
|
end
|
11
13
|
|
12
14
|
it 'assigns the authentication credentials' do
|
13
15
|
expect(described_class.configuration.api_key).to eq('some_api_key')
|
14
16
|
expect(described_class.configuration.access_token).to eq('some_access_token')
|
17
|
+
expect(described_class.configuration.intercept_text_message_recipient).to eq('+14108675309')
|
18
|
+
expect(described_class.configuration.intercept_push_notification_recipient).to eq('push_recipient')
|
15
19
|
end
|
16
20
|
end
|
17
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.6
|
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-04-
|
11
|
+
date: 2015-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|