From 043a27b9bee3059f9f0a0778a43ca0bfb70d0dab Mon Sep 17 00:00:00 2001 From: Kristof Daja Date: Sat, 30 May 2020 00:09:49 +0200 Subject: [PATCH] demo cases updated --- examples/README.MD | 85 +++++++++++++++++++++++----------------------- 1 file changed, 43 insertions(+), 42 deletions(-) diff --git a/examples/README.MD b/examples/README.MD index f4d3ae4..a8e1155 100644 --- a/examples/README.MD +++ b/examples/README.MD @@ -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" @@ -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)