diff --git a/CHANGELOG.md b/CHANGELOG.md index b831065..82f8314 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,10 @@ Incompatible changes: - NEW: Added support for context (dnsimple/dnsimple-go#82, dnsimple/dnsimple-go#90) - CHANGED: Changed all method signatures so that the returned value is exported (dnsimple/dnsimple-go#91) +- CHANGED: Renamed the following structs to clarify intent: + - DomainRegisterRequest -> RegisterDomainInput + - DomainTransferRequest -> TransferDomainInput + - DomainRenewRequest -> RenewDomainInput #### Release 0.40.0 diff --git a/dnsimple/live_test.go b/dnsimple/live_test.go index d71f4d7..6eaad0e 100644 --- a/dnsimple/live_test.go +++ b/dnsimple/live_test.go @@ -87,7 +87,7 @@ func TestLive_Registration(t *testing.T) { accountID := whoami.Account.ID // TODO: fetch the registrant randomly - registerRequest := &DomainRegisterRequest{RegistrantID: 2} + registerRequest := &RegisterDomainInput{RegistrantID: 2} registrationResponse, err := dnsimpleClient.Registrar.RegisterDomain(context.Background(), fmt.Sprintf("%v", accountID), fmt.Sprintf("example-%v.com", time.Now().Unix()), registerRequest) if err != nil { t.Fatalf("Live Registrar.Register() returned error: %v", err) @@ -176,7 +176,7 @@ func TestLive_Error(t *testing.T) { t.Fatalf("Live Error/Whoami() returned error: %v", err) } - _, err = dnsimpleClient.Registrar.RegisterDomain(context.Background(), fmt.Sprintf("%v", whoami.Account.ID), fmt.Sprintf("example-%v.test", time.Now().Unix()), &DomainRegisterRequest{}) + _, err = dnsimpleClient.Registrar.RegisterDomain(context.Background(), fmt.Sprintf("%v", whoami.Account.ID), fmt.Sprintf("example-%v.test", time.Now().Unix()), &RegisterDomainInput{}) if err == nil { t.Fatalf("Live Error/RegisterDomain() expected to return error") } diff --git a/dnsimple/registrar.go b/dnsimple/registrar.go index f4a03a0..0eb93ea 100644 --- a/dnsimple/registrar.go +++ b/dnsimple/registrar.go @@ -111,9 +111,9 @@ type DomainRegistrationResponse struct { Data *DomainRegistration `json:"data"` } -// DomainRegisterRequest represents the attributes you can pass to a register API request. +// RegisterDomainInput represents the attributes you can pass to a register API request. // Some attributes are mandatory. -type DomainRegisterRequest struct { +type RegisterDomainInput struct { // The ID of the Contact to use as registrant for the domain RegistrantID int `json:"registrant_id"` // Set to true to enable the whois privacy service. An extra cost may apply. @@ -131,13 +131,13 @@ type DomainRegisterRequest struct { // RegisterDomain registers a domain name. // // See https://developer.dnsimple.com/v2/registrar/#register -func (s *RegistrarService) RegisterDomain(ctx context.Context, accountID string, domainName string, request *DomainRegisterRequest) (*DomainRegistrationResponse, error) { +func (s *RegistrarService) RegisterDomain(ctx context.Context, accountID string, domainName string, input *RegisterDomainInput) (*DomainRegistrationResponse, error) { path := versioned(fmt.Sprintf("/%v/registrar/domains/%v/registrations", accountID, domainName)) registrationResponse := &DomainRegistrationResponse{} // TODO: validate mandatory attributes RegistrantID - resp, err := s.client.post(ctx, path, request, registrationResponse) + resp, err := s.client.post(ctx, path, input, registrationResponse) if err != nil { return nil, err } @@ -164,9 +164,9 @@ type DomainTransferResponse struct { Data *DomainTransfer `json:"data"` } -// DomainTransferRequest represents the attributes you can pass to a transfer API request. +// TransferDomainInput represents the attributes you can pass to a transfer API request. // Some attributes are mandatory. -type DomainTransferRequest struct { +type TransferDomainInput struct { // The ID of the Contact to use as registrant for the domain RegistrantID int `json:"registrant_id"` // The Auth-Code required to transfer the domain. @@ -187,13 +187,13 @@ type DomainTransferRequest struct { // TransferDomain transfers a domain name. // // See https://developer.dnsimple.com/v2/registrar/#transferDomain -func (s *RegistrarService) TransferDomain(ctx context.Context, accountID string, domainName string, request *DomainTransferRequest) (*DomainTransferResponse, error) { +func (s *RegistrarService) TransferDomain(ctx context.Context, accountID string, domainName string, input *TransferDomainInput) (*DomainTransferResponse, error) { path := versioned(fmt.Sprintf("/%v/registrar/domains/%v/transfers", accountID, domainName)) transferResponse := &DomainTransferResponse{} // TODO: validate mandatory attributes RegistrantID - resp, err := s.client.post(ctx, path, request, transferResponse) + resp, err := s.client.post(ctx, path, input, transferResponse) if err != nil { return nil, err } @@ -240,9 +240,9 @@ type DomainRenewalResponse struct { Data *DomainRenewal `json:"data"` } -// DomainRenewRequest represents the attributes you can pass to a renew API request. +// RenewDomainInput represents the attributes you can pass to a renew API request. // Some attributes are mandatory. -type DomainRenewRequest struct { +type RenewDomainInput struct { // The number of years Period int `json:"period"` // Required as confirmation of the price, only if the domain is premium. @@ -252,11 +252,11 @@ type DomainRenewRequest struct { // RenewDomain renews a domain name. // // See https://developer.dnsimple.com/v2/registrar/#register -func (s *RegistrarService) RenewDomain(ctx context.Context, accountID string, domainName string, request *DomainRenewRequest) (*DomainRenewalResponse, error) { +func (s *RegistrarService) RenewDomain(ctx context.Context, accountID string, domainName string, input *RenewDomainInput) (*DomainRenewalResponse, error) { path := versioned(fmt.Sprintf("/%v/registrar/domains/%v/renewals", accountID, domainName)) renewalResponse := &DomainRenewalResponse{} - resp, err := s.client.post(ctx, path, request, renewalResponse) + resp, err := s.client.post(ctx, path, input, renewalResponse) if err != nil { return nil, err } diff --git a/dnsimple/registrar_test.go b/dnsimple/registrar_test.go index 91c9f62..bb13160 100644 --- a/dnsimple/registrar_test.go +++ b/dnsimple/registrar_test.go @@ -100,7 +100,7 @@ func TestRegistrarService_RegisterDomain(t *testing.T) { io.Copy(w, httpResponse.Body) }) - registerRequest := &DomainRegisterRequest{RegistrantID: 2} + registerRequest := &RegisterDomainInput{RegistrantID: 2} registrationResponse, err := client.Registrar.RegisterDomain(context.Background(), "1010", "example.com", registerRequest) if err != nil { @@ -133,7 +133,7 @@ func TestRegistrarService_RegisterDomain_ExtendedAttributes(t *testing.T) { io.Copy(w, httpResponse.Body) }) - registerRequest := &DomainRegisterRequest{RegistrantID: 2, ExtendedAttributes: map[string]string{"att1": "val1", "att2": "val2"}} + registerRequest := &RegisterDomainInput{RegistrantID: 2, ExtendedAttributes: map[string]string{"att1": "val1", "att2": "val2"}} if _, err := client.Registrar.RegisterDomain(context.Background(), "1010", "example.com", registerRequest); err != nil { t.Fatalf("Registrar.RegisterDomain() returned error: %v", err) @@ -157,7 +157,7 @@ func TestRegistrarService_TransferDomain(t *testing.T) { io.Copy(w, httpResponse.Body) }) - transferRequest := &DomainTransferRequest{RegistrantID: 2, AuthCode: "x1y2z3"} + transferRequest := &TransferDomainInput{RegistrantID: 2, AuthCode: "x1y2z3"} transferResponse, err := client.Registrar.TransferDomain(context.Background(), "1010", "example.com", transferRequest) if err != nil { @@ -190,7 +190,7 @@ func TestRegistrarService_TransferDomain_ExtendedAttributes(t *testing.T) { io.Copy(w, httpResponse.Body) }) - transferRequest := &DomainTransferRequest{RegistrantID: 2, AuthCode: "x1y2z3", ExtendedAttributes: map[string]string{"att1": "val1", "att2": "val2"}} + transferRequest := &TransferDomainInput{RegistrantID: 2, AuthCode: "x1y2z3", ExtendedAttributes: map[string]string{"att1": "val1", "att2": "val2"}} if _, err := client.Registrar.TransferDomain(context.Background(), "1010", "example.com", transferRequest); err != nil { t.Fatalf("Registrar.TransferDomain() returned error: %v", err)