From e37cc6c6897830492c070667ab8b68bd85683fc3 Mon Sep 17 00:00:00 2001
From: Johan Meiring <johanmeiring@gmail.com>
Date: Fri, 18 Oct 2019 08:59:02 +0200
Subject: [PATCH] feat: Implement issue link type DELETE

---
 issuelinktype.go      | 14 ++++++++++++++
 issuelinktype_test.go | 19 +++++++++++++++++++
 2 files changed, 33 insertions(+)

diff --git a/issuelinktype.go b/issuelinktype.go
index c96f316..31eebc8 100644
--- a/issuelinktype.go
+++ b/issuelinktype.go
@@ -95,3 +95,17 @@ func (s *IssueLinkTypeService) Update(linkType *IssueLinkType) (*IssueLinkType,
 	ret := *linkType
 	return &ret, resp, nil
 }
+
+// Delete deletes an issue link type based on provided ID.
+//
+// JIRA API docs: https://developer.atlassian.com/cloud/jira/platform/rest/v2/#api-rest-api-2-issueLinkType-issueLinkTypeId-delete
+func (s *IssueLinkTypeService) Delete(ID string) (*Response, error) {
+	apiEndpoint := fmt.Sprintf("rest/api/2/issueLinkType/%s", ID)
+	req, err := s.client.NewRequest("DELETE", apiEndpoint, nil)
+	if err != nil {
+		return nil, err
+	}
+
+	resp, err := s.client.Do(req, nil)
+	return resp, err
+}
diff --git a/issuelinktype_test.go b/issuelinktype_test.go
index f0a3afb..5678662 100644
--- a/issuelinktype_test.go
+++ b/issuelinktype_test.go
@@ -97,3 +97,22 @@ func TestIssueLinkTypeService_Update(t *testing.T) {
 		t.Error("Expected linkType. LinkType is nil")
 	}
 }
+
+func TestIssueLinkTypeService_Delete(t *testing.T) {
+	setup()
+	defer teardown()
+	testMux.HandleFunc("/rest/api/2/issueLinkType/100", func(w http.ResponseWriter, r *http.Request) {
+		testMethod(t, r, "DELETE")
+		testRequestURL(t, r, "/rest/api/2/issueLinkType/100")
+
+		w.WriteHeader(http.StatusNoContent)
+	})
+
+	resp, err := testClient.IssueLinkType.Delete("100")
+	if resp.StatusCode != http.StatusNoContent {
+		t.Error("Expected issue not deleted.")
+	}
+	if err != nil {
+		t.Errorf("Error given: %s", err)
+	}
+}