-
Notifications
You must be signed in to change notification settings - Fork 0
/
maio.js
52 lines (42 loc) · 1.16 KB
/
maio.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
'use strict';
const request = require('request');
const Promise = require('bluebird');
const MAIO_URL = "https://maio-repository-service.us-west-2.int.expedia.com";
const requestOptions = {
timeout: 10000
};
/**
* Interfaces with Expedia MAIO repository.
*/
class Maio {
/**
* Get traveling tips.
*
* @param callback A function that will receive these parameters: error, response, body.
*/
getTipsCallback(callback) {
request(`${MAIO_URL}/v1/content/tips`,
requestOptions,
callback);
}
getTipsPromise() {
// 1- Create promise here
// ...
request(`${MAIO_URL}/v1/content/tips`,
requestOptions,
function (error, response, body) {
if (error) {
// 2- Reject promise
// ...
}
if (response.statusCode != 200) {
// 3- Reject promise
// ...
}
// 4- Resolve promise
// JSON.parse(...)
});
// 5- Don't forget to return the promise!
}
}
module.exports = new Maio();