This is a Ruby client library for communicating with the Novu API.
You can install the client library via RubyGems:
gem install novu
Or add it to your Gemfile:
gem 'novu'
Then run bundle install
.
To use the library, first initialize the client with your API token:
require 'novu'
client = Novu::Client.new('YOUR_NOVU_API_TOKEN')
You can then call methods on the client to interact with the Novu API:
client.notifications
The client methods map directly to the Novu API endpoints. Here's a list of all the available methods. Check the API docs for list of available methods
.
- Get changes:
changes(query = {})
client.changes({
'page' => 1, # optional
'limit' => 10, # optional
'promoted' => 'hello'
})
- Get changes count:
count_changes()
client.count_changes()
- Apply changes:
apply_bulk_changes()
client.apply_change({
'changeIds' => ['<insert-all-the-change-ids>']
})
- Apply change:
apply_change(change_id)
client.apply_change('7789')
- Get current environment:
current_environment()
client.current_environment()
- Create environment:
create_environment(body)
payload = {
'name' => 'Staging',
'parentId' => '7789' # optional
}
client.create_environment(payload)
- Get environments:
environments()
client.environments()
- Update environment by id:
update_environment(environment_id, body)
client.update_environment('64a713bdexxxxxx', {
'name' => 'Local', # optional
'identifier' => 'local', # optional
'parentId' => '7789', # optional
'dns' => { # optional
'inboundParseDomain' => 'dev.test' # optional
}
})
- Get api keys:
api_keys()
client.api_keys()
- Regenerate api keys:
regenerate_api_keys()
client.regenerate_api_keys()
update_widget_settings(body)
client.update_widget_settings({ 'notificationCenterEncryption' => true})
- Trigger event:
trigger_event(body)
payload = {
'name' => 'Trigger1',
'payload' => { # optional
'first-name' => 'Adam' # optional
},
'to' => {
'subscriberId' => '7789'
},
'transactionId' => '89kjfke9893' #optional
}
client.trigger_event(payload)
- Bulk trigger event:
trigger_bulk_event(body)
payload = {
'events' => [
{
'name' => 'Trigger1',
'payload' => { # optional
'first-name' => 'Adam' # optional
},
'to' => {
'subscriberId' => '7789'
},
'transactionId' => '89kjfke9893' #optional
},
{
'name' => 'Trigger2',
'payload' => { # optional
'last-name' => 'Eve' # optional
},
'to' => {
'subscriberId' => '7789'
},
'transactionId' => 'sw900999as' #optional
}
]
}
client.trigger_bulk_event(payload)
- Broadcast event to all:
broadcast_event(body)
payload = {
'name' => 'Trigger',
'payload' => {
'first-name' => 'Adam',
'last-name' => 'Eve'
},
'transactionId' => 'sw900999as' #optional
}
client.broadcast_event(payload)
- Cancel triggered event:
cancel_triggered_event(transaction_id)
client.cancel_triggered_event('8fxxxee-xxx-4f2b-a0e8-xxxxx')
- Get execution details:
execution_details(query = {})
client.execution_details({
'notificationId' => '8fxxx-xxx-ef9xxxxce66',
'subscriberId' => '7789'
})
- Create feed:
create_feed(body)
client.create_feed({
'name' => 'New feed'
})
- Get feeds:
feeds()
client.feeds()
- Delete feed:
delete_feed(feed_id)
client.delete_feed('xxxx714xxa8cbxxxxx2d932')
- Validate the mx record setup for the inbound parse functionality:
validate_mx_record_setup_for_inbound_parse()
client.validate_mx_record_setup_for_inbound_parse()
- Get integrations:
integrations()
client.integrations()
- Create integration:
create_integration(body)
body = {
'providerId' => '<insert-provider-id>',
'channel' => '<insert-channel>',
'credentials' => {
# insert all the fields
},
'active' => true,
'check' => true
}
client.create_integration(body)
- Get active integrations:
active_integrations()
client.active_integrations()
- Get webhook support status for provider:
webhook_provider_status(provider_id)
client.webhook_provider_status('<insert-provider-id>')
- Update integration:
update_integration(integration_id, body)
body = {
'active' => true,
'check' => true
'credentials' => {
# insert all the fields
},
}
client.update_integration('<insert-provider-id>', body)
- Delete integration:
delete_integration(integration_id)
client.delete_integration('<insert-provider-id>')
- Get channel limit:
channel_limit(channel_type)
client.channel_limit('<insert-channel-type>')
- Get in-app status:
in_app_status()
client.in_app_status()
- Layout creation:
create_layout(body)
payload = {
'name' => 'New layout',
'content' => '{{{body}}}',
'variables' => ['<list-variables-here>'], # optional
'description' => 'This is a description for the new layout', # optional
'isDefault' => true # optional
}
client.create_layout(payload)
- Filter layouts:
layouts(query = {})
client.layouts({
'page' => 1, # optional
'pageSize' => 10, # optional
'sortBy' => 'createdAt', # optional
'orderBy' => 1 # optional
})
- Get layout:
layout(layout_id)
client.layout('<insert-layout-id>')
- Delete layout:
delete_layout(layout_id)
client.delete_layout('<insert-layout-id>')
- Update a layout:
update_layout(layout_id, body)
payload = {
'name' => 'Update layout', # optional
'content' => '{{{body}}}', # optional
'description' => 'This is a description for the new layout', # optional
'isDefault' => true # optional
'variables' => ['<list-variables-here>'], # optional
}
client.update_layout('<insert-layout-id>', payload)
- Set default layout:
make_default_layout(layout_id)
client.make_default_layout('<insert-layout-id>')
- Get messages:
messages(query = {})
payload = {
'channel' => 'slack', # optional
'subscriberId' => '7789', # optional
'transactionId' =>'sw900999as', # optional
'page' => 4, # optional
'limit' => 10, # optional
}
client.messages(payload)
- Delete message:
delete_message(message_id)
client.delete_message('<insert-message-id>')
- Create Notification group:
create_notification_group(body)
client.create_notification_group({
'name' => '<insert-name>'
})
- Get Notification groups:
notification_groups()
client.notification_groups()
- Get notification templates:
notification_templates(query = {})
client.notification_templates({
'page' => 4, # optional
'limit' => 10, # optional
})
- Create notification template:
create_notification_template(body)
body = {
'name' => '<insert-name>',
'notificationGroupId' => 'notificationGroupId',
'tags' => ['tags'], # optional
'description' => 'description', # optional
'steps' => [ # optional
# insert all fields here
],
'active' => true, # optional
'draft' => true, # optional
'critical' => true, # optional
'preferenceSettings' => { # optional
# insert all fields here
},
'blueprintId' => 'blueprintId' # optional
}
client.create_notification_template(body)
- Update notification template:
update_notification_template(template_id, body)
body = {
'name' => '<insert-name>',
'notificationGroupId' => 'notificationGroupId',
'tags' => ['tags'], # optional
'description' => 'description', # optional
'steps' => [ # optional
# insert all fields here
],
'active' => true, # optional
'draft' => true, # optional
'critical' => true, # optional
'preferenceSettings' => { # optional
# insert all fields here
},
'blueprintId' => 'blueprintId' # optional
}
client.update_notification_template('<insert-template-id>', body)
- Delete notification template
delete_notification_template(template_id)
client.delete_notification_template('<insert-template-id>')
- Get a notification template:
notification_template(template_id)
client.notification_template('<insert-template-id>')
- Get a notification template blueprint:
notification_template_blueprint(template_id)
client.notification_template_blueprint('<insert-template-id>')
- Create a new notification template blueprint:
create_notification_template_blueprint(template_id)
client.create_notification_template_blueprint('<insert-template-id>')
- Update notification template status:
update_notification_template_status(template_id, body)
client.update_notification_template_status('<insert-template-id>', { 'active' => true })
- Get notifications:
notifications(query = {})
body = {
'channels' => ['<insert-channels>'],
'templates' => ['<insert-templates>'],
'emails' => ['<insert-emails>'],
'search' => '<insert-search-string>'
'page' => 2 , # optional
'transactionId' =>'sw900999as', # optional
}
client.notifications(body)
- Get notification statistics:
notifications_stats()
client.notifications_stats()
- Get notification graph statistics:
notifications_graph_stats(query = {})
client.notifications_graph_stats({
'days' => 5 # optional
})
- Get notification:
notification(notification_id)
client.notification('<insert-notification-id>')
- Get subscribers:
subscribers(query = {})
client.subscribers({
'page' => 1, # optional
'limit' => 15, # optional
})
- Create subscriber:
create_subscriber(body)
payload = {
'subscriberId' => '7789',
'email' => '<insert-email>', # optional
'firstName' => '<insert-firstName>', # optional
'lastName' => '<insert-lastName>', # optional
'phone' => '<insert-phone>', # optional
'avatar' => '<insert-profile-avatar>' # optional
}
client.create_subscriber(payload)
subscriber(subscriber_id)
client.subscriber('<insert-subscriber-id>')
- Update subscriber:
update_subscriber(subscriber_id, body)
payload = {
'email' => '<insert-email>', # optional
'firstName' => '<insert-firstName>', # optional
'lastName' => '<insert-lastName>', # optional
'phone' => '<insert-phone>', # optional
'avatar' => '<insert-profile-avatar>' # optional
}
client.update_subscriber('<insert-subscriber-id>', payload)
- Delete subscriber:
delete_subscriber(subscriber_id)
client.delete_subscriber('<insert-subscriber-id>')
- Update subscriber credentials:
update_subscriber_credentials(subscriber_id, body)
body = {
'providerId' => '<insert-provider-id>',
'credentials' => {
# Insert all fields here
}
}
client.update_subscriber_credentials('<insert-subscriber-id>', body)
- Update subscriber online status:
update_subscriber_online_status(subscriber_id, body)
client.update_subscriber_online_status('<insert-subscriber-id>', { 'isOnline' => true })
- Get subscriber preferences:
subscriber_preferences(subscriber_id)
client.subscriber_preferences('<insert-subscriber-id>')
- Update subscriber preference:
update_subscriber_preference(subscriber_id, template_id, body)
body = {
'channel' => {
# Insert all fields here
},
'enabled' => true
}
client.update_subscriber_preference('<insert-subscriber-id>', '<insert-template-id>', body)
- Get in-app notification feed for a particular subscriber:
subscriber_notification_feed(subscriber_id, query = {})
client.subscriber_notification_feed('<insert-subscriber-id>', {
'page' => 3, # optional
'limit' => 15, # optional
'read' => true, # optional
'seen' => true, # optional
})
- Get the unseen in-app notifications count for subscribers feed:
subscriber_unseen_notification_count(subscriber_id, query = {})
client.subscriber_unseen_notification_count('<insert-subscriber-id>', {
'limit' => 15, # optional
'seen' => false, # optional
})
- Mark a subscriber feed message as seen:
mark_subscriber_feed_seen(subscriber_id, body)
client.mark_subscriber_feed_seen('<insert-subscriber-id>', {
'messageId' => '<insert-message-id>',
'mark' => {
'seen' => true,
'read' => true
}
})
- Mark message action as seen:
mark_message_action_seen(subscriber_id, message_id, type)
client.mark_message_action_seen('<insert-subscriber-id>', '<insert-message-id>', '<insert-type>')
- Topic creation:
create_topic(body)
client.create_topic({
'key' => 'key',
'name' => 'name'
})
- Filter topics:
topics(query = {})
client.topics({
'name' => 'name', # optional
'page' => 1, # optional
'pageSize' => 10, # optional
})
- Subscribers addition:
add_subscribers(topic_key, body)
client.add_subscribers('<insert-topic-key>', {
'subscribers' => ['<insert-list-of-subscribers>']
})
remove_subscribers(topic_key, body)
client.
- Get topic:
topic(topic_key)
client.topic('<insert-topic-key>')
- Rename a topic:
rename_topic(topic_key, body)
client.rename_topic('<insert-topic-key>', {
'name' => 'new name'
})
For more information about these methods and their parameters, see the API documentation.
Bug reports and pull requests are welcome on GitHub at https://github.com/novuhq/novu-ruby