Skip to content

Latest commit

 

History

History
312 lines (214 loc) · 23.7 KB

README.md

File metadata and controls

312 lines (214 loc) · 23.7 KB

Preferences

(subscribers.preferences)

Overview

Available Operations

list

Get subscriber preferences

Example Usage

import { Novu } from "@novu/api";

const novu = new Novu({
  apiKey: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await novu.subscribers.preferences.list("<value>");
  
  // Handle the result
  console.log(result)
}

run();

Standalone function

The standalone function version of this method:

import { NovuCore } from "@novu/api/core.js";
import { subscribersPreferencesList } from "@novu/api/funcs/subscribersPreferencesList.js";

// Use `NovuCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const novu = new NovuCore({
  apiKey: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const res = await subscribersPreferencesList(novu, "<value>");

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
subscriberId string ✔️ N/A
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.UpdateSubscriberPreferenceResponseDto[]>

Errors

Error Object Status Code Content Type
errors.SDKError 4xx-5xx /

retrieveByLevel

Get subscriber preferences by level

Example Usage

import { Novu } from "@novu/api";

const novu = new Novu({
  apiKey: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await novu.subscribers.preferences.retrieveByLevel("Topic", "<value>");
  
  // Handle the result
  console.log(result)
}

run();

Standalone function

The standalone function version of this method:

import { NovuCore } from "@novu/api/core.js";
import { subscribersPreferencesRetrieveByLevel } from "@novu/api/funcs/subscribersPreferencesRetrieveByLevel.js";

// Use `NovuCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const novu = new NovuCore({
  apiKey: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const res = await subscribersPreferencesRetrieveByLevel(novu, "Topic", "<value>");

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
parameter operations.Parameter ✔️ the preferences level to be retrieved( Subscriber / Topic)
subscriberId string ✔️ N/A
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.GetSubscriberPreferencesResponseDto[]>

Errors

Error Object Status Code Content Type
errors.SDKError 4xx-5xx /

update

Update subscriber preference

Example Usage

import { Novu } from "@novu/api";

const novu = new Novu({
  apiKey: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await novu.subscribers.preferences.update({
    subscriberId: "<value>",
    parameter: "<value>",
    updateSubscriberPreferenceRequestDto: {},
  });
  
  // Handle the result
  console.log(result)
}

run();

Standalone function

The standalone function version of this method:

import { NovuCore } from "@novu/api/core.js";
import { subscribersPreferencesUpdate } from "@novu/api/funcs/subscribersPreferencesUpdate.js";

// Use `NovuCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const novu = new NovuCore({
  apiKey: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const res = await subscribersPreferencesUpdate(novu, {
    subscriberId: "<value>",
    parameter: "<value>",
    updateSubscriberPreferenceRequestDto: {},
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.SubscribersControllerUpdateSubscriberPreferenceRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.UpdateSubscriberPreferenceResponseDto>

Errors

Error Object Status Code Content Type
errors.SDKError 4xx-5xx /

updateGlobal

Update subscriber global preferences

Example Usage

import { Novu } from "@novu/api";

const novu = new Novu({
  apiKey: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await novu.subscribers.preferences.updateGlobal("<value>", {});
  
  // Handle the result
  console.log(result)
}

run();

Standalone function

The standalone function version of this method:

import { NovuCore } from "@novu/api/core.js";
import { subscribersPreferencesUpdateGlobal } from "@novu/api/funcs/subscribersPreferencesUpdateGlobal.js";

// Use `NovuCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const novu = new NovuCore({
  apiKey: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const res = await subscribersPreferencesUpdateGlobal(novu, "<value>", {});

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
subscriberId string ✔️ N/A
updateSubscriberGlobalPreferencesRequestDto components.UpdateSubscriberGlobalPreferencesRequestDto ✔️ N/A
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.UpdateSubscriberPreferenceResponseDto>

Errors

Error Object Status Code Content Type
errors.SDKError 4xx-5xx /