How to set available and unavailable times for a google resource for booking? - google-api

I'm looking for a way to set time availability and unavailability of the google calendar resources.
At the moment, I could create google calendar resource with google admin api. But the problem is, I don't know how to set available time for them that could use in booking process — creating an event in google calendar, and assign a resource to that event.
There's no any attribute to address this requirement here in documentation.

Alternative solution:
Apparently, there's no a straight forward procedure for bounding the time range of a resource calendar. So I decided to bound a resource calendar by creating fake events for those time ranges that the calendar should be unavailable. In this way, the users cannot book (i.e. create any events) on those specific time ranges!
OR
You can read every changes on a calendar (polling or push notification if applicable), then compare the created events with your system's events, and if there are any events that have conflicts with the system's events (booking), decline those google calendar events consequently.

Related

How to be aware of the creation of a new event in a google calendar? [duplicate]

I am developing a SPA webapp through which I add events to my users google calendar They have given permission for. However this is my first time using Google calendar API, and was unclear about how to retrieve my users existing events , or if they add new events or delete them. IS there an option to set a webhook within google calendar thus when the user makes any changes to the calendar I can receive the change. My current approach was to make multiple get requests but that seems very inefficient. How can I keep my app calendar in sync with all user created events.
You can set up a push notification to be alerted any time anything changes on one of your calendars. I looked into it before a little, if memory serves it doesn't alert you to a lot of particularly useful information (I don't believe it tells you exactly what changed and how). Check out the docs here: https://developers.google.com/google-apps/calendar/v3/push
What I ended up doing was setting up a cronjob and getting all of my calendars' events using the synctoken, which returns only the events that have changed since the last time I polled the API for events. https://developers.google.com/google-apps/calendar/v3/sync
If you are using the SyncToken in your request for data, all you get back is the events that have changed. There is an eventID in the Google records that you can use to connect the change to your event data.

How to create google resource calendar using any API?

I'm looking for a way to create resource calendars for shared rooms and for booking using any google API. In google documentation, it is mentioned that:
The Calendar API does not offer a way to create resource calendars. To do this, you need to use the Directory API's Calendar Resource object.
But the link mentioned refers to the creating calendar resource, not resource calendar!
Think of a resource room more like a user.
You can book resources and rooms by adding them to events as attendees, using their email address. When they receive the invitation, they automatically accept or decline the event based on the availability and access right of the inviting user.
Its not really a calendar. By adding the resource as an attendee for an event you are booking that room.

Is there a limit to the number of calendar events that can be programmatically scheduled for a given user?

My web app has an event scheduling feature, and I'd like to automatically create, update, and delete calendar events from users' individual calendars as the event details change on my site.
My plan to do this is to set up an automated/service user (e.g. events#example.co) and use the Calendar API to send invites that come from that user. As the event gets updated I continue to use the API through that user (using a server-to-server authentication protocol, so no human authorization required) to modify the event and deliver updates
If I'm scheduling several thousand events - will this scale with just one user? It doesn't feel right to schedule so many events under one automated user. But then again, it might work just fine.
Is there a limit to how many events I can schedule?
Is there a more sane way to approach this overall?
Thanks!
The google calendar api applies some standard quota limits on you. Basically the number of requests that you can make. However when you are planing on using a single user then there will be some other rules you will need to consider
Copied from here
If a user has created more than 10,000 events in his or her calendar within a short period of time, that user might lose calendar edit access.
If a user creates more than 25 new calendars within a short period of time, that user's calendar might go into read-only mode.
In order to prevent spamming, Google Calendar limits the number of invitations a user can send to external guests. This limit varies depending on the action, and is usually between 100-300 guests.
You can do this using a service account. To my knowledge there is no limit to the number of events you can put in a calendar per day however as stated above there will be a limit to how many you can insert at once.
I am not aware of a more sane option than this sorry.

Google Calendar event Created/Updated/Deleted Webhook?

I am developing a SPA webapp through which I add events to my users google calendar They have given permission for. However this is my first time using Google calendar API, and was unclear about how to retrieve my users existing events , or if they add new events or delete them. IS there an option to set a webhook within google calendar thus when the user makes any changes to the calendar I can receive the change. My current approach was to make multiple get requests but that seems very inefficient. How can I keep my app calendar in sync with all user created events.
You can set up a push notification to be alerted any time anything changes on one of your calendars. I looked into it before a little, if memory serves it doesn't alert you to a lot of particularly useful information (I don't believe it tells you exactly what changed and how). Check out the docs here: https://developers.google.com/google-apps/calendar/v3/push
What I ended up doing was setting up a cronjob and getting all of my calendars' events using the synctoken, which returns only the events that have changed since the last time I polled the API for events. https://developers.google.com/google-apps/calendar/v3/sync
If you are using the SyncToken in your request for data, all you get back is the events that have changed. There is an eventID in the Google records that you can use to connect the change to your event data.

Google Calendar API on add event callback for sync

I am using google-api-php-clientfor fetching and inserting Google Calendar events. Now I want to synchronize events on my system with events on Google Calendar.
I am wondering, if I add Event in Google Calendar, can it be automatically added in my system (maybe with some callback url) so I don't need to use CRON jobs to recheck events in Google Calendar in some time interval?
Thank you!
Google provides both iCal and XML output for viewing from external applications. This URL can be found by clicking on the drop down from your calendar name while logged in, selecting settings, and the calendar name. The private address row gives you both iCal and XML URLs.
Here are instructions for Outlook and iCal.

Resources