예제 #1
0
파일: item.go 프로젝트: jkotrlik/salsaflow
func (item *item) AddAssignee(user common.User) *errs.Error {
	task := "Assign the current user to the selected story"

	// Load the Sprintly config.
	config, err := LoadConfig()
	if err != nil {
		return errs.NewError(task, err)
	}

	// Parse the user ID.
	userId, err := strconv.Atoi(user.Id())
	if err != nil {
		panic(err)
	}

	// Instantiate the Sprintly client.
	client := sprintly.NewClient(config.Username(), config.Token())

	// Assign the user to the selected story.
	_, _, err = client.Items.Update(config.ProductId(), item.Number, &sprintly.ItemUpdateArgs{
		AssignedTo: userId,
	})
	if err != nil {
		return errs.NewError(task, err)
	}
	return nil
}
예제 #2
0
func (story *story) AddAssignee(user common.User) error {
	task := fmt.Sprintf("Add user as the owner to story %v", user.Id(), story.Id)
	for _, id := range story.OwnerIds {
		if strconv.Itoa(id) == user.Id() {
			return nil
		}
	}

	id, err := strconv.Atoi(user.Id())
	if err != nil {
		return errs.NewError(task, err)
	}

	return story.SetAssignees(append(story.Assignees(), userId(id)))
}