@emilgroup/billing-sdk-node 1.48.1-beta.9 → 1.49.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.
@@ -41,6 +41,7 @@ models/inline-response503.ts
41
41
  models/invoice-class.ts
42
42
  models/invoice-item-class.ts
43
43
  models/invoice-payment-class.ts
44
+ models/invoice-payment-method-class.ts
44
45
  models/invoice-payments-class.ts
45
46
  models/invoice-status-class.ts
46
47
  models/list-invoices-response-class.ts
package/README.md CHANGED
@@ -17,11 +17,11 @@ Although this package can be used in both TypeScript and JavaScript, it is inten
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/billing-sdk-node@1.48.1-beta.9 --save
20
+ npm install @emilgroup/billing-sdk-node@1.49.0 --save
21
21
  ```
22
22
  or
23
23
  ```
24
- yarn add @emilgroup/billing-sdk-node@1.48.1-beta.9
24
+ yarn add @emilgroup/billing-sdk-node@1.49.0
25
25
  ```
26
26
 
27
27
  And then you can import `InvoicesApi`.
package/base.ts CHANGED
@@ -44,6 +44,16 @@ export interface LoginClass {
44
44
  permissions: string;
45
45
  }
46
46
 
47
+ export interface SwitchWorkspaceRequest {
48
+ username: string;
49
+ targetWorkspace: string;
50
+ }
51
+
52
+ export interface SwitchWorkspaceResponseClass {
53
+ accessToken: string;
54
+ permissions: string;
55
+ }
56
+
47
57
  export enum Environment {
48
58
  Production = 'https://apiv2.emil.de',
49
59
  Test = 'https://apiv2-test.emil.de',
@@ -94,13 +104,13 @@ export class BaseAPI {
94
104
  this.attachInterceptor(axios);
95
105
  }
96
106
 
97
- async initialize(env: Environment = Environment.Production) {
107
+ async initialize(env: Environment = Environment.Production, targetWorkspace?: string) {
98
108
  this.configuration.basePath = env;
99
109
 
100
110
  await this.loadCredentials();
101
111
 
102
112
  if (this.username) {
103
- await this.authorize(this.username, this.password);
113
+ await this.authorize(this.username, this.password, targetWorkspace);
104
114
  this.password = null; // to avoid keeping password loaded in memory.
105
115
  }
106
116
  }
@@ -150,7 +160,7 @@ export class BaseAPI {
150
160
  this.configuration.basePath = env;
151
161
  }
152
162
 
153
- async authorize(username: string, password: string): Promise<void> {
163
+ async authorize(username: string, password: string, targetWorkspace?: string): Promise<void> {
154
164
  const options: AxiosRequestConfig = {
155
165
  method: 'POST',
156
166
  url: `${this.configuration.basePath}/authservice/v1/login`,
@@ -170,6 +180,38 @@ export class BaseAPI {
170
180
 
171
181
  const refreshToken = this.extractRefreshToken(response)
172
182
  this.configuration.refreshToken = refreshToken;
183
+
184
+ // Switch workspace if provided
185
+ if (targetWorkspace) {
186
+ await this.switchWorkspace(targetWorkspace);
187
+ }
188
+ }
189
+
190
+ async switchWorkspace(targetWorkspace: string): Promise<void> {
191
+ const options: AxiosRequestConfig = {
192
+ method: 'POST',
193
+ url: `${this.configuration.basePath}/authservice/v1/workspaces/switch`,
194
+ headers: {
195
+ 'Content-Type': 'application/json',
196
+ 'Authorization': `Bearer ${this.configuration.accessToken}`,
197
+ 'Cookie': this.configuration.refreshToken,
198
+ },
199
+ data: {
200
+ username: this.configuration.username,
201
+ targetWorkspace,
202
+ } as SwitchWorkspaceRequest,
203
+ withCredentials: true,
204
+ };
205
+
206
+ const response = await globalAxios.request<SwitchWorkspaceResponseClass>(options);
207
+
208
+ const { data: { accessToken } } = response;
209
+ this.configuration.accessToken = `Bearer ${accessToken}`;
210
+
211
+ const refreshToken = this.extractRefreshToken(response);
212
+ if (refreshToken) {
213
+ this.configuration.refreshToken = refreshToken;
214
+ }
173
215
  }
174
216
 
175
217
  async refreshTokenInternal(): Promise<string> {
package/dist/base.d.ts CHANGED
@@ -26,6 +26,14 @@ export interface LoginClass {
26
26
  accessToken: string;
27
27
  permissions: string;
28
28
  }
29
+ export interface SwitchWorkspaceRequest {
30
+ username: string;
31
+ targetWorkspace: string;
32
+ }
33
+ export interface SwitchWorkspaceResponseClass {
34
+ accessToken: string;
35
+ permissions: string;
36
+ }
29
37
  export declare enum Environment {
30
38
  Production = "https://apiv2.emil.de",
31
39
  Test = "https://apiv2-test.emil.de",
@@ -55,12 +63,13 @@ export declare class BaseAPI {
55
63
  private username?;
56
64
  private password?;
57
65
  constructor(configuration?: Configuration, basePath?: string, axios?: AxiosInstance);
58
- initialize(env?: Environment): Promise<void>;
66
+ initialize(env?: Environment, targetWorkspace?: string): Promise<void>;
59
67
  private loadCredentials;
60
68
  private readConfigFile;
61
69
  private readEnvVariables;
62
70
  selectEnvironment(env: Environment): void;
63
- authorize(username: string, password: string): Promise<void>;
71
+ authorize(username: string, password: string, targetWorkspace?: string): Promise<void>;
72
+ switchWorkspace(targetWorkspace: string): Promise<void>;
64
73
  refreshTokenInternal(): Promise<string>;
65
74
  private extractRefreshToken;
66
75
  getConfiguration(): Configuration;
package/dist/base.js CHANGED
@@ -162,7 +162,7 @@ var BaseAPI = /** @class */ (function () {
162
162
  }
163
163
  this.attachInterceptor(axios);
164
164
  }
165
- BaseAPI.prototype.initialize = function (env) {
165
+ BaseAPI.prototype.initialize = function (env, targetWorkspace) {
166
166
  if (env === void 0) { env = Environment.Production; }
167
167
  return __awaiter(this, void 0, void 0, function () {
168
168
  return __generator(this, function (_a) {
@@ -173,7 +173,7 @@ var BaseAPI = /** @class */ (function () {
173
173
  case 1:
174
174
  _a.sent();
175
175
  if (!this.username) return [3 /*break*/, 3];
176
- return [4 /*yield*/, this.authorize(this.username, this.password)];
176
+ return [4 /*yield*/, this.authorize(this.username, this.password, targetWorkspace)];
177
177
  case 2:
178
178
  _a.sent();
179
179
  this.password = null; // to avoid keeping password loaded in memory.
@@ -243,7 +243,7 @@ var BaseAPI = /** @class */ (function () {
243
243
  BaseAPI.prototype.selectEnvironment = function (env) {
244
244
  this.configuration.basePath = env;
245
245
  };
246
- BaseAPI.prototype.authorize = function (username, password) {
246
+ BaseAPI.prototype.authorize = function (username, password, targetWorkspace) {
247
247
  return __awaiter(this, void 0, void 0, function () {
248
248
  var options, response, accessToken, refreshToken;
249
249
  return __generator(this, function (_a) {
@@ -267,6 +267,45 @@ var BaseAPI = /** @class */ (function () {
267
267
  this.configuration.accessToken = "Bearer ".concat(accessToken);
268
268
  refreshToken = this.extractRefreshToken(response);
269
269
  this.configuration.refreshToken = refreshToken;
270
+ if (!targetWorkspace) return [3 /*break*/, 3];
271
+ return [4 /*yield*/, this.switchWorkspace(targetWorkspace)];
272
+ case 2:
273
+ _a.sent();
274
+ _a.label = 3;
275
+ case 3: return [2 /*return*/];
276
+ }
277
+ });
278
+ });
279
+ };
280
+ BaseAPI.prototype.switchWorkspace = function (targetWorkspace) {
281
+ return __awaiter(this, void 0, void 0, function () {
282
+ var options, response, accessToken, refreshToken;
283
+ return __generator(this, function (_a) {
284
+ switch (_a.label) {
285
+ case 0:
286
+ options = {
287
+ method: 'POST',
288
+ url: "".concat(this.configuration.basePath, "/authservice/v1/workspaces/switch"),
289
+ headers: {
290
+ 'Content-Type': 'application/json',
291
+ 'Authorization': "Bearer ".concat(this.configuration.accessToken),
292
+ 'Cookie': this.configuration.refreshToken,
293
+ },
294
+ data: {
295
+ username: this.configuration.username,
296
+ targetWorkspace: targetWorkspace,
297
+ },
298
+ withCredentials: true,
299
+ };
300
+ return [4 /*yield*/, axios_1.default.request(options)];
301
+ case 1:
302
+ response = _a.sent();
303
+ accessToken = response.data.accessToken;
304
+ this.configuration.accessToken = "Bearer ".concat(accessToken);
305
+ refreshToken = this.extractRefreshToken(response);
306
+ if (refreshToken) {
307
+ this.configuration.refreshToken = refreshToken;
308
+ }
270
309
  return [2 /*return*/];
271
310
  }
272
311
  });
@@ -21,6 +21,7 @@ export * from './inline-response503';
21
21
  export * from './invoice-class';
22
22
  export * from './invoice-item-class';
23
23
  export * from './invoice-payment-class';
24
+ export * from './invoice-payment-method-class';
24
25
  export * from './invoice-payments-class';
25
26
  export * from './invoice-status-class';
26
27
  export * from './list-invoices-response-class';
@@ -37,6 +37,7 @@ __exportStar(require("./inline-response503"), exports);
37
37
  __exportStar(require("./invoice-class"), exports);
38
38
  __exportStar(require("./invoice-item-class"), exports);
39
39
  __exportStar(require("./invoice-payment-class"), exports);
40
+ __exportStar(require("./invoice-payment-method-class"), exports);
40
41
  __exportStar(require("./invoice-payments-class"), exports);
41
42
  __exportStar(require("./invoice-status-class"), exports);
42
43
  __exportStar(require("./list-invoices-response-class"), exports);
@@ -10,6 +10,7 @@
10
10
  * Do not edit the class manually.
11
11
  */
12
12
  import { InvoiceItemClass } from './invoice-item-class';
13
+ import { InvoicePaymentMethodClass } from './invoice-payment-method-class';
13
14
  import { InvoicePaymentsClass } from './invoice-payments-class';
14
15
  import { InvoiceStatusClass } from './invoice-status-class';
15
16
  /**
@@ -162,6 +163,12 @@ export interface InvoiceClass {
162
163
  * @memberof InvoiceClass
163
164
  */
164
165
  'updatedBy': string;
166
+ /**
167
+ * Invoice payment method.
168
+ * @type {InvoicePaymentMethodClass}
169
+ * @memberof InvoiceClass
170
+ */
171
+ 'paymentMethod': InvoicePaymentMethodClass;
165
172
  }
166
173
  export declare const InvoiceClassTypeEnum: {
167
174
  readonly Initial: "initial";
@@ -0,0 +1,72 @@
1
+ /**
2
+ * EMIL BillingService
3
+ * The EMIL BillingService 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
+ /**
13
+ *
14
+ * @export
15
+ * @interface InvoicePaymentMethodClass
16
+ */
17
+ export interface InvoicePaymentMethodClass {
18
+ /**
19
+ * Internal unique identifier for the object. You should not have to use this, use code instead.
20
+ * @type {number}
21
+ * @memberof InvoicePaymentMethodClass
22
+ */
23
+ 'id': number;
24
+ /**
25
+ * Unique identifier for the object.
26
+ * @type {string}
27
+ * @memberof InvoicePaymentMethodClass
28
+ */
29
+ 'code': string;
30
+ /**
31
+ * The payment service provider associated with this payment method.
32
+ * @type {string}
33
+ * @memberof InvoicePaymentMethodClass
34
+ */
35
+ 'psp': string;
36
+ /**
37
+ * The payment method type.
38
+ * @type {string}
39
+ * @memberof InvoicePaymentMethodClass
40
+ */
41
+ 'type': string;
42
+ /**
43
+ * A unique identifier generated by the payment service provider for this payment method.
44
+ * @type {string}
45
+ * @memberof InvoicePaymentMethodClass
46
+ */
47
+ 'providerToken': string;
48
+ /**
49
+ * Customer identifier for the payment service provider.
50
+ * @type {string}
51
+ * @memberof InvoicePaymentMethodClass
52
+ */
53
+ 'pspCustomerId': string;
54
+ /**
55
+ * A slug is a human-readable, unique identifier, used to identify a resource instead of a less human-readable identifier like an id.
56
+ * @type {string}
57
+ * @memberof InvoicePaymentMethodClass
58
+ */
59
+ 'productSlug'?: string;
60
+ /**
61
+ * Identifier of the user who created the record.
62
+ * @type {string}
63
+ * @memberof InvoicePaymentMethodClass
64
+ */
65
+ 'createdBy': string;
66
+ /**
67
+ * Identifier of the user who last updated the record.
68
+ * @type {string}
69
+ * @memberof InvoicePaymentMethodClass
70
+ */
71
+ 'updatedBy': string;
72
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+ /**
5
+ * EMIL BillingService
6
+ * The EMIL BillingService 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
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -10,6 +10,7 @@
10
10
  * Do not edit the class manually.
11
11
  */
12
12
  import { InvoiceItemClass } from './invoice-item-class';
13
+ import { InvoicePaymentMethodClass } from './invoice-payment-method-class';
13
14
  import { InvoicePaymentsClass } from './invoice-payments-class';
14
15
  /**
15
16
  *
@@ -155,6 +156,12 @@ export interface OmitTypeClass {
155
156
  * @memberof OmitTypeClass
156
157
  */
157
158
  'updatedBy': string;
159
+ /**
160
+ * Invoice payment method.
161
+ * @type {InvoicePaymentMethodClass}
162
+ * @memberof OmitTypeClass
163
+ */
164
+ 'paymentMethod': InvoicePaymentMethodClass;
158
165
  }
159
166
  export declare const OmitTypeClassTypeEnum: {
160
167
  readonly Initial: "initial";
package/models/index.ts CHANGED
@@ -21,6 +21,7 @@ export * from './inline-response503';
21
21
  export * from './invoice-class';
22
22
  export * from './invoice-item-class';
23
23
  export * from './invoice-payment-class';
24
+ export * from './invoice-payment-method-class';
24
25
  export * from './invoice-payments-class';
25
26
  export * from './invoice-status-class';
26
27
  export * from './list-invoices-response-class';
@@ -14,6 +14,7 @@
14
14
 
15
15
 
16
16
  import { InvoiceItemClass } from './invoice-item-class';
17
+ import { InvoicePaymentMethodClass } from './invoice-payment-method-class';
17
18
  import { InvoicePaymentsClass } from './invoice-payments-class';
18
19
  import { InvoiceStatusClass } from './invoice-status-class';
19
20
 
@@ -167,6 +168,12 @@ export interface InvoiceClass {
167
168
  * @memberof InvoiceClass
168
169
  */
169
170
  'updatedBy': string;
171
+ /**
172
+ * Invoice payment method.
173
+ * @type {InvoicePaymentMethodClass}
174
+ * @memberof InvoiceClass
175
+ */
176
+ 'paymentMethod': InvoicePaymentMethodClass;
170
177
  }
171
178
 
172
179
  export const InvoiceClassTypeEnum = {
@@ -0,0 +1,78 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * EMIL BillingService
5
+ * The EMIL BillingService API description
6
+ *
7
+ * The version of the OpenAPI document: 1.0
8
+ * Contact: kontakt@emil.de
9
+ *
10
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11
+ * https://openapi-generator.tech
12
+ * Do not edit the class manually.
13
+ */
14
+
15
+
16
+
17
+ /**
18
+ *
19
+ * @export
20
+ * @interface InvoicePaymentMethodClass
21
+ */
22
+ export interface InvoicePaymentMethodClass {
23
+ /**
24
+ * Internal unique identifier for the object. You should not have to use this, use code instead.
25
+ * @type {number}
26
+ * @memberof InvoicePaymentMethodClass
27
+ */
28
+ 'id': number;
29
+ /**
30
+ * Unique identifier for the object.
31
+ * @type {string}
32
+ * @memberof InvoicePaymentMethodClass
33
+ */
34
+ 'code': string;
35
+ /**
36
+ * The payment service provider associated with this payment method.
37
+ * @type {string}
38
+ * @memberof InvoicePaymentMethodClass
39
+ */
40
+ 'psp': string;
41
+ /**
42
+ * The payment method type.
43
+ * @type {string}
44
+ * @memberof InvoicePaymentMethodClass
45
+ */
46
+ 'type': string;
47
+ /**
48
+ * A unique identifier generated by the payment service provider for this payment method.
49
+ * @type {string}
50
+ * @memberof InvoicePaymentMethodClass
51
+ */
52
+ 'providerToken': string;
53
+ /**
54
+ * Customer identifier for the payment service provider.
55
+ * @type {string}
56
+ * @memberof InvoicePaymentMethodClass
57
+ */
58
+ 'pspCustomerId': string;
59
+ /**
60
+ * A slug is a human-readable, unique identifier, used to identify a resource instead of a less human-readable identifier like an id.
61
+ * @type {string}
62
+ * @memberof InvoicePaymentMethodClass
63
+ */
64
+ 'productSlug'?: string;
65
+ /**
66
+ * Identifier of the user who created the record.
67
+ * @type {string}
68
+ * @memberof InvoicePaymentMethodClass
69
+ */
70
+ 'createdBy': string;
71
+ /**
72
+ * Identifier of the user who last updated the record.
73
+ * @type {string}
74
+ * @memberof InvoicePaymentMethodClass
75
+ */
76
+ 'updatedBy': string;
77
+ }
78
+
@@ -14,6 +14,7 @@
14
14
 
15
15
 
16
16
  import { InvoiceItemClass } from './invoice-item-class';
17
+ import { InvoicePaymentMethodClass } from './invoice-payment-method-class';
17
18
  import { InvoicePaymentsClass } from './invoice-payments-class';
18
19
 
19
20
  /**
@@ -160,6 +161,12 @@ export interface OmitTypeClass {
160
161
  * @memberof OmitTypeClass
161
162
  */
162
163
  'updatedBy': string;
164
+ /**
165
+ * Invoice payment method.
166
+ * @type {InvoicePaymentMethodClass}
167
+ * @memberof OmitTypeClass
168
+ */
169
+ 'paymentMethod': InvoicePaymentMethodClass;
163
170
  }
164
171
 
165
172
  export const OmitTypeClassTypeEnum = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@emilgroup/billing-sdk-node",
3
- "version": "1.48.1-beta.9",
3
+ "version": "1.49.0",
4
4
  "description": "OpenAPI client for @emilgroup/billing-sdk-node",
5
5
  "author": "OpenAPI-Generator Contributors",
6
6
  "keywords": [