A dependency-free cilent for the Dropbox Paper API
Go
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
LICENSE
README.md
paper.go

README.md

paper

A dependency-free client for the Dropbox Paper API.

Installation

Use the paper package via dep.

dep ensure -add github.com/kyleconroy/paper

Status

This client is ready to use, but only a subset of the API methods have been implemented.

Usage

package main

import (
	"log"

	"github.com/kyleconroy/paper"
)

func PaperSync(names string) error {
	client := paper.NewClient(os.Getenv("DROPBOX_API_KEY"))
	ctx := context.Background()

	list, err := client.ListDocs(ctx, &paper.ListPaperDocsArgs{Limit: 100})
	if err != nil {
		panic(err)
	}

	for _, doc := range list.DocIDs {
		folder, err := client.GetDocFolderInfo(ctx, &paper.RefPaperDoc{DocID: doc})
		if err != nil {
			panic(err)
		}
		if len(folder.Folders) > 0 {
			log.Printf("Document %s is inside folder %s", doc, folder.Folders[0].Name)
		}
		download, content, err := client.DownloadDoc(ctx, &paper.PaperDocExport{
			DocID: doc,
			Format: paper.ExportFormatMarkdown,
		})
		if err != nil {
			panic(err)
		}
		log.Println(download.Title)
		log.Println(string(content))
	}
}