Skip to content

Latest commit

 

History

History
186 lines (141 loc) · 11.9 KB

README.md

File metadata and controls

186 lines (141 loc) · 11.9 KB

NovuMessages

(Subscribers.Messages)

Overview

Available Operations

  • MarkAs - Mark a subscriber messages as seen, read, unseen or unread
  • MarkAll - Marks all the subscriber messages as read, unread, seen or unseen. Optionally you can pass feed id (or array) to mark messages of a particular feed.
  • UpdateAction - Mark message action as seen

MarkAs

Mark a subscriber messages as seen, read, unseen or unread

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.Subscribers.Messages.MarkAs(ctx, "<id>", components.MessageMarkAsRequestDto{
        MessageID: components.CreateMessageIDStr(
            "<id>",
        ),
        MarkAs: components.MarkAsUnread,
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.MessageResponseDtos != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
subscriberID string ✔️ N/A
messageMarkAsRequestDto components.MessageMarkAsRequestDto ✔️ N/A
opts []operations.Option The options for this request.

Response

*operations.SubscribersControllerMarkMessagesAsResponse, error

Errors

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

MarkAll

Marks all the subscriber messages as read, unread, seen or unseen. Optionally you can pass feed id (or array) to mark messages of a particular feed.

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.Subscribers.Messages.MarkAll(ctx, "<id>", components.MarkAllMessageAsRequestDto{
        MarkAs: components.MarkAllMessageAsRequestDtoMarkAsSeen,
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.Number != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
subscriberID string ✔️ N/A
markAllMessageAsRequestDto components.MarkAllMessageAsRequestDto ✔️ N/A
opts []operations.Option The options for this request.

Response

*operations.SubscribersControllerMarkAllUnreadAsReadResponse, error

Errors

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

UpdateAction

Mark message action as seen

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.Subscribers.Messages.UpdateAction(ctx, "<id>", "<value>", "<id>", components.MarkMessageActionAsSeenDto{
        Status: components.MarkMessageActionAsSeenDtoStatusDone,
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.MessageResponseDto != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
messageID string ✔️ N/A
type_ any ✔️ N/A
subscriberID string ✔️ N/A
markMessageActionAsSeenDto components.MarkMessageActionAsSeenDto ✔️ N/A
opts []operations.Option The options for this request.

Response

*operations.SubscribersControllerMarkActionAsSeenResponse, error

Errors

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