1
0
Fork 0

Only add channel param if specified

main v0.18.2
Jordan Hotmann 2023-12-14 11:27:30 -07:00
parent b0629be093
commit aa7c0d14ab
No known key found for this signature in database
GPG Key ID: 01B504170C2A2EA3
1 changed files with 3 additions and 3 deletions

View File

@ -31,12 +31,12 @@ type GetSnapshotResponse struct {
//
// channel int (optional): the channel index (starts at 1)
func (c *AmcrestClient) GetSnapshot(channel ...int) (GetSnapshotResponse, error) {
cameraChannel := 1
req := c.restClient.R()
if len(channel) > 0 && channel[0] != 0 {
cameraChannel = channel[0]
req.SetQueryParam("channel", fmt.Sprintf("%d", channel[0]))
}
resp, err := util.CheckSuccess(c.restClient.R().SetQueryParam("channel", fmt.Sprintf("%d", cameraChannel)).Get("cgi-bin/snapshot.cgi"))
resp, err := util.CheckSuccess(req.Get("cgi-bin/snapshot.cgi"))
if err != nil {
return GetSnapshotResponse{}, err
}