Go client library for the Sendowl API.
Note: implementation is incomplete. Please submit a PR for improvements.
For full documentation see: https://godoc.org/github.com/jonathaningram/sendowl.
go get github.com/jonathaningram/sendowl
package main
import (
"log"
"os"
"golang.org/x/net/context"
"github.com/jonathaningram/sendowl"
)
func main() {
key := "sendowl-key"
secret := "sendowl-secret"
client := sendowl.New(*key, *secret)
ctx := context.Background()
filename := "file.pdf"
name := filename
t := sendowl.Digital
price := 9.99
f, err := os.Open(filename)
if err != nil {
log.Fatal(err)
}
defer f.Close()
resp, err := client.CreateProduct(ctx, sendowl.CreateProductRequest{
Name: name,
Price: sendowl.PriceFromFloat64(price),
Type: t,
Attachment: f,
Filename: filename,
})
if err != nil {
log.Fatal(err)
}
log.Printf("%#v", resp)
}
To log Sendowl API requests, use WithLogger
:
client := sendowl.New(...).WithLogger(log.New(os.Stderr, "", log.LstdFlags))