caitlinelfring / databox-go

Go wrapper for Databox Push API

Home Page:http://databox.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Databox bindings for Go

Go wrapper for Databox - Mobile Executive Dashboard.

Build Status ReportCard

Installation

go install github.com/databox/databox-go
go get github.com/databox/databox-go # or this. :)

Usage

package main

import (
	databox "github.com/databox/databox-go"
	"fmt"
)

func main() {
	client := databox.NewClient("<push token>")

	if status, _ := client.Push(&databox.KPI{
		Key:	"temp.ny",
		Value: 	52.0,
		Date: 	"2015-01-01 09:00:00",
	}); len(status.Errors) == 0 {
		fmt.Println("Inserted.")
	}

	if data, _ := client.LastPush(); data != nil {
		fmt.Println(string(data))
	}

	// Additional attributes
	var attributes = make(map[string]interface{})
	attributes["test.number"] = 10
	attributes["test.string"] = "Oto Brglez"

	if status, _ := client.Push(&KPI{
		Key: "testing.this",
		Value: 10.0,
		Date: time.Now().Format(time.RFC3339),
		Attributes: attributes,
	}); len(status.Errors) > 0 {
		fmt.Println("This status contains errors")
	}

	// Retriving last push
	lastPush, err := client.LastPush()
	if err != nil {
		fmt.Println("Error was raised", err)
	}

	fmt.Println("Number of errors in last push", lastPush.NumberOfErrors)
}

Author

Oto Brglez

Contributions

About

Go wrapper for Databox Push API

http://databox.com


Languages

Language:Go 98.7%Language:Makefile 1.3%