-
Notifications
You must be signed in to change notification settings - Fork 0
/
reorg.el
88 lines (64 loc) · 2.67 KB
/
reorg.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
;;; reorg.el --- reorg is a bridge between emacs(org-mode) and the remarkable cloudy -*- lexical-binding: t -*-
;; Author: Daniel Rosel
;; Maintainer: Daniel Rosel
;; Version: 0.1.0
;; Package-Requires: (emacs-request)
;; Homepage: homepage
;; Keywords: remarkable org-mode cloud emacs
;; This file is not part of GNU Emacs
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; commentary
;;; Code:
(require 'request)
(defvar reorg-device-code nil)
(defvar reorg-bearer-token nil)
(defvar reorg-storage-api "document-storage-production-dot-remarkable-production.appspot.com")
(defun reorg/register-device ()
(interactive)
(browse-url-firefox "https://my.remarkable.com/#desktop") ; FIX this is not great
(setq reorg-device-code (read-string "Enter one-time code: "))
)
(defun reorg/connect-device ()
(interactive)
;; TODO make into let
(setq reorg-connection-url "https://webapp-production-dot-remarkable-production.appspot.com/token/json/2/device/new"
reorg-connection-payload-string (concat
"{\"code\": \"" reorg-device-code "\",
\"deviceDesc\": \"desktop-windows\",
\"deviceID\": \"" (uuidgen-4) "\"}"))
(request reorg-connection-url
:type "POST"
:data reorg-connection-payload-string
:parser 'buffer-string
:success (cl-function
(lambda (&key data &allow-other-keys)
(message "I got: %S" data)
(setq reorg-bearer-token data)))
:error
(cl-function (lambda (&rest args &key error-thrown &allow-other-keys)
(message "Got error: %S" error-thrown)))
)
)
(request "https://document-storage-production-dot-remarkable-production.appspot.com/document-storage/json/2/docs"
:type "POST"
:data (concat "Authorization=\"Bearer " reorg-bearer-token "\"")
:parser 'buffer-string
:success (cl-function
(lambda (&key data &allow-other-keys)
(message "I got: %S" data)))
:error
(cl-function (lambda (&rest args &key error-thrown &allow-other-keys)
(message "Got error: %S" error-thrown)))
)
(provide 'reorg)
;;; reorg.el ends here