@emilgroup/customer-sdk-node 1.0.0
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/.openapi-generator/FILES +35 -0
- package/.openapi-generator/VERSION +1 -0
- package/.openapi-generator-ignore +23 -0
- package/README.md +51 -0
- package/api/customers-api.ts +1284 -0
- package/api.ts +36 -0
- package/base.ts +187 -0
- package/common.ts +139 -0
- package/configuration.ts +118 -0
- package/dist/api/customers-api.d.ts +730 -0
- package/dist/api/customers-api.js +1095 -0
- package/dist/api.d.ts +16 -0
- package/dist/api.js +36 -0
- package/dist/base.d.ts +68 -0
- package/dist/base.js +251 -0
- package/dist/common.d.ts +66 -0
- package/dist/common.js +244 -0
- package/dist/configuration.d.ts +98 -0
- package/dist/configuration.js +45 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +35 -0
- package/dist/models/create-account-request-dto.d.ts +102 -0
- package/dist/models/create-account-request-dto.js +21 -0
- package/dist/models/create-customer-request-dto.d.ts +43 -0
- package/dist/models/create-customer-request-dto.js +15 -0
- package/dist/models/create-customer-response-class.d.ts +24 -0
- package/dist/models/create-customer-response-class.js +15 -0
- package/dist/models/forgot-password-request-dto.d.ts +30 -0
- package/dist/models/forgot-password-request-dto.js +15 -0
- package/dist/models/get-policy-response-class.d.ts +25 -0
- package/dist/models/get-policy-response-class.js +15 -0
- package/dist/models/index.d.ts +21 -0
- package/dist/models/index.js +37 -0
- package/dist/models/invite-class.d.ts +54 -0
- package/dist/models/invite-class.js +15 -0
- package/dist/models/invite-customer-request-dto.d.ts +30 -0
- package/dist/models/invite-customer-request-dto.js +15 -0
- package/dist/models/invite-customer-response-class.d.ts +25 -0
- package/dist/models/invite-customer-response-class.js +15 -0
- package/dist/models/list-invoices-response-class.d.ts +30 -0
- package/dist/models/list-invoices-response-class.js +15 -0
- package/dist/models/list-policies-response-class.d.ts +31 -0
- package/dist/models/list-policies-response-class.js +15 -0
- package/dist/models/login-request-dto.d.ts +36 -0
- package/dist/models/login-request-dto.js +15 -0
- package/dist/models/login-response-class.d.ts +30 -0
- package/dist/models/login-response-class.js +15 -0
- package/dist/models/policy-class.d.ts +55 -0
- package/dist/models/policy-class.js +15 -0
- package/dist/models/policy-object-class.d.ts +30 -0
- package/dist/models/policy-object-class.js +15 -0
- package/dist/models/policy-premium-class.d.ts +43 -0
- package/dist/models/policy-premium-class.js +15 -0
- package/dist/models/policy-premium-item-class.d.ts +36 -0
- package/dist/models/policy-premium-item-class.js +15 -0
- package/dist/models/policy-version-class.d.ts +49 -0
- package/dist/models/policy-version-class.js +15 -0
- package/dist/models/refresh-token-dto.d.ts +30 -0
- package/dist/models/refresh-token-dto.js +15 -0
- package/dist/models/reset-password-by-customer-request-dto.d.ts +36 -0
- package/dist/models/reset-password-by-customer-request-dto.js +15 -0
- package/dist/models/timeslice-class.d.ts +56 -0
- package/dist/models/timeslice-class.js +15 -0
- package/dist/models/verify-customer-invite-response-class.d.ts +36 -0
- package/dist/models/verify-customer-invite-response-class.js +15 -0
- package/git_push.sh +57 -0
- package/index.ts +19 -0
- package/models/create-account-request-dto.ts +111 -0
- package/models/create-customer-request-dto.ts +49 -0
- package/models/create-customer-response-class.ts +30 -0
- package/models/forgot-password-request-dto.ts +36 -0
- package/models/get-policy-response-class.ts +31 -0
- package/models/index.ts +21 -0
- package/models/invite-class.ts +60 -0
- package/models/invite-customer-request-dto.ts +36 -0
- package/models/invite-customer-response-class.ts +31 -0
- package/models/list-invoices-response-class.ts +36 -0
- package/models/list-policies-response-class.ts +37 -0
- package/models/login-request-dto.ts +42 -0
- package/models/login-response-class.ts +36 -0
- package/models/policy-class.ts +61 -0
- package/models/policy-object-class.ts +36 -0
- package/models/policy-premium-class.ts +49 -0
- package/models/policy-premium-item-class.ts +42 -0
- package/models/policy-version-class.ts +55 -0
- package/models/refresh-token-dto.ts +36 -0
- package/models/reset-password-by-customer-request-dto.ts +42 -0
- package/models/timeslice-class.ts +62 -0
- package/models/verify-customer-invite-response-class.ts +42 -0
- package/package.json +29 -0
- package/tsconfig.json +22 -0
package/dist/api.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EMIL CustomerService
|
|
3
|
+
* The EMIL CustomerService API description
|
|
4
|
+
*
|
|
5
|
+
* The version of the OpenAPI document: 1.0
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
9
|
+
* https://openapi-generator.tech
|
|
10
|
+
* Do not edit the class manually.
|
|
11
|
+
*/
|
|
12
|
+
export * from './api/customers-api';
|
|
13
|
+
export declare enum Environment {
|
|
14
|
+
Production = "https://apiv2.emil.de",
|
|
15
|
+
Test = "https://apiv2-test.emil.de"
|
|
16
|
+
}
|
package/dist/api.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
/**
|
|
5
|
+
* EMIL CustomerService
|
|
6
|
+
* The EMIL CustomerService API description
|
|
7
|
+
*
|
|
8
|
+
* The version of the OpenAPI document: 1.0
|
|
9
|
+
*
|
|
10
|
+
*
|
|
11
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
12
|
+
* https://openapi-generator.tech
|
|
13
|
+
* Do not edit the class manually.
|
|
14
|
+
*/
|
|
15
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
18
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
19
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
20
|
+
}
|
|
21
|
+
Object.defineProperty(o, k2, desc);
|
|
22
|
+
}) : (function(o, m, k, k2) {
|
|
23
|
+
if (k2 === undefined) k2 = k;
|
|
24
|
+
o[k2] = m[k];
|
|
25
|
+
}));
|
|
26
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
27
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
28
|
+
};
|
|
29
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
exports.Environment = void 0;
|
|
31
|
+
__exportStar(require("./api/customers-api"), exports);
|
|
32
|
+
var Environment;
|
|
33
|
+
(function (Environment) {
|
|
34
|
+
Environment["Production"] = "https://apiv2.emil.de";
|
|
35
|
+
Environment["Test"] = "https://apiv2-test.emil.de";
|
|
36
|
+
})(Environment = exports.Environment || (exports.Environment = {}));
|
package/dist/base.d.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EMIL CustomerService
|
|
3
|
+
* The EMIL CustomerService API description
|
|
4
|
+
*
|
|
5
|
+
* The version of the OpenAPI document: 1.0
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
9
|
+
* https://openapi-generator.tech
|
|
10
|
+
* Do not edit the class manually.
|
|
11
|
+
*/
|
|
12
|
+
import { Configuration } from "./configuration";
|
|
13
|
+
import { AxiosInstance, AxiosRequestConfig } from 'axios';
|
|
14
|
+
export declare const BASE_PATH: string;
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
* @export
|
|
18
|
+
*/
|
|
19
|
+
export declare const COLLECTION_FORMATS: {
|
|
20
|
+
csv: string;
|
|
21
|
+
ssv: string;
|
|
22
|
+
tsv: string;
|
|
23
|
+
pipes: string;
|
|
24
|
+
};
|
|
25
|
+
export interface LoginClass {
|
|
26
|
+
accessToken: string;
|
|
27
|
+
permissions: Array<string>;
|
|
28
|
+
newPasswordRequired: boolean;
|
|
29
|
+
}
|
|
30
|
+
export declare enum Environment {
|
|
31
|
+
Production = "https://apiv2.emil.de",
|
|
32
|
+
Test = "https://apiv2-test.emil.de"
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
*
|
|
36
|
+
* @export
|
|
37
|
+
* @interface RequestArgs
|
|
38
|
+
*/
|
|
39
|
+
export interface RequestArgs {
|
|
40
|
+
url: string;
|
|
41
|
+
options: AxiosRequestConfig;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
*
|
|
45
|
+
* @export
|
|
46
|
+
* @class BaseAPI
|
|
47
|
+
*/
|
|
48
|
+
export declare class BaseAPI {
|
|
49
|
+
protected basePath: string;
|
|
50
|
+
protected axios: AxiosInstance;
|
|
51
|
+
protected configuration: Configuration | undefined;
|
|
52
|
+
constructor(configuration?: Configuration, basePath?: string, axios?: AxiosInstance);
|
|
53
|
+
selectEnvironment(env: Environment): void;
|
|
54
|
+
authorize(username: string, password: string, tenantSlug: string): Promise<void>;
|
|
55
|
+
refreshTokenInternal(): Promise<string>;
|
|
56
|
+
private extractRefreshToken;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
*
|
|
60
|
+
* @export
|
|
61
|
+
* @class RequiredError
|
|
62
|
+
* @extends {Error}
|
|
63
|
+
*/
|
|
64
|
+
export declare class RequiredError extends Error {
|
|
65
|
+
field: string;
|
|
66
|
+
name: "RequiredError";
|
|
67
|
+
constructor(field: string, msg?: string);
|
|
68
|
+
}
|
package/dist/base.js
ADDED
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
/**
|
|
5
|
+
* EMIL CustomerService
|
|
6
|
+
* The EMIL CustomerService API description
|
|
7
|
+
*
|
|
8
|
+
* The version of the OpenAPI document: 1.0
|
|
9
|
+
*
|
|
10
|
+
*
|
|
11
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
12
|
+
* https://openapi-generator.tech
|
|
13
|
+
* Do not edit the class manually.
|
|
14
|
+
*/
|
|
15
|
+
var __extends = (this && this.__extends) || (function () {
|
|
16
|
+
var extendStatics = function (d, b) {
|
|
17
|
+
extendStatics = Object.setPrototypeOf ||
|
|
18
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
19
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
20
|
+
return extendStatics(d, b);
|
|
21
|
+
};
|
|
22
|
+
return function (d, b) {
|
|
23
|
+
if (typeof b !== "function" && b !== null)
|
|
24
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
25
|
+
extendStatics(d, b);
|
|
26
|
+
function __() { this.constructor = d; }
|
|
27
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
28
|
+
};
|
|
29
|
+
})();
|
|
30
|
+
var __assign = (this && this.__assign) || function () {
|
|
31
|
+
__assign = Object.assign || function(t) {
|
|
32
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
33
|
+
s = arguments[i];
|
|
34
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
35
|
+
t[p] = s[p];
|
|
36
|
+
}
|
|
37
|
+
return t;
|
|
38
|
+
};
|
|
39
|
+
return __assign.apply(this, arguments);
|
|
40
|
+
};
|
|
41
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
42
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
43
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
44
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
45
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
46
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
47
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
51
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
52
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
53
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
54
|
+
function step(op) {
|
|
55
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
56
|
+
while (_) try {
|
|
57
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
58
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
59
|
+
switch (op[0]) {
|
|
60
|
+
case 0: case 1: t = op; break;
|
|
61
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
62
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
63
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
64
|
+
default:
|
|
65
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
66
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
67
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
68
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
69
|
+
if (t[2]) _.ops.pop();
|
|
70
|
+
_.trys.pop(); continue;
|
|
71
|
+
}
|
|
72
|
+
op = body.call(thisArg, _);
|
|
73
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
74
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
78
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
79
|
+
};
|
|
80
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
81
|
+
exports.RequiredError = exports.BaseAPI = exports.Environment = exports.COLLECTION_FORMATS = exports.BASE_PATH = void 0;
|
|
82
|
+
var configuration_1 = require("./configuration");
|
|
83
|
+
// Some imports not used depending on template conditions
|
|
84
|
+
// @ts-ignore
|
|
85
|
+
var axios_1 = __importDefault(require("axios"));
|
|
86
|
+
exports.BASE_PATH = "http://localhost".replace(/\/+$/, "");
|
|
87
|
+
/**
|
|
88
|
+
*
|
|
89
|
+
* @export
|
|
90
|
+
*/
|
|
91
|
+
exports.COLLECTION_FORMATS = {
|
|
92
|
+
csv: ",",
|
|
93
|
+
ssv: " ",
|
|
94
|
+
tsv: "\t",
|
|
95
|
+
pipes: "|",
|
|
96
|
+
};
|
|
97
|
+
var Environment;
|
|
98
|
+
(function (Environment) {
|
|
99
|
+
Environment["Production"] = "https://apiv2.emil.de";
|
|
100
|
+
Environment["Test"] = "https://apiv2-test.emil.de";
|
|
101
|
+
})(Environment = exports.Environment || (exports.Environment = {}));
|
|
102
|
+
/**
|
|
103
|
+
*
|
|
104
|
+
* @export
|
|
105
|
+
* @class BaseAPI
|
|
106
|
+
*/
|
|
107
|
+
var BaseAPI = /** @class */ (function () {
|
|
108
|
+
function BaseAPI(configuration, basePath, axios) {
|
|
109
|
+
if (basePath === void 0) { basePath = exports.BASE_PATH; }
|
|
110
|
+
if (axios === void 0) { axios = axios_1.default; }
|
|
111
|
+
var _this = this;
|
|
112
|
+
this.basePath = basePath;
|
|
113
|
+
this.axios = axios;
|
|
114
|
+
if (configuration) {
|
|
115
|
+
this.configuration = configuration;
|
|
116
|
+
this.basePath = configuration.basePath || this.basePath;
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
this.configuration = new configuration_1.Configuration({
|
|
120
|
+
basePath: this.basePath,
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
axios.interceptors.response.use(function (res) {
|
|
124
|
+
return res;
|
|
125
|
+
}, function (err) { return __awaiter(_this, void 0, void 0, function () {
|
|
126
|
+
var originalConfig, tokenString, accessToken, localVarHeaderParameter, _error_1;
|
|
127
|
+
return __generator(this, function (_a) {
|
|
128
|
+
switch (_a.label) {
|
|
129
|
+
case 0:
|
|
130
|
+
originalConfig = err.config;
|
|
131
|
+
if (!err.response) return [3 /*break*/, 5];
|
|
132
|
+
if (!(err.response.status === 401 && !originalConfig._retry)) return [3 /*break*/, 4];
|
|
133
|
+
originalConfig._retry = true;
|
|
134
|
+
_a.label = 1;
|
|
135
|
+
case 1:
|
|
136
|
+
_a.trys.push([1, 3, , 4]);
|
|
137
|
+
return [4 /*yield*/, this.refreshTokenInternal()];
|
|
138
|
+
case 2:
|
|
139
|
+
tokenString = _a.sent();
|
|
140
|
+
accessToken = "Bearer ".concat(tokenString);
|
|
141
|
+
localVarHeaderParameter = {};
|
|
142
|
+
localVarHeaderParameter['Authorization'] = accessToken;
|
|
143
|
+
originalConfig.headers = __assign(__assign({}, originalConfig.headers), localVarHeaderParameter);
|
|
144
|
+
this.configuration.accessToken = accessToken;
|
|
145
|
+
return [2 /*return*/, axios(originalConfig)];
|
|
146
|
+
case 3:
|
|
147
|
+
_error_1 = _a.sent();
|
|
148
|
+
if (_error_1.response && _error_1.response.data) {
|
|
149
|
+
return [2 /*return*/, Promise.reject(_error_1.response.data)];
|
|
150
|
+
}
|
|
151
|
+
return [2 /*return*/, Promise.reject(_error_1)];
|
|
152
|
+
case 4:
|
|
153
|
+
if (err.response.status === 403 && err.response.data) {
|
|
154
|
+
return [2 /*return*/, Promise.reject(err.response.data)];
|
|
155
|
+
}
|
|
156
|
+
_a.label = 5;
|
|
157
|
+
case 5: return [2 /*return*/, Promise.reject(err)];
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
}); });
|
|
161
|
+
}
|
|
162
|
+
BaseAPI.prototype.selectEnvironment = function (env) {
|
|
163
|
+
this.configuration.basePath = env;
|
|
164
|
+
};
|
|
165
|
+
BaseAPI.prototype.authorize = function (username, password, tenantSlug) {
|
|
166
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
167
|
+
var options, response, accessToken, refreshToken;
|
|
168
|
+
return __generator(this, function (_a) {
|
|
169
|
+
switch (_a.label) {
|
|
170
|
+
case 0:
|
|
171
|
+
options = {
|
|
172
|
+
method: 'POST',
|
|
173
|
+
url: "".concat(Environment.Test, "/v1/customers/login"),
|
|
174
|
+
headers: { 'Content-Type': 'application/json' },
|
|
175
|
+
data: {
|
|
176
|
+
username: username,
|
|
177
|
+
password: password,
|
|
178
|
+
tenantSlug: tenantSlug,
|
|
179
|
+
},
|
|
180
|
+
withCredentials: true,
|
|
181
|
+
};
|
|
182
|
+
return [4 /*yield*/, axios_1.default.request(options)];
|
|
183
|
+
case 1:
|
|
184
|
+
response = _a.sent();
|
|
185
|
+
accessToken = response.data.accessToken;
|
|
186
|
+
refreshToken = this.extractRefreshToken(response);
|
|
187
|
+
this.configuration.username = username;
|
|
188
|
+
this.configuration.tenantSlug = tenantSlug;
|
|
189
|
+
this.configuration.accessToken = "Bearer ".concat(accessToken);
|
|
190
|
+
this.configuration.refreshToken = refreshToken;
|
|
191
|
+
return [2 /*return*/];
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
};
|
|
196
|
+
BaseAPI.prototype.refreshTokenInternal = function () {
|
|
197
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
198
|
+
var _a, username, refreshToken, tenantSlug, options, accessToken;
|
|
199
|
+
return __generator(this, function (_b) {
|
|
200
|
+
switch (_b.label) {
|
|
201
|
+
case 0:
|
|
202
|
+
_a = this.configuration, username = _a.username, refreshToken = _a.refreshToken, tenantSlug = _a.tenantSlug;
|
|
203
|
+
if (!username || !refreshToken) {
|
|
204
|
+
return [2 /*return*/, ''];
|
|
205
|
+
}
|
|
206
|
+
options = {
|
|
207
|
+
method: 'POST',
|
|
208
|
+
url: "".concat(Environment.Test, "/v1/customers/refresh-token"),
|
|
209
|
+
headers: {
|
|
210
|
+
'Content-Type': 'application/json',
|
|
211
|
+
Cookie: refreshToken,
|
|
212
|
+
},
|
|
213
|
+
data: { username: username, tenantSlug: tenantSlug },
|
|
214
|
+
withCredentials: true,
|
|
215
|
+
};
|
|
216
|
+
return [4 /*yield*/, axios_1.default.request(options)];
|
|
217
|
+
case 1:
|
|
218
|
+
accessToken = (_b.sent()).data.accessToken;
|
|
219
|
+
return [2 /*return*/, accessToken];
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
};
|
|
224
|
+
BaseAPI.prototype.extractRefreshToken = function (response) {
|
|
225
|
+
if (response.headers && response.headers['set-cookie']
|
|
226
|
+
&& response.headers['set-cookie'].length > 0) {
|
|
227
|
+
return "".concat(response.headers['set-cookie'][0].split(';')[0], ";");
|
|
228
|
+
}
|
|
229
|
+
return '';
|
|
230
|
+
};
|
|
231
|
+
return BaseAPI;
|
|
232
|
+
}());
|
|
233
|
+
exports.BaseAPI = BaseAPI;
|
|
234
|
+
;
|
|
235
|
+
/**
|
|
236
|
+
*
|
|
237
|
+
* @export
|
|
238
|
+
* @class RequiredError
|
|
239
|
+
* @extends {Error}
|
|
240
|
+
*/
|
|
241
|
+
var RequiredError = /** @class */ (function (_super) {
|
|
242
|
+
__extends(RequiredError, _super);
|
|
243
|
+
function RequiredError(field, msg) {
|
|
244
|
+
var _this = _super.call(this, msg) || this;
|
|
245
|
+
_this.field = field;
|
|
246
|
+
_this.name = "RequiredError";
|
|
247
|
+
return _this;
|
|
248
|
+
}
|
|
249
|
+
return RequiredError;
|
|
250
|
+
}(Error));
|
|
251
|
+
exports.RequiredError = RequiredError;
|
package/dist/common.d.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EMIL CustomerService
|
|
3
|
+
* The EMIL CustomerService API description
|
|
4
|
+
*
|
|
5
|
+
* The version of the OpenAPI document: 1.0
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
9
|
+
* https://openapi-generator.tech
|
|
10
|
+
* Do not edit the class manually.
|
|
11
|
+
*/
|
|
12
|
+
import { Configuration } from "./configuration";
|
|
13
|
+
import { RequestArgs } from "./base";
|
|
14
|
+
import { AxiosInstance, AxiosResponse } from 'axios';
|
|
15
|
+
import { URL } from 'url';
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* @export
|
|
19
|
+
*/
|
|
20
|
+
export declare const DUMMY_BASE_URL = "https://example.com";
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
* @throws {RequiredError}
|
|
24
|
+
* @export
|
|
25
|
+
*/
|
|
26
|
+
export declare const assertParamExists: (functionName: string, paramName: string, paramValue: unknown) => void;
|
|
27
|
+
/**
|
|
28
|
+
*
|
|
29
|
+
* @export
|
|
30
|
+
*/
|
|
31
|
+
export declare const setApiKeyToObject: (object: any, keyParamName: string, configuration?: Configuration) => Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
*
|
|
34
|
+
* @export
|
|
35
|
+
*/
|
|
36
|
+
export declare const setBasicAuthToObject: (object: any, configuration?: Configuration) => void;
|
|
37
|
+
/**
|
|
38
|
+
*
|
|
39
|
+
* @export
|
|
40
|
+
*/
|
|
41
|
+
export declare const setBearerAuthToObject: (object: any, configuration?: Configuration) => Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
*
|
|
44
|
+
* @export
|
|
45
|
+
*/
|
|
46
|
+
export declare const setOAuthToObject: (object: any, name: string, scopes: string[], configuration?: Configuration) => Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
*
|
|
49
|
+
* @export
|
|
50
|
+
*/
|
|
51
|
+
export declare const setSearchParams: (url: URL, ...objects: any[]) => void;
|
|
52
|
+
/**
|
|
53
|
+
*
|
|
54
|
+
* @export
|
|
55
|
+
*/
|
|
56
|
+
export declare const serializeDataIfNeeded: (value: any, requestOptions: any, configuration?: Configuration) => any;
|
|
57
|
+
/**
|
|
58
|
+
*
|
|
59
|
+
* @export
|
|
60
|
+
*/
|
|
61
|
+
export declare const toPathString: (url: URL) => string;
|
|
62
|
+
/**
|
|
63
|
+
*
|
|
64
|
+
* @export
|
|
65
|
+
*/
|
|
66
|
+
export declare const createRequestFunction: (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) => <T = unknown, R = AxiosResponse<T, any>>(axios?: AxiosInstance, basePath?: string) => Promise<R>;
|
package/dist/common.js
ADDED
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
/**
|
|
5
|
+
* EMIL CustomerService
|
|
6
|
+
* The EMIL CustomerService API description
|
|
7
|
+
*
|
|
8
|
+
* The version of the OpenAPI document: 1.0
|
|
9
|
+
*
|
|
10
|
+
*
|
|
11
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
12
|
+
* https://openapi-generator.tech
|
|
13
|
+
* Do not edit the class manually.
|
|
14
|
+
*/
|
|
15
|
+
var __assign = (this && this.__assign) || function () {
|
|
16
|
+
__assign = Object.assign || function(t) {
|
|
17
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
18
|
+
s = arguments[i];
|
|
19
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
20
|
+
t[p] = s[p];
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
};
|
|
24
|
+
return __assign.apply(this, arguments);
|
|
25
|
+
};
|
|
26
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
27
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
28
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
29
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
30
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
31
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
32
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
36
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
37
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
38
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
39
|
+
function step(op) {
|
|
40
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
41
|
+
while (_) try {
|
|
42
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
43
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
44
|
+
switch (op[0]) {
|
|
45
|
+
case 0: case 1: t = op; break;
|
|
46
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
47
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
48
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
49
|
+
default:
|
|
50
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
51
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
52
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
53
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
54
|
+
if (t[2]) _.ops.pop();
|
|
55
|
+
_.trys.pop(); continue;
|
|
56
|
+
}
|
|
57
|
+
op = body.call(thisArg, _);
|
|
58
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
59
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
63
|
+
exports.createRequestFunction = exports.toPathString = exports.serializeDataIfNeeded = exports.setSearchParams = exports.setOAuthToObject = exports.setBearerAuthToObject = exports.setBasicAuthToObject = exports.setApiKeyToObject = exports.assertParamExists = exports.DUMMY_BASE_URL = void 0;
|
|
64
|
+
var base_1 = require("./base");
|
|
65
|
+
var url_1 = require("url");
|
|
66
|
+
/**
|
|
67
|
+
*
|
|
68
|
+
* @export
|
|
69
|
+
*/
|
|
70
|
+
exports.DUMMY_BASE_URL = 'https://example.com';
|
|
71
|
+
/**
|
|
72
|
+
*
|
|
73
|
+
* @throws {RequiredError}
|
|
74
|
+
* @export
|
|
75
|
+
*/
|
|
76
|
+
var assertParamExists = function (functionName, paramName, paramValue) {
|
|
77
|
+
if (paramValue === null || paramValue === undefined) {
|
|
78
|
+
throw new base_1.RequiredError(paramName, "Required parameter ".concat(paramName, " was null or undefined when calling ").concat(functionName, "."));
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
exports.assertParamExists = assertParamExists;
|
|
82
|
+
/**
|
|
83
|
+
*
|
|
84
|
+
* @export
|
|
85
|
+
*/
|
|
86
|
+
var setApiKeyToObject = function (object, keyParamName, configuration) {
|
|
87
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
88
|
+
var localVarApiKeyValue, _a;
|
|
89
|
+
return __generator(this, function (_b) {
|
|
90
|
+
switch (_b.label) {
|
|
91
|
+
case 0:
|
|
92
|
+
if (!(configuration && configuration.apiKey)) return [3 /*break*/, 5];
|
|
93
|
+
if (!(typeof configuration.apiKey === 'function')) return [3 /*break*/, 2];
|
|
94
|
+
return [4 /*yield*/, configuration.apiKey(keyParamName)];
|
|
95
|
+
case 1:
|
|
96
|
+
_a = _b.sent();
|
|
97
|
+
return [3 /*break*/, 4];
|
|
98
|
+
case 2: return [4 /*yield*/, configuration.apiKey];
|
|
99
|
+
case 3:
|
|
100
|
+
_a = _b.sent();
|
|
101
|
+
_b.label = 4;
|
|
102
|
+
case 4:
|
|
103
|
+
localVarApiKeyValue = _a;
|
|
104
|
+
object[keyParamName] = localVarApiKeyValue;
|
|
105
|
+
_b.label = 5;
|
|
106
|
+
case 5: return [2 /*return*/];
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
exports.setApiKeyToObject = setApiKeyToObject;
|
|
112
|
+
/**
|
|
113
|
+
*
|
|
114
|
+
* @export
|
|
115
|
+
*/
|
|
116
|
+
var setBasicAuthToObject = function (object, configuration) {
|
|
117
|
+
if (configuration && (configuration.username || configuration.password)) {
|
|
118
|
+
object["auth"] = { username: configuration.username, password: configuration.password };
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
exports.setBasicAuthToObject = setBasicAuthToObject;
|
|
122
|
+
/**
|
|
123
|
+
*
|
|
124
|
+
* @export
|
|
125
|
+
*/
|
|
126
|
+
var setBearerAuthToObject = function (object, configuration) {
|
|
127
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
128
|
+
var accessToken, _a;
|
|
129
|
+
return __generator(this, function (_b) {
|
|
130
|
+
switch (_b.label) {
|
|
131
|
+
case 0:
|
|
132
|
+
if (!(configuration && configuration.accessToken)) return [3 /*break*/, 5];
|
|
133
|
+
if (!(typeof configuration.accessToken === 'function')) return [3 /*break*/, 2];
|
|
134
|
+
return [4 /*yield*/, configuration.accessToken()];
|
|
135
|
+
case 1:
|
|
136
|
+
_a = _b.sent();
|
|
137
|
+
return [3 /*break*/, 4];
|
|
138
|
+
case 2: return [4 /*yield*/, configuration.accessToken];
|
|
139
|
+
case 3:
|
|
140
|
+
_a = _b.sent();
|
|
141
|
+
_b.label = 4;
|
|
142
|
+
case 4:
|
|
143
|
+
accessToken = _a;
|
|
144
|
+
object["Authorization"] = "Bearer " + accessToken;
|
|
145
|
+
_b.label = 5;
|
|
146
|
+
case 5: return [2 /*return*/];
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
};
|
|
151
|
+
exports.setBearerAuthToObject = setBearerAuthToObject;
|
|
152
|
+
/**
|
|
153
|
+
*
|
|
154
|
+
* @export
|
|
155
|
+
*/
|
|
156
|
+
var setOAuthToObject = function (object, name, scopes, configuration) {
|
|
157
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
158
|
+
var localVarAccessTokenValue, _a;
|
|
159
|
+
return __generator(this, function (_b) {
|
|
160
|
+
switch (_b.label) {
|
|
161
|
+
case 0:
|
|
162
|
+
if (!(configuration && configuration.accessToken)) return [3 /*break*/, 5];
|
|
163
|
+
if (!(typeof configuration.accessToken === 'function')) return [3 /*break*/, 2];
|
|
164
|
+
return [4 /*yield*/, configuration.accessToken(name, scopes)];
|
|
165
|
+
case 1:
|
|
166
|
+
_a = _b.sent();
|
|
167
|
+
return [3 /*break*/, 4];
|
|
168
|
+
case 2: return [4 /*yield*/, configuration.accessToken];
|
|
169
|
+
case 3:
|
|
170
|
+
_a = _b.sent();
|
|
171
|
+
_b.label = 4;
|
|
172
|
+
case 4:
|
|
173
|
+
localVarAccessTokenValue = _a;
|
|
174
|
+
object["Authorization"] = "Bearer " + localVarAccessTokenValue;
|
|
175
|
+
_b.label = 5;
|
|
176
|
+
case 5: return [2 /*return*/];
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
};
|
|
181
|
+
exports.setOAuthToObject = setOAuthToObject;
|
|
182
|
+
/**
|
|
183
|
+
*
|
|
184
|
+
* @export
|
|
185
|
+
*/
|
|
186
|
+
var setSearchParams = function (url) {
|
|
187
|
+
var objects = [];
|
|
188
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
189
|
+
objects[_i - 1] = arguments[_i];
|
|
190
|
+
}
|
|
191
|
+
var searchParams = new url_1.URLSearchParams(url.search);
|
|
192
|
+
for (var _a = 0, objects_1 = objects; _a < objects_1.length; _a++) {
|
|
193
|
+
var object = objects_1[_a];
|
|
194
|
+
for (var key in object) {
|
|
195
|
+
if (Array.isArray(object[key])) {
|
|
196
|
+
searchParams.delete(key);
|
|
197
|
+
for (var _b = 0, _c = object[key]; _b < _c.length; _b++) {
|
|
198
|
+
var item = _c[_b];
|
|
199
|
+
searchParams.append(key, item);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
searchParams.set(key, object[key]);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
url.search = searchParams.toString();
|
|
208
|
+
};
|
|
209
|
+
exports.setSearchParams = setSearchParams;
|
|
210
|
+
/**
|
|
211
|
+
*
|
|
212
|
+
* @export
|
|
213
|
+
*/
|
|
214
|
+
var serializeDataIfNeeded = function (value, requestOptions, configuration) {
|
|
215
|
+
var nonString = typeof value !== 'string';
|
|
216
|
+
var needsSerialization = nonString && configuration && configuration.isJsonMime
|
|
217
|
+
? configuration.isJsonMime(requestOptions.headers['Content-Type'])
|
|
218
|
+
: nonString;
|
|
219
|
+
return needsSerialization
|
|
220
|
+
? JSON.stringify(value !== undefined ? value : {})
|
|
221
|
+
: (value || "");
|
|
222
|
+
};
|
|
223
|
+
exports.serializeDataIfNeeded = serializeDataIfNeeded;
|
|
224
|
+
/**
|
|
225
|
+
*
|
|
226
|
+
* @export
|
|
227
|
+
*/
|
|
228
|
+
var toPathString = function (url) {
|
|
229
|
+
return url.pathname + url.search + url.hash;
|
|
230
|
+
};
|
|
231
|
+
exports.toPathString = toPathString;
|
|
232
|
+
/**
|
|
233
|
+
*
|
|
234
|
+
* @export
|
|
235
|
+
*/
|
|
236
|
+
var createRequestFunction = function (axiosArgs, globalAxios, BASE_PATH, configuration) {
|
|
237
|
+
return function (axios, basePath) {
|
|
238
|
+
if (axios === void 0) { axios = globalAxios; }
|
|
239
|
+
if (basePath === void 0) { basePath = BASE_PATH; }
|
|
240
|
+
var axiosRequestArgs = __assign(__assign({}, axiosArgs.options), { url: ((configuration === null || configuration === void 0 ? void 0 : configuration.basePath) || basePath) + axiosArgs.url });
|
|
241
|
+
return axios.request(axiosRequestArgs);
|
|
242
|
+
};
|
|
243
|
+
};
|
|
244
|
+
exports.createRequestFunction = createRequestFunction;
|