func (item *item) Start() *errs.Error { task := fmt.Sprintf("Mark Sprintly item %v as being in progress", item.Number) // Check whether we are not finished already. switch item.Status { case sprintly.ItemStatusSomeday: case sprintly.ItemStatusBacklog: case sprintly.ItemStatusInProgress: fallthrough case sprintly.ItemStatusCompleted: fallthrough case sprintly.ItemStatusAccepted: // Nothing to do. return nil } // Load the Sprintly config. config, err := LoadConfig() if err != nil { return errs.NewError(task, err) } // Instantiate the Sprintly client. client := sprintly.NewClient(config.Username(), config.Token()) // Move the item to in-progress. _, _, err = client.Items.Update(config.ProductId(), item.Number, &sprintly.ItemUpdateArgs{ Status: sprintly.ItemStatusInProgress, }) if err != nil { return errs.NewError(task, err) } return nil }
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 }
func Factory() (common.IssueTracker, error) { config, err := LoadConfig() if err != nil { return nil, err } client := sprintly.NewClient(config.Username(), config.Token()) return &issueTracker{config, client}, nil }