esa

package
v0.0.0-...-a41514d Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2017 License: MIT Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoolP

func BoolP(v bool) *bool

func IntP

func IntP(v int) *int

func StrP

func StrP(v string) *string

func UintP

func UintP(v uint) *uint

Types

type BaseOption

type BaseOption func(*baseOptions)

BaseOption overwrite base requrest params

func WithHTTPClient

func WithHTTPClient(httpClient *http.Client) BaseOption

WithHTTPClient apply overwrite httpClient

func WithUserAgent

func WithUserAgent(userAgent string) BaseOption

WithUserAgent apply overwrite userAgent

type BatchMoveParam

type BatchMoveParam struct {
	From string `json:"from"`
	To   string `json:"to"`
}

BatchMoveParam is param for batch move

type BatchMoveResult

type BatchMoveResult struct {
	Count uint   `json:"count"`
	From  string `json:"from"`
	To    string `json:"to"`
}

BatchMoveResult is result for batch move

type Client

type Client interface {
	SetTeam(teamName string)
	SetAccessToken(accessToken string)
	AppendOption(options ...BaseOption)
	SetOption(options ...BaseOption)
	ClearOptions()
	// like url.URL{Scheme: "http", Host: "localhost"}
	OverwriteBaseURL(u url.URL)

	ListTeams(ctx context.Context, page uint, perPage uint) (*TeamsResp, error)
	GetTeam(ctx context.Context) (*Team, error)
	GetTeamStats(ctx context.Context) (*TeamStats, error)

	ListMembers(ctx context.Context, page uint, perPage uint) (*MembersResp, error)

	ListPosts(ctx context.Context, param ListPostsParam, page uint, perPage uint) (*PostsResp, error)
	GetPost(ctx context.Context, number uint) (*Post, error)
	CreatePost(ctx context.Context, param CreatePostParam) (*Post, error)
	UpdatePost(ctx context.Context, number uint, param UpdatePostParam) (*UpdatedPost, error)
	DeletePost(ctx context.Context, number uint) error

	ListComments(ctx context.Context, postNumber uint, page uint, perPage uint) (*CommentsResp, error)
	GetComment(ctx context.Context, id uint) (*Comment, error)
	CreateComment(ctx context.Context, postNumber uint, param CreateCommentParam) (*Comment, error)
	UpdateComment(ctx context.Context, id uint, param UpdateCommentParam) (*Comment, error)
	DeleteComment(ctx context.Context, id uint) error

	ListPostStargazers(ctx context.Context, postNumber uint, page uint, perPage uint) (*StargazersResp, error)
	StarPost(ctx context.Context, postNumber uint, param StarParam) error
	UnstarPost(ctx context.Context, postNumber uint) error

	ListCommentStargazers(ctx context.Context, commentID uint, page uint, perPage uint) (*StargazersResp, error)
	StarComment(ctx context.Context, commentID uint, param StarParam) error
	UnstarComment(ctx context.Context, commentID uint) error

	ListPostWatchers(ctx context.Context, postNumber uint, page uint, perPage uint) (*WatchersResp, error)
	WatchPost(ctx context.Context, postNumber uint) error
	UnwatchPost(ctx context.Context, postNumber uint) error

	ChangeCategory(ctx context.Context, from string, to string) (*BatchMoveResult, error)

	GetInvitationURL(ctx context.Context) (*URLResp, error)
	RegenerateInvitationURL(ctx context.Context) (*URLResp, error)
	InviteByEmail(ctx context.Context, emails ...string) (*InvitationByEmailResp, error)
	ListInvitations(ctx context.Context, page uint, perPage uint) (*InvitationsResp, error)
	DeleteInvitation(ctx context.Context, code string) error

	ListEmojis(ctx context.Context, param ListEmojisParam, page uint, perPage uint) (*EmojisResp, error)
	CreateEmoji(ctx context.Context, param CreateEmojiParam) (*Emoji, error)
	DeleteEmoji(ctx context.Context, code string) error

	GetUser(ctx context.Context, param GetUserParam) (*User, error)
}

Client is interface for esa

func NewClient

func NewClient(accessToken string, teamName string, options ...BaseOption) Client

NewClient initialize Client

type ClientImpl

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

ClientImpl is implementation of Client

func (*ClientImpl) AppendOption

func (c *ClientImpl) AppendOption(options ...BaseOption)

AppendOption append option

func (ClientImpl) ChangeCategory

func (c ClientImpl) ChangeCategory(ctx context.Context, from string, to string) (*BatchMoveResult, error)

ChangeCategory change category

func (*ClientImpl) ClearOptions

func (c *ClientImpl) ClearOptions()

ClearOptions clear options

func (ClientImpl) CreateComment

func (c ClientImpl) CreateComment(ctx context.Context, postNumber uint, param CreateCommentParam) (*Comment, error)

CreateComment create comment

func (ClientImpl) CreateEmoji

func (c ClientImpl) CreateEmoji(ctx context.Context, param CreateEmojiParam) (*Emoji, error)

CreateEmoji create emoji

func (ClientImpl) CreatePost

func (c ClientImpl) CreatePost(ctx context.Context, param CreatePostParam) (*Post, error)

CreatePost create post

func (ClientImpl) DeleteComment

func (c ClientImpl) DeleteComment(ctx context.Context, id uint) error

DeleteComment delete comment

func (ClientImpl) DeleteEmoji

func (c ClientImpl) DeleteEmoji(ctx context.Context, code string) error

DeleteEmoji delete emoji

func (ClientImpl) DeleteInvitation

func (c ClientImpl) DeleteInvitation(ctx context.Context, code string) error

DeleteInvitation delete invitation

func (ClientImpl) DeletePost

func (c ClientImpl) DeletePost(ctx context.Context, number uint) error

DeletePost delete post

func (ClientImpl) GetComment

func (c ClientImpl) GetComment(ctx context.Context, id uint) (*Comment, error)

GetComment get comment

func (ClientImpl) GetInvitationURL

func (c ClientImpl) GetInvitationURL(ctx context.Context) (*URLResp, error)

GetInvitationURL get invitationURL

func (ClientImpl) GetPost

func (c ClientImpl) GetPost(ctx context.Context, number uint) (*Post, error)

GetPost get post

func (ClientImpl) GetTeam

func (c ClientImpl) GetTeam(ctx context.Context) (*Team, error)

GetTeam get team

func (ClientImpl) GetTeamStats

func (c ClientImpl) GetTeamStats(ctx context.Context) (*TeamStats, error)

GetTeamStats get teamStats

func (ClientImpl) GetUser

func (c ClientImpl) GetUser(ctx context.Context, param GetUserParam) (*User, error)

GetUser get user

func (ClientImpl) InviteByEmail

func (c ClientImpl) InviteByEmail(ctx context.Context, emails ...string) (*InvitationByEmailResp, error)

InviteByEmail invite byEmail

func (ClientImpl) ListCommentStargazers

func (c ClientImpl) ListCommentStargazers(ctx context.Context, commentID uint, page uint, perPage uint) (*StargazersResp, error)

ListCommentStargazers list commentStargazers

func (ClientImpl) ListComments

func (c ClientImpl) ListComments(ctx context.Context, postNumber uint, page uint, perPage uint) (*CommentsResp, error)

ListComments list comments

func (ClientImpl) ListEmojis

func (c ClientImpl) ListEmojis(ctx context.Context, param ListEmojisParam, page uint, perPage uint) (*EmojisResp, error)

ListEmojis list emojis

func (ClientImpl) ListInvitations

func (c ClientImpl) ListInvitations(ctx context.Context, page uint, perPage uint) (*InvitationsResp, error)

ListInvitations list invitations

func (ClientImpl) ListMembers

func (c ClientImpl) ListMembers(ctx context.Context, page uint, perPage uint) (*MembersResp, error)

ListMembers list members

func (ClientImpl) ListPostStargazers

func (c ClientImpl) ListPostStargazers(ctx context.Context, postNumber uint, page uint, perPage uint) (*StargazersResp, error)

ListPostStargazers list postStargazers

func (ClientImpl) ListPostWatchers

func (c ClientImpl) ListPostWatchers(ctx context.Context, postNumber uint, page uint, perPage uint) (*WatchersResp, error)

ListPostWatchers list postWatchers

func (ClientImpl) ListPosts

func (c ClientImpl) ListPosts(ctx context.Context, param ListPostsParam, page uint, perPage uint) (*PostsResp, error)

ListPosts list posts

func (ClientImpl) ListTeams

func (c ClientImpl) ListTeams(ctx context.Context, page uint, perPage uint) (*TeamsResp, error)

ListTeams list teams

func (*ClientImpl) OverwriteBaseURL

func (c *ClientImpl) OverwriteBaseURL(u url.URL)

OverwriteBaseURL overwrite baseURL

func (ClientImpl) RegenerateInvitationURL

func (c ClientImpl) RegenerateInvitationURL(ctx context.Context) (*URLResp, error)

RegenerateInvitationURL regenerate invitationURL

func (*ClientImpl) SetAccessToken

func (c *ClientImpl) SetAccessToken(accessToken string)

SetAccessToken set accessToken

func (*ClientImpl) SetOption

func (c *ClientImpl) SetOption(options ...BaseOption)

SetOption set option

func (*ClientImpl) SetTeam

func (c *ClientImpl) SetTeam(teamName string)

SetTeam set team

func (ClientImpl) StarComment

func (c ClientImpl) StarComment(ctx context.Context, commentID uint, param StarParam) error

StarComment star comment

func (ClientImpl) StarPost

func (c ClientImpl) StarPost(ctx context.Context, postNumber uint, param StarParam) error

StarPost star post

func (ClientImpl) UnstarComment

func (c ClientImpl) UnstarComment(ctx context.Context, commentID uint) error

UnstarComment unstar comment

func (ClientImpl) UnstarPost

func (c ClientImpl) UnstarPost(ctx context.Context, postNumber uint) error

UnstarPost unstar post

func (ClientImpl) UnwatchPost

func (c ClientImpl) UnwatchPost(ctx context.Context, postNumber uint) error

UnwatchPost unwatch post

func (ClientImpl) UpdateComment

func (c ClientImpl) UpdateComment(ctx context.Context, id uint, param UpdateCommentParam) (*Comment, error)

UpdateComment update comment

func (ClientImpl) UpdatePost

func (c ClientImpl) UpdatePost(ctx context.Context, number uint, param UpdatePostParam) (*UpdatedPost, error)

UpdatePost update post

func (ClientImpl) WatchPost

func (c ClientImpl) WatchPost(ctx context.Context, postNumber uint) error

WatchPost watch post

type Comment

type Comment struct {
	ID              uint      `json:"id"`
	BodyMd          string    `json:"body_md"`
	BodyHTML        string    `json:"body_html"`
	CreatedAt       time.Time `json:"created_at"`
	UpdatedAt       time.Time `json:"updated_at"`
	URL             string    `json:"url"`
	CreatedBy       Member    `json:"created_by"`
	StargazersCount uint      `json:"stargazers_count"`
	Star            bool      `json:"star"`
}

Comment is struct for comment

type CommentsResp

type CommentsResp struct {
	PageResp
	Comments []Comment `json:"comments"`
}

CommentsResp is resp for comments

type CreateCommentParam

type CreateCommentParam struct {
	BodyMD string  `json:"body_md"`
	User   *string `json:"user,omitempty"`
}

CreateCommentParam is param for create comment

type CreateEmojiParam

type CreateEmojiParam struct {
	Code string `json:"code"`
	// For alias
	OriginCode string `json:"origin_code,omitempty"`
	// BASE64 String
	Image string `json:"image,omitempty"`
}

CreateEmojiParam is param for create emoji

type CreatePostParam

type CreatePostParam struct {
	Name     string    `json:"name"`
	BodyMD   *string   `json:"body_md,omitempty"`
	Tags     *[]string `json:"tags,omitempty"`
	Category *string   `json:"category,omitempty"`
	WIP      *bool     `json:"wip,omitempty"`
	Message  *string   `json:"message,omitempty"`
	User     *string   `json:"user,omitempty"`
}

CreatePostParam is param for create post

type Emoji

type Emoji struct {
	Code    string   `json:"code"`
	Aliases []string `json:"aliases,omitempty"`
	URL     string   `json:"url,omitempty"`
}

Emoji is struct for emoji

type EmojisResp

type EmojisResp struct {
	PageResp
	Emojis []Emoji `json:"emojis"`
}

EmojisResp is resp for emojis

type Error

type Error struct {
	StatusCode int
	Err        string `json:"error"`
	Message    string `json:"message"`
}

Error is struct for esa error

func (Error) Error

func (e Error) Error() string

Error output error message

func (Error) HTTPStatusCode

func (e Error) HTTPStatusCode() int

type GetUserParam

type GetUserParam struct {
	Include []GetUserParamInclude `url:"include,comma"`
}

GetUserParam is param for get user

type GetUserParamInclude

type GetUserParamInclude string

GetUserParamInclude is enum for post param "include"

const (
	// GetUserParamIncludeTeams is enum for post param "include"
	GetUserParamIncludeTeams GetUserParamInclude = "teams"
)

type Invitation

type Invitation struct {
	Email     string    `json:"email"`
	Code      string    `json:"code"`
	ExpiresAt time.Time `json:"expires_at"`
	URL       string    `json:"url"`
}

Invitation is struct for inivitaion

type InvitationByEmailParam

type InvitationByEmailParam struct {
	Member struct {
		Emails []string `json:"emails"`
	} `json:"member"`
}

InvitationByEmailParam is param for invitation by email

type InvitationByEmailResp

type InvitationByEmailResp struct {
	Invitations []Invitation `json:"invitations"`
}

InvitationByEmailResp is resp for invitation by email

type InvitationsResp

type InvitationsResp struct {
	PageResp
	Invitations []Invitation `json:"invitations"`
}

InvitationsResp is resp for invitations

type ListEmojisParam

type ListEmojisParam struct {
	Include []ListEmojisParamInclude `url:"include,comma"`
}

ListEmojisParam is param for fetch user

type ListEmojisParamInclude

type ListEmojisParamInclude string

ListEmojisParamInclude is enum for post param "include"

const (
	// ListEmojisParamIncludeAll is enum for post param "include"
	ListEmojisParamIncludeAll ListEmojisParamInclude = "all"
)

type ListPostsParam

type ListPostsParam struct {
	Q       string                  `url:"q,omitempty"`
	Include []ListPostsParamInclude `url:"include,omitempty,comma"`
	Sort    ListPostsParamSort      `url:"sort,omitempty"`
	Order   Order                   `url:"order,omitempty"`
}

ListPostsParam is param for list posts

type ListPostsParamInclude

type ListPostsParamInclude string

ListPostsParamInclude is enum for post param "include"

const (
	// ListPostsParamIncludeComments is enum for post param "include"
	ListPostsParamIncludeComments ListPostsParamInclude = "comments"
	// ListPostsParamIncludeCommentsStargazers is enum for post param "include"
	ListPostsParamIncludeCommentsStargazers ListPostsParamInclude = "comments.stargazers"
	// ListPostsParamIncludeStargazers is enum for post param "include"
	ListPostsParamIncludeStargazers ListPostsParamInclude = "stargazers"
)

type ListPostsParamSort

type ListPostsParamSort string

ListPostsParamSort is enum for post param "sort"

const (
	// ListPostsParamSortUpdated is enum for post param "sort"
	ListPostsParamSortUpdated ListPostsParamSort = "updated"
	// ListPostsParamSortCreated is enum for post param "sort"
	ListPostsParamSortCreated ListPostsParamSort = "created"
	// ListPostsParamSortStars is enum for post param "sort"
	ListPostsParamSortStars ListPostsParamSort = "stars"
	// ListPostsParamSortWatches is enum for post param "sort"
	ListPostsParamSortWatches ListPostsParamSort = "watches"
	// ListPostsParamSortComments is enum for post param "sort"
	ListPostsParamSortComments ListPostsParamSort = "comments"
	// ListPostsParamSortBestMatch is enum for post param "sort"
	ListPostsParamSortBestMatch ListPostsParamSort = "best_match"
)

type Member

type Member struct {
	Name       string `json:"name,omitempty"`
	ScreenName string `json:"screen_name,omitempty"`
	Icon       string `json:"icon,omitempty"`
	Email      string `json:"email,omitempty"`
	PostsCount int64  `json:"posts_count,omitempty"`
}

Member is struct for member

type MembersResp

type MembersResp struct {
	PageResp
	Members []Member `json:"members"`
}

MembersResp is resp for members

type Order

type Order string

Order is enum for order

const (
	// DESC is enum for order
	DESC Order = "desc"
	// ASC is enum for order
	ASC Order = "asc"
)

type OriginalRevision

type OriginalRevision struct {
	BodyMD string `json:"body_md"`
	Number uint   `json:"number"`
	User   string `json:"user"`
}

OriginalRevision is subparam for update post

type PageResp

type PageResp struct {
	PrevPage   *uint `json:"prev_page"`
	NextPage   *uint `json:"next_page"`
	TotalCount uint  `json:"total_count"`
	Page       uint  `json:"page"`
	PerPage    uint  `json:"per_page"`
	MaxPerPage uint  `json:"max_per_page"`
}

PageResp is resp for pager

type Post

type Post struct {
	Name            string    `json:"name"`
	Number          uint      `json:"number"`
	Tags            []string  `json:"tags"`
	Category        string    `json:"category"`
	FullName        string    `json:"full_name"`
	WIP             bool      `json:"wip"`
	BodyMD          string    `json:"body_md"`
	BodyHTML        string    `json:"body_html"`
	CreatedAt       time.Time `json:"created_at"`
	UpdatedAt       time.Time `json:"updated_at"`
	Message         string    `json:"message"`
	RevisionNumber  int64     `json:"revision_number"`
	CreatedBy       Member    `json:"created_by"`
	UpdatedBy       Member    `json:"updated_by"`
	Kind            PostKind  `json:"kind,omitempty"`
	URL             string    `json:"url"`
	CommentsCount   *uint     `json:"comments_count,omitempty"`
	TasksCount      *uint     `json:"tasks_count,omitempty"`
	DoneTasksCount  *uint     `json:"done_tasks_count,omitempty"`
	StargazersCount *uint     `json:"stargazers_count,omitempty"`
	WatchersCount   *uint     `json:"watchers_count,omitempty"`
	Star            *bool     `json:"star,omitempty"`
	Watch           *bool     `json:"watch,omitempty"`
}

Post is struct for post

type PostKind

type PostKind string

PostKind is enum for post kind

const (
	// PostKindStock is enum for post kind
	PostKindStock PostKind = "stock"
	// PostKindFlow is enum for post kind
	PostKindFlow PostKind = "flow"
)

type PostsResp

type PostsResp struct {
	PageResp
	Posts []Post `json:"posts"`
}

PostsResp is resp for posts

type Privacy

type Privacy string

Privacy is enum for team privacy

const (
	// PrivacyClosed is enum for team privacy
	PrivacyClosed Privacy = "closed"
	// PrivacyOpen is enum for team privacy
	PrivacyOpen Privacy = "open"
)

type StarParam

type StarParam struct {
	Body *string `json:"body"`
}

StarParam is param for create star

type Stargazer

type Stargazer struct {
	CreatedAt time.Time `json:"created_at"`
	Body      *string   `json:"body"`
	User      Member    `json:"user"`
}

Stargazer is struct for stargazer

type StargazersResp

type StargazersResp struct {
	PageResp
	Stargazers []Stargazer `json:"stargazers"`
}

StargazersResp is resp for stargazers

type Team

type Team struct {
	Name        string  `json:"name"`
	Privacy     Privacy `json:"privacy"`
	Description string  `json:"description"`
	Icon        string  `json:"icon"`
	URL         string  `json:"url"`
}

Team is struct for team

type TeamStats

type TeamStats struct {
	Members            uint `json:"members"`
	Posts              uint `json:"posts"`
	PostsWIP           uint `json:"posts_wip"`
	PostsShipped       uint `json:"posts_shipped"`
	Comments           uint `json:"comments"`
	Stars              uint `json:"stars"`
	DailyActiveUsers   uint `json:"daily_active_users"`
	WeeklyActiveUsers  uint `json:"weekly_active_users"`
	MonthlyActiveUsers uint `json:"monthly_active_users"`
}

TeamStats is struct for team status

type TeamsResp

type TeamsResp struct {
	PageResp
	Teams []Team `json:"teams"`
}

TeamsResp is resp for teams

type URLResp

type URLResp struct {
	URL string `json:"url"`
}

URLResp is struct for wrap url

type UpdateCommentParam

type UpdateCommentParam struct {
	BodyMD *string `json:"body_md"`
	User   *string `json:"user,omitempty"`
}

UpdateCommentParam is param for update comment

type UpdatePostParam

type UpdatePostParam struct {
	Name             *string           `json:"name,omitempty"`
	BodyMD           *string           `json:"body_md,omitempty"`
	Tags             *[]string         `json:"tags,omitempty"`
	Category         *string           `json:"category,omitempty"`
	WIP              *bool             `json:"wip,omitempty"`
	Message          *string           `json:"message,omitempty"`
	CreatedBy        *string           `json:"created_by,omitempty"`
	UpdatedBy        *string           `json:"updated_by,omitempty"`
	OriginalRevision *OriginalRevision `json:"original_revision,omitempty"`
}

UpdatePostParam is param for update post

type UpdatedPost

type UpdatedPost struct {
	Post
	Overlapped bool `json:"overlapped"`
}

UpdatedPost is struct for post

type User

type User struct {
	ID         uint      `json:"id"`
	Name       string    `json:"name"`
	ScreenName string    `json:"screen_name"`
	CreatedAt  time.Time `json:"created_at"`
	UpdatedAt  time.Time `json:"updated_at"`
	Icon       string    `json:"icon"`
	Email      string    `json:"email"`
}

User is struct for user

type Watcher

type Watcher struct {
	CreatedAt time.Time `json:"created_at"`
	User      Member    `json:"user"`
}

Watcher is struct for watcher

type WatchersResp

type WatchersResp struct {
	PageResp
	Watchers []Watcher `json:"watchers"`
}

WatchersResp is resp for watchers

Jump to

Keyboard shortcuts

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