Beispiel #1
0
func main() {
	mBytes := []byte(`{
            "MsgID": 1,
            "Name":  "Msg-1",
            "data":  "such a cool message"
          }`)
	var m Msg
	_ = json.Unmarshal(mBytes, &m)
	pretty.Println(m)
}
Beispiel #2
0
func main() {
	flag.Parse()

	client := trello.NewClient(*key, *token)

	board, err := client.BoardService().GetBoard(*boardID)
	if err != nil {
		fmt.Println("err: ", err)
		return
	}

	pretty.Println(board)
}
Beispiel #3
0
func main() {
	flag.Parse()

	if len(*clientId) == 0 || len(*clientSecret) == 0 ||
		len(*accessToken) == 0 || len(*refreshToken) == 0 {
		fmt.Println("unfortunately all flags must be provided")
		return
	}

	// Set our OAuth2 configuration up
	var (
		configSource = box.NewConfigSource(
			&oauth2.Config{
				ClientID:     *clientId,
				ClientSecret: *clientSecret,
				Scopes:       nil,
				Endpoint: oauth2.Endpoint{
					AuthURL:  "https://app.box.com/api/oauth2/authorize",
					TokenURL: "https://app.box.com/api/oauth2/token",
				},
				RedirectURL: "http://localhost:8080/handle",
			},
		)
		tok = &oauth2.Token{
			TokenType:    "Bearer",
			AccessToken:  *accessToken,
			RefreshToken: *refreshToken,
		}
		c = configSource.NewClient(tok)
	)

	resp, longPollInfo, err := c.EventService().LongPollURL()
	fmt.Println("resp: ", resp)
	fmt.Println("err: ", err)
	pretty.Print(longPollInfo)

	// Print out the new tokens for next time
	fmt.Printf("\n%#v\n", tok)

	connInfo := longPollInfo.Entries[0]
	resp, event, err := c.EventService().ListenForEvent(connInfo, "")
	fmt.Println("resp: ", resp)
	fmt.Println("err: ", err)
	pretty.Println(event)
}
Beispiel #4
0
func main() {
	flag.Parse()

	if len(*clientId) == 0 || len(*clientSecret) == 0 ||
		len(*accessToken) == 0 || len(*refreshToken) == 0 ||
		len(*membershipID) == 0 {
		fmt.Println("unfortunately all flags must be provided")
		return
	}

	// Set our OAuth2 configuration up
	var (
		configSource = box.NewConfigSource(
			&oauth2.Config{
				ClientID:     *clientId,
				ClientSecret: *clientSecret,
				Scopes:       nil,
				Endpoint: oauth2.Endpoint{
					AuthURL:  "https://app.box.com/api/oauth2/authorize",
					TokenURL: "https://app.box.com/api/oauth2/token",
				},
				RedirectURL: "https://localhost:8080/handle",
			},
		)
		tok = &oauth2.Token{
			TokenType:    "Bearer",
			AccessToken:  *accessToken,
			RefreshToken: *refreshToken,
		}
		c = configSource.NewClient(tok)
	)

	// NOTE:
	// There seem to be restriction on what "roles" one can pass in, I need
	// to track done the definitive list.
	resp, membershipEntry, err := c.GroupService().UpdateMembership(
		*membershipID, *role)
	fmt.Println("resp: ", resp)
	fmt.Println("err: ", err)
	pretty.Println(membershipEntry)
	// Print out the new tokens for next time
	fmt.Printf("\n%#v\n", tok)
}
Beispiel #5
0
func Test_ParseThenString(t *testing.T) {
	var tests = []string{
		"foo://example.com:8042/over/there?name=ferret#nose",
		"http://httpbin.org/get?utf8=\xe2\x98\x83",
		"mailto:[email protected]",
		"ssh://[email protected]:29418/openstack/keystone.git",
		"https://willo.io/#yolo",
	}

	for _, test := range tests {
		uri, err := ParseURI(test)
		if err != nil {
			t.Errorf("failed to parse URI, err: %v", err)
		} else if uri.String() != test {
			pretty.Println(uri)
			t.Errorf("uri.String() != test: %v != %v", uri.String(), test)
		}
	}
}
Beispiel #6
0
func main() {
	flag.Parse()

	if len(*clientId) == 0 || len(*clientSecret) == 0 ||
		len(*accessToken) == 0 || len(*refreshToken) == 0 ||
		len(*link) == 0 {
		fmt.Println("unfortunately all flags must be provided")
		return
	}

	// Set our OAuth2 configuration up
	var (
		configSource = box.NewConfigSource(
			&oauth2.Config{
				ClientID:     *clientId,
				ClientSecret: *clientSecret,
				Scopes:       nil,
				Endpoint: oauth2.Endpoint{
					AuthURL:  "https://app.box.com/api/oauth2/authorize",
					TokenURL: "https://app.box.com/api/oauth2/token",
				},
				RedirectURL: "http://localhost:8080/handle",
			},
		)
		tok = &oauth2.Token{
			TokenType:    "Bearer",
			AccessToken:  *accessToken,
			RefreshToken: *refreshToken,
		}
		c = configSource.NewClient(tok)
	)

	resp, sharedItem, err := c.SharedService().GetItem(*link, *password)
	fmt.Printf("%#v\n", resp)
	fmt.Println("err: ", err)
	pretty.Println(sharedItem)

	// Print out the new tokens for next time
	fmt.Printf("%#v\n", tok)
}