diff --git a/rest/record.go b/rest/record.go index fe7b475..364f078 100644 --- a/rest/record.go +++ b/rest/record.go @@ -5,7 +5,6 @@ import ( "fmt" "net/http" - "gopkg.in/ns1/ns1-go.v2/rest/model/data" "gopkg.in/ns1/ns1-go.v2/rest/model/dns" ) @@ -26,9 +25,9 @@ func (s *RecordsService) Get(zone, domain, t string) (*dns.Record, *http.Respons var r dns.Record resp, err := s.client.Do(req, &r) if err != nil { - switch err.(type) { + switch err := err.(type) { case *Error: - if err.(*Error).Message == "record not found" { + if err.Message == "record not found" { return nil, resp, ErrRecordMissing } } @@ -45,11 +44,6 @@ func (s *RecordsService) Get(zone, domain, t string) (*dns.Record, *http.Respons func (s *RecordsService) Create(r *dns.Record) (*http.Response, error) { path := fmt.Sprintf("zones/%s/%s/%s", r.Zone, r.Domain, r.Type) - // the current API can't deal with nulls and this is not omitempty - if r.Regions == nil { - r.Regions = data.Regions{} - } - req, err := s.client.NewRequest("PUT", path, &r) if err != nil { return nil, err @@ -58,9 +52,9 @@ func (s *RecordsService) Create(r *dns.Record) (*http.Response, error) { // Update record fields with data from api(ensure consistent) resp, err := s.client.Do(req, &r) if err != nil { - switch err.(type) { + switch err := err.(type) { case *Error: - switch err.(*Error).Message { + switch err.Message { case "zone not found": return resp, ErrZoneMissing case "record already exists": @@ -80,11 +74,6 @@ func (s *RecordsService) Create(r *dns.Record) (*http.Response, error) { func (s *RecordsService) Update(r *dns.Record) (*http.Response, error) { path := fmt.Sprintf("zones/%s/%s/%s", r.Zone, r.Domain, r.Type) - // the current API can't deal with nulls and this is not omitempty - if r.Regions == nil { - r.Regions = data.Regions{} - } - req, err := s.client.NewRequest("POST", path, &r) if err != nil { return nil, err @@ -93,9 +82,9 @@ func (s *RecordsService) Update(r *dns.Record) (*http.Response, error) { // Update records fields with data from api(ensure consistent) resp, err := s.client.Do(req, &r) if err != nil { - switch err.(type) { + switch err := err.(type) { case *Error: - switch err.(*Error).Message { + switch err.Message { case "zone not found": return resp, ErrZoneMissing case "record not found": @@ -123,9 +112,9 @@ func (s *RecordsService) Delete(zone string, domain string, t string) (*http.Res resp, err := s.client.Do(req, nil) if err != nil { - switch err.(type) { + switch err := err.(type) { case *Error: - if err.(*Error).Message == "record not found" { + if err.Message == "record not found" { return resp, ErrRecordMissing } }