rmapi

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 27, 2020 License: BSD-3-Clause Imports: 15 Imported by: 3

Documentation

Overview

Package rmapi implements reMarkable api, as described in https://github.com/splitbrain/ReMarkableAPI/wiki.

Index

Constants

This section is empty.

Variables

View Source
var RootDisplayName = "<ROOT>"

RootDisplayName is the display name to be used by the root directory.

Functions

This section is empty.

Types

type Client

type Client struct {
	RefreshToken string

	Logger logger.Logger
	// contains filtered or unexported fields
}

Client defines a reMarkable API client.

You can get it either by using Register with a new token, or construct directly from refresh token stored previously.

func Register

func Register(ctx context.Context, args RegisterArgs) (*Client, error)

Register registers a new token with reMarkable API server.

Upon success, it returns a *Client with RefreshToken set.

func (*Client) AutoRefresh

func (c *Client) AutoRefresh(ctx context.Context) error

AutoRefresh refreshes the token when needed.

func (*Client) ListDirs

func (c *Client) ListDirs(ctx context.Context) (map[string]string, error)

ListDirs lists all the directories user created on their reMarkable account.

The returned map is in format of <id> -> <display name>. When error is nil, the map is guaranteed to have at least an entry of "" -> RootDisplayName.

func (*Client) Refresh

func (c *Client) Refresh(ctx context.Context) error

Refresh refreshes the token.

func (*Client) Upload

func (c *Client) Upload(ctx context.Context, args UploadArgs) error

Upload uploads a document to reMarkable.

type ContentArgs

type ContentArgs struct {
	Font string
}

ContentArgs defines the args to population InitialContent.

type FileType

type FileType int

FileType is an enum type defining the file type on reMarkable.

It's either epub or pdf.

const (
	FileTypeEpub FileType
	FileTypePdf
)

FileType values.

func (FileType) Ext

func (ft FileType) Ext() string

Ext returns the file extension of the given FileType.

func (FileType) InitialContent

func (ft FileType) InitialContent(args ContentArgs) (string, error)

InitialContent returns the initial .content file for the given FileType.

type ItemInfo

type ItemInfo struct {
	ID        string `json:"ID,omitempty"`
	Type      string `json:"Type,omitempty"`
	Name      string `json:"VissibleName,omitempty"`
	Parent    string `json:"Parent,omitempty"`
	Version   int    `json:"Version,omitempty"`
	UploadURL string `json:"BlobURLPut,omitempty"`

	// responses only
	Message string `json:"Message,omitempty"`
	Success *bool  `json:"Success,omitempty"`
}

ItemInfo defines the json format of an item metadata.

Some of the fields are only used in requests and some of the fields are only used in responses, as a result it's important for all of them to have omitempty json tag.

func (ItemInfo) IsSuccess

func (i ItemInfo) IsSuccess() error

IsSuccess checks the Success field

func (ItemInfo) ToMetadata

func (i ItemInfo) ToMetadata() ItemMetadata

ToMetadata converts ItemInfo into ItemMetadata

type ItemMetadata

type ItemMetadata struct {
	Type    string `json:"type"`
	Name    string `json:"visibleName"`
	Parent  string `json:"parent"`
	Version int    `json:"version"`
}

ItemMetadata defines the json format for the .metadata files.

type RegisterArgs

type RegisterArgs struct {
	// A token got from either https://my.remarkable.com/connect/desktop or
	// https://my.remarkable.com/connect/mobile, usually with length of 8.
	Token string

	// A description of this device, usually something like "desktop-linux",
	// "mobile-android".
	Description string
}

RegisterArgs defines args to be used with Register.

type UploadArgs

type UploadArgs struct {
	ID    string
	Title string

	Data io.Reader
	Type FileType

	// Optional
	ParentID    string
	ContentArgs ContentArgs
}

UploadArgs defines the args used by Upload function.

Directories

Path Synopsis
debug module

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL