Appointment System with Google Calendar API (Timeslots) React/NodeJS - node.js

I am currently developing an appointment calendar with React and NodeJS using the Google Calendar API. The goal is to archive the following:
Step 1: User selects the desired Date in Calendar (done)
Step 2: Show Free 30 Minutes Timeslots in between the opening hours (done)
Step 3: Book Appointment and add to Calendar (done)
But now the problem is, that each timeslot can have 10 individual bookings and I want to show how much is left (e.g 3 People booked the slot at 15:30, I want to show that there are 7 Slots left) Currently if one booked the 15:30 slot it is removed. That is because I use a FreeBusy Query, and this only shows me the busy time not how many events there are.
My first thought was to save the bookings also in a database and then look for every timeslot how many people booked before, but this seems like not the best solution.
Do you have any better ideas on how to solve this problem?
Thanks in advance

Just a suggestion but maybe for each of the event placed on the calendar you could attach an extended property to mark the event as booked.
"extendedProperties": {
"shared": {
"booked": "false",}
}
https://developers.google.com/calendar/v3/reference/events#resource
Then whenever someone books an event, you could mark that event as booked by changing the extended property mentioned. To display the amount of event that are free to book you could filter the list of events by timeMin, timeMax of the selected Timeslot and count the number of events that are marked free or booked.

Related

How to deal with recurring events using the google calendar API?

I'm using the Google Calendar API and nodejs. I have an app that allows patients to book appointments with doctors. But first, I check the doctor's calendar to make sure they do not have appointments at this time. How can I tell if an event is recurring? Does it show up multiple times when I make a list API call or only once?
Does it show up multiple times when I made a list API call or only once?
By default, it'll come up only once. You'll need to include the singleEvents parameter and set it to true for the reoccurring events that are reoccurring to show up in the API response (otherwise only the first time the reoccurring event was scheduled will be included).
calendar.events.list({ calendarId: theCalendarId, singleEvents: true })
When you have a recurrent event the ID changes a lot. For example, a regular event ID would look like 3qoortuglk75k7fjhgmd9k2enn, but the event ID from a recurrent event would be like 3qoortuglk75k7fjhgmd9k2enn_20220217T160000Z. If you see it has additional information related to the date and time. You could try to use something like that to recognize if the event is recurrent or not.
When listing events with the API you also have the request parameter singleEvents. You could use it to list only single events and compare them to the full list of events to see which ones are recurrent events.

How to get the event instances of a multi-day events using google calendar API?

I am working on a demo project where I need to fetch all events from the google calendar and show it in the home page.I am using gapi to fetch the events.
The properties for fetching has singleEvents as true and showDeleted as true.
I get all the events and instances of the recurring events as well.However the instances of a multiday event, for example an event that starts at Jan 1st and ends at Jan5th doesn't get replicated and I get only one event that has start date as Jan 1st. Could anyone suggest why the event instances of multi-day events are not being fetched?
That is how Google Calendar works. A single event has a start datetime and an end datetime. There is only one event even though it occurs over several days.
If you want to retrieve multiple events you will need to insert an event for each time frame you are looking for.
Google is not going to spawn events for you it will only return the data it has.

Confusing shippo error during transaction using API

I keep getting this error when executing a transaction on rate object id's that were created a few days ago.
{
"source": "USPS",
"code": "",
"text": "The selected shipment date must be within 7 days of 02/15/2017, 07:11PM CST."
}
Im integrating shippo with my Node.js web application. I am using shippo node.js library.
shippo.shipment.create({, function(err, shipment) {});
I built a basic store. When user gets to checkout section, I get rates from shippo. I display those rates to the user. The user chooses which rate he wants. I save the rate object id to a database.
shippo.transaction.create({, function(err, transaction) {});
I fulfill the order and print the shipping label. The application goes to the database and retrieves rate object id to execute the transaction with shippo. In return Im suppose to get a tracking # and label information, but instead I get the error.
I first thought that the rate object id only last 7 days and then expires on its own or something. When I checked the rate object id:
https://api.goshippo.com/rates/2a0b50cbc5184362a0ea2385b490bc7b
It shows object was created 2/18. Today is the 2/21. So that cant be. The error says "The selected shipment date must be within 7 days of 02/15/2017, 07:11PM CST."
What does it mean? Why did I get it?
It seems to only happen to rate object id's that were create 2+ days ago. If the rate object id was created yesterday, I could still execute the transaction no problem.
screenshot
It looks like you are using a rate from the past (not the same day) that is causing this error to occur.
When you make a shipment at the /shipments/ endpoint, you are able to specify the submission_date when creating the shipment. If you do not specify the submission_date (you would generally only do this if you know the day you plan on shipping the item out), Shippo automatically sets the submission_date to the date the request is being made.
The reason that you are getting an error, is that you're using a rate for a shipment that has a submission_date in the past. Some carriers will only permit a submission date that is the current date, or some date in the future.
You can find more details here on the shipment object that might help.

Breaking down 1 calendar event into smaller events in SharePoint

I'm trying to create some sort of reservation system in SharePoint using a calendar list. It's been recommend to me to create events and add a column which allows a user to claim it. From there, claimed events would change color and only those who've claimed the event would have permission to unclaim the event.
This is what it would look like (see alternative option):
What I'd like to be able to do though, is instead of having to create three events like shown in the alternative option, creating 1 event (see original) and have that be broken down into 3 events or more, maybe using some form of drop down asking for intervals (ie. 15m, 30m, 1h). Based on the selected interval, it'd break the event accordingly.
A possible solution is in your main event you add another field named Interval.
The you design a workflow when you create the event that creates new events according to the interval specified using a while loop while incrementing the start time with your interval.
Those new events have a content type with a field named UserClaimed. you then associate another workflow to those new events that checks for that field and changes permissions on the event to only allow modifications of that event to the user specified.
This is the general idea, the implementation should not be that hard
just a thought -
I mean, the reason i think you want the events to pre-exist is so that users can easily create them in the correct time slot (rather than clicking the new item menu, which throws them away from the calendar view/context). Is that right?
If so, allow me to offer you this scenario:
If you are using KWizCom's Calendar Plus web part (yeah, I work for KWizCom...) it allows you to type in the event in the calendar itself directly.
Something simple like: "1pm-2:30pm Training meeting with Josh"
check the demo video here: http://www.kwizcom.com/sharepoint-add-ons/sharepoint-calendar-plus-web-part/overview/
Also, drag and drop events in the calendar to move them easily, and it also supports color coding events based on categories (meta data, views, sources, etc.).
The one thing you will need to develop is the unique meeting logic, and owner permissions.
meaning, an event handler that does not accept 2 meetings at the same time for the same room (define the unique resource field, if any), and the logic that allows only the person who created an event to edit or delete it.
ping me, I can help with the event handler - perhaps we can add this to our product, this is actually a cool idea. my work mail is shai at kwizcom dot com

Recurring Event or Automatically push Entry date forward in ExpressionEngine

I've got an events channel set up on a client site where everything is working just fine. However they now have a single event that runs every Sunday. Due to using the start_on parameter to only show events from the current month onwards this recurring event is now displaying a blank page.
Is there a simple way to have the entries publish date automatically updated to the current month or somehow display recurring events correctly. Client is unwilling to spend money on a new module such as Solspace Calendar.
You could set up a cron job on the server to run a PHP script which would modify the entry date on your recurring entry.
Yeah I see your dilemma, Sean - separating the event from its month and year (year in particular) to have one even display multiple times... What about using MX Clone to simply allow them to create multiple instances of the same entry (granted, they'd have to adjust the date for each one too, but that can be done en masse from the mass edit screen if you're using one of the native date fields and not a custom date field)?
Could you make the entry sticky? Not sure whether that would override the start_on parameter or not.

Resources