Ejemplo n.º 1
0
func main() {
	c := chatwork.NewClient(apiKey)
	b, e := c.Contacts()
	fmt.Printf("%+v\n", b)
	fmt.Printf("%+v\n", e)
	fmt.Printf("%+v\n", c.RateLimit())
}
Ejemplo n.º 2
0
func main() {
	c := chatwork.NewClient(apiKey)

	{
		b, e := c.MyStatus()
		fmt.Printf("%+v\n", b)
		fmt.Printf("%+v\n", e)
	}

	{
		b, e := c.MyTasks(map[string]string{})
		fmt.Printf("%+v\n", b)
		fmt.Printf("%+v\n", e)
	}

	fmt.Printf("%+v\n", c.RateLimit())
}
Ejemplo n.º 3
0
func main() {
	// GET
	c := chatwork.NewClient(apiKey)
	fmt.Printf("%+v\n", c.Rooms())
	fmt.Printf("%+v\n", c.Room(`room-id`))
	fmt.Printf("%+v\n", c.RoomMembers(`room-id`))
	fmt.Print(c.RoomMessages(`room-id`))
	fmt.Printf("%+v\n", c.RoomMessage(`room-id`, `message-id`))
	fmt.Printf("%+v\n", c.RoomTasks(`room-id`))
	fmt.Printf("%+v\n", c.RoomTask(`room-id`, `task-id`))
	fmt.Printf("%+v\n", c.RoomFiles(`room-id`, map[string]string{}))
	fmt.Printf("%+v\n", c.RoomFile(`room-id`, `file-id`))

	// POST
	c.CreateRoom(map[string]string{
		"name":              "Test Room",
		"members_admin_ids": `user-id`,
		"description":       "テスト",
	})

	// PUT
	c.UpdateRoom(`room-id`, map[string]string{
		"name":        "テストルーム",
		"description": "Update description",
	})
	c.UpdateRoomMembers(`room-id`, map[string]string{
		"members_admin_ids":    `user-id`,
		"members_member_ids":   `user-id`,
		"members_readonly_ids": `user-id`,
	})

	// DELETE
	c.DeleteRoom(`room-id`, map[string]string{
		"action_type": "delete",
	})
}
Ejemplo n.º 4
0
// CmdListConcreate is main part
func CmdListConcreate(c *cli.Context) int {

	// Backlog
	backlogToken := c.GlobalString("backlog-token")
	if len(backlogToken) == 0 {
		log.Printf("[ERROR] %s", "You need Backlog API-Key")
		return 1
	}

	backlogEndpoint := c.GlobalString("backlog-endpoint")
	if len(backlogEndpoint) == 0 {
		log.Printf("[ERROR] %s", "You need Backlog API endpoint")
		return 1
	}

	backlogClient := backlog.NewClient(backlogEndpoint, backlogToken)
	me, err := backlogClient.Myself()

	opt := &backlog.IssuesOption{
		AssigneeIds: []int{*me.ID},
		Statuses:    []backlog.IssueStatus{1, 2, 3},
	}

	issues, err := backlogClient.IssuesWithOption(opt)

	if err != nil {
		log.Printf("[ERROR] Backlog request fails '%s'", err)
		return 1
	}

	log.Printf("[DEBUG] issues: %#+v", issues)

	for _, item := range issues {
		url := backlogEndpoint + "/view" + "/" + *item.IssueKey

		due := ""
		if item.DueDate != nil {
			time := *item.DueDate
			due = time.String()
		}

		fmt.Printf("%v, %v, %v\n", *item.Summary, url, due)
	}

	// ChatWork
	chatworkToken := c.GlobalString("chatwork-token")
	if len(chatworkToken) == 0 {
		log.Printf("[ERROR] %s", "You need Chatwork API-Key")
		return 1
	}

	chatworkClient := chatwork.NewClient(chatworkToken)
	myTasks := chatworkClient.MyTasks(nil)
	for _, item := range myTasks {
		timeString := ""
		if item.LimitTime > 0 {
			timeString = item.LimitDate().String()
		}
		fmt.Printf("%v, %v\n", item.Body, timeString)
	}

	return 0
}
Ejemplo n.º 5
0
func main() {
	c := chatwork.NewClient(apiKey)
	fmt.Printf("%+v\n", c.MyStatus())
	fmt.Printf("%+v\n", c.MyTasks(map[string]string{}))
}
Ejemplo n.º 6
0
func main() {
	c := chatwork.NewClient(apiKey)
	fmt.Printf("%+v\n", c.Me())
}