Skip to content

Commit

Permalink
Merge pull request #203 from ctreminiom/feature/teams-service
Browse files Browse the repository at this point in the history
✨ Added the Jira Roadmaps Team service
  • Loading branch information
ctreminiom authored May 28, 2023
2 parents 47d190e + 4fb7531 commit cedda2e
Show file tree
Hide file tree
Showing 8 changed files with 511 additions and 2 deletions.
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

0 comments on commit cedda2e

Please sign in to comment.