Hi all,
I’m using Workflow to fetch data from Google Calendar. The API specify OAuth authentication but before to go into this part I’m playing a little with other easy part like “event requests”. Google API specify that this can be done by placing an GET request like this example:
Here you can see that some url parts and params like mail and “timeMin” will change over time, specially “timeMin”. So, how can I handle this param as a template ?, The idea is to automate this parameter to build request with the current date and a previous calculated time for each timed request.
The second question is about processing the typical payload coming from these kinds of requests:
{
"kind": "calendar#events",
"etag": "\"1465123213122000\"",
"summary": "Mi Sala",
"description": "Espacio para eventos académicos con aforo para 235 personas.",
"updated": "2016-06-05T19:56:35.852Z",
"timeZone": "Europe/Madrid",
"accessRole": "owner",
"defaultReminders": [
{
"method": "popup",
"minutes": 10
}
],
"items": [
{
"kind": "calendar#event",
"etag": "\"2930310513466000\"",
"id": "lk2vfsvexxxxxxmb5v0us",
"status": "confirmed",
"htmlLink": "https://www.google.com/calendar/event?eid=bGsyxxxxRAbQ",
"created": "2016-06-05T11:32:39.000Z",
"updated": "2016-06-05T19:34:16.733Z",
"summary": "LOSANT Test1",
"creator": {
"email": "agarciaibct@gmail.com",
"displayName": "Andrés García",
"self": true
},
"organizer": {
"email": "agarciaibct@gmail.com",
"displayName": "Andrés García",
"self": true
},
"start": {
"dateTime": "2016-06-05T19:00:00+02:00"
},
"end": {
"dateTime": "2016-06-05T20:00:00+02:00"
},
"iCalUID": "lk2vxx0us@google.com",
"sequence": 1,
"reminders": {
"useDefault": true
}
},
{
"kind": "calendar#event",
"etag": "\"2930313191240000\"",
"id": "nuxxxnpk",
"status": "confirmed",
"htmlLink": "https://www.google.com/calendar/event?eid=bnVoNTxxxxxxRAbQ",
"created": "2016-06-05T19:34:31.000Z",
"updated": "2016-06-05T19:56:35.620Z",
"summary": "LOSANT Test2",
"creator": {
"email": "agarciaibct@gmail.com",
"displayName": "Andrés García",
"self": true
},
"organizer": {
"email": "agarciaibct@gmail.com",
"displayName": "Andrés García",
"self": true
},
"start": {
"dateTime": "2016-06-05T22:00:00+02:00"
},
"end": {
"dateTime": "2016-06-05T23:00:00+02:00"
},
"iCalUID": "nuhxcsnpk@google.com",
"sequence": 0,
"reminders": {
"useDefault": true
}
}
]
}
Here we can see two events, I mean two items. This payloads have an undetermined number of items[n] so in order to build an STATE for a device, it will be something like {{Events.body.items[n].summary}} for Summary on each event. So again, How can I handle this issue and store the “n” events ? … probably I can write some function logic base on javascript to parse all the payload??
thanks in advance for your suggestions.