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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fdd971a1719504ce228ab976632db9e3825650a8
4
- data.tar.gz: df77c915b551cf99081aa6b588f494277b5d4e61
3
+ metadata.gz: 49f003949d2ca887b9228df2d488458d79b6a2d6
4
+ data.tar.gz: e9ccb408e56391fc911d6886425c83c5a43219a9
5
5
  SHA512:
6
- metadata.gz: 8edec41fecb00d3a5e6f400d3c6c1e6357dad6ecdd8bacc9c64cc90c05b45be1f1b7ecddd9e3fc3a08662653ca6807307a22da1823cd051a2e48a8e4400bdecd
7
- data.tar.gz: 6c3a8f5be882122b67e31c1a35543743b3dc66229880079f359a541ba2e70072d86f0bf7e3ab1abb5e3a23f8fb277f4aa242b0fe8bbf1cca6ff88b1f6929b44e
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 )
@@ -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
 
@@ -2,7 +2,9 @@ module Rumour
2
2
  class Configuration
3
3
  CONFIGURABLE_ATTRIBUTES = [
4
4
  :api_key,
5
- :access_token
5
+ :access_token,
6
+ :intercept_text_message_recipient,
7
+ :intercept_push_notification_recipient
6
8
  ]
7
9
 
8
10
  attr_accessor *CONFIGURABLE_ATTRIBUTES
@@ -1,3 +1,3 @@
1
1
  module Rumour
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'
3
3
  end
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
@@ -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.5
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-23 00:00:00.000000000 Z
11
+ date: 2015-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty