コード例 #1
0
ファイル: post.go プロジェクト: minodisk/qiitactl
// Update updates a post in Qiita.
func (post *Post) Update(client api.Client) (err error) {
	if post.ID == "" {
		err = EmptyIDError{}
		return
	}

	subDomain := ""
	if post.Team != nil {
		subDomain = post.Team.ID
	}
	body, _, err := client.Patch(subDomain, fmt.Sprintf("/items/%s", post.ID), post)
	if err != nil {
		return
	}
	err = json.Unmarshal(body, post)
	if err != nil {
		return
	}
	return
}