Repository: ctreminiom/go-atlassian
Pull request #89 (2021-11-28 20:56:07)

:bug: Fixed the issueLink.go v2 payload format


Patch:
diff --git a/jira/v2/issueLink.go b/jira/v2/issueLink.go
index ebaeec3..f0e5767 100644
--- a/jira/v2/issueLink.go
+++ b/jira/v2/issueLink.go
@@ -17,7 +17,7 @@ type IssueLinkService struct {
 // To use this resource the site must have Issue Linking enabled.
 // Docs: https://docs.go-atlassian.io/jira-software-cloud/issues/link#create-issue-link
 // Official Docs: https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issue-links/#api-rest-api-2-issuelink-post
-func (i *IssueLinkService) Create(ctx context.Context, payload *models.LinkPayloadScheme) (response *ResponseScheme, err error) {
+func (i *IssueLinkService) Create(ctx context.Context, payload *models.LinkPayloadSchemeV2) (response *ResponseScheme, err error) {
 
 	var endpoint = "rest/api/2/issueLink"
 
diff --git a/jira/v3/issueLink.go b/jira/v3/issueLink.go
index e9765b5..8053714 100644
--- a/jira/v3/issueLink.go
+++ b/jira/v3/issueLink.go
@@ -17,7 +17,7 @@ type IssueLinkService struct {
 // To use this resource the site must have Issue Linking enabled.
 // Docs: https://docs.go-atlassian.io/jira-software-cloud/issues/link#create-issue-link
 // Official Docs: https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-links/#api-rest-api-3-issuelink-post
-func (i *IssueLinkService) Create(ctx context.Context, payload *models.LinkPayloadScheme) (response *ResponseScheme, err error) {
+func (i *IssueLinkService) Create(ctx context.Context, payload *models.LinkPayloadSchemeV3) (response *ResponseScheme, err error) {
 
 	var endpoint = "rest/api/3/issueLink"
 
diff --git a/pkg/infra/models/jira_links.go b/pkg/infra/models/jira_links.go
index d180aa9..5f4c5db 100644
--- a/pkg/infra/models/jira_links.go
+++ b/pkg/infra/models/jira_links.go
@@ -22,13 +22,20 @@ type LinkedIssueScheme struct {
 	Fields *IssueFieldsScheme `json:"fields,omitempty"`
 }
 
-type LinkPayloadScheme struct {
+type LinkPayloadSchemeV3 struct {
 	Comment      *CommentPayloadScheme `json:"comment,omitempty"`
 	InwardIssue  *LinkedIssueScheme    `json:"inwardIssue,omitempty"`
 	OutwardIssue *LinkedIssueScheme    `json:"outwardIssue,omitempty"`
 	Type         *LinkTypeScheme       `json:"type,omitempty"`
 }
 
+type LinkPayloadSchemeV2 struct {
+	Comment      *CommentPayloadSchemeV2 `json:"comment,omitempty"`
+	InwardIssue  *LinkedIssueScheme      `json:"inwardIssue,omitempty"`
+	OutwardIssue *LinkedIssueScheme      `json:"outwardIssue,omitempty"`
+	Type         *LinkTypeScheme         `json:"type,omitempty"`
+}
+
 type IssueLinkPageScheme struct {
 	Expand string `json:"expand,omitempty"`
 	ID     string `json:"id,omitempty"`


Test patch:
diff --git a/jira/v2/issueLink_test.go b/jira/v2/issueLink_test.go
index 2742100..fe44a3b 100644
--- a/jira/v2/issueLink_test.go
+++ b/jira/v2/issueLink_test.go
@@ -12,39 +12,10 @@ import (
 
 func TestIssueLinkService_Create(t *testing.T) {
 
-	payloadMocked := &models2.LinkPayloadScheme{
-
-		Comment: &models2.CommentPayloadScheme{
-
-			Body: &models2.CommentNodeScheme{
-				Version: 1,
-				Type:    "doc",
-				Content: []*models2.CommentNodeScheme{
-					{
-						Type: "paragraph",
-						Content: []*models2.CommentNodeScheme{
-							{
-								Type: "text",
-								Text: "Carlos Test",
-							},
-							{
-								Type: "emoji",
-								Attrs: map[string]interface{}{
-									"shortName": ":grin",
-									"id":        "1f601",
-									"text":      "😁",
-								},
-							},
-							{
-								Type: "text",
-								Text: " ",
-							},
-						},
-					},
-				},
-			},
+	payloadMocked := &models2.LinkPayloadSchemeV2{
+		Comment: &models2.CommentPayloadSchemeV2{
+			Body: "test",
 		},
-
 		InwardIssue: &models2.LinkedIssueScheme{
 			Key: "KP-1",
 		},
@@ -58,7 +29,7 @@ func TestIssueLinkService_Create(t *testing.T) {
 
 	testCases := []struct {
 		name               string
-		payload            *models2.LinkPayloadScheme
+		payload            *models2.LinkPayloadSchemeV2
 		wantHTTPMethod     string
 		endpoint           string
 		context            context.Context
diff --git a/jira/v3/issueLink_test.go b/jira/v3/issueLink_test.go
index 85bacc8..9c5abc6 100644
--- a/jira/v3/issueLink_test.go
+++ b/jira/v3/issueLink_test.go
@@ -12,7 +12,7 @@ import (
 
 func TestIssueLinkService_Create(t *testing.T) {
 
-	payloadMocked := &models2.LinkPayloadScheme{
+	payloadMocked := &models2.LinkPayloadSchemeV3{
 
 		Comment: &models2.CommentPayloadScheme{
 
@@ -58,7 +58,7 @@ func TestIssueLinkService_Create(t *testing.T) {
 
 	testCases := []struct {
 		name               string
-		payload            *models2.LinkPayloadScheme
+		payload            *models2.LinkPayloadSchemeV3
 		wantHTTPMethod     string
 		endpoint           string
 		context            context.Context