forked from mirrors/easyappointments
Create new Google HTTP client.
This commit is contained in:
parent
8d93f283f8
commit
c154280026
1 changed files with 93 additions and 0 deletions
93
assets/js/http/google_http_client.js
Executable file
93
assets/js/http/google_http_client.js
Executable file
|
@ -0,0 +1,93 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Open Source Web Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.2.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Google HTTP client.
|
||||
*
|
||||
* This module implements the Google Calendar related HTTP requests.
|
||||
*/
|
||||
App.Http.Google = (function () {
|
||||
/**
|
||||
* Select the Google Calendar for the synchronization with a provider.
|
||||
*
|
||||
* @param {Number} providerId
|
||||
* @param {String} googleCalendarId
|
||||
*
|
||||
* @return {*|jQuery.jqXHR}
|
||||
*/
|
||||
function selectGoogleCalendar(providerId, googleCalendarId) {
|
||||
const url = App.Utils.Url.siteUrl('google/select_google_calendar');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
provider_id: providerId,
|
||||
calendar_id: googleCalendarId
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable the Google Calendar syncing of a provider.
|
||||
*
|
||||
* @param {Number} providerId
|
||||
*
|
||||
* @return {*|jQuery.jqXHR}
|
||||
*/
|
||||
function disableProviderSync(providerId) {
|
||||
const url = App.Utils.Url.siteUrl('google/disable_provider_sync');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
provider_id: providerId
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the available Google Calendars of the connected provider's account.
|
||||
*
|
||||
* @param {Number} providerId
|
||||
*
|
||||
* @return {*|jQuery.jqXHR}
|
||||
*/
|
||||
function getGoogleCalendars(providerId) {
|
||||
const url = App.Utils.Url.siteUrl('google/get_google_calendars');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
provider_id: providerId
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger the sync process between Easy!Appointments and Google Calendar.
|
||||
*
|
||||
* @param {Number} providerId
|
||||
*
|
||||
* @return {*|jQuery.jqXHR}
|
||||
*/
|
||||
function syncWithGoogle(providerId) {
|
||||
const url = App.Utils.Url.siteUrl('google/sync/' + providerId);
|
||||
|
||||
return $.get(url);
|
||||
}
|
||||
|
||||
return {
|
||||
getGoogleCalendars,
|
||||
selectGoogleCalendar,
|
||||
disableProviderSync,
|
||||
syncWithGoogle
|
||||
};
|
||||
})();
|
Loading…
Reference in a new issue