@@ -15,7 +15,7 @@ export class TokenValidationError extends Error {
15
15
16
16
/**
17
17
* Readwise API class
18
- */
18
+ */
19
19
export default class ReadwiseApi {
20
20
private apiToken : string ;
21
21
private validToken : boolean | undefined ;
@@ -64,12 +64,11 @@ export default class ReadwiseApi {
64
64
* @returns {Promise<boolean> } - Returns a promise that resolves to a boolean indicating if the token is valid
65
65
*/
66
66
async hasValidToken ( ) : Promise < boolean > {
67
- async hasValidToken ( ) : Promise < boolean > {
68
- if ( this . validToken === undefined ) {
69
- this . validToken = await this . validateToken ( ) ;
70
- }
71
- return this . validToken ;
72
- }
67
+ if ( this . validToken === undefined ) {
68
+ this . validToken = await this . validateToken ( ) ;
69
+ }
70
+ return this . validToken ;
71
+ }
73
72
74
73
/**
75
74
* Checks if the token is valid by making a request to the Readwise API
@@ -92,7 +91,7 @@ export default class ReadwiseApi {
92
91
* @param contentType - The type of content to fetch from the API
93
92
* @param lastUpdated - The date to fetch updates from
94
93
* @param bookId - The ID of the book to fetch highlights from
95
- * @returns {Promise<Export[]> } - Returns a promise that resolves to an array of Export objects
94
+ * @returns {Promise<Export[]> } - Returns a promise that resolves to an array of Export objects
96
95
* @throws {Error } - Throws an error if the request fails
97
96
*/
98
97
async fetchData ( contentType = 'export' , lastUpdated ?: string , bookId ?: number [ ] ) : Promise < Export [ ] > {
@@ -166,7 +165,7 @@ export default class ReadwiseApi {
166
165
/**
167
166
* Builds a library object from the fetched data
168
167
* @param results - The fetched data from the Readwise API
169
- * @returns {Promise<Library> } - Returns a promise that resolves to a Library object
168
+ * @returns {Promise<Library> } - Returns a promise that resolves to a Library object
170
169
*/
171
170
async buildLibrary ( results : Export [ ] ) : Promise < Library > {
172
171
const library : Library = {
@@ -189,7 +188,7 @@ export default class ReadwiseApi {
189
188
190
189
/**
191
190
* Fetches all highlights from Readwise API
192
- * @returns {Promise<Library> } - Returns a promise that resolves to a Library object
191
+ * @returns {Promise<Library> } - Returns a promise that resolves to a Library object
193
192
*/
194
193
async downloadFullLibrary ( ) : Promise < Library > {
195
194
const records = ( await this . fetchData ( 'export' ) ) as Export [ ] ;
@@ -199,8 +198,8 @@ export default class ReadwiseApi {
199
198
200
199
/**
201
200
* Fetches updates from Readwise API
202
- * @param lastUpdated - The date to fetch updates from
203
- * @returns {Promise<Library> } - Returns a promise that resolves to a Library object
201
+ * @param lastUpdated - The date to fetch updates from
202
+ * @returns {Promise<Library> } - Returns a promise that resolves to a Library object
204
203
*/
205
204
async downloadUpdates ( lastUpdated : string ) : Promise < Library > {
206
205
// Fetch updated books and then fetch all their highlights
0 commit comments