Finding email of calendar owner in the response of google calendar API's events.list?

Viewed 485

I am developing a web app that displays calendar statistics of my co-workers. To display the person's email, I am using a field called 'summary' (Basically the response object does not contain an id field. It only has summary field.)

In most cases, it is the email of the person. IT WORKS.

BUT in cases when the person has changed the name of the calendar to 'Work' or something, it appears as 'Work' instead of 'cathie@mydomain.com'. In that case I can't know his/her email, hence I cannot print those statistics.

QUESTIONS

  1. Is there a field in the API response of gapi.client.calendar.events.list response that has email of the owner of the calendar?

  2. Are there any javascript tricks to pass this info (calendarId) into 'request.execute(function(resp)' and access it from inside the callback function?

  3. If there is a standard way of doing this, please suggest.


function getStatistics() {
    people = ['Alice', 'Bob', 'Cathie'];
    people.forEach(fetchStats);
}

function fetchStats(person) {
    var calendarId = person + '@mydomain.com';

    // ... some code

    var request = gapi.client.calendar.events.list({
        'calendarId': calendarId,
        'timeMax': (new Date()).toISOString(),
        'timeMin': '2016-01-01T00:00:00+05:30'
  });

  request.execute(function(resp) {
        var calendarId = resp.summary;

        if (calendarId.indexOf('@') == -1) {
            window.alert(resp + "\n" + calendarId);
            return;
        }

        // code to render statistics on events of the calendarId
  );
}
1 Answers
Related