示例#1
0
func (c *Tower) CreateTodolist(projectID, title string) (TodoList, error) {
	var (
		url      = "https://tower.im/api/v2/projects/" + projectID + "/todolists"
		response TodoList
		request  = struct {
			Title string `json:"title"`
		}{
			Title: title,
		}
	)
	if _, err := requests.Post(url, request, c.authHeader(), &response); err != nil {
		return response, err
	}
	return response, nil
}
示例#2
0
func (c *Tower) Auth() error {
	var (
		url     = "https://tower.im/api/v2/oauth/token"
		request = struct {
			ClientID     string `json:"client_id"    bson:"client_id"`
			ClientSecret string `json:"client_secret"    bson:"client_secret"`
			Username     string `json:"username"`
			Password     string `json:"password"`
			GrantType    string `json:"grant_type"    bson:"grant_type"`
		}{
			ClientID:     c.clientID,
			ClientSecret: c.clientSecret,
			Username:     c.username,
			Password:     c.password,
			GrantType:    "password",
		}
	)
	if _, err := requests.Post(url, request, nil, &c.AuthInfo); err != nil {
		return err
	}
	fmt.Println(">>>", c.AuthInfo.TokenType, c.AuthInfo.AccessToken)
	return nil

}