Skip to content

Latest commit

 

History

History
123 lines (92 loc) · 6.29 KB

README.md

File metadata and controls

123 lines (92 loc) · 6.29 KB

NovuTopicsSubscribers

(Topics.Subscribers)

Overview

Available Operations

  • Check - Check topic subscriber
  • Remove - Subscribers removal

Check

Check if a subscriber belongs to a certain topic

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

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
externalSubscriberID string ✔️ The external subscriber id
topicKey string ✔️ The topic key
opts []operations.Option The options for this request.

Response

*operations.TopicsControllerGetTopicSubscriberResponse, error

Errors

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

Remove

Remove subscribers from a topic

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

    res, err := s.Topics.Subscribers.Remove(ctx, "<value>", components.RemoveSubscribersRequestDto{
        Subscribers: []string{
            "<value>",
            "<value>",
        },
    })
    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.
topicKey string ✔️ The topic key
removeSubscribersRequestDto components.RemoveSubscribersRequestDto ✔️ N/A
opts []operations.Option The options for this request.

Response

*operations.TopicsControllerRemoveSubscribersResponse, error

Errors

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