Documentation ¶
Overview ¶
Package hipchat provides a client for using the HipChat API v2.
Index ¶
- Constants
- Variables
- type Client
- func (c *Client) Do(req *http.Request, v interface{}) (*http.Response, error)
- func (c *Client) GenerateToken(credentials ClientCredentials, scopes []string) (*OAuthAccessToken, *http.Response, error)
- func (c *Client) NewFileUploadRequest(method, urlStr string, v interface{}) (*http.Request, error)
- func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Request, error)
- type ClientCredentials
- type CreateRoomRequest
- type CreateWebhookRequest
- type Emoticon
- type EmoticonService
- type Emoticons
- type History
- type HistoryRequest
- type ID
- type InviteRequest
- type LatestHistoryRequest
- type Links
- type ListWebhooksRequest
- type Message
- type MessageRequest
- type NotificationRequest
- type OAuthAccessToken
- type PageLinks
- type Room
- type RoomLinks
- type RoomService
- func (r *RoomService) Create(roomReq *CreateRoomRequest) (*Room, *http.Response, error)
- func (r *RoomService) CreateWebhook(id interface{}, roomReq *CreateWebhookRequest) (*Webhook, *http.Response, error)
- func (r *RoomService) Delete(id string) (*http.Response, error)
- func (r *RoomService) DeleteWebhook(id interface{}, webhookID interface{}) (*http.Response, error)
- func (r *RoomService) Get(id string) (*Room, *http.Response, error)
- func (r *RoomService) History(id string, roomReq *HistoryRequest) (*History, *http.Response, error)
- func (r *RoomService) Invite(room string, user string, reason string) (*http.Response, error)
- func (r *RoomService) Latest(id string, roomReq *LatestHistoryRequest) (*History, *http.Response, error)
- func (r *RoomService) List() (*Rooms, *http.Response, error)
- func (r *RoomService) ListWebhooks(id interface{}, roomReq *ListWebhooksRequest) (*WebhookList, *http.Response, error)
- func (r *RoomService) Notification(id string, notifReq *NotificationRequest) (*http.Response, error)
- func (r *RoomService) SetTopic(id string, topic string) (*http.Response, error)
- func (r *RoomService) ShareFile(id string, shareFileReq *ShareFileRequest) (*http.Response, error)
- func (r *RoomService) Update(id string, roomReq *UpdateRoomRequest) (*http.Response, error)
- type RoomStatistics
- type Rooms
- type SetTopicRequest
- type ShareFileRequest
- type UpdateRoomRequest
- type User
- type UserPresence
- type UserService
- func (u *UserService) List(start, max int, guests, deleted bool) ([]User, *http.Response, error)
- func (u *UserService) Message(id string, msgReq *MessageRequest) (*http.Response, error)
- func (u *UserService) ShareFile(id string, shareFileReq *ShareFileRequest) (*http.Response, error)
- func (u *UserService) View(id string) (*User, *http.Response, error)
- type Users
- type Webhook
- type WebhookList
Constants ¶
const ( // ScopeAdminGroup - Perform group administrative tasks ScopeAdminGroup = "admin_group" // ScopeAdminRoom - Perform room administrative tasks ScopeAdminRoom = "admin_room" // ScopeImportData - Import users, rooms, and chat history. Only available for select add-ons. ScopeImportData = "import_data" // ScopeManageRooms - Create, update, and remove rooms ScopeManageRooms = "manage_rooms" // ScopeSendMessage - Send private one-on-one messages ScopeSendMessage = "send_message" // ScopeSendNotification - Send room notifications ScopeSendNotification = "send_notification" // ScopeViewGroup - View users, rooms, and other group information ScopeViewGroup = "view_group" // ScopeViewMessages - View messages from chat rooms and private chats you have access to ScopeViewMessages = "view_messages" // ScopeViewRoom - View room information and participants, but not history ScopeViewRoom = "view_room" )
Variables ¶
var AuthTest = false
AuthTest can be set to true to test an auth token.
HipChat API docs: https://www.hipchat.com/docs/apiv2/auth#auth_test
var AuthTestResponse = map[string]interface{}{}
AuthTestResponse will contain the server response of any API calls if AuthTest=true.
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 ¶
NewClient returns a new HipChat API client. You must provide a valid AuthToken retrieved from your HipChat account.
func NewCustomClient ¶
NewClient returns a new HipChat API client for custom url, not default hipchat one. You must provide URl of hipchat server and a valid AuthToken retrieved from your HipChat account.
func (*Client) Do ¶
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) GenerateToken ¶
func (c *Client) GenerateToken(credentials ClientCredentials, scopes []string) (*OAuthAccessToken, *http.Response, error)
GenerateToken returns back an access token for a given integration's client ID and client secret
HipChat API documentation: https://www.hipchat.com/docs/apiv2/method/generate_token
func (*Client) NewFileUploadRequest ¶
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 ¶
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 ClientCredentials ¶
ClientCredentials represents the OAuth2 client ID and secret for an integration
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"` }
CreateWebhookRequest represents the body of the CreateWebhook method.
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 ¶
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 Timezone string StartIndex int MaxResults int Reverse bool }
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 LatestHistoryRequest ¶
LatestHistoryRequest represents a HipChat room chat latest history request.
type Links ¶
type Links struct {
Self string `json:"self"`
}
Links represents the HipChat default links.
type ListWebhooksRequest ¶
ListWebhooksRequest represents options for ListWebhooks method.
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 OAuthAccessToken ¶
type OAuthAccessToken struct { AccessToken string `json:"access_token"` ExpiresIn uint32 `json:"expires_in"` GroupID uint32 `json:"group_id"` GroupName string `json:"group_name"` Scope string `json:"scope"` TokenType string `json:"token_type"` }
OAuthAccessToken represents a newly created Hipchat OAuth access token
func (*OAuthAccessToken) CreateClient ¶
func (t *OAuthAccessToken) CreateClient() *Client
CreateClient creates a new client from this OAuth token
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 ¶
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 ¶
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 ¶
Invite someone to the Room.
HipChat API docs: https://www.hipchat.com/docs/apiv2/method/invite_user
func (*RoomService) Latest ¶
func (r *RoomService) Latest(id string, roomReq *LatestHistoryRequest) (*History, *http.Response, error)
Latest fetches a room's chat history.
HipChat API docs: https://www.hipchat.com/docs/apiv2/method/view_recent_room_history
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 ¶
SetTopic sets 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 {}
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 ¶
List returns all users in the group.
HipChat API docs: https://www.hipchat.com/docs/apiv2/method/get_all_users
func (*UserService) Message ¶
func (u *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 ¶
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