@emilgroup/discount-sdk-node 1.4.0 → 1.4.1-beta.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 +44 -3
- 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 +11 -2
- package/dist/base.js +42 -3
- 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-node@1.4.0 --save
|
|
20
|
+
npm install @emilgroup/discount-sdk-node@1.4.1-beta.0 --save
|
|
21
21
|
```
|
|
22
22
|
or
|
|
23
23
|
```
|
|
24
|
-
yarn add @emilgroup/discount-sdk-node@1.4.0
|
|
24
|
+
yarn add @emilgroup/discount-sdk-node@1.4.1-beta.0
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
And then you can import `CampaignApi`.
|
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,37 @@ 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
|
+
async switchWorkspace(targetWorkspace: string): Promise<void> {
|
|
190
|
+
const options: AxiosRequestConfig = {
|
|
191
|
+
method: 'POST',
|
|
192
|
+
url: `${this.configuration.basePath}/authservice/v1/workspaces/switch`,
|
|
193
|
+
headers: {
|
|
194
|
+
'Content-Type': 'application/json',
|
|
195
|
+
'Authorization': `Bearer ${this.configuration.accessToken}`,
|
|
196
|
+
'Cookie': this.configuration.refreshToken,
|
|
197
|
+
},
|
|
198
|
+
data: {
|
|
199
|
+
username: this.configuration.username,
|
|
200
|
+
targetWorkspace,
|
|
201
|
+
} as SwitchWorkspaceRequest,
|
|
202
|
+
withCredentials: true,
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
const response = await globalAxios.request<SwitchWorkspaceResponseClass>(options);
|
|
206
|
+
|
|
207
|
+
const { data: { accessToken } } = response;
|
|
208
|
+
this.configuration.accessToken = `Bearer ${accessToken}`;
|
|
209
|
+
|
|
210
|
+
const refreshToken = this.extractRefreshToken(response);
|
|
211
|
+
if (refreshToken) {
|
|
212
|
+
this.configuration.refreshToken = refreshToken;
|
|
213
|
+
}
|
|
173
214
|
}
|
|
174
215
|
|
|
175
216
|
async refreshTokenInternal(): Promise<string> {
|
|
@@ -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",
|
|
@@ -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
|
});
|
package/dist/common.d.ts
CHANGED
|
@@ -63,7 +63,7 @@ export declare const toPathString: (url: URL) => string;
|
|
|
63
63
|
*
|
|
64
64
|
* @export
|
|
65
65
|
*/
|
|
66
|
-
export declare const createRequestFunction: (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) => <T = unknown, R = AxiosResponse<T, any>>(axios?: AxiosInstance, basePath?: string) => Promise<R>;
|
|
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
67
|
/**
|
|
68
68
|
* EMIL DiscountService
|
|
69
69
|
* The EMIL DiscountService API description
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@emilgroup/discount-sdk-node",
|
|
3
|
-
"version": "1.4.0",
|
|
3
|
+
"version": "1.4.1-beta.0",
|
|
4
4
|
"description": "OpenAPI client for @emilgroup/discount-sdk-node",
|
|
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
|
"form-data": "^4.0.0",
|
|
23
23
|
"url": "^0.11.0"
|
|
24
24
|
},
|