\Google_Sync

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.

Summary

Methods
Properties
Constants
__construct()
get_auth_url()
authenticate()
refresh_token()
add_appointment()
update_appointment()
delete_appointment()
add_unavailable()
update_unavailable()
delete_unavailable()
get_event()
get_sync_events()
get_google_calendars()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
$CI
$client
$service
N/A

Properties

$CI

$CI : 

Type

$client

$client : 

Type

$service

$service : 

Type

Methods

__construct()

__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.

get_auth_url()

get_auth_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.

authenticate()

authenticate(  $auth_code) 

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.

Parameters

$auth_code

refresh_token()

refresh_token(string  $refresh_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

string $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.

add_appointment()

add_appointment(array  $appointment, array  $provider, array  $service, array  $customer,   $company_settings) : \Google_Event

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

array $appointment

Contains the appointment record data.

array $provider

Contains the provider record data.

array $service

Contains the service record data.

array $customer

Contains the customer recod data.

$company_settings

Returns

\Google_Event —

Returns the Google_Event class object.

update_appointment()

update_appointment(array  $appointment, array  $provider, array  $service, array  $customer,   $company_settings) : \Google_Event

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

array $appointment

Contains the appointment record data.

array $provider

Contains the provider record data.

array $service

Contains the service record data.

array $customer

Contains the customer recod data.

$company_settings

Returns

\Google_Event —

Returns the Google_Event class object.

delete_appointment()

delete_appointment(array  $provider, string  $google_event_id) 

Delete an existing appointment from Google Calendar.

Parameters

array $provider

Contains the provider record data.

string $google_event_id

The Google Calendar event id to be deleted.

add_unavailable()

add_unavailable(array  $provider, array  $unavailable) : \Google_Event

Add unavailable period event to Google Calendar.

Parameters

array $provider

Contains the provider record data.

array $unavailable

Contains unavailable period's data.

Returns

\Google_Event —

Returns the google event's object.

update_unavailable()

update_unavailable(array  $provider, array  $unavailable) : \Google_Event

Update Google Calendar unavailable period event.

Parameters

array $provider

Contains the provider record data.

array $unavailable

Contains the unavailable period data.

Returns

\Google_Event —

Returns the Google_Event object.

delete_unavailable()

delete_unavailable(array  $provider, string  $google_event_id) 

Delete unavailable period event from Google Calendar.

Parameters

array $provider

Contains the provider record data.

string $google_event_id

Google Calendar event id to be deleted.

get_event()

get_event(array  $provider, string  $google_event_id) : \Google_Event

Get an event object from gcal

Parameters

array $provider

Contains the provider record data.

string $google_event_id

Id of the google calendar event

Returns

\Google_Event —

Returns the google event object.

get_sync_events()

get_sync_events(string  $google_calendar, \date  $start, \date  $end) : object

Get all the events between the sync period.

Parameters

string $google_calendar

The name of the google calendar to be used.

\date $start

The start date of sync period.

\date $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).

get_google_calendars()

get_google_calendars() : array

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.

Returns

array —

Returns an array with the available calendars.