Documentation
¶
Index ¶
- func ExitCodeFor(slackErr string) int
- type APIError
- type Client
- func (c *Client) Call(method string, params map[string]string, body []byte) ([]byte, error)
- func (c *Client) CallAll(method string, params map[string]string, maxPages int) ([][]byte, error)
- func (c *Client) CallMultipart(method string, fields map[string]string, fileField, filename string, ...) ([]byte, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExitCodeFor ¶
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.
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 (*Client) Call ¶
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 ¶
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.