magicbell 2.0.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +169 -152
- data/lib/magicbell/action_mailer_extension.rb +0 -10
- data/lib/magicbell/api_operations.rb +7 -3
- data/lib/magicbell/api_resources/user.rb +10 -2
- data/lib/magicbell/client.rb +23 -5
- data/lib/magicbell/config.rb +0 -5
- data/lib/magicbell/version.rb +1 -1
- data/lib/magicbell.rb +4 -14
- metadata +15 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 205676a39e21a70f18682b926501b0d8c67ea674df273cbda92fe838f21b0750
|
4
|
+
data.tar.gz: 9d0e2fbf7661d9cd6f4f910fa2d0dd89e2ee6d230798015cabe606202627ca53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 524d8ed46c49c90e295974547b72b05db01a80ce3215070f48348a846ddcada01f07368846f4bbd5baca680a3ff8127e43abe5915bf1c85dfcb423270e72a8b9
|
7
|
+
data.tar.gz: 0d3d21452e55687032910556225db73a2f95d933d6a6f54edc9897c3499326ce8d9b527fa1226f9853352157cfb3c1cdbe1634dbbb58910078dd822c264e3512
|
data/README.md
CHANGED
@@ -1,261 +1,278 @@
|
|
1
|
-
#
|
1
|
+
# MagicBell Ruby Library
|
2
2
|
|
3
|
-
|
3
|
+
This library provides convenient access to the [MagicBell REST API](https://magicbell.com/docs/rest-api/overview)
|
4
|
+
from applications written in Ruby. It includes helpers for creating
|
5
|
+
notifications, fetching them, and calculating the HMAC for a user.
|
4
6
|
|
5
|
-
|
7
|
+
[MagicBell](https://magicbell.com) is the notification inbox for your web and
|
8
|
+
mobile applications. You may find it helpful to familiarize yourself with the
|
9
|
+
[core concepts of MagicBell](https://magicbell.com/docs/core-concepts).
|
6
10
|
|
7
|
-
|
11
|
+
<img width="415" alt="MagicBell Notification Inbox" src="https://files.readme.io/c09b21a-image1.png">
|
8
12
|
|
9
|
-
|
13
|
+
## Installation
|
10
14
|
|
11
|
-
|
15
|
+
First, [sign up for a MagicBell account](https://magicbell.com) and grab your
|
16
|
+
MagicBell project's API key and secret from the "Settings" section of your
|
17
|
+
MagicBell dashboard.
|
12
18
|
|
13
|
-
|
19
|
+
If you just want to use the package, run:
|
14
20
|
|
15
|
-
|
21
|
+
```
|
22
|
+
gem install magicbell
|
23
|
+
```
|
16
24
|
|
17
|
-
|
25
|
+
### Bundler
|
18
26
|
|
19
|
-
|
27
|
+
If you are installing via bundler, add the gem to your app's Gemfile:
|
20
28
|
|
21
|
-
|
29
|
+
```ruby
|
30
|
+
# Gemfile
|
31
|
+
source 'https://rubygems.org'
|
22
32
|
|
23
|
-
|
33
|
+
gem 'magicbell'
|
34
|
+
```
|
24
35
|
|
25
|
-
|
36
|
+
and run `bundle install` a usual.
|
26
37
|
|
27
|
-
|
28
|
-
gem "magicbell"
|
29
|
-
```
|
38
|
+
## Configuration
|
30
39
|
|
31
|
-
|
40
|
+
The library needs to be configured with your MagicBell project's API key and
|
41
|
+
secret.
|
32
42
|
|
33
|
-
|
34
|
-
bundle install
|
35
|
-
```
|
43
|
+
### Global configuration
|
36
44
|
|
37
|
-
|
45
|
+
By default, this library will automatically pick your MagicBell project's API
|
46
|
+
key and secret from the `MAGICBELL_API_KEY` and `MAGICBELL_API_SECRET`
|
47
|
+
environment variables, respectively.
|
38
48
|
|
39
|
-
|
40
|
-
|
41
|
-
|
49
|
+
Alternatively, you can configure your MagicBell manually. For example, for a
|
50
|
+
rails project, create an initializer file for MagicBell and set your project's
|
51
|
+
keys:
|
42
52
|
|
43
53
|
```ruby
|
44
54
|
# config/initializers/magicbell.rb
|
45
55
|
|
46
56
|
MagicBell.configure do |config|
|
47
|
-
config.api_key =
|
48
|
-
config.api_secret =
|
57
|
+
config.api_key = 'MAGICBELL_API_KEY'
|
58
|
+
config.api_secret = 'MAGICBELL_API_SECRET'
|
49
59
|
end
|
50
60
|
```
|
51
61
|
|
52
|
-
|
62
|
+
### Per-request configuration
|
63
|
+
|
64
|
+
For apps that need to use multiple keys during the lifetime of a process,
|
65
|
+
provide the specific keys when you create instances of `MagicBell::Client`:
|
66
|
+
|
67
|
+
```ruby
|
68
|
+
require 'magicbell'
|
69
|
+
|
70
|
+
magicbell = MagicBell::Client.new(
|
71
|
+
api_key: 'MAGICBELL_PROJECT_API_KEY',
|
72
|
+
api_secret: 'MAGICBELL_PROJECT_API_SECRET'
|
73
|
+
)
|
74
|
+
```
|
75
|
+
|
76
|
+
Please keep in mind that any instance of `MagicBell::Client` will default to the
|
77
|
+
global configuration unless an API key and secret are provided.
|
53
78
|
|
54
|
-
|
79
|
+
## Usage
|
55
80
|
|
56
81
|
### Create a notification
|
57
82
|
|
58
|
-
|
83
|
+
You can send a notification to one or many users by identifying them by their
|
84
|
+
email address:
|
59
85
|
|
60
86
|
```ruby
|
87
|
+
require 'magicbell'
|
88
|
+
|
61
89
|
magicbell = MagicBell::Client.new
|
62
90
|
magicbell.create_notification(
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
]
|
91
|
+
title: 'Rob assigned a task to you',
|
92
|
+
recipients: [{
|
93
|
+
email: 'joe@example.com'
|
94
|
+
}, {
|
95
|
+
email: 'mary@example.com'
|
96
|
+
}]
|
69
97
|
)
|
70
98
|
```
|
71
99
|
|
72
|
-
|
100
|
+
Or you can identify users by an `external_id` (their ID in your database, for example):
|
73
101
|
|
74
102
|
```ruby
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
103
|
+
require 'magicbell'
|
104
|
+
|
105
|
+
magicbell = MagicBell::Client.new
|
106
|
+
magicbell.create_notification(
|
107
|
+
title: 'Rob assigned a task to you',
|
108
|
+
recipients: [{
|
109
|
+
external_id: 'DATABASE_ID'
|
110
|
+
}]
|
111
|
+
)
|
81
112
|
```
|
82
113
|
|
83
|
-
|
114
|
+
This method has the benefit of allowing users to access their notifications when
|
115
|
+
their email address changes. Make sure you identify users by their `externalID`
|
116
|
+
when you [initialize the notification inbox](https://magicbell.com/docs/react/identifying-users), too.
|
117
|
+
|
118
|
+
You can also provide other data accepted by [our API](https://magicbell.com/docs/rest-api/reference):
|
84
119
|
|
85
120
|
```ruby
|
121
|
+
require 'magicbell'
|
122
|
+
|
86
123
|
magicbell = MagicBell::Client.new
|
87
124
|
magicbell.create_notification(
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
125
|
+
title: 'Rob assigned to a task to you',
|
126
|
+
content: 'Hey Joe, can give this customer a demo of our app?',
|
127
|
+
action_url: 'https://example.com/task_path',
|
128
|
+
custom_attributes: {
|
129
|
+
recipient: {
|
130
|
+
first_name: 'Joe',
|
131
|
+
last_name: 'Smith'
|
132
|
+
}
|
133
|
+
},
|
134
|
+
overrides: {
|
135
|
+
channels: {
|
136
|
+
web_push: {
|
137
|
+
title: 'New task assigned'
|
138
|
+
}
|
139
|
+
}
|
140
|
+
},
|
141
|
+
recipients: [{
|
142
|
+
email: 'joe@example.com'
|
143
|
+
}],
|
96
144
|
)
|
97
145
|
```
|
98
146
|
|
99
147
|
### Fetch a user's notifications
|
100
148
|
|
101
|
-
|
149
|
+
To fetch a user's notifications you can do this:
|
102
150
|
|
103
151
|
```ruby
|
152
|
+
require 'magicbell'
|
153
|
+
|
104
154
|
magicbell = MagicBell::Client.new
|
105
|
-
|
106
|
-
|
107
|
-
|
155
|
+
|
156
|
+
user = magicbell.user_with_email('joe@example.com')
|
157
|
+
user.notifications.each { |notification| puts notification.attribute('title') }
|
108
158
|
```
|
109
159
|
|
110
|
-
|
160
|
+
If you identify a user by an ID, you can use the
|
161
|
+
`magicbell.user_with_external_id` method instead.
|
162
|
+
|
163
|
+
Please note that the example above fetches the user's 15 most recent
|
164
|
+
notifications (the default number per page). If you'd like to fetch subsequent
|
165
|
+
pages, use the `each_page` method instead:
|
111
166
|
|
112
167
|
```ruby
|
168
|
+
require 'magicbell'
|
169
|
+
|
113
170
|
magicbell = MagicBell::Client.new
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
page.each do |
|
118
|
-
puts
|
171
|
+
|
172
|
+
user = magicbell.user_with_email('joe@example.com')
|
173
|
+
user.notifications.each_page do |page|
|
174
|
+
page.each do |notification|
|
175
|
+
puts notification.attribute('title')
|
119
176
|
end
|
120
177
|
end
|
121
178
|
```
|
122
179
|
|
123
|
-
### Mark a user notification as read/unread
|
180
|
+
### Mark a user's notification as read/unread
|
124
181
|
|
125
182
|
```ruby
|
183
|
+
require 'magicbell'
|
184
|
+
|
126
185
|
magicbell = MagicBell::Client.new
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
186
|
+
|
187
|
+
user = magicbell.user_with_email('joe@example.com')
|
188
|
+
|
189
|
+
notification = user.notifications.first
|
190
|
+
notification.mark_as_read
|
191
|
+
notification.mark_as_unread
|
131
192
|
```
|
132
193
|
|
133
|
-
### Mark all notifications of a user as read
|
194
|
+
### Mark all notifications of a user as read
|
134
195
|
|
135
196
|
```ruby
|
197
|
+
require 'magicbell'
|
198
|
+
|
136
199
|
magicbell = MagicBell::Client.new
|
137
|
-
|
200
|
+
|
201
|
+
user = magicbell.user_with_email('joe@example.com')
|
138
202
|
user.mark_all_notifications_as_read
|
203
|
+
```
|
204
|
+
|
205
|
+
### Mark all notifications of a user as seen
|
206
|
+
|
207
|
+
```ruby
|
208
|
+
require 'magicbell'
|
209
|
+
|
210
|
+
magicbell = MagicBell::Client.new
|
211
|
+
|
212
|
+
user = magicbell.user_with_email('joe@example.com')
|
139
213
|
user.mark_all_notifications_as_seen
|
140
214
|
```
|
141
215
|
|
142
216
|
### Error handling
|
143
217
|
|
144
|
-
|
218
|
+
This gem raises a `MagicBell::Client::HTTPError` if the MagicBell API returns a
|
219
|
+
non-2xx response.
|
145
220
|
|
146
221
|
```ruby
|
222
|
+
require 'magicbell'
|
223
|
+
|
147
224
|
begin
|
148
225
|
magicbell = MagicBell::Client.new
|
149
226
|
magicbell.create_notification(
|
150
|
-
|
227
|
+
title: 'Rob assigned to a task to you'
|
151
228
|
)
|
152
229
|
rescue MagicBell::Client::HTTPError => e
|
153
|
-
# Report the error to your error tracker
|
230
|
+
# Report the error to your error tracker, for example
|
154
231
|
error_context = {
|
155
232
|
response_status: e.response_status,
|
156
233
|
response_headers: e.response_headers,
|
157
234
|
response_body: e.response_body
|
158
235
|
}
|
159
|
-
ErrorReporter.report(e, context: error_context)
|
160
|
-
end
|
161
|
-
```
|
162
|
-
|
163
|
-
## Rails integration
|
164
|
-
|
165
|
-
If you've existing ActionMailer email notifications in your Rails app and prefer to not spend time migrating to MagicBell's API, you can blind copy your ActionMailer email notifications to MagicBell. MagicBell will create in-app notifications from email notifications blind copied to it.
|
166
|
-
|
167
|
-
Call the `ring_the_magicbell` method in your action mailers like in the example below
|
168
|
-
|
169
|
-
```ruby
|
170
|
-
class NotificationMailer < ActionMailer::Base
|
171
|
-
# The ring_the_magicbell method will bcc your email notifications to your MagicBell project's BCC email address
|
172
|
-
#
|
173
|
-
# Upon receiving a blind copied email notification, magicbell.io will automatically create an in-app notification for the user
|
174
|
-
ring_the_magicbell
|
175
|
-
|
176
|
-
# This is an email notification in your app
|
177
|
-
def new_comment
|
178
|
-
# ...
|
179
|
-
end
|
180
|
-
|
181
|
-
# This is another email notification in your app
|
182
|
-
def mentioned
|
183
|
-
# ...
|
184
|
-
end
|
185
|
-
end
|
186
|
-
```
|
187
|
-
|
188
|
-
The gem will automatically pick your MagicBell project's BCC email from the `MAGICBELL_BCC_EMAIL` environment variable. Alternatively, provide your MagicBell project's BCC email address in an initializer
|
189
|
-
|
190
|
-
```
|
191
|
-
vim config/initializers/magicbell.rb
|
192
|
-
```
|
193
236
|
|
194
|
-
|
195
|
-
# config/initializers/magicbell.rb
|
196
|
-
|
197
|
-
MagicBell.configure do |config|
|
198
|
-
config.api_key = "your_magicbell_api_key"
|
199
|
-
config.api_secret = "your_magicbell_api_secret"
|
200
|
-
config.bcc_email = "your_magicbell_bcc_email@ring.magicbell.io"
|
237
|
+
ErrorReporter.report(e, context: error_context)
|
201
238
|
end
|
202
239
|
```
|
203
240
|
|
204
|
-
|
205
|
-
|
206
|
-
### Customize Action URL
|
241
|
+
### Calculate the HMAC secret for a user
|
207
242
|
|
208
|
-
|
209
|
-
|
210
|
-
|
243
|
+
You can use the `MagicBell.hmac` method. Note that in this case, the API secret,
|
244
|
+
which is used to generate the HMAC, will be fetched from the global
|
245
|
+
configuration.
|
211
246
|
|
212
247
|
```ruby
|
213
|
-
|
214
|
-
ring_the_magicbell
|
248
|
+
require 'magicbell'
|
215
249
|
|
216
|
-
|
217
|
-
# ...
|
218
|
-
magicbell_notification_action_url("https://myapp.com/comments/#{comment.id}")
|
219
|
-
# ...
|
220
|
-
end
|
221
|
-
end
|
250
|
+
hmac = MagicBell.hmac('joe@example.com')
|
222
251
|
```
|
223
252
|
|
224
|
-
|
225
|
-
|
226
|
-
The Notification inbox will use the subject of the email notification as a notification's title. If this behaviour isn't sutiable for your app, provide a title in your mailers
|
253
|
+
You can also use the API secret of a specific client instance to calculate the
|
254
|
+
HMAC:
|
227
255
|
|
228
256
|
```ruby
|
229
|
-
|
230
|
-
ring_the_magicbell
|
257
|
+
require 'magicbell'
|
231
258
|
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
end
|
237
|
-
end
|
238
|
-
```
|
239
|
-
|
240
|
-
## HMAC Authentication
|
241
|
-
|
242
|
-
### Calculate HMAC
|
259
|
+
magicbell = MagicBell::Client.new(
|
260
|
+
api_key: 'MAGICBELL_API_KEY',
|
261
|
+
api_secret: 'MAGICBELL_API_SECRET'
|
262
|
+
)
|
243
263
|
|
244
|
-
|
245
|
-
user_email = "joe@example.com"
|
246
|
-
hmac = MagicBell.hmac(user_email)
|
264
|
+
hmac = magicbell.hmac('joe@example.com')
|
247
265
|
```
|
248
266
|
|
249
|
-
|
267
|
+
Please refer to our docs to know [how to turn on HMAC authentication](https://magicbell.com/docs/turn-on-hmac-authentication)
|
268
|
+
for your MagicBell project.
|
250
269
|
|
251
270
|
## API docs
|
252
271
|
|
253
|
-
Please visit our website
|
272
|
+
Please visit [our website](https://magicbell.com) and
|
273
|
+
[our docs](https://magicbell.com/docs) for more information.
|
254
274
|
|
255
275
|
## Contact Us
|
256
276
|
|
257
|
-
Have a query or hit upon a problem?
|
258
|
-
|
259
|
-
```
|
260
|
-
|
261
|
-
```
|
277
|
+
Have a query or hit upon a problem? Feel free to contact us at
|
278
|
+
[hello@magicbell.io](mailto:hello@magicbell.io).
|
@@ -2,16 +2,6 @@ require "json"
|
|
2
2
|
|
3
3
|
module MagicBell
|
4
4
|
module ActionMailerExtension
|
5
|
-
def self.included(mailer_class)
|
6
|
-
mailer_class.send :extend, ClassMethods
|
7
|
-
end
|
8
|
-
|
9
|
-
module ClassMethods
|
10
|
-
def ring_the_magicbell
|
11
|
-
default bcc: MagicBell.bcc_email
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
5
|
def magicbell_notification_action_url(action_url)
|
16
6
|
headers["X-MagicBell-Notification-ActionUrl"] = action_url
|
17
7
|
end
|
@@ -44,12 +44,16 @@ module MagicBell
|
|
44
44
|
e.errors = []
|
45
45
|
unless e.response_body.nil? || e.response_body.empty?
|
46
46
|
body = JSON.parse(response.body)
|
47
|
-
e.errors = body["errors"]
|
47
|
+
e.errors = body["errors"].is_a?(Array) ? body["errors"] : []
|
48
48
|
e.errors.each do |error, index|
|
49
|
-
|
50
|
-
|
49
|
+
suggestion = error["suggestion"]
|
50
|
+
help_link = error["help_link"]
|
51
|
+
|
52
|
+
puts "#{suggestion.red}" if suggestion
|
53
|
+
puts "#{help_link.blue.on_white}" if help_link
|
51
54
|
end
|
52
55
|
end
|
56
|
+
|
53
57
|
raise e
|
54
58
|
end
|
55
59
|
end
|
@@ -2,11 +2,13 @@ module MagicBell
|
|
2
2
|
class User < ApiResource
|
3
3
|
include ApiOperations
|
4
4
|
|
5
|
-
attr_reader :email
|
5
|
+
attr_reader :email, :external_id
|
6
6
|
|
7
7
|
def initialize(client, attributes)
|
8
8
|
@client = client
|
9
9
|
@email = attributes["email"]
|
10
|
+
@external_id = attributes["external_id"]
|
11
|
+
|
10
12
|
super(client, attributes)
|
11
13
|
end
|
12
14
|
|
@@ -38,13 +40,19 @@ module MagicBell
|
|
38
40
|
def path
|
39
41
|
if id
|
40
42
|
self.class.path + "/#{id}"
|
43
|
+
elsif external_id
|
44
|
+
self.class.path + "/external_id:#{external_id}"
|
41
45
|
elsif email
|
42
46
|
self.class.path + "/email:#{email}"
|
43
47
|
end
|
44
48
|
end
|
45
49
|
|
46
50
|
def authentication_headers
|
47
|
-
|
51
|
+
if external_id
|
52
|
+
MagicBell.authentication_headers.merge("X-MAGICBELL-USER-EXTERNAL-ID" => external_id)
|
53
|
+
elsif email
|
54
|
+
MagicBell.authentication_headers.merge("X-MAGICBELL-USER-EMAIL" => email)
|
55
|
+
end
|
48
56
|
end
|
49
57
|
end
|
50
58
|
end
|
data/lib/magicbell/client.rb
CHANGED
@@ -9,21 +9,39 @@ module MagicBell
|
|
9
9
|
|
10
10
|
include ApiOperations
|
11
11
|
|
12
|
+
def initialize(api_key: nil, api_secret: nil)
|
13
|
+
@api_key = api_key
|
14
|
+
@api_secret = api_secret
|
15
|
+
end
|
16
|
+
|
12
17
|
def create_notification(notification_attributes)
|
13
18
|
MagicBell::Notification.create(self, notification_attributes)
|
14
19
|
end
|
15
20
|
|
16
|
-
# def user(user_id)
|
17
|
-
# MagicBell::User.find(user_id)
|
18
|
-
# end
|
19
|
-
|
20
21
|
def user_with_email(email)
|
21
22
|
client = self
|
22
23
|
MagicBell::User.new(client, "email" => email)
|
23
24
|
end
|
24
25
|
|
26
|
+
def user_with_external_id(external_id)
|
27
|
+
client = self
|
28
|
+
MagicBell::User.new(client, "external_id" => external_id)
|
29
|
+
end
|
30
|
+
|
25
31
|
def authentication_headers
|
26
|
-
MagicBell.authentication_headers
|
32
|
+
MagicBell.authentication_headers(client_api_key: @api_key, client_api_secret: @api_secret)
|
33
|
+
end
|
34
|
+
|
35
|
+
def hmac(message)
|
36
|
+
secret = @api_secret || MagicBell.api_secret
|
37
|
+
|
38
|
+
Base64.encode64(OpenSSL::HMAC::digest(sha256_digest, secret, message)).strip
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def sha256_digest
|
44
|
+
OpenSSL::Digest::Digest.new('sha256')
|
27
45
|
end
|
28
46
|
end
|
29
47
|
end
|
data/lib/magicbell/config.rb
CHANGED
@@ -2,7 +2,6 @@ module MagicBell
|
|
2
2
|
class Config
|
3
3
|
attr_writer :api_key
|
4
4
|
attr_writer :api_secret
|
5
|
-
attr_writer :bcc_email
|
6
5
|
attr_writer :api_host
|
7
6
|
|
8
7
|
def initialize
|
@@ -17,10 +16,6 @@ module MagicBell
|
|
17
16
|
@api_secret || ENV["MAGICBELL_API_SECRET"]
|
18
17
|
end
|
19
18
|
|
20
|
-
def bcc_email
|
21
|
-
@bcc_email || ENV["MAGICBELL_BCC_EMAIL"]
|
22
|
-
end
|
23
|
-
|
24
19
|
def api_host
|
25
20
|
@api_host || ENV["MAGICBELL_API_HOST"] || "https://api.magicbell.io"
|
26
21
|
end
|
data/lib/magicbell/version.rb
CHANGED
data/lib/magicbell.rb
CHANGED
@@ -32,7 +32,6 @@ module MagicBell
|
|
32
32
|
|
33
33
|
def_delegators :config, :api_key,
|
34
34
|
:api_secret,
|
35
|
-
:bcc_email,
|
36
35
|
:api_host
|
37
36
|
|
38
37
|
def configure
|
@@ -47,25 +46,16 @@ module MagicBell
|
|
47
46
|
@config = Config.new
|
48
47
|
end
|
49
48
|
|
50
|
-
def authentication_headers
|
49
|
+
def authentication_headers(client_api_key: nil, client_api_secret: nil)
|
51
50
|
{
|
52
|
-
"X-MAGICBELL-API-KEY" => api_key,
|
53
|
-
"X-MAGICBELL-API-SECRET" => api_secret
|
51
|
+
"X-MAGICBELL-API-KEY" => client_api_key || api_key,
|
52
|
+
"X-MAGICBELL-API-SECRET" => client_api_secret || api_secret
|
54
53
|
}
|
55
54
|
end
|
56
55
|
|
57
56
|
# Calculate HMAC for user's email
|
58
57
|
def hmac(message)
|
59
|
-
|
60
|
-
secret = api_secret
|
61
|
-
|
62
|
-
Base64.encode64(OpenSSL::HMAC.digest(digest, secret, message)).strip
|
63
|
-
end
|
64
|
-
|
65
|
-
private
|
66
|
-
|
67
|
-
def sha256_digest
|
68
|
-
OpenSSL::Digest::Digest.new('sha256')
|
58
|
+
MagicBell::Client.new(api_key: api_key, api_secret: api_secret).hmac(message)
|
69
59
|
end
|
70
60
|
end
|
71
61
|
end
|
metadata
CHANGED
@@ -1,15 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: magicbell
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hana Mohan
|
8
8
|
- Nisanth Chunduru
|
9
|
-
|
9
|
+
- Rahmane Ousmane
|
10
|
+
- Josue Montano
|
11
|
+
autorequire:
|
10
12
|
bindir: bin
|
11
13
|
cert_chain: []
|
12
|
-
date: 2021-
|
14
|
+
date: 2021-10-27 00:00:00.000000000 Z
|
13
15
|
dependencies:
|
14
16
|
- !ruby/object:Gem::Dependency
|
15
17
|
name: httparty
|
@@ -123,10 +125,12 @@ dependencies:
|
|
123
125
|
- - ">="
|
124
126
|
- !ruby/object:Gem::Version
|
125
127
|
version: '0'
|
126
|
-
description:
|
128
|
+
description: The notification inbox for your product
|
127
129
|
email:
|
128
130
|
- hana@magicbell.io
|
129
131
|
- nisanth@supportbee.com
|
132
|
+
- rahmane@magicbell.io
|
133
|
+
- josue@magicbell.io
|
130
134
|
executables: []
|
131
135
|
extensions: []
|
132
136
|
extra_rdoc_files: []
|
@@ -153,11 +157,13 @@ files:
|
|
153
157
|
- lib/magicbell/railtie.rb
|
154
158
|
- lib/magicbell/singleton_api_resource.rb
|
155
159
|
- lib/magicbell/version.rb
|
156
|
-
homepage: https://magicbell.
|
160
|
+
homepage: https://magicbell.com
|
157
161
|
licenses:
|
158
162
|
- MIT
|
159
163
|
metadata: {}
|
160
|
-
post_install_message:
|
164
|
+
post_install_message: "\n *** Breaking Change:: The 2.0.0 release removes the BCC
|
165
|
+
functionality. ***\n Please update your MagicBell integration to use the API
|
166
|
+
for creating notifications or downgrade to 1.0.4\n "
|
161
167
|
rdoc_options: []
|
162
168
|
require_paths:
|
163
169
|
- lib
|
@@ -172,8 +178,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
172
178
|
- !ruby/object:Gem::Version
|
173
179
|
version: '0'
|
174
180
|
requirements: []
|
175
|
-
rubygems_version: 3.1.
|
176
|
-
signing_key:
|
181
|
+
rubygems_version: 3.1.6
|
182
|
+
signing_key:
|
177
183
|
specification_version: 4
|
178
|
-
summary: Ruby
|
184
|
+
summary: Ruby Library for MagicBell
|
179
185
|
test_files: []
|