aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--schedule.go10
-rw-r--r--schedule_test.go4
2 files changed, 10 insertions, 4 deletions
diff --git a/schedule.go b/schedule.go
index a98358a..8c49de2 100644
--- a/schedule.go
+++ b/schedule.go
@@ -32,7 +32,7 @@ type Schedule struct {
}
// Bridge.GetSchedules will get Alarms and Timers in a Schedule struct.
-func (bridge *Bridge) GetSchedules() ([]Schedule, error) {
+func (bridge *Bridge) GetAllSchedules() ([]Schedule, error) {
uri := fmt.Sprintf("/api/%s/schedules", bridge.Username)
body, _, err := bridge.Get(uri)
if err != nil {
@@ -68,7 +68,13 @@ func (bridge *Bridge) GetSchedule(id string) (Schedule, error) {
if err != nil {
return Schedule{}, err
}
- return Schedule{}, nil
+
+ schedule := Schedule{}
+ err = json.Unmarshal(body, &schedule)
+ if err != nil {
+ return Schedule{}, err
+ }
+ return schedule, nil
}
// func (bridge *Bridge) CreateSchedule(schedule interface{}) error {
diff --git a/schedule_test.go b/schedule_test.go
index 6618b27..fdb3df7 100644
--- a/schedule_test.go
+++ b/schedule_test.go
@@ -11,9 +11,9 @@ import (
"testing"
)
-func TestGetSchedules(t *testing.T) {
+func TestGetAllSchedules(t *testing.T) {
bridge, _ := NewBridge("192.168.1.128", "427de8bd6d49f149c8398e4fc08f")
- _, _ = bridge.GetSchedules()
+ _, _ = bridge.GetAllSchedules()
}
func TestGetSchedule(t *testing.T) {