@hapl/api-queries 0.1.120--canary.56.370797d.0 → 0.1.120

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/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ # v0.1.120 (Mon Feb 07 2022)
2
+
3
+ #### 🐛 Bug Fix
4
+
5
+ - отрефакторил запрос [#57](https://github.com/homeappcorporate/api-queries/pull/57) ([@yeshkarluk](https://github.com/yeshkarluk))
6
+
7
+ #### Authors: 1
8
+
9
+ - Ivan Ignatev ([@yeshkarluk](https://github.com/yeshkarluk))
10
+
11
+ ---
12
+
1
13
  # v0.1.119 (Fri Feb 04 2022)
2
14
 
3
15
  #### 🐛 Bug Fix
@@ -6,6 +6,7 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'defau
6
6
 
7
7
  var axios = _interopDefault(require('axios'));
8
8
  var qs = _interopDefault(require('qs'));
9
+ var nanoid = require('nanoid');
9
10
  var chunk = _interopDefault(require('lodash/chunk'));
10
11
 
11
12
  function getPasswordRequest(_ref) {
@@ -413,45 +414,6 @@ function declineContractRequest(_ref) {
413
414
  });
414
415
  }
415
416
 
416
- function findContractsRequest(_ref) {
417
- var _ref$baseURL = _ref.baseURL,
418
- baseURL = _ref$baseURL === void 0 ? 'https://clients.homeapp.ru' : _ref$baseURL,
419
- headers = _ref.headers,
420
- params = _ref.params;
421
- return axios.get('/api/contract', {
422
- baseURL: baseURL,
423
- params: params,
424
- paramsSerializer: function paramsSerializer(params) {
425
- return qs.stringify(params, {
426
- arrayFormat: 'brackets'
427
- });
428
- },
429
- headers: _extends({
430
- Accept: 'application/json'
431
- }, headers),
432
- transformResponse: [].concat(axios.defaults.transformResponse, [function (data) {
433
- if (!data.success) return data.data.error || data.data.message;
434
- var ids = [];
435
- var byId = {};
436
- data.data.forEach(function (entity) {
437
- byId[entity.id] = entity;
438
- ids.push(entity.id);
439
- });
440
- return {
441
- ids: ids,
442
- byId: byId,
443
- meta: {
444
- total: data.pageParams.length
445
- }
446
- };
447
- }])
448
- }).then(function (res) {
449
- return res;
450
- })["catch"](function (err) {
451
- throw err;
452
- });
453
- }
454
-
455
417
  function terminateContractRequest(_ref) {
456
418
  var _ref$baseURL = _ref.baseURL,
457
419
  baseURL = _ref$baseURL === void 0 ? 'https://clients.homeapp.ru' : _ref$baseURL,
@@ -2758,14 +2720,6 @@ var Api = function Api(baseURL) {
2758
2720
  });
2759
2721
  };
2760
2722
 
2761
- this.findContracts = function (params, headers) {
2762
- return findContractsRequest({
2763
- params: params,
2764
- headers: headers,
2765
- baseURL: _this.baseURL
2766
- });
2767
- };
2768
-
2769
2723
  this.terminateContract = function (urlParams, body, headers) {
2770
2724
  return terminateContractRequest({
2771
2725
  urlParams: urlParams,
@@ -3189,7 +3143,6 @@ var index = {
3189
3143
  createCallTaskRequest: createCallTaskRequest,
3190
3144
  approveContractRequest: approveContractRequest,
3191
3145
  declineContractRequest: declineContractRequest,
3192
- findContractsRequest: findContractsRequest,
3193
3146
  terminateContractRequest: terminateContractRequest,
3194
3147
  createDealCategorizedFileRequest: createDealCategorizedFileRequest,
3195
3148
  createDealInvestPrepaymentRequest: createDealInvestPrepaymentRequest,
@@ -4689,29 +4642,36 @@ function findActualEventsRowRequest(_ref) {
4689
4642
  },
4690
4643
  headers: _extends({
4691
4644
  Accept: 'application/json'
4692
- }, headers)
4693
- }).then(function (res) {
4694
- var data = {
4695
- data: {
4696
- byId: {},
4697
- ids: []
4698
- },
4699
- meta: {
4700
- total: res.data.pageParams.length
4645
+ }, headers),
4646
+ transformResponse: [].concat(axios.defaults.transformResponse, [function (data) {
4647
+ var _ref2, _data$data$error, _data$data;
4648
+
4649
+ if (data.success) {
4650
+ var ids = [];
4651
+ var byId = {};
4652
+ data.data.forEach(function (entity) {
4653
+ var _id = nanoid.nanoid();
4654
+
4655
+ byId[_id] = _extends({}, entity, {
4656
+ _id: _id
4657
+ });
4658
+ ids.push(_id);
4659
+ });
4660
+ return {
4661
+ ids: ids,
4662
+ byId: byId,
4663
+ meta: {
4664
+ total: data.pageParams.length
4665
+ }
4666
+ };
4701
4667
  }
4702
- };
4703
- res.data.data.forEach(function (entity) {
4704
- data.data.byId[entity.apartmentId] = entity;
4705
- data.data.ids.push(entity.apartmentId);
4706
- });
4707
- return data;
4708
- })["catch"](function (err) {
4709
- var _err$response$status, _err$response, _ref2, _err$response$data$me, _err$response2, _err$response3, _err$response3$data$d;
4710
4668
 
4711
- var error = new Error(err.message);
4712
- error.status = (_err$response$status = (_err$response = err.response) == null ? void 0 : _err$response.status) != null ? _err$response$status : 520;
4713
- error.data = (_ref2 = (_err$response$data$me = (_err$response2 = err.response) == null ? void 0 : _err$response2.data.message) != null ? _err$response$data$me : (_err$response3 = err.response) == null ? void 0 : (_err$response3$data$d = _err$response3.data.data) == null ? void 0 : _err$response3$data$d.error) != null ? _ref2 : 'Unknown Error';
4714
- throw error;
4669
+ return (_ref2 = (_data$data$error = (_data$data = data.data) == null ? void 0 : _data$data.error) != null ? _data$data$error : data.message) != null ? _ref2 : 'Unknown Error';
4670
+ }])
4671
+ }).then(function (res) {
4672
+ return res;
4673
+ })["catch"](function (err) {
4674
+ throw err;
4715
4675
  });
4716
4676
  }
4717
4677