Skip to content

Latest commit

 

History

History
258 lines (195 loc) · 22.8 KB

File metadata and controls

258 lines (195 loc) · 22.8 KB

Subscribers.Messages

Overview

Available Operations

updateAsSeen

Update in-app (inbox) notification's action status by its unique key identifier messageId and type field type. type field can be primary or secondary

Example Usage

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

const novu = new Novu({
  secretKey: "YOUR_SECRET_KEY_HERE",
});

async function run() {
  const result = await novu.subscribers.messages.updateAsSeen({
    messageId: "<id>",
    type: "<value>",
    subscriberId: "<id>",
    markMessageActionAsSeenDto: {
      status: "pending",
    },
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

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

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

async function run() {
  const res = await subscribersMessagesUpdateAsSeen(novu, {
    messageId: "<id>",
    type: "<value>",
    subscriberId: "<id>",
    markMessageActionAsSeenDto: {
      status: "pending",
    },
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("subscribersMessagesUpdateAsSeen failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.SubscribersV1ControllerMarkActionAsSeenRequest ✔️ 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<operations.SubscribersV1ControllerMarkActionAsSeenResponse>

Errors

Error Type Status Code Content Type
errors.ErrorDto 414 application/json
errors.ErrorDto 400, 401, 403, 404, 405, 409, 413, 415 application/json
errors.ValidationErrorDto 422 application/json
errors.ErrorDto 500 application/json
errors.SDKError 4XX, 5XX */*

markAll

Update all subscriber in-app (inbox) notifications state such as read, unread, seen or unseen by subscriberId.

Example Usage

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

const novu = new Novu({
  secretKey: "YOUR_SECRET_KEY_HERE",
});

async function run() {
  const result = await novu.subscribers.messages.markAll({
    markAs: "read",
  }, "<id>");

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

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

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

async function run() {
  const res = await subscribersMessagesMarkAll(novu, {
    markAs: "read",
  }, "<id>");
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("subscribersMessagesMarkAll failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
subscriberId string ✔️ N/A
markAllMessageAsRequestDto components.MarkAllMessageAsRequestDto ✔️ N/A
idempotencyKey string A header for idempotency purposes
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<operations.SubscribersV1ControllerMarkAllUnreadAsReadResponse>

Errors

Error Type Status Code Content Type
errors.ErrorDto 414 application/json
errors.ErrorDto 400, 401, 403, 404, 405, 409, 413, 415 application/json
errors.ValidationErrorDto 422 application/json
errors.ErrorDto 500 application/json
errors.SDKError 4XX, 5XX */*

markAllAs

Update subscriber's multiple in-app (inbox) notifications state such as seen, read, unseen or unread by subscriberId. messageId is of type mongodbId of notifications

Example Usage

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

const novu = new Novu({
  secretKey: "YOUR_SECRET_KEY_HERE",
});

async function run() {
  const result = await novu.subscribers.messages.markAllAs({
    messageId: [],
    markAs: "seen",
  }, "<id>");

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

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

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

async function run() {
  const res = await subscribersMessagesMarkAllAs(novu, {
    messageId: [],
    markAs: "seen",
  }, "<id>");
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("subscribersMessagesMarkAllAs failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
subscriberId string ✔️ N/A
messageMarkAsRequestDto components.MessageMarkAsRequestDto ✔️ N/A
idempotencyKey string A header for idempotency purposes
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<operations.SubscribersV1ControllerMarkMessagesAsResponse>

Errors

Error Type Status Code Content Type
errors.ErrorDto 414 application/json
errors.ErrorDto 400, 401, 403, 404, 405, 409, 413, 415 application/json
errors.ValidationErrorDto 422 application/json
errors.ErrorDto 500 application/json
errors.SDKError 4XX, 5XX */*