webhook

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2021 License: BSD-2-Clause Imports: 1 Imported by: 0

Documentation

Overview

See https://github.com/ninchat/ninchat-go/blob/master/webhook/example/processor.go for an example.

Index

Constants

View Source
const (
	MetadataNinchat = "ninchat"
	MetadataRating  = "rating"
	MetadataSecure  = "secure"
	MetadataTagIDs  = "tag_ids"
	MetadataVars    = "vars"
)

Well-known metadata keys.

View Source
const AudNinchat = "https://ninchat.com"
View Source
const (
	SecureMetadataIdentifier = "identifier"
)

Well-known secure metadata keys.

Variables

This section is empty.

Functions

This section is empty.

Types

type Audience

type Audience struct {
	RequestTime  float64                   `json:"request_time,omitempty"` // Always present in event; never in response.
	AcceptTime   float64                   `json:"accept_time,omitempty"`
	FinishTime   float64                   `json:"finish_time,omitempty"`
	CompleteTime float64                   `json:"complete_time,omitempty"`
	Members      map[string]AudienceMember `json:"members,omitempty"` // Always present in event; never in response.
	Metadata     Metadata                  `json:"metadata"`
}

type AudienceAccepted

type AudienceAccepted struct {
	RealmID    string   `json:"realm_id"`
	QueueID    string   `json:"queue_id"`
	AudienceID string   `json:"audience_id"`
	Audience   Audience `json:"audience"`
	DialogueID []string `json:"dialogue_id,omitempty"`
	ChannelID  string   `json:"channel_id,omitempty"`
}

type AudienceComplete

type AudienceComplete struct {
	RealmID               string              `json:"realm_id"`
	QueueID               string              `json:"queue_id"`
	AudienceID            string              `json:"audience_id"`
	Audience              Audience            `json:"audience"`
	DialogueID            []string            `json:"dialogue_id,omitempty"`
	ChannelID             string              `json:"channel_id,omitempty"`
	MemberMessageMetadata map[string]Metadata `json:"member_message_metadata"`
	Messages              []Message           `json:"messages,omitempty"`
}

type AudienceCompleteResponse added in v1.3.0

type AudienceCompleteResponse struct {
	TranscriptDeleteTime int64 `json:"transcript_delete_time,omitempty"`
}

type AudienceMember

type AudienceMember struct {
	Agent    bool `json:"agent,omitempty"`
	Customer bool `json:"customer,omitempty"`
}

type AudienceRequested added in v1.3.0

type AudienceRequested struct {
	RealmID    string   `json:"realm_id"`
	QueueID    string   `json:"queue_id"`
	AudienceID string   `json:"audience_id"`
	Audience   Audience `json:"audience"`
}

type ChannelInfoPayload

type ChannelInfoPayload struct {
	ChannelAttrsOldJSON map[string]json.RawMessage `json:"channel_attrs_old"`
	ChannelAttrsNewJSON map[string]json.RawMessage `json:"channel_attrs_new"`
}

type DataAccess added in v1.3.0

type DataAccess struct {
	RealmID   string `json:"realm_id,omitempty"`
	ChannelID string `json:"channel_id,omitempty"`
	Query     Query  `json:"query"`
}

type DataAccessResponse added in v1.3.0

type DataAccessResponse struct {
	Audience              *Audience           `json:"audience,omitempty"`
	MemberMessageMetadata map[string]Metadata `json:"member_message_metadata"`
	Messages              []Message           `json:"messages,omitempty"`
}

type EventType

type EventType string
const (
	EventWebhookVerification EventType = "webhook_verification"
	EventAudienceRequested   EventType = "audience_requested"
	EventAudienceAccepted    EventType = "audience_accepted"
	EventAudienceComplete    EventType = "audience_complete"
	EventDataAccess          EventType = "data_access"
)

type File

type File struct {
	FileID        string                     `json:"file_id"`
	FileAttrsJSON map[string]json.RawMessage `json:"file_attrs"`
}

type FilePayload

type FilePayload struct {
	Text  *string `json:"text,omitempty"`
	Files []File  `json:"files"`
}

type JoinInfoPayload

type JoinInfoPayload struct {
	UserID         string  `json:"user_id"`
	UserName       *string `json:"user_name,omitempty"`
	MemberSilenced bool    `json:"member_silenced,omitempty"`
}

type MemberInfoPayload

type MemberInfoPayload struct {
	UserID         string  `json:"user_id"`
	UserName       *string `json:"user_name,omitempty"`
	MemberSilenced bool    `json:"member_silenced,omitempty"`
}

type Message

type Message struct {
	ID       string      `json:"id"`
	Time     float64     `json:"time,omitempty"` // Always present in event, may be omitted in response.
	Type     MessageType `json:"type,omitempty"` // Always present in event, may be omitted in response.
	UserID   string      `json:"user_id,omitempty"`
	UserName *string     `json:"user_name,omitempty"`
	Fold     bool        `json:"fold,omitempty"`

	PayloadJSON json.RawMessage `json:"payload"`
}

func (*Message) ChannelInfoPayload

func (m *Message) ChannelInfoPayload() (p ChannelInfoPayload, err error)

func (*Message) FilePayload

func (m *Message) FilePayload() (p FilePayload, err error)

func (*Message) JoinInfoPayload

func (m *Message) JoinInfoPayload() (p JoinInfoPayload, err error)

func (*Message) MemberInfoPayload

func (m *Message) MemberInfoPayload() (p MemberInfoPayload, err error)

func (*Message) MetadataPayload

func (m *Message) MetadataPayload() (p MetadataPayload, err error)

func (*Message) NoticePayload

func (m *Message) NoticePayload() (p NoticePayload, err error)

func (*Message) PartInfoPayload

func (m *Message) PartInfoPayload() (p PartInfoPayload, err error)

func (*Message) TextPayload

func (m *Message) TextPayload() (p TextPayload, err error)

func (*Message) UIActionPayload

func (m *Message) UIActionPayload() (p UIActionPayload, err error)

func (*Message) UIComposePayload

func (m *Message) UIComposePayload() (p UIComposePayload, err error)

func (*Message) UserInfoPayload

func (m *Message) UserInfoPayload() (p UserInfoPayload, err error)

type MessageType

type MessageType string
const (
	MessageFile        MessageType = "ninchat.com/file"
	MessageChannelInfo MessageType = "ninchat.com/info/channel"
	MessageJoinInfo    MessageType = "ninchat.com/info/join"
	MessageMemberInfo  MessageType = "ninchat.com/info/member"
	MessagePartInfo    MessageType = "ninchat.com/info/part"
	MessageUserInfo    MessageType = "ninchat.com/info/user"
	MessageMetadata    MessageType = "ninchat.com/metadata"
	MessageNotice      MessageType = "ninchat.com/notice"
	MessageText        MessageType = "ninchat.com/text"
	MessageUIAction    MessageType = "ninchat.com/ui/action"
	MessageUICompose   MessageType = "ninchat.com/ui/compose"
)

type MessagesQuery added in v1.3.0

type MessagesQuery struct {
	MinID string `json:"min_id,omitempty"`
	MaxID string `json:"max_id,omitempty"`
}

type Metadata

type Metadata map[string]json.RawMessage

func (Metadata) Ninchat

func (toplevel Metadata) Ninchat() (ninchat Metadata, err error)

func (Metadata) Secure

func (toplevel Metadata) Secure() (secure Metadata, err error)

Secure metadata unmarshaling may fail e.g. if it's not an object but some other type of JSON value.

type MetadataPayload

type MetadataPayload struct {
	Data Metadata `json:"data"`
	Time float64  `json:"time,omitempty"`
}

type NoticePayload

type NoticePayload struct {
	TextPayload
}

type PartInfoPayload

type PartInfoPayload struct {
	UserID   string  `json:"user_id"`
	UserName *string `json:"user_name,omitempty"`
	Cause    string  `json:"cause,omitempty"`
}

type Query added in v1.3.0

type Query struct {
	AudienceMetadata      bool           `json:"audience.metadata,omitempty"`
	MemberMessageMetadata bool           `json:"member_message_metadata,omitempty"`
	Messages              *MessagesQuery `json:"messages,omitempty"`
}

type TextPayload

type TextPayload struct {
	Text string `json:"text"`
}

type UIActionPayload

type UIActionPayload struct {
	Action string    `json:"action"`
	Target UICompose `json:"target"`
}

type UICompose

type UICompose struct {
	Class   string `json:"class,omitempty"`
	Element string `json:"element"`
	ID      string `json:"id,omitempty"`
	Label   string `json:"label,omitempty"`
	Name    string `json:"name,omitempty"`
}

type UIComposePayload

type UIComposePayload []UICompose

type UserInfoPayload

type UserInfoPayload struct {
	UserID      string  `json:"user_id"`
	UserName    *string `json:"user_name,omitempty"`
	UserNameOld *string `json:"user_name_old,omitempty"`
	UserDeleted bool    `json:"user_deleted,omitempty"`
}

type Webhook

type Webhook struct {
	// Kid and Exp are specified only for transports which use signatures
	// (i.e. they are specified for HTTP, but not for AWS Lambda functions).
	Kid string `json:"kid,omitempty"`
	Exp int64  `json:"exp,omitempty"`

	Aud     string    `json:"aud"`
	Event   EventType `json:"event"`
	EventID string    `json:"event_id"`

	// Raw JSON event fields can be used to store the data in lossless form.
	WebhookVerificationJSON json.RawMessage `json:"webhook_verification,omitempty"`
	AudienceRequestedJSON   json.RawMessage `json:"audience_requested,omitempty"`
	AudienceAcceptedJSON    json.RawMessage `json:"audience_accepted,omitempty"`
	AudienceCompleteJSON    json.RawMessage `json:"audience_complete,omitempty"`
	DataAccessJSON          json.RawMessage `json:"data_access,omitempty"`
}

func (*Webhook) AudienceAccepted

func (doc *Webhook) AudienceAccepted() (event AudienceAccepted, err error)

func (*Webhook) AudienceComplete

func (doc *Webhook) AudienceComplete() (event AudienceComplete, err error)

func (*Webhook) AudienceRequested added in v1.3.0

func (doc *Webhook) AudienceRequested() (event AudienceRequested, err error)

func (*Webhook) DataAccess added in v1.3.0

func (doc *Webhook) DataAccess() (event DataAccess, err error)

func (*Webhook) WebhookVerificationResponse added in v1.3.0

func (doc *Webhook) WebhookVerificationResponse() (content []byte)

type WebhookVerificationResponse added in v1.3.0

type WebhookVerificationResponse struct {
	Aud                     string          `json:"aud"`
	WebhookVerificationJSON json.RawMessage `json:"webhook_verification"`
}

Jump to

Keyboard shortcuts

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