Skip to content

Commit

Permalink
🐛 Added the ability to extract the issue workflow comments based on t…
Browse files Browse the repository at this point in the history
…he Jira version.
  • Loading branch information
ctreminiom committed Apr 29, 2023
1 parent 511fc99 commit 77efacf
Show file tree
Hide file tree
Showing 6 changed files with 152 additions and 103 deletions.
30 changes: 15 additions & 15 deletions jira/internal/worklog_impl_adf.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type WorklogADFService struct {
// POST /rest/api/{2-3}/worklog/list
//
// https://docs.go-atlassian.io/jira-software-cloud/issues/worklogs#get-worklogs
func (w *WorklogADFService) Gets(ctx context.Context, worklogIds []int, expand []string) ([]*model.IssueWorklogScheme, *model.ResponseScheme, error) {
func (w *WorklogADFService) Gets(ctx context.Context, worklogIds []int, expand []string) ([]*model.IssueWorklogADFScheme, *model.ResponseScheme, error) {
return w.internalClient.Gets(ctx, worklogIds, expand)
}

Expand All @@ -45,7 +45,7 @@ func (w *WorklogADFService) Gets(ctx context.Context, worklogIds []int, expand [
// GET /rest/api/{2-3}/issue/{issueIdOrKey}/worklog/{id}
//
// https://docs.go-atlassian.io/jira-software-cloud/issues/worklogs#get-worklog
func (w *WorklogADFService) Get(ctx context.Context, issueKeyOrId, worklogId string, expand []string) (*model.IssueWorklogScheme, *model.ResponseScheme, error) {
func (w *WorklogADFService) Get(ctx context.Context, issueKeyOrId, worklogId string, expand []string) (*model.IssueWorklogADFScheme, *model.ResponseScheme, error) {
return w.internalClient.Get(ctx, issueKeyOrId, worklogId, expand)
}

Expand All @@ -56,7 +56,7 @@ func (w *WorklogADFService) Get(ctx context.Context, issueKeyOrId, worklogId str
// GET /rest/api/{2-3}/issue/{issueIdOrKey}/worklog
//
// https://docs.go-atlassian.io/jira-software-cloud/issues/worklogs#get-issue-worklogs
func (w *WorklogADFService) Issue(ctx context.Context, issueKeyOrId string, startAt, maxResults, after int, expand []string) (*model.IssueWorklogPageScheme, *model.ResponseScheme, error) {
func (w *WorklogADFService) Issue(ctx context.Context, issueKeyOrId string, startAt, maxResults, after int, expand []string) (*model.IssueWorklogADFPageScheme, *model.ResponseScheme, error) {
return w.internalClient.Issue(ctx, issueKeyOrId, startAt, maxResults, after, expand)
}

Expand Down Expand Up @@ -110,7 +110,7 @@ func (w *WorklogADFService) Updated(ctx context.Context, since int, expand []str
// POST /rest/api/3/issue/{issueIdOrKey}/worklog
//
// https://docs.go-atlassian.io/jira-software-cloud/issues/worklogs#add-worklog
func (w *WorklogADFService) Add(ctx context.Context, issueKeyOrID string, payload *model.WorklogPayloadSchemeV3, options *model.WorklogOptionsScheme) (*model.IssueWorklogScheme, *model.ResponseScheme, error) {
func (w *WorklogADFService) Add(ctx context.Context, issueKeyOrID string, payload *model.WorklogADFPayloadScheme, options *model.WorklogOptionsScheme) (*model.IssueWorklogADFScheme, *model.ResponseScheme, error) {
return w.internalClient.Add(ctx, issueKeyOrID, payload, options)
}

Expand All @@ -121,7 +121,7 @@ func (w *WorklogADFService) Add(ctx context.Context, issueKeyOrID string, payloa
// PUT /rest/api/3/issue/{issueIdOrKey}/worklog/{id}
//
// https://docs.go-atlassian.io/jira-software-cloud/issues/worklogs#update-worklog
func (w *WorklogADFService) Update(ctx context.Context, issueKeyOrId, worklogId string, payload *model.WorklogPayloadSchemeV3, options *model.WorklogOptionsScheme) (*model.IssueWorklogScheme, *model.ResponseScheme, error) {
func (w *WorklogADFService) Update(ctx context.Context, issueKeyOrId, worklogId string, payload *model.WorklogADFPayloadScheme, options *model.WorklogOptionsScheme) (*model.IssueWorklogADFScheme, *model.ResponseScheme, error) {
return w.internalClient.Update(ctx, issueKeyOrId, worklogId, payload, options)
}

Expand All @@ -130,7 +130,7 @@ type internalWorklogAdfImpl struct {
version string
}

func (i *internalWorklogAdfImpl) Gets(ctx context.Context, worklogIds []int, expand []string) ([]*model.IssueWorklogScheme, *model.ResponseScheme, error) {
func (i *internalWorklogAdfImpl) Gets(ctx context.Context, worklogIds []int, expand []string) ([]*model.IssueWorklogADFScheme, *model.ResponseScheme, error) {

if len(worklogIds) == 0 {
return nil, nil, model.ErrNpWorklogsError
Expand Down Expand Up @@ -164,7 +164,7 @@ func (i *internalWorklogAdfImpl) Gets(ctx context.Context, worklogIds []int, exp
return nil, nil, err
}

var worklogs []*model.IssueWorklogScheme
var worklogs []*model.IssueWorklogADFScheme
response, err := i.c.Call(request, &worklogs)
if err != nil {
return nil, response, err
Expand All @@ -173,7 +173,7 @@ func (i *internalWorklogAdfImpl) Gets(ctx context.Context, worklogIds []int, exp
return worklogs, response, nil
}

func (i *internalWorklogAdfImpl) Get(ctx context.Context, issueKeyOrId, worklogId string, expand []string) (*model.IssueWorklogScheme, *model.ResponseScheme, error) {
func (i *internalWorklogAdfImpl) Get(ctx context.Context, issueKeyOrId, worklogId string, expand []string) (*model.IssueWorklogADFScheme, *model.ResponseScheme, error) {

if issueKeyOrId == "" {
return nil, nil, model.ErrNoIssueKeyOrIDError
Expand All @@ -200,7 +200,7 @@ func (i *internalWorklogAdfImpl) Get(ctx context.Context, issueKeyOrId, worklogI
return nil, nil, err
}

worklog := new(model.IssueWorklogScheme)
worklog := new(model.IssueWorklogADFScheme)
response, err := i.c.Call(request, worklog)
if err != nil {
return nil, response, err
Expand All @@ -209,7 +209,7 @@ func (i *internalWorklogAdfImpl) Get(ctx context.Context, issueKeyOrId, worklogI
return worklog, response, nil
}

func (i *internalWorklogAdfImpl) Issue(ctx context.Context, issueKeyOrId string, startAt, maxResults, after int, expand []string) (*model.IssueWorklogPageScheme, *model.ResponseScheme, error) {
func (i *internalWorklogAdfImpl) Issue(ctx context.Context, issueKeyOrId string, startAt, maxResults, after int, expand []string) (*model.IssueWorklogADFPageScheme, *model.ResponseScheme, error) {

if issueKeyOrId == "" {
return nil, nil, model.ErrNoIssueKeyOrIDError
Expand All @@ -234,7 +234,7 @@ func (i *internalWorklogAdfImpl) Issue(ctx context.Context, issueKeyOrId string,
return nil, nil, err
}

worklogs := new(model.IssueWorklogPageScheme)
worklogs := new(model.IssueWorklogADFPageScheme)
response, err := i.c.Call(request, worklogs)
if err != nil {
return nil, response, err
Expand Down Expand Up @@ -349,7 +349,7 @@ func (i *internalWorklogAdfImpl) Updated(ctx context.Context, since int, expand
return worklogs, response, nil
}

func (i *internalWorklogAdfImpl) Add(ctx context.Context, issueKeyOrID string, payload *model.WorklogPayloadSchemeV3, options *model.WorklogOptionsScheme) (*model.IssueWorklogScheme, *model.ResponseScheme, error) {
func (i *internalWorklogAdfImpl) Add(ctx context.Context, issueKeyOrID string, payload *model.WorklogADFPayloadScheme, options *model.WorklogOptionsScheme) (*model.IssueWorklogADFScheme, *model.ResponseScheme, error) {

if issueKeyOrID == "" {
return nil, nil, model.ErrNoIssueKeyOrIDError
Expand Down Expand Up @@ -394,7 +394,7 @@ func (i *internalWorklogAdfImpl) Add(ctx context.Context, issueKeyOrID string, p
return nil, nil, err
}

worklog := new(model.IssueWorklogScheme)
worklog := new(model.IssueWorklogADFScheme)
response, err := i.c.Call(request, worklog)
if err != nil {
return nil, response, err
Expand All @@ -403,7 +403,7 @@ func (i *internalWorklogAdfImpl) Add(ctx context.Context, issueKeyOrID string, p
return worklog, response, nil
}

func (i *internalWorklogAdfImpl) Update(ctx context.Context, issueKeyOrId, worklogId string, payload *model.WorklogPayloadSchemeV3, options *model.WorklogOptionsScheme) (*model.IssueWorklogScheme, *model.ResponseScheme, error) {
func (i *internalWorklogAdfImpl) Update(ctx context.Context, issueKeyOrId, worklogId string, payload *model.WorklogADFPayloadScheme, options *model.WorklogOptionsScheme) (*model.IssueWorklogADFScheme, *model.ResponseScheme, error) {

if issueKeyOrId == "" {
return nil, nil, model.ErrNoIssueKeyOrIDError
Expand Down Expand Up @@ -452,7 +452,7 @@ func (i *internalWorklogAdfImpl) Update(ctx context.Context, issueKeyOrId, workl
return nil, nil, err
}

worklog := new(model.IssueWorklogScheme)
worklog := new(model.IssueWorklogADFScheme)
response, err := i.c.Call(request, worklog)
if err != nil {
return nil, response, err
Expand Down
28 changes: 14 additions & 14 deletions jira/internal/worklog_impl_adf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func Test_internalWorklogAdfImpl_Get(t *testing.T) {

client.On("Call",
&http.Request{},
&model.IssueWorklogScheme{}).
&model.IssueWorklogADFScheme{}).
Return(&model.ResponseScheme{}, nil)

fields.c = client
Expand Down Expand Up @@ -251,7 +251,7 @@ func Test_internalWorklogAdfImpl_Get(t *testing.T) {

client.On("Call",
&http.Request{},
&model.IssueWorklogScheme{}).
&model.IssueWorklogADFScheme{}).
Return(&model.ResponseScheme{}, nil)

fields.c = client
Expand Down Expand Up @@ -385,7 +385,7 @@ func Test_internalWorklogAdfImpl_Issue(t *testing.T) {

client.On("Call",
&http.Request{},
&model.IssueWorklogPageScheme{}).
&model.IssueWorklogADFPageScheme{}).
Return(&model.ResponseScheme{}, nil)

fields.c = client
Expand Down Expand Up @@ -418,7 +418,7 @@ func Test_internalWorklogAdfImpl_Issue(t *testing.T) {

client.On("Call",
&http.Request{},
&model.IssueWorklogPageScheme{}).
&model.IssueWorklogADFPageScheme{}).
Return(&model.ResponseScheme{}, nil)

fields.c = client
Expand Down Expand Up @@ -992,7 +992,7 @@ func Test_internalWorklogAdfImpl_Add(t *testing.T) {
},
})

payloadMocked := &model.WorklogPayloadSchemeV3{
payloadMocked := &model.WorklogADFPayloadScheme{
Comment: worklogCommentMocked,
Visibility: &model.IssueWorklogVisibilityScheme{
Type: "group",
Expand All @@ -1011,7 +1011,7 @@ func Test_internalWorklogAdfImpl_Add(t *testing.T) {
type args struct {
ctx context.Context
issueKeyOrID string
payload *model.WorklogPayloadSchemeV3
payload *model.WorklogADFPayloadScheme
options *model.WorklogOptionsScheme
}

Expand Down Expand Up @@ -1056,7 +1056,7 @@ func Test_internalWorklogAdfImpl_Add(t *testing.T) {

client.On("Call",
&http.Request{},
&model.IssueWorklogScheme{}).
&model.IssueWorklogADFScheme{}).
Return(&model.ResponseScheme{}, nil)

fields.c = client
Expand Down Expand Up @@ -1098,7 +1098,7 @@ func Test_internalWorklogAdfImpl_Add(t *testing.T) {

client.On("Call",
&http.Request{},
&model.IssueWorklogScheme{}).
&model.IssueWorklogADFScheme{}).
Return(&model.ResponseScheme{}, nil)

fields.c = client
Expand All @@ -1120,7 +1120,7 @@ func Test_internalWorklogAdfImpl_Add(t *testing.T) {
client := mocks.NewClient(t)

client.On("TransformStructToReader",
(*model.WorklogPayloadSchemeV3)(nil)).
(*model.WorklogADFPayloadScheme)(nil)).
Return(bytes.NewReader([]byte{}), model.ErrNonPayloadPointerError)

fields.c = client
Expand Down Expand Up @@ -1216,7 +1216,7 @@ func Test_internalWorklogAdfImpl_Update(t *testing.T) {
},
})

payloadMocked := &model.WorklogPayloadSchemeV3{
payloadMocked := &model.WorklogADFPayloadScheme{
Comment: worklogCommentMocked,
Visibility: &model.IssueWorklogVisibilityScheme{
Type: "group",
Expand All @@ -1235,7 +1235,7 @@ func Test_internalWorklogAdfImpl_Update(t *testing.T) {
type args struct {
ctx context.Context
issueKeyOrID, worklogId string
payload *model.WorklogPayloadSchemeV3
payload *model.WorklogADFPayloadScheme
options *model.WorklogOptionsScheme
}

Expand Down Expand Up @@ -1281,7 +1281,7 @@ func Test_internalWorklogAdfImpl_Update(t *testing.T) {

client.On("Call",
&http.Request{},
&model.IssueWorklogScheme{}).
&model.IssueWorklogADFScheme{}).
Return(&model.ResponseScheme{}, nil)

fields.c = client
Expand Down Expand Up @@ -1324,7 +1324,7 @@ func Test_internalWorklogAdfImpl_Update(t *testing.T) {

client.On("Call",
&http.Request{},
&model.IssueWorklogScheme{}).
&model.IssueWorklogADFScheme{}).
Return(&model.ResponseScheme{}, nil)

fields.c = client
Expand Down Expand Up @@ -1368,7 +1368,7 @@ func Test_internalWorklogAdfImpl_Update(t *testing.T) {
client := mocks.NewClient(t)

client.On("TransformStructToReader",
(*model.WorklogPayloadSchemeV3)(nil)).
(*model.WorklogADFPayloadScheme)(nil)).
Return(bytes.NewReader([]byte{}), model.ErrNonPayloadPointerError)

fields.c = client
Expand Down
30 changes: 15 additions & 15 deletions jira/internal/worklog_impl_rich_text.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type WorklogRichTextService struct {
// POST /rest/api/{2-3}/worklog/list
//
// https://docs.go-atlassian.io/jira-software-cloud/issues/worklogs#get-worklogs
func (w *WorklogRichTextService) Gets(ctx context.Context, worklogIds []int, expand []string) ([]*model.IssueWorklogScheme, *model.ResponseScheme, error) {
func (w *WorklogRichTextService) Gets(ctx context.Context, worklogIds []int, expand []string) ([]*model.IssueWorklogRichTextScheme, *model.ResponseScheme, error) {
return w.internalClient.Gets(ctx, worklogIds, expand)
}

Expand All @@ -45,7 +45,7 @@ func (w *WorklogRichTextService) Gets(ctx context.Context, worklogIds []int, exp
// GET /rest/api/{2-3}/issue/{issueIdOrKey}/worklog/{id}
//
// https://docs.go-atlassian.io/jira-software-cloud/issues/worklogs#get-worklog
func (w *WorklogRichTextService) Get(ctx context.Context, issueKeyOrId, worklogId string, expand []string) (*model.IssueWorklogScheme, *model.ResponseScheme, error) {
func (w *WorklogRichTextService) Get(ctx context.Context, issueKeyOrId, worklogId string, expand []string) (*model.IssueWorklogRichTextScheme, *model.ResponseScheme, error) {
return w.internalClient.Get(ctx, issueKeyOrId, worklogId, expand)
}

Expand All @@ -56,7 +56,7 @@ func (w *WorklogRichTextService) Get(ctx context.Context, issueKeyOrId, worklogI
// GET /rest/api/{2-3}/issue/{issueIdOrKey}/worklog
//
// https://docs.go-atlassian.io/jira-software-cloud/issues/worklogs#get-issue-worklogs
func (w *WorklogRichTextService) Issue(ctx context.Context, issueKeyOrId string, startAt, maxResults, after int, expand []string) (*model.IssueWorklogPageScheme, *model.ResponseScheme, error) {
func (w *WorklogRichTextService) Issue(ctx context.Context, issueKeyOrId string, startAt, maxResults, after int, expand []string) (*model.IssueWorklogRichTextPageScheme, *model.ResponseScheme, error) {
return w.internalClient.Issue(ctx, issueKeyOrId, startAt, maxResults, after, expand)
}

Expand Down Expand Up @@ -110,7 +110,7 @@ func (w *WorklogRichTextService) Updated(ctx context.Context, since int, expand
// POST /rest/api/2/issue/{issueIdOrKey}/worklog
//
// https://docs.go-atlassian.io/jira-software-cloud/issues/worklogs#add-worklog
func (w *WorklogRichTextService) Add(ctx context.Context, issueKeyOrID string, payload *model.WorklogPayloadSchemeV2, options *model.WorklogOptionsScheme) (*model.IssueWorklogScheme, *model.ResponseScheme, error) {
func (w *WorklogRichTextService) Add(ctx context.Context, issueKeyOrID string, payload *model.WorklogRichTextPayloadScheme, options *model.WorklogOptionsScheme) (*model.IssueWorklogRichTextScheme, *model.ResponseScheme, error) {
return w.internalClient.Add(ctx, issueKeyOrID, payload, options)
}

Expand All @@ -121,7 +121,7 @@ func (w *WorklogRichTextService) Add(ctx context.Context, issueKeyOrID string, p
// PUT /rest/api/2/issue/{issueIdOrKey}/worklog/{id}
//
// https://docs.go-atlassian.io/jira-software-cloud/issues/worklogs#update-worklog
func (w *WorklogRichTextService) Update(ctx context.Context, issueKeyOrId, worklogId string, payload *model.WorklogPayloadSchemeV2, options *model.WorklogOptionsScheme) (*model.IssueWorklogScheme, *model.ResponseScheme, error) {
func (w *WorklogRichTextService) Update(ctx context.Context, issueKeyOrId, worklogId string, payload *model.WorklogRichTextPayloadScheme, options *model.WorklogOptionsScheme) (*model.IssueWorklogRichTextScheme, *model.ResponseScheme, error) {
return w.internalClient.Update(ctx, issueKeyOrId, worklogId, payload, options)
}

Expand All @@ -130,7 +130,7 @@ type internalWorklogRichTextImpl struct {
version string
}

func (i *internalWorklogRichTextImpl) Gets(ctx context.Context, worklogIds []int, expand []string) ([]*model.IssueWorklogScheme, *model.ResponseScheme, error) {
func (i *internalWorklogRichTextImpl) Gets(ctx context.Context, worklogIds []int, expand []string) ([]*model.IssueWorklogRichTextScheme, *model.ResponseScheme, error) {

if len(worklogIds) == 0 {
return nil, nil, model.ErrNpWorklogsError
Expand Down Expand Up @@ -164,7 +164,7 @@ func (i *internalWorklogRichTextImpl) Gets(ctx context.Context, worklogIds []int
return nil, nil, err
}

var worklogs []*model.IssueWorklogScheme
var worklogs []*model.IssueWorklogRichTextScheme
response, err := i.c.Call(request, &worklogs)
if err != nil {
return nil, response, err
Expand All @@ -173,7 +173,7 @@ func (i *internalWorklogRichTextImpl) Gets(ctx context.Context, worklogIds []int
return worklogs, response, nil
}

func (i *internalWorklogRichTextImpl) Get(ctx context.Context, issueKeyOrId, worklogId string, expand []string) (*model.IssueWorklogScheme, *model.ResponseScheme, error) {
func (i *internalWorklogRichTextImpl) Get(ctx context.Context, issueKeyOrId, worklogId string, expand []string) (*model.IssueWorklogRichTextScheme, *model.ResponseScheme, error) {

if issueKeyOrId == "" {
return nil, nil, model.ErrNoIssueKeyOrIDError
Expand All @@ -200,7 +200,7 @@ func (i *internalWorklogRichTextImpl) Get(ctx context.Context, issueKeyOrId, wor
return nil, nil, err
}

worklog := new(model.IssueWorklogScheme)
worklog := new(model.IssueWorklogRichTextScheme)
response, err := i.c.Call(request, worklog)
if err != nil {
return nil, response, err
Expand All @@ -209,7 +209,7 @@ func (i *internalWorklogRichTextImpl) Get(ctx context.Context, issueKeyOrId, wor
return worklog, response, nil
}

func (i *internalWorklogRichTextImpl) Issue(ctx context.Context, issueKeyOrId string, startAt, maxResults, after int, expand []string) (*model.IssueWorklogPageScheme, *model.ResponseScheme, error) {
func (i *internalWorklogRichTextImpl) Issue(ctx context.Context, issueKeyOrId string, startAt, maxResults, after int, expand []string) (*model.IssueWorklogRichTextPageScheme, *model.ResponseScheme, error) {

if issueKeyOrId == "" {
return nil, nil, model.ErrNoIssueKeyOrIDError
Expand All @@ -234,7 +234,7 @@ func (i *internalWorklogRichTextImpl) Issue(ctx context.Context, issueKeyOrId st
return nil, nil, err
}

worklogs := new(model.IssueWorklogPageScheme)
worklogs := new(model.IssueWorklogRichTextPageScheme)
response, err := i.c.Call(request, worklogs)
if err != nil {
return nil, response, err
Expand Down Expand Up @@ -349,7 +349,7 @@ func (i *internalWorklogRichTextImpl) Updated(ctx context.Context, since int, ex
return worklogs, response, nil
}

func (i *internalWorklogRichTextImpl) Add(ctx context.Context, issueKeyOrID string, payload *model.WorklogPayloadSchemeV2, options *model.WorklogOptionsScheme) (*model.IssueWorklogScheme, *model.ResponseScheme, error) {
func (i *internalWorklogRichTextImpl) Add(ctx context.Context, issueKeyOrID string, payload *model.WorklogRichTextPayloadScheme, options *model.WorklogOptionsScheme) (*model.IssueWorklogRichTextScheme, *model.ResponseScheme, error) {

if issueKeyOrID == "" {
return nil, nil, model.ErrNoIssueKeyOrIDError
Expand Down Expand Up @@ -394,7 +394,7 @@ func (i *internalWorklogRichTextImpl) Add(ctx context.Context, issueKeyOrID stri
return nil, nil, err
}

worklog := new(model.IssueWorklogScheme)
worklog := new(model.IssueWorklogRichTextScheme)
response, err := i.c.Call(request, worklog)
if err != nil {
return nil, response, err
Expand All @@ -403,7 +403,7 @@ func (i *internalWorklogRichTextImpl) Add(ctx context.Context, issueKeyOrID stri
return worklog, response, nil
}

func (i *internalWorklogRichTextImpl) Update(ctx context.Context, issueKeyOrId, worklogId string, payload *model.WorklogPayloadSchemeV2, options *model.WorklogOptionsScheme) (*model.IssueWorklogScheme, *model.ResponseScheme, error) {
func (i *internalWorklogRichTextImpl) Update(ctx context.Context, issueKeyOrId, worklogId string, payload *model.WorklogRichTextPayloadScheme, options *model.WorklogOptionsScheme) (*model.IssueWorklogRichTextScheme, *model.ResponseScheme, error) {

if issueKeyOrId == "" {
return nil, nil, model.ErrNoIssueKeyOrIDError
Expand Down Expand Up @@ -452,7 +452,7 @@ func (i *internalWorklogRichTextImpl) Update(ctx context.Context, issueKeyOrId,
return nil, nil, err
}

worklog := new(model.IssueWorklogScheme)
worklog := new(model.IssueWorklogRichTextScheme)
response, err := i.c.Call(request, worklog)
if err != nil {
return nil, response, err
Expand Down
Loading

0 comments on commit 77efacf

Please sign in to comment.