1
0
mirror of https://github.com/writeas/go-writeas.git synced 2025-07-27 23:59:44 +00:00
Go client for the Write.as API https://developers.write.as
Go to file
2019-06-10 18:10:37 -04:00
.github Add GitHub issue template 2017-11-19 14:45:03 -05:00
.gitignore Initial commit 2015-09-30 15:04:38 -04:00
auth_test.go style: Run goimports on everything 2018-12-25 09:27:00 -08:00
auth.go Rearrange status checks in LogIn 2018-09-22 22:59:12 +02:00
collection_test.go closes T589 update tests to use dev client 2019-05-28 14:52:30 -07:00
collection.go adds GetCollectionPost 2019-05-27 09:04:23 -07:00
go.mod Support Go Modules 2019-01-13 10:14:14 -06:00
go.sum Support Go Modules 2019-01-13 10:14:14 -06:00
LICENSE Add README and LICENSE 2016-09-04 21:20:28 -04:00
post_test.go closes T589 update tests to use dev client 2019-05-28 14:52:30 -07:00
post.go do not exclude ID in OwnedPostParams 2019-06-10 14:14:38 -07:00
README.md style: Run goimports on everything 2018-12-25 09:27:00 -08:00
user.go style: Run goimports on everything 2018-12-25 09:27:00 -08:00
writeas.go Set User-Agent header instead of Adding it 2019-05-26 14:39:04 -04:00

go-writeas

godoc

Official Write.as Go client library.

Installation

Warning: the v2 branch is under heavy development and its API will change without notice.

For a stable API, use go.code.as/writeas.v1 and upgrade to v2 once everything is merged into master.

go get go.code.as/writeas.v2

Documentation

See all functionality and usages in the API documentation.

Example usage

import "go.code.as/writeas.v2"

func main() {
	// Create the client
	c := writeas.NewClient()

	// Publish a post
	p, err := c.CreatePost(&writeas.PostParams{
		Title:   "Title!",
		Content: "This is a post.",
		Font:    "sans",
	})
	if err != nil {
		// Perhaps show err.Error()
	}

	// Save token for later, since it won't ever be returned again
	token := p.Token

	// Update a published post
	p, err = c.UpdatePost(p.ID, token, &writeas.PostParams{
		Content: "Now it's been updated!",
	})
	if err != nil {
		// handle
	}

	// Get a published post
	p, err = c.GetPost(p.ID)
	if err != nil {
		// handle
	}

	// Delete a post
	err = c.DeletePost(p.ID, token)
}

Contributing

The library covers our usage, but might not be comprehensive of the API. So we always welcome contributions and improvements from the community. Before sending pull requests, make sure you've done the following:

  • Run goimports on all updated .go files.
  • Document all exported structs and funcs.

License

MIT