示例#1
0
func ExampleNewAPI_changingPermissions() {
	api, err := geotrigger.NewAPI(clientID, clientSecret)
	if err != nil {
		log.Println("error connecting to geotrigger api:", err)
		return
	}
	p, err := api.Permissions()
	if err != nil {
		panic(err)
	}
	fmt.Println("TriggerUpdate:", p.TriggerUpdate)

	p.TriggerUpdate = !p.TriggerUpdate
	if err = api.SetPermissions(p); err != nil {
		panic(err)
	}

	p, err = api.Permissions()
	if err != nil {
		panic(err)
	}
	fmt.Println("TriggerUpdate:", p.TriggerUpdate)

	// Output:
	// foo
}
示例#2
0
func ExampleNewAPI_listDevices() {
	api, err := geotrigger.NewAPI(clientID, clientSecret)
	if err != nil {
		log.Println("error connecting to geotrigger api:", err)
		return
	}
	devices, err := api.Devices(nil)
	if err != nil {
		panic(err)
	}
	fmt.Printf("devices: %+v\n", devices)
	// Output:
	// foo
}