novu 0.1.0 → 1.0.0
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/.rubocop.yml +6 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +8 -17
- data/README.md +763 -71
- data/Rakefile +2 -1
- data/lib/novu/api/blueprints.rb +29 -0
- data/lib/novu/api/changes.rb +4 -2
- data/lib/novu/api/integrations.rb +11 -0
- data/lib/novu/api/subscribers.rb +89 -1
- data/lib/novu/api/tenants.rb +82 -0
- data/lib/novu/api/topics.rb +23 -0
- data/lib/novu/client.rb +4 -0
- data/lib/novu/version.rb +1 -1
- metadata +21 -15
data/Rakefile
CHANGED
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Novu
|
4
|
+
class Api
|
5
|
+
# Module Novu::Api::Blueprints provides an API for managing templated for notifications that are sent out in the Novu application.
|
6
|
+
#
|
7
|
+
# This module includes methods for retrieving blueprints by templateID and grouping blueprints by category.
|
8
|
+
#
|
9
|
+
# For more information on the Novu Blueprint API, see https://docs.novu.co/api/get-messages/.
|
10
|
+
module Blueprints
|
11
|
+
# Returns the details of a particular template
|
12
|
+
#
|
13
|
+
# @pathParams
|
14
|
+
# @param `template_id` [String]
|
15
|
+
#
|
16
|
+
# @return [Hash] The list of properties that pertains to the template e.g. _id, name, description, active, draft, preferenceSettings, and many others.
|
17
|
+
# @return [number] status
|
18
|
+
# - Returns 200 if successful
|
19
|
+
def get_blueprint(template_id)
|
20
|
+
get("/blueprints/#{template_id}")
|
21
|
+
end
|
22
|
+
|
23
|
+
# Get V1blueprintsgroup by Category
|
24
|
+
def group_blueprints_by_category
|
25
|
+
get("/blueprints/group-by-category")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/novu/api/changes.rb
CHANGED
@@ -33,11 +33,13 @@ module Novu
|
|
33
33
|
|
34
34
|
# Apply Bulk Change
|
35
35
|
#
|
36
|
+
# @bodyParams
|
37
|
+
# @param changeIds [Array] The list of environment IDs to apply changes to.
|
36
38
|
# @return [Hash] updated change.
|
37
39
|
# @return [number] status
|
38
40
|
# - Returns 201 if the bulk change has been updated correctly.
|
39
|
-
def apply_bulk_changes
|
40
|
-
post("/changes/bulk/apply")
|
41
|
+
def apply_bulk_changes(changeIds)
|
42
|
+
post("/changes/bulk/apply", body: changeIds)
|
41
43
|
end
|
42
44
|
|
43
45
|
# Apply change
|
@@ -100,6 +100,17 @@ module Novu
|
|
100
100
|
def in_app_status
|
101
101
|
get("/integrations/in-app/status")
|
102
102
|
end
|
103
|
+
|
104
|
+
# Set integration as primary
|
105
|
+
#
|
106
|
+
# @pathparams
|
107
|
+
# @param `integration_id` [String]
|
108
|
+
#
|
109
|
+
# @return [number] status
|
110
|
+
# - Returns 200 if successful
|
111
|
+
def set_integration_as_primary(integration_id)
|
112
|
+
post("/integrations/#{integration_id}/set-primary")
|
113
|
+
end
|
103
114
|
end
|
104
115
|
end
|
105
116
|
end
|
data/lib/novu/api/subscribers.rb
CHANGED
@@ -45,7 +45,7 @@ module Novu
|
|
45
45
|
# Retrieves the subscriber with the given ID.
|
46
46
|
#
|
47
47
|
# @pathparams
|
48
|
-
# @param `
|
48
|
+
# @param `subscriber_id` [String] The ID of the subscriber to retrieve.
|
49
49
|
#
|
50
50
|
# @return [Hash] The retrieved subscriber.
|
51
51
|
# @return [number] status
|
@@ -103,6 +103,19 @@ module Novu
|
|
103
103
|
put("/subscribers/#{subscriber_id}/credentials", body: body)
|
104
104
|
end
|
105
105
|
|
106
|
+
# Delete subscriber credentials by providerId
|
107
|
+
# Delete subscriber credentials such as slack and expo tokens.
|
108
|
+
#
|
109
|
+
# @pathParams:
|
110
|
+
# @param `subscriberId` [String] The ID of the subscriber to update credentials.
|
111
|
+
# @param `providerId` [String] The provider identifier for the credentials
|
112
|
+
#
|
113
|
+
# @return [number] status
|
114
|
+
# - Returns 204 if the subscriber credentials has been deleted successfully.
|
115
|
+
def delete_subscriber_credentials(subscriberId, providerId)
|
116
|
+
delete("/subscribers/#{subscriberId}/credentials/#{providerId}")
|
117
|
+
end
|
118
|
+
|
106
119
|
# Used to update the subscriber isOnline flag.
|
107
120
|
#
|
108
121
|
# @pathparams:
|
@@ -207,6 +220,81 @@ module Novu
|
|
207
220
|
# - Returns 201 if successful
|
208
221
|
def mark_message_action_seen(subscriber_id, message_id, type)
|
209
222
|
post("/subscribers/#{subscriber_id}/messages/#{message_id}/actions/#{type}")
|
223
|
+
end
|
224
|
+
|
225
|
+
# Using this endpoint you can create multiple subscribers at once, to avoid multiple calls to the API.
|
226
|
+
# The bulk API is limited to 500 subscribers per request.
|
227
|
+
#
|
228
|
+
# @bodyparams:
|
229
|
+
# @param `subscribers` [Array[subscriber]]
|
230
|
+
# @subscriber : subscriber structure
|
231
|
+
# @param `firstName` [Stringoptional)] The first name of the subscriber.
|
232
|
+
# @param `lastName` [Stringoptional)] The last name of the subscriber.
|
233
|
+
# @param `email` [Stringoptional)] The email of the subscriber.
|
234
|
+
# @param `data` [Hash(optional)] The data object is used to pass additional custom information that could be used to identify the subscriber.
|
235
|
+
# @param `phone` [Hash(optional)] This phone of the subscriber.
|
236
|
+
# @param `locale` [String(optional)] The location of the subscriber.
|
237
|
+
# @param `subscriberId` [String] A unique identifier for the subscriber, usually correlates to the id the user in your systems.
|
238
|
+
# @param `avatar` [String(optional)] An http url to the profile image of your subscriber
|
239
|
+
#
|
240
|
+
# @return data [Hash]
|
241
|
+
# - updated [Array] - If the subscriber was updated
|
242
|
+
# - created [Array] - Array of objects for the subsribers ID created
|
243
|
+
# - failed [Array] - In case of an error, this field will contain the error message
|
244
|
+
#
|
245
|
+
# @return [number] status - The status code. Returns 201 if the subscribers were created successfully.
|
246
|
+
def bulk_create_subscribers(body)
|
247
|
+
post("/subscribers/bulk", body: body.to_json, headers: {'Content-Type': 'application/json'})
|
248
|
+
end
|
249
|
+
# Marks all the subscriber messages as read, unread, seen or unseen.
|
250
|
+
#
|
251
|
+
# @pathparams
|
252
|
+
# @param `subscriber_id` [String]
|
253
|
+
#
|
254
|
+
# @bodyParams:
|
255
|
+
# @param `markAs` [String] The type of action to perform either read, unread, seen or unseen.
|
256
|
+
# @param `feedIdentifier` [String|Array(Optional)] The feed id (or array) to mark messages of a particular feed.
|
257
|
+
#
|
258
|
+
# @return [number] status
|
259
|
+
# - Returns 201 if successful
|
260
|
+
def mark_all_subscriber_messages(subscriber_id, body)
|
261
|
+
post("/subscribers/#{subscriber_id}/messages/mark-all", body: body)
|
262
|
+
end
|
263
|
+
|
264
|
+
# Handle providers OAUTH redirect
|
265
|
+
#
|
266
|
+
# @pathparams:
|
267
|
+
# @param `subscriberId` [String]
|
268
|
+
# @param `providerId` [String]
|
269
|
+
#
|
270
|
+
# @queryparams:
|
271
|
+
# @param `code` [String]
|
272
|
+
# @param `hmacHash` [String]
|
273
|
+
# @param `environmentId` [String]
|
274
|
+
# @param `integrationIdentifier` [String]
|
275
|
+
#
|
276
|
+
# @return [Hash] The list of changes that match the criteria of the query params are successfully returned.
|
277
|
+
# @return [number] status
|
278
|
+
# - Returns 200 if successful
|
279
|
+
def provider_oauth_redirect(subscriberId, providerId, query = {})
|
280
|
+
get("/subscribers/#{subscriberId}/credentials/#{providerId}/oauth/callback", query: query)
|
281
|
+
end
|
282
|
+
|
283
|
+
# Handle chat OAUTH
|
284
|
+
#
|
285
|
+
# @pathparams:
|
286
|
+
# @param `subscriberId` [String]
|
287
|
+
# @param `providerId` [String]
|
288
|
+
#
|
289
|
+
# @queryparams:
|
290
|
+
# @param `hmacHash` [String]
|
291
|
+
# @param `environmentId` [String]
|
292
|
+
# @param `integrationIdentifier` [String]
|
293
|
+
#
|
294
|
+
# @return [number] status
|
295
|
+
# - Returns 200 if successful
|
296
|
+
def chat_oauth(subscriberId, providerId, query = {})
|
297
|
+
get("/subscribers/#{subscriberId}/credentials/#{providerId}/oauth", query: query)
|
210
298
|
end
|
211
299
|
end
|
212
300
|
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Novu
|
4
|
+
class Api
|
5
|
+
# Module Novu::Api::Tenants provides an API for managing tenants in the Novu application.
|
6
|
+
#
|
7
|
+
# This module includes methods for creating, retrieving, updating and deleting tenant.
|
8
|
+
#
|
9
|
+
# For more information on the tenants feature (https://docs.novu.co/tenants/introduction),
|
10
|
+
# for API documentation see https://docs.novu.co/api-reference/tenants/get-tenants.
|
11
|
+
module Tenants
|
12
|
+
# Create a tenant
|
13
|
+
#
|
14
|
+
# @bodyparams:
|
15
|
+
# @param `identifier` [String] - A unique value, and can be used later when pointing to this tenant during trigger calls.
|
16
|
+
# @param `name` [String] - A human-readable name of the tenant.
|
17
|
+
# @param `data` [Hash] - A custom data object that can store information about the tenant.
|
18
|
+
#
|
19
|
+
# @return [Hash] data - The list of information with respect to the created tenant are successfully returned.
|
20
|
+
# @return [number] status - The status code. Returns 200 if the tenant has been successfully created.
|
21
|
+
def create_tenant(body)
|
22
|
+
post("/tenants", body: body)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Returns a list of tenant that can be paginated using the `page` query parameter and
|
26
|
+
# set the number of tenants to be with the `limit` query parameter
|
27
|
+
#
|
28
|
+
# @queryparams:
|
29
|
+
# @param `page` [Integer(optional)] - Number of page for the pagination.
|
30
|
+
# @param `limit` [Integer(optional)] - Size of page for the pagination.
|
31
|
+
#
|
32
|
+
# @return [Hash] data - The list of tenants that match the criteria of the query params are successfully returned.
|
33
|
+
# @return [Boolean] hasMore - To specify if the list have more items to fetch
|
34
|
+
# @return [number] page - The current page of the paginated response
|
35
|
+
# @return [number] pageSize - The number of size of each page
|
36
|
+
# @return [number] status
|
37
|
+
# - Returns 200 if successful
|
38
|
+
def tenants(query = {})
|
39
|
+
get("/tenants", query: query)
|
40
|
+
end
|
41
|
+
|
42
|
+
# Get a tenant by the tenant identifier
|
43
|
+
#
|
44
|
+
# @pathparams
|
45
|
+
# @param `identifier` [String]
|
46
|
+
#
|
47
|
+
# @return [Hash] data -The retrieved topic.
|
48
|
+
# @return [number] status
|
49
|
+
# - Returns 200 if successful
|
50
|
+
def tenant(identifier)
|
51
|
+
get("/tenants/#{identifier}")
|
52
|
+
end
|
53
|
+
|
54
|
+
# Update a tenant
|
55
|
+
#
|
56
|
+
# @pathparams
|
57
|
+
# @param `identifier` [String]
|
58
|
+
#
|
59
|
+
# @bodyparams:
|
60
|
+
# @param `identifier` [String] - A unique value, and can be used later when pointing to this tenant during trigger calls.
|
61
|
+
# @param `name` [String] - A human-readable name of the tenant.
|
62
|
+
# @param `data` [Hash] - A custom data object that can store information about the tenant. This data can be later accessed inside workflows.
|
63
|
+
#
|
64
|
+
# @return [Hash] data - The list of information with respect to the created tenant are successfully returned.
|
65
|
+
# @return [number] status - The status code. Returns 200 if the tenant has been successfully created.
|
66
|
+
def update_tenant(identifier, body)
|
67
|
+
patch("/tenants/#{identifier}", body: body)
|
68
|
+
end
|
69
|
+
|
70
|
+
# Using a previously create identifier during the tenant ceation, will cancel any active or pending workflows.
|
71
|
+
# This is useful to cancel active digests, delays etc...
|
72
|
+
#
|
73
|
+
# @pathparams:
|
74
|
+
# @param `identifier` [String] - identifier of the tenant
|
75
|
+
#
|
76
|
+
# @return [number] status - The status code. Returns 200 if the event has been successfully cancelled.
|
77
|
+
def delete_tenant(identifier)
|
78
|
+
delete("/tenants/#{identifier}")
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
data/lib/novu/api/topics.rb
CHANGED
@@ -61,6 +61,18 @@ module Novu
|
|
61
61
|
post("/topics/#{topic_key}/subscribers/removal", body: body)
|
62
62
|
end
|
63
63
|
|
64
|
+
# Check topic subsriber
|
65
|
+
# Check if a subscriber belongs to a certain topic
|
66
|
+
#
|
67
|
+
# @pathparams
|
68
|
+
# @param `topic_key` [String]
|
69
|
+
# @param `externalSubscriberId` [String] The id of the subscriber created on `/subscribers` endpoint
|
70
|
+
#
|
71
|
+
# @return [number] status - The status code. Returns 200 if subscriber was added to the topic.
|
72
|
+
def subscriber_topic(topic_key, externalSubscriberId)
|
73
|
+
get("/topics/#{topic_key}/subscribers/#{externalSubscriberId}")
|
74
|
+
end
|
75
|
+
|
64
76
|
# Get a topic by its topic key
|
65
77
|
#
|
66
78
|
# @pathparams
|
@@ -87,6 +99,17 @@ module Novu
|
|
87
99
|
def rename_topic(topic_key, body)
|
88
100
|
patch("/topics/#{topic_key}", body: body)
|
89
101
|
end
|
102
|
+
|
103
|
+
# Delete topic
|
104
|
+
# Delete a topic by its topic key if it has no subscribers
|
105
|
+
#
|
106
|
+
# @pathparams
|
107
|
+
# @param `topic_key` [String]
|
108
|
+
#
|
109
|
+
# @return [number] status - The status code. Returns 204 if successfully deleted topic.
|
110
|
+
def delete_topic(topic_key)
|
111
|
+
delete("/topics/#{topic_key}")
|
112
|
+
end
|
90
113
|
end
|
91
114
|
end
|
92
115
|
end
|
data/lib/novu/client.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "novu/api/blueprints"
|
3
4
|
require "novu/api/changes"
|
4
5
|
require "novu/api/connection"
|
5
6
|
require "novu/api/environments"
|
@@ -14,11 +15,13 @@ require "novu/api/notification_groups"
|
|
14
15
|
require "novu/api/notification_templates"
|
15
16
|
require "novu/api/notification"
|
16
17
|
require "novu/api/subscribers"
|
18
|
+
require "novu/api/tenants"
|
17
19
|
require "novu/api/topics"
|
18
20
|
|
19
21
|
module Novu
|
20
22
|
class Client
|
21
23
|
include HTTParty
|
24
|
+
include Novu::Api::Blueprints
|
22
25
|
include Novu::Api::Changes
|
23
26
|
include Novu::Api::Connection
|
24
27
|
include Novu::Api::Environments
|
@@ -33,6 +36,7 @@ module Novu
|
|
33
36
|
include Novu::Api::NotificationTemplates
|
34
37
|
include Novu::Api::Notification
|
35
38
|
include Novu::Api::Subscribers
|
39
|
+
include Novu::Api::Tenants
|
36
40
|
include Novu::Api::Topics
|
37
41
|
|
38
42
|
base_uri "https://api.novu.co/v1"
|
data/lib/novu/version.rb
CHANGED
metadata
CHANGED
@@ -1,46 +1,50 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: novu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aman Saini
|
8
|
+
- Prosper Otemuyiwa
|
9
|
+
- Kolawole Ezekiel
|
8
10
|
autorequire:
|
9
11
|
bindir: exe
|
10
12
|
cert_chain: []
|
11
|
-
date: 2023-
|
13
|
+
date: 2023-10-12 00:00:00.000000000 Z
|
12
14
|
dependencies:
|
13
15
|
- !ruby/object:Gem::Dependency
|
14
16
|
requirement: !ruby/object:Gem::Requirement
|
15
17
|
requirements:
|
16
|
-
- - "
|
18
|
+
- - "~>"
|
17
19
|
- !ruby/object:Gem::Version
|
18
|
-
version: '0'
|
20
|
+
version: '0.21'
|
19
21
|
name: httparty
|
20
22
|
prerelease: false
|
21
23
|
type: :runtime
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
23
25
|
requirements:
|
24
|
-
- - "
|
26
|
+
- - "~>"
|
25
27
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
28
|
+
version: '0.21'
|
27
29
|
- !ruby/object:Gem::Dependency
|
28
30
|
requirement: !ruby/object:Gem::Requirement
|
29
31
|
requirements:
|
30
|
-
- -
|
32
|
+
- - '='
|
31
33
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
34
|
+
version: 6.1.7.2
|
33
35
|
name: activesupport
|
34
36
|
prerelease: false
|
35
37
|
type: :runtime
|
36
38
|
version_requirements: !ruby/object:Gem::Requirement
|
37
39
|
requirements:
|
38
|
-
- -
|
40
|
+
- - '='
|
39
41
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
42
|
+
version: 6.1.7.2
|
41
43
|
description: Client library for Novu API.
|
42
44
|
email:
|
45
|
+
- prosper@novu.co
|
43
46
|
- amansaini0003@gmail.com
|
47
|
+
- doneazy911@gmail.com
|
44
48
|
executables: []
|
45
49
|
extensions: []
|
46
50
|
extra_rdoc_files: []
|
@@ -55,6 +59,7 @@ files:
|
|
55
59
|
- README.md
|
56
60
|
- Rakefile
|
57
61
|
- lib/novu.rb
|
62
|
+
- lib/novu/api/blueprints.rb
|
58
63
|
- lib/novu/api/changes.rb
|
59
64
|
- lib/novu/api/connection.rb
|
60
65
|
- lib/novu/api/environments.rb
|
@@ -69,17 +74,18 @@ files:
|
|
69
74
|
- lib/novu/api/notification_groups.rb
|
70
75
|
- lib/novu/api/notification_templates.rb
|
71
76
|
- lib/novu/api/subscribers.rb
|
77
|
+
- lib/novu/api/tenants.rb
|
72
78
|
- lib/novu/api/topics.rb
|
73
79
|
- lib/novu/client.rb
|
74
80
|
- lib/novu/version.rb
|
75
81
|
- sig/novu.rbs
|
76
|
-
homepage: https://github.com/
|
82
|
+
homepage: https://github.com/novuhq/novu-ruby
|
77
83
|
licenses:
|
78
84
|
- MIT
|
79
85
|
metadata:
|
80
|
-
homepage_uri: https://github.com/
|
81
|
-
source_code_uri: https://github.com/
|
82
|
-
changelog_uri: https://github.com/
|
86
|
+
homepage_uri: https://github.com/novuhq/novu-ruby
|
87
|
+
source_code_uri: https://github.com/novuhq/novu-ruby
|
88
|
+
changelog_uri: https://github.com/novuhq/novu-ruby/blob/main/CHANGELOG.md
|
83
89
|
post_install_message:
|
84
90
|
rdoc_options: []
|
85
91
|
require_paths:
|
@@ -95,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
101
|
- !ruby/object:Gem::Version
|
96
102
|
version: '0'
|
97
103
|
requirements: []
|
98
|
-
rubygems_version: 3.
|
104
|
+
rubygems_version: 3.3.26
|
99
105
|
signing_key:
|
100
106
|
specification_version: 4
|
101
107
|
summary: Client library for Novu API.
|