Esempio n. 1
0
// GetTodos gets all todos from per user database
func (d database) GetTodos(database string) ([]item.Todo, error) {
	db := d.Client.Use(database)
	view := db.View("todo")
	params := couchdb.QueryParameters{
		StartKey:    pointer.String(past),
		EndKey:      pointer.String(future),
		IncludeDocs: pointer.Bool(true),
	}
	res, err := view.Get("byCreatedAt", params)
	if err != nil {
		return nil, fmt.Errorf("get view byCreatedAt: %v", err)
	}
	docs := make([]interface{}, len(res.Rows))
	for index, row := range res.Rows {
		docs[index] = row.Doc
	}
	todos := make([]item.Todo, len(res.Rows))
	b, err := json.Marshal(docs)
	if err != nil {
		return nil, fmt.Errorf("json marshal: %v", err)
	}
	return todos, json.Unmarshal(b, &todos)
}
Esempio n. 2
0
func main() {
	c := circle.New(os.Getenv("CIRCLE_TOKEN"))

	fmt.Println(c.Me())
	fmt.Println(c.Projects())
	fmt.Println(c.RecentBuilds())
	fmt.Println(c.RecentBuildsForProject("segmentio", "analytics-android"))
	fmt.Println(c.RecentBuildsForProjectBranch("segmentio", "analytics-android", "pull/346", circle.RecentBuildsOptions{
		Limit:  pointers.Int(2),
		Offset: pointers.Int(1),
		Filter: pointer.String("completed"),
	}))
	fmt.Println(c.BuildSummary("segmentio", "analytics-android", 345))
	fmt.Println(c.Artifacts("segmentio", "analytics-android", 345))
	fmt.Println(c.Retry("segmentio", "analytics-android", 346))
}