Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
esa
 
 
 
 
 
 
 
 
 
 
 
 
 
 

go-esa

Circle CI Coverage Status GoDoc

esa API v1 client library, written in Golang

Install

go get github.com/upamune/go-esa

Usage

// Initialization
client := esa.NewClient("access_token")

// Team API
client.Team.GetTeams()
// => GET /v1/teams

client.Team.GetTeam("bar")
// => GET /v1/teams/bar

// Stats API
client.Stats.Get("bar")
// => GET /v1/teams/bar/stats

// Post API
client.Post.GetPosts("foo")
// => GET /v1/teams/foo/posts

query := url.Values{}
query.Add("in", "help")
query.Add("page", "1")
query.Add("sort", "created")
query.Add("order", "asc")
client.Post.GetPosts("foo", query)
// => GET /v1/teams/foo/posts?q=in%3Ahelp&page=1&sort=created&order=asc

client.Post.GetPost("foo", 1)
// => GET /v1/teams/foobar/posts/1

var post esa.Post
client.Post.Create("foobar", post)
// => POST /v1/teams/foobar/posts

client.Post.Update("foobar", 1, post)
// => PATCH /v1/teams/foobar/posts/1

client.Post.Delete("foobar", 1)
// => DELETE /v1/teams/foobar/posts/1

client.Post.CreateSharing("foobar", 1)
// => POST /v1/teams/foobar/posts/1/sharing

client.Post.DeleteSharing("foobar", 1)
// => DELETE /v1/teams/foobar/posts/1/sharing

// Comment API
client.Comment.GetComments("foobar", 1)
// => GET /v1/teams/foobar/posts/1/comments

client.Comment.GetComment("foobar", 123)
// => GET /v1/teams/foobar/comments/123

var comment esa.Comment
client.Comment.Create("foobar", 1, comment)
// => POST /v1/teams/foobar/posts/1/comments

client.Comment.Update("foobar", 123, comment)
// => PATCH /v1/teams/foobar/comments/123

client.Comment.Delete("foobar", 123)
// => DELETE /v1/teams/foobar/comments/123

// Members API
client.Members.Get("foo")
// => GET /v1/teams/foo/members