Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Added the Jira Roadmaps Team service #203

Merged
merged 4 commits into from
May 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion jira/agile/internal/board_backlog_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (b *BoardBacklogService) Move(ctx context.Context, issues []string) (*model
//
// POST /rest/agile/1.0/backlog/{boardId}/issue
//
// https://docs.go-atlassian.io/jira-agile/boards/backlog#move-issues-to-backlog
// https://docs.go-atlassian.io/jira-agile/boards/backlog#move-issues-to-a-board-backlog
func (b *BoardBacklogService) MoveTo(ctx context.Context, boardID int, payload *model.BoardBacklogPayloadScheme) (*model.ResponseScheme, error) {
return b.internalClient.MoveTo(ctx, boardID, payload)
}
Expand Down
102 changes: 102 additions & 0 deletions jira/internal/team_impl.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
package internal

import (
"context"
model "github.com/ctreminiom/go-atlassian/pkg/infra/models"
"github.com/ctreminiom/go-atlassian/service"
"github.com/ctreminiom/go-atlassian/service/jira"
"net/http"
)

func NewTeamService(client service.Client) *TeamService {

return &TeamService{
internalClient: &internalTeamServiceImpl{c: client},
}
}

type TeamService struct {
internalClient jira.TeamConnector
}

// Gets gets the Teams information from the Jira Advanced Roadmaps application.
//
// Teams in Advanced Roadmaps are different from the teams found in the rest of Jira Software Cloud.
//
// In Advanced Roadmaps, they act as a label applied to issues that designates which team will eventually.
//
// pick up the work on your timeline. By adding the Team field to your Jira issues.
//
// you can save this value back to your Jira issues, which makes sprint planning easier.
//
// POST /rest/teams/1.0/teams/find
//
// https://docs.go-atlassian.io/jira-software-cloud/teams#get-teams
func (t *TeamService) Gets(ctx context.Context, maxResults int) (*model.JiraTeamPageScheme, *model.ResponseScheme, error) {
return t.internalClient.Gets(ctx, maxResults)
}

// Create creates a team on the Advanced Roadmaps
//
// POST /rest/teams/1.0/teams/create
//
// https://docs.go-atlassian.io/jira-software-cloud/teams#create-team
func (t *TeamService) Create(ctx context.Context, payload *model.JiraTeamCreatePayloadScheme) (*model.JiraTeamCreateResponseScheme, *model.ResponseScheme, error) {
return t.internalClient.Create(ctx, payload)
}

type internalTeamServiceImpl struct {
c service.Client
}

func (i *internalTeamServiceImpl) Gets(ctx context.Context, maxResults int) (*model.JiraTeamPageScheme, *model.ResponseScheme, error) {

payload := struct {
MaxResults int `json:"maxResults"`
}{
MaxResults: maxResults,
}

reader, err := i.c.TransformStructToReader(&payload)
if err != nil {
return nil, nil, err
}

endpoint := "rest/teams/1.0/teams/find"

request, err := i.c.NewRequest(ctx, http.MethodPost, endpoint, reader)
if err != nil {
return nil, nil, err
}

teams := new(model.JiraTeamPageScheme)
response, err := i.c.Call(request, teams)
if err != nil {
return nil, response, err
}

return teams, response, nil
}

func (i *internalTeamServiceImpl) Create(ctx context.Context, payload *model.JiraTeamCreatePayloadScheme) (*model.JiraTeamCreateResponseScheme, *model.ResponseScheme, error) {

reader, err := i.c.TransformStructToReader(payload)
if err != nil {
return nil, nil, err
}

endpoint := "rest/teams/1.0/teams/create"

request, err := i.c.NewRequest(ctx, http.MethodPost, endpoint, reader)
if err != nil {
return nil, nil, err
}

team := new(model.JiraTeamCreateResponseScheme)
response, err := i.c.Call(request, team)
if err != nil {
return nil, response, err
}

return team, response, nil
}
Loading