-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
package internal | ||
Check warning Code scanning / Revive (reported by Codacy) should have a package comment Warning
should have a package comment
|
||
|
||
import ( | ||
"context" | ||
"fmt" | ||
model "github.com/ctreminiom/go-atlassian/v2/pkg/infra/models" | ||
"github.com/ctreminiom/go-atlassian/v2/service" | ||
"github.com/ctreminiom/go-atlassian/v2/service/jira" | ||
"net/http" | ||
"path" | ||
) | ||
|
||
func NewIssueArchivalService(client service.Connector, version string) *IssueArchivalService { | ||
Check warning Code scanning / Revive (reported by Codacy) exported function NewIssueArchivalService should have comment or be unexported Warning
exported function NewIssueArchivalService should have comment or be unexported
|
||
return &IssueArchivalService{ | ||
internalClient: &internalIssueArchivalImpl{c: client, version: version}, | ||
} | ||
} | ||
|
||
type IssueArchivalService struct { | ||
Check warning Code scanning / Revive (reported by Codacy) exported type IssueArchivalService should have comment or be unexported Warning
exported type IssueArchivalService should have comment or be unexported
|
||
internalClient jira.ArchiveService | ||
} | ||
|
||
func (i *IssueArchivalService) Preserve(ctx context.Context, issueIdsOrKeys []string) (*model.IssueArchivalSyncResponseScheme, *model.ResponseScheme, error) { | ||
Check warning Code scanning / Revive (reported by Codacy) exported method IssueArchivalService.Preserve should have comment or be unexported Warning
exported method IssueArchivalService.Preserve should have comment or be unexported
Check warning Code scanning / Revive (reported by Codacy) method parameter issueIdsOrKeys should be issueIDsOrKeys Warning
method parameter issueIdsOrKeys should be issueIDsOrKeys
|
||
return i.internalClient.Preserve(ctx, issueIdsOrKeys) | ||
} | ||
|
||
func (i *IssueArchivalService) PreserveByJQL(ctx context.Context, jql string) (string, *model.ResponseScheme, error) { | ||
Check warning Code scanning / Revive (reported by Codacy) exported method IssueArchivalService.PreserveByJQL should have comment or be unexported Warning
exported method IssueArchivalService.PreserveByJQL should have comment or be unexported
|
||
return i.internalClient.PreserveByJQL(ctx, jql) | ||
} | ||
|
||
func (i *IssueArchivalService) Restore(ctx context.Context, issueIdsOrKeys []string) (*model.IssueArchivalSyncResponseScheme, *model.ResponseScheme, error) { | ||
Check warning Code scanning / Revive (reported by Codacy) method parameter issueIdsOrKeys should be issueIDsOrKeys Warning
method parameter issueIdsOrKeys should be issueIDsOrKeys
Check warning Code scanning / Revive (reported by Codacy) exported method IssueArchivalService.Restore should have comment or be unexported Warning
exported method IssueArchivalService.Restore should have comment or be unexported
|
||
return i.internalClient.Restore(ctx, issueIdsOrKeys) | ||
} | ||
|
||
func (i *IssueArchivalService) Export(ctx context.Context, payload *model.IssueArchivalExportPayloadScheme) (string, *model.ResponseScheme, error) { | ||
Check warning Code scanning / Revive (reported by Codacy) exported method IssueArchivalService.Export should have comment or be unexported Warning
exported method IssueArchivalService.Export should have comment or be unexported
|
||
return i.internalClient.Export(ctx, payload) | ||
} | ||
|
||
type internalIssueArchivalImpl struct { | ||
c service.Connector | ||
version string | ||
} | ||
|
||
func (i *internalIssueArchivalImpl) Preserve(ctx context.Context, issueIdsOrKeys []string) (result *model.IssueArchivalSyncResponseScheme, response *model.ResponseScheme, err error) { | ||
Check warning Code scanning / Revive (reported by Codacy) method parameter issueIdsOrKeys should be issueIDsOrKeys Warning
method parameter issueIdsOrKeys should be issueIDsOrKeys
|
||
|
||
if len(issueIdsOrKeys) == 0 { | ||
return nil, nil, model.ErrNoIssuesSlice | ||
} | ||
|
||
payload := make(map[string]interface{}) | ||
payload["issueIdsOrKeys"] = issueIdsOrKeys | ||
|
||
endpoint := fmt.Sprintf("rest/api/%s/issue/archive", i.version) | ||
|
||
request, err := i.c.NewRequest(ctx, http.MethodPut, endpoint, "", payload) | ||
if err != nil { | ||
return nil, nil, err | ||
} | ||
|
||
report := new(model.IssueArchivalSyncResponseScheme) | ||
response, err = i.c.Call(request, report) | ||
if err != nil { | ||
return nil, response, err | ||
} | ||
|
||
return report, response, nil | ||
} | ||
|
||
func (i *internalIssueArchivalImpl) PreserveByJQL(ctx context.Context, jql string) (taskID string, response *model.ResponseScheme, err error) { | ||
|
||
if jql == "" { | ||
return "", nil, model.ErrNoJQL | ||
} | ||
|
||
payload := make(map[string]interface{}) | ||
payload["jql"] = jql | ||
|
||
endpoint := fmt.Sprintf("rest/api/%s/issue/archive", i.version) | ||
|
||
request, err := i.c.NewRequest(ctx, http.MethodPost, endpoint, "", payload) | ||
if err != nil { | ||
return "", nil, err | ||
} | ||
|
||
response, err = i.c.Call(request, nil) | ||
if err != nil { | ||
return "", response, err | ||
} | ||
|
||
return path.Base(response.Bytes.String()), response, nil | ||
} | ||
|
||
func (i *internalIssueArchivalImpl) Restore(ctx context.Context, issueIdsOrKeys []string) (result *model.IssueArchivalSyncResponseScheme, response *model.ResponseScheme, err error) { | ||
Check warning Code scanning / Revive (reported by Codacy) method parameter issueIdsOrKeys should be issueIDsOrKeys Warning
method parameter issueIdsOrKeys should be issueIDsOrKeys
|
||
|
||
if len(issueIdsOrKeys) == 0 { | ||
return nil, nil, model.ErrNoIssuesSlice | ||
} | ||
|
||
payload := make(map[string]interface{}) | ||
payload["issueIdsOrKeys"] = issueIdsOrKeys | ||
|
||
endpoint := fmt.Sprintf("rest/api/%s/issue/unarchive", i.version) | ||
|
||
request, err := i.c.NewRequest(ctx, http.MethodPut, endpoint, "", payload) | ||
if err != nil { | ||
return nil, nil, err | ||
} | ||
|
||
report := new(model.IssueArchivalSyncResponseScheme) | ||
response, err = i.c.Call(request, report) | ||
if err != nil { | ||
return nil, response, err | ||
} | ||
|
||
return report, response, nil | ||
} | ||
|
||
func (i *internalIssueArchivalImpl) Export(ctx context.Context, payload *model.IssueArchivalExportPayloadScheme) (taskID string, response *model.ResponseScheme, err error) { | ||
|
||
endpoint := fmt.Sprintf("rest/api/%s/issues/archive/export", i.version) | ||
|
||
request, err := i.c.NewRequest(ctx, http.MethodPut, endpoint, "", payload) | ||
if err != nil { | ||
return "", nil, err | ||
} | ||
|
||
response, err = i.c.Call(request, nil) | ||
if err != nil { | ||
return "", response, err | ||
} | ||
|
||
return "", response, nil | ||
} |