client

package
v4.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: AGPL-3.0 Imports: 7 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
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, prov auth.Provider, opts ...Option) (*Client, error)

New creates a new Client instance. It checks if workspace provider is valid, and checks if it's an enterprise workspace. If it is, it creates an edge client.

func Wrap

func Wrap(cl *slack.Client) *Client

Wrap wraps a Slack client and returns a Client that implements the SlackClienter interface. This is useful for testing purposes.

func (*Client) AuthTestContext

func (c *Client) AuthTestContext(ctx context.Context) (response *slack.AuthTestResponse, err error)

AuthTestContext returns the cached workspace information that was captured on initialisation.

func (*Client) Client

func (c *Client) Client() (*slack.Client, bool)

Client returns an underlying slack.Client

func (*Client) Edge added in v4.0.2

func (c *Client) Edge() (*edge.Client, bool)

type Option

type Option func(*options)

func WithEnterprise

func WithEnterprise(enterprise bool) Option

WithEnterprise sets the enterprise flag. Setting the flag to true forces the use of the edge client, even if the workspace is not an enterprise workspace.

type Pool

type Pool struct {
	// contains filtered or unexported fields
}

Pool is a pool of Slack clients that can be used to make API calls. Zero value is not usable, must be initialised with NewPool.

func NewPool

func NewPool(scl ...Slack) *Pool

NewPool wraps the slack.Client with the edge client, so that the edge client can be used as a fallback.

func (*Pool) AuthTestContext

func (p *Pool) AuthTestContext(ctx context.Context) (response *slack.AuthTestResponse, err error)

func (*Pool) GetConversationInfoContext

func (p *Pool) GetConversationInfoContext(ctx context.Context, input *slack.GetConversationInfoInput) (*slack.Channel, error)

func (*Pool) GetConversationRepliesContext

func (p *Pool) GetConversationRepliesContext(ctx context.Context, params *slack.GetConversationRepliesParameters) (msgs []slack.Message, hasMore bool, nextCursor string, err error)

func (*Pool) GetConversationsContext

func (p *Pool) GetConversationsContext(ctx context.Context, params *slack.GetConversationsParameters) (channels []slack.Channel, nextCursor string, err error)

func (*Pool) GetEmojiContext

func (p *Pool) GetEmojiContext(ctx context.Context) (map[string]string, error)

func (*Pool) GetFileContext

func (p *Pool) GetFileContext(ctx context.Context, downloadURL string, writer io.Writer) error

func (*Pool) GetFileInfoContext

func (p *Pool) GetFileInfoContext(ctx context.Context, fileID string, count int, page int) (*slack.File, []slack.Comment, *slack.Paging, error)

func (*Pool) GetStarredContext

func (p *Pool) GetStarredContext(ctx context.Context, params slack.StarsParameters) ([]slack.StarredItem, *slack.Paging, error)

func (*Pool) GetUserInfoContext

func (p *Pool) GetUserInfoContext(ctx context.Context, user string) (*slack.User, error)

func (*Pool) GetUserProfileContext

func (w *Pool) GetUserProfileContext(ctx context.Context, params *slack.GetUserProfileParameters) (*slack.UserProfile, error)

func (*Pool) GetUsersContext

func (p *Pool) GetUsersContext(ctx context.Context, options ...slack.GetUsersOption) ([]slack.User, error)

func (*Pool) GetUsersInConversationContext

func (p *Pool) GetUsersInConversationContext(ctx context.Context, params *slack.GetUsersInConversationParameters) ([]string, string, error)

func (*Pool) GetUsersPaginated

func (p *Pool) GetUsersPaginated(options ...slack.GetUsersOption) slack.UserPagination

func (*Pool) ListBookmarks

func (p *Pool) ListBookmarks(channelID string) ([]slack.Bookmark, error)

func (*Pool) SearchFilesContext

func (p *Pool) SearchFilesContext(ctx context.Context, query string, params slack.SearchParameters) (*slack.SearchFiles, error)

func (*Pool) SearchMessagesContext

func (p *Pool) SearchMessagesContext(ctx context.Context, query string, params slack.SearchParameters) (*slack.SearchMessages, error)

type Slack

type Slack interface {
	AuthTestContext(ctx context.Context) (response *slack.AuthTestResponse, err error)
	GetConversationHistoryContext(ctx context.Context, params *slack.GetConversationHistoryParameters) (*slack.GetConversationHistoryResponse, error)
	GetConversationInfoContext(ctx context.Context, input *slack.GetConversationInfoInput) (*slack.Channel, error)
	GetConversationRepliesContext(ctx context.Context, params *slack.GetConversationRepliesParameters) (msgs []slack.Message, hasMore bool, nextCursor string, err error)
	GetConversationsContext(ctx context.Context, params *slack.GetConversationsParameters) (channels []slack.Channel, nextCursor string, err error)
	GetEmojiContext(ctx context.Context) (map[string]string, error)
	GetFileContext(ctx context.Context, downloadURL string, writer io.Writer) error
	GetFileInfoContext(ctx context.Context, fileID string, count int, page int) (*slack.File, []slack.Comment, *slack.Paging, error)
	GetStarredContext(ctx context.Context, params slack.StarsParameters) ([]slack.StarredItem, *slack.Paging, error)
	GetUserInfoContext(ctx context.Context, user string) (*slack.User, error)
	GetUsersContext(ctx context.Context, options ...slack.GetUsersOption) ([]slack.User, error)
	GetUsersInConversationContext(ctx context.Context, params *slack.GetUsersInConversationParameters) ([]string, string, error)
	GetUsersPaginated(options ...slack.GetUsersOption) slack.UserPagination
	ListBookmarks(channelID string) ([]slack.Bookmark, error)
	SearchFilesContext(ctx context.Context, query string, params slack.SearchParameters) (*slack.SearchFiles, error)
	SearchMessagesContext(ctx context.Context, query string, params slack.SearchParameters) (*slack.SearchMessages, error)
	GetUserProfileContext(ctx context.Context, params *slack.GetUserProfileParameters) (*slack.UserProfile, error)
}

Slack is an interface that defines the methods that a Slack client should provide.

type SlackClienter

type SlackClienter interface {
	Slack
	Client() (*slack.Client, bool)
}

SlackClienter is an extended interface that includes Client method that returns the underlying slack.Client instance.

type SlackEdge

type SlackEdge interface {
	SlackClienter
	Edge() (*edge.Client, bool)
	GetConversationsContextEx(ctx context.Context, params *slack.GetConversationsParameters, onlyMy bool) (channels []slack.Channel, nextCursor string, err error)
}

SlackEdge is an extended interface that includes Edge methods.

func NewEdge

func NewEdge(ctx context.Context, prov auth.Provider, opts ...Option) (SlackEdge, error)

NewEdge returns a new Slack Edge client.

Directories

Path Synopsis
Package mock_client is a generated GoMock package.
Package mock_client is a generated GoMock package.

Jump to

Keyboard shortcuts

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