1 =======================================================
2 ``PATCH https://bosh.pageplace.de/bosh/rest/sync-data``
3 =======================================================
4 Send changes to the server and get changes since last sync back.
5 This is the main API method for synchronization.
7 Part of the `Sync process`_.
13 OAuth token obtained from `POST https://thalia.de/auth/oauth2/token`_.
15 Example: ``eyJhbGciOiJSUzI1NiJ9.eyJhdWRpZW5jZSI6InRyZWFkZXJ2aXNpb24zIiw...``
17 ``application/json; charset=UTF-8``
19 ``application/json; charset=UTF-8``
23 Example: ``665fc389ef4e47258c5db9fa7821bd19``
25 Example: ``TOLINO_VISION_3``
28 Example: ``publications``
31 Request body parameters
33 ``revision`` of last sync response.
35 ``null`` when it is the first sync ever for this device.
39 No data to sync: Empty array ``[]``.
41 Changes are objects with the following properties:
44 The patch operation: ``add``, ``replace``, ``remove``
46 ``replace`` is used to update the reading position.
49 Example: ``/publications/DT0400.9783739673417_A27522964/bookmark/606779074``
51 Consists of several parts:
53 1. The prefix seems always to be ``/publications/``.
54 2. A publication ID ``DT0400.9783739673417_A27522964``
55 3. The type that is created/updated/deleted:
57 - ``bookmark`` is the reading position
58 - ``dogears`` when bookmarking a page in the e-book
59 - ``comments`` when highlighting/marking some text or adding a note
63 Details of the change. Properties depend on the type.
66 Time when this action was done in milliseconds. Type: Integer.
68 Example: ``1612127562802``
70 File name of the chapter in the epub,
71 plus specific data in the anchor. Type: String.
73 Example: ``OEBPS/caterina-di-montebasso-das-relikt_0.html#point(/1/2/1/11/1:114)``
77 FIXME: Can be ``null``. When?
79 The patch part revisions share some prefix with the patch revision,
81 Seem to be base64-encoded, since the often (always?) have ``==`` at the end.
83 In the response, the patch part revisions also share some prefix with
84 the new server revision.
86 Example: ``Lmu7TngaxhKWHdv2FFktQNcGFPmnOshpANcqFEx7udpEDvQDdiq93W8ryZG4oSfm9D9sp2Aowkhu/1wg8qj4PglnxUFM96DOLgZMd9NVnTByM/ZG1vgkHHCrqwpA/7bO67OjTjo1TLKVL442Lx3sGw==``
88 Reading progress in the ranging from 0-1. Type: Float.
90 Only for ``bookmark`` (reading position) patches.
92 Example: ``0.41666666``
94 Current page number. Type: String.
96 Only for ``bookmark`` (reading position) patches.
100 Last page number in the book. Type: String
102 Only for ``bookmark`` (reading position) patches.
108 Only when ``op=add`` on ``dogears`` (bookmark) and ``comments``.
112 Text on the bookmarked page. Type: String.
114 Only for ``dogears`` (bookmark) add+remove operations.
116 Highlighted text. Type: String
118 Only for ``comments`` (highlight/note) add+remove operations.
120 Start of highlighted text. Type: String.
122 Only for ``comments`` (highlight/note) add+remove operations.
124 Example: ``OEBPS/caterina-di-montebasso-das-relikt_0.html#point(/1/2/1/11/1:463)``
126 End of highlighted text. Type: String.
128 Only for ``comments`` (highlight/note) add+remove operations.
130 Example: ``OEBPS/caterina-di-montebasso-das-relikt_0.html#point(/1/2/1/11/1:682)``
132 Manually entered text (note). Type: String.
134 Only for ``comments`` (note) add+remove operations.
136 Property does not appear for non-note highlights.
141 When closing a book (going back to the book list), the current reading
142 position is synchronized to the server - regardless if it changed.
143 I removed that from the requests + responses to have cleaner examples.
145 The ``revision`` in the request is the ``revision`` the server returned
146 in the last response.
151 When nothing needs to be synchronized to the server, and nothing
152 ever has been synchronized:
154 .. include:: pageplace.bosh-bosh-rest-sync-data.request-first.json
160 Reading a page in the book and exiting back to the books list:
162 .. include:: pageplace.bosh-bosh-rest-sync-data.request-reading-position.json
169 HTTP status code: ``200 OK``
171 When something changed, a new ``revision`` number is returned.
173 When synchronizing local changes to the server - and the server has no
174 changes from other readers,
175 the request is mirrored back in the response
176 (only the revision number is updated).
178 The server first ingests the request's patch data into its database,
179 and then calculates and returns the changes from the
180 requests's ``revision`` number to the current revision.
181 Those changes are returned in the response, together with the current
182 latest revision number.
184 Same structure as the request data.
189 The "Set reading position" changes and a new revision is returned.
191 .. include:: pageplace.bosh-bosh-rest-sync-data.response-reading-position.json
198 .. include:: pageplace.bosh-bosh-rest-sync-data.response-bookmark-set.json
205 .. include:: pageplace.bosh-bosh-rest-sync-data.response-bookmark-remove.json
212 .. include:: pageplace.bosh-bosh-rest-sync-data.response-highlight-add.json
219 .. include:: pageplace.bosh-bosh-rest-sync-data.response-highlight-remove.json
226 .. include:: pageplace.bosh-bosh-rest-sync-data.response-note-add.json
233 .. include:: pageplace.bosh-bosh-rest-sync-data.response-note-remove.json
237 New bookmarks and comments
238 --------------------------
241 .. include:: pageplace.bosh-bosh-rest-sync-data.response-bookmarks-comments.json