@emilgroup/customer-sdk-node 1.24.0 → 1.25.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.
Files changed (208) hide show
  1. package/README.md +2 -2
  2. package/models/claim-class.ts +6 -0
  3. package/models/policy-class.ts +12 -0
  4. package/package.json +2 -2
  5. package/dist/api/authentication-api.d.ts +0 -332
  6. package/dist/api/authentication-api.js +0 -604
  7. package/dist/api/claims-api.d.ts +0 -431
  8. package/dist/api/claims-api.js +0 -670
  9. package/dist/api/customers-api.d.ts +0 -271
  10. package/dist/api/customers-api.js +0 -425
  11. package/dist/api/default-api.d.ts +0 -66
  12. package/dist/api/default-api.js +0 -200
  13. package/dist/api/documents-api.d.ts +0 -262
  14. package/dist/api/documents-api.js +0 -417
  15. package/dist/api/invites-api.d.ts +0 -249
  16. package/dist/api/invites-api.js +0 -456
  17. package/dist/api/invoices-api.d.ts +0 -150
  18. package/dist/api/invoices-api.js +0 -253
  19. package/dist/api/leads-api.d.ts +0 -365
  20. package/dist/api/leads-api.js +0 -571
  21. package/dist/api/payments-api.d.ts +0 -162
  22. package/dist/api/payments-api.js +0 -306
  23. package/dist/api/policies-api.d.ts +0 -578
  24. package/dist/api/policies-api.js +0 -808
  25. package/dist/api/products-api.d.ts +0 -215
  26. package/dist/api/products-api.js +0 -341
  27. package/dist/api.d.ts +0 -22
  28. package/dist/api.js +0 -40
  29. package/dist/base.d.ts +0 -82
  30. package/dist/base.js +0 -502
  31. package/dist/common.d.ts +0 -66
  32. package/dist/common.js +0 -244
  33. package/dist/configuration.d.ts +0 -98
  34. package/dist/configuration.js +0 -45
  35. package/dist/index.d.ts +0 -15
  36. package/dist/index.js +0 -36
  37. package/dist/models/account-class.d.ts +0 -169
  38. package/dist/models/account-class.js +0 -26
  39. package/dist/models/account-policy-class.d.ts +0 -30
  40. package/dist/models/account-policy-class.js +0 -15
  41. package/dist/models/authentication-result-class.d.ts +0 -30
  42. package/dist/models/authentication-result-class.js +0 -15
  43. package/dist/models/claim-class.d.ts +0 -150
  44. package/dist/models/claim-class.js +0 -15
  45. package/dist/models/complete-braintree-payment-setup-request-dto.d.ts +0 -48
  46. package/dist/models/complete-braintree-payment-setup-request-dto.js +0 -15
  47. package/dist/models/complete-payment-setup-psp-request.d.ts +0 -32
  48. package/dist/models/complete-payment-setup-psp-request.js +0 -15
  49. package/dist/models/complete-payment-setup-response-class.d.ts +0 -24
  50. package/dist/models/complete-payment-setup-response-class.js +0 -15
  51. package/dist/models/complete-stripe-payment-setup-request-dto.d.ts +0 -60
  52. package/dist/models/complete-stripe-payment-setup-request-dto.js +0 -15
  53. package/dist/models/create-account-request-dto.d.ts +0 -132
  54. package/dist/models/create-account-request-dto.js +0 -31
  55. package/dist/models/create-bank-account-request-dto.d.ts +0 -30
  56. package/dist/models/create-bank-account-request-dto.js +0 -15
  57. package/dist/models/create-customer-claim-request-dto.d.ts +0 -114
  58. package/dist/models/create-customer-claim-request-dto.js +0 -15
  59. package/dist/models/create-customer-claim-response-class.d.ts +0 -25
  60. package/dist/models/create-customer-claim-response-class.js +0 -15
  61. package/dist/models/create-customer-request-dto.d.ts +0 -43
  62. package/dist/models/create-customer-request-dto.js +0 -15
  63. package/dist/models/create-customer-response-class.d.ts +0 -25
  64. package/dist/models/create-customer-response-class.js +0 -15
  65. package/dist/models/create-lead-request-dto.d.ts +0 -83
  66. package/dist/models/create-lead-request-dto.js +0 -15
  67. package/dist/models/create-lead-response-class.d.ts +0 -25
  68. package/dist/models/create-lead-response-class.js +0 -15
  69. package/dist/models/create-payment-method-request-dto.d.ts +0 -31
  70. package/dist/models/create-payment-method-request-dto.js +0 -15
  71. package/dist/models/create-policy-request-dto.d.ts +0 -56
  72. package/dist/models/create-policy-request-dto.js +0 -15
  73. package/dist/models/create-presigned-post-response-class.d.ts +0 -30
  74. package/dist/models/create-presigned-post-response-class.js +0 -15
  75. package/dist/models/customer-class.d.ts +0 -73
  76. package/dist/models/customer-class.js +0 -15
  77. package/dist/models/customer-document-class.d.ts +0 -99
  78. package/dist/models/customer-document-class.js +0 -36
  79. package/dist/models/customer-product-class.d.ts +0 -54
  80. package/dist/models/customer-product-class.js +0 -15
  81. package/dist/models/forgot-password-request-dto.d.ts +0 -30
  82. package/dist/models/forgot-password-request-dto.js +0 -15
  83. package/dist/models/get-customer-claim-response-class.d.ts +0 -25
  84. package/dist/models/get-customer-claim-response-class.js +0 -15
  85. package/dist/models/get-customer-document-download-url-response-class.d.ts +0 -24
  86. package/dist/models/get-customer-document-download-url-response-class.js +0 -15
  87. package/dist/models/get-customer-response-class.d.ts +0 -25
  88. package/dist/models/get-customer-response-class.js +0 -15
  89. package/dist/models/get-lead-response-class.d.ts +0 -25
  90. package/dist/models/get-lead-response-class.js +0 -15
  91. package/dist/models/get-policy-response-class.d.ts +0 -25
  92. package/dist/models/get-policy-response-class.js +0 -15
  93. package/dist/models/get-product-response-class.d.ts +0 -25
  94. package/dist/models/get-product-response-class.js +0 -15
  95. package/dist/models/grpc-update-lead-request-dto.d.ts +0 -50
  96. package/dist/models/grpc-update-lead-request-dto.js +0 -15
  97. package/dist/models/index.d.ts +0 -85
  98. package/dist/models/index.js +0 -101
  99. package/dist/models/initiate-auth-request-dto.d.ts +0 -36
  100. package/dist/models/initiate-auth-request-dto.js +0 -15
  101. package/dist/models/initiate-auth-response-class.d.ts +0 -43
  102. package/dist/models/initiate-auth-response-class.js +0 -15
  103. package/dist/models/initiate-braintree-payment-setup-response-class.d.ts +0 -24
  104. package/dist/models/initiate-braintree-payment-setup-response-class.js +0 -15
  105. package/dist/models/initiate-payment-setup-response-class.d.ts +0 -32
  106. package/dist/models/initiate-payment-setup-response-class.js +0 -15
  107. package/dist/models/initiate-stripe-payment-setup-response-class.d.ts +0 -30
  108. package/dist/models/initiate-stripe-payment-setup-response-class.js +0 -15
  109. package/dist/models/inline-response200.d.ts +0 -54
  110. package/dist/models/inline-response200.js +0 -15
  111. package/dist/models/inline-response503.d.ts +0 -54
  112. package/dist/models/inline-response503.js +0 -15
  113. package/dist/models/invite-by-customer-request-dto.d.ts +0 -30
  114. package/dist/models/invite-by-customer-request-dto.js +0 -15
  115. package/dist/models/invite-by-customer-response-class.d.ts +0 -25
  116. package/dist/models/invite-by-customer-response-class.js +0 -15
  117. package/dist/models/invite-by-tenant-request-dto.d.ts +0 -24
  118. package/dist/models/invite-by-tenant-request-dto.js +0 -15
  119. package/dist/models/invite-by-tenant-response-class.d.ts +0 -25
  120. package/dist/models/invite-by-tenant-response-class.js +0 -15
  121. package/dist/models/invite-class.d.ts +0 -54
  122. package/dist/models/invite-class.js +0 -15
  123. package/dist/models/invoice-class.d.ts +0 -148
  124. package/dist/models/invoice-class.js +0 -28
  125. package/dist/models/lead-bank-account-class.d.ts +0 -30
  126. package/dist/models/lead-bank-account-class.js +0 -15
  127. package/dist/models/lead-class.d.ts +0 -121
  128. package/dist/models/lead-class.js +0 -15
  129. package/dist/models/list-customer-claims-response-class.d.ts +0 -31
  130. package/dist/models/list-customer-claims-response-class.js +0 -15
  131. package/dist/models/list-documents-response-class.d.ts +0 -31
  132. package/dist/models/list-documents-response-class.js +0 -15
  133. package/dist/models/list-invoices-response-class.d.ts +0 -31
  134. package/dist/models/list-invoices-response-class.js +0 -15
  135. package/dist/models/list-leads-response-class.d.ts +0 -43
  136. package/dist/models/list-leads-response-class.js +0 -15
  137. package/dist/models/list-policies-response-class.d.ts +0 -43
  138. package/dist/models/list-policies-response-class.js +0 -15
  139. package/dist/models/list-products-response-class.d.ts +0 -31
  140. package/dist/models/list-products-response-class.js +0 -15
  141. package/dist/models/policy-class.d.ts +0 -68
  142. package/dist/models/policy-class.js +0 -15
  143. package/dist/models/policy-object-class.d.ts +0 -54
  144. package/dist/models/policy-object-class.js +0 -15
  145. package/dist/models/policy-object-dto.d.ts +0 -42
  146. package/dist/models/policy-object-dto.js +0 -15
  147. package/dist/models/policy-premium-class.d.ts +0 -43
  148. package/dist/models/policy-premium-class.js +0 -15
  149. package/dist/models/policy-premium-item-class.d.ts +0 -36
  150. package/dist/models/policy-premium-item-class.js +0 -15
  151. package/dist/models/policy-version-class.d.ts +0 -49
  152. package/dist/models/policy-version-class.js +0 -15
  153. package/dist/models/premium-override-dto.d.ts +0 -55
  154. package/dist/models/premium-override-dto.js +0 -27
  155. package/dist/models/premium-override-request-class.d.ts +0 -25
  156. package/dist/models/premium-override-request-class.js +0 -15
  157. package/dist/models/premium-override-request-dto.d.ts +0 -25
  158. package/dist/models/premium-override-request-dto.js +0 -15
  159. package/dist/models/refresh-token-dto.d.ts +0 -30
  160. package/dist/models/refresh-token-dto.js +0 -15
  161. package/dist/models/request-policy-update-request-dto.d.ts +0 -43
  162. package/dist/models/request-policy-update-request-dto.js +0 -15
  163. package/dist/models/request-policy-update-response-class.d.ts +0 -25
  164. package/dist/models/request-policy-update-response-class.js +0 -15
  165. package/dist/models/reset-password-by-customer-request-dto.d.ts +0 -36
  166. package/dist/models/reset-password-by-customer-request-dto.js +0 -15
  167. package/dist/models/respond-to-auth-challenge-class.d.ts +0 -43
  168. package/dist/models/respond-to-auth-challenge-class.js +0 -15
  169. package/dist/models/respond-to-auth-challenge-request-dto.d.ts +0 -42
  170. package/dist/models/respond-to-auth-challenge-request-dto.js +0 -15
  171. package/dist/models/sepa-dto.d.ts +0 -30
  172. package/dist/models/sepa-dto.js +0 -15
  173. package/dist/models/shared-customer-policy-object-request-dto.d.ts +0 -36
  174. package/dist/models/shared-customer-policy-object-request-dto.js +0 -15
  175. package/dist/models/shared-invoice-item-class.d.ts +0 -129
  176. package/dist/models/shared-invoice-item-class.js +0 -24
  177. package/dist/models/shared-invoice-status-class.d.ts +0 -47
  178. package/dist/models/shared-invoice-status-class.js +0 -20
  179. package/dist/models/terminate-customer-policy-request-dto.d.ts +0 -24
  180. package/dist/models/terminate-customer-policy-request-dto.js +0 -15
  181. package/dist/models/terminate-customer-policy-response-class.d.ts +0 -25
  182. package/dist/models/terminate-customer-policy-response-class.js +0 -15
  183. package/dist/models/timeslice-class.d.ts +0 -56
  184. package/dist/models/timeslice-class.js +0 -15
  185. package/dist/models/update-account-request-dto.d.ts +0 -113
  186. package/dist/models/update-account-request-dto.js +0 -25
  187. package/dist/models/update-customer-claim-request-dto.d.ts +0 -120
  188. package/dist/models/update-customer-claim-request-dto.js +0 -15
  189. package/dist/models/update-customer-claim-response-class.d.ts +0 -25
  190. package/dist/models/update-customer-claim-response-class.js +0 -15
  191. package/dist/models/update-customer-request-dto.d.ts +0 -31
  192. package/dist/models/update-customer-request-dto.js +0 -15
  193. package/dist/models/update-customer-response-class.d.ts +0 -25
  194. package/dist/models/update-customer-response-class.js +0 -15
  195. package/dist/models/update-lead-request-dto.d.ts +0 -44
  196. package/dist/models/update-lead-request-dto.js +0 -15
  197. package/dist/models/update-lead-response-class.d.ts +0 -25
  198. package/dist/models/update-lead-response-class.js +0 -15
  199. package/dist/models/upload-customer-claim-documents-request-dto.d.ts +0 -36
  200. package/dist/models/upload-customer-claim-documents-request-dto.js +0 -15
  201. package/dist/models/upload-customer-policy-documents-request-dto.d.ts +0 -47
  202. package/dist/models/upload-customer-policy-documents-request-dto.js +0 -20
  203. package/dist/models/uploaded-document-dto.d.ts +0 -24
  204. package/dist/models/uploaded-document-dto.js +0 -15
  205. package/dist/models/verify-customer-invite-response-class.d.ts +0 -36
  206. package/dist/models/verify-customer-invite-response-class.js +0 -15
  207. package/dist/models/withdraw-customer-policy-response-class.d.ts +0 -25
  208. package/dist/models/withdraw-customer-policy-response-class.js +0 -15
package/dist/base.d.ts DELETED
@@ -1,82 +0,0 @@
1
- /**
2
- * EMIL CustomerService
3
- * The EMIL CustomerService API description
4
- *
5
- * The version of the OpenAPI document: 1.0
6
- * Contact: kontakt@emil.de
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, AxiosResponse } from 'axios';
14
- import { InitiateAuthResponseClass, RespondToAuthChallengeClass, RespondToAuthChallengeRequestDto } from "./models";
15
- export declare const BASE_PATH: string;
16
- /**
17
- *
18
- * @export
19
- */
20
- export declare const COLLECTION_FORMATS: {
21
- csv: string;
22
- ssv: string;
23
- tsv: string;
24
- pipes: string;
25
- };
26
- export interface LoginClass {
27
- accessToken: string;
28
- permissions: Array<string>;
29
- }
30
- export declare enum Environment {
31
- Production = "https://apiv2.emil.de",
32
- Test = "https://apiv2-test.emil.de",
33
- Development = "https://apiv2-dev.emil.de",
34
- ProductionZurich = "https://eu-central-2.apiv2.emil.de"
35
- }
36
- export declare function resetRetry(): void;
37
- /**
38
- *
39
- * @export
40
- * @interface RequestArgs
41
- */
42
- export interface RequestArgs {
43
- url: string;
44
- options: AxiosRequestConfig;
45
- }
46
- /**
47
- *
48
- * @export
49
- * @class BaseAPI
50
- */
51
- export declare class BaseAPI {
52
- protected basePath: string;
53
- protected axios: AxiosInstance;
54
- protected configuration: Configuration | undefined;
55
- private username?;
56
- private password?;
57
- private isCustomerToken;
58
- constructor(configuration?: Configuration, basePath?: string, axios?: AxiosInstance);
59
- initialize(env?: Environment): Promise<void>;
60
- private loadCredentials;
61
- private readConfigFile;
62
- private readEnvVariables;
63
- selectEnvironment(env: Environment): void;
64
- authorize(username: string, password: string): Promise<void>;
65
- initiateAuthorization(username: string, password: string, tenantSlug: string): Promise<AxiosResponse<InitiateAuthResponseClass>>;
66
- respondToAuthorizationChallenge(respondToAuthChallengeRequestDto: RespondToAuthChallengeRequestDto): Promise<AxiosResponse<RespondToAuthChallengeClass>>;
67
- refreshTokenTenant(): Promise<string>;
68
- refreshTokenCustomer(): Promise<string>;
69
- private extractRefreshToken;
70
- private attachInterceptor;
71
- }
72
- /**
73
- *
74
- * @export
75
- * @class RequiredError
76
- * @extends {Error}
77
- */
78
- export declare class RequiredError extends Error {
79
- field: string;
80
- name: "RequiredError";
81
- constructor(field: string, msg?: string);
82
- }
package/dist/base.js DELETED
@@ -1,502 +0,0 @@
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
- * Contact: kontakt@emil.de
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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
42
- if (k2 === undefined) k2 = k;
43
- var desc = Object.getOwnPropertyDescriptor(m, k);
44
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
45
- desc = { enumerable: true, get: function() { return m[k]; } };
46
- }
47
- Object.defineProperty(o, k2, desc);
48
- }) : (function(o, m, k, k2) {
49
- if (k2 === undefined) k2 = k;
50
- o[k2] = m[k];
51
- }));
52
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
53
- Object.defineProperty(o, "default", { enumerable: true, value: v });
54
- }) : function(o, v) {
55
- o["default"] = v;
56
- });
57
- var __importStar = (this && this.__importStar) || function (mod) {
58
- if (mod && mod.__esModule) return mod;
59
- var result = {};
60
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
61
- __setModuleDefault(result, mod);
62
- return result;
63
- };
64
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
65
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
66
- return new (P || (P = Promise))(function (resolve, reject) {
67
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
68
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
69
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
70
- step((generator = generator.apply(thisArg, _arguments || [])).next());
71
- });
72
- };
73
- var __generator = (this && this.__generator) || function (thisArg, body) {
74
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
75
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
76
- function verb(n) { return function (v) { return step([n, v]); }; }
77
- function step(op) {
78
- if (f) throw new TypeError("Generator is already executing.");
79
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
80
- 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;
81
- if (y = 0, t) op = [op[0] & 2, t.value];
82
- switch (op[0]) {
83
- case 0: case 1: t = op; break;
84
- case 4: _.label++; return { value: op[1], done: false };
85
- case 5: _.label++; y = op[1]; op = [0]; continue;
86
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
87
- default:
88
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
89
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
90
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
91
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
92
- if (t[2]) _.ops.pop();
93
- _.trys.pop(); continue;
94
- }
95
- op = body.call(thisArg, _);
96
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
97
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
98
- }
99
- };
100
- var __importDefault = (this && this.__importDefault) || function (mod) {
101
- return (mod && mod.__esModule) ? mod : { "default": mod };
102
- };
103
- Object.defineProperty(exports, "__esModule", { value: true });
104
- exports.RequiredError = exports.BaseAPI = exports.resetRetry = exports.Environment = exports.COLLECTION_FORMATS = exports.BASE_PATH = void 0;
105
- var configuration_1 = require("./configuration");
106
- // Some imports not used depending on template conditions
107
- // @ts-ignore
108
- var axios_1 = __importDefault(require("axios"));
109
- var fs = __importStar(require("fs"));
110
- var path = __importStar(require("path"));
111
- var os = __importStar(require("os"));
112
- exports.BASE_PATH = "https://apiv2.emil.de".replace(/\/+$/, "");
113
- var CONFIG_DIRECTORY = '.emil';
114
- var CONFIG_FILENAME = 'credentials';
115
- var KEY_USERNAME = 'emil_username';
116
- var KEY_PASSWORD = 'emil_password';
117
- var filePath = os.homedir() + path.sep + CONFIG_DIRECTORY + path.sep + CONFIG_FILENAME;
118
- /**
119
- *
120
- * @export
121
- */
122
- exports.COLLECTION_FORMATS = {
123
- csv: ",",
124
- ssv: " ",
125
- tsv: "\t",
126
- pipes: "|",
127
- };
128
- var Environment;
129
- (function (Environment) {
130
- Environment["Production"] = "https://apiv2.emil.de";
131
- Environment["Test"] = "https://apiv2-test.emil.de";
132
- Environment["Development"] = "https://apiv2-dev.emil.de";
133
- Environment["ProductionZurich"] = "https://eu-central-2.apiv2.emil.de";
134
- })(Environment = exports.Environment || (exports.Environment = {}));
135
- var _retry_count = 0;
136
- var _retry = null;
137
- function resetRetry() {
138
- _retry_count = 0;
139
- }
140
- exports.resetRetry = resetRetry;
141
- var NETWORK_ERROR_MESSAGE = "Network Error";
142
- /**
143
- *
144
- * @export
145
- * @class BaseAPI
146
- */
147
- var BaseAPI = /** @class */ (function () {
148
- function BaseAPI(configuration, basePath, axios) {
149
- if (basePath === void 0) { basePath = exports.BASE_PATH; }
150
- if (axios === void 0) { axios = axios_1.default; }
151
- this.basePath = basePath;
152
- this.axios = axios;
153
- this.isCustomerToken = false;
154
- if (configuration) {
155
- this.configuration = configuration;
156
- this.basePath = configuration.basePath || this.basePath;
157
- }
158
- else {
159
- this.configuration = new configuration_1.Configuration({
160
- basePath: this.basePath,
161
- });
162
- }
163
- this.attachInterceptor(axios);
164
- }
165
- BaseAPI.prototype.initialize = function (env) {
166
- if (env === void 0) { env = Environment.Production; }
167
- return __awaiter(this, void 0, void 0, function () {
168
- return __generator(this, function (_a) {
169
- switch (_a.label) {
170
- case 0:
171
- this.configuration.basePath = env;
172
- return [4 /*yield*/, this.loadCredentials()];
173
- case 1:
174
- _a.sent();
175
- if (!this.username) return [3 /*break*/, 3];
176
- return [4 /*yield*/, this.authorize(this.username, this.password)];
177
- case 2:
178
- _a.sent();
179
- this.password = null; // to avoid keeping password loaded in memory.
180
- _a.label = 3;
181
- case 3: return [2 /*return*/];
182
- }
183
- });
184
- });
185
- };
186
- BaseAPI.prototype.loadCredentials = function () {
187
- return __awaiter(this, void 0, void 0, function () {
188
- var error_1;
189
- return __generator(this, function (_a) {
190
- switch (_a.label) {
191
- case 0:
192
- _a.trys.push([0, 2, , 3]);
193
- return [4 /*yield*/, this.readConfigFile()];
194
- case 1:
195
- _a.sent();
196
- return [3 /*break*/, 3];
197
- case 2:
198
- error_1 = _a.sent();
199
- console.warn("No credentials file found. Check that ".concat(filePath, " exists."));
200
- return [3 /*break*/, 3];
201
- case 3:
202
- this.readEnvVariables();
203
- if (!this.username) {
204
- console.info("No credentials found in credentials file or environment variables. Either provide some or use \n authorize() function.");
205
- }
206
- return [2 /*return*/];
207
- }
208
- });
209
- });
210
- };
211
- BaseAPI.prototype.readConfigFile = function () {
212
- return __awaiter(this, void 0, void 0, function () {
213
- var file, lines;
214
- var _this = this;
215
- return __generator(this, function (_a) {
216
- switch (_a.label) {
217
- case 0: return [4 /*yield*/, fs.promises.readFile(filePath, 'utf-8')];
218
- case 1:
219
- file = _a.sent();
220
- lines = file.split(os.EOL)
221
- .filter(Boolean);
222
- lines.forEach(function (line) {
223
- if (line.startsWith(KEY_USERNAME)) {
224
- _this.username = line.length > KEY_USERNAME.length + 1 ? line.substring(KEY_USERNAME.length + 1) : '';
225
- }
226
- else if (line.startsWith(KEY_PASSWORD)) {
227
- _this.password = line.length > KEY_PASSWORD.length + 1 ? line.substring(KEY_PASSWORD.length + 1) : '';
228
- }
229
- });
230
- return [2 /*return*/];
231
- }
232
- });
233
- });
234
- };
235
- BaseAPI.prototype.readEnvVariables = function () {
236
- if (process.env.EMIL_USERNAME) {
237
- this.username = process.env.EMIL_USERNAME;
238
- this.password = process.env.EMIL_PASSWORD || '';
239
- return true;
240
- }
241
- return false;
242
- };
243
- BaseAPI.prototype.selectEnvironment = function (env) {
244
- this.configuration.basePath = env;
245
- };
246
- BaseAPI.prototype.authorize = function (username, password) {
247
- return __awaiter(this, void 0, void 0, function () {
248
- var options, response, accessToken, refreshToken;
249
- return __generator(this, function (_a) {
250
- switch (_a.label) {
251
- case 0:
252
- options = {
253
- method: 'POST',
254
- url: "".concat(this.configuration.basePath, "/authservice/v1/login"),
255
- headers: { 'Content-Type': 'application/json' },
256
- data: {
257
- username: username,
258
- password: password,
259
- },
260
- withCredentials: true,
261
- };
262
- return [4 /*yield*/, axios_1.default.request(options)];
263
- case 1:
264
- response = _a.sent();
265
- accessToken = response.data.accessToken;
266
- this.configuration.username = username;
267
- this.configuration.accessToken = "Bearer ".concat(accessToken);
268
- refreshToken = this.extractRefreshToken(response);
269
- this.configuration.refreshToken = refreshToken;
270
- return [2 /*return*/];
271
- }
272
- });
273
- });
274
- };
275
- BaseAPI.prototype.initiateAuthorization = function (username, password, tenantSlug) {
276
- return __awaiter(this, void 0, void 0, function () {
277
- var options, response, accessToken, refreshToken;
278
- return __generator(this, function (_a) {
279
- switch (_a.label) {
280
- case 0:
281
- options = {
282
- method: 'POST',
283
- url: "".concat(this.configuration.basePath, "/v1/customers/auth/initiate"),
284
- headers: { 'Content-Type': 'application/json' },
285
- data: {
286
- authFlow: "USER_PASSWORD_AUTH",
287
- authParameters: {
288
- "USERNAME": username,
289
- "PASSWORD": password,
290
- },
291
- tenantSlug: tenantSlug,
292
- },
293
- withCredentials: true,
294
- };
295
- return [4 /*yield*/, axios_1.default.request(options)];
296
- case 1:
297
- response = _a.sent();
298
- if (response.data.authenticationResult) {
299
- accessToken = response.data.authenticationResult.accessToken;
300
- this.configuration.username = username;
301
- this.configuration.tenantSlug = tenantSlug;
302
- this.configuration.accessToken = "Bearer ".concat(accessToken);
303
- this.isCustomerToken = true;
304
- refreshToken = this.extractRefreshToken(response);
305
- this.configuration.refreshToken = refreshToken;
306
- }
307
- return [2 /*return*/, response];
308
- }
309
- });
310
- });
311
- };
312
- BaseAPI.prototype.respondToAuthorizationChallenge = function (respondToAuthChallengeRequestDto) {
313
- return __awaiter(this, void 0, void 0, function () {
314
- var options, response, accessToken, refreshToken;
315
- return __generator(this, function (_a) {
316
- switch (_a.label) {
317
- case 0:
318
- options = {
319
- method: 'POST',
320
- url: "".concat(this.configuration.basePath, "/v1/customers/auth/respond"),
321
- headers: { 'Content-Type': 'application/json' },
322
- data: __assign({}, respondToAuthChallengeRequestDto),
323
- withCredentials: true,
324
- };
325
- return [4 /*yield*/, axios_1.default.request(options)];
326
- case 1:
327
- response = _a.sent();
328
- if (response.data.authenticationResult) {
329
- accessToken = response.data.authenticationResult.accessToken;
330
- this.configuration.accessToken = "Bearer ".concat(accessToken);
331
- this.isCustomerToken = true;
332
- refreshToken = this.extractRefreshToken(response);
333
- this.configuration.refreshToken = refreshToken;
334
- }
335
- return [2 /*return*/, response];
336
- }
337
- });
338
- });
339
- };
340
- BaseAPI.prototype.refreshTokenTenant = function () {
341
- return __awaiter(this, void 0, void 0, function () {
342
- var _a, username, refreshToken, options, accessToken;
343
- return __generator(this, function (_b) {
344
- switch (_b.label) {
345
- case 0:
346
- _a = this.configuration, username = _a.username, refreshToken = _a.refreshToken;
347
- if (!username || !refreshToken) {
348
- return [2 /*return*/, ''];
349
- }
350
- options = {
351
- method: 'POST',
352
- url: "".concat(this.configuration.basePath, "/authservice/v1/refresh-token"),
353
- headers: {
354
- 'Content-Type': 'application/json',
355
- Cookie: refreshToken,
356
- },
357
- data: { username: username },
358
- withCredentials: true,
359
- };
360
- return [4 /*yield*/, axios_1.default.request(options)];
361
- case 1:
362
- accessToken = (_b.sent()).data.accessToken;
363
- return [2 /*return*/, accessToken];
364
- }
365
- });
366
- });
367
- };
368
- BaseAPI.prototype.refreshTokenCustomer = function () {
369
- return __awaiter(this, void 0, void 0, function () {
370
- var _a, username, refreshToken, tenantSlug, options, accessToken;
371
- return __generator(this, function (_b) {
372
- switch (_b.label) {
373
- case 0:
374
- _a = this.configuration, username = _a.username, refreshToken = _a.refreshToken, tenantSlug = _a.tenantSlug;
375
- if (!username || !refreshToken) {
376
- return [2 /*return*/, ''];
377
- }
378
- options = {
379
- method: 'POST',
380
- url: "".concat(this.configuration.basePath, "/v1/customers/refresh-token"),
381
- headers: {
382
- 'Content-Type': 'application/json',
383
- Cookie: refreshToken,
384
- },
385
- data: { username: username, tenantSlug: tenantSlug },
386
- withCredentials: true,
387
- };
388
- return [4 /*yield*/, axios_1.default.request(options)];
389
- case 1:
390
- accessToken = (_b.sent()).data.accessToken;
391
- return [2 /*return*/, accessToken];
392
- }
393
- });
394
- });
395
- };
396
- BaseAPI.prototype.extractRefreshToken = function (response) {
397
- if (response.headers && response.headers['set-cookie']
398
- && response.headers['set-cookie'].length > 0) {
399
- return "".concat(response.headers['set-cookie'][0].split(';')[0], ";");
400
- }
401
- return '';
402
- };
403
- BaseAPI.prototype.attachInterceptor = function (axios) {
404
- var _this = this;
405
- axios.interceptors.response.use(function (res) {
406
- return res;
407
- }, function (err) { return __awaiter(_this, void 0, void 0, function () {
408
- var originalConfig, tokenString, accessToken, _error_1, tokenString, accessToken, _error_2;
409
- return __generator(this, function (_a) {
410
- switch (_a.label) {
411
- case 0:
412
- originalConfig = err.config;
413
- if (!err.response) return [3 /*break*/, 8];
414
- if (!(err.response.status === 401 && !originalConfig._retry)) return [3 /*break*/, 7];
415
- originalConfig._retry = true;
416
- _a.label = 1;
417
- case 1:
418
- _a.trys.push([1, 6, , 7]);
419
- tokenString = void 0;
420
- if (!this.isCustomerToken) return [3 /*break*/, 3];
421
- return [4 /*yield*/, this.refreshTokenCustomer()];
422
- case 2:
423
- tokenString = _a.sent();
424
- return [3 /*break*/, 5];
425
- case 3: return [4 /*yield*/, this.refreshTokenTenant()];
426
- case 4:
427
- tokenString = _a.sent();
428
- _a.label = 5;
429
- case 5:
430
- accessToken = "Bearer ".concat(tokenString);
431
- delete originalConfig.headers['Authorization'];
432
- originalConfig.headers['Authorization'] = accessToken;
433
- this.configuration.accessToken = accessToken;
434
- return [2 /*return*/, axios(originalConfig)];
435
- case 6:
436
- _error_1 = _a.sent();
437
- if (_error_1.response && _error_1.response.data) {
438
- return [2 /*return*/, Promise.reject(_error_1.response.data)];
439
- }
440
- return [2 /*return*/, Promise.reject(_error_1)];
441
- case 7:
442
- if (err.response.status === 403 && err.response.data) {
443
- return [2 /*return*/, Promise.reject(err.response.data)];
444
- }
445
- return [3 /*break*/, 15];
446
- case 8:
447
- if (!(err.message === NETWORK_ERROR_MESSAGE
448
- && err.isAxiosError
449
- && originalConfig.headers.hasOwnProperty('Authorization')
450
- && _retry_count < 4)) return [3 /*break*/, 15];
451
- _retry_count++;
452
- _a.label = 9;
453
- case 9:
454
- _a.trys.push([9, 14, , 15]);
455
- tokenString = void 0;
456
- if (!this.isCustomerToken) return [3 /*break*/, 11];
457
- return [4 /*yield*/, this.refreshTokenCustomer()];
458
- case 10:
459
- tokenString = _a.sent();
460
- return [3 /*break*/, 13];
461
- case 11: return [4 /*yield*/, this.refreshTokenTenant()];
462
- case 12:
463
- tokenString = _a.sent();
464
- _a.label = 13;
465
- case 13:
466
- accessToken = "Bearer ".concat(tokenString);
467
- _retry = true;
468
- originalConfig.headers['Authorization'] = accessToken;
469
- this.configuration.accessToken = accessToken;
470
- return [2 /*return*/, axios.request(__assign({}, originalConfig))];
471
- case 14:
472
- _error_2 = _a.sent();
473
- if (_error_2.response && _error_2.response.data) {
474
- return [2 /*return*/, Promise.reject(_error_2.response.data)];
475
- }
476
- return [2 /*return*/, Promise.reject(_error_2)];
477
- case 15: return [2 /*return*/, Promise.reject(err)];
478
- }
479
- });
480
- }); });
481
- };
482
- return BaseAPI;
483
- }());
484
- exports.BaseAPI = BaseAPI;
485
- ;
486
- /**
487
- *
488
- * @export
489
- * @class RequiredError
490
- * @extends {Error}
491
- */
492
- var RequiredError = /** @class */ (function (_super) {
493
- __extends(RequiredError, _super);
494
- function RequiredError(field, msg) {
495
- var _this = _super.call(this, msg) || this;
496
- _this.field = field;
497
- _this.name = "RequiredError";
498
- return _this;
499
- }
500
- return RequiredError;
501
- }(Error));
502
- exports.RequiredError = RequiredError;
package/dist/common.d.ts DELETED
@@ -1,66 +0,0 @@
1
- /**
2
- * EMIL CustomerService
3
- * The EMIL CustomerService API description
4
- *
5
- * The version of the OpenAPI document: 1.0
6
- * Contact: kontakt@emil.de
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>;