-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathproject_test.go
61 lines (53 loc) · 1.45 KB
/
project_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package teamwork_test
import (
"fmt"
"os"
"github.com/swill/teamwork"
)
func ExampleConnection_GetProjects() {
// setup the teamwork connection
baseURL := "a teamwork baseURL"
apiToken := "a_teamwork_apiToken"
conn, err := teamwork.Connect(baseURL, apiToken)
if err != nil {
fmt.Printf("Error connecting to TeamWork: %s", err.Error())
os.Exit(1)
}
// get all projects
projectsOps := &teamwork.GetProjectsOps{
Status: "ALL",
}
projects, pages, err := conn.GetProjects(projectsOps)
if err != nil {
fmt.Printf("Error getting Projects: %s", err.Error())
}
fmt.Println("GetProjects")
fmt.Println("1. Name:", projects[0].Name)
fmt.Println("1. Status:", projects[0].Status)
fmt.Println("on page #:", pages.Page)
fmt.Println("# of pages:", pages.Pages)
fmt.Println("# of records:", pages.Records)
}
func ExampleConnection_GetProject() {
// setup the teamwork connection
baseURL := "a teamwork baseURL"
apiToken := "a_teamwork_apiToken"
conn, err := teamwork.Connect(baseURL, apiToken)
if err != nil {
fmt.Printf("Error connecting to TeamWork: %s", err.Error())
os.Exit(1)
}
// get one project
True := true
projectOps := &teamwork.GetProjectOps{
IncludePeople: &True,
}
project, err := conn.GetProject("158747", projectOps)
if err != nil {
fmt.Printf("Error getting Projects: %s", err.Error())
}
fmt.Println("GetProject")
fmt.Println("ID:", project.ID)
fmt.Println("Name:", project.Name)
fmt.Println("Status:", project.Status)
}