Module: Novu::Api::NotificationTemplates

Included in:
Client
Defined in:
lib/novu/api/notification_templates.rb

Overview

Module Novu::Api::NotificationTemplates provides an API for managing notification templates in the Novu application.

This module includes methods for creating, retrieving, updating, and deleting notification templates. It also includes methods for creating and retrieving the notification blueprint.

For more information on the Novu API(api.novu.co/api#/Notification%20templates), see docs.novu.co/api/get-notification-templates/.

Instance Method Summary collapse

Instance Method Details

#create_notification_template(body) ⇒ Hash, number

Creates a new notification template.

@bodyparams:

Parameters:

  • `name` (String)
  • `notificationGroupId` (String)
  • `tags` (Array(optional))
  • `description` (String(optional))
  • `steps` (Array)
  • `active` (Boolean(optional))
  • `draft` (Boolean(optional))
  • `critical` (Boolean(optional))
  • `preferenceSettings` (Hash(optional))

Returns:

  • (Hash)

    Notification template entity.

  • (number)

    status - The status code. Returns 201 if the notification template has been successfully created.



40
41
42
# File 'lib/novu/api/notification_templates.rb', line 40

def create_notification_template(body)
  post("/notification-templates", body: body)
end

#create_notification_template_blueprint(template_id) ⇒ Hash, number

Creates a new notification template blueprint.

Returns:

  • (Hash)

    Notification template blueprint entity.

  • (number)

    status - The status code. Returns 201 if the notification template blueprint has been successfully created.



105
106
107
# File 'lib/novu/api/notification_templates.rb', line 105

def create_notification_template_blueprint(template_id)
  post("/notification-templates/#{template_id}/blueprint")
end

#delete_notification_template(template_id) ⇒ number

Execute a soft delete of a notification template given a certain ID.

@pathparams:

Parameters:

  • `template_id` (String)

    The ID of the template to delete.

Returns:

  • (number)

    status

    • Returns 200 if the notification template has been deleted correctly.



73
74
75
# File 'lib/novu/api/notification_templates.rb', line 73

def delete_notification_template(template_id)
  delete("/notification-templates/#{template_id}")
end

#notification_template(template_id) ⇒ Hash, number

Retrieves the notification template with the given ID.

Parameters:

  • `template_id` (String)

    The ID of the template to retrieve.

Returns:

  • (Hash)

    The retrieved template.

  • (number)

    status

    • Returns 200 if the template with the template_id provided exists in the database.



85
86
87
# File 'lib/novu/api/notification_templates.rb', line 85

def notification_template(template_id)
  get("/notification-templates/#{template_id}")
end

#notification_template_blueprint(template_id) ⇒ Hash, number

Retrieves the notification template blueprint with the given ID.

Parameters:

  • `template_id` (String)

    The ID of the template to retrieve.

Returns:

  • (Hash)

    The retrieved template blueprint.

  • (number)

    status

    • Returns 200 if the template blueprint with the template_id provided exists in the database.



97
98
99
# File 'lib/novu/api/notification_templates.rb', line 97

def notification_template_blueprint(template_id)
  get("/notification-templates/#{template_id}/blueprint")
end

#notification_templates(query = {}) ⇒ Hash, number

Returns a list of notification template that can be paginated using the ‘page` query parameter

@queryparams:

Parameters:

  • `page` (Integer(optional))

    Number of page for the pagination.

  • `limit` (Integer(optional))

Returns:

  • (Hash)

    The list of notification templates that match the criteria of the query params are successfully returned.

  • (number)

    status

    • Returns 200 if successful



21
22
23
# File 'lib/novu/api/notification_templates.rb', line 21

def notification_templates(query = {})
  get("/notification-templates", query: query)
end

#update_notification_template(template_id, body) ⇒ Hash, number

Updates new notification template.

@pathparams: @bodyparams:

Parameters:

  • `template_id` (String)

    The ID of the notification template to update.

  • `name` (String)
  • `tags` (Array(optional))
  • `description` (String(optional))
  • `identifier` (String(optional))
  • `steps` (Array(optional))
  • `notificationGroupId` (String)
  • `active` (Boolean(optional))
  • `critical` (Boolean(optional))
  • `preferenceSettings` (Hash(optional))

Returns:

  • (Hash)

    Updated notification template entity.

  • (number)

    status - The status code. Returns 200 if the notification template has been successfully updated.



62
63
64
# File 'lib/novu/api/notification_templates.rb', line 62

def update_notification_template(template_id, body)
  put("/notification-templates/#{template_id}", body: body)
end

#update_notification_template_status(template_id, body) ⇒ Hash, number

Update notification template status

@pathparams:

Parameters:

  • `template_id` (String)

    The ID of the template to update.

  • `active` (Boolean)

Returns:

  • (Hash)

    The updated notification template.

  • (number)

    status

    • Returns 200 if the notification template with the template_id provided has been updated correctly.



120
121
122
# File 'lib/novu/api/notification_templates.rb', line 120

def update_notification_template_status(template_id, body)
  put("/notification-templates/#{template_id}/status", body: body)
end