Skip to content

Commit edff1fd

Browse files
committed
progress
1 parent 7cac5f5 commit edff1fd

16 files changed

+470
-428
lines changed

.eslintrc.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ const ALWAYS = 'always';
66
const NEVER = 'never';
77

88
module.exports = {
9+
"parserOptions": {
10+
"ecmaVersion": 8
11+
},
912
'env': {
1013
es6: true,
1114
node: true
@@ -93,7 +96,7 @@ module.exports = {
9396
WARN,
9497
ALWAYS
9598
],
96-
'object-curly-newline': [
99+
'object-curly-newline': [
97100
ERROR,
98101
{
99102
ObjectExpression: {
@@ -151,4 +154,4 @@ module.exports = {
151154
}
152155
]
153156
}
154-
};
157+
};

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
node_modules
22
coverage
33
.idea
4+
.vscode

component.json

Lines changed: 222 additions & 214 deletions
Large diffs are not rendered by default.

lib/actions/checkAvailability.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const elasticio = require('elasticio-node');
2+
const messages = elasticio.messages;
3+
const ApiClient = require('../apiClient');
4+
module.exports.process = processAction;
5+
async function processAction(msg, cfg) {
6+
try {
7+
const client = ApiClient(cfg);
8+
let currentTime = msg.body.time || (new Date()).toISOString();
9+
let events = await client.get(`/me/events?$filter=start/dateTime le '${currentTime}'
10+
and end/dateTime ge '${currentTime}'`);
11+
this.emit('date', messages.newMessageWithBody({
12+
available: !events.value.length
13+
}));
14+
} catch (e) {
15+
console.log(e.error);
16+
this.emit('error', e);
17+
} finally {
18+
this.emit('end');
19+
}
20+
}

lib/actions/createEvent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*eslint no-console: 0 consistent-this: 0*/
2-
'use strict';
2+
33
const elasticio = require('elasticio-node');
44
const messages = elasticio.messages;
55
const _ = require('lodash');

lib/apiClient.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
'use strict';
21
const request = require('request-promise');
32

43
function ApiClient(config) {
@@ -63,7 +62,7 @@ function ApiClient(config) {
6362
};
6463
return options;
6564
}
66-
65+
//return request(setOptions(config.oauth.access_token));
6766
return refreshToken().then(setOptions).then(request);
6867
}
6968
};

lib/processEventDataHelper.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*eslint no-console: 0 */
2-
'use strict';
2+
33
const moment = require('moment-timezone');
44
const _ = require('lodash');
55
const Q = require('q');
@@ -25,17 +25,17 @@ function checkRequiredFields(cfg, messageBody) {
2525

2626
function formatDate(date, timeZone, format) {
2727

28-
//Valid date string
28+
//Valid date string
2929
if (moment(date).isValid()) {
3030
//Valid ISO_8601 string
3131
if ((moment(date, moment.ISO_8601).isValid())) {
3232
console.log(`Date ${date} has a known ISO-8601 format.`);
3333
return moment.tz(date, timeZone).format(format);
3434
}
35-
// non ISO_8601 string
35+
// non ISO_8601 string
3636
throw new Error(`non ISO-8601 date formats are currently not supported: ${date}.`);
3737
}
38-
//Valid millisecond value
38+
//Valid millisecond value
3939
if (moment(date, 'x').isValid()) {
4040
return moment(date, 'x').tz(timeZone).format(format);
4141
}
@@ -71,9 +71,9 @@ function buildPostBody(cfg, messageBody) {
7171

7272
if ((cfg.isAllDay) && (cfg.isAllDay === 'true')) {
7373
result.isAllDay = cfg.isAllDay;
74-
// The last day given as parameter is exclusive.
75-
// If the user wants to add all day event for 21-23 for ex,
76-
// outlook expects something like: 21 (00:00 AM) - 24 (00:00 AM)
74+
// The last day given as parameter is exclusive.
75+
// If the user wants to add all day event for 21-23 for ex,
76+
// outlook expects something like: 21 (00:00 AM) - 24 (00:00 AM)
7777
let FORMAT = 'YYYY-MM-DD';
7878
result.start.dateTime = formatDate(result.start.dateTime.trim(), cfg.timeZone, FORMAT);
7979
result.end.dateTime = formatDate(result.end.dateTime.trim(), cfg.timeZone, FORMAT);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"type": "object",
3+
"required": false,
4+
"properties": {
5+
"time": {
6+
"type": "string",
7+
"required": false,
8+
"title": "Time"
9+
}
10+
}
11+
}

lib/triggers/contacts.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint no-console: 0 no-invalid-this: 0*/
2-
'use strict';
2+
33
const messages = require('elasticio-node').messages;
44
const co = require('co');
55
const MicrosoftGraph = require('msgraph-sdk-javascript');

package.json

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,47 @@
11
{
2-
"name": "outlook-component",
3-
"version": "0.0.3",
4-
"description": "elastic.io integration component for Office 365 Outlook REST API",
5-
"homepage": "http://www.outlook.com/",
6-
"author": {
7-
"name": "elastic.io GmbH",
8-
"email": "[email protected]",
9-
"url": "http://elastic.io"
10-
},
11-
"files": [
12-
"lib"
13-
],
14-
"scripts": {
15-
"pretest": "eslint lib spec --fix",
16-
"test": "jasmine"
17-
},
18-
"main": "lib/index.js",
19-
"keywords": [
20-
"office365",
21-
"outlook",
22-
"rest",
23-
"elasticio",
24-
"elasticio-component"
25-
],
26-
"dependencies": {
27-
"bluebird": "^3.4.6",
28-
"co": "^4.6.0",
29-
"elasticio-node": "0.0.8",
30-
"elasticio-sailor-nodejs": "2.1.0",
31-
"lodash": "^4.17.2",
32-
"moment": "^2.1.16",
33-
"moment-timezone": "^0.5.9",
34-
"msgraph-sdk-javascript": "^0.1.2",
35-
"q": "^1.4.1",
36-
"request": "^2.75.0",
37-
"request-promise": "^4.1.1"
38-
},
39-
"devDependencies": {
40-
"elasticio-cli": "1.0.0",
41-
"eslint": "^3.1.2",
42-
"jasmine": "^2.5.2",
43-
"nock": "9.0.2"
44-
},
45-
"repository": "elasticio/outlook",
46-
"license": "Apache-2.0"
47-
}
2+
"name": "outlook-component",
3+
"version": "0.0.3",
4+
"description": "elastic.io integration component for Office 365 Outlook REST API",
5+
"homepage": "http://www.outlook.com/",
6+
"author": {
7+
"name": "elastic.io GmbH",
8+
"email": "[email protected]",
9+
"url": "http://elastic.io"
10+
},
11+
"files": [
12+
"lib"
13+
],
14+
"scripts": {
15+
"pretest": "eslint lib spec --fix",
16+
"test": "jasmine"
17+
},
18+
"main": "lib/index.js",
19+
"keywords": [
20+
"office365",
21+
"outlook",
22+
"rest",
23+
"elasticio",
24+
"elasticio-component"
25+
],
26+
"dependencies": {
27+
"bluebird": "^3.4.6",
28+
"co": "^4.6.0",
29+
"elasticio-node": "0.0.8",
30+
"elasticio-sailor-nodejs": "2.1.0",
31+
"lodash": "^4.17.2",
32+
"moment": "^2.1.16",
33+
"moment-timezone": "^0.5.9",
34+
"msgraph-sdk-javascript": "^0.1.2",
35+
"q": "^1.4.1",
36+
"request": "^2.75.0",
37+
"request-promise": "^4.1.1"
38+
},
39+
"devDependencies": {
40+
"elasticio-cli": "1.0.0",
41+
"eslint": "^3.1.2",
42+
"jasmine": "^2.5.2",
43+
"nock": "9.0.2"
44+
},
45+
"repository": "elasticio/outlook",
46+
"license": "Apache-2.0"
47+
}

0 commit comments

Comments
 (0)