@emilgroup/account-sdk 1.27.0 → 1.27.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/api/accounts-api.ts +18 -18
- package/base.ts +15 -7
- package/dist/api/accounts-api.d.ts +18 -18
- package/dist/api/accounts-api.js +9 -9
- package/dist/base.d.ts +3 -1
- package/dist/base.js +27 -20
- 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/account-sdk@1.27.0 --save
|
|
20
|
+
npm install @emilgroup/account-sdk@1.27.1-beta.0 --save
|
|
21
21
|
```
|
|
22
22
|
or
|
|
23
23
|
```
|
|
24
|
-
yarn add @emilgroup/account-sdk@1.27.0
|
|
24
|
+
yarn add @emilgroup/account-sdk@1.27.1-beta.0
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
And then you can import `AccountsApi`.
|
package/api/accounts-api.ts
CHANGED
|
@@ -186,15 +186,15 @@ export const AccountsApiAxiosParamCreator = function (configuration?: Configurat
|
|
|
186
186
|
* @param {string} [authorization] Bearer Token: provided by the login endpoint under the name accessToken.
|
|
187
187
|
* @param {any} [pageSize] A limit on the number of objects to be returned. Limit ranges between 1 and 50. Default: 10.
|
|
188
188
|
* @param {any} [pageToken] A cursor for use in pagination. pageToken is an ID that defines your place in the list. For instance, if you make a list request and receive 100 objects and pageToken=1, your subsequent call can include pageToken=2 in order to fetch the next page of the list.
|
|
189
|
-
* @param {
|
|
189
|
+
* @param {string} [filter] Filter the response by one or multiple fields. In general, fetching filtered responses will conserve bandwidth and reduce response time.
|
|
190
190
|
* @param {any} [search] To search the list by any field, pass search=xxx to fetch the result.
|
|
191
|
-
* @param {
|
|
192
|
-
* @param {
|
|
191
|
+
* @param {string} [order] The order parameter determines how the results should be sorted according to a specified field. It functions similarly to an SQL ORDER BY. Sorting can be performed in either ascending (ASC) or descending (DESC) order. Default: ASC.
|
|
192
|
+
* @param {string} [expand] Use this parameter to fetch additional information about the list items. The expand query parameter increases the set of fields that appear in the response in addition to the default ones. Expanding resources can reduce the number of API calls required to accomplish a task. However, use this with parsimony as some expanded fields can drastically increase payload size.
|
|
193
193
|
* @param {any} [filters] Filters the response by one or multiple fields. Advanced filter functionality allows you to perform more complex filtering operations. In general, fetching filtered responses conserves bandwidth and reduces response time.
|
|
194
194
|
* @param {*} [options] Override http request option.
|
|
195
195
|
* @throws {RequiredError}
|
|
196
196
|
*/
|
|
197
|
-
listAccounts: async (authorization?: string, pageSize?: any, pageToken?: any, filter?:
|
|
197
|
+
listAccounts: async (authorization?: string, pageSize?: any, pageToken?: any, filter?: string, search?: any, order?: string, expand?: string, filters?: any, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
|
|
198
198
|
const localVarPath = `/accountservice/v1/accounts`;
|
|
199
199
|
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
|
200
200
|
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
|
@@ -360,15 +360,15 @@ export const AccountsApiFp = function(configuration?: Configuration) {
|
|
|
360
360
|
* @param {string} [authorization] Bearer Token: provided by the login endpoint under the name accessToken.
|
|
361
361
|
* @param {any} [pageSize] A limit on the number of objects to be returned. Limit ranges between 1 and 50. Default: 10.
|
|
362
362
|
* @param {any} [pageToken] A cursor for use in pagination. pageToken is an ID that defines your place in the list. For instance, if you make a list request and receive 100 objects and pageToken=1, your subsequent call can include pageToken=2 in order to fetch the next page of the list.
|
|
363
|
-
* @param {
|
|
363
|
+
* @param {string} [filter] Filter the response by one or multiple fields. In general, fetching filtered responses will conserve bandwidth and reduce response time.
|
|
364
364
|
* @param {any} [search] To search the list by any field, pass search=xxx to fetch the result.
|
|
365
|
-
* @param {
|
|
366
|
-
* @param {
|
|
365
|
+
* @param {string} [order] The order parameter determines how the results should be sorted according to a specified field. It functions similarly to an SQL ORDER BY. Sorting can be performed in either ascending (ASC) or descending (DESC) order. Default: ASC.
|
|
366
|
+
* @param {string} [expand] Use this parameter to fetch additional information about the list items. The expand query parameter increases the set of fields that appear in the response in addition to the default ones. Expanding resources can reduce the number of API calls required to accomplish a task. However, use this with parsimony as some expanded fields can drastically increase payload size.
|
|
367
367
|
* @param {any} [filters] Filters the response by one or multiple fields. Advanced filter functionality allows you to perform more complex filtering operations. In general, fetching filtered responses conserves bandwidth and reduces response time.
|
|
368
368
|
* @param {*} [options] Override http request option.
|
|
369
369
|
* @throws {RequiredError}
|
|
370
370
|
*/
|
|
371
|
-
async listAccounts(authorization?: string, pageSize?: any, pageToken?: any, filter?:
|
|
371
|
+
async listAccounts(authorization?: string, pageSize?: any, pageToken?: any, filter?: string, search?: any, order?: string, expand?: string, filters?: any, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<ListAccountsResponseClass>> {
|
|
372
372
|
const localVarAxiosArgs = await localVarAxiosParamCreator.listAccounts(authorization, pageSize, pageToken, filter, search, order, expand, filters, options);
|
|
373
373
|
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
|
374
374
|
},
|
|
@@ -435,15 +435,15 @@ export const AccountsApiFactory = function (configuration?: Configuration, baseP
|
|
|
435
435
|
* @param {string} [authorization] Bearer Token: provided by the login endpoint under the name accessToken.
|
|
436
436
|
* @param {any} [pageSize] A limit on the number of objects to be returned. Limit ranges between 1 and 50. Default: 10.
|
|
437
437
|
* @param {any} [pageToken] A cursor for use in pagination. pageToken is an ID that defines your place in the list. For instance, if you make a list request and receive 100 objects and pageToken=1, your subsequent call can include pageToken=2 in order to fetch the next page of the list.
|
|
438
|
-
* @param {
|
|
438
|
+
* @param {string} [filter] Filter the response by one or multiple fields. In general, fetching filtered responses will conserve bandwidth and reduce response time.
|
|
439
439
|
* @param {any} [search] To search the list by any field, pass search=xxx to fetch the result.
|
|
440
|
-
* @param {
|
|
441
|
-
* @param {
|
|
440
|
+
* @param {string} [order] The order parameter determines how the results should be sorted according to a specified field. It functions similarly to an SQL ORDER BY. Sorting can be performed in either ascending (ASC) or descending (DESC) order. Default: ASC.
|
|
441
|
+
* @param {string} [expand] Use this parameter to fetch additional information about the list items. The expand query parameter increases the set of fields that appear in the response in addition to the default ones. Expanding resources can reduce the number of API calls required to accomplish a task. However, use this with parsimony as some expanded fields can drastically increase payload size.
|
|
442
442
|
* @param {any} [filters] Filters the response by one or multiple fields. Advanced filter functionality allows you to perform more complex filtering operations. In general, fetching filtered responses conserves bandwidth and reduces response time.
|
|
443
443
|
* @param {*} [options] Override http request option.
|
|
444
444
|
* @throws {RequiredError}
|
|
445
445
|
*/
|
|
446
|
-
listAccounts(authorization?: string, pageSize?: any, pageToken?: any, filter?:
|
|
446
|
+
listAccounts(authorization?: string, pageSize?: any, pageToken?: any, filter?: string, search?: any, order?: string, expand?: string, filters?: any, options?: any): AxiosPromise<ListAccountsResponseClass> {
|
|
447
447
|
return localVarFp.listAccounts(authorization, pageSize, pageToken, filter, search, order, expand, filters, options).then((request) => request(axios, basePath));
|
|
448
448
|
},
|
|
449
449
|
/**
|
|
@@ -560,10 +560,10 @@ export interface AccountsApiListAccountsRequest {
|
|
|
560
560
|
|
|
561
561
|
/**
|
|
562
562
|
* Filter the response by one or multiple fields. In general, fetching filtered responses will conserve bandwidth and reduce response time.
|
|
563
|
-
* @type {
|
|
563
|
+
* @type {string}
|
|
564
564
|
* @memberof AccountsApiListAccounts
|
|
565
565
|
*/
|
|
566
|
-
readonly filter?:
|
|
566
|
+
readonly filter?: string
|
|
567
567
|
|
|
568
568
|
/**
|
|
569
569
|
* To search the list by any field, pass search=xxx to fetch the result.
|
|
@@ -574,17 +574,17 @@ export interface AccountsApiListAccountsRequest {
|
|
|
574
574
|
|
|
575
575
|
/**
|
|
576
576
|
* The order parameter determines how the results should be sorted according to a specified field. It functions similarly to an SQL ORDER BY. Sorting can be performed in either ascending (ASC) or descending (DESC) order. Default: ASC.
|
|
577
|
-
* @type {
|
|
577
|
+
* @type {string}
|
|
578
578
|
* @memberof AccountsApiListAccounts
|
|
579
579
|
*/
|
|
580
|
-
readonly order?:
|
|
580
|
+
readonly order?: string
|
|
581
581
|
|
|
582
582
|
/**
|
|
583
583
|
* Use this parameter to fetch additional information about the list items. The expand query parameter increases the set of fields that appear in the response in addition to the default ones. Expanding resources can reduce the number of API calls required to accomplish a task. However, use this with parsimony as some expanded fields can drastically increase payload size.
|
|
584
|
-
* @type {
|
|
584
|
+
* @type {string}
|
|
585
585
|
* @memberof AccountsApiListAccounts
|
|
586
586
|
*/
|
|
587
|
-
readonly expand?:
|
|
587
|
+
readonly expand?: string
|
|
588
588
|
|
|
589
589
|
/**
|
|
590
590
|
* Filters the response by one or multiple fields. Advanced filter functionality allows you to perform more complex filtering operations. In general, fetching filtered responses conserves bandwidth and reduces response time.
|
package/base.ts
CHANGED
|
@@ -77,6 +77,7 @@ const TOKEN_DATA = 'APP_TOKEN';
|
|
|
77
77
|
export class BaseAPI {
|
|
78
78
|
protected configuration: Configuration | undefined;
|
|
79
79
|
private tokenData?: TokenData;
|
|
80
|
+
private permissions: Array<string> = [];
|
|
80
81
|
|
|
81
82
|
constructor(configuration?: Configuration,
|
|
82
83
|
protected basePath: string = BASE_PATH,
|
|
@@ -109,6 +110,10 @@ export class BaseAPI {
|
|
|
109
110
|
this.configuration.basePath = path;
|
|
110
111
|
}
|
|
111
112
|
|
|
113
|
+
getPermissions(): Array<string> {
|
|
114
|
+
return this.permissions;
|
|
115
|
+
}
|
|
116
|
+
|
|
112
117
|
async authorize(username: string, password: string): Promise<void> {
|
|
113
118
|
const options: AxiosRequestConfig = {
|
|
114
119
|
method: 'POST',
|
|
@@ -123,23 +128,24 @@ export class BaseAPI {
|
|
|
123
128
|
|
|
124
129
|
const response = await globalAxios.request<LoginClass>(options);
|
|
125
130
|
|
|
126
|
-
const { data: { accessToken } } = response;
|
|
131
|
+
const { data: { accessToken, permissions } } = response;
|
|
127
132
|
|
|
128
133
|
this.configuration.username = username;
|
|
129
134
|
this.configuration.accessToken = `Bearer ${accessToken}`;
|
|
130
135
|
this.tokenData.username = username;
|
|
131
136
|
this.tokenData.accessToken = accessToken;
|
|
137
|
+
this.permissions = permissions;
|
|
132
138
|
|
|
133
139
|
this.storeTokenData({
|
|
134
140
|
...this.tokenData
|
|
135
141
|
});
|
|
136
142
|
}
|
|
137
143
|
|
|
138
|
-
async refreshTokenInternal(): Promise<
|
|
144
|
+
async refreshTokenInternal(): Promise<LoginClass> {
|
|
139
145
|
const { username } = this.configuration;
|
|
140
146
|
|
|
141
147
|
if (!username) {
|
|
142
|
-
|
|
148
|
+
throw new Error('Failed to refresh token.');
|
|
143
149
|
}
|
|
144
150
|
|
|
145
151
|
const options: AxiosRequestConfig = {
|
|
@@ -152,9 +158,9 @@ export class BaseAPI {
|
|
|
152
158
|
withCredentials: true,
|
|
153
159
|
};
|
|
154
160
|
|
|
155
|
-
const
|
|
161
|
+
const response = await globalAxios.request<LoginClass>(options);
|
|
156
162
|
|
|
157
|
-
return
|
|
163
|
+
return response.data;
|
|
158
164
|
}
|
|
159
165
|
|
|
160
166
|
private storeTokenData(tokenData?: TokenData) {
|
|
@@ -188,8 +194,9 @@ export class BaseAPI {
|
|
|
188
194
|
&& !originalConfig._retry) {
|
|
189
195
|
originalConfig._retry = true;
|
|
190
196
|
try {
|
|
191
|
-
|
|
197
|
+
const { accessToken: tokenString, permissions } = await this.refreshTokenInternal();
|
|
192
198
|
const accessToken = `Bearer ${tokenString}`;
|
|
199
|
+
this.permissions = permissions;
|
|
193
200
|
|
|
194
201
|
delete originalConfig.headers['Authorization']
|
|
195
202
|
|
|
@@ -214,8 +221,9 @@ export class BaseAPI {
|
|
|
214
221
|
) {
|
|
215
222
|
_retry_count++;
|
|
216
223
|
try {
|
|
217
|
-
|
|
224
|
+
const { accessToken: tokenString, permissions } = await this.refreshTokenInternal();
|
|
218
225
|
const accessToken = `Bearer ${tokenString}`;
|
|
226
|
+
this.permissions = permissions;
|
|
219
227
|
|
|
220
228
|
_retry = true;
|
|
221
229
|
originalConfig.headers['Authorization'] = accessToken;
|
|
@@ -57,15 +57,15 @@ export declare const AccountsApiAxiosParamCreator: (configuration?: Configuratio
|
|
|
57
57
|
* @param {string} [authorization] Bearer Token: provided by the login endpoint under the name accessToken.
|
|
58
58
|
* @param {any} [pageSize] A limit on the number of objects to be returned. Limit ranges between 1 and 50. Default: 10.
|
|
59
59
|
* @param {any} [pageToken] A cursor for use in pagination. pageToken is an ID that defines your place in the list. For instance, if you make a list request and receive 100 objects and pageToken=1, your subsequent call can include pageToken=2 in order to fetch the next page of the list.
|
|
60
|
-
* @param {
|
|
60
|
+
* @param {string} [filter] Filter the response by one or multiple fields. In general, fetching filtered responses will conserve bandwidth and reduce response time.
|
|
61
61
|
* @param {any} [search] To search the list by any field, pass search=xxx to fetch the result.
|
|
62
|
-
* @param {
|
|
63
|
-
* @param {
|
|
62
|
+
* @param {string} [order] The order parameter determines how the results should be sorted according to a specified field. It functions similarly to an SQL ORDER BY. Sorting can be performed in either ascending (ASC) or descending (DESC) order. Default: ASC.
|
|
63
|
+
* @param {string} [expand] Use this parameter to fetch additional information about the list items. The expand query parameter increases the set of fields that appear in the response in addition to the default ones. Expanding resources can reduce the number of API calls required to accomplish a task. However, use this with parsimony as some expanded fields can drastically increase payload size.
|
|
64
64
|
* @param {any} [filters] Filters the response by one or multiple fields. Advanced filter functionality allows you to perform more complex filtering operations. In general, fetching filtered responses conserves bandwidth and reduces response time.
|
|
65
65
|
* @param {*} [options] Override http request option.
|
|
66
66
|
* @throws {RequiredError}
|
|
67
67
|
*/
|
|
68
|
-
listAccounts: (authorization?: string, pageSize?: any, pageToken?: any, filter?:
|
|
68
|
+
listAccounts: (authorization?: string, pageSize?: any, pageToken?: any, filter?: string, search?: any, order?: string, expand?: string, filters?: any, options?: AxiosRequestConfig) => Promise<RequestArgs>;
|
|
69
69
|
/**
|
|
70
70
|
* Updates the specified account by setting the values of the parameters passed. Any parameters not provided will be left unchanged.
|
|
71
71
|
* @summary Update the account
|
|
@@ -116,15 +116,15 @@ export declare const AccountsApiFp: (configuration?: Configuration) => {
|
|
|
116
116
|
* @param {string} [authorization] Bearer Token: provided by the login endpoint under the name accessToken.
|
|
117
117
|
* @param {any} [pageSize] A limit on the number of objects to be returned. Limit ranges between 1 and 50. Default: 10.
|
|
118
118
|
* @param {any} [pageToken] A cursor for use in pagination. pageToken is an ID that defines your place in the list. For instance, if you make a list request and receive 100 objects and pageToken=1, your subsequent call can include pageToken=2 in order to fetch the next page of the list.
|
|
119
|
-
* @param {
|
|
119
|
+
* @param {string} [filter] Filter the response by one or multiple fields. In general, fetching filtered responses will conserve bandwidth and reduce response time.
|
|
120
120
|
* @param {any} [search] To search the list by any field, pass search=xxx to fetch the result.
|
|
121
|
-
* @param {
|
|
122
|
-
* @param {
|
|
121
|
+
* @param {string} [order] The order parameter determines how the results should be sorted according to a specified field. It functions similarly to an SQL ORDER BY. Sorting can be performed in either ascending (ASC) or descending (DESC) order. Default: ASC.
|
|
122
|
+
* @param {string} [expand] Use this parameter to fetch additional information about the list items. The expand query parameter increases the set of fields that appear in the response in addition to the default ones. Expanding resources can reduce the number of API calls required to accomplish a task. However, use this with parsimony as some expanded fields can drastically increase payload size.
|
|
123
123
|
* @param {any} [filters] Filters the response by one or multiple fields. Advanced filter functionality allows you to perform more complex filtering operations. In general, fetching filtered responses conserves bandwidth and reduces response time.
|
|
124
124
|
* @param {*} [options] Override http request option.
|
|
125
125
|
* @throws {RequiredError}
|
|
126
126
|
*/
|
|
127
|
-
listAccounts(authorization?: string, pageSize?: any, pageToken?: any, filter?:
|
|
127
|
+
listAccounts(authorization?: string, pageSize?: any, pageToken?: any, filter?: string, search?: any, order?: string, expand?: string, filters?: any, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<ListAccountsResponseClass>>;
|
|
128
128
|
/**
|
|
129
129
|
* Updates the specified account by setting the values of the parameters passed. Any parameters not provided will be left unchanged.
|
|
130
130
|
* @summary Update the account
|
|
@@ -175,15 +175,15 @@ export declare const AccountsApiFactory: (configuration?: Configuration, basePat
|
|
|
175
175
|
* @param {string} [authorization] Bearer Token: provided by the login endpoint under the name accessToken.
|
|
176
176
|
* @param {any} [pageSize] A limit on the number of objects to be returned. Limit ranges between 1 and 50. Default: 10.
|
|
177
177
|
* @param {any} [pageToken] A cursor for use in pagination. pageToken is an ID that defines your place in the list. For instance, if you make a list request and receive 100 objects and pageToken=1, your subsequent call can include pageToken=2 in order to fetch the next page of the list.
|
|
178
|
-
* @param {
|
|
178
|
+
* @param {string} [filter] Filter the response by one or multiple fields. In general, fetching filtered responses will conserve bandwidth and reduce response time.
|
|
179
179
|
* @param {any} [search] To search the list by any field, pass search=xxx to fetch the result.
|
|
180
|
-
* @param {
|
|
181
|
-
* @param {
|
|
180
|
+
* @param {string} [order] The order parameter determines how the results should be sorted according to a specified field. It functions similarly to an SQL ORDER BY. Sorting can be performed in either ascending (ASC) or descending (DESC) order. Default: ASC.
|
|
181
|
+
* @param {string} [expand] Use this parameter to fetch additional information about the list items. The expand query parameter increases the set of fields that appear in the response in addition to the default ones. Expanding resources can reduce the number of API calls required to accomplish a task. However, use this with parsimony as some expanded fields can drastically increase payload size.
|
|
182
182
|
* @param {any} [filters] Filters the response by one or multiple fields. Advanced filter functionality allows you to perform more complex filtering operations. In general, fetching filtered responses conserves bandwidth and reduces response time.
|
|
183
183
|
* @param {*} [options] Override http request option.
|
|
184
184
|
* @throws {RequiredError}
|
|
185
185
|
*/
|
|
186
|
-
listAccounts(authorization?: string, pageSize?: any, pageToken?: any, filter?:
|
|
186
|
+
listAccounts(authorization?: string, pageSize?: any, pageToken?: any, filter?: string, search?: any, order?: string, expand?: string, filters?: any, options?: any): AxiosPromise<ListAccountsResponseClass>;
|
|
187
187
|
/**
|
|
188
188
|
* Updates the specified account by setting the values of the parameters passed. Any parameters not provided will be left unchanged.
|
|
189
189
|
* @summary Update the account
|
|
@@ -284,10 +284,10 @@ export interface AccountsApiListAccountsRequest {
|
|
|
284
284
|
readonly pageToken?: any;
|
|
285
285
|
/**
|
|
286
286
|
* Filter the response by one or multiple fields. In general, fetching filtered responses will conserve bandwidth and reduce response time.
|
|
287
|
-
* @type {
|
|
287
|
+
* @type {string}
|
|
288
288
|
* @memberof AccountsApiListAccounts
|
|
289
289
|
*/
|
|
290
|
-
readonly filter?:
|
|
290
|
+
readonly filter?: string;
|
|
291
291
|
/**
|
|
292
292
|
* To search the list by any field, pass search=xxx to fetch the result.
|
|
293
293
|
* @type {any}
|
|
@@ -296,16 +296,16 @@ export interface AccountsApiListAccountsRequest {
|
|
|
296
296
|
readonly search?: any;
|
|
297
297
|
/**
|
|
298
298
|
* The order parameter determines how the results should be sorted according to a specified field. It functions similarly to an SQL ORDER BY. Sorting can be performed in either ascending (ASC) or descending (DESC) order. Default: ASC.
|
|
299
|
-
* @type {
|
|
299
|
+
* @type {string}
|
|
300
300
|
* @memberof AccountsApiListAccounts
|
|
301
301
|
*/
|
|
302
|
-
readonly order?:
|
|
302
|
+
readonly order?: string;
|
|
303
303
|
/**
|
|
304
304
|
* Use this parameter to fetch additional information about the list items. The expand query parameter increases the set of fields that appear in the response in addition to the default ones. Expanding resources can reduce the number of API calls required to accomplish a task. However, use this with parsimony as some expanded fields can drastically increase payload size.
|
|
305
|
-
* @type {
|
|
305
|
+
* @type {string}
|
|
306
306
|
* @memberof AccountsApiListAccounts
|
|
307
307
|
*/
|
|
308
|
-
readonly expand?:
|
|
308
|
+
readonly expand?: string;
|
|
309
309
|
/**
|
|
310
310
|
* Filters the response by one or multiple fields. Advanced filter functionality allows you to perform more complex filtering operations. In general, fetching filtered responses conserves bandwidth and reduces response time.
|
|
311
311
|
* @type {any}
|
package/dist/api/accounts-api.js
CHANGED
|
@@ -247,10 +247,10 @@ var AccountsApiAxiosParamCreator = function (configuration) {
|
|
|
247
247
|
* @param {string} [authorization] Bearer Token: provided by the login endpoint under the name accessToken.
|
|
248
248
|
* @param {any} [pageSize] A limit on the number of objects to be returned. Limit ranges between 1 and 50. Default: 10.
|
|
249
249
|
* @param {any} [pageToken] A cursor for use in pagination. pageToken is an ID that defines your place in the list. For instance, if you make a list request and receive 100 objects and pageToken=1, your subsequent call can include pageToken=2 in order to fetch the next page of the list.
|
|
250
|
-
* @param {
|
|
250
|
+
* @param {string} [filter] Filter the response by one or multiple fields. In general, fetching filtered responses will conserve bandwidth and reduce response time.
|
|
251
251
|
* @param {any} [search] To search the list by any field, pass search=xxx to fetch the result.
|
|
252
|
-
* @param {
|
|
253
|
-
* @param {
|
|
252
|
+
* @param {string} [order] The order parameter determines how the results should be sorted according to a specified field. It functions similarly to an SQL ORDER BY. Sorting can be performed in either ascending (ASC) or descending (DESC) order. Default: ASC.
|
|
253
|
+
* @param {string} [expand] Use this parameter to fetch additional information about the list items. The expand query parameter increases the set of fields that appear in the response in addition to the default ones. Expanding resources can reduce the number of API calls required to accomplish a task. However, use this with parsimony as some expanded fields can drastically increase payload size.
|
|
254
254
|
* @param {any} [filters] Filters the response by one or multiple fields. Advanced filter functionality allows you to perform more complex filtering operations. In general, fetching filtered responses conserves bandwidth and reduces response time.
|
|
255
255
|
* @param {*} [options] Override http request option.
|
|
256
256
|
* @throws {RequiredError}
|
|
@@ -446,10 +446,10 @@ var AccountsApiFp = function (configuration) {
|
|
|
446
446
|
* @param {string} [authorization] Bearer Token: provided by the login endpoint under the name accessToken.
|
|
447
447
|
* @param {any} [pageSize] A limit on the number of objects to be returned. Limit ranges between 1 and 50. Default: 10.
|
|
448
448
|
* @param {any} [pageToken] A cursor for use in pagination. pageToken is an ID that defines your place in the list. For instance, if you make a list request and receive 100 objects and pageToken=1, your subsequent call can include pageToken=2 in order to fetch the next page of the list.
|
|
449
|
-
* @param {
|
|
449
|
+
* @param {string} [filter] Filter the response by one or multiple fields. In general, fetching filtered responses will conserve bandwidth and reduce response time.
|
|
450
450
|
* @param {any} [search] To search the list by any field, pass search=xxx to fetch the result.
|
|
451
|
-
* @param {
|
|
452
|
-
* @param {
|
|
451
|
+
* @param {string} [order] The order parameter determines how the results should be sorted according to a specified field. It functions similarly to an SQL ORDER BY. Sorting can be performed in either ascending (ASC) or descending (DESC) order. Default: ASC.
|
|
452
|
+
* @param {string} [expand] Use this parameter to fetch additional information about the list items. The expand query parameter increases the set of fields that appear in the response in addition to the default ones. Expanding resources can reduce the number of API calls required to accomplish a task. However, use this with parsimony as some expanded fields can drastically increase payload size.
|
|
453
453
|
* @param {any} [filters] Filters the response by one or multiple fields. Advanced filter functionality allows you to perform more complex filtering operations. In general, fetching filtered responses conserves bandwidth and reduces response time.
|
|
454
454
|
* @param {*} [options] Override http request option.
|
|
455
455
|
* @throws {RequiredError}
|
|
@@ -539,10 +539,10 @@ var AccountsApiFactory = function (configuration, basePath, axios) {
|
|
|
539
539
|
* @param {string} [authorization] Bearer Token: provided by the login endpoint under the name accessToken.
|
|
540
540
|
* @param {any} [pageSize] A limit on the number of objects to be returned. Limit ranges between 1 and 50. Default: 10.
|
|
541
541
|
* @param {any} [pageToken] A cursor for use in pagination. pageToken is an ID that defines your place in the list. For instance, if you make a list request and receive 100 objects and pageToken=1, your subsequent call can include pageToken=2 in order to fetch the next page of the list.
|
|
542
|
-
* @param {
|
|
542
|
+
* @param {string} [filter] Filter the response by one or multiple fields. In general, fetching filtered responses will conserve bandwidth and reduce response time.
|
|
543
543
|
* @param {any} [search] To search the list by any field, pass search=xxx to fetch the result.
|
|
544
|
-
* @param {
|
|
545
|
-
* @param {
|
|
544
|
+
* @param {string} [order] The order parameter determines how the results should be sorted according to a specified field. It functions similarly to an SQL ORDER BY. Sorting can be performed in either ascending (ASC) or descending (DESC) order. Default: ASC.
|
|
545
|
+
* @param {string} [expand] Use this parameter to fetch additional information about the list items. The expand query parameter increases the set of fields that appear in the response in addition to the default ones. Expanding resources can reduce the number of API calls required to accomplish a task. However, use this with parsimony as some expanded fields can drastically increase payload size.
|
|
546
546
|
* @param {any} [filters] Filters the response by one or multiple fields. Advanced filter functionality allows you to perform more complex filtering operations. In general, fetching filtered responses conserves bandwidth and reduces response time.
|
|
547
547
|
* @param {*} [options] Override http request option.
|
|
548
548
|
* @throws {RequiredError}
|
package/dist/base.d.ts
CHANGED
|
@@ -52,11 +52,13 @@ export declare class BaseAPI {
|
|
|
52
52
|
protected axios: AxiosInstance;
|
|
53
53
|
protected configuration: Configuration | undefined;
|
|
54
54
|
private tokenData?;
|
|
55
|
+
private permissions;
|
|
55
56
|
constructor(configuration?: Configuration, basePath?: string, axios?: AxiosInstance);
|
|
56
57
|
selectEnvironment(env: Environment): void;
|
|
57
58
|
selectBasePath(path: string): void;
|
|
59
|
+
getPermissions(): Array<string>;
|
|
58
60
|
authorize(username: string, password: string): Promise<void>;
|
|
59
|
-
refreshTokenInternal(): Promise<
|
|
61
|
+
refreshTokenInternal(): Promise<LoginClass>;
|
|
60
62
|
private storeTokenData;
|
|
61
63
|
loadTokenData(): void;
|
|
62
64
|
cleanTokenData(): void;
|
package/dist/base.js
CHANGED
|
@@ -121,6 +121,7 @@ var BaseAPI = /** @class */ (function () {
|
|
|
121
121
|
if (axios === void 0) { axios = axios_1.default; }
|
|
122
122
|
this.basePath = basePath;
|
|
123
123
|
this.axios = axios;
|
|
124
|
+
this.permissions = [];
|
|
124
125
|
this.loadTokenData();
|
|
125
126
|
if (configuration) {
|
|
126
127
|
this.configuration = configuration;
|
|
@@ -143,11 +144,14 @@ var BaseAPI = /** @class */ (function () {
|
|
|
143
144
|
BaseAPI.prototype.selectBasePath = function (path) {
|
|
144
145
|
this.configuration.basePath = path;
|
|
145
146
|
};
|
|
147
|
+
BaseAPI.prototype.getPermissions = function () {
|
|
148
|
+
return this.permissions;
|
|
149
|
+
};
|
|
146
150
|
BaseAPI.prototype.authorize = function (username, password) {
|
|
147
151
|
return __awaiter(this, void 0, void 0, function () {
|
|
148
|
-
var options, response, accessToken;
|
|
149
|
-
return __generator(this, function (
|
|
150
|
-
switch (
|
|
152
|
+
var options, response, _a, accessToken, permissions;
|
|
153
|
+
return __generator(this, function (_b) {
|
|
154
|
+
switch (_b.label) {
|
|
151
155
|
case 0:
|
|
152
156
|
options = {
|
|
153
157
|
method: 'POST',
|
|
@@ -161,12 +165,13 @@ var BaseAPI = /** @class */ (function () {
|
|
|
161
165
|
};
|
|
162
166
|
return [4 /*yield*/, axios_1.default.request(options)];
|
|
163
167
|
case 1:
|
|
164
|
-
response =
|
|
165
|
-
|
|
168
|
+
response = _b.sent();
|
|
169
|
+
_a = response.data, accessToken = _a.accessToken, permissions = _a.permissions;
|
|
166
170
|
this.configuration.username = username;
|
|
167
171
|
this.configuration.accessToken = "Bearer ".concat(accessToken);
|
|
168
172
|
this.tokenData.username = username;
|
|
169
173
|
this.tokenData.accessToken = accessToken;
|
|
174
|
+
this.permissions = permissions;
|
|
170
175
|
this.storeTokenData(__assign({}, this.tokenData));
|
|
171
176
|
return [2 /*return*/];
|
|
172
177
|
}
|
|
@@ -175,13 +180,13 @@ var BaseAPI = /** @class */ (function () {
|
|
|
175
180
|
};
|
|
176
181
|
BaseAPI.prototype.refreshTokenInternal = function () {
|
|
177
182
|
return __awaiter(this, void 0, void 0, function () {
|
|
178
|
-
var username, options,
|
|
183
|
+
var username, options, response;
|
|
179
184
|
return __generator(this, function (_a) {
|
|
180
185
|
switch (_a.label) {
|
|
181
186
|
case 0:
|
|
182
187
|
username = this.configuration.username;
|
|
183
188
|
if (!username) {
|
|
184
|
-
|
|
189
|
+
throw new Error('Failed to refresh token.');
|
|
185
190
|
}
|
|
186
191
|
options = {
|
|
187
192
|
method: 'POST',
|
|
@@ -194,8 +199,8 @@ var BaseAPI = /** @class */ (function () {
|
|
|
194
199
|
};
|
|
195
200
|
return [4 /*yield*/, axios_1.default.request(options)];
|
|
196
201
|
case 1:
|
|
197
|
-
|
|
198
|
-
return [2 /*return*/,
|
|
202
|
+
response = _a.sent();
|
|
203
|
+
return [2 /*return*/, response.data];
|
|
199
204
|
}
|
|
200
205
|
});
|
|
201
206
|
});
|
|
@@ -221,22 +226,23 @@ var BaseAPI = /** @class */ (function () {
|
|
|
221
226
|
axios.interceptors.response.use(function (res) {
|
|
222
227
|
return res;
|
|
223
228
|
}, function (err) { return __awaiter(_this, void 0, void 0, function () {
|
|
224
|
-
var originalConfig, tokenString, accessToken, _error_1, tokenString, accessToken, _error_2;
|
|
225
|
-
return __generator(this, function (
|
|
226
|
-
switch (
|
|
229
|
+
var originalConfig, _a, tokenString, permissions, accessToken, _error_1, _b, tokenString, permissions, accessToken, _error_2;
|
|
230
|
+
return __generator(this, function (_c) {
|
|
231
|
+
switch (_c.label) {
|
|
227
232
|
case 0:
|
|
228
233
|
originalConfig = err.config;
|
|
229
234
|
if (!(err.response && !(err.response instanceof XMLHttpRequest))) return [3 /*break*/, 5];
|
|
230
235
|
if (!((err.response.status === 401 || err.response.status === 403)
|
|
231
236
|
&& !originalConfig._retry)) return [3 /*break*/, 4];
|
|
232
237
|
originalConfig._retry = true;
|
|
233
|
-
|
|
238
|
+
_c.label = 1;
|
|
234
239
|
case 1:
|
|
235
|
-
|
|
240
|
+
_c.trys.push([1, 3, , 4]);
|
|
236
241
|
return [4 /*yield*/, this.refreshTokenInternal()];
|
|
237
242
|
case 2:
|
|
238
|
-
|
|
243
|
+
_a = _c.sent(), tokenString = _a.accessToken, permissions = _a.permissions;
|
|
239
244
|
accessToken = "Bearer ".concat(tokenString);
|
|
245
|
+
this.permissions = permissions;
|
|
240
246
|
delete originalConfig.headers['Authorization'];
|
|
241
247
|
originalConfig.headers['Authorization'] = accessToken;
|
|
242
248
|
this.configuration.accessToken = accessToken;
|
|
@@ -244,7 +250,7 @@ var BaseAPI = /** @class */ (function () {
|
|
|
244
250
|
this.storeTokenData(this.tokenData);
|
|
245
251
|
return [2 /*return*/, axios(originalConfig)];
|
|
246
252
|
case 3:
|
|
247
|
-
_error_1 =
|
|
253
|
+
_error_1 = _c.sent();
|
|
248
254
|
if (_error_1.response && _error_1.response.data) {
|
|
249
255
|
return [2 /*return*/, Promise.reject(_error_1.response.data)];
|
|
250
256
|
}
|
|
@@ -255,13 +261,14 @@ var BaseAPI = /** @class */ (function () {
|
|
|
255
261
|
&& originalConfig.headers.hasOwnProperty('Authorization')
|
|
256
262
|
&& _retry_count < 4)) return [3 /*break*/, 9];
|
|
257
263
|
_retry_count++;
|
|
258
|
-
|
|
264
|
+
_c.label = 6;
|
|
259
265
|
case 6:
|
|
260
|
-
|
|
266
|
+
_c.trys.push([6, 8, , 9]);
|
|
261
267
|
return [4 /*yield*/, this.refreshTokenInternal()];
|
|
262
268
|
case 7:
|
|
263
|
-
|
|
269
|
+
_b = _c.sent(), tokenString = _b.accessToken, permissions = _b.permissions;
|
|
264
270
|
accessToken = "Bearer ".concat(tokenString);
|
|
271
|
+
this.permissions = permissions;
|
|
265
272
|
_retry = true;
|
|
266
273
|
originalConfig.headers['Authorization'] = accessToken;
|
|
267
274
|
this.configuration.accessToken = accessToken;
|
|
@@ -269,7 +276,7 @@ var BaseAPI = /** @class */ (function () {
|
|
|
269
276
|
this.storeTokenData(this.tokenData);
|
|
270
277
|
return [2 /*return*/, axios.request(__assign({}, originalConfig))];
|
|
271
278
|
case 8:
|
|
272
|
-
_error_2 =
|
|
279
|
+
_error_2 = _c.sent();
|
|
273
280
|
if (_error_2.response && _error_2.response.data) {
|
|
274
281
|
return [2 /*return*/, Promise.reject(_error_2.response.data)];
|
|
275
282
|
}
|