Google Synchronization Class
This class implements all the core synchronization between the Google Calendar
and the Easy!Appointments system. Do not place any model handling inside this
library.
public
|
#
__construct( )
Class Constructor
This method initializes the Google client class and the Calendar service
class so that they can be used by the other methods.
|
public
|
#
get_auth_url( )
Get Google OAuth authorization url.
Get Google OAuth authorization url.
This url must be used to redirect the user to the Google user consent page,
where the user grants access to his data for the Easy!Appointments app.
|
public
|
#
authenticate( $auth_code )
Authenticate the Google API usage.
Authenticate the Google API usage.
When the user grants consent for his data usage, google is going to redirect
the browser back to the given redirect url. There a authentication code is
provided. Using this code, we can authenticate the API usage and store the
token information to the database.
See
Google Controller
|
public
|
#
refresh_token( string $refresh_token )
Refresh the Google Client access token.
Refresh the Google Client access token.
This method must be executed every time we need to make actions on a
provider's Google Calendar account. A new token is necessary and the
only way to get it is to use the stored refresh token that was provided
when the provider granted consent to Easy!Appointments for use his
Google Calendar account.
Parameters
- $refresh_token
The provider's refresh token. This value is
stored in the database and used every time we need to make actions to his
Google Caledar account.
|
public
Google_Event
|
#
add_appointment( array $appointment, array $provider, array $service, array $customer, $company_settings )
Add an appointment record to its providers Google Calendar account.
Add an appointment record to its providers Google Calendar account.
This method checks whether the appointment's provider has enabled the Google
Sync utility of Easy!Appointments and the stored access token is still valid.
If yes, the selected appointment record is going to be added to the Google
Calendar account.
Parameters
- $appointment
- Contains the appointment record data.
- $provider
- Contains the provider record data.
- $service
- Contains the service record data.
- $customer
- Contains the customer recod data.
- $company_settings
Returns
Google_Event Returns the Google_Event class object.
Parma
array $company_settings Contains some company settings that are used
by this method. By the time the following values must be in the array:
'company_name'.
|
public
Google_Event
|
#
update_appointment( array $appointment, array $provider, array $service, array $customer, $company_settings )
Update an existing appointment that is already synced with Google Calendar.
Update an existing appointment that is already synced with Google Calendar.
This method updates the google calendar event item that is connected with the
provided appointment record of Easy!Appointments.
Parameters
- $appointment
- Contains the appointment record data.
- $provider
- Contains the provider record data.
- $service
- Contains the service record data.
- $customer
- Contains the customer recod data.
- $company_settings
Returns
Google_Event Returns the Google_Event class object.
Parma
array $company_settings Contains some company settings that are used
by this method. By the time the following values must be in the array:
'company_name'.
|
public
|
#
delete_appointment( array $provider, string $google_event_id )
Delete an existing appointment from Google Calendar.
Delete an existing appointment from Google Calendar.
Parameters
- $provider
- Contains the provider record data.
- $google_event_id
The Google Calendar event id to
be deleted.
|
public
Google_Event
|
#
add_unavailable( array $provider, array $unavailable )
Add unavailable period event to Google Calendar.
Add unavailable period event to Google Calendar.
Parameters
- $provider
- Contains the provider record data.
- $unavailable
- Contains unavailable period's data.
Returns
Google_Event Returns the google event's object.
|
public
Google_Event
|
#
update_unavailable( array $provider, array $unavailable )
Update Google Calendar unavailable period event.
Update Google Calendar unavailable period event.
Parameters
- $provider
- Contains the provider record data.
- $unavailable
- Contains the unavailable period data.
Returns
Google_Event Returns the Google_Event object.
|
public
|
#
delete_unavailable( array $provider, string $google_event_id )
Delete unavailable period event from Google Calendar.
Delete unavailable period event from Google Calendar.
Parameters
- $provider
- Contains the provider record data.
- $google_event_id
- Google Calendar event id to be deleted.
|
public
Google_Event
|
#
get_event( array $provider, string $google_event_id )
Get an event object from gcal
Get an event object from gcal
Parameters
- $provider
- Contains the provider record data.
- $google_event_id
- Id of the google calendar event
Returns
Google_Event Returns the google event object.
|
public
object
|
#
get_sync_events( string $google_calendar, date $start, date $end )
Get all the events between the sync period.
Get all the events between the sync period.
Parameters
- $google_calendar
- The name of the google calendar to be used.
- $start
- The start date of sync period.
- $end
- The end date of sync period.
Returns
object Returns an array with Google_Event objects that belong on the given
sync period (start, end).
|
public
array
|
#
get_google_calendars( string $google_token,… )
Return available google calendars for specific user.
Return available google calendars for specific user.
The given user's token must already exist in db in order to get access to his
Google Calendar account.
Parameters
- $google_token,…
- The user's token will be used to grant access to google calendar.
Returns
array Returns an array with the available calendars.
|