Skip to content

Latest commit

 

History

History
178 lines (149 loc) · 10.1 KB

File metadata and controls

178 lines (149 loc) · 10.1 KB

SubscribersPreferences

Overview

Available Operations

  • List - Retrieve subscriber preferences
  • Update - Update subscriber preferences

List

Retrieve subscriber channel preferences by its unique key identifier subscriberId. This API returns all five channels preferences for all workflows and global preferences.

Example Usage

using Novu;
using Novu.Models.Components;
using Novu.Models.Requests;
using System.Collections.Generic;

var sdk = new NovuSDK(secretKey: "YOUR_SECRET_KEY_HERE");

var res = await sdk.SubscribersPreferences.ListAsync(
    subscriberId: "<id>",
    criticality: Criticality.NonCritical,
    contextKeys: new List<string>() {
        "tenant:acme",
    }
);

// handle response

Parameters

Parameter Type Required Description Example
SubscriberId string ✔️ The identifier of the subscriber
Criticality Criticality N/A
ContextKeys List<string> Context keys for filtering preferences (e.g., ["tenant:acme"]) [
"tenant:acme"
]
IdempotencyKey string A header for idempotency purposes

Response

SubscribersControllerGetSubscriberPreferencesResponse

Errors

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

Update

Update subscriber preferences by its unique key identifier subscriberId. workflowId is optional field, if provided, this API will update that workflow preference, otherwise it will update global preferences

Example Usage

using Novu;
using Novu.Models.Components;
using System.Collections.Generic;

var sdk = new NovuSDK(secretKey: "YOUR_SECRET_KEY_HERE");

var res = await sdk.SubscribersPreferences.UpdateAsync(
    subscriberId: "<id>",
    patchSubscriberPreferencesDto: new PatchSubscriberPreferencesDto() {
        Schedule = new ScheduleDto() {
            IsEnabled = true,
            WeeklySchedule = new WeeklySchedule() {
                Monday = new Monday() {
                    IsEnabled = true,
                    Hours = new List<TimeRangeDto>() {
                        new TimeRangeDto() {
                            Start = "09:00 AM",
                            End = "05:00 PM",
                        },
                    },
                },
                Tuesday = new Tuesday() {
                    IsEnabled = true,
                    Hours = new List<TimeRangeDto>() {
                        new TimeRangeDto() {
                            Start = "09:00 AM",
                            End = "05:00 PM",
                        },
                    },
                },
                Wednesday = new Wednesday() {
                    IsEnabled = true,
                    Hours = new List<TimeRangeDto>() {
                        new TimeRangeDto() {
                            Start = "09:00 AM",
                            End = "05:00 PM",
                        },
                    },
                },
                Thursday = new Thursday() {
                    IsEnabled = true,
                    Hours = new List<TimeRangeDto>() {
                        new TimeRangeDto() {
                            Start = "09:00 AM",
                            End = "05:00 PM",
                        },
                    },
                },
                Friday = new Friday() {
                    IsEnabled = true,
                    Hours = new List<TimeRangeDto>() {
                        new TimeRangeDto() {
                            Start = "09:00 AM",
                            End = "05:00 PM",
                        },
                    },
                },
                Saturday = new Saturday() {
                    IsEnabled = true,
                    Hours = new List<TimeRangeDto>() {
                        new TimeRangeDto() {
                            Start = "09:00 AM",
                            End = "05:00 PM",
                        },
                    },
                },
                Sunday = new Sunday() {
                    IsEnabled = true,
                    Hours = new List<TimeRangeDto>() {
                        new TimeRangeDto() {
                            Start = "09:00 AM",
                            End = "05:00 PM",
                        },
                    },
                },
            },
        },
        Context = new Dictionary<string, Context>() {
            { "key", Context.CreateStr(
                "org-acme"
            ) },
        },
    }
);

// handle response

Parameters

Parameter Type Required Description
SubscriberId string ✔️ The identifier of the subscriber
PatchSubscriberPreferencesDto PatchSubscriberPreferencesDto ✔️ N/A
IdempotencyKey string A header for idempotency purposes

Response

SubscribersControllerUpdateSubscriberPreferencesResponse

Errors

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