Skip to content

Instantly share code, notes, and snippets.

@andreas
Created July 15, 2016 08:03
Show Gist options
  • Save andreas/94edca19275f7ba49e426981eb620a83 to your computer and use it in GitHub Desktop.
Save andreas/94edca19275f7ba49e426981eb620a83 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"github.com/andreas/podio-go"
)
func main() {
authToken, err := podio.AuthWithUserCredentials("my-client-id", "my-client-secret", "my-username", "my-password")
if err != nil {
fmt.Println("Auth failed: ", err)
return
}
client := podio.NewClient(authToken)
orgs, err := client.GetOrganizations()
if err != nil {
fmt.Println("Failed to get orgs: ", err)
return
}
for _, org := range orgs {
fmt.Println("Org: ", org.Name)
spaces, err := client.GetSpaces(org.Id)
if err != nil {
fmt.Println("Failed to get spaces: ", err)
continue
}
for _, space := range spaces {
fmt.Println("Space: ", space.Name)
apps, err := client.GetApps(space.Id)
if err != nil {
fmt.Println("Failed to get apps: ", err)
continue
}
for _, app := range apps {
fmt.Println("App: ", app.Name)
items, err := client.GetItems(app.Id)
if err != nil {
fmt.Println("Failed to get items: ", err)
continue
}
for _, item := range items.Items {
fmt.Printf("Item #%d\n", item.Id)
for _, field := range item.Fields {
// Example 1
switch field.Type {
case "app":
fmt.Printf("Field #%d: App values [0]: %#v", field.Id, field.Values.([]podio.AppValue)[0].Value.Id)
default:
fmt.Printf("Field #%d: Not app field type", field.Id)
}
// Example 2
switch values := field.Values.(type) {
case []podio.AppValue:
fmt.Printf("Field #%d: App values [0]: %#v", field.Id, values[0].Value.Id)
default:
fmt.Printf("Field #%d: Not app field type", field.Id)
}
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment