slack

package
v0.0.0-...-e91b8ae Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2015 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Channel

type Channel struct {
	ID          string           `json:"id,omitempty"`
	Name        string           `json:"name,omitempty"`
	IsChannel   bool             `json:"is_channel,omitempty"`
	Created     Timestamp        `json:"created,omitempty"`
	Creator     string           `json:"creator,omitempty"`
	IsArchived  bool             `json:"is_archived,omitempty"`
	IsGeneral   bool             `json:"is_general,omitempty"`
	IsMember    bool             `json:"is_member,omitempty"`
	Topic       Topic            `json:"topic,omitempty"`
	Members     []string         `json:"members,omitempty"`
	Purpose     Purpose          `json:"purpose,omitempty"`
	NumMembers  int              `json:"num_members,omitempty"`
	Latest      Message          `json:"latest,omitempty"`
	LastRead    MessageTimestamp `json:"last_read,omitempty"`
	UnreadCount int              `json:"unread_count,omitempty"`
}

Channel represents a Slack channel.

type ChannelOptions

type ChannelOptions struct {
	Channel string `url:"channel,omitempty"`
	Name    string `url:"name,omitempty"`
	Pretty  bool   `url:"pretty,int,omitempty"`
}

type ChannelsService

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

ChannelsService handles channel-related API requests.

func (*ChannelsService) History

func (s *ChannelsService) History(ch string, opts *HistoryOptions) (*History, *http.Response, error)

History retrieves the message history of a channel.

func (*ChannelsService) Info

func (s *ChannelsService) Info(id string, opts *ChannelOptions) (*Channel, *http.Response, error)

Info retrieves a channel.

func (*ChannelsService) List

func (s *ChannelsService) List() ([]Channel, *http.Response, error)

List returns a slice of Channels, the raw http.Response, and an optional error.

func (*ChannelsService) Rename

func (s *ChannelsService) Rename(id, name string, opts *ChannelOptions) (*Channel, *http.Response, error)

Rename sets a channel's name, optionally returning an error.

type Client

type Client struct {
	Team    string
	APIKey  string
	BaseURL *url.URL

	Channels *ChannelsService
	// contains filtered or unexported fields
}

func New

func New(team, key string) *Client

New creates a new slack.Client and returns a pointer to it.

func NewClient

func NewClient(team, key string, httpClient *http.Client) *Client

func (*Client) Do

func (c *Client) Do(req *http.Request, output interface{}) (*http.Response, error)

Do performs the request

func (*Client) Get

func (c *Client) Get(path string, output interface{}) (*http.Response, error)

func (*Client) NewRequest

func (c *Client) NewRequest(meth string, path string, input interface{}) (*http.Request, error)

NewRequest builds an http.Request, resolves relative URLs, and sets HTTP headers

type ErrorResponse

type ErrorResponse struct {
	Response *http.Response
	Ok       bool   `json:"ok"`
	Message  string `json:"error"`
}

func Error

func Error(err error) *ErrorResponse

Error takes an error interface and attempts to assert it is of type *slack.ErrorResponse, returning the ErrorResponse if possible, or nil if not.

func (*ErrorResponse) Error

func (r *ErrorResponse) Error() string

type History

type History struct {
	Messages []Message `json:"messages,omitempty"`
	HasMore  bool      `json:"has_more,omitempty"`
}

History is the result type for any history request.

type HistoryOptions

type HistoryOptions struct {
	Channel string `url:"channel"`
	Latest  string `url:"latest,omitempty"`
	Oldest  string `url:"oldest,omitempty"`
	Count   int    `url:"count,omitempty"`
}

HistoryOptions is an options type that modifies the history query for channels, groups, and IMs.

type Info

type Info struct {
	Value   string `json:"value,omitempty"`
	Creator string `json:"creator,omitempty"`
	LastSet Timestamp
}

Info provides a generic type for additional data

type Message

type Message struct {
	Text      string           `json:"text,omitempty"`
	Username  string           `json:"username,omitempty"`
	Type      string           `json:"type,omitempty"`
	Subtype   string           `json:"subtype,omitempty"`
	Timestamp MessageTimestamp `json:"ts,omitempty"`
}

Message type

type MessageTimestamp

type MessageTimestamp time.Time

func (MessageTimestamp) MarshalJSON

func (t MessageTimestamp) MarshalJSON() ([]byte, error)

func (*MessageTimestamp) UnmarshalJSON

func (t *MessageTimestamp) UnmarshalJSON(b []byte) error

type Purpose

type Purpose Info

Purpose type for Channel.Purpose

type Timestamp

type Timestamp time.Time

Timestamp is a custom time.Time type to convert Slack's use of seconds-since-epoch timestamps

func (*Timestamp) MarshalJSON

func (t *Timestamp) MarshalJSON() ([]byte, error)

MarshalJSON implements the json encoder interface

func (*Timestamp) String

func (t *Timestamp) String() string

func (*Timestamp) UnmarshalJSON

func (t *Timestamp) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json decoder interface

type Topic

type Topic Info

Topic type for Channel.Topic

Jump to

Keyboard shortcuts

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