goroon

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2017 License: MIT Imports: 10 Imported by: 0

README

Build Status

Goroon

Command Line Interface and Library for Garoon with Go language

Install

CLI

MacOS user can use homebrew to install goroon

$ brew tap tzmfreedom/goroon
$ brew install goroon

If you want to use latest version of goroon, execute following command.

$ go get -u github.com/tzmfreedom/goroon/goroon
Library
$ go get github.com/tzmfreedom/goroon

Usage

NAME:
   goroon - garoon utility

USAGE:
   goroon [global options] command [command options] [arguments...]

VERSION:
   0.1.0

COMMANDS:
     login, l     login to garoon
     schedule, s  get your schedule
     bulletin, b  get bulletin
     help, h      Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --help, -h     show help
   --version, -v  print the version

Get schedule on target date

NAME:
   goroon schedule - get your schedule

USAGE:
   goroon schedule [command options] [arguments...]

OPTIONS:
   --username value, -u value   [$GAROON_USERNAME]
   --password value, -p value   [$GAROON_PASSWORD]
   --endpoint value, -e value   [$GAROON_ENDPOINT]
   --userid value, -i value
   --start value
   --end value
   --type value, -t value      (default: "all")
   --columns value, -c value   (default: "detail,start,end")
   --debug, -D
   --date value, -d value

Get my schedule on target date

$ goroon schedule -u {USERNAME} -p {PASSWORD} -e {ENDPOINT} --start {START DATETIME} --end {END DATETIME}
$ goroon schedule -u {USERNAME} -p {PASSWORD} -e {ENDPOINT} -d {DATE:[today|yesterday]}

ex)
$ goroon schedule -u hoge -p fuga -e https//hoge.garoon.com/grn.exe \
  --start '2017-03-01 00:00:00' --end '2017-03-01 23:59:59'
$ goroon schedule -u hoge -p fuga -e https//hoge.garoon.com/grn.exe -d today # get today's your schedule
$ goroon schedule -u hoge -p fuga -e https//hoge.garoon.com/grn.exe # get today's your schedule

Get target user's schedule

$ goroon schedule -u {USERNAME} -p {PASSWORD} -e {ENDPOINT} --start {START DATETIME} --end {END DATETIME} --userid {USER ID}

Get bulletin

NAME:
   goroon bulletin - get bulletin

USAGE:
   goroon bulletin [command options] [arguments...]

OPTIONS:
   --username value, -u value   [$GAROON_USERNAME]
   --password value, -p value   [$GAROON_PASSWORD]
   --endpoint value, -e value   [$GAROON_ENDPOINT]
   --topic_id value            (default: 0)
   --offset value, -o value    (default: 0)
   --limit value, -l value     (default: 20)
   --debug, -D
   --columns value, -c value   (default: "creator,text")
$ goroon bulleting -u {USERNAME} -p {PASSWORD} -e {ENDPOINT}

Login to garoon

NAME:
   goroon login - login to garoon

USAGE:
   goroon login [command options] [arguments...]

OPTIONS:
   --username value, -u value   [$GAROON_USERNAME]
   --password value, -p value   [$GAROON_PASSWORD]
   --endpoint value, -e value   [$GAROON_ENDPOINT]
   --debug, -D
ex)
$ goroon login -u hoge -p fuga -e "https://hoge.garoon.com/grn.exe"

The credentials, that is username, password, endpoint, is required on any goroon command. For this reason, it's hard to use these commands. Login subcommand solve the problem. If you call garoon login subcommand, goroon create .goroon file on your home path and write session id and endpoint on it. When .goroon file exists, every command read .goroon file and use information on file to login to garoon.

For example, if you called login command, you can use the following command to get your schedule on today.

$ goroon schedule
Library

Initialize by credentials

client := goroon.NewClient("input garoon endpoint")
client.Username = "input your username"
client.Password = "input your password"

Initialize by sessionId

client := goroon.NewClient("input garoon endpoint")
client.SessionId = "input your sessionId"

Get my schedule on target date

start := time.Date(2017, 1, 1, 0, 0, 0, 0, time.Local)
end := time.Date(2017, 1, 1, 23, 59, 59, 999999, time.Local)

res, err := client.ScheduleGetEvents(&goroon.Parameters{
  Start: goroon.XmlDateTime{start},
  End:   goroon.XmlDateTime{end},
})
if err != nil {
  return err
}
for _, sch := range res.ScheduleEvents {
  fmt.Println(event.Id)
  fmt.Println(event.Members)
  fmt.Println(event.EventType)
  fmt.Println(event.Detail)
  fmt.Println(event.Description)
  if event.When.Datetime.Start == new(time.Time) {
    fmt.Println(event.When.Date.Start.Format("2006-01-02"))
    fmt.Println(event.When.Date.End.Format("2006-01-02")
  } else {
    fmt.Println(event.When.Datetime.Start.Format("2006-01-02T15:04:05"))
    fmt.Println(event.When.Datetime.End.Format("2006-01-02T15:04:05"))
  }
}

Get UserId from login name

res, err := client.BaseGetUserByLoginName(&goroon.Parameters{
  LoginName: []string{"hogehoge"},
})
if err != nil {
  return err
}
fmt.Println(res.LoginId)

Get Bulletin folows

res, err := client.BulletinGetFollows(&goroon.Parameters{
  TopicId: 1234,
  Offset:  0,
  Limit:   20,
})
if err != nil {
  return err
}

for _, follow := range res.Follow {
  fmt.Println(fmt.Sprint(follow.Number))
  fmt.Println(follow.Creator.Name)
  fmt.Println(follow.Text)
}

Debug your request

client := goroon.NewClient("https://garoon.hogehoge.com/grn.exe")
client.Debugger = os.Stdout

Debugger property is io.Writer interface. You can debug out to anywhere with io.Writer.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseGetUserByLoginNameRequest

type BaseGetUserByLoginNameRequest struct {
	XMLName    xml.Name    `xml:"BaseGetUsersByLoginName"`
	Parameters *Parameters `xml:"parameters"`
}

type BaseGetUserByLoginNameResponse

type BaseGetUserByLoginNameResponse struct {
	XMLName xml.Name `xml:"BaseGetUserByLoginNameResponse"`
	Returns *Returns `xml:"returns"`
}

type BulletinGetFollowsRequest

type BulletinGetFollowsRequest struct {
	XMLName    xml.Name    `xml:"BulletinGetFollows"`
	Parameters *Parameters `xml:"parameters"`
}

type BulletinGetFollowsResponse

type BulletinGetFollowsResponse struct {
	XMLName xml.Name `xml:"BulletinGetFollowsResponse"`
	Returns *Returns `xml:"returns"`
}

type Client

type Client struct {
	Endpoint  string
	Username  string
	Password  string
	Locale    string
	Debugger  io.Writer
	SessionId string
}

func NewClient

func NewClient(endpoint string) *Client

func (*Client) BaseGetUserByLoginName

func (c *Client) BaseGetUserByLoginName(params *Parameters) (*Returns, error)

func (*Client) BulletinGetFollows

func (c *Client) BulletinGetFollows(params *Parameters) (*Returns, error)

func (*Client) Request

func (c *Client) Request(action string, path string, req interface{}, res interface{}) error

func (*Client) ScheduleGetEvents

func (c *Client) ScheduleGetEvents(params *Parameters) (*Returns, error)

func (*Client) ScheduleGetEventsByTarget

func (c *Client) ScheduleGetEventsByTarget(params *Parameters) (*Returns, error)

func (*Client) UtilGetLoginUserId

func (c *Client) UtilGetLoginUserId(params *Parameters) (*Returns, error)

func (*Client) UtilLogin

func (c *Client) UtilLogin(params *Parameters) (*Returns, error)

type Condition

type Condition struct {
	Type               string             `xml:"type,attr"`
	Day                int                `xml:"day,attr"`
	Week               int                `xml:"week,attr"`
	StartDate          XmlDate            `xml:"start_date,attr"`
	EndDate            XmlDate            `xml:"end_date,attr"`
	StartTime          string             `xml:"start_time,attr"`
	EndTime            string             `xml:"end_time,attr"`
	ExclusiveDatetimes ExclusiveDatetimes `xml:"exclusive_datetimes"`
}

type Creator

type Creator struct {
	UserId int       `xml:"user_id,attr,omitempty"`
	Name   string    `xml:"name,attr,omitempty"`
	Date   time.Time `xml:"date,attr,omitempty"`
}

type Date

type Date struct {
	XMLName xml.Name `xml:"date"`
	Start   XmlDate  `xml:"start,attr"`
	End     XmlDate  `xml:"end,attr"`
}

type Datetime

type Datetime struct {
	XMLName xml.Name  `xml:"datetime"`
	Start   time.Time `xml:"start,attr"`
	End     time.Time `xml:"end,attr"`
}

type ExclusiveDatetime

type ExclusiveDatetime struct {
	Start string `xml:"start,attr"`
	End   string `xml:"end,attr"`
}

type ExclusiveDatetimes

type ExclusiveDatetimes struct {
	ExclusiveDatetime []ExclusiveDatetime `xml:"exclusive_datetime"`
}

type FaultDetail

type FaultDetail struct {
	Code           string `xml:"code"`
	Diagnosis      string `xml:"diagnosis"`
	Cause          string `xml:"cause"`
	CounterMeasure string `xml:"counter_measure"`
}

type Follow

type Follow struct {
	Creator *Creator `xml:"http://schemas.cybozu.co.jp/bulletin/2008 creator"`
	TopicId int      `xml:"topic_id,attr,omitempty"`
	Id      int      `xml:"id,attr,omitempty"`
	Number  int      `xml:"number,attr,omitempty"`
	Text    string   `xml:"text,attr,omitempty"`
}

type Member

type Member struct {
	XMLName xml.Name `xml:"member"`
	User    User     `xml:"user"`
}

type Members

type Members struct {
	XMLName xml.Name `xml:"members"`
	Member  []Member `xml:"member"`
}

type NopWriter

type NopWriter struct{}

func (*NopWriter) Write

func (d *NopWriter) Write(b []byte) (int, error)

type Parameters

type Parameters struct {
	Start     XmlDateTime `xml:"start,attr,omitempty"`
	End       XmlDateTime `xml:"end,attr,omitempty"`
	User      User        `xml:"user,omitempty"`
	LoginName []string    `xml:"login_name,omitempty"`
	TopicId   int         `xml:"topic_id,attr"`
	Offset    int         `xml:"offset,attr"`
	Limit     int         `xml:"limit,attr"`
	Password  string      `xml:"password"`
}

type RepeatInfo

type RepeatInfo struct {
	Condition Condition `xml:"condition"`
}

type Returns

type Returns struct {
	ScheduleEvents []ScheduleEvent `xml:"schedule_event,omitempty"`
	Follow         []Follow        `xml:"follow,omitempty"`
	UserId         int             `xml:"user_id,omitempty"`
	User           []User          `xml:"user,omitempty"`
	LoginName      string          `xml:"login_name,omitempty"`
	Status         string          `xml:"status,omitempty"`
	Cookie         string          `xml:"cookie,omitempty"`
}

type ScheduleEvent

type ScheduleEvent struct {
	Members     Members    `xml:"members"`
	RepeatInfo  RepeatInfo `xml:"repeat_info"`
	When        When       `xml:"when"`
	Detail      string     `xml:"detail,attr"`
	Description string     `xml:"description,attr"`
	Id          int        `xml:"id,attr"`
	EventType   string     `xml:"event_type,attr"`
}

type ScheduleGetEventsByTargetRequest

type ScheduleGetEventsByTargetRequest struct {
	XMLName    xml.Name    `xml:"ScheduleGetEventsByTarget"`
	Parameters *Parameters `xml:"parameters"`
}

type ScheduleGetEventsByTargetResponse

type ScheduleGetEventsByTargetResponse struct {
	XMLName xml.Name `xml:"ScheduleGetEventsByTargetResponse"`
	Returns *Returns `xml:"returns"`
}

type ScheduleGetEventsRequest

type ScheduleGetEventsRequest struct {
	XMLName    xml.Name    `xml:"ScheduleGetEvents"`
	Parameters *Parameters `xml:"parameters"`
}

type ScheduleGetEventsResponse

type ScheduleGetEventsResponse struct {
	XMLName xml.Name `xml:"ScheduleGetEventsResponse"`
	Returns *Returns `xml:"returns"`
}

type Security

type Security struct {
	UsernameToken UsernameToken `xml:"UsernameToken,omitempty`
}

type SoapBody

type SoapBody struct {
	XMLName xml.Name    `xml:"Body"`
	Content interface{} `xml:",omitempty"`
	Fault   *SoapFault  `xml:",omitempty"`
}

func (*SoapBody) UnmarshalXML

func (b *SoapBody) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type SoapEnvelope

type SoapEnvelope struct {
	XMLName    xml.Name    `xml:"http://www.w3.org/2003/05/soap-envelope Envelope"`
	SoapHeader *SoapHeader `xml:"http://www.w3.org/2003/05/soap-envelope Header,omitempty"`
	SoapBody   *SoapBody   `xml:"http://www.w3.org/2003/05/soap-envelope Body"`
}

type SoapFault

type SoapFault struct {
	XMLName xml.Name `xml:"http://www.w3.org/2003/05/soap-envelope Fault"`

	Code   string      `xml:"Code>Value,omitempty"`
	Reason string      `xml:"Reason>Text,omitempty"`
	Actor  string      `xml:"Actor,omitempty"`
	Detail FaultDetail `xml:"Detail,omitempty"`
}

type SoapHeader

type SoapHeader struct {
	Action    string    `xml:"Action"`
	Security  Security  `xml:"Security"`
	Timestamp Timestamp `xml:"Timestamp"`
	Locale    string    `xml:"Locale"`
}

type Timestamp

type Timestamp struct {
	Created time.Time `xml:"Created"`
	Expires time.Time `xml:"Expires"`
}

type User

type User struct {
	XMLName     xml.Name `xml:"user,omitempty"`
	Id          int      `xml:"id,attr,omitempty"`
	Name        string   `xml:"name,attr,omitempty"`
	Key         int      `xml:"key,attr,omitempty"`
	Version     int      `xml:"version,attr,omitempty"`
	Order       int      `xml:"order,attr,omitempty"`
	LoginName   string   `xml:"login_name,attr,omitempty"`
	Status      int      `xml:"status,attr,omitempty"`
	URL         string   `xml:"url,attr,omitempty"`
	Email       string   `xml:"email,attr,omitempty"`
	Phone       string   `xml:"phone,attr,omitempty"`
	Description string   `xml:"description,attr,omitempty"`
	Title       string   `xml:"title,attr,omitempty"`
}

type UsernameToken

type UsernameToken struct {
	Username string `xml:"Username"`
	Password string `xml:"Password"`
}

type UtilGetLoginUserIdRequest

type UtilGetLoginUserIdRequest struct {
	XMLName    xml.Name    `xml:"UtilGetLoginUserId"`
	Parameters *Parameters `xml:"parameters"`
}

type UtilGetLoginUserIdResponse

type UtilGetLoginUserIdResponse struct {
	XMLName xml.Name `xml:"UtilGetLoginUserIdResponse"`
	Returns *Returns `xml:"returns"`
}

type UtilLoginRequest

type UtilLoginRequest struct {
	XMLName    xml.Name    `xml:"UtilLogin"`
	Parameters *Parameters `xml:"parameters"`
}

type UtilLoginResponse

type UtilLoginResponse struct {
	XMLName xml.Name `xml:"LoginResponse"`
	Returns *Returns `xml:"returns"`
}

type When

type When struct {
	XMLName  xml.Name `xml:"when"`
	Datetime Datetime `xml:"datetime"`
	Date     Date     `xml:"date"`
}

type XmlDate

type XmlDate struct {
	time.Time
}

func (*XmlDate) UnmarshalXMLAttr

func (c *XmlDate) UnmarshalXMLAttr(attr xml.Attr) error

type XmlDateTime

type XmlDateTime struct {
	time.Time
}

func (XmlDateTime) MarshalXML

func (c XmlDateTime) MarshalXML(e *xml.Encoder, start xml.StartElement) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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