Skip to content

Latest commit

 

History

History
119 lines (88 loc) · 8.93 KB

README.md

File metadata and controls

119 lines (88 loc) · 8.93 KB

Preferences

(Subscribers.Preferences)

Overview

Available Operations

List

Get subscriber preferences

Example Usage

package main

import(
	"context"
	"os"
	novugo "github.com/novuhq/novu-go"
	"log"
)

func main() {
    ctx := context.Background()
    
    s := novugo.New(
        novugo.WithSecurity(os.Getenv("NOVU_API_KEY")),
    )

    res, err := s.Subscribers.Preferences.List(ctx, "<id>", nil)
    if err != nil {
        log.Fatal(err)
    }
    if res.UpdateSubscriberPreferenceResponseDtos != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
subscriberID string ✔️ N/A
includeInactiveChannels *bool A flag which specifies if the inactive workflow channels should be included in the retrieved preferences. Default is true
opts []operations.Option The options for this request.

Response

*operations.SubscribersControllerListSubscriberPreferencesResponse, error

Errors

Error Type Status Code Content Type
apierrors.ErrorDto 400, 404, 409 application/json
apierrors.ValidationErrorDto 422 application/json
apierrors.APIError 4XX, 5XX */*

RetrieveByLevel

Get subscriber preferences by level

Example Usage

package main

import(
	"context"
	"os"
	novugo "github.com/novuhq/novu-go"
	"github.com/novuhq/novu-go/models/operations"
	"log"
)

func main() {
    ctx := context.Background()
    
    s := novugo.New(
        novugo.WithSecurity(os.Getenv("NOVU_API_KEY")),
    )

    res, err := s.Subscribers.Preferences.RetrieveByLevel(ctx, operations.ParameterTemplate, "<id>", nil)
    if err != nil {
        log.Fatal(err)
    }
    if res.GetSubscriberPreferencesResponseDtos != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
preferenceLevel operations.Parameter ✔️ the preferences level to be retrieved (template / global)
subscriberID string ✔️ N/A
includeInactiveChannels *bool A flag which specifies if the inactive workflow channels should be included in the retrieved preferences. Default is true
opts []operations.Option The options for this request.

Response

*operations.SubscribersControllerGetSubscriberPreferenceByLevelResponse, error

Errors

Error Type Status Code Content Type
apierrors.ErrorDto 400, 404, 409 application/json
apierrors.ValidationErrorDto 422 application/json
apierrors.APIError 4XX, 5XX */*