Created
May 24, 2019 10:01
-
-
Save akfaew/36d0fa4e5c8db7cf04ad9520d1cdc50e to your computer and use it in GitHub Desktop.
A working golang example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"fmt" | |
"net/http" | |
geekmail "github.com/geekmail/go-geekmail" | |
) | |
func main() { | |
conf := &geekmail.Conf{ | |
GitHubAuth: geekmail.GitHubAuth{ | |
Repository: "github.com/geekmail/geekmail-sample", | |
ConfigPath: "config.yaml", | |
RepoSecret: "password123", | |
}, | |
UserToken: "XXX", | |
} | |
vars := map[string]string{ | |
"To": "John Doe <[email protected]>", | |
"Name": "John", | |
} | |
draft := &geekmail.DraftCreateGitHub{ | |
TemplatePath: "templates/example.template", | |
Vars: vars, | |
Labels: []string{"GeekMail"}, | |
} | |
client := geekmail.NewClient(&http.Client{}, conf) | |
if resp, err := client.Draft.CreateGitHub(context.Background(), draft); err != nil { | |
fmt.Printf("Cannot communicate with the API: err=%v\n", err) | |
} else { | |
fmt.Printf("GeekMail response: %+v\n", resp) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment