diff --git a/pkg/customers/address.go b/pkg/customers/address.go index 2264ca69b..e78469abb 100644 --- a/pkg/customers/address.go +++ b/pkg/customers/address.go @@ -86,7 +86,7 @@ func createAddress(logger log.Logger, ownerType client.OwnerType, repo CustomerR for _, addr := range addresses { addrs = append(addrs, address{ Type: addr.Type, - OwnerType: addr.OwnerType, + OwnerType: ownerType, Address1: addr.Address1, Address2: addr.Address2, City: addr.City, diff --git a/pkg/customers/customer_representatives.go b/pkg/customers/customer_representatives.go index a5fb42268..17583f88a 100644 --- a/pkg/customers/customer_representatives.go +++ b/pkg/customers/customer_representatives.go @@ -412,7 +412,7 @@ func (req customerRepresentativeRequest) asRepresentative(storage *ssnStorage) ( representative.Phones = append(representative.Phones, client.Phone{ Number: req.Phones[i].Number, Type: req.Phones[i].Type, - OwnerType: req.Phones[i].OwnerType, + OwnerType: client.OWNERTYPE_REPRESENTATIVE, }) } for i := range req.Addresses { diff --git a/pkg/customers/customer_representatives_test.go b/pkg/customers/customer_representatives_test.go index 605b38d25..3a8011213 100644 --- a/pkg/customers/customer_representatives_test.go +++ b/pkg/customers/customer_representatives_test.go @@ -145,7 +145,6 @@ func TestCustomers__customerRepresentativeRequest(t *testing.T) { req.Phones = append(req.Phones, phone{ Number: "123.456.7890", Type: "mobile", - OwnerType: "customer", }) if err := req.validate(); err != nil { t.Errorf("unexpected error: %v", err) @@ -158,7 +157,6 @@ func TestCustomers__customerRepresentativeRequest(t *testing.T) { PostalCode: "90210", Country: "US", Type: "primary", - OwnerType: client.OWNERTYPE_REPRESENTATIVE, }) if err := req.validate(); err != nil { t.Errorf("unexpected error: %v", err) @@ -273,7 +271,6 @@ func TestCustomers__updateRepresentative(t *testing.T) { { Number: "123.456.7890", Type: "mobile", - OwnerType: "representative", }, }, Addresses: []address{ @@ -284,7 +281,6 @@ func TestCustomers__updateRepresentative(t *testing.T) { PostalCode: "90210", Country: "US", Type: "primary", - OwnerType: "representative", }, }, } @@ -349,7 +345,6 @@ func TestCustomers__updateRepresentative(t *testing.T) { PostalCode: "90210", Country: "US", Type: "primary", - OwnerType: "representative", }, { Address1: "444 4th st", @@ -358,7 +353,6 @@ func TestCustomers__updateRepresentative(t *testing.T) { PostalCode: "90210", Country: "US", Type: "primary", - OwnerType: "representative", }, } payload, err = json.Marshal(&updateReq) @@ -412,7 +406,6 @@ func TestCustomerRepository__updateRepresentative(t *testing.T) { PostalCode: "90210", Country: "US", Type: "primary", - OwnerType: "customer", }, }, } @@ -429,7 +422,6 @@ func TestCustomerRepository__updateRepresentative(t *testing.T) { { Number: "555.555.5555", Type: "mobile", - OwnerType: "customer", }, }, Addresses: []address{ @@ -437,7 +429,6 @@ func TestCustomerRepository__updateRepresentative(t *testing.T) { Address1: "555 5th st", City: "real city", Type: "primary", - OwnerType: "customer", }, }, } @@ -496,7 +487,6 @@ func TestCustomersRepository__addRepresentativeAddress(t *testing.T) { PostalCode: "90210", Country: "US", Type: "primary", - OwnerType: "representative", }, ); err != nil { t.Fatal(err) diff --git a/pkg/customers/customers.go b/pkg/customers/customers.go index 0c702013a..c9a42705c 100644 --- a/pkg/customers/customers.go +++ b/pkg/customers/customers.go @@ -155,12 +155,6 @@ func (p *phone) validate() error { return fmt.Errorf("unknown type: %s", p.Type) } - switch p.OwnerType { - case client.OWNERTYPE_CUSTOMER, client.OWNERTYPE_REPRESENTATIVE: - default: - return fmt.Errorf("unknown owner type: %s", p.OwnerType) - } - return nil } @@ -185,12 +179,6 @@ func (add *address) validate() error { return fmt.Errorf("unknown type: %s", add.Type) } - switch add.OwnerType { - case client.OWNERTYPE_CUSTOMER, client.OWNERTYPE_REPRESENTATIVE: - default: - return fmt.Errorf("unknown owner type: %s", add.OwnerType) - } - if !usstates.Valid(add.State) { return fmt.Errorf("create customer: invalid state=%s", add.State) } diff --git a/pkg/customers/customers_test.go b/pkg/customers/customers_test.go index e00513bfe..49a3a7959 100644 --- a/pkg/customers/customers_test.go +++ b/pkg/customers/customers_test.go @@ -318,7 +318,6 @@ func TestCustomers__customerRequest(t *testing.T) { req.Phones = append(req.Phones, phone{ Number: "123.456.7890", Type: "mobile", - OwnerType: "customer", }) if err := req.validate(); err != nil { t.Errorf("unexpected error: %v", err) @@ -351,7 +350,7 @@ func TestCustomers__customerRequest(t *testing.T) { } func TestCustomers__addressValidate(t *testing.T) { - add := address{Type: "primary", OwnerType: "customer"} + add := address{Type: "primary"} add.State = "IA" if err := add.validate(); err != nil { @@ -366,8 +365,8 @@ func TestCustomers__addressValidate(t *testing.T) { func TestCustomers__CreateCustomer(t *testing.T) { w := httptest.NewRecorder() - phone := `{"number": "555.555.5555", "type": "mobile", "ownerType": "customer"}` - address := `{"type": "primary", "ownerType": "customer", "address1": "123 1st St", "city": "Denver", "state": "CO", "postalCode": "12345", "country": "USA"}` + phone := `{"number": "555.555.5555", "type": "mobile"}` + address := `{"type": "primary", "address1": "123 1st St", "city": "Denver", "state": "CO", "postalCode": "12345", "country": "USA"}` body := fmt.Sprintf(`{"firstName": "jane", "lastName": "doe", "email": "jane@example.com", "birthDate": "1991-04-01", "ssn": "123456789", "type": "individual", "phones": [%s], "addresses": [%s]}`, phone, address) req := httptest.NewRequest("POST", "/customers", strings.NewReader(body)) req.Header.Set("x-organization", "test") @@ -444,7 +443,6 @@ func TestCustomers__updateCustomer(t *testing.T) { { Number: "123.456.7890", Type: "mobile", - OwnerType: "customer", }, }, Addresses: []address{ @@ -455,7 +453,6 @@ func TestCustomers__updateCustomer(t *testing.T) { PostalCode: "90210", Country: "US", Type: "primary", - OwnerType: "customer", }, }, } @@ -479,7 +476,6 @@ func TestCustomers__updateCustomer(t *testing.T) { { Number: "555.555.5555", Type: "mobile", - OwnerType: "customer", }, } updateReq.Addresses = []address{ @@ -490,7 +486,6 @@ func TestCustomers__updateCustomer(t *testing.T) { PostalCode: "90210", Country: "US", Type: "primary", - OwnerType: "customer", }, } payload, err := json.Marshal(&updateReq) @@ -526,7 +521,6 @@ func TestCustomers__updateCustomer(t *testing.T) { PostalCode: "90210", Country: "US", Type: "primary", - OwnerType: "customer", }, { Address1: "444 4th st", @@ -535,7 +529,6 @@ func TestCustomers__updateCustomer(t *testing.T) { PostalCode: "90210", Country: "US", Type: "primary", - OwnerType: "customer", }, } payload, err = json.Marshal(&updateReq) @@ -581,7 +574,6 @@ func TestCustomers__repository(t *testing.T) { { Number: "123.456.7890", Type: "mobile", - OwnerType: "customer", }, }, Addresses: []address{ @@ -686,7 +678,6 @@ func TestCustomerRepository__updateCustomer(t *testing.T) { { Number: "123.456.7890", Type: "mobile", - OwnerType: "customer", }, }, Addresses: []address{ @@ -712,7 +703,6 @@ func TestCustomerRepository__updateCustomer(t *testing.T) { { Number: "555.555.5555", Type: "mobile", - OwnerType: "customer", }, }, Addresses: []address{ @@ -720,7 +710,6 @@ func TestCustomerRepository__updateCustomer(t *testing.T) { Address1: "555 5th st", City: "real city", Type: "primary", - OwnerType: "customer", }, }, } @@ -789,7 +778,6 @@ func TestCustomersRepository__addAddress(t *testing.T) { PostalCode: "90210", Country: "US", Type: "primary", - OwnerType: "customer", }, ); err != nil { t.Fatal(err) @@ -1056,7 +1044,6 @@ func mockCustomerRequest() customerRequest { p := phone{} p.Number = "123-456-7892" p.Type = "mobile" - p.OwnerType = "customer" c.Phones = append(c.Phones, p) a := address{} @@ -1066,7 +1053,6 @@ func mockCustomerRequest() customerRequest { a.Country = "USA" a.PostalCode = "19456" a.State = "MA" - a.OwnerType = "customer" c.Addresses = append(c.Addresses, a) return c }