slack

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Slack

	URL        *url.URL
	HTTPClient *http.Client

	Token string

	Logger *slog.Logger
}

func NewClient

func NewClient(urlStr string, logger *slog.Logger) (*Client, error)

func NewClientForPostFile

func NewClientForPostFile(token string, logger *slog.Logger) (*Client, error)

func (*Client) CompleteUploadExternal

func (c *Client) CompleteUploadExternal(ctx context.Context, params *CompleteUploadExternalParam) error

func (*Client) GetUploadURLExternalURL

func (c *Client) GetUploadURLExternalURL(ctx context.Context, param *GetUploadURLExternalResParam) (uploadURL string, fileID string, err error)

func (*Client) PostFile

func (c *Client) PostFile(ctx context.Context, param *PostFileParam, content []byte) error

func (*Client) PostText

func (c *Client) PostText(ctx context.Context, param *PostTextParam) error

func (*Client) UploadToURL

func (c *Client) UploadToURL(ctx context.Context, filename, uploadURL string, content []byte) error

type CompleteUploadExternalParam

type CompleteUploadExternalParam struct {
	FileID    string
	Title     string
	ChannelID string
}

type CompleteUploadExternalRes

type CompleteUploadExternalRes struct {
	OK    bool `json:"ok"`
	Files []struct {
		ID    string `json:"id"`
		Title string `json:"title"`
	} `json:"files"`
}

type FileSummary

type FileSummary struct {
	ID    string `json:"id"`
	Title string `json:"title,omitempty"`
}

type GetUploadURLExternalRes

type GetUploadURLExternalRes struct {
	OK        bool   `json:"ok"`
	UploadURL string `json:"upload_url"`
	FileID    string `json:"file_id"`
}

type GetUploadURLExternalResParam

type GetUploadURLExternalResParam struct {
	Filename    string
	Length      int
	SnippetType string
	AltText     string
}

type PostFileParam

type PostFileParam struct {
	ChannelID   string
	Filename    string
	AltText     string
	Title       string
	SnippetType string
}

type PostTextParam

type PostTextParam struct {
	Channel   string `json:"channel,omitempty"`
	Username  string `json:"username,omitempty"`
	Text      string `json:"text"`
	IconEmoji string `json:"icon_emoji,omitempty"`
}

type Slack

type Slack interface {
	PostText(ctx context.Context, param *PostTextParam) error
	PostFile(ctx context.Context, param *PostFileParam, content []byte) error
}

Jump to

Keyboard shortcuts

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