gochatwork

package module
v0.0.0-...-63cb788 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2015 License: MIT, MIT Imports: 7 Imported by: 1

README

Circle CI Coverage Status GoDoc License

Chatwork api client for golang.

This support www.chatwork.com and kcw.kddi.ne.jp

Install

$ go get github.com/ota42y/go-chatwork-api

Usage

package main

import (
	chatwork "github.com/ota42y/go-chatwork-api"
)

func main() {
	chatwork := chatwork.New("api-key")
	
	rooms, err := client.GetRooms()
	if err == nil {
		for _, room := range rooms {
			fmt.Println(room.RoomId, room.Name, room.UnreadNum)
		}
	} else {
		fmt.Println(err)
	}
}

Feature

Full api support. (in 2015/11)

  • /me
  • /my
  • /contacts
  • /rooms

License

MIT: https://github.com/ota42y/go-chatwork-api/LICENSE.txt

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	AccountID        int64 `json:"account_id"`
	Name             string
	Role             string
	ChatworkID       string `json:"chatwork_id"`
	OrganizationID   int64  `json:"organization_id"`
	OrganizationName string `json:"organization_name"`
	Department       string
	AvatarImageURL   string `json:"avatar_image_url"`
}

Account is task struct

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is chatwork api client

func New

func New(token string) *Client

New return api client for www.chatwork.com

func (*Client) DeleteRooms

func (c *Client) DeleteRooms(roomID int64, actionType string) error

DeleteRooms send DELETE rooms/room_id response, this api don't return response

func (*Client) GetContacts

func (c *Client) GetContacts() ([]Account, error)

GetContacts return GET /contacts response by []Account

func (*Client) GetContactsRaw

func (c *Client) GetContactsRaw() ([]byte, error)

GetContactsRaw return GET /contacts response by []byte

func (*Client) GetFiles

func (c *Client) GetFiles(roomID int64, accountID int64) ([]File, error)

GetFiles return /rooms/{room_id}/files response by []File

func (*Client) GetFilesRaw

func (c *Client) GetFilesRaw(roomID int64, accountID int64) ([]byte, error)

GetFilesRaw return /rooms/{room_id}/files response by []byte

func (*Client) GetMembers

func (c *Client) GetMembers(roomID int64) ([]Account, error)

GetMembers return rooms/room_id/members response by []Account

func (*Client) GetMembersRaw

func (c *Client) GetMembersRaw(roomID int64) ([]byte, error)

GetMembersRaw return rooms/room_id/members response by []byte

func (*Client) GetMessage

func (c *Client) GetMessage(roomID int64, force bool) ([]Message, error)

GetMessage get message to rooms/room_id/messages and response by []Message

func (*Client) GetMessageRaw

func (c *Client) GetMessageRaw(roomID int64, force bool) ([]byte, error)

GetMessageRaw get message to rooms/room_id/messages and response by []byte

func (*Client) GetRooms

func (c *Client) GetRooms() ([]Room, error)

GetRooms return rooms response by []Room

func (*Client) GetRoomsRaw

func (c *Client) GetRoomsRaw() ([]byte, error)

GetRoomsRaw return rooms response by []byte

func (*Client) GetSpecificFiles

func (c *Client) GetSpecificFiles(roomID int64, fileID int64, createDownloadURL bool) (File, error)

GetSpecificFiles return /rooms/{room_id}/files/file_id response by File

func (*Client) GetSpecificFilesRaw

func (c *Client) GetSpecificFilesRaw(roomID int64, fileID int64, createDownloadURL bool) ([]byte, error)

GetSpecificFilesRaw return /rooms/{room_id}/files/file_id response by []byte

func (*Client) GetSpecificMessage

func (c *Client) GetSpecificMessage(roomID int64, messageID int64) (Message, error)

GetSpecificMessage get message to rooms/room_id/messages/message_id and response by Message

func (*Client) GetSpecificMessageRaw

func (c *Client) GetSpecificMessageRaw(roomID int64, messageID int64) ([]byte, error)

GetSpecificMessageRaw get message to rooms/room_id/messages/message_id and response by []byte

func (*Client) GetSpecificRooms

func (c *Client) GetSpecificRooms(roomID int64) (Room, error)

GetSpecificRooms return rooms/room_id response by Room

func (*Client) GetSpecificRoomsRaw

func (c *Client) GetSpecificRoomsRaw(roomID int64) ([]byte, error)

GetSpecificRoomsRaw return rooms/room_id response by []byte

func (*Client) GetSpecificTask

func (c *Client) GetSpecificTask(roomID int64, taskID int64) (Task, error)

GetSpecificTask get tasks to rooms/room_id/tasks/task_id and response by Task

func (*Client) GetSpecificTaskRaw

func (c *Client) GetSpecificTaskRaw(roomID int64, taskID int64) ([]byte, error)

GetSpecificTaskRaw get tasks to rooms/room_id/tasks/task_id and response by []byte

func (*Client) GetTasks

func (c *Client) GetTasks(roomID int64, accountID int64, assignedByAccountID int64, status string) ([]Task, error)

GetTasks get tasks to rooms/room_id/tasks and response by []tasks

func (*Client) GetTasksRaw

func (c *Client) GetTasksRaw(roomID int64, accountID int64, assignedByAccountID int64, status string) ([]byte, error)

GetTasksRaw get tasks to rooms/room_id/tasks and response by []tasks

func (*Client) Me

func (c *Client) Me() (Me, error)

Me return /me response by Me struct

func (*Client) MeRaw

func (c *Client) MeRaw() ([]byte, error)

MeRaw return /me response by []byte

func (*Client) MyStatus

func (c *Client) MyStatus() (Status, error)

MyStatus return my/status response by Status struct

func (*Client) MyStatusRaw

func (c *Client) MyStatusRaw() ([]byte, error)

MyStatusRaw return my/status response by []byte

func (*Client) MyTasks

func (c *Client) MyTasks(params url.Values) ([]Task, error)

MyTasks return my/tasks response by []Task

func (*Client) MyTasksRaw

func (c *Client) MyTasksRaw(params url.Values) ([]byte, error)

MyTasksRaw return my/tasks response by []byte

func (*Client) PostMessage

func (c *Client) PostMessage(roomID int64, message string) (int64, error)

PostMessage post message to rooms/room_id/messages and response by int64

func (*Client) PostMessageRaw

func (c *Client) PostMessageRaw(roomID int64, message string) ([]byte, error)

PostMessageRaw post message to rooms/room_id/messages and response by []byte

func (*Client) PostRooms

func (c *Client) PostRooms(description string, iconPreset string, membersAdminIDs []int64, membersMemberIDs []int64, membersReadonlyIDs []int64, name string) (int64, error)

PostRooms return POST rooms response by int64

func (*Client) PostRoomsRaw

func (c *Client) PostRoomsRaw(description string, iconPreset string, membersAdminIDs []int64, membersMemberIDs []int64, membersReadonlyIDs []int64, name string) ([]byte, error)

PostRoomsRaw return POST rooms response by []byte

func (*Client) PostTasks

func (c *Client) PostTasks(roomID int64, body string, limit time.Time, toIDs []int64) ([]int64, error)

PostTasks post tasks to rooms/room_id/tasks and response by []int64

func (*Client) PostTasksRaw

func (c *Client) PostTasksRaw(roomID int64, body string, limit time.Time, toIDs []int64) ([]byte, error)

PostTasksRaw post tasks to rooms/room_id/tasks and response by []byte

func (*Client) PutMembers

func (c *Client) PutMembers(roomID int64, membersAdminIDs []int64, membersMemberIDs []int64, membersReadonlyIDs []int64) (admin []int64, member []int64, readonly []int64, err error)

PutMembers return PUT rooms/room_id/members response

func (*Client) PutMembersRaw

func (c *Client) PutMembersRaw(roomID int64, membersAdminIDs []int64, membersMemberIDs []int64, membersReadonlyIDs []int64) ([]byte, error)

PutMembersRaw return PUT rooms/room_id/members response by []byte

func (*Client) PutRooms

func (c *Client) PutRooms(roomID int64, description string, iconPreset string, name string) (int64, error)

PutRooms return PUT rooms/room_id response by int64

func (*Client) PutRoomsRaw

func (c *Client) PutRoomsRaw(roomID int64, description string, iconPreset string, name string) ([]byte, error)

PutRoomsRaw return PUT rooms/room_id response by []byte

type Errors

type Errors struct {
	Errors []string
}

Errors is error response struct

type File

type File struct {
	FileID      int64 `json:"file_id"`
	Account     Account
	MessageID   int64 `json:"message_id"`
	Filename    string
	Filesize    int64
	UploadTime  int64  `json:"upload_time"`
	DownloadURL string `json:"download_url"`
}

File is file struct

type Me

type Me struct {
	AccountID        int64 `json:"account_id"`
	RoomID           int64 `json:"room_id"`
	Name             string
	ChatworkID       string `json:"chatwork_id"`
	OrganizationID   int64  `json:"organization_id"`
	OrganizationName string `json:"organization_name"`
	Department       string
	Title            string
	URL              string
	Introduction     string
	Mail             string
	TelOrganization  string `json:"tel_organization"`
	TelExtension     string `json:"tel_extension"`
	TelMobile        string `json:"tel_mobile"`
	Skype            string
	Facebook         string
	Twitter          string
	AvatarImageURL   string `json:"avatar_image_url"`
}

Me is /me response struct

type Message

type Message struct {
	MessageID  int64 `json:"message_id"`
	Account    Account
	Body       string
	SendTime   int64 `json:"send_time"`
	UpdateTime int64 `json:"update_time"`
}

Message is message struct

type Room

type Room struct {
	RoomID         int64 `json:"room_id"`
	Name           string
	Type           string
	Role           string
	Sticky         bool
	UnreadNum      int64  `json:"unread_num"`
	MentionNum     int64  `json:"mention_num"`
	MytaskNum      int64  `json:"mytask_num"`
	MessageNum     int64  `json:"message_num"`
	FileNum        int64  `json:"file_num"`
	TaskNum        int64  `json:"task_num"`
	IconPath       string `json:"icon_path"`
	Description    string
	LastUpdateTime int64 `json:"last_update_time"`
}

Room is room struct

type Status

type Status struct {
	UnreadRoomNum  int64 `json:"unread_room_num"`
	MentionRoomNum int64 `json:"mention_room_num"`
	MytaskRoomNum  int64 `json:"mytask_room_num"`
	UnreadNum      int64 `json:"unread_num"`
	MentionNum     int64 `json:"mention_num"`
	MytaskNum      int64 `json:"mytask_num"`
}

Status is /me response struct

type Task

type Task struct {
	TaskID            int64 `json:"task_id"`
	Room              Room
	Account           Account
	AssignedByAccount Account `json:"assigned_by_account"`
	MessageID         int64   `json:"message_id"`
	Body              string
	LimitTime         int64 `json:"limit_time"`
	Status            string
}

Task is task struct

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL