@emilgroup/partner-sdk-node 1.15.1-beta.1 → 1.16.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/README.md +2 -2
- package/api/partners-api.ts +7 -20
- package/base.ts +45 -3
- package/dist/api/partners-api.d.ts +3 -12
- package/dist/api/partners-api.js +7 -13
- package/dist/base.d.ts +11 -2
- package/dist/base.js +42 -3
- package/package.json +1 -1
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/partner-sdk-node@1.
|
|
20
|
+
npm install @emilgroup/partner-sdk-node@1.16.0 --save
|
|
21
21
|
```
|
|
22
22
|
or
|
|
23
23
|
```
|
|
24
|
-
yarn add @emilgroup/partner-sdk-node@1.
|
|
24
|
+
yarn add @emilgroup/partner-sdk-node@1.16.0
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
And then you can import `PartnersApi`.
|
package/api/partners-api.ts
CHANGED
|
@@ -57,19 +57,15 @@ export const PartnersApiAxiosParamCreator = function (configuration?: Configurat
|
|
|
57
57
|
/**
|
|
58
58
|
* Creates or updates a partner from an account. Resolves the account by partner code if not provided. **Required Permissions** \"partner-management.partners.create\"
|
|
59
59
|
* @summary Retrieve the create or update partner from account
|
|
60
|
-
* @param {any} code Unique identifier for the object.
|
|
61
60
|
* @param {CreateOrUpdatePartnerFromAccountRequestDto} createOrUpdatePartnerFromAccountRequestDto
|
|
62
61
|
* @param {string} [authorization] Bearer Token: provided by the login endpoint under the name accessToken.
|
|
63
62
|
* @param {*} [options] Override http request option.
|
|
64
63
|
* @throws {RequiredError}
|
|
65
64
|
*/
|
|
66
|
-
createOrUpdatePartnerFromAccount: async (
|
|
67
|
-
// verify required parameter 'code' is not null or undefined
|
|
68
|
-
assertParamExists('createOrUpdatePartnerFromAccount', 'code', code)
|
|
65
|
+
createOrUpdatePartnerFromAccount: async (createOrUpdatePartnerFromAccountRequestDto: CreateOrUpdatePartnerFromAccountRequestDto, authorization?: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
|
|
69
66
|
// verify required parameter 'createOrUpdatePartnerFromAccountRequestDto' is not null or undefined
|
|
70
67
|
assertParamExists('createOrUpdatePartnerFromAccount', 'createOrUpdatePartnerFromAccountRequestDto', createOrUpdatePartnerFromAccountRequestDto)
|
|
71
|
-
const localVarPath = `/partnerservice/v1/partners/create-or-update-partner-from-account
|
|
72
|
-
.replace(`{${"code"}}`, encodeURIComponent(String(code)));
|
|
68
|
+
const localVarPath = `/partnerservice/v1/partners/create-or-update-partner-from-account`;
|
|
73
69
|
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
|
74
70
|
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
|
75
71
|
let baseOptions;
|
|
@@ -563,14 +559,13 @@ export const PartnersApiFp = function(configuration?: Configuration) {
|
|
|
563
559
|
/**
|
|
564
560
|
* Creates or updates a partner from an account. Resolves the account by partner code if not provided. **Required Permissions** \"partner-management.partners.create\"
|
|
565
561
|
* @summary Retrieve the create or update partner from account
|
|
566
|
-
* @param {any} code Unique identifier for the object.
|
|
567
562
|
* @param {CreateOrUpdatePartnerFromAccountRequestDto} createOrUpdatePartnerFromAccountRequestDto
|
|
568
563
|
* @param {string} [authorization] Bearer Token: provided by the login endpoint under the name accessToken.
|
|
569
564
|
* @param {*} [options] Override http request option.
|
|
570
565
|
* @throws {RequiredError}
|
|
571
566
|
*/
|
|
572
|
-
async createOrUpdatePartnerFromAccount(
|
|
573
|
-
const localVarAxiosArgs = await localVarAxiosParamCreator.createOrUpdatePartnerFromAccount(
|
|
567
|
+
async createOrUpdatePartnerFromAccount(createOrUpdatePartnerFromAccountRequestDto: CreateOrUpdatePartnerFromAccountRequestDto, authorization?: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<CreateOrUpdatePartnerFromAccountResponseClass>> {
|
|
568
|
+
const localVarAxiosArgs = await localVarAxiosParamCreator.createOrUpdatePartnerFromAccount(createOrUpdatePartnerFromAccountRequestDto, authorization, options);
|
|
574
569
|
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
|
575
570
|
},
|
|
576
571
|
/**
|
|
@@ -698,14 +693,13 @@ export const PartnersApiFactory = function (configuration?: Configuration, baseP
|
|
|
698
693
|
/**
|
|
699
694
|
* Creates or updates a partner from an account. Resolves the account by partner code if not provided. **Required Permissions** \"partner-management.partners.create\"
|
|
700
695
|
* @summary Retrieve the create or update partner from account
|
|
701
|
-
* @param {any} code Unique identifier for the object.
|
|
702
696
|
* @param {CreateOrUpdatePartnerFromAccountRequestDto} createOrUpdatePartnerFromAccountRequestDto
|
|
703
697
|
* @param {string} [authorization] Bearer Token: provided by the login endpoint under the name accessToken.
|
|
704
698
|
* @param {*} [options] Override http request option.
|
|
705
699
|
* @throws {RequiredError}
|
|
706
700
|
*/
|
|
707
|
-
createOrUpdatePartnerFromAccount(
|
|
708
|
-
return localVarFp.createOrUpdatePartnerFromAccount(
|
|
701
|
+
createOrUpdatePartnerFromAccount(createOrUpdatePartnerFromAccountRequestDto: CreateOrUpdatePartnerFromAccountRequestDto, authorization?: string, options?: any): AxiosPromise<CreateOrUpdatePartnerFromAccountResponseClass> {
|
|
702
|
+
return localVarFp.createOrUpdatePartnerFromAccount(createOrUpdatePartnerFromAccountRequestDto, authorization, options).then((request) => request(axios, basePath));
|
|
709
703
|
},
|
|
710
704
|
/**
|
|
711
705
|
* This will create a partner. **Required Permissions** \"partner-management.partners.create\"
|
|
@@ -820,13 +814,6 @@ export const PartnersApiFactory = function (configuration?: Configuration, baseP
|
|
|
820
814
|
* @interface PartnersApiCreateOrUpdatePartnerFromAccountRequest
|
|
821
815
|
*/
|
|
822
816
|
export interface PartnersApiCreateOrUpdatePartnerFromAccountRequest {
|
|
823
|
-
/**
|
|
824
|
-
* Unique identifier for the object.
|
|
825
|
-
* @type {any}
|
|
826
|
-
* @memberof PartnersApiCreateOrUpdatePartnerFromAccount
|
|
827
|
-
*/
|
|
828
|
-
readonly code: any
|
|
829
|
-
|
|
830
817
|
/**
|
|
831
818
|
*
|
|
832
819
|
* @type {CreateOrUpdatePartnerFromAccountRequestDto}
|
|
@@ -1138,7 +1125,7 @@ export class PartnersApi extends BaseAPI {
|
|
|
1138
1125
|
* @memberof PartnersApi
|
|
1139
1126
|
*/
|
|
1140
1127
|
public createOrUpdatePartnerFromAccount(requestParameters: PartnersApiCreateOrUpdatePartnerFromAccountRequest, options?: AxiosRequestConfig) {
|
|
1141
|
-
return PartnersApiFp(this.configuration).createOrUpdatePartnerFromAccount(requestParameters.
|
|
1128
|
+
return PartnersApiFp(this.configuration).createOrUpdatePartnerFromAccount(requestParameters.createOrUpdatePartnerFromAccountRequestDto, requestParameters.authorization, options).then((request) => request(this.axios, this.basePath));
|
|
1142
1129
|
}
|
|
1143
1130
|
|
|
1144
1131
|
/**
|
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> {
|
|
@@ -32,13 +32,12 @@ export declare const PartnersApiAxiosParamCreator: (configuration?: Configuratio
|
|
|
32
32
|
/**
|
|
33
33
|
* Creates or updates a partner from an account. Resolves the account by partner code if not provided. **Required Permissions** \"partner-management.partners.create\"
|
|
34
34
|
* @summary Retrieve the create or update partner from account
|
|
35
|
-
* @param {any} code Unique identifier for the object.
|
|
36
35
|
* @param {CreateOrUpdatePartnerFromAccountRequestDto} createOrUpdatePartnerFromAccountRequestDto
|
|
37
36
|
* @param {string} [authorization] Bearer Token: provided by the login endpoint under the name accessToken.
|
|
38
37
|
* @param {*} [options] Override http request option.
|
|
39
38
|
* @throws {RequiredError}
|
|
40
39
|
*/
|
|
41
|
-
createOrUpdatePartnerFromAccount: (
|
|
40
|
+
createOrUpdatePartnerFromAccount: (createOrUpdatePartnerFromAccountRequestDto: CreateOrUpdatePartnerFromAccountRequestDto, authorization?: string, options?: AxiosRequestConfig) => Promise<RequestArgs>;
|
|
42
41
|
/**
|
|
43
42
|
* This will create a partner. **Required Permissions** \"partner-management.partners.create\"
|
|
44
43
|
* @summary Create the partner
|
|
@@ -136,13 +135,12 @@ export declare const PartnersApiFp: (configuration?: Configuration) => {
|
|
|
136
135
|
/**
|
|
137
136
|
* Creates or updates a partner from an account. Resolves the account by partner code if not provided. **Required Permissions** \"partner-management.partners.create\"
|
|
138
137
|
* @summary Retrieve the create or update partner from account
|
|
139
|
-
* @param {any} code Unique identifier for the object.
|
|
140
138
|
* @param {CreateOrUpdatePartnerFromAccountRequestDto} createOrUpdatePartnerFromAccountRequestDto
|
|
141
139
|
* @param {string} [authorization] Bearer Token: provided by the login endpoint under the name accessToken.
|
|
142
140
|
* @param {*} [options] Override http request option.
|
|
143
141
|
* @throws {RequiredError}
|
|
144
142
|
*/
|
|
145
|
-
createOrUpdatePartnerFromAccount(
|
|
143
|
+
createOrUpdatePartnerFromAccount(createOrUpdatePartnerFromAccountRequestDto: CreateOrUpdatePartnerFromAccountRequestDto, authorization?: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<CreateOrUpdatePartnerFromAccountResponseClass>>;
|
|
146
144
|
/**
|
|
147
145
|
* This will create a partner. **Required Permissions** \"partner-management.partners.create\"
|
|
148
146
|
* @summary Create the partner
|
|
@@ -240,13 +238,12 @@ export declare const PartnersApiFactory: (configuration?: Configuration, basePat
|
|
|
240
238
|
/**
|
|
241
239
|
* Creates or updates a partner from an account. Resolves the account by partner code if not provided. **Required Permissions** \"partner-management.partners.create\"
|
|
242
240
|
* @summary Retrieve the create or update partner from account
|
|
243
|
-
* @param {any} code Unique identifier for the object.
|
|
244
241
|
* @param {CreateOrUpdatePartnerFromAccountRequestDto} createOrUpdatePartnerFromAccountRequestDto
|
|
245
242
|
* @param {string} [authorization] Bearer Token: provided by the login endpoint under the name accessToken.
|
|
246
243
|
* @param {*} [options] Override http request option.
|
|
247
244
|
* @throws {RequiredError}
|
|
248
245
|
*/
|
|
249
|
-
createOrUpdatePartnerFromAccount(
|
|
246
|
+
createOrUpdatePartnerFromAccount(createOrUpdatePartnerFromAccountRequestDto: CreateOrUpdatePartnerFromAccountRequestDto, authorization?: string, options?: any): AxiosPromise<CreateOrUpdatePartnerFromAccountResponseClass>;
|
|
250
247
|
/**
|
|
251
248
|
* This will create a partner. **Required Permissions** \"partner-management.partners.create\"
|
|
252
249
|
* @summary Create the partner
|
|
@@ -342,12 +339,6 @@ export declare const PartnersApiFactory: (configuration?: Configuration, basePat
|
|
|
342
339
|
* @interface PartnersApiCreateOrUpdatePartnerFromAccountRequest
|
|
343
340
|
*/
|
|
344
341
|
export interface PartnersApiCreateOrUpdatePartnerFromAccountRequest {
|
|
345
|
-
/**
|
|
346
|
-
* Unique identifier for the object.
|
|
347
|
-
* @type {any}
|
|
348
|
-
* @memberof PartnersApiCreateOrUpdatePartnerFromAccount
|
|
349
|
-
*/
|
|
350
|
-
readonly code: any;
|
|
351
342
|
/**
|
|
352
343
|
*
|
|
353
344
|
* @type {CreateOrUpdatePartnerFromAccountRequestDto}
|
package/dist/api/partners-api.js
CHANGED
|
@@ -99,25 +99,21 @@ var PartnersApiAxiosParamCreator = function (configuration) {
|
|
|
99
99
|
/**
|
|
100
100
|
* Creates or updates a partner from an account. Resolves the account by partner code if not provided. **Required Permissions** \"partner-management.partners.create\"
|
|
101
101
|
* @summary Retrieve the create or update partner from account
|
|
102
|
-
* @param {any} code Unique identifier for the object.
|
|
103
102
|
* @param {CreateOrUpdatePartnerFromAccountRequestDto} createOrUpdatePartnerFromAccountRequestDto
|
|
104
103
|
* @param {string} [authorization] Bearer Token: provided by the login endpoint under the name accessToken.
|
|
105
104
|
* @param {*} [options] Override http request option.
|
|
106
105
|
* @throws {RequiredError}
|
|
107
106
|
*/
|
|
108
|
-
createOrUpdatePartnerFromAccount: function (
|
|
107
|
+
createOrUpdatePartnerFromAccount: function (createOrUpdatePartnerFromAccountRequestDto, authorization, options) {
|
|
109
108
|
if (options === void 0) { options = {}; }
|
|
110
109
|
return __awaiter(_this, void 0, void 0, function () {
|
|
111
110
|
var localVarPath, localVarUrlObj, baseOptions, baseAccessToken, localVarRequestOptions, localVarHeaderParameter, localVarQueryParameter, headersFromBaseOptions;
|
|
112
111
|
return __generator(this, function (_a) {
|
|
113
112
|
switch (_a.label) {
|
|
114
113
|
case 0:
|
|
115
|
-
// verify required parameter 'code' is not null or undefined
|
|
116
|
-
(0, common_1.assertParamExists)('createOrUpdatePartnerFromAccount', 'code', code);
|
|
117
114
|
// verify required parameter 'createOrUpdatePartnerFromAccountRequestDto' is not null or undefined
|
|
118
115
|
(0, common_1.assertParamExists)('createOrUpdatePartnerFromAccount', 'createOrUpdatePartnerFromAccountRequestDto', createOrUpdatePartnerFromAccountRequestDto);
|
|
119
|
-
localVarPath = "/partnerservice/v1/partners/create-or-update-partner-from-account"
|
|
120
|
-
.replace("{".concat("code", "}"), encodeURIComponent(String(code)));
|
|
116
|
+
localVarPath = "/partnerservice/v1/partners/create-or-update-partner-from-account";
|
|
121
117
|
localVarUrlObj = new url_1.URL(localVarPath, common_1.DUMMY_BASE_URL);
|
|
122
118
|
if (configuration) {
|
|
123
119
|
baseOptions = configuration.baseOptions;
|
|
@@ -613,18 +609,17 @@ var PartnersApiFp = function (configuration) {
|
|
|
613
609
|
/**
|
|
614
610
|
* Creates or updates a partner from an account. Resolves the account by partner code if not provided. **Required Permissions** \"partner-management.partners.create\"
|
|
615
611
|
* @summary Retrieve the create or update partner from account
|
|
616
|
-
* @param {any} code Unique identifier for the object.
|
|
617
612
|
* @param {CreateOrUpdatePartnerFromAccountRequestDto} createOrUpdatePartnerFromAccountRequestDto
|
|
618
613
|
* @param {string} [authorization] Bearer Token: provided by the login endpoint under the name accessToken.
|
|
619
614
|
* @param {*} [options] Override http request option.
|
|
620
615
|
* @throws {RequiredError}
|
|
621
616
|
*/
|
|
622
|
-
createOrUpdatePartnerFromAccount: function (
|
|
617
|
+
createOrUpdatePartnerFromAccount: function (createOrUpdatePartnerFromAccountRequestDto, authorization, options) {
|
|
623
618
|
return __awaiter(this, void 0, void 0, function () {
|
|
624
619
|
var localVarAxiosArgs;
|
|
625
620
|
return __generator(this, function (_a) {
|
|
626
621
|
switch (_a.label) {
|
|
627
|
-
case 0: return [4 /*yield*/, localVarAxiosParamCreator.createOrUpdatePartnerFromAccount(
|
|
622
|
+
case 0: return [4 /*yield*/, localVarAxiosParamCreator.createOrUpdatePartnerFromAccount(createOrUpdatePartnerFromAccountRequestDto, authorization, options)];
|
|
628
623
|
case 1:
|
|
629
624
|
localVarAxiosArgs = _a.sent();
|
|
630
625
|
return [2 /*return*/, (0, common_1.createRequestFunction)(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration)];
|
|
@@ -829,14 +824,13 @@ var PartnersApiFactory = function (configuration, basePath, axios) {
|
|
|
829
824
|
/**
|
|
830
825
|
* Creates or updates a partner from an account. Resolves the account by partner code if not provided. **Required Permissions** \"partner-management.partners.create\"
|
|
831
826
|
* @summary Retrieve the create or update partner from account
|
|
832
|
-
* @param {any} code Unique identifier for the object.
|
|
833
827
|
* @param {CreateOrUpdatePartnerFromAccountRequestDto} createOrUpdatePartnerFromAccountRequestDto
|
|
834
828
|
* @param {string} [authorization] Bearer Token: provided by the login endpoint under the name accessToken.
|
|
835
829
|
* @param {*} [options] Override http request option.
|
|
836
830
|
* @throws {RequiredError}
|
|
837
831
|
*/
|
|
838
|
-
createOrUpdatePartnerFromAccount: function (
|
|
839
|
-
return localVarFp.createOrUpdatePartnerFromAccount(
|
|
832
|
+
createOrUpdatePartnerFromAccount: function (createOrUpdatePartnerFromAccountRequestDto, authorization, options) {
|
|
833
|
+
return localVarFp.createOrUpdatePartnerFromAccount(createOrUpdatePartnerFromAccountRequestDto, authorization, options).then(function (request) { return request(axios, basePath); });
|
|
840
834
|
},
|
|
841
835
|
/**
|
|
842
836
|
* This will create a partner. **Required Permissions** \"partner-management.partners.create\"
|
|
@@ -966,7 +960,7 @@ var PartnersApi = /** @class */ (function (_super) {
|
|
|
966
960
|
*/
|
|
967
961
|
PartnersApi.prototype.createOrUpdatePartnerFromAccount = function (requestParameters, options) {
|
|
968
962
|
var _this = this;
|
|
969
|
-
return (0, exports.PartnersApiFp)(this.configuration).createOrUpdatePartnerFromAccount(requestParameters.
|
|
963
|
+
return (0, exports.PartnersApiFp)(this.configuration).createOrUpdatePartnerFromAccount(requestParameters.createOrUpdatePartnerFromAccountRequestDto, requestParameters.authorization, options).then(function (request) { return request(_this.axios, _this.basePath); });
|
|
970
964
|
};
|
|
971
965
|
/**
|
|
972
966
|
* This will create a partner. **Required Permissions** \"partner-management.partners.create\"
|
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
|
});
|