import { Client } from '@notionhq/client';
export class NotionClient {
client;
constructor(apiKey, version) {
this.client = new Client({
auth: apiKey,
notionVersion: version || '2022-06-28'
});
}
async createPage(args) {
return await this.client.pages.create(args);
}
async retrievePage(args) {
const { page_id, filter_properties } = args;
return await this.client.pages.retrieve({
page_id,
...(filter_properties && { filter_properties })
});
}
async updatePage(args) {
return await this.client.pages.update(args);
}
async retrievePageProperty(args) {
const { page_id, property_id, page_size, start_cursor } = args;
return await this.client.pages.properties.retrieve({
page_id,
property_id,
...(page_size && { page_size }),
...(start_cursor && { start_cursor })
});
}
}