@@ -6,10 +6,10 @@ import {
66 createPurrfectCompany ,
77 createPurrfectPage ,
88 queryPurrfectPageByCalendarId ,
9- patchPurrfectPage ,
109} from './../utilities/notion' ;
1110
1211import { getEvent , listEventInvitees } from './../utilities/calendly' ;
12+ import { utcOffset } from '../utilities/date' ;
1313
1414export const calendarPush = functions . https . onRequest ( async ( req , res ) => {
1515 console . log ( 'Headers' , JSON . stringify ( req . headers ) ) ;
@@ -37,38 +37,40 @@ export const calendarPush = functions.https.onRequest(async (req, res) => {
3737
3838 try {
3939 const calendlyEvent = await getEvent ( eventUuid ) ;
40+ console . log ( 'calendlyEvent' , JSON . stringify ( calendlyEvent ) ) ;
4041 const calendlyInvitees = await listEventInvitees ( eventUuid ) ;
42+ console . log ( 'calendlyInvitees' , JSON . stringify ( calendlyInvitees ) ) ;
4143
4244 // Check if calendar event already created.
4345 console . log (
4446 'Searching for Pod with calendarid: ' ,
45- webhookPayload . payload . event
47+ JSON . stringify ( webhookPayload . payload . event )
4648 ) ;
4749 const purrfectPageRes = await queryPurrfectPageByCalendarId (
4850 webhookPayload . payload . event
4951 ) ;
5052 if ( purrfectPageRes ?. results . length > 0 ) {
51- console . log ( 'Pod found' , JSON . stringify ( purrfectPageRes ) ) ;
52- const purrfectPage = purrfectPageRes ?. results ?. [ 0 ] ;
53- console . log (
54- 'Updating pod with time: ' ,
55- calendlyEvent . resource . start_time
56- ) ;
57- const purrfectPagePatchRes = await patchPurrfectPage ( {
58- page_id : purrfectPage . id ,
59- properties : {
60- 'Recording Date' : {
61- date : {
62- start : calendlyEvent . resource . start_time ,
63- end : null ,
64- time_zone : 'America/New_York' ,
65- } ,
66- } ,
67- } ,
68- } ) ;
53+ // console.log('Pod found', JSON.stringify(purrfectPageRes));
54+ // const purrfectPage = purrfectPageRes?.results?.[0];
55+ // console.log(
56+ // 'Updating pod with time: ',
57+ // JSON.stringify( calendlyEvent.resource.start_time)
58+ // );
59+ // const purrfectPagePatchRes = await patchPurrfectPage({
60+ // page_id: purrfectPage.id,
61+ // properties: {
62+ // 'Recording Date': {
63+ // date: {
64+ // start: utcOffset( calendlyEvent.resource.start_time) ,
65+ // end: null,
66+ // time_zone: 'America/New_York',
67+ // },
68+ // },
69+ // },
70+ // });
6971
70- console . log ( 'Patched' , JSON . stringify ( purrfectPagePatchRes ) ) ;
71- res . status ( 200 ) . send ( 'updated ' ) ;
72+ // console.log('Patched', JSON.stringify(purrfectPagePatchRes));
73+ res . status ( 200 ) . send ( 'duplicate entry ' ) ;
7274 }
7375
7476 // Check if Notion Company exists, if not create
@@ -120,7 +122,7 @@ export const calendarPush = functions.https.onRequest(async (req, res) => {
120122 const newPodcast = {
121123 guestIds : [ guestId ] ,
122124 companyIds,
123- recordingDate : new Date ( calendlyEvent . resource . start_time ) ,
125+ recordingDate : utcOffset ( calendlyEvent . resource . start_time ) ,
124126 calendarid : webhookPayload . payload . event ,
125127 } ;
126128 console . log ( 'Creating Podcast with values: ' , JSON . stringify ( newPodcast ) ) ;
0 commit comments