@emilgroup/account-sdk-node 1.1.0 → 1.3.1

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.
@@ -13,7 +13,6 @@ models/account-class.ts
13
13
  models/create-account-request-dto.ts
14
14
  models/create-account-response-class.ts
15
15
  models/delete-request-dto.ts
16
- models/get-account-request-dto.ts
17
16
  models/get-account-response-class.ts
18
17
  models/index.ts
19
18
  models/list-accounts-response-class.ts
package/README.md CHANGED
@@ -10,18 +10,18 @@ Module system
10
10
  * CommonJS
11
11
  * ES6 module system
12
12
 
13
- Although this package can be used in both TypeScript and JavaScript, it is intended to be used with TypeScript. The definition should be automatically resolved via `package.json`. ([Reference](http://www.typescriptlang.org/docs/handbook/typings-for-npm-packages.html))
13
+ Although this package can be used in both TypeScript and JavaScript, it is intended to be used with TypeScript. The definition should be automatically resolved via `package.json`. ([Reference](http://www.typescriptlang.org/docs/handbook/typings-for-npm-packages.html)). For more information, you can go to [Emil Api documentation](https://emil.stoplight.io/docs/emil-api/).
14
14
 
15
15
  ## Consuming
16
16
 
17
17
  Navigate to the folder of your consuming project and run one of the following commands:
18
18
 
19
19
  ```
20
- npm install @emilgroup/account-sdk-node@1.1.0 --save
20
+ npm install @emilgroup/account-sdk-node@1.3.1 --save
21
21
  ```
22
22
  or
23
23
  ```
24
- yarn add @emilgroup/account-sdk-node@1.1.0
24
+ yarn add @emilgroup/account-sdk-node@1.3.1
25
25
  ```
26
26
 
27
27
  And then you can import `AccountsApi`.
@@ -185,7 +185,7 @@ export const AccountsApiAxiosParamCreator = function (configuration?: Configurat
185
185
  };
186
186
  },
187
187
  /**
188
- * Returns a list of accounts you have previously created. The accounts are returned in sorted order, with the oldest account appearing first. For more information about pagination, read the Pagination documentation.
188
+ * Returns a list of accounts you have previously created. The accounts are returned in sorted order, with the oldest one appearing first. For more information about pagination, read the Pagination documentation.
189
189
  * @summary List accounts
190
190
  * @param {string} [authorization] Bearer Token: provided by the login endpoint under the name accessToken.
191
191
  * @param {number} [pageSize] A limit on the number of objects to be returned. Limit ranges between 1 and 100. Default: 10.
@@ -349,7 +349,7 @@ export const AccountsApiFp = function(configuration?: Configuration) {
349
349
  return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
350
350
  },
351
351
  /**
352
- * Returns a list of accounts you have previously created. The accounts are returned in sorted order, with the oldest account appearing first. For more information about pagination, read the Pagination documentation.
352
+ * Returns a list of accounts you have previously created. The accounts are returned in sorted order, with the oldest one appearing first. For more information about pagination, read the Pagination documentation.
353
353
  * @summary List accounts
354
354
  * @param {string} [authorization] Bearer Token: provided by the login endpoint under the name accessToken.
355
355
  * @param {number} [pageSize] A limit on the number of objects to be returned. Limit ranges between 1 and 100. Default: 10.
@@ -422,7 +422,7 @@ export const AccountsApiFactory = function (configuration?: Configuration, baseP
422
422
  return localVarFp.getAccount(code, authorization, expand, options).then((request) => request(axios, basePath));
423
423
  },
424
424
  /**
425
- * Returns a list of accounts you have previously created. The accounts are returned in sorted order, with the oldest account appearing first. For more information about pagination, read the Pagination documentation.
425
+ * Returns a list of accounts you have previously created. The accounts are returned in sorted order, with the oldest one appearing first. For more information about pagination, read the Pagination documentation.
426
426
  * @summary List accounts
427
427
  * @param {string} [authorization] Bearer Token: provided by the login endpoint under the name accessToken.
428
428
  * @param {number} [pageSize] A limit on the number of objects to be returned. Limit ranges between 1 and 100. Default: 10.
@@ -642,7 +642,7 @@ export class AccountsApi extends BaseAPI {
642
642
  }
643
643
 
644
644
  /**
645
- * Returns a list of accounts you have previously created. The accounts are returned in sorted order, with the oldest account appearing first. For more information about pagination, read the Pagination documentation.
645
+ * Returns a list of accounts you have previously created. The accounts are returned in sorted order, with the oldest one appearing first. For more information about pagination, read the Pagination documentation.
646
646
  * @summary List accounts
647
647
  * @param {AccountsApiListAccountsRequest} requestParameters Request parameters.
648
648
  * @param {*} [options] Override http request option.
package/api.ts CHANGED
@@ -33,4 +33,5 @@ export * from './api/accounts-api';
33
33
  export enum Environment {
34
34
  Production = 'https://apiv2.emil.de',
35
35
  Test = 'https://apiv2-test.emil.de',
36
+ Development = 'https://apiv2-dev.emil.de',
36
37
  }
package/base.ts CHANGED
@@ -14,6 +14,7 @@
14
14
 
15
15
 
16
16
  import { Configuration } from "./configuration";
17
+ import { Environment } from "./api";
17
18
  // Some imports not used depending on template conditions
18
19
  // @ts-ignore
19
20
  import globalAxios, { AxiosPromise, AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
@@ -42,12 +43,13 @@ export const COLLECTION_FORMATS = {
42
43
  export interface LoginClass {
43
44
  accessToken: string;
44
45
  permissions: Array<string>;
45
- newPasswordRequired: boolean;
46
46
  }
47
47
 
48
- export enum Environment {
49
- Production = 'https://apiv2.emil.de',
50
- Test = 'https://apiv2-test.emil.de',
48
+ let _retry_count = 0
49
+ let _retry = null
50
+
51
+ export function resetRetry() {
52
+ _retry_count = 0
51
53
  }
52
54
 
53
55
  /**
@@ -60,6 +62,8 @@ export interface RequestArgs {
60
62
  options: AxiosRequestConfig;
61
63
  }
62
64
 
65
+ const NETWORK_ERROR_MESSAGE = "Network Error";
66
+
63
67
  /**
64
68
  *
65
69
  * @export
@@ -154,15 +158,16 @@ export class BaseAPI {
154
158
  const response = await globalAxios.request<LoginClass>(options);
155
159
 
156
160
  const { data: { accessToken } } = response;
157
- const refreshToken = this.extractRefreshToken(response)
158
-
159
161
  this.configuration.username = username;
160
162
  this.configuration.accessToken = `Bearer ${accessToken}`;
163
+
164
+ const refreshToken = this.extractRefreshToken(response)
161
165
  this.configuration.refreshToken = refreshToken;
162
166
  }
163
167
 
164
168
  async refreshToken(): Promise<string> {
165
169
  const { username, refreshToken } = this.configuration;
170
+
166
171
 
167
172
  if (!username || !refreshToken) {
168
173
  return '';
@@ -204,7 +209,7 @@ export class BaseAPI {
204
209
  return res;
205
210
  },
206
211
  async (err) => {
207
- const originalConfig = err.config;
212
+ let originalConfig = err.config;
208
213
  if (err.response) {
209
214
  // Access Token was expired
210
215
  if (err.response.status === 401 && !originalConfig._retry) {
@@ -213,17 +218,11 @@ export class BaseAPI {
213
218
  const tokenString = await this.refreshToken();
214
219
  const accessToken = `Bearer ${tokenString}`;
215
220
 
216
- const localVarHeaderParameter = {} as any;
217
- localVarHeaderParameter['Authorization'] = accessToken;
218
-
219
- originalConfig.headers = {
220
- ...originalConfig.headers,
221
- ...localVarHeaderParameter,
222
- };
221
+ originalConfig.headers['Authorization'] = `Bearer ${accessToken}`
223
222
 
224
223
  this.configuration.accessToken = accessToken;
225
224
 
226
- return axios(originalConfig);
225
+ return axios.request(originalConfig);
227
226
  } catch (_error) {
228
227
  if (_error.response && _error.response.data) {
229
228
  return Promise.reject(_error.response.data);
@@ -234,6 +233,30 @@ export class BaseAPI {
234
233
  if (err.response.status === 403 && err.response.data) {
235
234
  return Promise.reject(err.response.data);
236
235
  }
236
+ } else if(err.message === NETWORK_ERROR_MESSAGE
237
+ && err.isAxiosError
238
+ && originalConfig.headers.hasOwnProperty('Authorization')
239
+ && _retry_count < 4
240
+ ){
241
+ _retry_count++;
242
+ try {
243
+ const tokenString = await this.refreshToken();
244
+ const accessToken = `Bearer ${tokenString}`;
245
+
246
+ _retry = true;
247
+ originalConfig.headers['Authorization'] = accessToken;
248
+
249
+ this.configuration.accessToken = accessToken;
250
+
251
+ return axios.request({
252
+ ...originalConfig,
253
+ });
254
+ } catch (_error) {
255
+ if (_error.response && _error.response.data) {
256
+ return Promise.reject(_error.response.data);
257
+ }
258
+ return Promise.reject(_error);
259
+ }
237
260
  }
238
261
  return Promise.reject(err);
239
262
  }
@@ -253,3 +276,4 @@ export class RequiredError extends Error {
253
276
  super(msg);
254
277
  }
255
278
  }
279
+
package/common.ts CHANGED
@@ -136,3 +136,64 @@ export const createRequestFunction = function (axiosArgs: RequestArgs, globalAxi
136
136
  return axios.request<T, R>(axiosRequestArgs);
137
137
  };
138
138
  }
139
+
140
+ /* tslint:disable */
141
+ /* eslint-disable */
142
+ /**
143
+ * EMIL AccountService
144
+ * The EMIL AccountService API description
145
+ *
146
+ * The version of the OpenAPI document: 1.0
147
+ *
148
+ *
149
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
150
+ * https://openapi-generator.tech
151
+ * Do not edit the class manually.
152
+ */
153
+
154
+
155
+ export interface IStorageConverter<D, SD> {
156
+ toStorageData( data: D ): SD;
157
+ fromStorageData( storageData: SD ): D;
158
+ }
159
+
160
+ export interface IStorage {
161
+ get<T>( key: string, converter?: IStorageConverter<T, any> ): T | null;
162
+ set<T>( key: string, value: T, converter?: IStorageConverter<T, any> ): void;
163
+ }
164
+
165
+ export class LocalStorage implements IStorage {
166
+ readonly storage: Storage;
167
+
168
+ constructor() {
169
+ this.storage = localStorage;
170
+ }
171
+
172
+ get<T>( key: string, converter?: IStorageConverter<T, any> ): T | null {
173
+ const jsonValue = this.storage.getItem( key );
174
+ if ( jsonValue === null ) {
175
+ return null;
176
+ }
177
+ const value = JSON.parse( jsonValue );
178
+ if ( converter !== undefined ) {
179
+ return converter.fromStorageData( value );
180
+ } else {
181
+ return value as T;
182
+ }
183
+ }
184
+
185
+ set<T>( key: string, value: T, converter?: IStorageConverter<T, any> ): void {
186
+ let valueToStore: any = value;
187
+ if ( converter !== undefined ) {
188
+ valueToStore = converter.toStorageData( value );
189
+ }
190
+ const jsonValue = JSON.stringify( valueToStore );
191
+ this.storage.setItem( key, jsonValue );
192
+ }
193
+ }
194
+
195
+ let _defaultStorage: IStorage = null;
196
+
197
+ export const defaultStorage = (): IStorage => {
198
+ return _defaultStorage || (_defaultStorage = new LocalStorage());
199
+ };
@@ -52,7 +52,7 @@ export declare const AccountsApiAxiosParamCreator: (configuration?: Configuratio
52
52
  */
53
53
  getAccount: (code: string, authorization?: string, expand?: string, options?: AxiosRequestConfig) => Promise<RequestArgs>;
54
54
  /**
55
- * Returns a list of accounts you have previously created. The accounts are returned in sorted order, with the oldest account appearing first. For more information about pagination, read the Pagination documentation.
55
+ * Returns a list of accounts you have previously created. The accounts are returned in sorted order, with the oldest one appearing first. For more information about pagination, read the Pagination documentation.
56
56
  * @summary List accounts
57
57
  * @param {string} [authorization] Bearer Token: provided by the login endpoint under the name accessToken.
58
58
  * @param {number} [pageSize] A limit on the number of objects to be returned. Limit ranges between 1 and 100. Default: 10.
@@ -109,7 +109,7 @@ export declare const AccountsApiFp: (configuration?: Configuration) => {
109
109
  */
110
110
  getAccount(code: string, authorization?: string, expand?: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<GetAccountResponseClass>>;
111
111
  /**
112
- * Returns a list of accounts you have previously created. The accounts are returned in sorted order, with the oldest account appearing first. For more information about pagination, read the Pagination documentation.
112
+ * Returns a list of accounts you have previously created. The accounts are returned in sorted order, with the oldest one appearing first. For more information about pagination, read the Pagination documentation.
113
113
  * @summary List accounts
114
114
  * @param {string} [authorization] Bearer Token: provided by the login endpoint under the name accessToken.
115
115
  * @param {number} [pageSize] A limit on the number of objects to be returned. Limit ranges between 1 and 100. Default: 10.
@@ -166,7 +166,7 @@ export declare const AccountsApiFactory: (configuration?: Configuration, basePat
166
166
  */
167
167
  getAccount(code: string, authorization?: string, expand?: string, options?: any): AxiosPromise<GetAccountResponseClass>;
168
168
  /**
169
- * Returns a list of accounts you have previously created. The accounts are returned in sorted order, with the oldest account appearing first. For more information about pagination, read the Pagination documentation.
169
+ * Returns a list of accounts you have previously created. The accounts are returned in sorted order, with the oldest one appearing first. For more information about pagination, read the Pagination documentation.
170
170
  * @summary List accounts
171
171
  * @param {string} [authorization] Bearer Token: provided by the login endpoint under the name accessToken.
172
172
  * @param {number} [pageSize] A limit on the number of objects to be returned. Limit ranges between 1 and 100. Default: 10.
@@ -355,7 +355,7 @@ export declare class AccountsApi extends BaseAPI {
355
355
  */
356
356
  getAccount(requestParameters: AccountsApiGetAccountRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<GetAccountResponseClass, any>>;
357
357
  /**
358
- * Returns a list of accounts you have previously created. The accounts are returned in sorted order, with the oldest account appearing first. For more information about pagination, read the Pagination documentation.
358
+ * Returns a list of accounts you have previously created. The accounts are returned in sorted order, with the oldest one appearing first. For more information about pagination, read the Pagination documentation.
359
359
  * @summary List accounts
360
360
  * @param {AccountsApiListAccountsRequest} requestParameters Request parameters.
361
361
  * @param {*} [options] Override http request option.
@@ -53,7 +53,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
53
53
  function verb(n) { return function (v) { return step([n, v]); }; }
54
54
  function step(op) {
55
55
  if (f) throw new TypeError("Generator is already executing.");
56
- while (_) try {
56
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
57
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
58
  if (y = 0, t) op = [op[0] & 2, t.value];
59
59
  switch (op[0]) {
@@ -246,7 +246,7 @@ var AccountsApiAxiosParamCreator = function (configuration) {
246
246
  });
247
247
  },
248
248
  /**
249
- * Returns a list of accounts you have previously created. The accounts are returned in sorted order, with the oldest account appearing first. For more information about pagination, read the Pagination documentation.
249
+ * Returns a list of accounts you have previously created. The accounts are returned in sorted order, with the oldest one appearing first. For more information about pagination, read the Pagination documentation.
250
250
  * @summary List accounts
251
251
  * @param {string} [authorization] Bearer Token: provided by the login endpoint under the name accessToken.
252
252
  * @param {number} [pageSize] A limit on the number of objects to be returned. Limit ranges between 1 and 100. Default: 10.
@@ -437,7 +437,7 @@ var AccountsApiFp = function (configuration) {
437
437
  });
438
438
  },
439
439
  /**
440
- * Returns a list of accounts you have previously created. The accounts are returned in sorted order, with the oldest account appearing first. For more information about pagination, read the Pagination documentation.
440
+ * Returns a list of accounts you have previously created. The accounts are returned in sorted order, with the oldest one appearing first. For more information about pagination, read the Pagination documentation.
441
441
  * @summary List accounts
442
442
  * @param {string} [authorization] Bearer Token: provided by the login endpoint under the name accessToken.
443
443
  * @param {number} [pageSize] A limit on the number of objects to be returned. Limit ranges between 1 and 100. Default: 10.
@@ -528,7 +528,7 @@ var AccountsApiFactory = function (configuration, basePath, axios) {
528
528
  return localVarFp.getAccount(code, authorization, expand, options).then(function (request) { return request(axios, basePath); });
529
529
  },
530
530
  /**
531
- * Returns a list of accounts you have previously created. The accounts are returned in sorted order, with the oldest account appearing first. For more information about pagination, read the Pagination documentation.
531
+ * Returns a list of accounts you have previously created. The accounts are returned in sorted order, with the oldest one appearing first. For more information about pagination, read the Pagination documentation.
532
532
  * @summary List accounts
533
533
  * @param {string} [authorization] Bearer Token: provided by the login endpoint under the name accessToken.
534
534
  * @param {number} [pageSize] A limit on the number of objects to be returned. Limit ranges between 1 and 100. Default: 10.
@@ -605,7 +605,7 @@ var AccountsApi = /** @class */ (function (_super) {
605
605
  return (0, exports.AccountsApiFp)(this.configuration).getAccount(requestParameters.code, requestParameters.authorization, requestParameters.expand, options).then(function (request) { return request(_this.axios, _this.basePath); });
606
606
  };
607
607
  /**
608
- * Returns a list of accounts you have previously created. The accounts are returned in sorted order, with the oldest account appearing first. For more information about pagination, read the Pagination documentation.
608
+ * Returns a list of accounts you have previously created. The accounts are returned in sorted order, with the oldest one appearing first. For more information about pagination, read the Pagination documentation.
609
609
  * @summary List accounts
610
610
  * @param {AccountsApiListAccountsRequest} requestParameters Request parameters.
611
611
  * @param {*} [options] Override http request option.
package/dist/api.d.ts CHANGED
@@ -12,5 +12,6 @@
12
12
  export * from './api/accounts-api';
13
13
  export declare enum Environment {
14
14
  Production = "https://apiv2.emil.de",
15
- Test = "https://apiv2-test.emil.de"
15
+ Test = "https://apiv2-test.emil.de",
16
+ Development = "https://apiv2-dev.emil.de"
16
17
  }
package/dist/api.js CHANGED
@@ -33,4 +33,5 @@ var Environment;
33
33
  (function (Environment) {
34
34
  Environment["Production"] = "https://apiv2.emil.de";
35
35
  Environment["Test"] = "https://apiv2-test.emil.de";
36
+ Environment["Development"] = "https://apiv2-dev.emil.de";
36
37
  })(Environment = exports.Environment || (exports.Environment = {}));
package/dist/base.d.ts CHANGED
@@ -10,6 +10,7 @@
10
10
  * Do not edit the class manually.
11
11
  */
12
12
  import { Configuration } from "./configuration";
13
+ import { Environment } from "./api";
13
14
  import { AxiosInstance, AxiosRequestConfig } from 'axios';
14
15
  export declare const BASE_PATH: string;
15
16
  /**
@@ -25,12 +26,8 @@ export declare const COLLECTION_FORMATS: {
25
26
  export interface LoginClass {
26
27
  accessToken: string;
27
28
  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
29
  }
30
+ export declare function resetRetry(): void;
34
31
  /**
35
32
  *
36
33
  * @export
package/dist/base.js CHANGED
@@ -76,7 +76,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
76
76
  function verb(n) { return function (v) { return step([n, v]); }; }
77
77
  function step(op) {
78
78
  if (f) throw new TypeError("Generator is already executing.");
79
- while (_) try {
79
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
80
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
81
  if (y = 0, t) op = [op[0] & 2, t.value];
82
82
  switch (op[0]) {
@@ -101,8 +101,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
101
101
  return (mod && mod.__esModule) ? mod : { "default": mod };
102
102
  };
103
103
  Object.defineProperty(exports, "__esModule", { value: true });
104
- exports.RequiredError = exports.BaseAPI = exports.Environment = exports.COLLECTION_FORMATS = exports.BASE_PATH = void 0;
104
+ exports.RequiredError = exports.BaseAPI = exports.resetRetry = exports.COLLECTION_FORMATS = exports.BASE_PATH = void 0;
105
105
  var configuration_1 = require("./configuration");
106
+ var api_1 = require("./api");
106
107
  // Some imports not used depending on template conditions
107
108
  // @ts-ignore
108
109
  var axios_1 = __importDefault(require("axios"));
@@ -125,11 +126,13 @@ exports.COLLECTION_FORMATS = {
125
126
  tsv: "\t",
126
127
  pipes: "|",
127
128
  };
128
- var Environment;
129
- (function (Environment) {
130
- Environment["Production"] = "https://apiv2.emil.de";
131
- Environment["Test"] = "https://apiv2-test.emil.de";
132
- })(Environment = exports.Environment || (exports.Environment = {}));
129
+ var _retry_count = 0;
130
+ var _retry = null;
131
+ function resetRetry() {
132
+ _retry_count = 0;
133
+ }
134
+ exports.resetRetry = resetRetry;
135
+ var NETWORK_ERROR_MESSAGE = "Network Error";
133
136
  /**
134
137
  *
135
138
  * @export
@@ -153,7 +156,7 @@ var BaseAPI = /** @class */ (function () {
153
156
  this.attachInterceptor(axios);
154
157
  }
155
158
  BaseAPI.prototype.initialize = function (env) {
156
- if (env === void 0) { env = Environment.Production; }
159
+ if (env === void 0) { env = api_1.Environment.Production; }
157
160
  return __awaiter(this, void 0, void 0, function () {
158
161
  return __generator(this, function (_a) {
159
162
  switch (_a.label) {
@@ -253,9 +256,9 @@ var BaseAPI = /** @class */ (function () {
253
256
  case 1:
254
257
  response = _a.sent();
255
258
  accessToken = response.data.accessToken;
256
- refreshToken = this.extractRefreshToken(response);
257
259
  this.configuration.username = username;
258
260
  this.configuration.accessToken = "Bearer ".concat(accessToken);
261
+ refreshToken = this.extractRefreshToken(response);
259
262
  this.configuration.refreshToken = refreshToken;
260
263
  return [2 /*return*/];
261
264
  }
@@ -305,7 +308,7 @@ var BaseAPI = /** @class */ (function () {
305
308
  axios.interceptors.response.use(function (res) {
306
309
  return res;
307
310
  }, function (err) { return __awaiter(_this, void 0, void 0, function () {
308
- var originalConfig, tokenString, accessToken, localVarHeaderParameter, _error_1;
311
+ var originalConfig, tokenString, accessToken, _error_1, tokenString, accessToken, _error_2;
309
312
  return __generator(this, function (_a) {
310
313
  switch (_a.label) {
311
314
  case 0:
@@ -320,11 +323,9 @@ var BaseAPI = /** @class */ (function () {
320
323
  case 2:
321
324
  tokenString = _a.sent();
322
325
  accessToken = "Bearer ".concat(tokenString);
323
- localVarHeaderParameter = {};
324
- localVarHeaderParameter['Authorization'] = accessToken;
325
- originalConfig.headers = __assign(__assign({}, originalConfig.headers), localVarHeaderParameter);
326
+ originalConfig.headers['Authorization'] = "Bearer ".concat(accessToken);
326
327
  this.configuration.accessToken = accessToken;
327
- return [2 /*return*/, axios(originalConfig)];
328
+ return [2 /*return*/, axios.request(originalConfig)];
328
329
  case 3:
329
330
  _error_1 = _a.sent();
330
331
  if (_error_1.response && _error_1.response.data) {
@@ -335,8 +336,31 @@ var BaseAPI = /** @class */ (function () {
335
336
  if (err.response.status === 403 && err.response.data) {
336
337
  return [2 /*return*/, Promise.reject(err.response.data)];
337
338
  }
338
- _a.label = 5;
339
- case 5: return [2 /*return*/, Promise.reject(err)];
339
+ return [3 /*break*/, 9];
340
+ case 5:
341
+ if (!(err.message === NETWORK_ERROR_MESSAGE
342
+ && err.isAxiosError
343
+ && originalConfig.headers.hasOwnProperty('Authorization')
344
+ && _retry_count < 4)) return [3 /*break*/, 9];
345
+ _retry_count++;
346
+ _a.label = 6;
347
+ case 6:
348
+ _a.trys.push([6, 8, , 9]);
349
+ return [4 /*yield*/, this.refreshToken()];
350
+ case 7:
351
+ tokenString = _a.sent();
352
+ accessToken = "Bearer ".concat(tokenString);
353
+ _retry = true;
354
+ originalConfig.headers['Authorization'] = accessToken;
355
+ this.configuration.accessToken = accessToken;
356
+ return [2 /*return*/, axios.request(__assign({}, originalConfig))];
357
+ case 8:
358
+ _error_2 = _a.sent();
359
+ if (_error_2.response && _error_2.response.data) {
360
+ return [2 /*return*/, Promise.reject(_error_2.response.data)];
361
+ }
362
+ return [2 /*return*/, Promise.reject(_error_2)];
363
+ case 9: return [2 /*return*/, Promise.reject(err)];
340
364
  }
341
365
  });
342
366
  }); });
package/dist/common.d.ts CHANGED
@@ -64,3 +64,29 @@ export declare const toPathString: (url: URL) => string;
64
64
  * @export
65
65
  */
66
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>;
67
+ /**
68
+ * EMIL AccountService
69
+ * The EMIL AccountService API description
70
+ *
71
+ * The version of the OpenAPI document: 1.0
72
+ *
73
+ *
74
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
75
+ * https://openapi-generator.tech
76
+ * Do not edit the class manually.
77
+ */
78
+ export interface IStorageConverter<D, SD> {
79
+ toStorageData(data: D): SD;
80
+ fromStorageData(storageData: SD): D;
81
+ }
82
+ export interface IStorage {
83
+ get<T>(key: string, converter?: IStorageConverter<T, any>): T | null;
84
+ set<T>(key: string, value: T, converter?: IStorageConverter<T, any>): void;
85
+ }
86
+ export declare class LocalStorage implements IStorage {
87
+ readonly storage: Storage;
88
+ constructor();
89
+ get<T>(key: string, converter?: IStorageConverter<T, any>): T | null;
90
+ set<T>(key: string, value: T, converter?: IStorageConverter<T, any>): void;
91
+ }
92
+ export declare const defaultStorage: () => IStorage;
package/dist/common.js CHANGED
@@ -38,7 +38,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
38
38
  function verb(n) { return function (v) { return step([n, v]); }; }
39
39
  function step(op) {
40
40
  if (f) throw new TypeError("Generator is already executing.");
41
- while (_) try {
41
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
42
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
43
  if (y = 0, t) op = [op[0] & 2, t.value];
44
44
  switch (op[0]) {
@@ -60,7 +60,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
60
60
  }
61
61
  };
62
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;
63
+ exports.defaultStorage = exports.LocalStorage = 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
64
  var base_1 = require("./base");
65
65
  var url_1 = require("url");
66
66
  /**
@@ -242,3 +242,36 @@ var createRequestFunction = function (axiosArgs, globalAxios, BASE_PATH, configu
242
242
  };
243
243
  };
244
244
  exports.createRequestFunction = createRequestFunction;
245
+ var LocalStorage = /** @class */ (function () {
246
+ function LocalStorage() {
247
+ this.storage = localStorage;
248
+ }
249
+ LocalStorage.prototype.get = function (key, converter) {
250
+ var jsonValue = this.storage.getItem(key);
251
+ if (jsonValue === null) {
252
+ return null;
253
+ }
254
+ var value = JSON.parse(jsonValue);
255
+ if (converter !== undefined) {
256
+ return converter.fromStorageData(value);
257
+ }
258
+ else {
259
+ return value;
260
+ }
261
+ };
262
+ LocalStorage.prototype.set = function (key, value, converter) {
263
+ var valueToStore = value;
264
+ if (converter !== undefined) {
265
+ valueToStore = converter.toStorageData(value);
266
+ }
267
+ var jsonValue = JSON.stringify(valueToStore);
268
+ this.storage.setItem(key, jsonValue);
269
+ };
270
+ return LocalStorage;
271
+ }());
272
+ exports.LocalStorage = LocalStorage;
273
+ var _defaultStorage = null;
274
+ var defaultStorage = function () {
275
+ return _defaultStorage || (_defaultStorage = new LocalStorage());
276
+ };
277
+ exports.defaultStorage = defaultStorage;
@@ -33,6 +33,12 @@ export interface AccountClass {
33
33
  * @memberof AccountClass
34
34
  */
35
35
  'accountNumber': string;
36
+ /**
37
+ * The account\'s title.
38
+ * @type {string}
39
+ * @memberof AccountClass
40
+ */
41
+ 'title': AccountClassTitleEnum;
36
42
  /**
37
43
  * The account\'s first name.
38
44
  * @type {string}
@@ -86,13 +92,25 @@ export interface AccountClass {
86
92
  * @type {string}
87
93
  * @memberof AccountClass
88
94
  */
89
- 'birthDate': string;
95
+ 'birthDate'?: string;
90
96
  /**
91
97
  * The account\'s phone number.
92
98
  * @type {string}
93
99
  * @memberof AccountClass
94
100
  */
95
101
  'phone': string;
102
+ /**
103
+ * The type of account, default to person
104
+ * @type {string}
105
+ * @memberof AccountClass
106
+ */
107
+ 'type': string;
108
+ /**
109
+ * The company name of account, required for account type org
110
+ * @type {string}
111
+ * @memberof AccountClass
112
+ */
113
+ 'companyName'?: string;
96
114
  /**
97
115
  * The account\'s version.
98
116
  * @type {number}
@@ -130,3 +148,10 @@ export interface AccountClass {
130
148
  */
131
149
  'customFields': object;
132
150
  }
151
+ export declare const AccountClassTitleEnum: {
152
+ readonly Empty: "";
153
+ readonly Dr: "Dr.";
154
+ readonly DrMed: "Dr. med.";
155
+ readonly ProfDrMed: "Prof. Dr. med.";
156
+ };
157
+ export type AccountClassTitleEnum = typeof AccountClassTitleEnum[keyof typeof AccountClassTitleEnum];
@@ -13,3 +13,10 @@
13
13
  * Do not edit the class manually.
14
14
  */
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.AccountClassTitleEnum = void 0;
17
+ exports.AccountClassTitleEnum = {
18
+ Empty: '',
19
+ Dr: 'Dr.',
20
+ DrMed: 'Dr. med.',
21
+ ProfDrMed: 'Prof. Dr. med.'
22
+ };