node-calendly
Advanced tools
Comparing version 1.0.7 to 1.0.8
@@ -7,2 +7,7 @@ export declare type Options = { | ||
}; | ||
export declare type RequestOptions = { | ||
method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH'; | ||
headers?: any; | ||
body?: any; | ||
}; | ||
export default class CalendlyApiEndpoint { | ||
@@ -14,3 +19,4 @@ protected ACCESS_TOKEN: string; | ||
protected fetchPost(url: string, body: string): Promise<any>; | ||
protected request(uri: string, options: RequestOptions): Promise<any>; | ||
} | ||
//# sourceMappingURL=CalendlyApiEndpoint.d.ts.map |
@@ -21,2 +21,5 @@ "use strict"; | ||
const stopcock_1 = __importDefault(require("stopcock")); | ||
const Logger_1 = require("../Logger"); | ||
const logger = Logger_1.LogHandler.newInstance(); | ||
const LOG_NAMESPACE = 'API CALL'; | ||
class CalendlyApiEndpoint { | ||
@@ -31,8 +34,20 @@ constructor(ACCESS_TOKEN, params) { | ||
this.ACCESS_TOKEN = ACCESS_TOKEN; | ||
this.fetchGet = (0, stopcock_1.default)(this.fetchGet, this.options); | ||
this.fetchPost = (0, stopcock_1.default)(this.fetchPost, this.options); | ||
// this.fetchGet = stopcock(this.fetchGet, this.options); | ||
// this.fetchPost = stopcock(this.fetchPost, this.options); | ||
this.request = (0, stopcock_1.default)(this.request, this.options); | ||
} | ||
fetchGet(url) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const response = yield fetch(url, { | ||
// const response = await fetch(url, { | ||
// method: 'GET', | ||
// headers: { | ||
// Authorization: `Bearer ${this.ACCESS_TOKEN}`, | ||
// 'Content-Type': 'application/json' | ||
// } | ||
// }); | ||
// const data = await response.json(); | ||
// if (data && data.message) | ||
// throw new Error(data.title + ': ' + data.message); | ||
// return data; | ||
return this.request(url, { | ||
method: 'GET', | ||
@@ -44,6 +59,2 @@ headers: { | ||
}); | ||
const data = yield response.json(); | ||
if (data && data.message) | ||
throw new Error(data.title + ': ' + data.message); | ||
return data; | ||
}); | ||
@@ -53,3 +64,15 @@ } | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const response = yield fetch(url, { | ||
// const response = await fetch(url, { | ||
// method: 'POST', | ||
// headers: { | ||
// 'Content-Type': 'application/json', | ||
// Authorization: `Bearer ${this.ACCESS_TOKEN}` | ||
// }, | ||
// body | ||
// }); | ||
// const data = await response.json(); | ||
// if (data && data.message) | ||
// throw new Error(data.title + ': ' + data.message); | ||
// return data; | ||
return this.request(url, { | ||
method: 'POST', | ||
@@ -62,10 +85,41 @@ headers: { | ||
}); | ||
const data = yield response.json(); | ||
if (data && data.message) | ||
throw new Error(data.title + ': ' + data.message); | ||
return data; | ||
}); | ||
} | ||
request(uri, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return new Promise((resolve, reject) => { | ||
fetch(uri, options) | ||
.then((response) => { | ||
// console.log(response.headers); | ||
if (response.status === 429) { | ||
reject('Too many requests'); | ||
} | ||
else if (!response.ok) { | ||
logger.error(`Error fetching data. Response status ${response.status}`, LOG_NAMESPACE, 'request'); | ||
console.error(uri, response.status, response.statusText); | ||
if (Logger_1.DEBUG_LEVEL === 'debug') | ||
console.error(options); | ||
} | ||
if (response.status === 202) { | ||
return null; | ||
} | ||
return response.json().catch((error) => { | ||
logger.error(`Error parsing response: ${error}`, LOG_NAMESPACE, 'request'); | ||
return null; | ||
}); | ||
}) | ||
.then((data) => { | ||
if (data === null) { | ||
resolve(null); | ||
} | ||
resolve(data); | ||
}) | ||
.catch((error) => { | ||
reject(error); | ||
}); | ||
}); | ||
}); | ||
} | ||
} | ||
exports.default = CalendlyApiEndpoint; | ||
//# sourceMappingURL=CalendlyApiEndpoint.js.map |
{ | ||
"name": "node-calendly", | ||
"version": "1.0.7", | ||
"version": "1.0.8", | ||
"description": "Node module to access calendly api.", | ||
@@ -59,4 +59,5 @@ "main": "./lib/Calendly.js", | ||
"dependencies": { | ||
"stopcock": "^1.1.0" | ||
"stopcock": "^1.1.0", | ||
"winston": "^3.10.0" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
141981
92
1823
1
2
3
+ Addedwinston@^3.10.0
+ Added@colors/colors@1.6.0(transitive)
+ Added@dabh/diagnostics@2.0.3(transitive)
+ Added@types/triple-beam@1.3.5(transitive)
+ Addedasync@3.2.6(transitive)
+ Addedcolor@3.2.1(transitive)
+ Addedcolor-convert@1.9.3(transitive)
+ Addedcolor-name@1.1.3(transitive)
+ Addedcolor-string@1.9.1(transitive)
+ Addedcolorspace@1.1.4(transitive)
+ Addedenabled@2.0.0(transitive)
+ Addedfecha@4.2.3(transitive)
+ Addedfn.name@1.1.0(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedis-arrayish@0.3.2(transitive)
+ Addedis-stream@2.0.1(transitive)
+ Addedkuler@2.0.0(transitive)
+ Addedlogform@2.7.0(transitive)
+ Addedms@2.1.3(transitive)
+ Addedone-time@1.0.0(transitive)
+ Addedreadable-stream@3.6.2(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedsafe-stable-stringify@2.5.0(transitive)
+ Addedsimple-swizzle@0.2.2(transitive)
+ Addedstack-trace@0.0.10(transitive)
+ Addedstring_decoder@1.3.0(transitive)
+ Addedtext-hex@1.0.0(transitive)
+ Addedtriple-beam@1.4.1(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
+ Addedwinston@3.17.0(transitive)
+ Addedwinston-transport@4.9.0(transitive)