You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: events.go
    path of file: ./repos/erda/bundle
    
    the code of the file until where you have to start completion: // Copyright (c) 2021 Terminus, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not 
    
func (b *Bundle) DeleteWebhook(r apistructs.DeleteHookRequest) error {
	host, err := b.urls.ErdaServer()
	if err != nil {
		return err
	}
	hc := b.hc
	list := apistructs.WebhookListResponse{}
	resp, err := hc.Get(host).Path("/api/dice/eventbox/webhooks").
		Param("orgId", r.Org).
		Header("Accept", "application/json").
		Do().JSON(&list)
	if err != nil {
		return apierrors.ErrInvoke.InternalError(err)
	}
	if !resp.IsOK() {
		return apierrors.ErrInvoke.InternalError(
			errors.Errorf("failed to list webhook, status-code: %d", resp.StatusCode()))
	}

	if !list.Success {
		return apierrors.ErrInvoke.InternalError(errors.New(list.Error.Msg))
	}

	for i := range list.Data {
		// delete webhook if already exist
		if list.Data[i].Name == r.Name {
			req := apistructs.WebhookDeleteRequestBody{
				OrgId:         r.Org,
				ProjectId:     r.Project,
				ApplicationId: r.Application,
				Id:            list.Data[i].ID,
			}
			var deleteRsp apistructs.WebhookDeleteResponse
			resp, err := hc.Delete(host).Path("/api/dice/eventbox/webhooks/"+list.Data[i].ID).
				Header("Accept", "application/json").
				Header("Internal-Client", "bundle").
				JSONBody(&req).
				Do().JSON(&deleteRsp)
			if err != nil {
				return apierrors.ErrInvoke.InternalError(err)
			}
			if !resp.IsOK() {
				return apierrors.ErrInvoke.InternalError(
					errors.Errorf("failed to delete webhook, status-code: %d", resp.StatusCode()))
			}
			if !deleteRsp.Success {
				return apierrors.ErrInvoke.InternalError(
					errors.Errorf("failed to delete webhook: %+v", deleteRsp.Error))
			}
			return nil
		}
	}
	return nil
}