-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgoodreads.ts
More file actions
31 lines (28 loc) · 889 Bytes
/
goodreads.ts
File metadata and controls
31 lines (28 loc) · 889 Bytes
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
import { config, cosmicSync } from "@anandchowdhary/cosmic";
import goodreads from "goodreads-api-node";
import type { Integration } from "../integration";
cosmicSync("stethoscope");
const userId = config("goodreadsUserId") || "example";
const api = goodreads(
{
key: config("goodreadsKey") || "example",
secret: config("goodreadsSecret") || "example",
},
config("goodreadsCallbackUrl") || "http://localhost:3000/callback"
);
export default class Goodreads implements Integration {
name = "goodreads";
cli = {};
async update() {
for await (const shelf of (await api.getUserInfo(userId)).user_shelves.user_shelf.map((shelf) => shelf.name)) {
try {
const books = await api.getBooksOnUserShelf(userId, shelf);
console.log(books);
} catch (error) {
console.log(error);
}
}
}
async legacy() {}
async summary() {}
}