aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCollin Guarino <collin.guarino@gmail.com>2016-02-14 19:05:47 -0500
committerCollin Guarino <collin.guarino@gmail.com>2016-02-14 19:05:47 -0500
commitf985fc200641b55526c2f094d9bf5ddafd030727 (patch)
tree3c2d5b8a84032c155032a082325bb56b86649659
parent5c230f73b5d481dd21a52877395e63739897cb58 (diff)
Renamed Bridge.GetSchedules to Bridge.GetAllSchedules for clarify between that and Bridge.GetSchedule (singular).
-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) {