@emilgroup/discount-sdk 1.4.0 → 1.5.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/base.ts +55 -2
- package/dist/api/campaigns-api.d.ts +11 -11
- package/dist/api/default-api.d.ts +1 -1
- package/dist/api/policy-vouchers-api.d.ts +8 -8
- package/dist/api/vouchers-api.d.ts +5 -5
- package/dist/base.d.ts +10 -1
- package/dist/base.js +48 -2
- package/dist/common.d.ts +1 -1
- package/package.json +2 -2
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/discount-sdk@1.
|
|
20
|
+
npm install @emilgroup/discount-sdk@1.5.0 --save
|
|
21
21
|
```
|
|
22
22
|
or
|
|
23
23
|
```
|
|
24
|
-
yarn add @emilgroup/discount-sdk@1.
|
|
24
|
+
yarn add @emilgroup/discount-sdk@1.5.0
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
And then you can import `CampaignApi`.
|
package/base.ts
CHANGED
|
@@ -37,6 +37,16 @@ export interface LoginClass {
|
|
|
37
37
|
permissions: string;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
export interface SwitchWorkspaceRequest {
|
|
41
|
+
username: string;
|
|
42
|
+
targetWorkspace: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface SwitchWorkspaceResponseClass {
|
|
46
|
+
accessToken: string;
|
|
47
|
+
permissions: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
40
50
|
export enum Environment {
|
|
41
51
|
Production = 'https://apiv2.emil.de',
|
|
42
52
|
Test = 'https://apiv2-test.emil.de',
|
|
@@ -87,9 +97,14 @@ export class BaseAPI {
|
|
|
87
97
|
this.loadTokenData();
|
|
88
98
|
|
|
89
99
|
if (configuration) {
|
|
100
|
+
const { accessToken } = this.tokenData;
|
|
90
101
|
this.configuration = configuration;
|
|
91
102
|
this.basePath = configuration.basePath || this.basePath;
|
|
92
|
-
|
|
103
|
+
|
|
104
|
+
// Use config token if provided, otherwise use tokenData token
|
|
105
|
+
const configToken = this.configuration.accessToken;
|
|
106
|
+
const storedToken = accessToken ? `Bearer ${accessToken}` : '';
|
|
107
|
+
this.configuration.accessToken = configToken || storedToken;
|
|
93
108
|
} else {
|
|
94
109
|
const { accessToken, username } = this.tokenData;
|
|
95
110
|
|
|
@@ -119,7 +134,7 @@ export class BaseAPI {
|
|
|
119
134
|
return this.tokenData.permissions.split(',');
|
|
120
135
|
}
|
|
121
136
|
|
|
122
|
-
async authorize(username: string, password: string): Promise<void> {
|
|
137
|
+
async authorize(username: string, password: string, targetWorkspace?: string): Promise<void> {
|
|
123
138
|
const options: AxiosRequestConfig = {
|
|
124
139
|
method: 'POST',
|
|
125
140
|
url: `${this.configuration.basePath}/authservice/v1/login`,
|
|
@@ -141,6 +156,44 @@ export class BaseAPI {
|
|
|
141
156
|
this.tokenData.accessToken = accessToken;
|
|
142
157
|
this.tokenData.permissions = permissions;
|
|
143
158
|
|
|
159
|
+
// Switch workspace if provided
|
|
160
|
+
if (targetWorkspace) {
|
|
161
|
+
await this.switchWorkspace(targetWorkspace);
|
|
162
|
+
} else {
|
|
163
|
+
// Only store if no workspace switch (since switchWorkspace will store after switching)
|
|
164
|
+
this.storeTokenData({
|
|
165
|
+
...this.tokenData
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
this.storeTokenData({
|
|
170
|
+
...this.tokenData
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
async switchWorkspace(targetWorkspace: string): Promise<void> {
|
|
175
|
+
const options: AxiosRequestConfig = {
|
|
176
|
+
method: 'POST',
|
|
177
|
+
url: `${this.configuration.basePath}/authservice/v1/workspaces/switch`,
|
|
178
|
+
headers: {
|
|
179
|
+
'Content-Type': 'application/json',
|
|
180
|
+
'Authorization': `Bearer ${this.configuration.accessToken}`,
|
|
181
|
+
},
|
|
182
|
+
data: {
|
|
183
|
+
username: this.configuration.username,
|
|
184
|
+
targetWorkspace,
|
|
185
|
+
} as SwitchWorkspaceRequest,
|
|
186
|
+
withCredentials: true,
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
const response = await globalAxios.request<SwitchWorkspaceResponseClass>(options);
|
|
190
|
+
|
|
191
|
+
const { data: { accessToken, permissions } } = response;
|
|
192
|
+
|
|
193
|
+
this.configuration.accessToken = `Bearer ${accessToken}`;
|
|
194
|
+
this.tokenData.accessToken = accessToken;
|
|
195
|
+
this.tokenData.permissions = permissions;
|
|
196
|
+
|
|
144
197
|
this.storeTokenData({
|
|
145
198
|
...this.tokenData
|
|
146
199
|
});
|
|
@@ -714,7 +714,7 @@ export declare class CampaignsApi extends BaseAPI {
|
|
|
714
714
|
* @throws {RequiredError}
|
|
715
715
|
* @memberof CampaignsApi
|
|
716
716
|
*/
|
|
717
|
-
createCampaign(requestParameters: CampaignsApiCreateCampaignRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<CreateCampaignResponseClass, any>>;
|
|
717
|
+
createCampaign(requestParameters: CampaignsApiCreateCampaignRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<CreateCampaignResponseClass, any, {}>>;
|
|
718
718
|
/**
|
|
719
719
|
* Creates an account that is eligible to redeem a vouchers from a specific campaign.
|
|
720
720
|
* @summary Create the Eligible Account
|
|
@@ -723,7 +723,7 @@ export declare class CampaignsApi extends BaseAPI {
|
|
|
723
723
|
* @throws {RequiredError}
|
|
724
724
|
* @memberof CampaignsApi
|
|
725
725
|
*/
|
|
726
|
-
createEligibleAccount(requestParameters: CampaignsApiCreateEligibleAccountRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<CreateEligibleAccountResponseClass, any>>;
|
|
726
|
+
createEligibleAccount(requestParameters: CampaignsApiCreateEligibleAccountRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<CreateEligibleAccountResponseClass, any, {}>>;
|
|
727
727
|
/**
|
|
728
728
|
* Removes a campaign and its associated vouchers. This will prevent any further voucher redemptions.
|
|
729
729
|
* @summary Delete the Campaign
|
|
@@ -732,7 +732,7 @@ export declare class CampaignsApi extends BaseAPI {
|
|
|
732
732
|
* @throws {RequiredError}
|
|
733
733
|
* @memberof CampaignsApi
|
|
734
734
|
*/
|
|
735
|
-
deleteCampaign(requestParameters: CampaignsApiDeleteCampaignRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<void, any>>;
|
|
735
|
+
deleteCampaign(requestParameters: CampaignsApiDeleteCampaignRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<void, any, {}>>;
|
|
736
736
|
/**
|
|
737
737
|
* Removes an eligible account from a campaign. This will prevent the account from using the assigned voucher code for discounts when the campaign is released.
|
|
738
738
|
* @summary Delete the Eligible Account
|
|
@@ -741,7 +741,7 @@ export declare class CampaignsApi extends BaseAPI {
|
|
|
741
741
|
* @throws {RequiredError}
|
|
742
742
|
* @memberof CampaignsApi
|
|
743
743
|
*/
|
|
744
|
-
deleteEligibleAccount(requestParameters: CampaignsApiDeleteEligibleAccountRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<void, any>>;
|
|
744
|
+
deleteEligibleAccount(requestParameters: CampaignsApiDeleteEligibleAccountRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<void, any, {}>>;
|
|
745
745
|
/**
|
|
746
746
|
* Removes all eligible accounts from a campaign. This will prevent these accounts from using their assigned voucher codes for discounts when the campaign is released.
|
|
747
747
|
* @summary Delete the Eligible Accounts
|
|
@@ -750,7 +750,7 @@ export declare class CampaignsApi extends BaseAPI {
|
|
|
750
750
|
* @throws {RequiredError}
|
|
751
751
|
* @memberof CampaignsApi
|
|
752
752
|
*/
|
|
753
|
-
deleteEligibleAccounts(requestParameters: CampaignsApiDeleteEligibleAccountsRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<void, any>>;
|
|
753
|
+
deleteEligibleAccounts(requestParameters: CampaignsApiDeleteEligibleAccountsRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<void, any, {}>>;
|
|
754
754
|
/**
|
|
755
755
|
* Retrieves detailed information about a specific campaign.
|
|
756
756
|
* @summary Retrieve the Campaign
|
|
@@ -759,7 +759,7 @@ export declare class CampaignsApi extends BaseAPI {
|
|
|
759
759
|
* @throws {RequiredError}
|
|
760
760
|
* @memberof CampaignsApi
|
|
761
761
|
*/
|
|
762
|
-
getCampaign(requestParameters: CampaignsApiGetCampaignRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<GetCampaignResponseClass, any>>;
|
|
762
|
+
getCampaign(requestParameters: CampaignsApiGetCampaignRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<GetCampaignResponseClass, any, {}>>;
|
|
763
763
|
/**
|
|
764
764
|
* Retrieves a list of campaigns.
|
|
765
765
|
* @summary List Campaigns
|
|
@@ -768,7 +768,7 @@ export declare class CampaignsApi extends BaseAPI {
|
|
|
768
768
|
* @throws {RequiredError}
|
|
769
769
|
* @memberof CampaignsApi
|
|
770
770
|
*/
|
|
771
|
-
listCampaigns(requestParameters?: CampaignsApiListCampaignsRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<ListCampaignsResponseClass, any>>;
|
|
771
|
+
listCampaigns(requestParameters?: CampaignsApiListCampaignsRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<ListCampaignsResponseClass, any, {}>>;
|
|
772
772
|
/**
|
|
773
773
|
* Retrieves a list of eligible accounts.
|
|
774
774
|
* @summary List Eligible Accounts
|
|
@@ -777,7 +777,7 @@ export declare class CampaignsApi extends BaseAPI {
|
|
|
777
777
|
* @throws {RequiredError}
|
|
778
778
|
* @memberof CampaignsApi
|
|
779
779
|
*/
|
|
780
|
-
listEligibleAccounts(requestParameters?: CampaignsApiListEligibleAccountsRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<ListEligibleAccountsResponseClass, any>>;
|
|
780
|
+
listEligibleAccounts(requestParameters?: CampaignsApiListEligibleAccountsRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<ListEligibleAccountsResponseClass, any, {}>>;
|
|
781
781
|
/**
|
|
782
782
|
* Updates the data of an existing campaign. Only DRAFT campaigns can be updated.
|
|
783
783
|
* @summary Update the Campaign
|
|
@@ -786,7 +786,7 @@ export declare class CampaignsApi extends BaseAPI {
|
|
|
786
786
|
* @throws {RequiredError}
|
|
787
787
|
* @memberof CampaignsApi
|
|
788
788
|
*/
|
|
789
|
-
updateCampaign(requestParameters: CampaignsApiUpdateCampaignRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<UpdateCampaignResponseClass, any>>;
|
|
789
|
+
updateCampaign(requestParameters: CampaignsApiUpdateCampaignRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<UpdateCampaignResponseClass, any, {}>>;
|
|
790
790
|
/**
|
|
791
791
|
* Updates the status of a campaign, which affects whether vouchers can be redeemed.
|
|
792
792
|
* @summary Updates the status of a campaign.
|
|
@@ -795,7 +795,7 @@ export declare class CampaignsApi extends BaseAPI {
|
|
|
795
795
|
* @throws {RequiredError}
|
|
796
796
|
* @memberof CampaignsApi
|
|
797
797
|
*/
|
|
798
|
-
updateCampaignStatus(requestParameters: CampaignsApiUpdateCampaignStatusRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<void, any>>;
|
|
798
|
+
updateCampaignStatus(requestParameters: CampaignsApiUpdateCampaignStatusRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<void, any, {}>>;
|
|
799
799
|
/**
|
|
800
800
|
* Uploads accounts that are eligible to redeem vouchers from a specific campaign using a CSV file. The CSV file must contain a header row with the following columns: partnerNumber, voucherCode. Separate each column with a comma.
|
|
801
801
|
* @summary Uploads the eligible accounts.
|
|
@@ -804,5 +804,5 @@ export declare class CampaignsApi extends BaseAPI {
|
|
|
804
804
|
* @throws {RequiredError}
|
|
805
805
|
* @memberof CampaignsApi
|
|
806
806
|
*/
|
|
807
|
-
uploadEligibleAccounts(requestParameters: CampaignsApiUploadEligibleAccountsRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<void, any>>;
|
|
807
|
+
uploadEligibleAccounts(requestParameters: CampaignsApiUploadEligibleAccountsRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<void, any, {}>>;
|
|
808
808
|
}
|
|
@@ -66,5 +66,5 @@ export declare class DefaultApi extends BaseAPI {
|
|
|
66
66
|
* @throws {RequiredError}
|
|
67
67
|
* @memberof DefaultApi
|
|
68
68
|
*/
|
|
69
|
-
check(options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<InlineResponse200, any>>;
|
|
69
|
+
check(options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<InlineResponse200, any, {}>>;
|
|
70
70
|
}
|
|
@@ -488,7 +488,7 @@ export declare class PolicyVouchersApi extends BaseAPI {
|
|
|
488
488
|
* @throws {RequiredError}
|
|
489
489
|
* @memberof PolicyVouchersApi
|
|
490
490
|
*/
|
|
491
|
-
chargePolicyVoucher(requestParameters: PolicyVouchersApiChargePolicyVoucherRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<ChargePolicyVoucherResponseClass, any>>;
|
|
491
|
+
chargePolicyVoucher(requestParameters: PolicyVouchersApiChargePolicyVoucherRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<ChargePolicyVoucherResponseClass, any, {}>>;
|
|
492
492
|
/**
|
|
493
493
|
* This will check if the account is eligible for a specific voucher.
|
|
494
494
|
* @summary Checks the account eligibility.
|
|
@@ -497,7 +497,7 @@ export declare class PolicyVouchersApi extends BaseAPI {
|
|
|
497
497
|
* @throws {RequiredError}
|
|
498
498
|
* @memberof PolicyVouchersApi
|
|
499
499
|
*/
|
|
500
|
-
checkAccountEligibility(requestParameters: PolicyVouchersApiCheckAccountEligibilityRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<CheckAccountEligibilityResponseClass, any>>;
|
|
500
|
+
checkAccountEligibility(requestParameters: PolicyVouchersApiCheckAccountEligibilityRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<CheckAccountEligibilityResponseClass, any, {}>>;
|
|
501
501
|
/**
|
|
502
502
|
* This will create an policy voucher.
|
|
503
503
|
* @summary Create the policy voucher
|
|
@@ -506,7 +506,7 @@ export declare class PolicyVouchersApi extends BaseAPI {
|
|
|
506
506
|
* @throws {RequiredError}
|
|
507
507
|
* @memberof PolicyVouchersApi
|
|
508
508
|
*/
|
|
509
|
-
createPolicyVoucher(requestParameters: PolicyVouchersApiCreatePolicyVoucherRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<CreatePolicyVoucherResponseClass, any>>;
|
|
509
|
+
createPolicyVoucher(requestParameters: PolicyVouchersApiCreatePolicyVoucherRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<CreatePolicyVoucherResponseClass, any, {}>>;
|
|
510
510
|
/**
|
|
511
511
|
* This will delete an policy voucher.
|
|
512
512
|
* @summary Delete the policy voucher
|
|
@@ -515,7 +515,7 @@ export declare class PolicyVouchersApi extends BaseAPI {
|
|
|
515
515
|
* @throws {RequiredError}
|
|
516
516
|
* @memberof PolicyVouchersApi
|
|
517
517
|
*/
|
|
518
|
-
deletePolicyVoucher(requestParameters: PolicyVouchersApiDeletePolicyVoucherRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<void, any>>;
|
|
518
|
+
deletePolicyVoucher(requestParameters: PolicyVouchersApiDeletePolicyVoucherRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<void, any, {}>>;
|
|
519
519
|
/**
|
|
520
520
|
* This will get an policy voucher.
|
|
521
521
|
* @summary Retrieve the policy voucher
|
|
@@ -524,7 +524,7 @@ export declare class PolicyVouchersApi extends BaseAPI {
|
|
|
524
524
|
* @throws {RequiredError}
|
|
525
525
|
* @memberof PolicyVouchersApi
|
|
526
526
|
*/
|
|
527
|
-
getPolicyVoucher(requestParameters: PolicyVouchersApiGetPolicyVoucherRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<GetPolicyVoucherResponseClass, any>>;
|
|
527
|
+
getPolicyVoucher(requestParameters: PolicyVouchersApiGetPolicyVoucherRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<GetPolicyVoucherResponseClass, any, {}>>;
|
|
528
528
|
/**
|
|
529
529
|
* Returns a list of policy vouchers you have previously created. The policy vouchers are returned in sorted order, with the oldest one appearing first. For more information about pagination, read the Pagination documentation.
|
|
530
530
|
* @summary List policy vouchers
|
|
@@ -533,7 +533,7 @@ export declare class PolicyVouchersApi extends BaseAPI {
|
|
|
533
533
|
* @throws {RequiredError}
|
|
534
534
|
* @memberof PolicyVouchersApi
|
|
535
535
|
*/
|
|
536
|
-
listPolicyVouchers(requestParameters?: PolicyVouchersApiListPolicyVouchersRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<ListPolicyVouchersResponseClass, any>>;
|
|
536
|
+
listPolicyVouchers(requestParameters?: PolicyVouchersApiListPolicyVouchersRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<ListPolicyVouchersResponseClass, any, {}>>;
|
|
537
537
|
/**
|
|
538
538
|
* This will redeem the policy voucher.
|
|
539
539
|
* @summary Redeems the policy voucher.
|
|
@@ -542,7 +542,7 @@ export declare class PolicyVouchersApi extends BaseAPI {
|
|
|
542
542
|
* @throws {RequiredError}
|
|
543
543
|
* @memberof PolicyVouchersApi
|
|
544
544
|
*/
|
|
545
|
-
redeemPolicyVoucher(requestParameters: PolicyVouchersApiRedeemPolicyVoucherRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<RedeemPolicyVoucherResponseClass, any>>;
|
|
545
|
+
redeemPolicyVoucher(requestParameters: PolicyVouchersApiRedeemPolicyVoucherRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<RedeemPolicyVoucherResponseClass, any, {}>>;
|
|
546
546
|
/**
|
|
547
547
|
* This will withdraw the policy voucher.
|
|
548
548
|
* @summary Withdraws the policy voucher.
|
|
@@ -551,5 +551,5 @@ export declare class PolicyVouchersApi extends BaseAPI {
|
|
|
551
551
|
* @throws {RequiredError}
|
|
552
552
|
* @memberof PolicyVouchersApi
|
|
553
553
|
*/
|
|
554
|
-
withdrawPolicyVoucher(requestParameters: PolicyVouchersApiWithdrawPolicyVoucherRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<WithdrawPolicyVoucherResponseClass, any>>;
|
|
554
|
+
withdrawPolicyVoucher(requestParameters: PolicyVouchersApiWithdrawPolicyVoucherRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<WithdrawPolicyVoucherResponseClass, any, {}>>;
|
|
555
555
|
}
|
|
@@ -353,7 +353,7 @@ export declare class VouchersApi extends BaseAPI {
|
|
|
353
353
|
* @throws {RequiredError}
|
|
354
354
|
* @memberof VouchersApi
|
|
355
355
|
*/
|
|
356
|
-
createVoucher(requestParameters: VouchersApiCreateVoucherRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<CreateVoucherResponseClass, any>>;
|
|
356
|
+
createVoucher(requestParameters: VouchersApiCreateVoucherRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<CreateVoucherResponseClass, any, {}>>;
|
|
357
357
|
/**
|
|
358
358
|
* This will delete a voucher.
|
|
359
359
|
* @summary Delete the Voucher
|
|
@@ -362,7 +362,7 @@ export declare class VouchersApi extends BaseAPI {
|
|
|
362
362
|
* @throws {RequiredError}
|
|
363
363
|
* @memberof VouchersApi
|
|
364
364
|
*/
|
|
365
|
-
deleteVoucher(requestParameters: VouchersApiDeleteVoucherRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<void, any>>;
|
|
365
|
+
deleteVoucher(requestParameters: VouchersApiDeleteVoucherRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<void, any, {}>>;
|
|
366
366
|
/**
|
|
367
367
|
* This will get a voucher.
|
|
368
368
|
* @summary Retrieve the Voucher
|
|
@@ -371,7 +371,7 @@ export declare class VouchersApi extends BaseAPI {
|
|
|
371
371
|
* @throws {RequiredError}
|
|
372
372
|
* @memberof VouchersApi
|
|
373
373
|
*/
|
|
374
|
-
getVoucher(requestParameters: VouchersApiGetVoucherRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<GetVoucherResponseClass, any>>;
|
|
374
|
+
getVoucher(requestParameters: VouchersApiGetVoucherRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<GetVoucherResponseClass, any, {}>>;
|
|
375
375
|
/**
|
|
376
376
|
* Returns a list of Vouchers you have previously created. The Vouchers are returned in sorted order, with the oldest one appearing first. For more information about pagination, read the Pagination documentation.
|
|
377
377
|
* @summary List Vouchers
|
|
@@ -380,7 +380,7 @@ export declare class VouchersApi extends BaseAPI {
|
|
|
380
380
|
* @throws {RequiredError}
|
|
381
381
|
* @memberof VouchersApi
|
|
382
382
|
*/
|
|
383
|
-
listVouchers(requestParameters?: VouchersApiListVouchersRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<ListVouchersResponseClass, any>>;
|
|
383
|
+
listVouchers(requestParameters?: VouchersApiListVouchersRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<ListVouchersResponseClass, any, {}>>;
|
|
384
384
|
/**
|
|
385
385
|
* This will update a voucher.
|
|
386
386
|
* @summary Update the Voucher
|
|
@@ -389,5 +389,5 @@ export declare class VouchersApi extends BaseAPI {
|
|
|
389
389
|
* @throws {RequiredError}
|
|
390
390
|
* @memberof VouchersApi
|
|
391
391
|
*/
|
|
392
|
-
updateVoucher(requestParameters: VouchersApiUpdateVoucherRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<UpdateVoucherResponseClass, any>>;
|
|
392
|
+
updateVoucher(requestParameters: VouchersApiUpdateVoucherRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<UpdateVoucherResponseClass, any, {}>>;
|
|
393
393
|
}
|
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",
|
|
@@ -57,7 +65,8 @@ export declare class BaseAPI {
|
|
|
57
65
|
selectEnvironment(env: Environment): void;
|
|
58
66
|
selectBasePath(path: string): void;
|
|
59
67
|
getPermissions(): Array<string>;
|
|
60
|
-
authorize(username: string, password: string): Promise<void>;
|
|
68
|
+
authorize(username: string, password: string, targetWorkspace?: string): Promise<void>;
|
|
69
|
+
switchWorkspace(targetWorkspace: string): Promise<void>;
|
|
61
70
|
refreshTokenInternal(): Promise<LoginClass>;
|
|
62
71
|
private storeTokenData;
|
|
63
72
|
loadTokenData(): void;
|
package/dist/base.js
CHANGED
|
@@ -124,9 +124,13 @@ var BaseAPI = /** @class */ (function () {
|
|
|
124
124
|
this.axios = axios;
|
|
125
125
|
this.loadTokenData();
|
|
126
126
|
if (configuration) {
|
|
127
|
+
var accessToken = this.tokenData.accessToken;
|
|
127
128
|
this.configuration = configuration;
|
|
128
129
|
this.basePath = configuration.basePath || this.basePath;
|
|
129
|
-
|
|
130
|
+
// Use config token if provided, otherwise use tokenData token
|
|
131
|
+
var configToken = this.configuration.accessToken;
|
|
132
|
+
var storedToken = accessToken ? "Bearer ".concat(accessToken) : '';
|
|
133
|
+
this.configuration.accessToken = configToken || storedToken;
|
|
130
134
|
}
|
|
131
135
|
else {
|
|
132
136
|
var _a = this.tokenData, accessToken = _a.accessToken, username = _a.username;
|
|
@@ -151,7 +155,7 @@ var BaseAPI = /** @class */ (function () {
|
|
|
151
155
|
}
|
|
152
156
|
return this.tokenData.permissions.split(',');
|
|
153
157
|
};
|
|
154
|
-
BaseAPI.prototype.authorize = function (username, password) {
|
|
158
|
+
BaseAPI.prototype.authorize = function (username, password, targetWorkspace) {
|
|
155
159
|
return __awaiter(this, void 0, void 0, function () {
|
|
156
160
|
var options, response, _a, accessToken, permissions;
|
|
157
161
|
return __generator(this, function (_b) {
|
|
@@ -176,6 +180,48 @@ var BaseAPI = /** @class */ (function () {
|
|
|
176
180
|
this.tokenData.username = username;
|
|
177
181
|
this.tokenData.accessToken = accessToken;
|
|
178
182
|
this.tokenData.permissions = permissions;
|
|
183
|
+
if (!targetWorkspace) return [3 /*break*/, 3];
|
|
184
|
+
return [4 /*yield*/, this.switchWorkspace(targetWorkspace)];
|
|
185
|
+
case 2:
|
|
186
|
+
_b.sent();
|
|
187
|
+
return [3 /*break*/, 4];
|
|
188
|
+
case 3:
|
|
189
|
+
// Only store if no workspace switch (since switchWorkspace will store after switching)
|
|
190
|
+
this.storeTokenData(__assign({}, this.tokenData));
|
|
191
|
+
_b.label = 4;
|
|
192
|
+
case 4:
|
|
193
|
+
this.storeTokenData(__assign({}, this.tokenData));
|
|
194
|
+
return [2 /*return*/];
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
};
|
|
199
|
+
BaseAPI.prototype.switchWorkspace = function (targetWorkspace) {
|
|
200
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
201
|
+
var options, response, _a, accessToken, permissions;
|
|
202
|
+
return __generator(this, function (_b) {
|
|
203
|
+
switch (_b.label) {
|
|
204
|
+
case 0:
|
|
205
|
+
options = {
|
|
206
|
+
method: 'POST',
|
|
207
|
+
url: "".concat(this.configuration.basePath, "/authservice/v1/workspaces/switch"),
|
|
208
|
+
headers: {
|
|
209
|
+
'Content-Type': 'application/json',
|
|
210
|
+
'Authorization': "Bearer ".concat(this.configuration.accessToken),
|
|
211
|
+
},
|
|
212
|
+
data: {
|
|
213
|
+
username: this.configuration.username,
|
|
214
|
+
targetWorkspace: targetWorkspace,
|
|
215
|
+
},
|
|
216
|
+
withCredentials: true,
|
|
217
|
+
};
|
|
218
|
+
return [4 /*yield*/, axios_1.default.request(options)];
|
|
219
|
+
case 1:
|
|
220
|
+
response = _b.sent();
|
|
221
|
+
_a = response.data, accessToken = _a.accessToken, permissions = _a.permissions;
|
|
222
|
+
this.configuration.accessToken = "Bearer ".concat(accessToken);
|
|
223
|
+
this.tokenData.accessToken = accessToken;
|
|
224
|
+
this.tokenData.permissions = permissions;
|
|
179
225
|
this.storeTokenData(__assign({}, this.tokenData));
|
|
180
226
|
return [2 /*return*/];
|
|
181
227
|
}
|
package/dist/common.d.ts
CHANGED
|
@@ -62,7 +62,7 @@ export declare const toPathString: (url: URL) => string;
|
|
|
62
62
|
*
|
|
63
63
|
* @export
|
|
64
64
|
*/
|
|
65
|
-
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>;
|
|
65
|
+
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>;
|
|
66
66
|
/**
|
|
67
67
|
* EMIL DiscountService
|
|
68
68
|
* The EMIL DiscountService API description
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@emilgroup/discount-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "OpenAPI client for @emilgroup/discount-sdk",
|
|
5
5
|
"author": "OpenAPI-Generator Contributors",
|
|
6
6
|
"keywords": [
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"prepare": "npm run build"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"axios": "^
|
|
21
|
+
"axios": "^1.12.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"typescript": "^4.0"
|