(Subscribers.Notifications)
- GetFeed - Get in-app notification feed for a particular subscriber
- UnseenCount - Get the unseen in-app notifications count for subscribers feed
Get in-app notification feed for a particular subscriber
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
}
}
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. |
*operations.SubscribersControllerGetNotificationsFeedResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.ErrorDto | 400, 404, 409 | application/json |
apierrors.ValidationErrorDto | 422 | application/json |
apierrors.APIError | 4XX, 5XX | */* |
Get the unseen in-app notifications count for subscribers feed
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
}
}
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. |
*operations.SubscribersControllerGetUnseenCountResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.ErrorDto | 400, 404, 409 | application/json |
apierrors.ValidationErrorDto | 422 | application/json |
apierrors.APIError | 4XX, 5XX | */* |