Code Monkey home page Code Monkey 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>")

rooms, _, err := c.Room.List()
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

Contributors

abachman avatar adampresley avatar danriti avatar ivey avatar joekr avatar koenw avatar mark-adams avatar mkevac avatar ojongerius avatar tbruyelle avatar toashd avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

codeofthrone

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.