notification_hub 0.1.1 → 0.1.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 +17 -4
- data/lib/notification_hub/version.rb +1 -1
- data/lib/notification_hub.rb +9 -6
- 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: c08c80dcdbc25630fb719dc622f5541947f9534b
|
4
|
+
data.tar.gz: 22ad7dc461b6230bb66b1eb8fd5c6d0442b21b80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3cc4d4d0ecc10298c85242c71c247f525ca6377d8a74fe63e656d46bf75a5c394e842b6e83cd5a265062ea591a4f6f317f91ac4545b408f71ea191aa373c477
|
7
|
+
data.tar.gz: 8331c4e3d149485aa1fac74c7aa79d8f666ff4477c707b080acda112fb9a7cc0883c05812392d3addb4db6ca63b425af45ac05d7bffb54a1d187f260601831c1
|
data/README.md
CHANGED
@@ -24,12 +24,12 @@ Or install it yourself as:
|
|
24
24
|
|
25
25
|
This gem can be used to centralize the notification dispatching of an application.
|
26
26
|
|
27
|
-
Currently, this gem supports 5 notification channels
|
27
|
+
Currently, this gem supports 5 notification channels.
|
28
28
|
* Email
|
29
29
|
* Webhook
|
30
30
|
* SMS
|
31
31
|
* Mobile Push Notifications
|
32
|
-
*
|
32
|
+
* Browser Push Notifications
|
33
33
|
|
34
34
|
Each channel can be configured to use with a gateway.
|
35
35
|
Below gateways are already bult-in. You can always add custom gateways.
|
@@ -37,7 +37,7 @@ Below gateways are already bult-in. You can always add custom gateways.
|
|
37
37
|
* Webhook - HTTParty
|
38
38
|
* SMS - AWS
|
39
39
|
* Mobile Push Notifications - FCM(Firebase Cloud Messaging)
|
40
|
-
*
|
40
|
+
* Browser Push Notifications - FCM(Firebase Cloud Messaging)
|
41
41
|
|
42
42
|
## SETUP
|
43
43
|
|
@@ -75,18 +75,31 @@ Step 2
|
|
75
75
|
Define events in configuration file (config/initializers/notification_hub.rb)
|
76
76
|
Example:
|
77
77
|
config.events = {
|
78
|
+
[Event Code] => [Event Name],
|
78
79
|
"user.signed_up" => "When an user is signed up",
|
79
80
|
"user.trial_ended" => "When the trial period is ended",
|
80
81
|
"message.received" => "When a message is received"
|
81
82
|
}
|
82
83
|
|
84
|
+
Event code is namespaced by ".". For example, you can use relevant model name
|
85
|
+
as the first part of the code and actual event name as the last part,
|
83
86
|
|
84
87
|
Step 2
|
85
88
|
Create message templates
|
86
89
|
|
87
90
|
Examples: URL
|
88
91
|
|
89
|
-
|
92
|
+
For emails you need to create mailers too.
|
93
|
+
Example: (app/mailers/user_mailer.rb)
|
94
|
+
class UserMailer < ActionMailer::Base
|
95
|
+
def signed_up(data, to_email)
|
96
|
+
mail(to: to_email, subject: "Welcome to XYZ")
|
97
|
+
end
|
98
|
+
|
99
|
+
def trial_ended(data, to_email)
|
100
|
+
mail(to: to_email, subject: "[XYZ] Trial period ended")
|
101
|
+
end
|
102
|
+
end
|
90
103
|
|
91
104
|
## Development
|
92
105
|
|
data/lib/notification_hub.rb
CHANGED
@@ -33,9 +33,12 @@ module NotificationHub
|
|
33
33
|
send_message(association_model_id, event_code, data, options)
|
34
34
|
end
|
35
35
|
|
36
|
-
def deliver(association_model_id, event_code, data, options=nil)
|
37
|
-
|
38
|
-
|
36
|
+
def deliver(association_model_id, event_code, data, options=nil)
|
37
|
+
if NotificationHubJob.respond_to?("perform_later".to_sym)
|
38
|
+
NotificationHubJob.perform_later(association_model_id, event_code, data, options)
|
39
|
+
elsif NotificationHubJob.respond_to?("async0_later".to_sym)
|
40
|
+
NotificationHubJob.perform_async(association_model_id, event_code, data, options)
|
41
|
+
end
|
39
42
|
end
|
40
43
|
|
41
44
|
def send_message(association_model_id, event_code, data_wrapper, options)
|
@@ -72,10 +75,10 @@ module NotificationHub
|
|
72
75
|
end
|
73
76
|
|
74
77
|
def send_direct(event_code, data, device_details, channel_code, gateway_code=nil)
|
75
|
-
if
|
76
|
-
channel_const = "NotificationHub::Channels::#{
|
78
|
+
if gateway_code.present?
|
79
|
+
channel_const = "NotificationHub::Channels::#{channel_code.camelize}::#{gateway_code.camelize}".constantize
|
77
80
|
else
|
78
|
-
channel_const = "NotificationHub::Channels::#{
|
81
|
+
channel_const = "NotificationHub::Channels::#{channel_code.camelize}".constantize
|
79
82
|
end
|
80
83
|
begin
|
81
84
|
channel_const.send_message(event_code, data, device_details)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: notification_hub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Viduranga Wijesooriya
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05-
|
11
|
+
date: 2017-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|