Skip to content

Commit 48a15c1

Browse files
johanmeiringghostsquad
authored andcommitted
feat: Implement issue link type PUT
1 parent 75b9df8 commit 48a15c1

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

issuelinktype.go

+17
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,20 @@ func (s *IssueLinkTypeService) Create(linkType *IssueLinkType) (*IssueLinkType,
7878
}
7979
return linkType, resp, nil
8080
}
81+
82+
// Update updates an issue link type. The issue is found by key.
83+
//
84+
// JIRA API docs: https://developer.atlassian.com/cloud/jira/platform/rest/v2/#api-rest-api-2-issueLinkType-issueLinkTypeId-put
85+
func (s *IssueLinkTypeService) Update(linkType *IssueLinkType) (*IssueLinkType, *Response, error) {
86+
apiEndpoint := fmt.Sprintf("rest/api/2/issueLinkType/%s", linkType.ID)
87+
req, err := s.client.NewRequest("PUT", apiEndpoint, linkType)
88+
if err != nil {
89+
return nil, nil, err
90+
}
91+
resp, err := s.client.Do(req, nil)
92+
if err != nil {
93+
return nil, resp, NewJiraError(resp, err)
94+
}
95+
ret := *linkType
96+
return &ret, resp, nil
97+
}

issuelinktype_test.go

+24
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,27 @@ func TestIssueLinkTypeService_Create(t *testing.T) {
7373
t.Error("Expected linkType. LinkType is nil")
7474
}
7575
}
76+
77+
func TestIssueLinkTypeService_Update(t *testing.T) {
78+
setup()
79+
defer teardown()
80+
testMux.HandleFunc("/rest/api/2/issueLinkType/100", func(w http.ResponseWriter, r *http.Request) {
81+
testMethod(t, r, "PUT")
82+
testRequestURL(t, r, "/rest/api/2/issueLinkType/100")
83+
84+
w.WriteHeader(http.StatusNoContent)
85+
})
86+
87+
lt := &IssueLinkType{
88+
ID: "100",
89+
Name: "Problem/Incident",
90+
Inward: "is caused by",
91+
Outward: "causes",
92+
}
93+
94+
if linkType, _, err := testClient.IssueLinkType.Update(lt); err != nil {
95+
t.Errorf("Error given: %s", err)
96+
} else if linkType == nil {
97+
t.Error("Expected linkType. LinkType is nil")
98+
}
99+
}

0 commit comments

Comments
 (0)