Module: Novu::Api::Tenants

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

Overview

Module Novu::Api::Tenants provides an API for managing tenants in the Novu application.

This module includes methods for creating, retrieving, updating and deleting tenant.

For more information on the tenants feature (docs.novu.co/tenants/introduction), for API documentation see docs.novu.co/api-reference/tenants/get-tenants.

Instance Method Summary collapse

Instance Method Details

#create_tenant(body) ⇒ Hash, number

Create a tenant

@bodyparams:

Parameters:

  • `identifier` (String)
    • A unique value, and can be used later when pointing to this tenant during trigger calls.

  • `name` (String)
    • A human-readable name of the tenant.

  • `data` (Hash)
    • A custom data object that can store information about the tenant.

Returns:

  • (Hash)

    data - The list of information with respect to the created tenant are successfully returned.

  • (number)

    status - The status code. Returns 200 if the tenant has been successfully created.



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

def create_tenant(body)
  post("/tenants", body: body)
end

#delete_tenant(identifier) ⇒ number

Using a previously create identifier during the tenant ceation, will cancel any active or pending workflows. This is useful to cancel active digests, delays etc…

@pathparams:

Parameters:

  • `identifier` (String)
    • identifier of the tenant

Returns:

  • (number)

    status - The status code. Returns 200 if the event has been successfully cancelled.



77
78
79
# File 'lib/novu/api/tenants.rb', line 77

def delete_tenant(identifier)
  delete("/tenants/#{identifier}")
end

#tenant(identifier) ⇒ Hash, number

Get a tenant by the tenant identifier

Parameters:

  • `identifier` (String)

Returns:

  • (Hash)

    data -The retrieved topic.

  • (number)

    status

    • Returns 200 if successful



50
51
52
# File 'lib/novu/api/tenants.rb', line 50

def tenant(identifier)
  get("/tenants/#{identifier}")
end

#tenants(query = {}) ⇒ Hash, ...

Returns a list of tenant that can be paginated using the ‘page` query parameter and

set the number of tenants to be with the `limit` query parameter

@queryparams:

Parameters:

  • `page` (Integer(optional))
    • Number of page for the pagination.

  • `limit` (Integer(optional))
    • Size of page for the pagination.

Returns:

  • (Hash)

    data - The list of tenants that match the criteria of the query params are successfully returned.

  • (Boolean)

    hasMore - To specify if the list have more items to fetch

  • (number)

    page - The current page of the paginated response

  • (number)

    pageSize - The number of size of each page

  • (number)

    status

    • Returns 200 if successful



38
39
40
# File 'lib/novu/api/tenants.rb', line 38

def tenants(query = {})
  get("/tenants", query: query)
end

#update_tenant(identifier, body) ⇒ Hash, number

Update a tenant

@bodyparams:

Parameters:

  • `identifier` (String)
  • `identifier` (String)
    • A unique value, and can be used later when pointing to this tenant during trigger calls.

  • `name` (String)
    • A human-readable name of the tenant.

  • `data` (Hash)
    • A custom data object that can store information about the tenant. This data can be later accessed inside workflows.

Returns:

  • (Hash)

    data - The list of information with respect to the created tenant are successfully returned.

  • (number)

    status - The status code. Returns 200 if the tenant has been successfully created.



66
67
68
# File 'lib/novu/api/tenants.rb', line 66

def update_tenant(identifier, body)
  patch("/tenants/#{identifier}", body: body)
end