|
|
@@ -1,13 +1,13 @@ |
|
|
|
# go-writeas |
|
|
|
|
|
|
|
[![godoc](https://godoc.org/github.com/writeas/go-writeas?status.svg)](https://godoc.org/github.com/writeas/go-writeas) |
|
|
|
[![godoc](https://godoc.org/go.code.as/writeas.v1?status.svg)](https://godoc.org/go.code.as/writeas.v1) |
|
|
|
|
|
|
|
Official Write.as Go client library. |
|
|
|
|
|
|
|
## Installation |
|
|
|
|
|
|
|
```bash |
|
|
|
go get github.com/writeas/go-writeas |
|
|
|
go get go.code.as/writeas.v1 |
|
|
|
``` |
|
|
|
|
|
|
|
## Documentation |
|
|
@@ -17,14 +17,14 @@ See all functionality and usages in the [API documentation](https://developer.wr |
|
|
|
### Example usage |
|
|
|
|
|
|
|
```go |
|
|
|
import "github.com/writeas/go-writeas" |
|
|
|
import "go.code.as/writeas.v1" |
|
|
|
|
|
|
|
func main() { |
|
|
|
// Create the client |
|
|
|
c := writeas.NewClient() |
|
|
|
|
|
|
|
// Publish a post |
|
|
|
p, err := c.CreatePost(&PostParams{ |
|
|
|
p, err := c.CreatePost(&writeas.PostParams{ |
|
|
|
Title: "Title!", |
|
|
|
Content: "This is a post.", |
|
|
|
Font: "sans", |
|
|
@@ -37,9 +37,11 @@ func main() { |
|
|
|
token := p.Token |
|
|
|
|
|
|
|
// Update a published post |
|
|
|
p, err = c.UpdatePost(&PostParams{ |
|
|
|
ID: p.ID, |
|
|
|
Token: token, |
|
|
|
p, err = c.UpdatePost(&writeas.PostParams{ |
|
|
|
OwnedPostParams: writeas.OwnedPostParams{ |
|
|
|
ID: p.ID, |
|
|
|
Token: token, |
|
|
|
}, |
|
|
|
Content: "Now it's been updated!", |
|
|
|
}) |
|
|
|
if err != nil { |
|
|
@@ -53,9 +55,11 @@ func main() { |
|
|
|
} |
|
|
|
|
|
|
|
// Delete a post |
|
|
|
err = c.DeletePost(&PostParams{ |
|
|
|
ID: p.ID, |
|
|
|
Token: token, |
|
|
|
err = c.DeletePost(&writeas.PostParams{ |
|
|
|
OwnedPostParams: writeas.OwnedPostParams{ |
|
|
|
ID: p.ID, |
|
|
|
Token: token, |
|
|
|
}, |
|
|
|
}) |
|
|
|
} |
|
|
|
``` |
|
|
|