generated from obsidianmd/obsidian-sample-plugin
-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Public TEST OAuth client for new users.
- Loading branch information
Showing
17 changed files
with
356 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,31 @@ | ||
import { requestUrl } from "obsidian"; | ||
import { getGoogleAuthToken } from "./GoogleAuth"; | ||
import GoogleCalendarPlugin from "../GoogleCalendarPlugin"; | ||
import { settingsAreCompleteAndLoggedIn } from "../view/GoogleCalendarSettingTab"; | ||
import type { GoogleEvent } from "../helper/types"; | ||
|
||
import {getToken} from "../helper/LocalStorage" | ||
import { createNotice } from "../helper/NoticeHelper"; | ||
/** | ||
* Function to get information of a single event by id | ||
* @param eventId The id of the event | ||
* @param calendarId The id of the calendar the event is in | ||
* @returns The found Event | ||
*/ | ||
export async function googleGetEvent(eventId: string, calendarId?: string): Promise<GoogleEvent> { | ||
const plugin = GoogleCalendarPlugin.getInstance(); | ||
|
||
if(!settingsAreCompleteAndLoggedIn())return null; | ||
|
||
const updateResponse = await requestUrl({ | ||
url: `https://www.googleapis.com/calendar/v3/calendars/${calendarId}/events/${eventId}?key=${plugin.settings.googleApiToken}`, | ||
url: `https://www.googleapis.com/calendar/v3/calendars/${calendarId}/events/${eventId}?key=${getToken()}`, | ||
method: "GET", | ||
headers: {"Authorization": "Bearer " + (await getGoogleAuthToken())}, | ||
}); | ||
|
||
if (updateResponse.status !== 200) { | ||
createNotice("Could not get Google Event"); | ||
return null; | ||
} | ||
|
||
|
||
const createdEvent = await updateResponse.json; | ||
return createdEvent; | ||
} |
Oops, something went wrong.