Repository: ctreminiom/go-atlassian
Pull request #90 (2021-11-28 22:21:04)

:bug: Fixed the jira_work_log.go v2 payload format


Patch:
diff --git a/jira/v2/issueWorklog.go b/jira/v2/issueWorklog.go
index ab93f6d..ae93420 100644
--- a/jira/v2/issueWorklog.go
+++ b/jira/v2/issueWorklog.go
@@ -94,8 +94,8 @@ func (w *IssueWorklogService) Issue(ctx context.Context, issueKeyOrID string, st
 // Add adds a worklog to an issue.
 // Docs: N/A
 // Atlassian Docs: https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issue-worklogs/#api-rest-api-2-issue-issueidorkey-worklog-post
-func (w *IssueWorklogService) Add(ctx context.Context, issueKeyOrID string, options *models.WorklogOptionsScheme) (
-	result *models.IssueWorklogScheme, response *ResponseScheme, err error) {
+func (w *IssueWorklogService) Add(ctx context.Context, issueKeyOrID string, payload *models.WorklogPayloadSchemeV2,
+	options *models.WorklogOptionsScheme) (result *models.IssueWorklogScheme, response *ResponseScheme, err error) {
 
 	if len(issueKeyOrID) == 0 {
 		return nil, nil, models.ErrNoIssueKeyOrIDError
@@ -126,7 +126,7 @@ func (w *IssueWorklogService) Add(ctx context.Context, issueKeyOrID string, opti
 		params.Add("overrideEditableFlag", "true")
 	}
 
-	payloadAsReader, err := transformStructToReader(options.Payload)
+	payloadAsReader, err := transformStructToReader(payload)
 	if err != nil {
 		return nil, nil, err
 	}
@@ -156,8 +156,8 @@ func (w *IssueWorklogService) Add(ctx context.Context, issueKeyOrID string, opti
 
 // Update updates a worklog.
 // Atlassian Docs: https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issue-worklogs/#api-rest-api-2-issue-issueidorkey-worklog-id-put
-func (w *IssueWorklogService) Update(ctx context.Context, issueKeyOrID, worklogID string, options *models.WorklogOptionsScheme) (
-	result *models.IssueWorklogScheme, response *ResponseScheme, err error) {
+func (w *IssueWorklogService) Update(ctx context.Context, issueKeyOrID, worklogID string, payload *models.WorklogPayloadSchemeV2,
+	options *models.WorklogOptionsScheme) (result *models.IssueWorklogScheme, response *ResponseScheme, err error) {
 
 	if len(issueKeyOrID) == 0 {
 		return nil, nil, models.ErrNoIssueKeyOrIDError
@@ -193,7 +193,7 @@ func (w *IssueWorklogService) Update(ctx context.Context, issueKeyOrID, worklogI
 		params.Add("overrideEditableFlag", "true")
 	}
 
-	payloadAsReader, err := transformStructToReader(options.Payload)
+	payloadAsReader, err := transformStructToReader(payload)
 	if err != nil {
 		return nil, nil, err
 	}
diff --git a/jira/v3/issueWorklog.go b/jira/v3/issueWorklog.go
index 585de00..d030b11 100644
--- a/jira/v3/issueWorklog.go
+++ b/jira/v3/issueWorklog.go
@@ -94,7 +94,7 @@ func (w *IssueWorklogService) Issue(ctx context.Context, issueKeyOrID string, st
 // Add adds a worklog to an issue.
 // Docs: N/A
 // Atlassian Docs: https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-worklogs/#api-rest-api-3-issue-issueidorkey-worklog-post
-func (w *IssueWorklogService) Add(ctx context.Context, issueKeyOrID string, options *models.WorklogOptionsScheme) (
+func (w *IssueWorklogService) Add(ctx context.Context, issueKeyOrID string, payload *models.WorklogPayloadSchemeV3, options *models.WorklogOptionsScheme) (
 	result *models.IssueWorklogScheme, response *ResponseScheme, err error) {
 
 	if len(issueKeyOrID) == 0 {
@@ -126,7 +126,7 @@ func (w *IssueWorklogService) Add(ctx context.Context, issueKeyOrID string, opti
 		params.Add("overrideEditableFlag", "true")
 	}
 
-	payloadAsReader, err := transformStructToReader(options.Payload)
+	payloadAsReader, err := transformStructToReader(payload)
 	if err != nil {
 		return nil, nil, err
 	}
@@ -156,7 +156,7 @@ func (w *IssueWorklogService) Add(ctx context.Context, issueKeyOrID string, opti
 
 // Update updates a worklog.
 // Atlassian Docs: https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-worklogs/#api-rest-api-3-issue-issueidorkey-worklog-id-put
-func (w *IssueWorklogService) Update(ctx context.Context, issueKeyOrID, worklogID string, options *models.WorklogOptionsScheme) (
+func (w *IssueWorklogService) Update(ctx context.Context, issueKeyOrID, worklogID string, payload *models.WorklogPayloadSchemeV3, options *models.WorklogOptionsScheme) (
 	result *models.IssueWorklogScheme, response *ResponseScheme, err error) {
 
 	if len(issueKeyOrID) == 0 {
@@ -193,7 +193,7 @@ func (w *IssueWorklogService) Update(ctx context.Context, issueKeyOrID, worklogI
 		params.Add("overrideEditableFlag", "true")
 	}
 
-	payloadAsReader, err := transformStructToReader(options.Payload)
+	payloadAsReader, err := transformStructToReader(payload)
 	if err != nil {
 		return nil, nil, err
 	}
diff --git a/pkg/infra/models/jira_work_log.go b/pkg/infra/models/jira_work_log.go
index 726cf18..6c062ea 100644
--- a/pkg/infra/models/jira_work_log.go
+++ b/pkg/infra/models/jira_work_log.go
@@ -7,10 +7,9 @@ type WorklogOptionsScheme struct {
 	ReduceBy             string
 	OverrideEditableFlag bool
 	Expand               []string
-	Payload              *WorklogPayloadScheme
 }
 
-type WorklogPayloadScheme struct {
+type WorklogPayloadSchemeV3 struct {
 	Comment          *CommentNodeScheme            `json:"comment,omitempty"`
 	Visibility       *IssueWorklogVisibilityScheme `json:"visibility,omitempty"`
 	Started          string                        `json:"started,omitempty"`
@@ -18,6 +17,14 @@ type WorklogPayloadScheme struct {
 	TimeSpentSeconds int                           `json:"timeSpentSeconds,omitempty"`
 }
 
+type WorklogPayloadSchemeV2 struct {
+	Comment          *CommentPayloadSchemeV2       `json:"comment,omitempty"`
+	Visibility       *IssueWorklogVisibilityScheme `json:"visibility,omitempty"`
+	Started          string                        `json:"started,omitempty"`
+	TimeSpent        string                        `json:"timeSpent,omitempty"`
+	TimeSpentSeconds int                           `json:"timeSpentSeconds,omitempty"`
+}
+
 type ChangedWorklogPageScheme struct {
 	Since    int                     `json:"since,omitempty"`
 	Until    int                     `json:"until,omitempty"`


Test patch:
diff --git a/jira/sm/serviceDesk_test.go b/jira/sm/serviceDesk_test.go
index 547e9fe..8193bec 100644
--- a/jira/sm/serviceDesk_test.go
+++ b/jira/sm/serviceDesk_test.go
@@ -335,9 +335,9 @@ func TestServiceDeskService_Attach(t *testing.T) {
 
 	testCases := []struct {
 		name               string
-		serviceDeskID int
-		fileName string
-		file io.Reader
+		serviceDeskID      int
+		fileName           string
+		file               io.Reader
 		mockFile           string
 		wantHTTPMethod     string
 		endpoint           string
@@ -461,10 +461,6 @@ func TestServiceDeskService_Attach(t *testing.T) {
 			wantHTTPCodeReturn: http.StatusOK,
 			wantErr:            true,
 		},
-
-
-
-
 	}
 
 	for _, testCase := range testCases {
@@ -536,4 +532,3 @@ func TestServiceDeskService_Attach(t *testing.T) {
 	}
 
 }
-
diff --git a/jira/v2/issueWorklog_test.go b/jira/v2/issueWorklog_test.go
index 0e28e6c..02165d2 100644
--- a/jira/v2/issueWorklog_test.go
+++ b/jira/v2/issueWorklog_test.go
@@ -329,6 +329,7 @@ func TestIssueWorklogService_Add(t *testing.T) {
 		name               string
 		ctx                context.Context
 		issueKeyOrID       string
+		payload            *models.WorklogPayloadSchemeV2
 		options            *models.WorklogOptionsScheme
 		mockFile           string
 		wantHTTPMethod     string
@@ -348,16 +349,16 @@ func TestIssueWorklogService_Add(t *testing.T) {
 				OverrideEditableFlag: true,
 				NewEstimate:          "2h",
 				Expand:               []string{"expand", "properties"},
-				Payload: &models.WorklogPayloadScheme{
-					/*
-						Visibility:       &jira.IssueWorklogVisibilityScheme{
-							Type:  "group",
-							Value: "jira-users",
-						},
-					*/
-					Started:          "2021-07-16T07:01:10.774+0000",
-					TimeSpentSeconds: 12000,
-				},
+			},
+			payload: &models.WorklogPayloadSchemeV2{
+				/*
+					Visibility:       &jira.IssueWorklogVisibilityScheme{
+						Type:  "group",
+						Value: "jira-users",
+					},
+				*/
+				Started:          "2021-07-16T07:01:10.774+0000",
+				TimeSpentSeconds: 12000,
 			},
 			wantHTTPMethod:     http.MethodPost,
 			endpoint:           "/rest/api/2/issue/KP-1/worklog?adjustEstimate=auto&expand=expand%2Cproperties&newEstimate=2h&notifyUsers=false&overrideEditableFlag=true&reduceBy=2h",
@@ -376,16 +377,16 @@ func TestIssueWorklogService_Add(t *testing.T) {
 				ReduceBy:       "2h",
 				//OverrideEditableFlag: true,
 				Expand: []string{"expand", "properties"},
-				Payload: &models.WorklogPayloadScheme{
-					/*
-						Visibility:       &jira.IssueWorklogVisibilityScheme{
-							Type:  "group",
-							Value: "jira-users",
-						},
-					*/
-					Started:          "2021-07-16T07:01:10.774+0000",
-					TimeSpentSeconds: 12000,
-				},
+			},
+			payload: &models.WorklogPayloadSchemeV2{
+				/*
+					Visibility:       &jira.IssueWorklogVisibilityScheme{
+						Type:  "group",
+						Value: "jira-users",
+					},
+				*/
+				Started:          "2021-07-16T07:01:10.774+0000",
+				TimeSpentSeconds: 12000,
 			},
 			wantHTTPMethod:     http.MethodPost,
 			endpoint:           "/rest/api/2/issue/KP-1/worklog?adjustEstimate=auto&expand=expand%2Cproperties&reduceBy=2h",
@@ -404,16 +405,16 @@ func TestIssueWorklogService_Add(t *testing.T) {
 				ReduceBy:       "2h",
 				//OverrideEditableFlag: true,
 				Expand: []string{"expand", "properties"},
-				Payload: &models.WorklogPayloadScheme{
-					/*
-						Visibility:       &jira.IssueWorklogVisibilityScheme{
-							Type:  "group",
-							Value: "jira-users",
-						},
-					*/
-					Started:          "2021-07-16T07:01:10.774+0000",
-					TimeSpentSeconds: 12000,
-				},
+			},
+			payload: &models.WorklogPayloadSchemeV2{
+				/*
+					Visibility:       &jira.IssueWorklogVisibilityScheme{
+						Type:  "group",
+						Value: "jira-users",
+					},
+				*/
+				Started:          "2021-07-16T07:01:10.774+0000",
+				TimeSpentSeconds: 12000,
 			},
 			wantHTTPMethod:     http.MethodPost,
 			endpoint:           "/rest/api/2/issue/KP-1/worklog?adjustEstimate=auto&expand=expand%2Cproperties&reduceBy=2h",
@@ -431,9 +432,9 @@ func TestIssueWorklogService_Add(t *testing.T) {
 				AdjustEstimate: "auto",
 				ReduceBy:       "2h",
 				//OverrideEditableFlag: true,
-				Expand:  []string{"expand", "properties"},
-				Payload: nil,
+				Expand: []string{"expand", "properties"},
 			},
+			payload:            nil,
 			wantHTTPMethod:     http.MethodPost,
 			endpoint:           "/rest/api/2/issue/KP-1/worklog?adjustEstimate=auto&expand=expand%2Cproperties&reduceBy=2h",
 			wantHTTPCodeReturn: http.StatusOK,
@@ -451,16 +452,16 @@ func TestIssueWorklogService_Add(t *testing.T) {
 				ReduceBy:       "2h",
 				//OverrideEditableFlag: true,
 				Expand: []string{"expand", "properties"},
-				Payload: &models.WorklogPayloadScheme{
-					/*
-						Visibility:       &jira.IssueWorklogVisibilityScheme{
-							Type:  "group",
-							Value: "jira-users",
-						},
-					*/
-					Started:          "2021-07-16T07:01:10.774+0000",
-					TimeSpentSeconds: 12000,
-				},
+			},
+			payload: &models.WorklogPayloadSchemeV2{
+				/*
+					Visibility:       &jira.IssueWorklogVisibilityScheme{
+						Type:  "group",
+						Value: "jira-users",
+					},
+				*/
+				Started:          "2021-07-16T07:01:10.774+0000",
+				TimeSpentSeconds: 12000,
 			},
 			wantHTTPMethod:     http.MethodGet,
 			endpoint:           "/rest/api/2/issue/KP-1/worklog?adjustEstimate=auto&expand=expand%2Cproperties&reduceBy=2h",
@@ -479,16 +480,16 @@ func TestIssueWorklogService_Add(t *testing.T) {
 				ReduceBy:       "2h",
 				//OverrideEditableFlag: true,
 				Expand: []string{"expand", "properties"},
-				Payload: &models.WorklogPayloadScheme{
-					/*
-						Visibility:       &jira.IssueWorklogVisibilityScheme{
-							Type:  "group",
-							Value: "jira-users",
-						},
-					*/
-					Started:          "2021-07-16T07:01:10.774+0000",
-					TimeSpentSeconds: 12000,
-				},
+			},
+			payload: &models.WorklogPayloadSchemeV2{
+				/*
+					Visibility:       &jira.IssueWorklogVisibilityScheme{
+						Type:  "group",
+						Value: "jira-users",
+					},
+				*/
+				Started:          "2021-07-16T07:01:10.774+0000",
+				TimeSpentSeconds: 12000,
 			},
 			wantHTTPMethod:     http.MethodPost,
 			endpoint:           "/rest/api/2/issue/KP-1/worklog?adjustEstimate=auto&expand=expand%2Cproperties&reduceBy=2h",
@@ -524,7 +525,7 @@ func TestIssueWorklogService_Add(t *testing.T) {
 
 			i := &IssueWorklogService{client: mockClient}
 
-			gotResult, gotResponse, err := i.Add(testCase.ctx, testCase.issueKeyOrID, testCase.options)
+			gotResult, gotResponse, err := i.Add(testCase.ctx, testCase.issueKeyOrID, testCase.payload, testCase.options)
 
 			if testCase.wantErr {
 
@@ -568,6 +569,7 @@ func TestIssueWorklogService_Update(t *testing.T) {
 		ctx                context.Context
 		issueKeyOrID       string
 		worklogID          string
+		payload            *models.WorklogPayloadSchemeV2
 		options            *models.WorklogOptionsScheme
 		mockFile           string
 		wantHTTPMethod     string
@@ -588,16 +590,16 @@ func TestIssueWorklogService_Update(t *testing.T) {
 				OverrideEditableFlag: true,
 				NewEstimate:          "2h",
 				Expand:               []string{"expand", "properties"},
-				Payload: &models.WorklogPayloadScheme{
-					/*
-						Visibility:       &jira.IssueWorklogVisibilityScheme{
-							Type:  "group",
-							Value: "jira-users",
-						},
-					*/
-					Started:          "2021-07-16T07:01:10.774+0000",
-					TimeSpentSeconds: 12000,
-				},
+			},
+			payload: &models.WorklogPayloadSchemeV2{
+				/*
+					Visibility:       &jira.IssueWorklogVisibilityScheme{
+						Type:  "group",
+						Value: "jira-users",
+					},
+				*/
+				Started:          "2021-07-16T07:01:10.774+0000",
+				TimeSpentSeconds: 12000,
 			},
 			wantHTTPMethod:     http.MethodPut,
 			endpoint:           "/rest/api/2/issue/KP-1/worklog/10000?adjustEstimate=auto&expand=expand%2Cproperties&newEstimate=2h&notifyUsers=false&overrideEditableFlag=true&reduceBy=2h",
@@ -618,16 +620,16 @@ func TestIssueWorklogService_Update(t *testing.T) {
 				OverrideEditableFlag: true,
 				NewEstimate:          "2h",
 				Expand:               []string{"expand", "properties"},
-				Payload: &models.WorklogPayloadScheme{
-					/*
-						Visibility:       &jira.IssueWorklogVisibilityScheme{
-							Type:  "group",
-							Value: "jira-users",
-						},
-					*/
-					Started:          "2021-07-16T07:01:10.774+0000",
-					TimeSpentSeconds: 12000,
-				},
+			},
+			payload: &models.WorklogPayloadSchemeV2{
+				/*
+					Visibility:       &jira.IssueWorklogVisibilityScheme{
+						Type:  "group",
+						Value: "jira-users",
+					},
+				*/
+				Started:          "2021-07-16T07:01:10.774+0000",
+				TimeSpentSeconds: 12000,
 			},
 			wantHTTPMethod:     http.MethodPut,
 			endpoint:           "/rest/api/2/issue/KP-1/worklog/10000?adjustEstimate=auto&expand=expand%2Cproperties&newEstimate=2h&notifyUsers=false&overrideEditableFlag=true&reduceBy=2h",
@@ -648,16 +650,16 @@ func TestIssueWorklogService_Update(t *testing.T) {
 				OverrideEditableFlag: true,
 				NewEstimate:          "2h",
 				Expand:               []string{"expand", "properties"},
-				Payload: &models.WorklogPayloadScheme{
-					/*
-						Visibility:       &jira.IssueWorklogVisibilityScheme{
-							Type:  "group",
-							Value: "jira-users",
-						},
-					*/
-					Started:          "2021-07-16T07:01:10.774+0000",
-					TimeSpentSeconds: 12000,
-				},
+			},
+			payload: &models.WorklogPayloadSchemeV2{
+				/*
+					Visibility:       &jira.IssueWorklogVisibilityScheme{
+						Type:  "group",
+						Value: "jira-users",
+					},
+				*/
+				Started:          "2021-07-16T07:01:10.774+0000",
+				TimeSpentSeconds: 12000,
 			},
 			wantHTTPMethod:     http.MethodPut,
 			endpoint:           "/rest/api/2/issue/KP-1/worklog/10000?adjustEstimate=auto&expand=expand%2Cproperties&newEstimate=2h&notifyUsers=false&overrideEditableFlag=true&reduceBy=2h",
@@ -678,16 +680,16 @@ func TestIssueWorklogService_Update(t *testing.T) {
 				OverrideEditableFlag: true,
 				NewEstimate:          "2h",
 				Expand:               []string{"expand", "properties"},
-				Payload: &models.WorklogPayloadScheme{
-					/*
-						Visibility:       &jira.IssueWorklogVisibilityScheme{
-							Type:  "group",
-							Value: "jira-users",
-						},
-					*/
-					Started:          "2021-07-16T07:01:10.774+0000",
-					TimeSpentSeconds: 12000,
-				},
+			},
+			payload: &models.WorklogPayloadSchemeV2{
+				/*
+					Visibility:       &jira.IssueWorklogVisibilityScheme{
+						Type:  "group",
+						Value: "jira-users",
+					},
+				*/
+				Started:          "2021-07-16T07:01:10.774+0000",
+				TimeSpentSeconds: 12000,
 			},
 			wantHTTPMethod:     http.MethodPut,
 			endpoint:           "/rest/api/2/issue/KP-1/worklog/10000?adjustEstimate=auto&expand=expand%2Cproperties&newEstimate=2h&notifyUsers=false&overrideEditableFlag=true&reduceBy=2h",
@@ -708,8 +710,8 @@ func TestIssueWorklogService_Update(t *testing.T) {
 				OverrideEditableFlag: true,
 				NewEstimate:          "2h",
 				Expand:               []string{"expand", "properties"},
-				Payload:              nil,
 			},
+			payload:            nil,
 			wantHTTPMethod:     http.MethodPut,
 			endpoint:           "/rest/api/2/issue/KP-1/worklog/10000?adjustEstimate=auto&expand=expand%2Cproperties&newEstimate=2h&notifyUsers=false&overrideEditableFlag=true&reduceBy=2h",
 			wantHTTPCodeReturn: http.StatusOK,
@@ -729,16 +731,16 @@ func TestIssueWorklogService_Update(t *testing.T) {
 				OverrideEditableFlag: true,
 				NewEstimate:          "2h",
 				Expand:               []string{"expand", "properties"},
-				Payload: &models.WorklogPayloadScheme{
-					/*
-						Visibility:       &jira.IssueWorklogVisibilityScheme{
-							Type:  "group",
-							Value: "jira-users",
-						},
-					*/
-					Started:          "2021-07-16T07:01:10.774+0000",
-					TimeSpentSeconds: 12000,
-				},
+			},
+			payload: &models.WorklogPayloadSchemeV2{
+				/*
+					Visibility:       &jira.IssueWorklogVisibilityScheme{
+						Type:  "group",
+						Value: "jira-users",
+					},
+				*/
+				Started:          "2021-07-16T07:01:10.774+0000",
+				TimeSpentSeconds: 12000,
 			},
 			wantHTTPMethod:     http.MethodDelete,
 			endpoint:           "/rest/api/2/issue/KP-1/worklog/10000?adjustEstimate=auto&expand=expand%2Cproperties&newEstimate=2h&notifyUsers=false&overrideEditableFlag=true&reduceBy=2h",
@@ -759,16 +761,16 @@ func TestIssueWorklogService_Update(t *testing.T) {
 				OverrideEditableFlag: true,
 				NewEstimate:          "2h",
 				Expand:               []string{"expand", "properties"},
-				Payload: &models.WorklogPayloadScheme{
-					/*
-						Visibility:       &jira.IssueWorklogVisibilityScheme{
-							Type:  "group",
-							Value: "jira-users",
-						},
-					*/
-					Started:          "2021-07-16T07:01:10.774+0000",
-					TimeSpentSeconds: 12000,
-				},
+			},
+			payload: &models.WorklogPayloadSchemeV2{
+				/*
+					Visibility:       &jira.IssueWorklogVisibilityScheme{
+						Type:  "group",
+						Value: "jira-users",
+					},
+				*/
+				Started:          "2021-07-16T07:01:10.774+0000",
+				TimeSpentSeconds: 12000,
 			},
 			wantHTTPMethod:     http.MethodPut,
 			endpoint:           "/rest/api/2/issue/KP-1/worklog/10000?adjustEstimate=auto&expand=expand%2Cproperties&newEstimate=2h&notifyUsers=false&overrideEditableFlag=true&reduceBy=2h",
@@ -804,7 +806,7 @@ func TestIssueWorklogService_Update(t *testing.T) {
 
 			i := &IssueWorklogService{client: mockClient}
 
-			gotResult, gotResponse, err := i.Update(testCase.ctx, testCase.issueKeyOrID, testCase.worklogID, testCase.options)
+			gotResult, gotResponse, err := i.Update(testCase.ctx, testCase.issueKeyOrID, testCase.worklogID, testCase.payload, testCase.options)
 
 			if testCase.wantErr {
 
@@ -868,16 +870,6 @@ func TestIssueWorklogService_Delete(t *testing.T) {
 				OverrideEditableFlag: true,
 				NewEstimate:          "2h",
 				Expand:               []string{"expand", "properties"},
-				Payload: &models.WorklogPayloadScheme{
-					/*
-						Visibility:       &jira.IssueWorklogVisibilityScheme{
-							Type:  "group",
-							Value: "jira-users",
-						},
-					*/
-					Started:          "2021-07-16T07:01:10.774+0000",
-					TimeSpentSeconds: 12000,
-				},
 			},
 			wantHTTPMethod:     http.MethodDelete,
 			endpoint:           "/rest/api/2/issue/KP-1/worklog/10000?adjustEstimate=auto&expand=expand%2Cproperties&newEstimate=2h&notifyUsers=false&overrideEditableFlag=true&reduceBy=2h",
@@ -898,16 +890,6 @@ func TestIssueWorklogService_Delete(t *testing.T) {
 				OverrideEditableFlag: true,
 				NewEstimate:          "2h",
 				Expand:               []string{"expand", "properties"},
-				Payload: &models.WorklogPayloadScheme{
-					/*
-						Visibility:       &jira.IssueWorklogVisibilityScheme{
-							Type:  "group",
-							Value: "jira-users",
-						},
-					*/
-					Started:          "2021-07-16T07:01:10.774+0000",
-					TimeSpentSeconds: 12000,
-				},
 			},
 			wantHTTPMethod:     http.MethodDelete,
 			endpoint:           "/rest/api/2/issue/KP-1/worklog/10000?adjustEstimate=auto&expand=expand%2Cproperties&newEstimate=2h&notifyUsers=false&overrideEditableFlag=true&reduceBy=2h",
@@ -928,16 +910,6 @@ func TestIssueWorklogService_Delete(t *testing.T) {
 				OverrideEditableFlag: true,
 				NewEstimate:          "2h",
 				Expand:               []string{"expand", "properties"},
-				Payload: &models.WorklogPayloadScheme{
-					/*
-						Visibility:       &jira.IssueWorklogVisibilityScheme{
-							Type:  "group",
-							Value: "jira-users",
-						},
-					*/
-					Started:          "2021-07-16T07:01:10.774+0000",
-					TimeSpentSeconds: 12000,
-				},
 			},
 			wantHTTPMethod:     http.MethodDelete,
 			endpoint:           "/rest/api/2/issue/KP-1/worklog/10000?adjustEstimate=auto&expand=expand%2Cproperties&newEstimate=2h&notifyUsers=false&overrideEditableFlag=true&reduceBy=2h",
@@ -958,16 +930,6 @@ func TestIssueWorklogService_Delete(t *testing.T) {
 				OverrideEditableFlag: true,
 				NewEstimate:          "2h",
 				Expand:               []string{"expand", "properties"},
-				Payload: &models.WorklogPayloadScheme{
-					/*
-						Visibility:       &jira.IssueWorklogVisibilityScheme{
-							Type:  "group",
-							Value: "jira-users",
-						},
-					*/
-					Started:          "2021-07-16T07:01:10.774+0000",
-					TimeSpentSeconds: 12000,
-				},
 			},
 			wantHTTPMethod:     http.MethodDelete,
 			endpoint:           "/rest/api/2/issue/KP-1/worklog/10000?adjustEstimate=auto&expand=expand%2Cproperties&newEstimate=2h&notifyUsers=false&overrideEditableFlag=true&reduceBy=2h",
@@ -1021,16 +983,6 @@ func TestIssueWorklogService_Delete(t *testing.T) {
 				OverrideEditableFlag: true,
 				NewEstimate:          "2h",
 				Expand:               []string{"expand", "properties"},
-				Payload: &models.WorklogPayloadScheme{
-					/*
-						Visibility:       &jira.IssueWorklogVisibilityScheme{
-							Type:  "group",
-							Value: "jira-users",
-						},
-					*/
-					Started:          "2021-07-16T07:01:10.774+0000",
-					TimeSpentSeconds: 12000,
-				},
 			},
 			wantHTTPMethod:     http.MethodDelete,
 			endpoint:           "/rest/api/2/issue/KP-1/worklog/10000?adjustEstimate=auto&expand=expand%2Cproperties&newEstimate=2h&notifyUsers=false&overrideEditableFlag=true&reduceBy=2h",
diff --git a/jira/v3/issueWorklog_test.go b/jira/v3/issueWorklog_test.go
index 2ed1de9..70eada1 100644
--- a/jira/v3/issueWorklog_test.go
+++ b/jira/v3/issueWorklog_test.go
@@ -329,6 +329,7 @@ func TestIssueWorklogService_Add(t *testing.T) {
 		name               string
 		ctx                context.Context
 		issueKeyOrID       string
+		payload            *models.WorklogPayloadSchemeV3
 		options            *models.WorklogOptionsScheme
 		mockFile           string
 		wantHTTPMethod     string
@@ -348,16 +349,16 @@ func TestIssueWorklogService_Add(t *testing.T) {
 				OverrideEditableFlag: true,
 				NewEstimate:          "3h",
 				Expand:               []string{"expand", "properties"},
-				Payload: &models.WorklogPayloadScheme{
-					/*
-						Visibility:       &jira.IssueWorklogVisibilityScheme{
-							Type:  "group",
-							Value: "jira-users",
-						},
-					*/
-					Started:          "2021-07-16T07:01:10.774+0000",
-					TimeSpentSeconds: 12000,
-				},
+			},
+			payload: &models.WorklogPayloadSchemeV3{
+				/*
+					Visibility:       &jira.IssueWorklogVisibilityScheme{
+						Type:  "group",
+						Value: "jira-users",
+					},
+				*/
+				Started:          "2021-07-16T07:01:10.774+0000",
+				TimeSpentSeconds: 12000,
 			},
 			wantHTTPMethod:     http.MethodPost,
 			endpoint:           "/rest/api/3/issue/KP-1/worklog?adjustEstimate=auto&expand=expand%2Cproperties&newEstimate=3h&notifyUsers=false&overrideEditableFlag=true&reduceBy=3h",
@@ -376,16 +377,16 @@ func TestIssueWorklogService_Add(t *testing.T) {
 				ReduceBy:       "3h",
 				//OverrideEditableFlag: true,
 				Expand: []string{"expand", "properties"},
-				Payload: &models.WorklogPayloadScheme{
-					/*
-						Visibility:       &jira.IssueWorklogVisibilityScheme{
-							Type:  "group",
-							Value: "jira-users",
-						},
-					*/
-					Started:          "2021-07-16T07:01:10.774+0000",
-					TimeSpentSeconds: 12000,
-				},
+			},
+			payload: &models.WorklogPayloadSchemeV3{
+				/*
+					Visibility:       &jira.IssueWorklogVisibilityScheme{
+						Type:  "group",
+						Value: "jira-users",
+					},
+				*/
+				Started:          "2021-07-16T07:01:10.774+0000",
+				TimeSpentSeconds: 12000,
 			},
 			wantHTTPMethod:     http.MethodPost,
 			endpoint:           "/rest/api/3/issue/KP-1/worklog?adjustEstimate=auto&expand=expand%2Cproperties&reduceBy=3h",
@@ -404,16 +405,16 @@ func TestIssueWorklogService_Add(t *testing.T) {
 				ReduceBy:       "3h",
 				//OverrideEditableFlag: true,
 				Expand: []string{"expand", "properties"},
-				Payload: &models.WorklogPayloadScheme{
-					/*
-						Visibility:       &jira.IssueWorklogVisibilityScheme{
-							Type:  "group",
-							Value: "jira-users",
-						},
-					*/
-					Started:          "2021-07-16T07:01:10.774+0000",
-					TimeSpentSeconds: 12000,
-				},
+			},
+			payload: &models.WorklogPayloadSchemeV3{
+				/*
+					Visibility:       &jira.IssueWorklogVisibilityScheme{
+						Type:  "group",
+						Value: "jira-users",
+					},
+				*/
+				Started:          "2021-07-16T07:01:10.774+0000",
+				TimeSpentSeconds: 12000,
 			},
 			wantHTTPMethod:     http.MethodPost,
 			endpoint:           "/rest/api/3/issue/KP-1/worklog?adjustEstimate=auto&expand=expand%2Cproperties&reduceBy=3h",
@@ -431,9 +432,9 @@ func TestIssueWorklogService_Add(t *testing.T) {
 				AdjustEstimate: "auto",
 				ReduceBy:       "3h",
 				//OverrideEditableFlag: true,
-				Expand:  []string{"expand", "properties"},
-				Payload: nil,
+				Expand: []string{"expand", "properties"},
 			},
+			payload:            nil,
 			wantHTTPMethod:     http.MethodPost,
 			endpoint:           "/rest/api/3/issue/KP-1/worklog?adjustEstimate=auto&expand=expand%2Cproperties&reduceBy=3h",
 			wantHTTPCodeReturn: http.StatusOK,
@@ -451,16 +452,16 @@ func TestIssueWorklogService_Add(t *testing.T) {
 				ReduceBy:       "3h",
 				//OverrideEditableFlag: true,
 				Expand: []string{"expand", "properties"},
-				Payload: &models.WorklogPayloadScheme{
-					/*
-						Visibility:       &jira.IssueWorklogVisibilityScheme{
-							Type:  "group",
-							Value: "jira-users",
-						},
-					*/
-					Started:          "2021-07-16T07:01:10.774+0000",
-					TimeSpentSeconds: 12000,
-				},
+			},
+			payload: &models.WorklogPayloadSchemeV3{
+				/*
+					Visibility:       &jira.IssueWorklogVisibilityScheme{
+						Type:  "group",
+						Value: "jira-users",
+					},
+				*/
+				Started:          "2021-07-16T07:01:10.774+0000",
+				TimeSpentSeconds: 12000,
 			},
 			wantHTTPMethod:     http.MethodGet,
 			endpoint:           "/rest/api/3/issue/KP-1/worklog?adjustEstimate=auto&expand=expand%2Cproperties&reduceBy=3h",
@@ -479,16 +480,16 @@ func TestIssueWorklogService_Add(t *testing.T) {
 				ReduceBy:       "3h",
 				//OverrideEditableFlag: true,
 				Expand: []string{"expand", "properties"},
-				Payload: &models.WorklogPayloadScheme{
-					/*
-						Visibility:       &jira.IssueWorklogVisibilityScheme{
-							Type:  "group",
-							Value: "jira-users",
-						},
-					*/
-					Started:          "2021-07-16T07:01:10.774+0000",
-					TimeSpentSeconds: 12000,
-				},
+			},
+			payload: &models.WorklogPayloadSchemeV3{
+				/*
+					Visibility:       &jira.IssueWorklogVisibilityScheme{
+						Type:  "group",
+						Value: "jira-users",
+					},
+				*/
+				Started:          "2021-07-16T07:01:10.774+0000",
+				TimeSpentSeconds: 12000,
 			},
 			wantHTTPMethod:     http.MethodPost,
 			endpoint:           "/rest/api/3/issue/KP-1/worklog?adjustEstimate=auto&expand=expand%2Cproperties&reduceBy=3h",
@@ -524,7 +525,7 @@ func TestIssueWorklogService_Add(t *testing.T) {
 
 			i := &IssueWorklogService{client: mockClient}
 
-			gotResult, gotResponse, err := i.Add(testCase.ctx, testCase.issueKeyOrID, testCase.options)
+			gotResult, gotResponse, err := i.Add(testCase.ctx, testCase.issueKeyOrID, testCase.payload, testCase.options)
 
 			if testCase.wantErr {
 
@@ -568,6 +569,7 @@ func TestIssueWorklogService_Update(t *testing.T) {
 		ctx                context.Context
 		issueKeyOrID       string
 		worklogID          string
+		payload            *models.WorklogPayloadSchemeV3
 		options            *models.WorklogOptionsScheme
 		mockFile           string
 		wantHTTPMethod     string
@@ -588,16 +590,16 @@ func TestIssueWorklogService_Update(t *testing.T) {
 				OverrideEditableFlag: true,
 				NewEstimate:          "3h",
 				Expand:               []string{"expand", "properties"},
-				Payload: &models.WorklogPayloadScheme{
-					/*
-						Visibility:       &jira.IssueWorklogVisibilityScheme{
-							Type:  "group",
-							Value: "jira-users",
-						},
-					*/
-					Started:          "2021-07-16T07:01:10.774+0000",
-					TimeSpentSeconds: 12000,
-				},
+			},
+			payload: &models.WorklogPayloadSchemeV3{
+				/*
+					Visibility:       &jira.IssueWorklogVisibilityScheme{
+						Type:  "group",
+						Value: "jira-users",
+					},
+				*/
+				Started:          "2021-07-16T07:01:10.774+0000",
+				TimeSpentSeconds: 12000,
 			},
 			wantHTTPMethod:     http.MethodPut,
 			endpoint:           "/rest/api/3/issue/KP-1/worklog/10000?adjustEstimate=auto&expand=expand%2Cproperties&newEstimate=3h&notifyUsers=false&overrideEditableFlag=true&reduceBy=3h",
@@ -618,16 +620,16 @@ func TestIssueWorklogService_Update(t *testing.T) {
 				OverrideEditableFlag: true,
 				NewEstimate:          "3h",
 				Expand:               []string{"expand", "properties"},
-				Payload: &models.WorklogPayloadScheme{
-					/*
-						Visibility:       &jira.IssueWorklogVisibilityScheme{
-							Type:  "group",
-							Value: "jira-users",
-						},
-					*/
-					Started:          "2021-07-16T07:01:10.774+0000",
-					TimeSpentSeconds: 12000,
-				},
+			},
+			payload: &models.WorklogPayloadSchemeV3{
+				/*
+					Visibility:       &jira.IssueWorklogVisibilityScheme{
+						Type:  "group",
+						Value: "jira-users",
+					},
+				*/
+				Started:          "2021-07-16T07:01:10.774+0000",
+				TimeSpentSeconds: 12000,
 			},
 			wantHTTPMethod:     http.MethodPut,
 			endpoint:           "/rest/api/3/issue/KP-1/worklog/10000?adjustEstimate=auto&expand=expand%2Cproperties&newEstimate=3h&notifyUsers=false&overrideEditableFlag=true&reduceBy=3h",
@@ -648,16 +650,16 @@ func TestIssueWorklogService_Update(t *testing.T) {
 				OverrideEditableFlag: true,
 				NewEstimate:          "3h",
 				Expand:               []string{"expand", "properties"},
-				Payload: &models.WorklogPayloadScheme{
-					/*
-						Visibility:       &jira.IssueWorklogVisibilityScheme{
-							Type:  "group",
-							Value: "jira-users",
-						},
-					*/
-					Started:          "2021-07-16T07:01:10.774+0000",
-					TimeSpentSeconds: 12000,
-				},
+			},
+			payload: &models.WorklogPayloadSchemeV3{
+				/*
+					Visibility:       &jira.IssueWorklogVisibilityScheme{
+						Type:  "group",
+						Value: "jira-users",
+					},
+				*/
+				Started:          "2021-07-16T07:01:10.774+0000",
+				TimeSpentSeconds: 12000,
 			},
 			wantHTTPMethod:     http.MethodPut,
 			endpoint:           "/rest/api/3/issue/KP-1/worklog/10000?adjustEstimate=auto&expand=expand%2Cproperties&newEstimate=3h&notifyUsers=false&overrideEditableFlag=true&reduceBy=3h",
@@ -678,16 +680,16 @@ func TestIssueWorklogService_Update(t *testing.T) {
 				OverrideEditableFlag: true,
 				NewEstimate:          "3h",
 				Expand:               []string{"expand", "properties"},
-				Payload: &models.WorklogPayloadScheme{
-					/*
-						Visibility:       &jira.IssueWorklogVisibilityScheme{
-							Type:  "group",
-							Value: "jira-users",
-						},
-					*/
-					Started:          "2021-07-16T07:01:10.774+0000",
-					TimeSpentSeconds: 12000,
-				},
+			},
+			payload: &models.WorklogPayloadSchemeV3{
+				/*
+					Visibility:       &jira.IssueWorklogVisibilityScheme{
+						Type:  "group",
+						Value: "jira-users",
+					},
+				*/
+				Started:          "2021-07-16T07:01:10.774+0000",
+				TimeSpentSeconds: 12000,
 			},
 			wantHTTPMethod:     http.MethodPut,
 			endpoint:           "/rest/api/3/issue/KP-1/worklog/10000?adjustEstimate=auto&expand=expand%2Cproperties&newEstimate=3h&notifyUsers=false&overrideEditableFlag=true&reduceBy=3h",
@@ -708,8 +710,8 @@ func TestIssueWorklogService_Update(t *testing.T) {
 				OverrideEditableFlag: true,
 				NewEstimate:          "3h",
 				Expand:               []string{"expand", "properties"},
-				Payload:              nil,
 			},
+			payload:            nil,
 			wantHTTPMethod:     http.MethodPut,
 			endpoint:           "/rest/api/3/issue/KP-1/worklog/10000?adjustEstimate=auto&expand=expand%2Cproperties&newEstimate=3h&notifyUsers=false&overrideEditableFlag=true&reduceBy=3h",
 			wantHTTPCodeReturn: http.StatusOK,
@@ -729,16 +731,16 @@ func TestIssueWorklogService_Update(t *testing.T) {
 				OverrideEditableFlag: true,
 				NewEstimate:          "3h",
 				Expand:               []string{"expand", "properties"},
-				Payload: &models.WorklogPayloadScheme{
-					/*
-						Visibility:       &jira.IssueWorklogVisibilityScheme{
-							Type:  "group",
-							Value: "jira-users",
-						},
-					*/
-					Started:          "2021-07-16T07:01:10.774+0000",
-					TimeSpentSeconds: 12000,
-				},
+			},
+			payload: &models.WorklogPayloadSchemeV3{
+				/*
+					Visibility:       &jira.IssueWorklogVisibilityScheme{
+						Type:  "group",
+						Value: "jira-users",
+					},
+				*/
+				Started:          "2021-07-16T07:01:10.774+0000",
+				TimeSpentSeconds: 12000,
 			},
 			wantHTTPMethod:     http.MethodDelete,
 			endpoint:           "/rest/api/3/issue/KP-1/worklog/10000?adjustEstimate=auto&expand=expand%2Cproperties&newEstimate=3h&notifyUsers=false&overrideEditableFlag=true&reduceBy=3h",
@@ -759,16 +761,16 @@ func TestIssueWorklogService_Update(t *testing.T) {
 				OverrideEditableFlag: true,
 				NewEstimate:          "3h",
 				Expand:               []string{"expand", "properties"},
-				Payload: &models.WorklogPayloadScheme{
-					/*
-						Visibility:       &jira.IssueWorklogVisibilityScheme{
-							Type:  "group",
-							Value: "jira-users",
-						},
-					*/
-					Started:          "2021-07-16T07:01:10.774+0000",
-					TimeSpentSeconds: 12000,
-				},
+			},
+			payload: &models.WorklogPayloadSchemeV3{
+				/*
+					Visibility:       &jira.IssueWorklogVisibilityScheme{
+						Type:  "group",
+						Value: "jira-users",
+					},
+				*/
+				Started:          "2021-07-16T07:01:10.774+0000",
+				TimeSpentSeconds: 12000,
 			},
 			wantHTTPMethod:     http.MethodPut,
 			endpoint:           "/rest/api/3/issue/KP-1/worklog/10000?adjustEstimate=auto&expand=expand%2Cproperties&newEstimate=3h&notifyUsers=false&overrideEditableFlag=true&reduceBy=3h",
@@ -804,7 +806,7 @@ func TestIssueWorklogService_Update(t *testing.T) {
 
 			i := &IssueWorklogService{client: mockClient}
 
-			gotResult, gotResponse, err := i.Update(testCase.ctx, testCase.issueKeyOrID, testCase.worklogID, testCase.options)
+			gotResult, gotResponse, err := i.Update(testCase.ctx, testCase.issueKeyOrID, testCase.worklogID, testCase.payload, testCase.options)
 
 			if testCase.wantErr {
 
@@ -868,16 +870,6 @@ func TestIssueWorklogService_Delete(t *testing.T) {
 				OverrideEditableFlag: true,
 				NewEstimate:          "3h",
 				Expand:               []string{"expand", "properties"},
-				Payload: &models.WorklogPayloadScheme{
-					/*
-						Visibility:       &jira.IssueWorklogVisibilityScheme{
-							Type:  "group",
-							Value: "jira-users",
-						},
-					*/
-					Started:          "2021-07-16T07:01:10.774+0000",
-					TimeSpentSeconds: 12000,
-				},
 			},
 			wantHTTPMethod:     http.MethodDelete,
 			endpoint:           "/rest/api/3/issue/KP-1/worklog/10000?adjustEstimate=auto&expand=expand%2Cproperties&newEstimate=3h&notifyUsers=false&overrideEditableFlag=true&reduceBy=3h",
@@ -898,16 +890,6 @@ func TestIssueWorklogService_Delete(t *testing.T) {
 				OverrideEditableFlag: true,
 				NewEstimate:          "3h",
 				Expand:               []string{"expand", "properties"},
-				Payload: &models.WorklogPayloadScheme{
-					/*
-						Visibility:       &jira.IssueWorklogVisibilityScheme{
-							Type:  "group",
-							Value: "jira-users",
-						},
-					*/
-					Started:          "2021-07-16T07:01:10.774+0000",
-					TimeSpentSeconds: 12000,
-				},
 			},
 			wantHTTPMethod:     http.MethodDelete,
 			endpoint:           "/rest/api/3/issue/KP-1/worklog/10000?adjustEstimate=auto&expand=expand%2Cproperties&newEstimate=3h&notifyUsers=false&overrideEditableFlag=true&reduceBy=3h",
@@ -928,16 +910,6 @@ func TestIssueWorklogService_Delete(t *testing.T) {
 				OverrideEditableFlag: true,
 				NewEstimate:          "3h",
 				Expand:               []string{"expand", "properties"},
-				Payload: &models.WorklogPayloadScheme{
-					/*
-						Visibility:       &jira.IssueWorklogVisibilityScheme{
-							Type:  "group",
-							Value: "jira-users",
-						},
-					*/
-					Started:          "2021-07-16T07:01:10.774+0000",
-					TimeSpentSeconds: 12000,
-				},
 			},
 			wantHTTPMethod:     http.MethodDelete,
 			endpoint:           "/rest/api/3/issue/KP-1/worklog/10000?adjustEstimate=auto&expand=expand%2Cproperties&newEstimate=3h&notifyUsers=false&overrideEditableFlag=true&reduceBy=3h",
@@ -958,16 +930,6 @@ func TestIssueWorklogService_Delete(t *testing.T) {
 				OverrideEditableFlag: true,
 				NewEstimate:          "3h",
 				Expand:               []string{"expand", "properties"},
-				Payload: &models.WorklogPayloadScheme{
-					/*
-						Visibility:       &jira.IssueWorklogVisibilityScheme{
-							Type:  "group",
-							Value: "jira-users",
-						},
-					*/
-					Started:          "2021-07-16T07:01:10.774+0000",
-					TimeSpentSeconds: 12000,
-				},
 			},
 			wantHTTPMethod:     http.MethodDelete,
 			endpoint:           "/rest/api/3/issue/KP-1/worklog/10000?adjustEstimate=auto&expand=expand%2Cproperties&newEstimate=3h&notifyUsers=false&overrideEditableFlag=true&reduceBy=3h",
@@ -1021,16 +983,6 @@ func TestIssueWorklogService_Delete(t *testing.T) {
 				OverrideEditableFlag: true,
 				NewEstimate:          "3h",
 				Expand:               []string{"expand", "properties"},
-				Payload: &models.WorklogPayloadScheme{
-					/*
-						Visibility:       &jira.IssueWorklogVisibilityScheme{
-							Type:  "group",
-							Value: "jira-users",
-						},
-					*/
-					Started:          "2021-07-16T07:01:10.774+0000",
-					TimeSpentSeconds: 12000,
-				},
 			},
 			wantHTTPMethod:     http.MethodDelete,
 			endpoint:           "/rest/api/3/issue/KP-1/worklog/10000?adjustEstimate=auto&expand=expand%2Cproperties&newEstimate=3h&notifyUsers=false&overrideEditableFlag=true&reduceBy=3h",