api

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeaderContentType = "Content-Type"

	ContentTypeJSON            = "application/json"                // Accept
	ContentTypeJSONCharsetUTF8 = "application/json; charset=utf-8" // Content-Type
	ContentTypeForm            = "application/x-www-form-urlencoded"
)

Variables

This section is empty.

Functions

func Post added in v0.14.1

func Post(ctx context.Context, botToken, slackMethod string, body, resp any) error

Post is a helper function to make an HTTP POST request with a JSON body to the Slack API. Use case 1: connection initialization (AuthTest and AppsConnectionsOpen API calls). Use case 2: send updates to Slack webhooks when we finish processing interaction events (https://api.slack.com/interactivity/handling#updating_message_response).

Types

type AppsConnectionsOpenResponse added in v0.14.1

type AppsConnectionsOpenResponse struct {
	SlackResponse

	URL string `json:"url"`
}

https://api.slack.com/methods/apps.connections.open#examples

func AppsConnectionsOpen added in v0.14.1

func AppsConnectionsOpen(ctx context.Context, appToken string) (*AppsConnectionsOpenResponse, error)

AppsConnectionsOpen generates a temporary WebSocket URL for a Socket Mode app, to check the usability of an app-level token provided by the user. Based on: https://api.slack.com/methods/apps.connections.open Required Slack app scope: https://api.slack.com/scopes/connections:write

type AuthTestResponse added in v0.14.1

type AuthTestResponse struct {
	SlackResponse

	URL                 string `json:"url"`
	Team                string `json:"team"`
	User                string `json:"user"`
	TeamID              string `json:"team_id"`
	UserID              string `json:"user_id"`
	BotID               string `json:"bot_id"`
	EnterpriseID        string `json:"enterprise_id,omitempty"`
	IsEnterpriseInstall bool   `json:"is_enterprise_install"`
}

https://api.slack.com/methods/auth.test#examples

func AuthTest added in v0.14.1

func AuthTest(ctx context.Context, botToken string) (*AuthTestResponse, error)

AuthTest checks the caller's authentication & identity. Based on: https://api.slack.com/methods/auth.test (no scopes required).

type Bot added in v0.14.1

type Bot struct {
	ID      string            `json:"id"`
	Deleted bool              `json:"deleted"`
	Name    string            `json:"name"`
	Updated int               `json:"updated"`
	AppID   string            `json:"app_id"`
	UserID  string            `json:"user_id"`
	Icons   map[string]string `json:"icons"`
}

https://api.slack.com/methods/bots.info#examples

func BotsInfo added in v0.14.1

func BotsInfo(ctx context.Context, botToken string, authTest *AuthTestResponse) (*Bot, error)

BotsInfo gets information about a bot user. Based on: https://api.slack.com/methods/bots.info Required Slack app scope: https://api.slack.com/scopes/users:read

type BotsInfoResponse added in v0.14.1

type BotsInfoResponse struct {
	SlackResponse

	Bot Bot `json:"bot"`
}

https://api.slack.com/methods/bots.info#examples

type ResponseMetadata

type ResponseMetadata struct {
	Messages   []string `json:"messages,omitempty"`
	Warnings   []string `json:"warnings,omitempty"`
	NextCursor string   `json:"next_cursor,omitempty"`
}

type SlackResponse

type SlackResponse struct {
	OK               bool              `json:"ok"`
	Warning          string            `json:"warning,omitempty"`
	Error            string            `json:"error,omitempty"`
	ResponseMetadata *ResponseMetadata `json:"response_metadata,omitempty"`
}

Directories

Path Synopsis
Package chat is a lightweight wrapper over the "chat" methods in Slack's Web API: https://api.slack.com/methods?filter=chat.
Package chat is a lightweight wrapper over the "chat" methods in Slack's Web API: https://api.slack.com/methods?filter=chat.
Package conversations is a lightweight wrapper over the "conversations" methods in Slack's Web API: https://api.slack.com/methods?filter=conversations.
Package conversations is a lightweight wrapper over the "conversations" methods in Slack's Web API: https://api.slack.com/methods?filter=conversations.
Package users is a lightweight wrapper over the "users" methods in Slack's Web API: https://api.slack.com/methods?filter=users.
Package users is a lightweight wrapper over the "users" methods in Slack's Web API: https://api.slack.com/methods?filter=users.

Jump to

Keyboard shortcuts

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