mirror of
https://github.com/jxpeng98/obsidian-to-NotionNext
synced 2026-07-30 00:48:36 +08:00
modify the notionapi variable
This commit is contained in:
@@ -4,23 +4,27 @@ import {markdownToBlocks,} from "@tryfabric/martian";
|
|||||||
import * as yamlFrontMatter from "yaml-front-matter";
|
import * as yamlFrontMatter from "yaml-front-matter";
|
||||||
// import * as yaml from "yaml"
|
// import * as yaml from "yaml"
|
||||||
import MyPlugin from "src/main";
|
import MyPlugin from "src/main";
|
||||||
|
import {DatabaseDetails} from "../../ui/settingTabs";
|
||||||
|
|
||||||
export class UploadBaseGeneral {
|
export class UploadBaseGeneral {
|
||||||
plugin: MyPlugin;
|
plugin: MyPlugin;
|
||||||
notion: Client;
|
notion: Client;
|
||||||
agent: any;
|
agent: any;
|
||||||
|
dbDetails: DatabaseDetails
|
||||||
constructor(plugin: MyPlugin) {
|
constructor(plugin: MyPlugin, dbDetails: DatabaseDetails) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
this.dbDetails = dbDetails
|
||||||
}
|
}
|
||||||
|
|
||||||
async deletePage(notionID: string) {
|
async deletePage(notionID: string) {
|
||||||
|
|
||||||
|
const {notionAPI} = this.dbDetails
|
||||||
return requestUrl({
|
return requestUrl({
|
||||||
url: `https://api.notion.com/v1/blocks/${notionID}`,
|
url: `https://api.notion.com/v1/blocks/${notionID}`,
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'Authorization': 'Bearer ' + this.plugin.settings.notionAPINext,
|
'Authorization': 'Bearer ' + notionAPI,
|
||||||
'Notion-Version': '2022-06-28',
|
'Notion-Version': '2022-06-28',
|
||||||
},
|
},
|
||||||
body: ''
|
body: ''
|
||||||
@@ -28,11 +32,12 @@ export class UploadBaseGeneral {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getDataBase(databaseID: string) {
|
async getDataBase(databaseID: string) {
|
||||||
|
const {notionAPI} = this.dbDetails
|
||||||
const response = await requestUrl({
|
const response = await requestUrl({
|
||||||
url: `https://api.notion.com/v1/databases/${databaseID}`,
|
url: `https://api.notion.com/v1/databases/${databaseID}`,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
'Authorization': 'Bearer ' + this.plugin.settings.notionAPINext,
|
'Authorization': 'Bearer ' + notionAPI,
|
||||||
'Notion-Version': '2022-06-28',
|
'Notion-Version': '2022-06-28',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ export class Upload2NotionGeneral extends UploadBaseGeneral {
|
|||||||
dbDetails: DatabaseDetails;
|
dbDetails: DatabaseDetails;
|
||||||
|
|
||||||
constructor(plugin: MyPlugin, dbDetails: DatabaseDetails) {
|
constructor(plugin: MyPlugin, dbDetails: DatabaseDetails) {
|
||||||
super(plugin);
|
super(plugin, dbDetails);
|
||||||
this.dbDetails = dbDetails;
|
this.dbDetails = dbDetails;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,23 +4,27 @@ import { markdownToBlocks, } from "@tryfabric/martian";
|
|||||||
import * as yamlFrontMatter from "yaml-front-matter";
|
import * as yamlFrontMatter from "yaml-front-matter";
|
||||||
// import * as yaml from "yaml"
|
// import * as yaml from "yaml"
|
||||||
import MyPlugin from "src/main";
|
import MyPlugin from "src/main";
|
||||||
|
import {DatabaseDetails} from "../../ui/settingTabs";
|
||||||
|
|
||||||
export class UploadBaseNext {
|
export class UploadBaseNext {
|
||||||
plugin: MyPlugin;
|
plugin: MyPlugin;
|
||||||
notion: Client;
|
notion: Client;
|
||||||
agent: any;
|
agent: any;
|
||||||
|
dbDetails: DatabaseDetails
|
||||||
|
|
||||||
constructor(plugin: MyPlugin) {
|
constructor(plugin: MyPlugin, dbDetails: DatabaseDetails) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
this.dbDetails = dbDetails
|
||||||
}
|
}
|
||||||
|
|
||||||
async deletePage(notionID: string) {
|
async deletePage(notionID: string) {
|
||||||
|
const {notionAPI} = this.dbDetails
|
||||||
return requestUrl({
|
return requestUrl({
|
||||||
url: `https://api.notion.com/v1/blocks/${notionID}`,
|
url: `https://api.notion.com/v1/blocks/${notionID}`,
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'Authorization': 'Bearer ' + this.plugin.settings.notionAPINext,
|
'Authorization': 'Bearer ' + notionAPI,
|
||||||
'Notion-Version': '2022-06-28',
|
'Notion-Version': '2022-06-28',
|
||||||
},
|
},
|
||||||
body: ''
|
body: ''
|
||||||
@@ -28,11 +32,13 @@ export class UploadBaseNext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getDataBase(databaseID: string) {
|
async getDataBase(databaseID: string) {
|
||||||
|
const {notionAPI} = this.dbDetails
|
||||||
|
|
||||||
const response = await requestUrl({
|
const response = await requestUrl({
|
||||||
url: `https://api.notion.com/v1/databases/${databaseID}`,
|
url: `https://api.notion.com/v1/databases/${databaseID}`,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
'Authorization': 'Bearer ' + this.plugin.settings.notionAPINext,
|
'Authorization': 'Bearer ' + notionAPI,
|
||||||
'Notion-Version': '2022-06-28',
|
'Notion-Version': '2022-06-28',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ export class Upload2NotionNext extends UploadBaseNext {
|
|||||||
dbDetails: DatabaseDetails
|
dbDetails: DatabaseDetails
|
||||||
|
|
||||||
constructor(plugin: MyPlugin, dbDetails: DatabaseDetails) {
|
constructor(plugin: MyPlugin, dbDetails: DatabaseDetails) {
|
||||||
super(plugin);
|
super(plugin, dbDetails);
|
||||||
this.dbDetails = dbDetails
|
this.dbDetails = dbDetails
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,23 +4,27 @@ import {markdownToBlocks,} from "@tryfabric/martian";
|
|||||||
import * as yamlFrontMatter from "yaml-front-matter";
|
import * as yamlFrontMatter from "yaml-front-matter";
|
||||||
// import * as yaml from "yaml"
|
// import * as yaml from "yaml"
|
||||||
import MyPlugin from "src/main";
|
import MyPlugin from "src/main";
|
||||||
|
import {DatabaseDetails} from "../../ui/settingTabs";
|
||||||
|
|
||||||
export class UploadBaseCustom {
|
export class UploadBaseCustom {
|
||||||
plugin: MyPlugin;
|
plugin: MyPlugin;
|
||||||
notion: Client;
|
notion: Client;
|
||||||
agent: any;
|
agent: any;
|
||||||
|
dbDetails: DatabaseDetails
|
||||||
|
|
||||||
constructor(plugin: MyPlugin) {
|
constructor(plugin: MyPlugin, dbDetails: DatabaseDetails) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
this.dbDetails = dbDetails
|
||||||
}
|
}
|
||||||
|
|
||||||
async deletePage(notionID: string) {
|
async deletePage(notionID: string) {
|
||||||
|
const {notionAPI} = this.dbDetails
|
||||||
return requestUrl({
|
return requestUrl({
|
||||||
url: `https://api.notion.com/v1/blocks/${notionID}`,
|
url: `https://api.notion.com/v1/blocks/${notionID}`,
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'Authorization': 'Bearer ' + this.plugin.settings.notionAPINext,
|
'Authorization': 'Bearer ' + notionAPI,
|
||||||
'Notion-Version': '2022-06-28',
|
'Notion-Version': '2022-06-28',
|
||||||
},
|
},
|
||||||
body: ''
|
body: ''
|
||||||
@@ -28,11 +32,12 @@ export class UploadBaseCustom {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getDataBase(databaseID: string) {
|
async getDataBase(databaseID: string) {
|
||||||
|
const {notionAPI} = this.dbDetails
|
||||||
const response = await requestUrl({
|
const response = await requestUrl({
|
||||||
url: `https://api.notion.com/v1/databases/${databaseID}`,
|
url: `https://api.notion.com/v1/databases/${databaseID}`,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
'Authorization': 'Bearer ' + this.plugin.settings.notionAPINext,
|
'Authorization': 'Bearer ' + notionAPI,
|
||||||
'Notion-Version': '2022-06-28',
|
'Notion-Version': '2022-06-28',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ export class Upload2NotionCustom extends UploadBaseCustom {
|
|||||||
dbDetails: DatabaseDetails;
|
dbDetails: DatabaseDetails;
|
||||||
|
|
||||||
constructor(plugin: MyPlugin, dbDetails: DatabaseDetails) {
|
constructor(plugin: MyPlugin, dbDetails: DatabaseDetails) {
|
||||||
super(plugin);
|
super(plugin, dbDetails);
|
||||||
this.dbDetails = dbDetails;
|
this.dbDetails = dbDetails;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,7 +116,7 @@ export class Upload2NotionCustom extends UploadBaseCustom {
|
|||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
// 'User-Agent': 'obsidian.md',
|
// 'User-Agent': 'obsidian.md',
|
||||||
Authorization:
|
Authorization:
|
||||||
"Bearer " + this.plugin.settings.notionAPIGeneral,
|
"Bearer " + notionAPI,
|
||||||
"Notion-Version": "2022-06-28",
|
"Notion-Version": "2022-06-28",
|
||||||
},
|
},
|
||||||
body: JSON.stringify(bodyString),
|
body: JSON.stringify(bodyString),
|
||||||
|
|||||||
Reference in New Issue
Block a user