api

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: May 24, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExitCodeFor

func ExitCodeFor(slackErr string) int

ExitCodeFor maps a Slack error string to a slk exit code.

Types

type APIError

type APIError struct {
	Method     string // Slack method, e.g. "conversations.history"
	SlackError string // Slack "error" field, e.g. "channel_not_found"
}

APIError is a structured failure from a Slack Web API call.

func (*APIError) Error

func (e *APIError) Error() string

func (*APIError) ExitCode

func (e *APIError) ExitCode() int

ExitCode returns the process exit code for this error.

type Client

type Client struct {
	Token      string
	BaseURL    string // overridable for tests; default https://slack.com/api
	HTTP       *http.Client
	MaxRetries int // rate-limit retries
}

Client is a thin Slack Web API HTTP client.

func New

func New(token string) *Client

New returns a Client for the given token.

func (*Client) Call

func (c *Client) Call(method string, params map[string]string, body []byte) ([]byte, error)

Call invokes a Slack method. params become POST form fields; if body is non-nil it is sent as a JSON body instead. Returns the raw response bytes.

func (*Client) CallAll

func (c *Client) CallAll(method string, params map[string]string, maxPages int) ([][]byte, error)

CallAll repeatedly calls method, following response_metadata.next_cursor, until the cursor is empty or maxPages is reached. Returns one raw response per page.

func (*Client) CallMultipart added in v0.4.0

func (c *Client) CallMultipart(method string, fields map[string]string, fileField, filename string, data []byte) ([]byte, error)

CallMultipart invokes a Slack method with a multipart/form-data body carrying text fields plus a single file part. Used by methods that take a binary upload (e.g. users.setPhoto with the `image` field). Returns the raw response bytes.

Jump to

Keyboard shortcuts

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