-
Notifications
You must be signed in to change notification settings - Fork 0
/
delete.go
48 lines (40 loc) · 1.12 KB
/
delete.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright 2021 To Levan Giguashvili. All rights reserved.
// Use of this source code is governed by a MIT
// license that can be found in the LICENSE file.
package sensibo
import (
"context"
"fmt"
)
// DeleteDeviceTimer deletes the timer on the device.
//
// id is the ID of the device
//
// It returns the direct response from Sensibo API as a string or error
// if an issue occurred
func (s *Sensibo) DeleteDeviceTimer(ctx context.Context, id string) (string, error) {
resp, err := s.makeDeleteRequest(
ctx,
"v1",
fmt.Sprintf("pods/%s/timer", id),
)
if err != nil {
return "", fmt.Errorf("failed deleting timer: \n\t%v", err)
}
return resp, nil
}
// DeleteDeviceSchedule deletes a schedule.
//
// It returns the direct response from Sensibo API as a string or error
// if an issue occurred
func (s *Sensibo) DeleteDeviceSchedule(ctx context.Context, deviceID string, scheduleID string) (string, error) {
resp, err := s.makeDeleteRequest(
ctx,
"v1",
fmt.Sprintf("pods/%s/schedules/%s", deviceID, scheduleID),
)
if err != nil {
return "", fmt.Errorf("failed deleting schedule: \n\t%v", err)
}
return resp, nil
}