hipchat

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2015 License: GPL-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package hipchat provides a client for using the HipChat API v2.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	BaseURL *url.URL

	// Room gives access to the /room part of the API.
	Room *RoomService
	// User gives access to the /user part of the API.
	User *UserService
	// Emoticon gives access to the /emoticon part of the API.
	Emoticon *EmoticonService
	// contains filtered or unexported fields
}

Client manages the communication with the HipChat API.

func NewClient

func NewClient(authToken string) *Client

NewClient returns a new HipChat API client. You must provide a valid AuthToken retrieved from your HipChat account.

func (*Client) Do

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

Do performs the request, the json received in the response is decoded and stored in the value pointed by v. Do can be used to perform the request created with NewRequest, as the latter it should be used only for API requests not implemented in this library.

func (*Client) NewFileUploadRequest

func (c *Client) NewFileUploadRequest(method, urlStr string, v interface{}) (*http.Request, error)

NewFileUploadRequest creates an API request to upload a file. This method manually formats the request as multipart/related with a single part of content-type application/json and a second part containing the file to be sent. Relative URLs should always be specified without a preceding slash.

func (*Client) NewRequest

func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Request, error)

NewRequest creates an API request. This method can be used to performs API request not implemented in this library. Otherwise it should not be be used directly. Relative URLs should always be specified without a preceding slash.

type CreateRoomRequest

type CreateRoomRequest struct {
	Topic       string `json:"topic,omitempty"`
	GuestAccess bool   `json:"guest_access,omitempty"`
	Name        string `json:"name,omitempty"`
	OwnerUserID string `json:"owner_user_id,omitempty"`
	Privacy     string `json:"privacy,omitempty"`
}

CreateRoomRequest represents a HipChat room creation request.

type CreateWebhookRequest

type CreateWebhookRequest struct {
	Name    string `json:"name"`
	Event   string `json:"event"`
	Pattern string `json:"pattern"`
	URL     string `json:"url"`
}

type Emoticon

type Emoticon struct {
	ID       int    `json:"id"`
	Url      string `json:"url"`
	Links    Links  `json:"links"`
	Shortcut string `json:"shortcut"`
}

Emoticon represents a hipchat emoticon.

type EmoticonService

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

EmoticonService gives access to the emoticon related part of the API.

func (*EmoticonService) List

func (e *EmoticonService) List(start, max int, type_ string) (*Emoticons, *http.Response, error)

List returns the list of all the emoticons

HipChat api docs : https://www.hipchat.com/docs/apiv2/method/get_all_emoticons

type Emoticons

type Emoticons struct {
	Items      []Emoticon `json:"items"`
	StartIndex int        `json:"startIndex"`
	MaxResults int        `json:"maxResults"`
	Links      PageLinks  `json:"links"`
}

Emoticons represents a list of hipchat emoticons.

type History

type History struct {
	Items      []Message `json:"items"`
	StartIndex int       `json:"startIndex"`
	MaxResults int       `json:"maxResults"`
	Links      PageLinks `json:"links"`
}

History represents a HipChat room chat history.

type HistoryRequest

type HistoryRequest struct {
	Date       string `json:"date"`
	Timezone   string `json:"timezone"`
	StartIndex int    `json:"start-index"`
	MaxResults int    `json:"max-results"`
	Reverse    bool   `json:"reverse"`
}

HistoryRequest represents a HipChat room chat history request.

type ID

type ID struct {
	ID string `json:"id"`
}

ID represents a HipChat id. Use a separate struct because it can be a string or a int.

type InviteRequest

type InviteRequest struct {
	Reason string `json:"reason"`
}

InviteRequest represents a hipchat invite to room request

type Links struct {
	Self string `json:"self"`
}

Links represents the HipChat default links.

type ListWebhooksRequest

type ListWebhooksRequest struct {
	MaxResults int `json:"max-results"`
	StartIndex int `json:"start-index"`
}

type Message

type Message struct {
	Date          string      `json:"date"`
	From          interface{} `json:"from"` // string | obj <- weak
	Id            string      `json:"id"`
	Mentions      []User      `json:"mentions"`
	Message       string      `json:"message"`
	MessageFormat string      `json:"message_format"`
	Type          string      `json:"type"`
}

Message represents a HipChat message.

type MessageRequest

type MessageRequest struct {
	Message       string `json:"message,omitempty"`
	Notify        bool   `json:"notify,omitempty"`
	MessageFormat string `json:"message_format,omitempty"`
}

MessageRequest represents a HipChat private message to user.

type NotificationRequest

type NotificationRequest struct {
	Color         string `json:"color,omitempty"`
	Message       string `json:"message,omitempty"`
	Notify        bool   `json:"notify,omitempty"`
	MessageFormat string `json:"message_format,omitempty"`
}

NotificationRequest represents a HipChat room notification request.

type PageLinks struct {
	Links
	Prev string `json:"prev"`
	Next string `json:"next"`
}

PageLinks represents the HipChat page links.

type Room

type Room struct {
	ID                int            `json:"id"`
	Links             RoomLinks      `json:"links"`
	Name              string         `json:"name"`
	XmppJid           string         `json:"xmpp_jid"`
	Statistics        RoomStatistics `json:"statistics"`
	Created           string         `json:"created"`
	IsArchived        bool           `json:"is_archived"`
	Privacy           string         `json:"privacy"`
	IsGuestAccessible bool           `json:"is_guess_accessible"`
	Topic             string         `json:"topic"`
	Participants      []User         `json:"participants"`
	Owner             User           `json:"owner"`
	GuestAccessURL    string         `json:"guest_access_url"`
}

Room represents a HipChat room.

type RoomLinks struct {
	Links
	Webhooks     string `json:"webhooks"`
	Members      string `json:"members"`
	Participants string `json:"participants"`
}

RoomLinks represents the HipChat room links.

type RoomService

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

RoomService gives access to the room related methods of the API.

func (*RoomService) Create

func (r *RoomService) Create(roomReq *CreateRoomRequest) (*Room, *http.Response, error)

Create creates a new room.

HipChat API docs: https://www.hipchat.com/docs/apiv2/method/create_room

func (*RoomService) CreateWebhook

func (r *RoomService) CreateWebhook(id interface{}, roomReq *CreateWebhookRequest) (*Webhook, *http.Response, error)

CreateWebhook creates a new webhook.

HipChat API docs: https://www.hipchat.com/docs/apiv2/method/create_webhook

func (*RoomService) Delete

func (r *RoomService) Delete(id string) (*http.Response, error)

Delete deletes an existing room.

HipChat API docs: https://www.hipchat.com/docs/apiv2/method/delete_room

func (*RoomService) DeleteWebhook

func (r *RoomService) DeleteWebhook(id interface{}, webhookId interface{}) (*http.Response, error)

DeleteWebhook removes the given webhook.

HipChat API docs: https://www.hipchat.com/docs/apiv2/method/delete_webhook

func (*RoomService) Get

func (r *RoomService) Get(id string) (*Room, *http.Response, error)

Get returns the room specified by the id.

HipChat API docs: https://www.hipchat.com/docs/apiv2/method/get_room

func (*RoomService) History

func (r *RoomService) History(id string, roomReq *HistoryRequest) (*History, *http.Response, error)

History fetches a room's chat history.

HipChat API docs: https://www.hipchat.com/docs/apiv2/method/view_room_history

func (*RoomService) Invite

func (r *RoomService) Invite(room string, user string, reason string) (*http.Response, error)

Invite someone to the Room.

HipChat API docs: https://www.hipchat.com/docs/apiv2/method/invite_user

func (*RoomService) List

func (r *RoomService) List() (*Rooms, *http.Response, error)

List returns all the rooms authorized.

HipChat API docs: https://www.hipchat.com/docs/apiv2/method/get_all_rooms

func (*RoomService) ListWebhooks

func (r *RoomService) ListWebhooks(id interface{}, roomReq *ListWebhooksRequest) (*WebhookList, *http.Response, error)

ListWebhooks returns all the webhooks for a given room.

HipChat API docs: https://www.hipchat.com/docs/apiv2/method/get_all_webhooks

func (*RoomService) Notification

func (r *RoomService) Notification(id string, notifReq *NotificationRequest) (*http.Response, error)

Notification sends a notification to the room specified by the id.

HipChat API docs: https://www.hipchat.com/docs/apiv2/method/send_room_notification

func (*RoomService) SetTopic

func (r *RoomService) SetTopic(id string, topic string) (*http.Response, error)

Set Room topic.

HipChat API docs: https://www.hipchat.com/docs/apiv2/method/set_topic

func (*RoomService) ShareFile

func (r *RoomService) ShareFile(id string, shareFileReq *ShareFileRequest) (*http.Response, error)

ShareFile sends a file to the room specified by the id.

HipChat API docs: https://www.hipchat.com/docs/apiv2/method/share_file_with_room

func (*RoomService) Update

func (r *RoomService) Update(id string, roomReq *UpdateRoomRequest) (*http.Response, error)

Update updates an existing room.

HipChat API docs: https://www.hipchat.com/docs/apiv2/method/update_room

type RoomStatistics

type RoomStatistics struct {
	Links Links `json:"links"`
}

RoomStatistics represents the HipChat room statistics.

type Rooms

type Rooms struct {
	Items      []Room    `json:"items"`
	StartIndex int       `json:"startIndex"`
	MaxResults int       `json:"maxResults"`
	Links      PageLinks `json:"links"`
}

Rooms represents a HipChat room list.

type SetTopicRequest

type SetTopicRequest struct {
	Topic string `json:"topic"`
}

SetTopicRequest represents a hipchat update topic request

type ShareFileRequest

type ShareFileRequest struct {
	Path     string `json:"path"`
	Filename string `json:"filename,omitempty"`
	Message  string `json:"message,omitempty"`
}

ShareFileRequest represents a HipChat room file share request.

type UpdateRoomRequest

type UpdateRoomRequest struct {
	Name          string `json:"name"`
	Topic         string `json:"topic"`
	IsGuestAccess bool   `json:"is_guest_access"`
	IsArchived    bool   `json:"is_archived"`
	Privacy       string `json:"privacy"`
	Owner         ID     `json:"owner"`
}

UpdateRoomRequest represents a HipChat room update request.

type User

type User struct {
	XmppJid      string       `json:"xmpp_jid"`
	IsDeleted    bool         `json:"is_deleted"`
	Name         string       `json:"name"`
	LastActive   string       `json:"last_active"`
	Title        string       `json:"title"`
	Presence     UserPresence `json:"presence"`
	Created      string       `json:"created"`
	ID           int          `json:"id"`
	MentionName  string       `json:"mention_name"`
	IsGroupAdmin bool         `json:"is_group_admin"`
	Timezone     string       `json:"timezone"`
	IsGuest      bool         `json:"is_guest"`
	Email        string       `json:"email"`
	PhotoUrl     string       `json:"photo_url"`
	Links        Links        `json:"links"`
}

User represents the HipChat user.

type UserPresence

type UserPresence struct {
	Status   string `json:"status"`
	Idle     int    `json:"idle"`
	Show     string `json:"show"`
	IsOnline bool   `json:"is_online"`
}

UserPresence represents the HipChat user's presence.

type UserService

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

UserService gives access to the user related methods of the API.

func (*UserService) List

func (u *UserService) List(start, max int, guests, deleted bool) ([]User, *http.Response, error)

List returns all users in the group.

HipChat API docs: https://www.hipchat.com/docs/apiv2/method/get_all_users

func (*UserService) Message

func (r *UserService) Message(id string, msgReq *MessageRequest) (*http.Response, error)

Message sends a private message to the user specified by the id.

HipChat API docs: https://www.hipchat.com/docs/apiv2/method/private_message_user

func (*UserService) ShareFile

func (u *UserService) ShareFile(id string, shareFileReq *ShareFileRequest) (*http.Response, error)

ShareFile sends a file to the user specified by the id.

HipChat API docs: https://www.hipchat.com/docs/apiv2/method/share_file_with_user

func (*UserService) View

func (u *UserService) View(id string) (*User, *http.Response, error)

View fetches a user's details.

HipChat API docs: https://www.hipchat.com/docs/apiv2/method/view_user

type Users

type Users struct {
	Items      []User `json:"items"`
	StartIndex int    `json:"start_index"`
	MaxResults int    `json:"max_results"`
	Links      Links  `json:"links"`
}

Users represents the API return of a collection of Users plus metadata

type Webhook

type Webhook struct {
	WebhookLinks WebhookLinks `json:"links"`
	Name         string       `json:"name"`
	Event        string       `json:"event"`
	Pattern      string       `json:"pattern"`
	URL          string       `json:"url"`
	ID           int          `json:"id,omitempty"`
}
type WebhookLinks struct {
	Links
}

type WebhookList

type WebhookList struct {
	Webhooks   []Webhook `json:"items"`
	StartIndex int       `json:"startIndex"`
	MaxResults int       `json:"maxResults"`
	Links      PageLinks `json:"links"`
}

Jump to

Keyboard shortcuts

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