Documentation ¶
Index ¶
- Constants
- func NewRepository(c *Client, dataDir string) rmtool.Repository
- type Client
- func (c *Client) Bookmark(id string, mark bool) error
- func (c *Client) CreateFolder(parentID, name string) error
- func (c *Client) Delete(id string) error
- func (c *Client) Fetch(id string, w io.Writer) (Item, error)
- func (c *Client) IsRegistered() bool
- func (c *Client) List() ([]Item, error)
- func (c *Client) Move(id, parentID string) error
- func (c *Client) NewNotifications() (*Notifications, error)
- func (c *Client) Register(code string) (string, error)
- func (c *Client) Rename(id, name string) error
- func (c *Client) Upload(name, id, parentID string, src io.Reader) error
- type DateTime
- type Event
- type Item
- type Message
- type MessageHandler
- type Notifications
Constants ¶
const ( AuthURL = "https://my.remarkable.com" StorageDiscoveryURL = "" /* 175-byte string literal not displayed */ NotificationsDiscoveryURL = "" /* 172-byte string literal not displayed */ )
Default URLs
Variables ¶
This section is empty.
Functions ¶
func NewRepository ¶
func NewRepository(c *Client, dataDir string) rmtool.Repository
NewRepository creates a Repository with the reMarkable cloud service as backend.
The supplied dataDir is used to cache downloaded content.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents the ReST API for the reMarkable cloud service.
func DefaultClient ¶
DefaultClient sets up an API client with default URLs. See NewClient for details.
func NewClient ¶
NewClient sets up an API client with the given base URLs.
The *three* URLs are the base URLs for the various services.
Device token is the authentication token obtained from the API. This is intended for setting up a client when the registration has already been completed and a token can be loaded from storage. If set to the empty string, Register can be used to obtain a token.
Refer to DefaultClient for a more simple constructor.
func (*Client) CreateFolder ¶
CreateFolder creates a new folder under the given parent folder. The parentID can be empty (root folder) or refer to another folder.
func (*Client) Fetch ¶
Fetch retrieves a single item from the service and writes the item's blob data to the given writer.
The caller is responsible for closing the writer.
func (*Client) IsRegistered ¶
IsRegistered tells if this client thinks it is registered. This merely looks if a device token is present; that token might still be invalid.
func (*Client) List ¶
List retrieves the full list of items (notebooks and folders) from the service.
func (*Client) Move ¶
Move transfers the documents with the given id to a destination folder. The parentID can be empty (root folder) or refer to another folder.
func (*Client) NewNotifications ¶
func (c *Client) NewNotifications() (*Notifications, error)
NewNotifications sets up a client for the notifications service.
This method will retrieve the hostname for the notification service from the discovery URL. If necessary, this method will also fetch a fresh authentication token for the notification service.
func (*Client) Register ¶
Register registers a new device with the remarkable service. It sends a one-time code from my.remarkable.com/connect/desktop and retrieves a "device token" which can later be used to authenticate.
Returns the device token.
type DateTime ¶
DateTime is the type used to serialize a Time instance to a date string and vice versa. Used when converting an Item to and from JSON.
func (DateTime) MarshalJSON ¶
MarshalJSON marsahls a DateTime to JSON.
func (*DateTime) UnmarshalJSON ¶
UnmarshalJSON unmarshales a DateTime from JSON. The JSON date is expected to be a string in format "yyyy-mm-ddThh:mm:ss.sss".
type Event ¶
type Event int
Event is the type for event types used in notification messages.
func (Event) MarshalJSON ¶
MarshalJSON marshals an Event to a JSON string value.
func (*Event) UnmarshalJSON ¶
UnmarshalJSON unmarshals an Event from a JSON string value.
type Item ¶
type Item struct { // ID is the UUID for this item. ID string // Version is incremented with each update. Version int // Type describes the type of item (Notebook or Folder). Type rmtool.NotebookType // VisibleName is the display name for an item. VisibleName string `json:"VissibleName"` // CurrentPage is the last opened page from a notebook, CurrentPage int // Bookmarked tells if this item is "pinned". Bookmarked bool // Parent is the id of the parent item. // It can be the empty string if the item is contained in the root folder. // The special value "trash" is used for deleted items. Parent string // Success is set to false if this item is sent by the server as a response // to a request. Success bool // Message should contain the error message if Success is false. Message string // BlobURLGet is the download URL for the zipped content. BlobURLGet string // BlobURLGetExpires describes how long the download URL remains valid. BlobURLGetExpires DateTime // BlobURLPut is the upload URL for zipped content. BlobURLPut string // BlobURLGetExpires describes how long the upload URL remains valid. BlobURLPutExpires DateTime // ModifiedClient is the last modification date for this item. // It is set automatically when the Client is used to change items- ModifiedClient DateTime }
Item holds the data for a single metadata entry from the API. The Item struct is also used by the service to send the response.
type Message ¶
type Message struct { MessageID string PublishTime time.Time SourceDesc string SourceID string Event Event ItemID string Parent string Type rmtool.NotebookType Bookmarked bool Version int VisibleName string }
Message contains the data from a notification message, slightly simplified.
type MessageHandler ¶
type MessageHandler func(Message)
A MessageHandler can be registered with the notifications client to receive incoming messages.
type Notifications ¶
type Notifications struct {
// contains filtered or unexported fields
}
Notifications is the client for the notification service.
It connects to the websocket service, parses messages from JSON and forwards them to a registered message handler.
func (*Notifications) Connect ¶
func (n *Notifications) Connect() error
Connect creates a new websocket connection to the notification service.
After a connection is made, the notifications client starts to receive messages and dispatches them to the MessageHandler registered via OnMessage.
Calling Connect while the client is already connected leads to a reconnect.
func (*Notifications) Disconnect ¶
func (n *Notifications) Disconnect()
Disconnect closes the connection with the notification server. Calling Disconnect while the client is already disconnected has no effect.
func (*Notifications) OnMessage ¶
func (n *Notifications) OnMessage(f MessageHandler)
OnMessage registers a handler function for received messages.
Setting a handler removes the current one; setting the handler to `nil` is allowed to remove the current handler.
The handler function will be called in a separate goroutine for each message.