Skip to content

Latest commit

 

History

History
122 lines (91 loc) · 7.3 KB

File metadata and controls

122 lines (91 loc) · 7.3 KB

NovuSubscribersNotifications

(Subscribers.Notifications)

Overview

Available Operations

  • GetFeed - Get in-app notification feed for a particular subscriber
  • UnseenCount - Get the unseen in-app notifications count for subscribers feed

GetFeed

Get in-app notification feed for a particular subscriber

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.Notifications.GetFeed(ctx, operations.SubscribersControllerGetNotificationsFeedRequest{
        SubscriberID: "<id>",
        Limit: novugo.Float64(10),
        Payload: novugo.String("btoa(JSON.stringify({ foo: 123 })) results in base64 encoded string like eyJmb28iOjEyM30="),
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.FeedResponseDto != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.SubscribersControllerGetNotificationsFeedRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.SubscribersControllerGetNotificationsFeedResponse, error

Errors

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

UnseenCount

Get the unseen in-app notifications count for subscribers feed

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.Notifications.UnseenCount(ctx, "<id>", novugo.Bool(false), novugo.Float64(100))
    if err != nil {
        log.Fatal(err)
    }
    if res.UnseenCountResponse != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
subscriberID string ✔️ N/A
seen *bool Indicates whether to count seen notifications.
limit *float64 The maximum number of notifications to return.
opts []operations.Option The options for this request.

Response

*operations.SubscribersControllerGetUnseenCountResponse, error

Errors

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