knock

package
v0.1.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 24, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultBaseUrl = "https://api.knock.app/"
)

Variables

This section is empty.

Functions

func NewBulkOperationsService

func NewBulkOperationsService(client *Client) *bulkOperationsService

func NewMessagesService

func NewMessagesService(client *Client) *messagesService

func NewObjectService

func NewObjectService(client *Client) *objectsService

func NewTenantService added in v0.1.2

func NewTenantService(client *Client) *tenantsService

func NewUsersService

func NewUsersService(client *Client) *usersService

func NewWorkflowsService

func NewWorkflowsService(client *Client) *workflowsService

func ParseRFC3339Timestamp

func ParseRFC3339Timestamp(input string) time.Time

func PreferencesMapAppend added in v0.1.1

func PreferencesMapAppend(m map[string]interface{}, new map[string]interface{}) map[string]interface{}

func UsersAPIPath

func UsersAPIPath(userId string) string

Types

type AddSubscriptionsRequest added in v0.1.4

type AddSubscriptionsRequest struct {
	ObjectID   string                 `json:"-"`
	Collection string                 `json:"-"`
	Recipients []interface{}          `json:"recipients"`
	Properties map[string]interface{} `json:"properties,omitempty"`
}

type AddSubscriptionsResponse added in v0.1.4

type AddSubscriptionsResponse struct {
	Subscriptions []*ObjectSubscription
}

type BatchSetStatusRequest

type BatchSetStatusRequest struct {
	Status     MessageStatus `json:"-"`
	MessageIDs []string      `json:"message_ids"`
}

type BatchSetStatusResponse

type BatchSetStatusResponse struct {
	Messages []*Message
}

type BulkAddObjectSubscription added in v0.1.9

type BulkAddObjectSubscription struct {
	ID         string                 `json:"id"`
	Properties map[string]interface{} `json:"properties,omitempty"`
	Recipients []interface{}          `json:"recipients"`
}

type BulkAddSubscriptionsRequest added in v0.1.9

type BulkAddSubscriptionsRequest struct {
	Collection    string                       `json:"-"`
	Subscriptions []*BulkAddObjectSubscription `json:"subscriptions"`
}

type BulkChangeChannelStatusRequest

type BulkChangeChannelStatusRequest struct {
	ChannelID string        `json:"-"`
	Status    MessageStatus `json:"-"`

	UserIDs          []string         `json:"user_ids,omitempty"`
	OlderThan        *time.Time       `json:"older_than,omitempty"`
	NewerThan        *time.Time       `json:"newer_than,omitempty"`
	DeliveryStatus   EngagementStatus `json:"delivery_status,omitempty"`
	EngagementStatus string           `json:"engagement_status,omitempty"`
}

type BulkChangeChannelStatusResponse

type BulkChangeChannelStatusResponse struct {
	BulkOperation *BulkOperation
}

type BulkDeleteObjectsRequest added in v0.1.9

type BulkDeleteObjectsRequest struct {
	Collection string   `json:"-"`
	ObjectIDs  []string `json:"object_ids"`
}

type BulkDeleteUserRequest

type BulkDeleteUserRequest struct {
	UserIDs []string `json:"user_ids"`
}

type BulkDeleteUserResponse

type BulkDeleteUserResponse = BulkIdentifyUserResponse

type BulkIdentifyUserRequest

type BulkIdentifyUserRequest struct {
	Users []*IdentifyUserRequest
}

type BulkIdentifyUserResponse

type BulkIdentifyUserResponse struct {
	BulkOperation *BulkOperation
}

type BulkOperation

type BulkOperation struct {
	ID                 string              `json:"id"`
	CompletedAt        time.Time           `json:"completed_at"`
	FailedAt           time.Time           `json:"failed_at"`
	StartedAt          time.Time           `json:"started_at"`
	InsertedAt         time.Time           `json:"inserted_at"`
	UpdatedAt          time.Time           `json:"updated_at"`
	EstimatedTotalRows int                 `json:"estimated_total_rows"`
	ProcessedRows      int                 `json:"processed_rows"`
	ProgressPath       string              `json:"progress_path"`
	Status             BulkOperationStatus `json:"status"`
}

type BulkOperationStatus

type BulkOperationStatus string
const (
	BulkOperationQueued BulkOperationStatus = "queued"
	Processing          BulkOperationStatus = "processing"
	Completed           BulkOperationStatus = "completed"
	Failed              BulkOperationStatus = "failed"
)

type BulkOperationsService

type BulkOperationsService interface {
	Get(context.Context, *GetBulkOperationRequest) (*BulkOperation, error)
}

BulkOperationsService is an interface for communicating with API endpoints that return BulkOperations, which are used by other services including the UsersService and MessagesService

type BulkRequestResponse added in v0.1.9

type BulkRequestResponse struct {
	BulkOperation *BulkOperation
}

type BulkSetObject added in v0.1.9

type BulkSetObject struct {
	ID         string `json:"id"`
	Properties map[string]interface{}
}

type BulkSetObjectsRequest added in v0.1.9

type BulkSetObjectsRequest struct {
	Collection string           `json:"-"`
	Objects    []*BulkSetObject `json:"objects"`
}

type BulkSetUserPreferencesRequest

type BulkSetUserPreferencesRequest struct {
	UserIDs     []string      `json:"user_ids"`
	Preferences PreferenceSet `json:"preferences"`
}

func (*BulkSetUserPreferencesRequest) AddCategoriesPreference added in v0.1.1

func (br *BulkSetUserPreferencesRequest) AddCategoriesPreference(category map[string]interface{}) BulkSetUserPreferencesRequest

func (*BulkSetUserPreferencesRequest) AddChannelTypesPreference added in v0.1.1

func (br *BulkSetUserPreferencesRequest) AddChannelTypesPreference(channelType map[string]interface{}) BulkSetUserPreferencesRequest

func (*BulkSetUserPreferencesRequest) AddWorkflowsPreference added in v0.1.1

func (br *BulkSetUserPreferencesRequest) AddWorkflowsPreference(workflow map[string]interface{}) BulkSetUserPreferencesRequest

type BulkSetUserPreferencesResponse

type BulkSetUserPreferencesResponse = BulkIdentifyUserResponse

type CancelWorkflowRequest

type CancelWorkflowRequest struct {
	Workflow        string        `json:"workflow"`
	Recipients      []interface{} `json:"recipients"`
	CancellationKey string        `json:"cancellation_key"`
}

func (*CancelWorkflowRequest) AddRecipientByEntity added in v0.1.1

func (tr *CancelWorkflowRequest) AddRecipientByEntity(entity map[string]interface{}) CancelWorkflowRequest

func (*CancelWorkflowRequest) AddRecipientByID added in v0.1.1

func (tr *CancelWorkflowRequest) AddRecipientByID(recipientID string) CancelWorkflowRequest

type ChannelData

type ChannelData struct {
	ChannelID string                 `json:"channel_id"`
	Data      map[string]interface{} `json:"data"`
}

type Client

type Client struct {
	BulkOperations BulkOperationsService
	Messages       MessagesService
	Objects        ObjectsService
	Tenants        TenantsService
	Users          UsersService
	Workflows      WorkflowsService
	// contains filtered or unexported fields
}

Client encapsulates a client that talks to the Knock API

func NewClient

func NewClient(opts ...ClientOption) (*Client, error)

NewClient instantiates an instance of the Knock API client.

type ClientOption

type ClientOption func(c *Client) error

ClientOption provides a variadic option for configuring the client

func WithAccessToken

func WithAccessToken(token string) ClientOption

WithAccessToken configures a client with the given Knock access token.

func WithBaseURL

func WithBaseURL(baseURL string) ClientOption

WithBaseURL overrides the base URL for the API.

func WithHTTPClient

func WithHTTPClient(client *http.Client) ClientOption

WithHTTPClient configures the Knock client with the given HTTP client.

type CreateSchedulesRequest added in v0.1.6

type CreateSchedulesRequest struct {
	Workflow    string                 `json:"workflow"`
	Recipients  []interface{}          `json:"recipients"`
	Repeats     []*ScheduleRepeat      `json:"repeats"`
	Actor       interface{}            `json:"actor,omitempty"`
	Tenant      interface{}            `json:"tenant,omitempty"`
	ScheduledAt time.Time              `json:"scheduled_at,omitempty"`
	Data        map[string]interface{} `json:"data,omitempty"`
}

func (*CreateSchedulesRequest) AddActorByEntity added in v0.1.6

func (csr *CreateSchedulesRequest) AddActorByEntity(entity map[string]interface{}) CreateSchedulesRequest

func (*CreateSchedulesRequest) AddActorByID added in v0.1.6

func (csr *CreateSchedulesRequest) AddActorByID(actorID string) CreateSchedulesRequest

func (*CreateSchedulesRequest) AddRecipientByEntity added in v0.1.6

func (csr *CreateSchedulesRequest) AddRecipientByEntity(entity map[string]interface{}) CreateSchedulesRequest

func (*CreateSchedulesRequest) AddRecipientByID added in v0.1.6

func (csr *CreateSchedulesRequest) AddRecipientByID(recipientID string) CreateSchedulesRequest

func (*CreateSchedulesRequest) AddRepeat added in v0.1.6

func (*CreateSchedulesRequest) AddTenantByEntity added in v0.1.14

func (csr *CreateSchedulesRequest) AddTenantByEntity(entity map[string]interface{}) CreateSchedulesRequest

func (*CreateSchedulesRequest) AddTenantByID added in v0.1.14

func (csr *CreateSchedulesRequest) AddTenantByID(tenantID string) CreateSchedulesRequest

type DeleteObjectChannelDataRequest

type DeleteObjectChannelDataRequest = GetObjectChannelDataRequest

type DeleteObjectRequest

type DeleteObjectRequest = GetObjectRequest

type DeleteSchedulesRequest added in v0.1.6

type DeleteSchedulesRequest struct {
	ScheduleIDs []string `json:"schedule_ids"`
}

type DeleteStatusRequest

type DeleteStatusRequest = SetStatusRequest

type DeleteStatusResponse

type DeleteStatusResponse = GetMessageResponse

type DeleteSubscriptionsRequest added in v0.1.4

type DeleteSubscriptionsRequest struct {
	ObjectID   string        `json:"-"`
	Collection string        `json:"-"`
	Recipients []interface{} `json:"recipients"`
}

type DeleteSubscriptionsResponse added in v0.1.4

type DeleteSubscriptionsResponse struct {
	Subscriptions []*ObjectSubscription
}

type DeleteTenantRequest added in v0.1.2

type DeleteTenantRequest = GetTenantRequest

type DeleteUserChannelDataRequest

type DeleteUserChannelDataRequest = GetUserChannelDataRequest

type DeleteUserRequest

type DeleteUserRequest struct {
	ID string
}

type EngagementStatus

type EngagementStatus string
const (
	Queued      EngagementStatus = "queued"
	Sent        EngagementStatus = "sent"
	Delivered   EngagementStatus = "delivered"
	Undelivered EngagementStatus = "undelivered"
)

User message query statuses

type Error

type Error struct {

	// Code specifies the error code. i.e; NotFound, RateLimited, etc...
	Code ErrorCode

	// Meta contains additional information depending on the error code. As an
	// example, if the Code is "ErrResponseMalformed", the map will be: ["body"]
	// = "body of the response"
	Meta map[string]string
	// contains filtered or unexported fields
}

Error represents common errors originating from the Client.

func (*Error) Error

func (e *Error) Error() string

Error returns the string representation of the error.

type ErrorCode

type ErrorCode string

ErrorCode defines the code of an error.

const (
	ErrInternal          ErrorCode = "internal"           // Internal error.
	ErrInvalid           ErrorCode = "invalid"            // Invalid operation, e.g wrong params
	ErrPermission        ErrorCode = "permission"         // Permission denied.
	ErrNotFound          ErrorCode = "not_found"          // Resource not found.
	ErrRetry             ErrorCode = "retry"              // Operation should be retried.
	ErrResponseMalformed ErrorCode = "response_malformed" // Response body is malformed.
)

type Feed

type Feed struct {
	FeedItems    []*FeedItem            `json:"entries"`
	PageInfo     *PageInfo              `json:"page_info"`
	Vars         map[string]interface{} `json:"vars"`
	FeedMetadata *FeedMetadata          `json:"meta"`
}

Context structs

type FeedBlock

type FeedBlock struct {
	Content  string `json:"content"`
	Name     string `json:"name"`
	Rendered string `json:"rendered"`
	Type     string `json:"type"`
}

type FeedItem

type FeedItem struct {
	Activities      []*MessageActivity     `json:"activities"`
	Actors          []*User                `json:"actors"`
	TotalActivities int                    `json:"total_activities"`
	TotalActors     int                    `json:"total_actors"`
	Blocks          []*FeedBlock           `json:"blocks"`
	Data            map[string]interface{} `json:"vars"`
	InsertedAt      time.Time              `json:"inserted_at"`
	UpdatedAt       time.Time              `json:"updated_at"`
	ReadAt          time.Time              `json:"read_at"`
	SeenAt          time.Time              `json:"seen_at"`
	ArchivedAt      time.Time              `json:"archived_at"`
	Source          NotificationSource     `json:"source"`
	Tenant          string                 `json:"tenant"`
}

type FeedMetadata

type FeedMetadata struct {
	UnreadCount int `json:"unread_count"`
	UnseenCount int `json:"unseen_count"`
}

type GetAllPreferencesRequest

type GetAllPreferencesRequest struct {
	UserID string `json:"-"`
}

type GetAllPreferencesResponse

type GetAllPreferencesResponse struct {
	Preferences []*PreferenceSet
}

type GetBulkOperationRequest

type GetBulkOperationRequest struct {
	ID string
}

Client structs

type GetBulkOperationResponse

type GetBulkOperationResponse struct {
	BulkOperation *BulkOperation
}

type GetFeedRequest

type GetFeedRequest struct {
	UserID      string                 `url:"-"`
	FeedID      string                 `url:"-"`
	PageSize    int                    `url:"page_size,omitempty"`
	After       string                 `url:"after,omitempty"`
	Before      string                 `url:"before,omitempty"`
	Status      []string               `url:"status,omitempty"`
	Source      string                 `url:"source,omitempty"`
	Tenant      string                 `url:"tenant,omitempty"`
	HasTenant   bool                   `url:"has_tenant,omitempty"`
	Archived    string                 `url:"archived,omitempty"`
	TriggerData map[string]interface{} `url:"-"`
}

type GetFeedResponse

type GetFeedResponse struct {
	Feed *Feed
}

type GetMessageActivitiesRequest

type GetMessageActivitiesRequest = struct {
	ID          string
	PageSize    int                    `url:"page_size,omitempty"`
	Cursor      string                 `url:"page_size,omitempty"`
	Before      string                 `url:"before,omitempty"`
	After       string                 `url:"after,omitempty"`
	TriggerData map[string]interface{} `url:"-"`
}

type GetMessageActivitiesResponse

type GetMessageActivitiesResponse struct {
	Activities []*MessageActivity `json:"items"`
	PageInfo   *PageInfo          `json:"page_info"`
}

type GetMessageContentRequest

type GetMessageContentRequest = GetMessageRequest

type GetMessageContentResponse

type GetMessageContentResponse struct {
	Content *MessageContent
}

type GetMessageEventsRequest

type GetMessageEventsRequest = GetMessageRequest

type GetMessageEventsResponse

type GetMessageEventsResponse struct {
	Items    []*MessageEvent `json:"items"`
	PageInfo *PageInfo       `json:"page_info"`
}

type GetMessageRequest

type GetMessageRequest struct {
	ID string
}

type GetMessageResponse

type GetMessageResponse struct {
	Message *Message
}

type GetObjectChannelDataRequest

type GetObjectChannelDataRequest struct {
	Collection string
	ChannelID  string
	ObjectID   string
}

type GetObjectChannelDataResponse

type GetObjectChannelDataResponse = GetUserChannelDataResponse

type GetObjectMessagesRequest

type GetObjectMessagesRequest struct {
	ObjectID   string `url:"-"`
	Collection string `url:"-"`

	PageSize    int                    `url:"page_size,omitempty"`
	Before      string                 `url:"before,omitempty"`
	After       string                 `url:"after,omitempty"`
	Source      string                 `url:"source,omitempty"`
	Tenant      string                 `url:"tenant,omitempty"`
	Status      []EngagementStatus     `url:"status,omitempty"`
	ChannelID   string                 `url:"channel_id,omitempty"`
	TriggerData map[string]interface{} `url:"-"`
}

type GetObjectMessagesResponse

type GetObjectMessagesResponse struct {
	Items    []*ObjectMessage `json:"items"`
	PageInfo *PageInfo        `json:"page_info"`
}

type GetObjectPreferencesRequest

type GetObjectPreferencesRequest struct {
	PreferenceID string `json:"-"`
	ObjectID     string `json:"-"`
	Collection   string `json:"-"`
}

type GetObjectPreferencesResponse

type GetObjectPreferencesResponse struct {
	Preferences *PreferenceSet
}

type GetObjectRequest

type GetObjectRequest struct {
	ID         string
	Collection string
}

Client structs

type GetObjectResponse

type GetObjectResponse struct {
	Object *Object
}

type GetObjectSchedulesRequest added in v0.1.6

type GetObjectSchedulesRequest struct {
	ObjectID   string `url:"-"`
	Collection string `url:"-"`

	PageSize int    `url:"page_size,omitempty"`
	Before   string `url:"before,omitempty"`
	After    string `url:"after,omitempty"`
	Workflow string `url:"workflow,omitempty"`
	Tenant   string `url:"tenant,omitempty"`
}

type GetObjectSchedulesResponse added in v0.1.6

type GetObjectSchedulesResponse struct {
	Items    []*Schedule `json:"entries"`
	PageInfo *PageInfo   `json:"page_info"`
}

type GetObjectSubscriptionsRequest added in v0.1.8

type GetObjectSubscriptionsRequest struct {
	Collection string `url:"-"`
	ObjectID   string `url:"-"`
	PageSize   int    `url:"page_size,omitempty"`
	Before     string `url:"before,omitempty"`
	After      string `url:"after,omitempty"`
}

type GetObjectSubscriptionsResponse added in v0.1.8

type GetObjectSubscriptionsResponse struct {
	Entries  []*ObjectSubscription `json:"entries"`
	PageInfo *PageInfo             `json:"page_info"`
}

type GetTenantRequest added in v0.1.2

type GetTenantRequest struct {
	ID string
}

type GetTenantResponse added in v0.1.2

type GetTenantResponse struct {
	Tenant *Tenant
}

type GetUserChannelDataRequest

type GetUserChannelDataRequest struct {
	UserID    string
	ChannelID string
}

type GetUserChannelDataResponse

type GetUserChannelDataResponse struct {
	ChannelData map[string]interface{} `json:"data"`
}

type GetUserMessagesRequest

type GetUserMessagesRequest struct {
	ID          string                 `url:"-"`
	PageSize    int                    `url:"page_size,omitempty"`
	After       string                 `url:"after,omitempty"`
	Before      string                 `url:"before,omitempty"`
	Source      string                 `url:"source,omitempty"`
	Tenant      string                 `url:"tenant,omitempty"`
	Status      []EngagementStatus     `url:"status,omitempty"`
	ChannelID   string                 `url:"channel_id,omitempty"`
	TriggerData map[string]interface{} `url:"-"`
}

type GetUserMessagesResponse

type GetUserMessagesResponse struct {
	Messages []*Message `json:"items"`
}

type GetUserPreferencesRequest

type GetUserPreferencesRequest struct {
	UserID       string `json:"-"`
	PreferenceID string `json:"-"`
}

type GetUserPreferencesResponse

type GetUserPreferencesResponse struct {
	Preferences *PreferenceSet
}

type GetUserRequest

type GetUserRequest struct {
	ID string
}

type GetUserResponse

type GetUserResponse struct {
	User *User
}

type GetUserSchedulesRequest added in v0.1.6

type GetUserSchedulesRequest struct {
	ID string `url:"-"`

	PageSize int    `url:"page_size,omitempty"`
	Before   string `url:"before,omitempty"`
	After    string `url:"after,omitempty"`
	Workflow string `url:"workflow,omitempty"`
	Tenant   string `url:"tenant,omitempty"`
}

type GetUserSchedulesResponse added in v0.1.6

type GetUserSchedulesResponse struct {
	Items    []*Schedule `json:"entries"`
	PageInfo *PageInfo   `json:"page_info"`
}

type GetUserSubscriptionsRequest added in v0.1.8

type GetUserSubscriptionsRequest struct {
	ID       string
	PageSize int    `url:"page_size,omitempty"`
	Before   string `url:"before,omitempty"`
	After    string `url:"after,omitempty"`
}

type GetUserSubscriptionsResponse added in v0.1.8

type GetUserSubscriptionsResponse struct {
	Entries  []*ObjectSubscription `json:"entries"`
	PageInfo *PageInfo             `json:"page_info"`
}

type IdentifyUserRequest

type IdentifyUserRequest = User

type IdentifyUserResponse

type IdentifyUserResponse = GetUserResponse

type ListMessagesRequest

type ListMessagesRequest struct {
	PageSize    int                    `url:"page_size,omitempty"`
	Before      string                 `url:"before,omitempty"`
	After       string                 `url:"after,omitempty"`
	Source      string                 `url:"source,omitempty"`
	Tenant      string                 `url:"tenant,omitempty"`
	Status      []EngagementStatus     `url:"status,omitempty"`
	ChannelID   string                 `url:"channel_id,omitempty"`
	TriggerData map[string]interface{} `url:"-"`
}

Client structs

type ListMessagesResponse

type ListMessagesResponse struct {
	Items    []*Message `json:"items"`
	PageInfo *PageInfo  `json:"page_info"`
}

type ListObjectsRequest added in v0.1.8

type ListObjectsRequest struct {
	Collection string `url:"-"`
	ObjectId   string `url:"object_id,omitempty"`
	Name       string `url:"name,omitempty"`
	PageSize   int    `url:"page_size,omitempty"`
	Before     string `url:"before,omitempty"`
	After      string `url:"after,omitempty"`
}

type ListObjectsResponse added in v0.1.8

type ListObjectsResponse struct {
	Entries  []*Object `json:"entries"`
	PageInfo *PageInfo `json:"page_info"`
}

type ListSchedulesRequest added in v0.1.6

type ListSchedulesRequest struct {
	PageSize   int           `url:"page_size,omitempty"`
	Cursor     string        `url:"cursor,omitempty"`
	Before     string        `url:"before,omitempty"`
	After      string        `url:"after,omitempty"`
	Workflow   string        `url:"workflow"`
	Tenant     string        `url:"tenant,omitempty"`
	Recipients []interface{} `url:"recipients,omitempty"`
}

type ListSchedulesResponse added in v0.1.6

type ListSchedulesResponse struct {
	Entries  []*Schedule `json:"entries"`
	PageInfo *PageInfo   `json:"page_info"`
}

type ListSubscriptionsRequest added in v0.1.4

type ListSubscriptionsRequest struct {
	ObjectID   string `url:"-"`
	Collection string `url:"-"`
	PageSize   int    `url:"page_size,omitempty"`
	Before     string `url:"before,omitempty"`
	After      string `url:"after,omitempty"`
}

type ListSubscriptionsResponse added in v0.1.4

type ListSubscriptionsResponse struct {
	Entries  []*ObjectSubscription `json:"entries"`
	PageInfo *PageInfo             `json:"page_info"`
}

type ListTenantsRequest added in v0.1.2

type ListTenantsRequest struct {
	PageSize int    `url:"page_size,omitempty"`
	Before   string `url:"before,omitempty"`
	After    string `url:"after,omitempty"`
	TenantID string `url:"tenant_id,omitempty"`
	Name     string `url:"name,omitempty"`
}

Client structs

type ListTenantsResponse added in v0.1.2

type ListTenantsResponse struct {
	Entries  []*Tenant `json:"entries"`
	PageInfo *PageInfo `json:"page_info"`
}

type ListUsersRequest added in v0.1.10

type ListUsersRequest struct {
	PageSize int    `url:"page_size,omitempty"`
	Before   string `url:"before,omitempty"`
	After    string `url:"after,omitempty"`
}

Client structs

type ListUsersResponse added in v0.1.10

type ListUsersResponse struct {
	Entries  []*User   `json:"entries"`
	PageInfo *PageInfo `json:"page_info"`
}

type MergeUserRequest

type MergeUserRequest struct {
	ID         string
	FromUserID string `json:"from_user_id"`
}

type MergeUserResponse

type MergeUserResponse = GetUserResponse

type Message

type Message struct {
	Cursor     string                 `json:"__cursor"`
	ID         string                 `json:"id"`
	ChannelID  string                 `json:"channel_id"`
	Recipient  string                 `json:"recipient"`
	Workflow   string                 `json:"workflow"`
	Tenant     string                 `json:"tenant"`
	Status     EngagementStatus       `json:"status"`
	ReadAt     time.Time              `json:"read_at"`
	SeenAt     time.Time              `json:"seen_at"`
	ArchivedAt time.Time              `json:"archived_at"`
	InsertedAt time.Time              `json:"inserted_at"`
	UpdatedAt  time.Time              `json:"updated_at"`
	Source     *NotificationSource    `json:"source"`
	Data       map[string]interface{} `json:"data"`
}

type MessageActivity

type MessageActivity struct {
	Cursor    string                 `json:"__cursor"`
	ID        string                 `json:"id"`
	Data      map[string]interface{} `json:"data"`
	Actor     *User                  `json:"actor"`
	Recipient *User                  `json:"recipient"`
}

type MessageContent

type MessageContent struct {
	ID         string                 `json:"id"`
	Data       map[string]interface{} `json:"data"`
	InsertedAt time.Time              `json:"inserted_at"`
}

type MessageEvent

type MessageEvent struct {
	Cursor        string                 `json:"__cursor"`
	ID            string                 `json:"id"`
	EnvironmentID string                 `json:"environment_id"`
	Recipient     string                 `json:"recipient"`
	Data          map[string]interface{} `json:"data"`
}

type MessageStatus

type MessageStatus string
const (
	NotSent    MessageStatus = "seen"
	Read       MessageStatus = "read"
	Archived   MessageStatus = "archived"
	Unarchived MessageStatus = "unarchived"
	Unread     MessageStatus = "unread"
)

type MessagesService

MessagesService is an interface for communicating with the Knock Messages API endpoints.

type MethodOptions added in v0.1.5

type MethodOptions struct {
	IdempotencyKey string
}

type NotificationSource

type NotificationSource struct {
	Key       string `json:"key"`
	VersionID string `json:"version_id"`
}

type Object

type Object struct {
	Collection string                 `json:"collection"`
	ID         string                 `json:"id"`
	Properties map[string]interface{} `json:"properties"`
	UpdatedAt  time.Time              `json:"updated_at"`
	CreatedAt  time.Time              `json:"created_at"`
}

Context structs

type ObjectMessage

type ObjectMessage struct {
	Cursor     string                 `json:"__cursor"`
	ID         string                 `json:"id"`
	ChannelID  string                 `json:"channel_id"`
	Recipient  map[string]interface{} `json:"recipient"`
	Workflow   string                 `json:"workflow"`
	Tenant     string                 `json:"tenant"`
	Status     EngagementStatus       `json:"status"`
	ReadAt     time.Time              `json:"read_at"`
	SeenAt     time.Time              `json:"seen_at"`
	ArchivedAt time.Time              `json:"archived_at"`
	InsertedAt time.Time              `json:"inserted_at"`
	UpdatedAt  time.Time              `json:"updated_at"`
	Source     *NotificationSource    `json:"source"`
	Data       map[string]interface{} `json:"data"`
}

type ObjectSubscription added in v0.1.4

type ObjectSubscription struct {
	Recipient  interface{}            `json:"recipient"`
	Object     Object                 `json:"object"`
	Properties map[string]interface{} `json:"properties"`
	InsertedAt time.Time              `json:"inserted_at"`
	UpdatedAt  time.Time              `json:"updated_at"`
}

type ObjectsService

type ObjectsService interface {
	Get(context.Context, *GetObjectRequest) (*Object, error)
	Set(context.Context, *SetObjectRequest) (*Object, error)
	BulkSet(context.Context, *BulkSetObjectsRequest) (*BulkOperation, error)
	Delete(context.Context, *DeleteObjectRequest) error
	BulkDelete(context.Context, *BulkDeleteObjectsRequest) (*BulkOperation, error)
	List(context.Context, *ListObjectsRequest) ([]*Object, *PageInfo, error)

	GetMessages(context.Context, *GetObjectMessagesRequest) ([]*ObjectMessage, *PageInfo, error)
	GetSchedules(context.Context, *GetObjectSchedulesRequest) ([]*Schedule, *PageInfo, error)
	GetSubscriptions(context.Context, *GetObjectSubscriptionsRequest) ([]*ObjectSubscription, *PageInfo, error)

	GetChannelData(context.Context, *GetObjectChannelDataRequest) (map[string]interface{}, error)
	SetChannelData(context.Context, *SetObjectChannelDataRequest) (map[string]interface{}, error)
	DeleteChannelData(context.Context, *DeleteObjectChannelDataRequest) error

	GetPreferences(context.Context, *GetObjectPreferencesRequest) (*PreferenceSet, error)
	SetPreferences(context.Context, *SetObjectPreferencesRequest) (*PreferenceSet, error)

	AddSubscriptions(context.Context, *AddSubscriptionsRequest) ([]*ObjectSubscription, error)
	BulkAddSubscriptions(context.Context, *BulkAddSubscriptionsRequest) (*BulkOperation, error)
	DeleteSubscriptions(context.Context, *DeleteSubscriptionsRequest) ([]*ObjectSubscription, error)
	ListSubscriptions(context.Context, *ListSubscriptionsRequest) (*ListSubscriptionsResponse, error)
}

ObjectsService is an interface for communicating with the Knock Objects API endpoints.

type PageInfo

type PageInfo struct {
	PageSize int    `json:"page_size,omitempty"`
	Before   string `json:"before,omitempty"`
	After    string `json:"after,omitempty"`
}

type PreferenceSet

type PreferenceSet struct {
	ID           string                 `json:"id"`
	Workflows    map[string]interface{} `json:"workflows,omitempty"`
	Categories   map[string]interface{} `json:"categories,omitempty"`
	ChannelTypes map[string]interface{} `json:"channel_types,omitempty"`
}

type Schedule added in v0.1.6

type Schedule struct {
	Cursor           string                 `json:"__cursor"`
	ID               string                 `json:"id"`
	Recipient        interface{}            `json:"recipient"`
	Repeats          []*ScheduleRepeat      `json:"repeats"`
	Workflow         string                 `json:"workflow"`
	Tenant           string                 `json:"tenant"`
	LastOccurrenceAt time.Time              `json:"last_occurrence_at"`
	NextOccurrenceAt time.Time              `json:"next_occurrence_at"`
	InsertedAt       time.Time              `json:"inserted_at"`
	UpdatedAt        time.Time              `json:"updated_at"`
	Data             map[string]interface{} `json:"data"`
}

type ScheduleRepeat added in v0.1.6

type ScheduleRepeat struct {
	Frequency  string   `json:"frequency"`
	Interval   int      `json:"interval,omitempty"`
	Days       []string `json:"days"`
	DayOfMonth int      `json:"day_of_month,omitempty"`
	Hours      int      `json:"hours,omitempty"`
	Minutes    int      `json:"minutes,omitempty"`
}

type SetObjectChannelDataRequest

type SetObjectChannelDataRequest struct {
	Collection string                 `json:"-"`
	ChannelID  string                 `json:"-"`
	ObjectID   string                 `json:"-"`
	Data       map[string]interface{} `json:"data"`
}

type SetObjectChannelDataResponse

type SetObjectChannelDataResponse = GetUserChannelDataResponse

type SetObjectPreferencesRequest

type SetObjectPreferencesRequest struct {
	PreferenceID string `json:"-"`
	ObjectID     string `json:"-"`
	Collection   string `json:"-"`

	Workflows    map[string]interface{} `json:"workflows,omitempty"`
	ChannelTypes map[string]interface{} `json:"channel_types,omitempty"`
	Categories   map[string]interface{} `json:"categories,omitempty"`
}

func (*SetObjectPreferencesRequest) AddCategoriesPreference added in v0.1.1

func (sr *SetObjectPreferencesRequest) AddCategoriesPreference(categories map[string]interface{}) SetObjectPreferencesRequest

func (*SetObjectPreferencesRequest) AddChannelTypesPreference added in v0.1.1

func (sr *SetObjectPreferencesRequest) AddChannelTypesPreference(channelType map[string]interface{}) SetObjectPreferencesRequest

func (*SetObjectPreferencesRequest) AddWorkflowsPreference added in v0.1.1

func (sr *SetObjectPreferencesRequest) AddWorkflowsPreference(workflows map[string]interface{}) SetObjectPreferencesRequest

type SetObjectPreferencesResponse

type SetObjectPreferencesResponse = GetObjectPreferencesResponse

type SetObjectRequest

type SetObjectRequest struct {
	ID         string                 `json:"-"`
	Collection string                 `json:"-"`
	Properties map[string]interface{} `json:""`
}

type SetObjectResponse

type SetObjectResponse = GetObjectResponse

type SetStatusRequest

type SetStatusRequest struct {
	ID     string
	Status MessageStatus
}

type SetStatusResponse

type SetStatusResponse = GetMessageResponse

type SetTenantRequest added in v0.1.2

type SetTenantRequest struct {
	ID         string                 `json:"-"`
	Properties map[string]interface{} `json:""`
	Settings   map[string]interface{} `json:""`
}

type SetTenantResponse added in v0.1.2

type SetTenantResponse = GetTenantResponse

type SetUserChannelDataRequest

type SetUserChannelDataRequest struct {
	UserID    string                 `json:"-"`
	ChannelID string                 `json:"-"`
	Data      map[string]interface{} `json:"data"`
}

type SetUserChannelDataResponse

type SetUserChannelDataResponse = GetUserChannelDataResponse

type SetUserPreferencesRequest

type SetUserPreferencesRequest struct {
	UserId       string `json:"-"`
	PreferenceID string `json:"-"`

	Workflows    map[string]interface{} `json:"workflows,omitempty"`
	ChannelTypes map[string]interface{} `json:"channel_types,omitempty"`
	Categories   map[string]interface{} `json:"categories,omitempty"`
}

func (*SetUserPreferencesRequest) AddCategoriesPreference added in v0.1.1

func (sr *SetUserPreferencesRequest) AddCategoriesPreference(categories map[string]interface{}) SetUserPreferencesRequest

func (*SetUserPreferencesRequest) AddChannelTypesPreference added in v0.1.1

func (sr *SetUserPreferencesRequest) AddChannelTypesPreference(channelType map[string]interface{}) SetUserPreferencesRequest

func (*SetUserPreferencesRequest) AddWorkflowsPreference added in v0.1.1

func (sr *SetUserPreferencesRequest) AddWorkflowsPreference(workflows map[string]interface{}) SetUserPreferencesRequest

type SetUserPreferencesResponse

type SetUserPreferencesResponse = GetUserPreferencesResponse

type Tenant added in v0.1.2

type Tenant struct {
	ID         string                 `json:"id"`
	Properties map[string]interface{} `json:"properties"`
	Settings   map[string]interface{} `json:"settings"`
	UpdatedAt  time.Time              `json:"updated_at"`
	CreatedAt  time.Time              `json:"created_at"`
}

Context structs

type TenantsService added in v0.1.2

TenantsService is an interface for communicating with the Knock Tenants API endpoints.

type TriggerWorkflowRequest

type TriggerWorkflowRequest struct {
	Workflow        string                 `json:"workflow"`
	Recipients      []interface{}          `json:"recipients"`
	Actor           interface{}            `json:"actor,omitempty"`
	CancellationKey string                 `json:"cancellation_key,omitempty"`
	Tenant          interface{}            `json:"tenant,omitempty"`
	Data            map[string]interface{} `json:"data,omitempty"`
}

Client structs

func (*TriggerWorkflowRequest) AddActorByEntity added in v0.1.1

func (tr *TriggerWorkflowRequest) AddActorByEntity(entity map[string]interface{}) TriggerWorkflowRequest

func (*TriggerWorkflowRequest) AddActorByID added in v0.1.1

func (tr *TriggerWorkflowRequest) AddActorByID(actorID string) TriggerWorkflowRequest

func (*TriggerWorkflowRequest) AddRecipientByEntity added in v0.1.1

func (tr *TriggerWorkflowRequest) AddRecipientByEntity(entity map[string]interface{}) TriggerWorkflowRequest

func (*TriggerWorkflowRequest) AddRecipientByID added in v0.1.1

func (tr *TriggerWorkflowRequest) AddRecipientByID(recipientID string) TriggerWorkflowRequest

func (*TriggerWorkflowRequest) AddTenantByEntity added in v0.1.14

func (tr *TriggerWorkflowRequest) AddTenantByEntity(entity map[string]interface{}) TriggerWorkflowRequest

func (*TriggerWorkflowRequest) AddTenantByID added in v0.1.14

func (tr *TriggerWorkflowRequest) AddTenantByID(tenantID string) TriggerWorkflowRequest

type TriggerWorkflowResponse

type TriggerWorkflowResponse struct {
	WorkflowRunId string `json:"workflow_run_id"`
}

type UpdateSchedulesRequest added in v0.1.6

type UpdateSchedulesRequest struct {
	ScheduleIDs []string               `json:"schedule_ids"`
	Repeats     []*ScheduleRepeat      `json:"repeats"`
	Actor       interface{}            `json:"actor,omitempty"`
	Tenant      interface{}            `json:"tenant,omitempty"`
	ScheduledAt time.Time              `json:"scheduled_at,omitempty"`
	Data        map[string]interface{} `json:"data,omitempty"`
}

func (*UpdateSchedulesRequest) AddActorByEntity added in v0.1.6

func (usr *UpdateSchedulesRequest) AddActorByEntity(entity map[string]interface{}) UpdateSchedulesRequest

func (*UpdateSchedulesRequest) AddActorByID added in v0.1.6

func (usr *UpdateSchedulesRequest) AddActorByID(actorID string) UpdateSchedulesRequest

func (*UpdateSchedulesRequest) AddRepeat added in v0.1.6

func (*UpdateSchedulesRequest) AddTenantByEntity added in v0.1.14

func (usr *UpdateSchedulesRequest) AddTenantByEntity(entity map[string]interface{}) UpdateSchedulesRequest

func (*UpdateSchedulesRequest) AddTenantByID added in v0.1.14

func (usr *UpdateSchedulesRequest) AddTenantByID(tenantID string) UpdateSchedulesRequest

type User

type User struct {
	ID               string    `json:"id"`
	Name             string    `json:"name"`
	Email            string    `json:"email"`
	PhoneNumber      string    `json:"phone_number"`
	Avatar           string    `json:"avatar,omitempty"`
	CreatedAt        time.Time `json:"created_at"`
	UpdatedAt        time.Time `json:"updated_at"`
	CustomProperties map[string]interface{}
}

type UsersService

UsersService is an interface for communicating with the Knock Users API endpoints.

type WorkflowsService

WorkflowsService is an interface for communicating with the Knock Workflows API endpoints.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL