Code cleanup.

This commit is contained in:
Jeff Walter 2018-09-19 16:41:00 -05:00
parent e4006df88a
commit 533202c8b9
3 changed files with 5 additions and 7 deletions

View File

@ -94,7 +94,7 @@ func (a *Arlo) GetDevices() (Devices, error) {
deviceResponse.Data[i].arlo = a deviceResponse.Data[i].arlo = a
} }
// Unsubscribe all of the basestations to the EventStream. // Unsubscribe all of the basestations from the EventStream.
for i := range a.Basestations { for i := range a.Basestations {
if err := a.Basestations[i].Unsubscribe(); err != nil { if err := a.Basestations[i].Unsubscribe(); err != nil {
return nil, errors.WithMessage(err, "failed to get devices") return nil, errors.WithMessage(err, "failed to get devices")

View File

@ -3,7 +3,6 @@ package arlo
import ( import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"fmt"
"net/http" "net/http"
"sync" "sync"
@ -51,7 +50,6 @@ func (e *EventStream) Listen() (connected chan bool) {
go func() { go func() {
err := e.SSEClient.SubscribeChanRaw(e.Events) err := e.SSEClient.SubscribeChanRaw(e.Events)
if err != nil { if err != nil {
fmt.Println(FAILED_TO_SUBSCRIBE)
e.Error <- FAILED_TO_SUBSCRIBE e.Error <- FAILED_TO_SUBSCRIBE
} }

View File

@ -39,7 +39,7 @@ type Library []Recording
func (a *Arlo) GetLibraryMetaData(fromDate, toDate time.Time) (*LibraryMetaDataResponse, error) { func (a *Arlo) GetLibraryMetaData(fromDate, toDate time.Time) (*LibraryMetaDataResponse, error) {
body := map[string]string{"dateFrom": fromDate.Format("20060102"), "dateTo": toDate.Format("20060102")} body := map[string]string{"dateFrom": fromDate.Format("20060102"), "dateTo": toDate.Format("20060102")}
resp, err := a.client.Post(LibraryMetadataUri, body, nil) resp, err := a.post(LibraryMetadataUri, "", body, nil)
if err != nil { if err != nil {
return nil, errors.WithMessage(err, "failed to get library metadata") return nil, errors.WithMessage(err, "failed to get library metadata")
@ -56,7 +56,7 @@ func (a *Arlo) GetLibraryMetaData(fromDate, toDate time.Time) (*LibraryMetaDataR
func (a *Arlo) GetLibrary(fromDate, toDate time.Time) (*LibraryResponse, error) { func (a *Arlo) GetLibrary(fromDate, toDate time.Time) (*LibraryResponse, error) {
body := map[string]string{"dateFrom": fromDate.Format("20060102"), "dateTo": toDate.Format("20060102")} body := map[string]string{"dateFrom": fromDate.Format("20060102"), "dateTo": toDate.Format("20060102")}
resp, err := a.client.Post(LibraryUri, body, nil) resp, err := a.post(LibraryUri, "", body, nil)
if err != nil { if err != nil {
return nil, errors.WithMessage(err, "failed to get library") return nil, errors.WithMessage(err, "failed to get library")
} }
@ -79,7 +79,7 @@ func (a *Arlo) GetLibrary(fromDate, toDate time.Time) (*LibraryResponse, error)
func (a *Arlo) DeleteRecording(r Recording) (*Error, error) { func (a *Arlo) DeleteRecording(r Recording) (*Error, error) {
body := map[string]Library{"data": {r}} body := map[string]Library{"data": {r}}
resp, err := a.client.Post(LibraryRecycleUri, body, nil) resp, err := a.post(LibraryRecycleUri, "", body, nil)
if err != nil { if err != nil {
return nil, errors.WithMessage(err, "failed to delete recording") return nil, errors.WithMessage(err, "failed to delete recording")
} }
@ -102,7 +102,7 @@ func (a *Arlo) DeleteRecording(r Recording) (*Error, error) {
func (a *Arlo) BatchDeleteRecordings(l Library) (*Error, error) { func (a *Arlo) BatchDeleteRecordings(l Library) (*Error, error) {
body := map[string]Library{"data": l} body := map[string]Library{"data": l}
resp, err := a.client.Post(LibraryRecycleUri, body, nil) resp, err := a.post(LibraryRecycleUri, "", body, nil)
if err != nil { if err != nil {
return nil, errors.WithMessage(err, "failed to delete recordings") return nil, errors.WithMessage(err, "failed to delete recordings")
} }