Skip to content

Commit

Permalink
demo cases updated
Browse files Browse the repository at this point in the history
  • Loading branch information
theriverman committed May 29, 2020
1 parent 84fbbcf commit 043a27b
Showing 1 changed file with 43 additions and 42 deletions.
85 changes: 43 additions & 42 deletions examples/README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ Make sure you always import the required packages and you always put these snipp

There is no proper error handling implemented in these snippets, each error panics the application. Make sure you always implement proper error handling.

# Create Client & Authenticate
# Cases

## Create Client & Authenticate
```go
import (
"fmt"
Expand Down Expand Up @@ -42,65 +44,64 @@ func main() {

```

# Get Self (User) /users/me
## Get Self (User) /users/me
```go
me, err := client.User.Me()
if err != nil {
panic(err)
}
fmt.Println("Me: (ID, Username, FullName)", me.ID, me.Username, me.FullName)
me, err := client.User.Me()
if err != nil {
panic(err)
}
fmt.Println("Me: (ID, Username, FullName)", me.ID, me.Username, me.FullName)
```

# Get a Project
## Get a Project
```go
// Get Project
slug := "my-sassy-project-1"
fmt.Printf("\nGetting Project (slug=%s)..\n", slug)
project, err := client.Project.GetBySlug(slug)
if err != nil {
panic(err)
}
fmt.Printf("\nProject name: %s \n", project.Name)

// Get Project
slug := "my-sassy-project-1"
fmt.Printf("\nGetting Project (slug=%s)..\n", slug)
project, err := client.Project.GetBySlug(slug)
if err != nil {
panic(err)
}
fmt.Printf("\nProject name: %s \n", project.Name)
```

# Get Project Severities
## Get Project Severities
In this scenario observe that we're accessing the `ProjectDETAIL` meta field.
```go
fmt.Printf("\nProject Severities:\n")
for _, severity := range project.ProjectDETAIL.Severities {
fmt.Printf(" * ID=%d Name=%s\n", severity.ID, severity.Name)
}
fmt.Printf("\nProject Severities:\n")
for _, severity := range project.ProjectDETAIL.Severities {
fmt.Printf(" * ID=%d Name=%s\n", severity.ID, severity.Name)
}
```

# Get (Project) Epic Custom Attributes
## Get (Project) Epic Custom Attributes
A total of 3 epic custom attributes are returned. See it limited by the for-loop.
```go
fmt.Println("\nGetting all (Project) Epics Custom Attributes and printing the first 3 to the console:")
fmt.Printf("Project Epic Custom Attributes:\n")
for _, epicCA := range project.ProjectDETAIL.EpicCustomAttributes {
fmt.Printf(" * ID=%d Name=%s ProjectID=%d\n", epicCA.ID, epicCA.Name, epicCA.ProjectID)
}
fmt.Println("\nGetting all (Project) Epics Custom Attributes and printing the first 3 to the console:")
fmt.Printf("Project Epic Custom Attributes:\n")
for _, epicCA := range project.ProjectDETAIL.EpicCustomAttributes {
fmt.Printf(" * ID=%d Name=%s ProjectID=%d\n", epicCA.ID, epicCA.Name, epicCA.ProjectID)
}
```

# Get Epics
## Get Epics
A total of 3 epics are returned. See it limited by the for-loop.
```go
fmt.Println("\nGetting all Epics and printing the first 3 to the console:")
epics, err := client.Epic.List(nil)
if err != nil {
panic(err)
}
for i := 0; i < 3; i++ {
epic := epics[i]
fmt.Printf(" * epics[%d] :: ID=%d | Subject=%s\n", i, epic.ID, epic.Subject)
// Access ModifiedDate via meta because that's not available through the generic `Epic`
meta := *epic.EpicDetailLIST
fmt.Printf(" * meta :: ModifiedDate = %s\n\n", meta[i].ModifiedDate.Format("2006-01-02 15:04:05"))
}
fmt.Println("\nGetting all Epics and printing the first 3 to the console:")
epics, err := client.Epic.List(nil)
if err != nil {
panic(err)
}
for i := 0; i < 3; i++ {
epic := epics[i]
fmt.Printf(" * epics[%d] :: ID=%d | Subject=%s\n", i, epic.ID, epic.Subject)
// Access ModifiedDate via meta because that's not available through the generic `Epic`
meta := *epic.EpicDetailLIST
fmt.Printf(" * meta :: ModifiedDate = %s\n\n", meta[i].ModifiedDate.Format("2006-01-02 15:04:05"))
}
```

# Get Epic by ID
## Get Epic by ID
```go
epicID := 123456
fmt.Println("Getting an Epic by ID:", epicID)
Expand Down

0 comments on commit 043a27b

Please sign in to comment.