mirror of
https://github.com/quepasaevents/qpa-client.git
synced 2023-12-14 05:33:02 +01:00
Fix list events
This commit is contained in:
parent
5649de8a7d
commit
88dbb7f316
2 changed files with 40 additions and 40 deletions
|
@ -1,51 +1,30 @@
|
|||
import {auth} from 'google-auth-library';
|
||||
import { atob } from 'atob';
|
||||
import Calendar from '../calendar'
|
||||
import { gcal as gcalConfig } from '../config'
|
||||
import Repository from "../repository";
|
||||
|
||||
let calendar
|
||||
describe('cal access', () => {
|
||||
it('atob test', () => {
|
||||
beforeEach(() => {
|
||||
calendar = new Calendar({
|
||||
repository: new Repository('testProject'),
|
||||
gcalConfig: gcalConfig,
|
||||
})
|
||||
})
|
||||
xit('atob test', () => {
|
||||
expect(atob('aGVsbG8=')).toEqual('hello')
|
||||
});
|
||||
|
||||
it('try to access', async (done) => {
|
||||
|
||||
|
||||
/**
|
||||
iss The email address of the service account.
|
||||
scope A space-delimited list of the permissions that the application requests.
|
||||
aud A descriptor of the intended target of the assertion. When making an access token request this value is always https://www.googleapis.com/oauth2/v4/token.
|
||||
exp The expiration time of the assertion, specified as seconds since 00:00:00 UTC, January 1, 1970. This value has a maximum of 1 hour after the issued time.
|
||||
iat The time the assertion was issued, specified as seconds since 00:00:00 UTC, January 1, 1970.
|
||||
*/
|
||||
|
||||
// const client: any = auth.fromJSON(keys);
|
||||
// client.scopes = ['https://www.googleapis.com/auth/calendar'];
|
||||
// await client.authorize();
|
||||
|
||||
// const url = `https://www.googleapis.com/calendar/v3/users/me/calendarList`;
|
||||
// const res = await client.request({
|
||||
// url,
|
||||
// });
|
||||
// console.log(JSON.stringify(res.data.items[0], null, '\t'));
|
||||
|
||||
|
||||
// const calendarId = 'tved0d7d5s4pk9qebub2pgpkks@group.calendar.google.com'
|
||||
//
|
||||
// const calendar = await client.request({
|
||||
// method: 'get',
|
||||
// url: `https://www.googleapis.com/calendar/v3/calendars/${calendarId}/events`,
|
||||
// })
|
||||
|
||||
|
||||
// console.log('calendar', calendar.data)
|
||||
|
||||
// client.request({
|
||||
// method: 'post',
|
||||
// url: `https://www.googleapis.com/calendar/v3/calendars/${calendarId}/events`,
|
||||
// })
|
||||
|
||||
|
||||
it('read events', async (done) => {
|
||||
const events = await calendar.listEvents()
|
||||
console.log('events', events)
|
||||
done()
|
||||
})
|
||||
|
||||
xit('try to access', async (done) => {
|
||||
const cals = await calendar.listCalendars()
|
||||
console.log('cals', cals)
|
||||
done();
|
||||
|
||||
})
|
||||
})
|
|
@ -33,6 +33,27 @@ export default class Calendar {
|
|||
return client as OAuth2Client;
|
||||
}
|
||||
|
||||
createPrimaryCalendar = async ( ) => {
|
||||
const client = await this.getClient()
|
||||
const res = await client.request({
|
||||
method: 'post',
|
||||
url: 'https://www.googleapis.com/calendar/v3/calendars',
|
||||
data: {
|
||||
summary: 'primary events calendar'
|
||||
}
|
||||
});
|
||||
console.log('res', res.data)
|
||||
return res.data
|
||||
}
|
||||
|
||||
listCalendars = async () => {
|
||||
const client = await this.getClient()
|
||||
const res = await client.request({
|
||||
url: 'https://www.googleapis.com/calendar/v3/users/me/calendarList'
|
||||
});
|
||||
return (res.data as any).items;
|
||||
}
|
||||
|
||||
listEvents = async () => {
|
||||
const client = await this.getClient()
|
||||
let eventsResponse
|
||||
|
|
Loading…
Reference in a new issue