timezest 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/dist/index.js +0 -90
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "timezest",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist/index.js"
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"format": "prettier --write .",
|
|
12
12
|
"clean": "if exist dist rmdir /s /q dist",
|
|
13
13
|
"prep-publish": "npm run clean && npm run build && copy package.json dist\\package.json && copy README.md dist\\README.md && copy LICENSE dist\\LICENSE",
|
|
14
|
-
"publish": "npm run prep-publish && npm publish dist
|
|
14
|
+
"publish": "npm run prep-publish && npm publish .\\dist"
|
|
15
15
|
},
|
|
16
16
|
"keywords": [],
|
|
17
17
|
"author": "",
|
package/dist/index.js
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.TimeZestAPI = void 0;
|
|
13
|
-
const schemas_1 = require("./entities/schemas");
|
|
14
|
-
const config_1 = require("./config/config");
|
|
15
|
-
const makeRequest_1 = require("./utils/makeRequest");
|
|
16
|
-
const endpoints_1 = require("./constants/endpoints");
|
|
17
|
-
const logger_1 = require("./utils/logger");
|
|
18
|
-
const makePaginatedRequest_1 = require("./utils/makePaginatedRequest");
|
|
19
|
-
class TimeZestAPI {
|
|
20
|
-
constructor(apiKey, options) {
|
|
21
|
-
this.getResources = (...args_1) => __awaiter(this, [...args_1], void 0, function* (filter = null) {
|
|
22
|
-
const response = yield (0, makePaginatedRequest_1.makePaginatedRequest)(this, endpoints_1.API_ENDPOINTS.RESOURCES, "GET", null, filter);
|
|
23
|
-
return response.map((item) => schemas_1.ResourceSchema.parse(item));
|
|
24
|
-
});
|
|
25
|
-
this.apiKey = apiKey;
|
|
26
|
-
this.config = {
|
|
27
|
-
logLevel: (options === null || options === void 0 ? void 0 : options.logLevel) || config_1.CONFIG.logLevel,
|
|
28
|
-
logger: (options === null || options === void 0 ? void 0 : options.logger) || config_1.CONFIG.logger,
|
|
29
|
-
baseUrl: (options === null || options === void 0 ? void 0 : options.baseUrl) || config_1.CONFIG.baseUrl,
|
|
30
|
-
maxRetryDelayMs: (options === null || options === void 0 ? void 0 : options.maxRetryDelayMs) || config_1.CONFIG.maxRetryDelayMs,
|
|
31
|
-
maxRetryTimeMs: (options === null || options === void 0 ? void 0 : options.maxRetryTimeMs) || config_1.CONFIG.maxRetryTimeMs,
|
|
32
|
-
};
|
|
33
|
-
this.log = (0, logger_1.buildLogger)(this.config.logger, this.config.logLevel);
|
|
34
|
-
// Log the initialization of the API client but remove apiKey
|
|
35
|
-
this.log("info", "TimeZestAPI initialized");
|
|
36
|
-
this.log("debug", "TimeZestAPI initialized with custom config", Object.assign({}, options));
|
|
37
|
-
this.log("debug", "TimeZestAPI initialized with final config", Object.assign({}, this.config));
|
|
38
|
-
// Wrap methods with logging middleware using the instance's log method
|
|
39
|
-
this.getResources = (0, logger_1.withLogging)(this.getResources.bind(this), this, "getResources");
|
|
40
|
-
this.getAgents = (0, logger_1.withLogging)(this.getAgents.bind(this), this, "getAgents");
|
|
41
|
-
this.getTeams = (0, logger_1.withLogging)(this.getTeams.bind(this), this, "getTeams");
|
|
42
|
-
this.getAppointmentTypes = (0, logger_1.withLogging)(this.getAppointmentTypes.bind(this), this, "getAppointmentTypes");
|
|
43
|
-
this.getSchedulingRequest = (0, logger_1.withLogging)(this.getSchedulingRequest.bind(this), this, "getSchedulingRequest");
|
|
44
|
-
this.createSchedulingRequest = (0, logger_1.withLogging)(this.createSchedulingRequest.bind(this), this, "createSchedulingRequest");
|
|
45
|
-
}
|
|
46
|
-
getApiKey() {
|
|
47
|
-
return this.apiKey;
|
|
48
|
-
}
|
|
49
|
-
getConfig() {
|
|
50
|
-
return this.config;
|
|
51
|
-
}
|
|
52
|
-
getAgents() {
|
|
53
|
-
return __awaiter(this, arguments, void 0, function* (filter = null) {
|
|
54
|
-
const response = yield (0, makePaginatedRequest_1.makePaginatedRequest)(this, endpoints_1.API_ENDPOINTS.AGENTS, "GET", null, filter);
|
|
55
|
-
return response.map((item) => schemas_1.AgentSchema.parse(item));
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
getTeams() {
|
|
59
|
-
return __awaiter(this, arguments, void 0, function* (filter = null) {
|
|
60
|
-
const response = yield (0, makePaginatedRequest_1.makePaginatedRequest)(this, endpoints_1.API_ENDPOINTS.TEAMS, "GET", null, filter);
|
|
61
|
-
return response.map((item) => schemas_1.TeamSchema.parse(item));
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
getAppointmentTypes() {
|
|
65
|
-
return __awaiter(this, arguments, void 0, function* (filter = null) {
|
|
66
|
-
const response = yield (0, makePaginatedRequest_1.makePaginatedRequest)(this, endpoints_1.API_ENDPOINTS.APPOINTMENT_TYPES, "GET", null, filter);
|
|
67
|
-
return response.map((item) => schemas_1.AppointmentTypeSchema.parse(item));
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
getSchedulingRequest(id) {
|
|
71
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
72
|
-
const response = yield (0, makeRequest_1.makeRequest)(this.log, this.apiKey, this.config.baseUrl, `${endpoints_1.API_ENDPOINTS.SCHEDULING_REQUESTS}/${id}`, "GET", null, this.config.maxRetryTimeMs, this.config.maxRetryDelayMs);
|
|
73
|
-
return schemas_1.SchedulingRequestSchema.parse(response);
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
getSchedulingRequests() {
|
|
77
|
-
return __awaiter(this, arguments, void 0, function* (filter = null) {
|
|
78
|
-
const response = yield (0, makePaginatedRequest_1.makePaginatedRequest)(this, endpoints_1.API_ENDPOINTS.SCHEDULING_REQUESTS, "GET", null, filter);
|
|
79
|
-
return response.map((item) => schemas_1.SchedulingRequestSchema.parse(item));
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
createSchedulingRequest(data) {
|
|
83
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
-
const response = yield (0, makeRequest_1.makeRequest)(this.log, this.apiKey, this.config.baseUrl, endpoints_1.API_ENDPOINTS.SCHEDULING_REQUESTS, "POST", data, this.config.maxRetryTimeMs, this.config.maxRetryDelayMs);
|
|
85
|
-
return response;
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
exports.TimeZestAPI = TimeZestAPI;
|
|
90
|
-
//# sourceMappingURL=index.js.map
|