hipchat

package
v0.0.0-...-bd47a18 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2015 License: Apache-2.0 Imports: 14 Imported by: 1

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
	// 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 File

type File struct {
	Name     string `json:"name"`
	Size     int    `json:"size"`
	ThumbURL string `json:"thumb_url"`
	URL      string `json:"url"`
}

type GetAllWebhooksRequest

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

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 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 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 RoomMessage

type RoomMessage struct {
	Event string           `json:"event"`
	Item  RoomMessageEvent `json:"item`
}

Represents a room_message webhook event message

func (*RoomMessage) UnmarshallJSON

func (rm *RoomMessage) UnmarshallJSON(data []byte) (err error)

type RoomMessageEvent

type RoomMessageEvent struct {
	Message WebhookMessage `json:"message"`
	Room    WebhookRoom    `json:"room"`
}

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)

Create a new webhook.

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

func (*RoomService) DeleteWebhook

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

Delete a 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) GetAllWebhooks

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

List all webhooks for a given room.

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

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) 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) 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 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"`
}

type WebhookMessage

type WebhookMessage struct {
	Date    string `json:"date"`
	File    *File  `json:"file"`
	Id      string `json:"id"`
	Message string `json:"message"`
	Type    string `json:"type"`
}

type WebhookRoom

type WebhookRoom struct {
	Id    string `json:"id"`
	Links struct {
		Members       string `json:"members"`
		Participtants string `json:"participants"`
		Self          string `json:"self"`
		Webhooks      string `json:"webhooks"`
	}
	Name string `json:"name"`
}

Jump to

Keyboard shortcuts

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