gochatwork

package module
v0.0.0-...-de7673a Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2019 License: MIT Imports: 14 Imported by: 3

README

ChatWork API Client for Golang

ChatWork client for Golang.

Install

$ go get github.com/griffin-stewie/go-chatwork

Usage

package main

import (
  chatwork "github.com/griffin-stewie/go-chatwork"
)

func main() {
  chatwork := chatwork.NewClient(`api-key`)

  chatwork.Me()

  chatwork.MyStatus()

  chatwork.MyTasks(map[string]string {
    "assigned_by_account_id": "123",
    "status": "open"
  })

  chatwork.RateLimit()

  ...
}
for GoogleAppEngine/Go
c := appengine.NewContext(r)
client := urlfetch.Client(c)
chatwork := chatwork.NewClient(`api-key`)
chatwork.HTTPClient = client

See more examples in examples directory.

Documentation

Index

Constants

View Source
const BaseURL = `https://api.chatwork.com/v2`

BaseURL ChatWork API endpooint URL

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	AccountID      int    `json:"account_id"`
	Name           string `json:"name"`
	AvatarImageURL string `json:"avatar_image_url"`
}

Account model

type ChatWorkError

type ChatWorkError struct {
	Errors []string `json:"errors"`
}

ChatWorkError is error model

type Client

type Client struct {
	APIKey  string
	BaseURL string
	HTTP
	HTTPClient *http.Client
	// contains filtered or unexported fields
}

Client ChatWork HTTP client

func NewClient

func NewClient(apiKey string) *Client

NewClient returns ChatWork HTTP Client

func (*Client) ApproveIncomingRequests

func (c *Client) ApproveIncomingRequests(requestID int) (incomingRequest IncomingRequest, err error)

ApproveIncomingRequests PUT "/incoming_requests/{request_id}"

func (*Client) Contacts

func (c *Client) Contacts() (contacts []Contact, err error)

Contacts GET "/contacts"

func (*Client) CreateRoom

func (c *Client) CreateRoom(params map[string]string) ([]byte, error)

CreateRoom POST "/rooms" params keys

  • name
  • members_admin_ids
  • description
  • icon_preset
  • members_member_ids
  • members_readonly_ids

func (*Client) Delete

func (c *Client) Delete(endpoint string, params map[string]string) ([]byte, error)

Delete DELETE method

func (*Client) DeleteIncomingRequests

func (c *Client) DeleteIncomingRequests(requestID int) error

DeleteIncomingRequests DELETE "/incoming_requests/{request_id}"

func (c *Client) DeleteInvitationLink(roomID string) (invitationLink InvitationLink, err error)

DeleteInvitationLink DELETE "/rooms/{room_id}/link" params keys

  • code
  • description
  • need_acceptance

func (*Client) DeleteRoom

func (c *Client) DeleteRoom(roomID string, params map[string]string) ([]byte, error)

DeleteRoom DELETE "/rooms/{room_id}" params key

  • action_type: [leave, delete]

func (*Client) DeleteRoomMessage

func (c *Client) DeleteRoomMessage(roomID, messageID string) ([]byte, error)

DeleteRoomMessage DELETE "/rooms/{room_id}/messages/{message_id}"

func (*Client) Get

func (c *Client) Get(endpoint string, params map[string]string) ([]byte, error)

Get GET method

func (*Client) GetIncomingRequests

func (c *Client) GetIncomingRequests() (incomingRequests []IncomingRequest, err error)

GetIncomingRequests GET "/incoming_requests"

func (c *Client) GetInvitationLink(roomID string) (invitationLink InvitationLink, err error)

GetInvitationLink GET "/rooms/{room_id}/link"

func (*Client) Me

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

Me GET "/me"

func (*Client) MyStatus

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

MyStatus GET "/my/status"

func (*Client) MyTasks

func (c *Client) MyTasks(params map[string]string) (tasks []MyTask, err error)

MyTasks GET "/my/tasks" params keys

  • assigned_by_account_id
  • status: [open, done]

func (*Client) Post

func (c *Client) Post(endpoint string, params map[string]string) ([]byte, error)

Post POST method

func (c *Client) PostInvitationLink(roomID, code, description string, needAcceptance bool) (invitationLink InvitationLink, err error)

PostInvitationLink POST "/rooms/{room_id}/link" params keys

  • code
  • description
  • need_acceptance

func (*Client) PostRoomFile

func (c *Client) PostRoomFile(roomID, message, fileName string, file io.Reader) ([]byte, error)

PostRoomFile POST "/rooms/{room_id}/files"

func (*Client) PostRoomMessage

func (c *Client) PostRoomMessage(roomID string, body string) ([]byte, error)

PostRoomMessage POST "/rooms/{room_id}/messages"

func (*Client) PostRoomTask

func (c *Client) PostRoomTask(roomID string, params map[string]string) ([]byte, error)

PostRoomTask POST "/rooms/{room_id}/tasks" params keys

  • body
  • to_ids
  • limit

func (*Client) Put

func (c *Client) Put(endpoint string, params map[string]string) ([]byte, error)

Put PUT method

func (*Client) RateLimit

func (c *Client) RateLimit() *RateLimit

RateLimit returns rate limit

func (*Client) Room

func (c *Client) Room(roomID string) (room Room, err error)

Room GET "/rooms/{room_id}"

func (*Client) RoomFile

func (c *Client) RoomFile(roomID, fileID string, params map[string]string) (file File, err error)

RoomFile GET "/rooms/{room_id}/files/{file_id}" params key

  • create_download_url: ["0", "1"]

func (*Client) RoomFiles

func (c *Client) RoomFiles(roomID string, params map[string]string) (files []File, err error)

RoomFiles GET "/rooms/{room_id}/files/" params key

  • account_id

func (*Client) RoomMembers

func (c *Client) RoomMembers(roomID string) (members []Member, err error)

RoomMembers GET "/rooms/{room_id}/members"

func (*Client) RoomMessage

func (c *Client) RoomMessage(roomID, messageID string) (message Message, err error)

RoomMessage GET "/rooms/{room_id}/messages/{message_id}"

func (*Client) RoomMessageMarkAsRead

func (c *Client) RoomMessageMarkAsRead(roomID, messageID string) ([]byte, error)

RoomMessageMarkAsRead PUT "/rooms/{room_id}/messages/read"

func (*Client) RoomMessageMarkAsUnread

func (c *Client) RoomMessageMarkAsUnread(roomID, messageID string) ([]byte, error)

RoomMessageMarkAsUnread PUT "/rooms/{room_id}/messages/unread"

func (*Client) RoomMessages

func (c *Client) RoomMessages(roomID string, params map[string]string) (msgs Messages, err error)

RoomMessages GET "/rooms/{room_id}/messages"

func (*Client) RoomTask

func (c *Client) RoomTask(roomID, taskID string) (task Task, err error)

RoomTask GET "/rooms/{room_id}/tasks/tasks_id"

func (*Client) RoomTasks

func (c *Client) RoomTasks(roomID string, params map[string]string) (tasks []Task, err error)

RoomTasks GET "/rooms/{room_id}/tasks" params keys

  • account_id
  • assigned_by_account_id
  • status: [open, done]

func (*Client) Rooms

func (c *Client) Rooms() (rooms []Room, err error)

Rooms GET "/rooms"

func (c *Client) UpdateInvitationLink(roomID, code, description string, needAcceptance bool) (invitationLink InvitationLink, err error)

UpdateInvitationLink PUT "/rooms/{room_id}/link" params keys

  • code
  • description
  • need_acceptance

func (*Client) UpdateRoom

func (c *Client) UpdateRoom(roomID string, params map[string]string) ([]byte, error)

UpdateRoom PUT "/rooms/{room_id}" params keys

  • description
  • icon_preset
  • name

func (*Client) UpdateRoomMembers

func (c *Client) UpdateRoomMembers(roomID string, params map[string]string) ([]byte, error)

UpdateRoomMembers PUT "/rooms/{room_id}/members" params keys

  • members_admin_ids
  • members_member_ids
  • members_readonly_ids

func (*Client) UpdateRoomMessage

func (c *Client) UpdateRoomMessage(roomID, messageID, body string) ([]byte, error)

UpdateRoomMessage PUT "/rooms/{room_id}/messages/{message_id}"

type Contact

type Contact struct {
	AccountID        int    `json:"account_id"`
	RoomID           int    `json:"room_id"`
	Name             string `json:"name"`
	ChatworkID       string `json:"chatwork_id"`
	OrganizationID   int    `json:"organization_id"`
	OrganizationName string `json:"organization_name"`
	Department       string `json:"department"`
	AvatarImageURL   string `json:"avatar_image_url"`
}

Contact model

type File

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

File model

func (File) UploadDate

func (f File) UploadDate() time.Time

UploadDate time.Time representation of UploadTime

type HTTP

type HTTP interface {
	Get()
	Post()
	Put()
	Delete()
}

HTTP interface of HTTP METHODS's methods

type IncomingRequest

type IncomingRequest struct {
	RequestID        int    `json:"request_id"`
	AccountID        int    `json:"account_id"`
	Message          string `json:"message"`
	Name             string `json:"name"`
	ChatworkID       string `json:"chatwork_id"`
	OrganizationID   string `json:"organization_id"`
	OrganizationName string `json:"organization_name"`
	Department       string `json:"department"`
	AvatarImageUrl   string `json:"avatar_image_url"`
}

IncomingRequest model

type InvitationLink struct {
	IsPublic       bool   `json:"public"`
	URL            string `json:"url"`
	NeedAcceptance bool   `json:"need_acceptance"`
	Description    string `json:"description"`
}

InvitationLink model

type Me

type Me struct {
	AccountID        int    `json:"account_id"`
	RoomID           int    `json:"room_id"`
	Name             string `json:"name"`
	ChatworkID       string `json:"chatwork_id"`
	OrganizationID   int    `json:"organization_id"`
	OrganizationName string `json:"organization_name"`
	Department       string `json:"department"`
	Title            string `json:"title"`
	URL              string `json:"url"`
	Introduction     string `json:"introduction"`
	Mail             string `json:"mail"`
	TelOrganization  string `json:"tel_organization"`
	TelExtension     string `json:"tel_extension"`
	TelMobile        string `json:"tel_mobile"`
	Skype            string `json:"skype"`
	Facebook         string `json:"facebook"`
	Twitter          string `json:"twitter"`
	AvatarImageURL   string `json:"avatar_image_url"`
	LoginMail        string `json:"login_mail"`
}

Me model

type Member

type Member struct {
	AccountID        int    `json:"account_id"`
	Role             string `json:"role"`
	Name             string `json:"name"`
	ChatworkID       string `json:"chatwork_id"`
	OrganizationID   int    `json:"organization_id"`
	OrganizationName string `json:"organization_name"`
	Department       string `json:"department"`
	AvatarImageURL   string `json:"avatar_image_url"`
}

Member model

type Message

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

Message model

func (Message) SendDate

func (m Message) SendDate() time.Time

SendDate time.Time representation of SendTime

func (Message) UpdateDate

func (m Message) UpdateDate() time.Time

UpdateDate time.Time representation of UpdateTime

type Messages

type Messages []Message

Messages slice of Message

type MyTask

type MyTask struct {
	Task
	Room struct {
		Roomid   int    `json:"room_id"`
		Name     string `json:"name"`
		IconPath string `json:"icon_path"`
	}
}

MyTask model

type RateLimit

type RateLimit struct {
	Limit     int
	Remaining int
	ResetTime int64
}

RateLimit model

func (RateLimit) ResetDate

func (r RateLimit) ResetDate() time.Time

ResetDate time.Time representation of ResetTime

type Room

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

Room model

type Status

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

Status model

type Task

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

Task model

func (Task) LimitDate

func (t Task) LimitDate() time.Time

LimitDate time.Time representation of LimitTime

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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