Example #1
0
func (w *DbusRestWrapper) SendNotification(name, parameters string, priority uint64) *dbus.Error {
	say.Verbosef("SendNotification(name='%s',params='%s',priority=%d)\n", name, parameters, priority)
	dat, err := parseJSON(parameters)

	if err != nil {
		return newDHError(err.Error())
	}

	rest.DeviceNotificationInsert(w.URL, w.DeviceID, w.AccessKey, name, dat)

	return nil
}
func main() {
	name := "TestRestNotification"
	parameters := map[string]interface{}{"key1": "value1"}

	f, c, err := conf.FromArgs()
	if err != nil {
		say.Infof("Load conf err: %s", err.Error())
		return
	}

	say.Infof("Conf(%s): %+v", f, c)

	dnir, err := rest.DeviceNotificationInsert(c.URL, c.DeviceID, c.AccessKey, name, parameters)

	if err != nil {
		say.Infof("Error: %s", err.Error())
	} else {
		say.Infof("Ok: %+v", dnir)
	}
}