Skip to content

Latest commit

 

History

History
307 lines (232 loc) · 24.1 KB

README.md

File metadata and controls

307 lines (232 loc) · 24.1 KB

Preferences

(Subscribers.Preferences)

Overview

Available Operations

  • ListLegacy - Get subscriber preferences ⚠️ Deprecated
  • RetrieveByLevelLegacy - Get subscriber preferences by level ⚠️ Deprecated
  • UpdateLegacy - Update subscriber preference
  • Retrieve - Get subscriber preferences
  • Update - Update subscriber global or workflow specific preferences

ListLegacy

Get subscriber preferences

⚠️ DEPRECATED: This will be removed in a future release, please migrate away from it as soon as possible.

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_SECRET_KEY")),
    )

    res, err := s.Subscribers.Preferences.ListLegacy(ctx, "<id>", nil, 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
idempotencyKey *string A header for idempotency purposes
opts []operations.Option The options for this request.

Response

*operations.SubscribersV1ControllerListSubscriberPreferencesResponse, error

Errors

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

RetrieveByLevelLegacy

Get subscriber preferences by level

⚠️ DEPRECATED: This will be removed in a future release, please migrate away from it as soon as possible.

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_SECRET_KEY")),
    )

    res, err := s.Subscribers.Preferences.RetrieveByLevelLegacy(ctx, operations.ParameterTemplate, "<id>", nil, 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
idempotencyKey *string A header for idempotency purposes
opts []operations.Option The options for this request.

Response

*operations.SubscribersV1ControllerGetSubscriberPreferenceByLevelResponse, error

Errors

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

UpdateLegacy

Update subscriber preference

Example Usage

package main

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

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

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

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
subscriberID string ✔️ N/A
workflowID string ✔️ N/A
updateSubscriberPreferenceRequestDto components.UpdateSubscriberPreferenceRequestDto ✔️ N/A
idempotencyKey *string A header for idempotency purposes
opts []operations.Option The options for this request.

Response

*operations.SubscribersV1ControllerUpdateSubscriberPreferenceResponse, error

Errors

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

Retrieve

Get subscriber global and workflow specific 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_SECRET_KEY")),
    )

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

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
subscriberID string ✔️ N/A
idempotencyKey *string A header for idempotency purposes
opts []operations.Option The options for this request.

Response

*operations.SubscribersControllerGetSubscriberPreferencesResponse, error

Errors

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

Update

Update subscriber global or workflow specific preferences

Example Usage

package main

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

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

    res, err := s.Subscribers.Preferences.Update(ctx, "<id>", components.PatchSubscriberPreferencesDto{
        Channels: components.PatchPreferenceChannelsDto{},
    }, nil)
    if err != nil {
        log.Fatal(err)
    }
    if res.GetSubscriberPreferencesDto != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
subscriberID string ✔️ N/A
patchSubscriberPreferencesDto components.PatchSubscriberPreferencesDto ✔️ N/A
idempotencyKey *string A header for idempotency purposes
opts []operations.Option The options for this request.

Response

*operations.SubscribersControllerUpdateSubscriberPreferencesResponse, error

Errors

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