Skip to content
This repository was archived by the owner on Sep 11, 2018. It is now read-only.

Commit 09a4af4

Browse files
davidtonghelixdlebech
authored andcommitted
Add Customer.Delete() (#100)
1 parent 4508bdd commit 09a4af4

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

customer.go

+7
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ type CustomerService interface {
2020
Search(interface{}) ([]Customer, error)
2121
Create(Customer) (*Customer, error)
2222
Update(Customer) (*Customer, error)
23+
Delete(int) (error)
2324

2425
// MetafieldsService used for Customer resource to communicate with Metafields resource
2526
MetafieldsService
@@ -115,6 +116,12 @@ func (s *CustomerServiceOp) Update(customer Customer) (*Customer, error) {
115116
return resource.Customer, err
116117
}
117118

119+
// Delete an existing customer
120+
func (s *CustomerServiceOp) Delete(customerID int) error {
121+
path := fmt.Sprintf("%s/%d.json", customersBasePath, customerID)
122+
return s.client.Delete(path)
123+
}
124+
118125
// Search customers
119126
func (s *CustomerServiceOp) Search(options interface{}) ([]Customer, error) {
120127
path := fmt.Sprintf("%s/search.json", customersBasePath)

customer_test.go

+13
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,19 @@ func TestCustomerCreate(t *testing.T) {
272272
}
273273
}
274274

275+
func TestCustomerDelete(t *testing.T) {
276+
setup()
277+
defer teardown()
278+
279+
httpmock.RegisterResponder("DELETE", "https://fooshop.myshopify.com/admin/customers/1.json",
280+
httpmock.NewStringResponder(200, ""))
281+
282+
err := client.Customer.Delete(1)
283+
if err != nil {
284+
t.Errorf("Customer.Delete returned error: %v", err)
285+
}
286+
}
287+
275288
func TestCustomerListMetafields(t *testing.T) {
276289
setup()
277290
defer teardown()

0 commit comments

Comments
 (0)