This project implements a Go client library for the Hipchat API.

Overview

Hipchat

This project implements a Go client library for the Hipchat API (API version 2 is not supported).

Pull requests are welcome as the API is limited to only a few calls right now.

API documentation can be found on godoc.org.

Star this or get at me on the Twitters if you end up using this since this is pretty early stage and I may make breaking changes to the API. – @andybons

Installing

Run

go get github.com/andybons/hipchat

Example usage:

package main

import (
	"github.com/andybons/hipchat"
	"log"
)

func main() {
	c := hipchat.NewClient("<PUT YOUR AUTH TOKEN HERE>")
	req := hipchat.MessageRequest{
		RoomId:        "Rat Man's Den",
		From:          "GLaDOS",
		Message:       "Bad news: Combustible lemons failed.",
		Color:         hipchat.ColorPurple,
		MessageFormat: hipchat.FormatText,
		Notify:        true,
	}

	if err := c.PostMessage(req); err != nil {
		log.Printf("Expected no error, but got %q", err)
	}
}

Setting a custom HipChat Server:

c := hipchat.NewClient("<AUTH TOKEN>")
c.BaseURL = "https://your.host.name/v1"
...

Use customized proxy settings In case you need to use transport other than http.DefaultTransport:

c := hipchat.NewClient("<AUTH TOKEN>")

proxyURL, err := url.Parse("<PROXY_URL:PROXY_PORT>")
if err != nil {
	log.Fatalf("Expected no error, but got %q", err)
}
c.Transport = &http.Transport{Proxy: http.ProxyURL(proxyURL)}

Contributors

Issues
  • Change Client to take base URL as argument, add tests

    Change Client to take base URL as argument, add tests

    Change how callers construct Clients to make testing easier. Then add tests for:

    • [x] Posting
    • [x] Fetching room history
    • [x] Listing rooms

    This addresses part of (1) in andybons/hipchat#1. Since we're adding tests anyways, I also added a Travis config file and badge.

    opened by akshayjshah 5
  • Version 2.0: export interface and add tests

    Version 2.0: export interface and add tests

    This is the re-worked, leaner, meaner version of #2. It makes a few breaking changes, so it's tucked away in /v2/. Changes:

    1. Client constructor takes a Config struct. This allows callers to specify just an auth token, but lets us alter the base URL in the test code.
    2. Client constructor returns an interface, not a concrete type. This enables the next item.
    3. Add a Mock that satisfies the Client interface. Callers can use the mock in their own test code.
    4. Add tests for all methods on the real client and the mock. Per the built-in coverage tools, test coverage is a little over 93%.
    5. Move the example into the test code, so it's compiler-verified and integrated into the docs.
    opened by akshayjshah 4
  • Improve error handling

    Improve error handling

    • Return optionally structured errors with more information.
    if hcErr, ok := err.(hipchat.Error); ok {
        log.Printf("[%d] %q", hcErr.Code, hcErr.Message)
    }
    
    • Actually return the error if a message wasn't posted.

    This removes the human friendly error message being reported by https://github.com/andybons/hipchat/issues/8 and returns a standard Hipchat.Error instead.

    opened by keyneston 3
  • x509: certificate signed by unknown authority

    x509: certificate signed by unknown authority

    I got this error when running your script from Debian 7 :

    go run hipchat.go 
    2015/10/22 09:22:41 Expected no error, but got "x509: certificate signed by unknown authority"
    

    Script :

    package main
    
    import (
        "github.com/andybons/hipchat"
        "log"
    )
    
    func main() {
        c := hipchat.NewClient("xxxx")
        req := hipchat.MessageRequest{
            RoomId:        "xxxx",
            From:          "GoLang",
            Message:       "Bad news: Combustible lemons failed.",
            Color:         hipchat.ColorPurple,
            MessageFormat: hipchat.FormatText,
            Notify:        true,
        }
    
        if err := c.PostMessage(req); err != nil {
            log.Printf("Expected no error, but got %q", err)
        }
    }
    
    opened by gallart 2
  • PostMessage: response 'status' field was not 'sent'.

    PostMessage: response 'status' field was not 'sent'.

    I keep getting the following when sending a message using the example:

    2014/11/17 10:47:38 Expected no error, but got "PostMessage: response 'status' field was not 'sent'."
    

    My example is as follows

    package main
    
    import (
        "github.com/andybons/hipchat"
        "log"
    )
    
    func main() {
        c := hipchat.Client{AuthToken: "xxxxxx"}
        req := hipchat.MessageRequest{
            RoomId:        "VCS Source",
            From:          "Aspect",
            Message:       "Bad news: Combustible lemons failed.",
            Color:         hipchat.ColorPurple,
            MessageFormat: hipchat.FormatText,
            Notify:        true,
        }
    
        if err := c.PostMessage(req); err != nil {
            log.Printf("Expected no error, but got %q", err)
        }
    }
    

    I have also tried an admin token, a room token, and a neither work

    opened by johntdyer 2
  • JIRA + GAE

    JIRA + GAE

    Hi Andy, let me know if you're interested in these changes. Keep in mind that this breaks the the PostMessage function. func (c *Client) PostMessage(m MessageRequest, h http.Client) error

    I'm flexible on a lot of this.

    opened by corytodd 2
  • Open to a refactoring to support unit tests and a polling client?

    Open to a refactoring to support unit tests and a polling client?

    Hey @andybons,

    Thanks for this library! I'm using it for some internal tools, and it's been great. Two questions:

    1. Are you open to a refactoring to make testing easier? I'd like to add both tests for this code and a mock Client implementation that callers can use in their tests.
    2. I've written a polling client (runs in its own goroutine, polls for messages and pushes them onto a channel). I find it convenient - are you open to integrating it into this library as a second client type?
    opened by akshayjshah 2
  • Add Custom Proxy settings for specialize environment

    Add Custom Proxy settings for specialize environment

    When hipchat-go client runs inside Private DC and need proxy settings to connect internet or particular development environment this settings are necessary

    opened by rr-paras-patel 1
  • Add AuthTest support for messages

    Add AuthTest support for messages

    This will allow rooms/message API calls to use the 'auth_test' flag described here: https://www.hipchat.com/docs/api/auth

    The response type is different than a normal request. Catch the 'success' vs 'error' response and return the error if present (nil if successfully authenticated).

    opened by gtosh4 1
  • Can now set a Url endpoint different than base

    Can now set a Url endpoint different than base

    Added a feature that allows you to specify a different endpoint Url when creating a Client struct. The code will use it if it is not blank. If it is the code defaults to the baseUrl.

    opened by adampresley 1
  • Add MIT license

    Add MIT license

    In the middle of working on the v2 code we discussed, I realized that this project isn't open-source. Mind adding a license?

    This PR adds the MIT license, but feel free to add whichever you'd like (or keep the code closed).

    opened by akshayjshah 1
Owner
Andrew Bonventre
Andrew Bonventre
Clusterpedia-client - clusterpedia-client supports the use of native client-go mode to call the clusterpedia API

clusterpedia-client supports the use of native client-go mode to call the cluste

Calvin Chen 4 Jan 7, 2022
Client-go - Clusterpedia-client supports the use of native client-go mode to call the clusterpedia API

clusterpedia-client supports the use of native client-go mode to call the cluste

clusterpedia.io 8 Aug 6, 2022
Package rhymen/go-whatsapp implements the WhatsApp Web API to provide a clean interface for developers

go-whatsapp Package rhymen/go-whatsapp implements the WhatsApp Web API to provide a clean interface for developers. Big thanks to all contributors of

Relldev メイ 3 Mar 19, 2022
Godaddy - This package implements the libdns interfaces for the Godaddy API

Godaddy for libdns This package implements the libdns interfaces for the Godaddy

null 1 Jan 26, 2022
GoStorm is a Go library that implements the communications protocol required to write Storm spouts and Bolts in Go that communicate with the Storm shells.

gostorm godocs GoStorm is a Go library that implements the communications protocol required for non-Java languages to communicate as part of a storm t

John Gilmore 128 Nov 2, 2021
This library implements the pub/sub pattern in a generic way. It uses Go's generic types to declare the type of the event.

observer This library implements the pub/sub pattern in a generic way. It uses Go's generic types to declare the type of the event. Usage go get githu

Leon Steinhäuser 4 Jun 15, 2022
A Go client implementing a client-side distributed consumer group client for Amazon Kinesis.

Kinesumer is a Go client implementing a client-side distributed consumer group client for Amazon Kinesis.

당근마켓 65 Aug 16, 2022
Nutanix-client-go - Go client for the Nutanix Prism V3 API

nutanix-client-go This repository contains portions of the Nutanix API client code in nutanix/terraform-provider-nutanix. It has been extracted to red

Marvin Beckers 0 Jan 6, 2022
Aoe4-client - Client library for aoe4 leaderboards etc

AOE4 Client Overview This is a go client used to query AOE4 data from either the

Mark Smith 0 Jan 18, 2022
Go client for the YNAB API. Unofficial. It covers 100% of the resources made available by the YNAB API.

YNAB API Go Library This is an UNOFFICIAL Go client for the YNAB API. It covers 100% of the resources made available by the YNAB API. Installation go

Bruno Souza 52 Jul 15, 2022
An API client for the Notion API implemented in Golang

An API client for the Notion API implemented in Golang

Anatoly Nosov 316 Aug 8, 2022
A Wrapper Client for Google Spreadsheet API (Sheets API)

Senmai A Wrapper Client for Google Spreadsheet API (Sheets API) PREPARATION Service Account and Key File Create a service account on Google Cloud Plat

ytnobody / satoshi azuma 0 Nov 5, 2021
A project template for a weather client in Go

A project template for a weather client in Go

John Arundel 6 Jun 30, 2022
A very simple local client-server calculator project built using Cobra and socket programming, written in Go.

Golculator Introduction A very simple local client-server calculator project built using Cobra and socket programming, written in Go. Setup and run Fi

Amir Iravanimanesh 8 Apr 3, 2022
Go Client Library for Amazon Product Advertising API

go-amazon-product-advertising-api Go Client Library for Amazon Product Advertising API How to Use go get -u github.com/ngs/go-amazon-product-advertisi

Atsushi NAGASE 53 Aug 3, 2022
A Go client library for the Twitter 1.1 API

Anaconda Anaconda is a simple, transparent Go package for accessing version 1.1 of the Twitter API. Successful API queries return native Go structs th

Aditya Mukerjee 1.1k Aug 9, 2022
Go client library for interacting with Coinpaprika's API

Coinpaprika API Go Client Usage This library provides convenient way to use coinpaprika.com API in Go. Coinpaprika delivers full market data to the wo

Coinpaprika 15 Aug 8, 2022
Package githubv4 is a client library for accessing GitHub GraphQL API v4 (https://developer.github.com/v4/).

githubv4 Package githubv4 is a client library for accessing GitHub GraphQL API v4 (https://docs.github.com/en/graphql). If you're looking for a client

null 909 Aug 17, 2022
Client library for UptimeRobot v2 API

uptimerobot uptimerobot is a Go library and command-line client for the Uptime Robot website monitoring service. It allows you to search for existing

John Arundel 49 Aug 13, 2022