Giter Site home page Giter Site logo

hipchat-go's Introduction

hipchat-go

Go client library for the HipChat API v2.

GoDoc Build Status

Currently only a small part of the API is implemented, so pull requests are welcome.

Usage

import "github.com/tbruyelle/hipchat-go/hipchat"

Build a new client, then use the client.Room service to spam all the rooms you have access to (not recommended):

c := hipchat.NewClient("<your AuthToken here>")

opt := &hipchat.RoomsListOptions{IncludePrivate:  true, IncludeArchived: true}
rooms, _, err := c.Room.List(opt)
if err != nil {
	panic(err)
}

notifRq := &hipchat.NotificationRequest{Message: "Hey there!"}

for _, room := range rooms.Items {
	_, err := c.Room.Notification(room.Name, notifRq)
	if err != nil {
		panic(err)
	}
}

Testing the auth token

HipChat allows to test the auth token by adding the auth_test=true param, into any API endpoints.

You can do this with hipchat-go by setting the global var hipchat.AuthTest. Because the server response will be different from the one defined in the API endpoint, you need to check another global var AuthTestReponse to see if the authentication succeeds.

hipchat.AuthTest = true

client.Room.Get(42)

_, ok := hipchat.AuthTestResponse["success"]
fmt.Println("Authentification succeed :", ok)
// Dont forget to reset the variable, or every other API calls
// will be impacted.
hipchat.AuthTest = false

The code architecture is hugely inspired by google/go-github.

hipchat-go's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hipchat-go's Issues

Breaking change for GetAllWebhook

For consistency I renamed GetAllWebhooks to ListWebhooks, sorry for the annoyance.

You can rename the method call in your code, or you can change the import to http://gopkg.in/tbruyelle/hipchat-go.v1/hipchat, where the method is still named GetAllWebhooks.

I can't make a message with new line

I tried the following and none of them work

notifyHipchat("/code This \n is \n a \n message")
notifyHipchat("This \n is \n a \n message")
notifyHipchat("This \\n is \\n a \\n message")
notifyHipchat(`This
 is
 a
 message`)
notifyHipchat(`This \nis \na \nmessage`)

Using any HTTP client in hipchat.Client

Hi,

I'm considering using this library on a Google App Engine module, so I want to use hipchat.Client with an HTTP client returned by urlfetch.Client function. But, as of now, hipchat.Client always uses http.DefaultClient and there's no way to replace it.

I believe it would be really useful if an HTTP client can be specified to hipchat.NewClient like go-github.NewClient. I understand this could be a breaking change, however, following it is very easy and it is just to replace hipchat.NewClient(token) with hipchat.NewClient(nil, token). Just adding a method like SetHTTPClient(*http.Client) to hipchat.Client might be enough if such breaking change is not acceptable

Does anyone have any thoughts on this?

If one of the above suggestions is acceptable, I can work on a PR to make changes accordingly.

using Card in Notification

Hi Dev team this is not really an issue but a request. Are you able to provide a working example of notification with Card object. When I add card object in my notification, I get HTTP 400 error. Not sure why. My goal is to post a notification with link where when the user click the link it will open a dialog displaying some text. Thank you!

Enhancement proposal feedback

I think the project could be improved adding convenience methods to the objects instead of passing id's through the relevant services.

Examples would be:

func (r *Room) History(opt *HistoryOptions)
func (r *Room) Message(msgReq *RoomMessageRequest) (*http.Response, error)

With a flow like:

room := client.Room.get("123")
room.History(&hipchat.HistoryOptions{})

This could be achieved by adding the service to the struct and then create some wrapper methods.

type Room struct {
	...
	GuestAccessURL    string         `json:"guest_access_url"`
	roomService       *RoomService
}
func (r *Room) History(opt *HistoryOptions) (*History, *http.Response, error) {
	return r.roomService.History(strconv.Itoa(r.ID), opt)
}

library throws away temporary/permanent error information

If I use this library to send a message it currently throws away the HTTP status code. It's not possible to know from the error if the error is temporary or permanent. For example, on network errors and 5xx I want to try again. Possible solutions is always returning the http client even on errors or alternatively creating an error type that can be interrogated for temporariness.

Insecure SSL connection

Hello!
This package can't work other insecure connections. In some cases (like proxy) it's necessary.
Implement this feature please.

bot can post notification to hipchat rooms but hipchat not able to send request to bot server.

Hi Dev team,
This is not an issue, I just need you expert advise on how to configure my bot developed with this package. The bot I developed is deployed in a company owned dev env. The bot is running on port 443 and was able to send notification to HipChat rooms. Unfortunately, the bot is not receiving any request coming from HipChat.

When I test in my local machine using ngrok to expose my bot, it works fine w\o issue. But when I deploy to our dev env w\o ngrok, the issue occurs.

What could be the requirement in order for HipChat to send request to my bot?
Do I need certificates? Should the HipChat server have network access to the bot server?
I lack knowledge in this area and appreciate any advise.

Many thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.