slackrest

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MessageResponsePool     *sync.Pool
	MessageResponseItemPool *sync.Pool
)
View Source
var ErrorResponsePool *sync.Pool
View Source
var MessagePayloadPool *sync.Pool

Functions

This section is empty.

Types

type Client

type Client interface {
	Do(*http.Request) (*http.Response, error)
}

type ErrorResponse

type ErrorResponse struct {
	Ok  bool   `json:"ok"`
	Err string `json:"error"`
}

func (*ErrorResponse) Error

func (err *ErrorResponse) Error() string

func (*ErrorResponse) IsNil

func (r *ErrorResponse) IsNil() bool

IsNil checks if instance is nil

func (*ErrorResponse) MarshalJSONObject

func (r *ErrorResponse) MarshalJSONObject(enc *gojay.Encoder)

MarshalJSONObject implements MarshalerJSONObject

func (*ErrorResponse) NKeys

func (r *ErrorResponse) NKeys() int

NKeys returns the number of keys to unmarshal

func (*ErrorResponse) Reset

func (r *ErrorResponse) Reset()

Reset reset fields

func (*ErrorResponse) UnmarshalJSONObject

func (r *ErrorResponse) UnmarshalJSONObject(dec *gojay.Decoder, k string) error

UnmarshalJSONObject implements gojay's UnmarshalerJSONObject

type FileResponse

type FileResponse struct {
	Id                 string     `json:"id"`
	Created            int        `json:"created"`
	Timestamp          int        `json:"timestamp"`
	Name               string     `json:"name"`
	Title              string     `json:"title"`
	Mimetype           string     `json:"mimetype"`
	Filetype           string     `json:"filetype"`
	PrettyType         string     `json:"pretty_type"`
	User               string     `json:"user"`
	Editable           bool       `json:"editable"`
	Size               int        `json:"size"`
	Mode               string     `json:"mode"`
	IsExternal         bool       `json:"is_external"`
	ExternalType       string     `json:"external_type"`
	IsPublic           bool       `json:"is_public"`
	PublicUrlShared    bool       `json:"public_url_shared"`
	DisplayAsBot       bool       `json:"display_as_bot"`
	Username           string     `json:"username"`
	UrlPrivate         string     `json:"url_private"`
	UrlPrivateDownload string     `json:"url_private_download"`
	Thumb64            string     `json:"thumb_64"`
	Thumb80            string     `json:"thumb_80"`
	Thumb360           string     `json:"thumb_360"`
	Thumb360W          int        `json:"thumb_360_w"`
	Thumb360H          int        `json:"thumb_360_h"`
	Thumb480           string     `json:"thumb_480"`
	Thumb480W          int        `json:"thumb_480_w"`
	Thumb480H          int        `json:"thumb_480_h"`
	Thumb160           string     `json:"thumb_160"`
	ImageExifRotation  int        `json:"image_exif_rotation"`
	OriginalW          int        `json:"original_w"`
	OriginalH          int        `json:"original_h"`
	Permalink          string     `json:"permalink"`
	PermalinkPublic    string     `json:"permalink_public"`
	CommentsCount      int        `json:"comments_count"`
	IsStarred          bool       `json:"is_starred"`
	Shares             FileShares `json:"shares"`
	Channels           []string   `json:"channels"`
	Groups             []string   `json:"groups"`
	Ims                []string   `json:"ims"`
	HasRichPreview     bool       `json:"has_rich_preview"`
}

type FileShares

type FileShares struct {
	Private map[string][]FileThread `json:"private"`
	Public  map[string][]FileThread `json:"public"`
}

type FileThread

type FileThread struct {
	ReplyUsers      []interface{} `json:"reply_users"`
	ReplyUsersCount int           `json:"reply_users_count"`
	ReplyCount      int           `json:"reply_count"`
	Ts              string        `json:"ts"`
}

type FilesUploadPayload

type FilesUploadPayload struct {
	Channels       []string
	Content        string
	File           io.Reader
	Filename       string
	Filetype       string
	InitialComment string
	ThreadTS       string
	Title          string
}

func (FilesUploadPayload) FormData

func (f FilesUploadPayload) FormData(writer io.Writer) error

type FilesUploadResponse

type FilesUploadResponse struct {
	Ok   bool         `json:"ok"`
	File FileResponse `json:"file"`
}

func FileUpload

func FileUpload(ctx context.Context, client Client, payload FilesUploadPayload) (resp FilesUploadResponse, err error)

FileUpload uploads file to slack.

type MessageParseOption

type MessageParseOption string

type MessagePayload

type MessagePayload struct {
	Channel        string                      `json:"channel"`
	Text           string                      `json:"text"`
	Blocks         block.Blocks                `json:"blocks"`
	Attachments    []gojay.MarshalerJSONObject `json:"attachments"`
	AsUser         bool                        `json:"as_user"`
	IconEmoji      string                      `json:"icon_emoji"`
	IconURL        string                      `json:"icon_url"`
	LinkNames      bool                        `json:"link_names"`
	Metadata       gojay.MarshalerJSONArray    `json:"metadata"`
	Mrkdwn         bool                        `json:"mrkdwn"`
	Parse          MessageParseOption          `json:"parse"`
	ReplyBroadcast bool                        `json:"reply_broadcast"`
	ThreadTS       string                      `json:"thread_ts"`
	UnfurlLinks    bool                        `json:"unfurl_links"`
	UnfurlMedia    bool                        `json:"unfurl_media"`
	Username       string                      `json:"username"`
}

See https://api.slack.com/methods/chat.postMessage for details.

func (MessagePayload) IsNil

func (m MessagePayload) IsNil() bool

func (MessagePayload) MarshalJSONObject

func (m MessagePayload) MarshalJSONObject(enc *gojay.Encoder)

func (*MessagePayload) Reset

func (m *MessagePayload) Reset()

type MessageResponse

type MessageResponse struct {
	Ok      bool                `json:"ok"`
	Channel string              `json:"channel"`
	Ts      string              `json:"ts"`
	Message MessageResponseItem `json:"message"`
}

func PostMessage

func PostMessage(ctx context.Context, client Client, token string, payload *MessagePayload) (resp *MessageResponse, err error)

PostMessage Posts Message to Slack. This is not for messages with file attachments.

func (*MessageResponse) IsNil

func (r *MessageResponse) IsNil() bool

IsNil checks if instance is nil

func (*MessageResponse) MarshalJSONObject

func (r *MessageResponse) MarshalJSONObject(enc *gojay.Encoder)

MarshalJSONObject implements MarshalerJSONObject

func (*MessageResponse) NKeys

func (r *MessageResponse) NKeys() int

NKeys returns the number of keys to unmarshal

func (*MessageResponse) Release

func (i *MessageResponse) Release()

func (*MessageResponse) Reset

func (r *MessageResponse) Reset()

Reset reset fields

func (*MessageResponse) UnmarshalJSONObject

func (r *MessageResponse) UnmarshalJSONObject(dec *gojay.Decoder, k string) error

UnmarshalJSONObject implements gojay's UnmarshalerJSONObject

type MessageResponseItem

type MessageResponseItem struct {
	Text        string          `json:"text"`
	Username    string          `json:"username"`
	BotID       string          `json:"bot_id"`
	Attachments json.RawMessage `json:"attachments"`
	Type        string          `json:"type"`
	Subtype     string          `json:"subtype"`
	Ts          string          `json:"ts"`
}

func (*MessageResponseItem) IsNil

func (i *MessageResponseItem) IsNil() bool

IsNil checks if instance is nil

func (*MessageResponseItem) MarshalJSONObject

func (i *MessageResponseItem) MarshalJSONObject(enc *gojay.Encoder)

MarshalJSONObject implements MarshalerJSONObject

func (*MessageResponseItem) NKeys

func (i *MessageResponseItem) NKeys() int

NKeys returns the number of keys to unmarshal

func (*MessageResponseItem) Reset

func (i *MessageResponseItem) Reset()

Reset reset fields

func (*MessageResponseItem) UnmarshalJSONObject

func (i *MessageResponseItem) UnmarshalJSONObject(dec *gojay.Decoder, k string) error

UnmarshalJSONObject implements gojay's UnmarshalerJSONObject

Jump to

Keyboard shortcuts

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