Skip to content

Latest commit

 

History

History
216 lines (171 loc) · 14.3 KB

README.md

File metadata and controls

216 lines (171 loc) · 14.3 KB

Credentials

(Subscribers.Credentials)

Overview

Available Operations

  • Update - Update subscriber credentials
  • Append - Modify subscriber credentials
  • Delete - Delete subscriber credentials by providerId

Update

Subscriber credentials associated to the delivery methods such as slack and push tokens.

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.Credentials.Update(ctx, "<id>", components.UpdateSubscriberChannelRequestDto{
        ProviderID: components.UpdateSubscriberChannelRequestDtoProviderIDPushpad,
        Credentials: components.ChannelCredentials{
            WebhookURL: novugo.String("https://example.com/webhook"),
            Channel: novugo.String("general"),
            DeviceTokens: []string{
                "token1",
                "token2",
                "token3",
            },
            AlertUID: novugo.String("12345-abcde"),
            Title: novugo.String("Critical Alert"),
            ImageURL: novugo.String("https://example.com/image.png"),
            State: novugo.String("resolved"),
            ExternalURL: novugo.String("https://example.com/details"),
        },
    }, nil)
    if err != nil {
        log.Fatal(err)
    }
    if res.SubscriberResponseDto != nil {
        // handle response
    }
}

Parameters

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

Response

*operations.SubscribersV1ControllerUpdateSubscriberChannelResponse, 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 */*

Append

Subscriber credentials associated to the delivery methods such as slack and push tokens. This endpoint appends provided credentials and deviceTokens to the existing ones.

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.Credentials.Append(ctx, "<id>", components.UpdateSubscriberChannelRequestDto{
        ProviderID: components.UpdateSubscriberChannelRequestDtoProviderIDZulip,
        Credentials: components.ChannelCredentials{
            WebhookURL: novugo.String("https://example.com/webhook"),
            Channel: novugo.String("general"),
            DeviceTokens: []string{
                "token1",
                "token2",
                "token3",
            },
            AlertUID: novugo.String("12345-abcde"),
            Title: novugo.String("Critical Alert"),
            ImageURL: novugo.String("https://example.com/image.png"),
            State: novugo.String("resolved"),
            ExternalURL: novugo.String("https://example.com/details"),
        },
    }, nil)
    if err != nil {
        log.Fatal(err)
    }
    if res.SubscriberResponseDto != nil {
        // handle response
    }
}

Parameters

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

Response

*operations.SubscribersV1ControllerModifySubscriberChannelResponse, 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 */*

Delete

Delete subscriber credentials such as slack and expo tokens.

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.Credentials.Delete(ctx, "<id>", "<id>", nil)
    if err != nil {
        log.Fatal(err)
    }
    if res != nil {
        // handle response
    }
}

Parameters

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

Response

*operations.SubscribersV1ControllerDeleteSubscriberCredentialsResponse, 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 */*