@etsoo/appscript 1.3.10 → 1.3.12

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.
@@ -3,6 +3,7 @@ import { AddressRegion, AddressRegionDb } from '../address/AddressRegion';
3
3
  import { AddressState } from '../address/AddressState';
4
4
  import { IdLabelConditional } from './dto/IdLabelDto';
5
5
  import { BaseApi } from './BaseApi';
6
+ import { IApiPayload } from '@etsoo/restclient';
6
7
  /**
7
8
  * Address Api
8
9
  */
@@ -28,7 +29,8 @@ export declare class AddressApi extends BaseApi {
28
29
  /**
29
30
  * Get state list
30
31
  * @param regionId Region id
32
+ * @param payload Payload
31
33
  * @returns Result
32
34
  */
33
- states(regionId: string): Promise<AddressState[] | undefined>;
35
+ states(regionId: string, payload?: IApiPayload<AddressState[]>): Promise<AddressState[] | undefined>;
34
36
  }
@@ -44,16 +44,18 @@ class AddressApi extends BaseApi_1.BaseApi {
44
44
  });
45
45
  }
46
46
  else {
47
- return (await this.api.get(`Address/RegionList?language=${this.app.culture}`, undefined, { defaultValue: [] }));
47
+ return (await this.api.get(`Address/RegionList?language=${this.app.culture}`, undefined, { defaultValue: [], showLoading: false }));
48
48
  }
49
49
  }
50
50
  /**
51
51
  * Get state list
52
52
  * @param regionId Region id
53
+ * @param payload Payload
53
54
  * @returns Result
54
55
  */
55
- states(regionId) {
56
- return this.api.get(`Address/StateList?regionId=${regionId}&language=${this.app.culture}`, undefined, { defaultValue: [] });
56
+ states(regionId, payload) {
57
+ payload !== null && payload !== void 0 ? payload : (payload = { defaultValue: [], showLoading: false });
58
+ return this.api.get(`Address/StateList?regionId=${regionId}&language=${this.app.culture}`, undefined, payload);
57
59
  }
58
60
  }
59
61
  exports.AddressApi = AddressApi;
@@ -29,8 +29,8 @@ export declare class EntityApi<T extends IApp = IApp> extends BaseApi<T> {
29
29
  * @param id Id or ids
30
30
  * @param payload Payload
31
31
  */
32
- protected deleteBase<R extends IActionResult>(id: DataTypes.IdType, payload?: IApiPayload<R>): R;
33
- protected deleteBase<R extends IActionResult>(ids: DataTypes.IdType[], payload?: IApiPayload<R>): R;
32
+ protected deleteBase<R extends IActionResult>(id: DataTypes.IdType, payload?: IApiPayload<R>): Promise<R | undefined>;
33
+ protected deleteBase<R extends IActionResult>(ids: DataTypes.IdType[], payload?: IApiPayload<R>): Promise<R | undefined>;
34
34
  /**
35
35
  * List
36
36
  * @param rq Request data
@@ -56,7 +56,7 @@ class EntityApi extends BaseApi_1.BaseApi {
56
56
  * @returns Result
57
57
  */
58
58
  readBase(id, payload) {
59
- return this.api.get(`${this.flag}/Read/${id}`, payload);
59
+ return this.api.get(`${this.flag}/Read/${id}`, undefined, payload);
60
60
  }
61
61
  /**
62
62
  * Sort
@@ -85,7 +85,7 @@ class EntityApi extends BaseApi_1.BaseApi {
85
85
  * @returns Result
86
86
  */
87
87
  updateReadBase(id, payload) {
88
- return this.api.get(`${this.flag}/UpdateRead/${id}`, payload);
88
+ return this.api.get(`${this.flag}/UpdateRead/${id}`, undefined, payload);
89
89
  }
90
90
  }
91
91
  exports.EntityApi = EntityApi;
@@ -20,6 +20,7 @@ export declare class OrgApi extends EntityApi {
20
20
  * Get organization list
21
21
  * @param items Max items or request data
22
22
  * @param serviceId Service id
23
+ * @param payload Payload
23
24
  * @returns Result
24
25
  */
25
26
  list(items?: number, serviceId?: number): Promise<ListType[] | undefined>;
@@ -35,6 +36,7 @@ export declare class OrgApi extends EntityApi {
35
36
  * Switch organization
36
37
  * @param id Organization id
37
38
  * @param serviceId Service id
39
+ * @param payload Payload
38
40
  */
39
41
  switch(id: number, serviceId?: number, payload?: IApiPayload<boolean>): Promise<boolean | undefined>;
40
42
  /**
@@ -31,6 +31,7 @@ class OrgApi extends EntityApi_1.EntityApi {
31
31
  * Switch organization
32
32
  * @param id Organization id
33
33
  * @param serviceId Service id
34
+ * @param payload Payload
34
35
  */
35
36
  async switch(id, serviceId, payload) {
36
37
  const result = await this.app.api.put('Organization/Switch', {
@@ -1,3 +1,4 @@
1
+ import { IApiPayload } from '@etsoo/restclient';
1
2
  import { ListType, ListType1 } from '@etsoo/shared';
2
3
  import { Currency } from '../business/Currency';
3
4
  import { ProductUnit } from '../business/ProductUnit';
@@ -19,16 +20,18 @@ export declare class PublicApi extends BaseApi {
19
20
  /**
20
21
  * Get exchange rate
21
22
  * @param currency Currency
23
+ * @param payload Payload
22
24
  * @returns Result
23
25
  */
24
- exchangeRate(currency: Currency | string): Promise<ExchangeRateDto | undefined>;
26
+ exchangeRate(currency: Currency | string, payload?: IApiPayload<ExchangeRateDto>): Promise<ExchangeRateDto | undefined>;
25
27
  /**
26
28
  * Get exchange rate history
27
29
  * @param currencies Currencies
28
30
  * @param months Max months
31
+ * @param payload Payload
29
32
  * @returns Result
30
33
  */
31
- exchangeRateHistory(currencies: (Currency | string)[], months?: number): Promise<ExchangeRateHistoryDto[] | undefined>;
34
+ exchangeRateHistory(currencies: (Currency | string)[], months?: number, payload?: IApiPayload<ExchangeRateHistoryDto[]>): Promise<ExchangeRateHistoryDto[] | undefined>;
32
35
  /**
33
36
  * Get product unit's label
34
37
  * Please define the label in culture with key 'unitPC' for ProductUnit.PC like that
@@ -42,15 +45,17 @@ export declare class PublicApi extends BaseApi {
42
45
  * Get mobile base64 QRCode
43
46
  * @param id User id
44
47
  * @param host Host URL
48
+ * @param payload Payload
45
49
  */
46
- mobileQRCode(id?: string, host?: string): Promise<string | undefined>;
50
+ mobileQRCode(id?: string, host?: string, payload?: IApiPayload<string>): Promise<string | undefined>;
47
51
  /**
48
52
  * Get public and valid product data
49
53
  * @param id Product/Service Id or Uid
50
54
  * @param culture Language
55
+ * @param payload Payload
51
56
  * @returns Result
52
57
  */
53
- product<T extends number | string>(id: T, culture?: string): T extends number ? PublicProductDto : PublicOrgProductDto;
58
+ product<T extends number | string>(id: T, culture?: string, payload?: IApiPayload<PublicProductDto>): Promise<(T extends number ? PublicProductDto : PublicOrgProductDto) | undefined>;
54
59
  /**
55
60
  *
56
61
  * Get all repeat options
@@ -16,7 +16,7 @@ class PublicApi extends BaseApi_1.BaseApi {
16
16
  */
17
17
  async currencies(currencyNames) {
18
18
  if (currencyNames == null)
19
- return (await this.api.get('Public/GetCurrencies'));
19
+ return (await this.api.get('Public/GetCurrencies', undefined, { defaultValue: [], showLoading: false }));
20
20
  else
21
21
  return currencyNames.map((name) => {
22
22
  var _a;
@@ -29,19 +29,22 @@ class PublicApi extends BaseApi_1.BaseApi {
29
29
  /**
30
30
  * Get exchange rate
31
31
  * @param currency Currency
32
+ * @param payload Payload
32
33
  * @returns Result
33
34
  */
34
- exchangeRate(currency) {
35
- return this.api.get(`Public/ExchangeRate/${currency}`);
35
+ exchangeRate(currency, payload) {
36
+ return this.api.get(`Public/ExchangeRate/${currency}`, undefined, payload);
36
37
  }
37
38
  /**
38
39
  * Get exchange rate history
39
40
  * @param currencies Currencies
40
41
  * @param months Max months
42
+ * @param payload Payload
41
43
  * @returns Result
42
44
  */
43
- exchangeRateHistory(currencies, months) {
44
- return this.api.post('Public/ExchangeRateHistory', { currencies, months }, { defaultValue: [] });
45
+ exchangeRateHistory(currencies, months, payload) {
46
+ payload !== null && payload !== void 0 ? payload : (payload = { defaultValue: [] });
47
+ return this.api.post('Public/ExchangeRateHistory', { currencies, months }, payload);
45
48
  }
46
49
  /**
47
50
  * Get product unit's label
@@ -72,19 +75,21 @@ class PublicApi extends BaseApi_1.BaseApi {
72
75
  * Get mobile base64 QRCode
73
76
  * @param id User id
74
77
  * @param host Host URL
78
+ * @param payload Payload
75
79
  */
76
- mobileQRCode(id, host) {
77
- return this.api.post('Public/MobileQRCode', { id, host });
80
+ mobileQRCode(id, host, payload) {
81
+ return this.api.post('Public/MobileQRCode', { id, host }, payload);
78
82
  }
79
83
  /**
80
84
  * Get public and valid product data
81
85
  * @param id Product/Service Id or Uid
82
86
  * @param culture Language
87
+ * @param payload Payload
83
88
  * @returns Result
84
89
  */
85
- product(id, culture) {
90
+ product(id, culture, payload) {
86
91
  culture = this.app.checkLanguage(culture);
87
- return this.api.post(`Public/Product/${id}/${culture}`);
92
+ return this.api.get(`Public/Product/${id}/${culture}`, undefined, payload);
88
93
  }
89
94
  /**
90
95
  *
@@ -3,6 +3,7 @@ import { AddressRegion, AddressRegionDb } from '../address/AddressRegion';
3
3
  import { AddressState } from '../address/AddressState';
4
4
  import { IdLabelConditional } from './dto/IdLabelDto';
5
5
  import { BaseApi } from './BaseApi';
6
+ import { IApiPayload } from '@etsoo/restclient';
6
7
  /**
7
8
  * Address Api
8
9
  */
@@ -28,7 +29,8 @@ export declare class AddressApi extends BaseApi {
28
29
  /**
29
30
  * Get state list
30
31
  * @param regionId Region id
32
+ * @param payload Payload
31
33
  * @returns Result
32
34
  */
33
- states(regionId: string): Promise<AddressState[] | undefined>;
35
+ states(regionId: string, payload?: IApiPayload<AddressState[]>): Promise<AddressState[] | undefined>;
34
36
  }
@@ -41,15 +41,17 @@ export class AddressApi extends BaseApi {
41
41
  });
42
42
  }
43
43
  else {
44
- return (await this.api.get(`Address/RegionList?language=${this.app.culture}`, undefined, { defaultValue: [] }));
44
+ return (await this.api.get(`Address/RegionList?language=${this.app.culture}`, undefined, { defaultValue: [], showLoading: false }));
45
45
  }
46
46
  }
47
47
  /**
48
48
  * Get state list
49
49
  * @param regionId Region id
50
+ * @param payload Payload
50
51
  * @returns Result
51
52
  */
52
- states(regionId) {
53
- return this.api.get(`Address/StateList?regionId=${regionId}&language=${this.app.culture}`, undefined, { defaultValue: [] });
53
+ states(regionId, payload) {
54
+ payload !== null && payload !== void 0 ? payload : (payload = { defaultValue: [], showLoading: false });
55
+ return this.api.get(`Address/StateList?regionId=${regionId}&language=${this.app.culture}`, undefined, payload);
54
56
  }
55
57
  }
@@ -29,8 +29,8 @@ export declare class EntityApi<T extends IApp = IApp> extends BaseApi<T> {
29
29
  * @param id Id or ids
30
30
  * @param payload Payload
31
31
  */
32
- protected deleteBase<R extends IActionResult>(id: DataTypes.IdType, payload?: IApiPayload<R>): R;
33
- protected deleteBase<R extends IActionResult>(ids: DataTypes.IdType[], payload?: IApiPayload<R>): R;
32
+ protected deleteBase<R extends IActionResult>(id: DataTypes.IdType, payload?: IApiPayload<R>): Promise<R | undefined>;
33
+ protected deleteBase<R extends IActionResult>(ids: DataTypes.IdType[], payload?: IApiPayload<R>): Promise<R | undefined>;
34
34
  /**
35
35
  * List
36
36
  * @param rq Request data
@@ -53,7 +53,7 @@ export class EntityApi extends BaseApi {
53
53
  * @returns Result
54
54
  */
55
55
  readBase(id, payload) {
56
- return this.api.get(`${this.flag}/Read/${id}`, payload);
56
+ return this.api.get(`${this.flag}/Read/${id}`, undefined, payload);
57
57
  }
58
58
  /**
59
59
  * Sort
@@ -82,6 +82,6 @@ export class EntityApi extends BaseApi {
82
82
  * @returns Result
83
83
  */
84
84
  updateReadBase(id, payload) {
85
- return this.api.get(`${this.flag}/UpdateRead/${id}`, payload);
85
+ return this.api.get(`${this.flag}/UpdateRead/${id}`, undefined, payload);
86
86
  }
87
87
  }
@@ -20,6 +20,7 @@ export declare class OrgApi extends EntityApi {
20
20
  * Get organization list
21
21
  * @param items Max items or request data
22
22
  * @param serviceId Service id
23
+ * @param payload Payload
23
24
  * @returns Result
24
25
  */
25
26
  list(items?: number, serviceId?: number): Promise<ListType[] | undefined>;
@@ -35,6 +36,7 @@ export declare class OrgApi extends EntityApi {
35
36
  * Switch organization
36
37
  * @param id Organization id
37
38
  * @param serviceId Service id
39
+ * @param payload Payload
38
40
  */
39
41
  switch(id: number, serviceId?: number, payload?: IApiPayload<boolean>): Promise<boolean | undefined>;
40
42
  /**
@@ -28,6 +28,7 @@ export class OrgApi extends EntityApi {
28
28
  * Switch organization
29
29
  * @param id Organization id
30
30
  * @param serviceId Service id
31
+ * @param payload Payload
31
32
  */
32
33
  async switch(id, serviceId, payload) {
33
34
  const result = await this.app.api.put('Organization/Switch', {
@@ -1,3 +1,4 @@
1
+ import { IApiPayload } from '@etsoo/restclient';
1
2
  import { ListType, ListType1 } from '@etsoo/shared';
2
3
  import { Currency } from '../business/Currency';
3
4
  import { ProductUnit } from '../business/ProductUnit';
@@ -19,16 +20,18 @@ export declare class PublicApi extends BaseApi {
19
20
  /**
20
21
  * Get exchange rate
21
22
  * @param currency Currency
23
+ * @param payload Payload
22
24
  * @returns Result
23
25
  */
24
- exchangeRate(currency: Currency | string): Promise<ExchangeRateDto | undefined>;
26
+ exchangeRate(currency: Currency | string, payload?: IApiPayload<ExchangeRateDto>): Promise<ExchangeRateDto | undefined>;
25
27
  /**
26
28
  * Get exchange rate history
27
29
  * @param currencies Currencies
28
30
  * @param months Max months
31
+ * @param payload Payload
29
32
  * @returns Result
30
33
  */
31
- exchangeRateHistory(currencies: (Currency | string)[], months?: number): Promise<ExchangeRateHistoryDto[] | undefined>;
34
+ exchangeRateHistory(currencies: (Currency | string)[], months?: number, payload?: IApiPayload<ExchangeRateHistoryDto[]>): Promise<ExchangeRateHistoryDto[] | undefined>;
32
35
  /**
33
36
  * Get product unit's label
34
37
  * Please define the label in culture with key 'unitPC' for ProductUnit.PC like that
@@ -42,15 +45,17 @@ export declare class PublicApi extends BaseApi {
42
45
  * Get mobile base64 QRCode
43
46
  * @param id User id
44
47
  * @param host Host URL
48
+ * @param payload Payload
45
49
  */
46
- mobileQRCode(id?: string, host?: string): Promise<string | undefined>;
50
+ mobileQRCode(id?: string, host?: string, payload?: IApiPayload<string>): Promise<string | undefined>;
47
51
  /**
48
52
  * Get public and valid product data
49
53
  * @param id Product/Service Id or Uid
50
54
  * @param culture Language
55
+ * @param payload Payload
51
56
  * @returns Result
52
57
  */
53
- product<T extends number | string>(id: T, culture?: string): T extends number ? PublicProductDto : PublicOrgProductDto;
58
+ product<T extends number | string>(id: T, culture?: string, payload?: IApiPayload<PublicProductDto>): Promise<(T extends number ? PublicProductDto : PublicOrgProductDto) | undefined>;
54
59
  /**
55
60
  *
56
61
  * Get all repeat options
@@ -13,7 +13,7 @@ export class PublicApi extends BaseApi {
13
13
  */
14
14
  async currencies(currencyNames) {
15
15
  if (currencyNames == null)
16
- return (await this.api.get('Public/GetCurrencies'));
16
+ return (await this.api.get('Public/GetCurrencies', undefined, { defaultValue: [], showLoading: false }));
17
17
  else
18
18
  return currencyNames.map((name) => {
19
19
  var _a;
@@ -26,19 +26,22 @@ export class PublicApi extends BaseApi {
26
26
  /**
27
27
  * Get exchange rate
28
28
  * @param currency Currency
29
+ * @param payload Payload
29
30
  * @returns Result
30
31
  */
31
- exchangeRate(currency) {
32
- return this.api.get(`Public/ExchangeRate/${currency}`);
32
+ exchangeRate(currency, payload) {
33
+ return this.api.get(`Public/ExchangeRate/${currency}`, undefined, payload);
33
34
  }
34
35
  /**
35
36
  * Get exchange rate history
36
37
  * @param currencies Currencies
37
38
  * @param months Max months
39
+ * @param payload Payload
38
40
  * @returns Result
39
41
  */
40
- exchangeRateHistory(currencies, months) {
41
- return this.api.post('Public/ExchangeRateHistory', { currencies, months }, { defaultValue: [] });
42
+ exchangeRateHistory(currencies, months, payload) {
43
+ payload !== null && payload !== void 0 ? payload : (payload = { defaultValue: [] });
44
+ return this.api.post('Public/ExchangeRateHistory', { currencies, months }, payload);
42
45
  }
43
46
  /**
44
47
  * Get product unit's label
@@ -69,19 +72,21 @@ export class PublicApi extends BaseApi {
69
72
  * Get mobile base64 QRCode
70
73
  * @param id User id
71
74
  * @param host Host URL
75
+ * @param payload Payload
72
76
  */
73
- mobileQRCode(id, host) {
74
- return this.api.post('Public/MobileQRCode', { id, host });
77
+ mobileQRCode(id, host, payload) {
78
+ return this.api.post('Public/MobileQRCode', { id, host }, payload);
75
79
  }
76
80
  /**
77
81
  * Get public and valid product data
78
82
  * @param id Product/Service Id or Uid
79
83
  * @param culture Language
84
+ * @param payload Payload
80
85
  * @returns Result
81
86
  */
82
- product(id, culture) {
87
+ product(id, culture, payload) {
83
88
  culture = this.app.checkLanguage(culture);
84
- return this.api.post(`Public/Product/${id}/${culture}`);
89
+ return this.api.get(`Public/Product/${id}/${culture}`, undefined, payload);
85
90
  }
86
91
  /**
87
92
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.3.10",
3
+ "version": "1.3.12",
4
4
  "description": "Applications shared TypeScript framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -65,8 +65,8 @@
65
65
  "@babel/preset-env": "^7.19.4",
66
66
  "@babel/runtime-corejs3": "^7.19.4",
67
67
  "@types/jest": "^29.1.2",
68
- "@typescript-eslint/eslint-plugin": "^5.40.0",
69
- "@typescript-eslint/parser": "^5.40.0",
68
+ "@typescript-eslint/eslint-plugin": "^5.40.1",
69
+ "@typescript-eslint/parser": "^5.40.1",
70
70
  "eslint": "^8.25.0",
71
71
  "eslint-config-airbnb-base": "^15.0.0",
72
72
  "eslint-plugin-import": "^2.26.0",
@@ -4,6 +4,7 @@ import { AddressRegion, AddressRegionDb } from '../address/AddressRegion';
4
4
  import { AddressState } from '../address/AddressState';
5
5
  import { IdLabelConditional } from './dto/IdLabelDto';
6
6
  import { BaseApi } from './BaseApi';
7
+ import { IApiPayload } from '@etsoo/restclient';
7
8
 
8
9
  /**
9
10
  * Address Api
@@ -57,7 +58,7 @@ export class AddressApi extends BaseApi {
57
58
  return (await this.api.get<AddressRegionDb[]>(
58
59
  `Address/RegionList?language=${this.app.culture}`,
59
60
  undefined,
60
- { defaultValue: [] }
61
+ { defaultValue: [], showLoading: false }
61
62
  )) as any;
62
63
  }
63
64
  }
@@ -65,13 +66,16 @@ export class AddressApi extends BaseApi {
65
66
  /**
66
67
  * Get state list
67
68
  * @param regionId Region id
69
+ * @param payload Payload
68
70
  * @returns Result
69
71
  */
70
- states(regionId: string) {
71
- return this.api.get<AddressState[]>(
72
+ states(regionId: string, payload?: IApiPayload<AddressState[]>) {
73
+ payload ??= { defaultValue: [], showLoading: false };
74
+
75
+ return this.api.get(
72
76
  `Address/StateList?regionId=${regionId}&language=${this.app.culture}`,
73
77
  undefined,
74
- { defaultValue: [] }
78
+ payload
75
79
  );
76
80
  }
77
81
  }
@@ -30,7 +30,7 @@ export class EntityApi<T extends IApp = IApp> extends BaseApi<T> {
30
30
  data: object,
31
31
  payload?: IApiPayload<R>
32
32
  ) {
33
- return this.api.put<R>(`${this.flag}/Create`, data, payload);
33
+ return this.api.put(`${this.flag}/Create`, data, payload);
34
34
  }
35
35
 
36
36
  /**
@@ -41,11 +41,11 @@ export class EntityApi<T extends IApp = IApp> extends BaseApi<T> {
41
41
  protected deleteBase<R extends IActionResult>(
42
42
  id: DataTypes.IdType,
43
43
  payload?: IApiPayload<R>
44
- ): R;
44
+ ): Promise<R | undefined>;
45
45
  protected deleteBase<R extends IActionResult>(
46
46
  ids: DataTypes.IdType[],
47
47
  payload?: IApiPayload<R>
48
- ): R;
48
+ ): Promise<R | undefined>;
49
49
  protected deleteBase<R extends IActionResult>(
50
50
  id: DataTypes.IdType | DataTypes.IdType[],
51
51
  payload?: IApiPayload<R>
@@ -53,7 +53,7 @@ export class EntityApi<T extends IApp = IApp> extends BaseApi<T> {
53
53
  const query = Array.isArray(id)
54
54
  ? '?' + id.map((item) => `ids=${item}`).join('&')
55
55
  : id;
56
- return this.api.delete<R>(
56
+ return this.api.delete(
57
57
  `${this.flag}/Delete/${query}`,
58
58
  undefined,
59
59
  payload
@@ -70,7 +70,7 @@ export class EntityApi<T extends IApp = IApp> extends BaseApi<T> {
70
70
  rq: RQ,
71
71
  payload?: IApiPayload<R[]>
72
72
  ) {
73
- return this.api.post<R[]>(`${this.flag}/List`, rq, payload);
73
+ return this.api.post(`${this.flag}/List`, rq, payload);
74
74
  }
75
75
 
76
76
  /**
@@ -83,7 +83,7 @@ export class EntityApi<T extends IApp = IApp> extends BaseApi<T> {
83
83
  rq: RQ,
84
84
  payload?: IApiPayload<R[]>
85
85
  ) {
86
- return this.api.post<R[]>(`${this.flag}/Query`, rq, payload);
86
+ return this.api.post(`${this.flag}/Query`, rq, payload);
87
87
  }
88
88
 
89
89
  /**
@@ -96,7 +96,7 @@ export class EntityApi<T extends IApp = IApp> extends BaseApi<T> {
96
96
  id: DataTypes.IdType,
97
97
  payload?: IApiPayload<R>
98
98
  ) {
99
- return this.api.get<R>(`${this.flag}/Read/${id}`, payload);
99
+ return this.api.get(`${this.flag}/Read/${id}`, undefined, payload);
100
100
  }
101
101
 
102
102
  /**
@@ -111,7 +111,7 @@ export class EntityApi<T extends IApp = IApp> extends BaseApi<T> {
111
111
  ) {
112
112
  const rq: Record<DataTypes.IdType, number> = {};
113
113
  items.forEach((item, index) => (rq[item.id] = index));
114
- return this.api.put<number>(`${this.flag}/Sort`, rq, payload);
114
+ return this.api.put(`${this.flag}/Sort`, rq, payload);
115
115
  }
116
116
 
117
117
  /**
@@ -124,7 +124,7 @@ export class EntityApi<T extends IApp = IApp> extends BaseApi<T> {
124
124
  data: object,
125
125
  payload?: IApiPayload<R>
126
126
  ) {
127
- return this.api.put<R>(`${this.flag}/Update`, data, payload);
127
+ return this.api.put(`${this.flag}/Update`, data, payload);
128
128
  }
129
129
 
130
130
  /**
@@ -137,6 +137,10 @@ export class EntityApi<T extends IApp = IApp> extends BaseApi<T> {
137
137
  id: DataTypes.IdType,
138
138
  payload?: IApiPayload<R>
139
139
  ) {
140
- return this.api.get<R>(`${this.flag}/UpdateRead/${id}`, payload);
140
+ return this.api.get(
141
+ `${this.flag}/UpdateRead/${id}`,
142
+ undefined,
143
+ payload
144
+ );
141
145
  }
142
146
  }
package/src/erp/OrgApi.ts CHANGED
@@ -24,6 +24,7 @@ export class OrgApi extends EntityApi {
24
24
  * Get organization list
25
25
  * @param items Max items or request data
26
26
  * @param serviceId Service id
27
+ * @param payload Payload
27
28
  * @returns Result
28
29
  */
29
30
  list(items?: number, serviceId?: number): Promise<ListType[] | undefined>;
@@ -52,13 +53,14 @@ export class OrgApi extends EntityApi {
52
53
  * Switch organization
53
54
  * @param id Organization id
54
55
  * @param serviceId Service id
56
+ * @param payload Payload
55
57
  */
56
58
  async switch(
57
59
  id: number,
58
60
  serviceId?: number,
59
61
  payload?: IApiPayload<boolean>
60
62
  ) {
61
- const result = await this.app.api.put<boolean>(
63
+ const result = await this.app.api.put(
62
64
  'Organization/Switch',
63
65
  {
64
66
  id,
@@ -81,6 +83,6 @@ export class OrgApi extends EntityApi {
81
83
  data: DataTypes.AddOrEditType<OrgRQ, true>,
82
84
  payload?: IApiPayload<IdActionResult>
83
85
  ) {
84
- return super.updateBase<IdActionResult>(data, payload);
86
+ return super.updateBase(data, payload);
85
87
  }
86
88
  }
@@ -1,3 +1,4 @@
1
+ import { IApiPayload } from '@etsoo/restclient';
1
2
  import { DataTypes, ListType, ListType1 } from '@etsoo/shared';
2
3
  import { Currency } from '../business/Currency';
3
4
  import { ProductUnit } from '../business/ProductUnit';
@@ -22,7 +23,9 @@ export class PublicApi extends BaseApi {
22
23
  ): Promise<T extends undefined ? CurrencyDto[] | undefined : ListType1[]> {
23
24
  if (currencyNames == null)
24
25
  return (await this.api.get<CurrencyDto[]>(
25
- 'Public/GetCurrencies'
26
+ 'Public/GetCurrencies',
27
+ undefined,
28
+ { defaultValue: [], showLoading: false }
26
29
  )) as any;
27
30
  else
28
31
  return currencyNames.map((name) => ({
@@ -34,23 +37,37 @@ export class PublicApi extends BaseApi {
34
37
  /**
35
38
  * Get exchange rate
36
39
  * @param currency Currency
40
+ * @param payload Payload
37
41
  * @returns Result
38
42
  */
39
- exchangeRate(currency: Currency | string) {
40
- return this.api.get<ExchangeRateDto>(`Public/ExchangeRate/${currency}`);
43
+ exchangeRate(
44
+ currency: Currency | string,
45
+ payload?: IApiPayload<ExchangeRateDto>
46
+ ) {
47
+ return this.api.get(
48
+ `Public/ExchangeRate/${currency}`,
49
+ undefined,
50
+ payload
51
+ );
41
52
  }
42
53
 
43
54
  /**
44
55
  * Get exchange rate history
45
56
  * @param currencies Currencies
46
57
  * @param months Max months
58
+ * @param payload Payload
47
59
  * @returns Result
48
60
  */
49
- exchangeRateHistory(currencies: (Currency | string)[], months?: number) {
50
- return this.api.post<ExchangeRateHistoryDto[]>(
61
+ exchangeRateHistory(
62
+ currencies: (Currency | string)[],
63
+ months?: number,
64
+ payload?: IApiPayload<ExchangeRateHistoryDto[]>
65
+ ) {
66
+ payload ??= { defaultValue: [] };
67
+ return this.api.post(
51
68
  'Public/ExchangeRateHistory',
52
69
  { currencies, months },
53
- { defaultValue: [] }
70
+ payload
54
71
  );
55
72
  }
56
73
 
@@ -83,24 +100,31 @@ export class PublicApi extends BaseApi {
83
100
  * Get mobile base64 QRCode
84
101
  * @param id User id
85
102
  * @param host Host URL
103
+ * @param payload Payload
86
104
  */
87
- mobileQRCode(id?: string, host?: string) {
88
- return this.api.post<string>('Public/MobileQRCode', { id, host });
105
+ mobileQRCode(id?: string, host?: string, payload?: IApiPayload<string>) {
106
+ return this.api.post('Public/MobileQRCode', { id, host }, payload);
89
107
  }
90
108
 
91
109
  /**
92
110
  * Get public and valid product data
93
111
  * @param id Product/Service Id or Uid
94
112
  * @param culture Language
113
+ * @param payload Payload
95
114
  * @returns Result
96
115
  */
97
116
  product<T extends number | string>(
98
117
  id: T,
99
- culture?: string
100
- ): T extends number ? PublicProductDto : PublicOrgProductDto {
118
+ culture?: string,
119
+ payload?: IApiPayload<PublicProductDto>
120
+ ): Promise<
121
+ (T extends number ? PublicProductDto : PublicOrgProductDto) | undefined
122
+ > {
101
123
  culture = this.app.checkLanguage(culture);
102
- return this.api.post<PublicProductDto>(
103
- `Public/Product/${id}/${culture}`
124
+ return this.api.get(
125
+ `Public/Product/${id}/${culture}`,
126
+ undefined,
127
+ payload
104
128
  ) as any;
105
129
  }
106
130