flowdock

package
v0.0.0-...-93c0a78 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2017 License: BSD-2-Clause Imports: 11 Imported by: 5

Documentation

Overview

Golang Flowdock client (REST API)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckResponse

func CheckResponse(r *http.Response) error

CheckResponse checks the API response for errors, and returns them if present. A response is considered an error if it has a status code outside the 200 range. API error responses are expected to have either no response body, or a JSON response body that maps to ErrorResponse. Any other response body will be silently ignored.

Types

type Client

type Client struct {

	// Base URL for API requests.
	RestURL *url.URL

	// Streaming URL for API requests.
	StreamURL *url.URL

	// User agent used when communicating with the Flowdock API.
	UserAgent string

	// Services used for talking to different parts of the Flowdock API.
	Flows         *FlowsService
	Messages      *MessagesService
	Users         *UsersService
	Organizations *OrganizationsService
	Inbox         *InboxService
	// contains filtered or unexported fields
}

A Client manages communication with the Flowdock API.

func NewClient

func NewClient(httpClient *http.Client) *Client

NewClient returns a new Flowdock API client. If a nil httpClient is provided, http.DefaultClient will be used. To use API methods which require authentication, provide an http.Client that will perform the authentication for you (such as that provided by the goauth2 library).

func NewClientWithToken

func NewClientWithToken(httpClient *http.Client, token string) *Client

NewClientWithToken returns a new Flowdock API client instantiated with a personal token. Works the same way as NewClient.

func (*Client) Do

func (c *Client) Do(req *http.Request, v interface{}) (*http.Response, error)

Do sends an API request and returns the API response. The API response is decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred.

func (*Client) NewRequest

func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Request, error)

NewRequest creates an API request. A relative URL can be provided in urlStr, in which case it is resolved relative to the RestURL of the Client. Relative URLs should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included as the request body.

func (*Client) NewStreamRequest

func (c *Client) NewStreamRequest(method, urlStr string, body interface{}) (*http.Request, error)

NewStreamRequest creates an API request. A relative URL can be provided in urlStr, in which case it is resolved relative to the StreamURL of the Client. Relative URLs should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included as the request body.

type CommentContent

type CommentContent struct {
	Title *string `json:"title"`
	Text  *string `json:"text"`
}

CommentContent represents a Message's Content when Message.Event is "comment"

func (*CommentContent) String

func (c *CommentContent) String() string

Return the string version of a CommentContent

It returns the *CommentContent.Text

type Content

type Content interface {
	String() string
}

Content should be implemented by any value that is parsed into Message.RawContent. Its API will likly expand as more Message types are implemented.

type ErrorResponse

type ErrorResponse struct {
	Response *http.Response // HTTP response
	Data     []byte         // the error details
}

An ErrorResponse reports the errors caused by an API request.

func (*ErrorResponse) Error

func (r *ErrorResponse) Error() string

type Flow

type Flow struct {
	Id                *string       `json:"id,omitempty"`
	Name              *string       `json:"name,omitempty"`
	ParameterizedName *string       `json:"parameterized_name,omitempty"`
	UnreadMentions    *int64        `json:"unread_mentions,omitempty"`
	Open              *bool         `json:"open,omitempty"`
	Disabled          *bool         `json:"disabled,omitempty"`
	Joined            *bool         `json:"joined,omitempty"`
	Url               *string       `json:"url,omitempty"`
	WebUrl            *string       `json:"web_url,omitempty"`
	JoinUrl           *string       `json:"join_url,omitempty"`
	AccessMode        *string       `json:"access_mode,omitempty"`
	Organization      *Organization `json:"organization,omitempty"`
	Users             *[]User       `json:"users,omitempty"`
}

Flow represents a Flowdock flow (room).

type FlowsCreateOptions

type FlowsCreateOptions struct {
	Name string `url:"name"`
}

FlowsCreateOptions specifies the optional parameters to the FlowsService.Create method.

type FlowsGetOptions

type FlowsGetOptions struct {
	Id string `url:"id,omitempty"`
}

FlowsGetOptions specifies the optional parameters to the FlowsService.Get method.

type FlowsListOptions

type FlowsListOptions struct {
	// User a boolean value (1/0) that controls whether a list of users should
	// be included with each flow.
	User bool `url:"user,omitempty"`
}

FlowsListOptions specifies the optional parameters to the FlowsService.List method.

type FlowsService

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

FlowsService handles communication with the flow related methods of the Flowdock API.

Flowdock API docs: https://www.flowdock.com/api/flows

func (*FlowsService) Create

func (s *FlowsService) Create(orgName string, opt *FlowsCreateOptions) (*Flow, *http.Response, error)

Create a flow for the specified organization

Flowdock API docs: https://www.flowdock.com/api/flows

func (*FlowsService) Get

func (s *FlowsService) Get(org, flowName string) (*Flow, *http.Response, error)

Get a single flow. Single flow information always includes the flow's user list. Otherwise, the data format is identical to what is returned with the list of flows.

Flowdock API docs: https://www.flowdock.com/api/flows

func (*FlowsService) GetById

func (s *FlowsService) GetById(id string) (*Flow, *http.Response, error)

Get a single flow. Single flow information always includes the flow's user list. Otherwise, the data format is identical to what is returned with the list of flows.

Flowdock API docs: https://www.flowdock.com/api/flows

func (*FlowsService) List

func (s *FlowsService) List(all bool, opt *FlowsListOptions) ([]Flow, *http.Response, error)

Lists the flows that the authenticated user is a member of.

Flowdock API docs: https://www.flowdock.com/api/flows

func (*FlowsService) Update

func (s *FlowsService) Update(orgName, flowName string, flow *Flow) (*Flow, *http.Response, error)

Update a flow.

Flowdock API docs: https://www.flowdock.com/api/flows

type InboxCreateOptions

type InboxCreateOptions struct {
	Source      string   `url:"source,omitempty"`
	FromAddress string   `url:"from_address,omitempty"`
	Subject     string   `url:"subject,omitempty"`
	Content     string   `url:"content,omitempty"`
	FromName    string   `url:"from_name,omitempty"`
	ReplyTo     string   `url:"reply_to,omitempty"`
	Project     string   `url:"project,omitempty"`
	Tags        []string `url:"tags,comma,omitempty"`
	Link        string   `url:"link,omitempty"`
}

InboxCreateOptions specifies the optional parameters to the InboxCreate method.

type InboxService

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

InboxService handles communication with the Team Inbox related methods of the Flowdock API.

Flowdock API docs: https://flowdock.com/api/team-inbox

func (*InboxService) Create

func (s *InboxService) Create(flowApiToken string, opt *InboxCreateOptions) (*Message, *http.Response, error)

Create an Inbox mail message for the specified flow api token

Flowdock API docs: https://www.flowdock.com/api/team-inbox

type JsonContent

type JsonContent string

JsonContent is the default type for Message.Content() that does not have its own explicit type.

func (*JsonContent) String

func (c *JsonContent) String() string

Return the string version of a JsonContent

func (*JsonContent) UnmarshalJSON

func (c *JsonContent) UnmarshalJSON(data []byte) error

Unmarshal the json data into JsonContent (i.e. just a string really)

This just casts a byte data into a JsonContent

type Message

type Message struct {
	ID               *int             `json:"id,omitempty"`
	FlowID           *string          `json:"flow,omitempty"`
	Sent             *Time            `json:"sent,omitempty"`
	UserID           *string          `json:"user,omitempty"`
	Event            *string          `json:"event,omitempty"`
	RawContent       *json.RawMessage `json:"content,omitempty"`
	MessageID        *int             `json:"message,omitempty"`
	Tags             *[]string        `json:"tags,omitempty"`
	UUID             *string          `json:"uuid,omitempty"`
	ExternalUserName *string          `json:"external_user_name,omitempty"`
	App              *string          `json:"app,omitempty"` // deprecated
}

Message represents a Flowdock chat message.

func (*Message) Content

func (m *Message) Content() (content Content)

Return the content of a Message

It can be a MessageContent, CommentContent, etc. Depends on the Event

type MessageContent

type MessageContent string

MessageContent represents a Message's Content when Message.Event is "message"

func (*MessageContent) String

func (c *MessageContent) String() string

Return the string version of a MessageContent

type MessagesCreateOptions

type MessagesCreateOptions struct {
	FlowID           string   `url:"flow,omitempty"`
	MessageID        int      `url:"message,omitempty"`
	Event            string   `url:"event,omitempty"`
	Content          string   `url:"content,omitempty"`
	Tags             []string `url:"tags,comma,omitempty"`
	UUID             string   `url:"uuid,omitempty"`
	ExternalUserName string   `url:"external_user_name,omitempty"`
	Subject          string   `url:"subject,omitempty"`
	FromAddress      string   `url:"from_address,omitempty"`
	Source           string   `url:"source,omitempty"`
}

MessagesCreateOptions specifies the optional parameters to the MessageService.Create method.

type MessagesListOptions

type MessagesListOptions struct {
	Event   string   `url:"event,omitempty"`
	Limit   int      `url:"limit,omitempty"`
	SinceId int      `url:"since_id,omitempty"`
	UntilId int      `url:"until_id,omitempty"`
	Tags    []string `url:"tags,comma,omitempty"`
	TagMode string   `url:"tag_mode,omitempty"`
	Search  string   `url:"search,omitempty"`
}

MessagesListOptions specifies the optional parameters to the MessageService.List method.

type MessagesService

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

MessagesService handles communication with the messages related methods of the Flowdock API.

Flowdock API docs: https://www.flowdock.com/api/messages

func (*MessagesService) Create

Create a message for the specified organization

Flowdock API docs: https://www.flowdock.com/api/messages

func (*MessagesService) CreateComment

func (s *MessagesService) CreateComment(opt *MessagesCreateOptions) (*Message, *http.Response, error)

Create a comment for the specified organization

Flowdock API docs: https://www.flowdock.com/api/messages

func (*MessagesService) List

func (s *MessagesService) List(org, flow string, opt *MessagesListOptions) ([]Message, *http.Response, error)

Lists the messages for the given flow.

Flowdock API docs: https://www.flowdock.com/api/messages

func (*MessagesService) Stream

func (s *MessagesService) Stream(token, org, flow string) (chan Message, *eventsource.EventSource, error)

Stream the messages for the given flow.

Flowdock API docs: https://flowdock.com/api/streaming and https://www.flowdock.com/api/messages

type Organization

type Organization struct {
	Id                *int    `json:"id,omitempty"`
	Name              *string `json:"name,omitempty"`
	ParameterizedName *string `json:"parameterized_name,omitempty"`
	UserLimit         *int64  `json:"user_limit,omitempty"`
	UserCount         *int64  `json:"user_count,omitempty"`
	Active            *bool   `json:"active,omitempty"`
	Url               *string `json:"url,omitempty"`
	Users             *[]User `json:"users"`
}

Organization represents a Flowdock organization to which members belong

type OrganizationUpdateOptions

type OrganizationUpdateOptions struct {
	Name string `json:"name,omitempty"`
}

type OrganizationsService

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

func (*OrganizationsService) All

All organizations authenticated user belongs to.

Flowdock API docs: https://www.flowdock.com/api/organizations

func (*OrganizationsService) GetById

func (s *OrganizationsService) GetById(id int) (*Organization, *http.Response, error)

GetById fetches an organization by it's id.

Flowdock API docs: https://www.flowdock.com/api/organizations

func (*OrganizationsService) GetByParameterizedName

func (s *OrganizationsService) GetByParameterizedName(name string) (*Organization, *http.Response, error)

GetByParameterizedName fetches an organization by it's parameterized_name.

Flowdock API docs: https://www.flowdock.com/api/organizations

func (*OrganizationsService) Update

Update an organization by id.

Flowdock API docs: https://www.flowdock.com/api/organizations

type Time

type Time struct {
	time.Time
}

Time represents a Flowdock time stamp which is milliseconds since Epoch based

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json.Unmarshaler interface. The time is expected to be an intger representing milliseconds since Epoch.

type User

type User struct {
	Id           *int    `json:"id,omitempty"`
	Nick         *string `json:"nick,omitempty"`
	Name         *string `json:"name,omitempty"`
	Email        *string `json:"email,omitempty"`
	Avatar       *string `json:"avatar,omitempty"`
	Status       *string `json:"status,omitempty"`
	Disabled     *bool   `json:"disabled,omitempty"`
	LastActivity *Time   `json:"last_activity,omitempty"`
	LastPing     *Time   `json:"last_ping,omitempty"`
}

type UserUpdateOptions

type UserUpdateOptions struct {
	Nick  string `json:"nick,omitempty"`
	Email string `json:"email,omitempty"`
}

type UsersService

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

func (*UsersService) All

func (s *UsersService) All() ([]User, *http.Response, error)

All users visible to the authenticated user.

Flowdock API docs: https://www.flowdock.com/api/users

func (*UsersService) Get

func (s *UsersService) Get(id int) (*User, *http.Response, error)

Get a user by their id.

Flowdock API docs: https://www.flowdock.com/api/users

func (*UsersService) List

func (s *UsersService) List(org, flow string) ([]User, *http.Response, error)

List the users inside a flow.

Flowdock API docs: https://www.flowdock.com/api/users

func (*UsersService) Update

func (s *UsersService) Update(id int, opt *UserUpdateOptions) (*User, *http.Response, error)

Update a user by their id.

Flowdock API docs: https://www.flowdock.com/api/users

type VcsContent

type VcsContent struct {
	Issue struct {
		Url *string `json:"url"`
	} `json:"issue,omitempty"`
	PullRequest struct {
		Url *string `json:"url"`
	} `json:"pull_request,omitempty"`
	Pusher struct {
		Name *string `json:"name"`
	} `json:"pusher,omitempty"`
	Sender struct {
		Login *string `json:"login"`
	} `json:"sender,omitempty"`
	Repository struct {
		Name *string `json:"name"`
	} `json:"repository,omitempty"`
	Event      *string `json:"event,omitempty"`
	CompareUrl *string `json:"compare,omitempty"`
}

VCS (i.e. Github)

func (*VcsContent) String

func (c *VcsContent) String() string

Return the string version of a VcsContent

It returns the *CommentContent.Text

Jump to

Keyboard shortcuts

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