taxtank-core 0.16.4 → 0.16.7

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.
@@ -831,7 +831,8 @@
831
831
  BANK_TRANSACTIONS_GET: new Endpoint('GET', '\\/bank-transactions'),
832
832
  BANK_TRANSACTIONS_DELETE: new Endpoint('DELETE', '\\/bank-transactions\\/\\d+'),
833
833
  BANK_TRANSACTIONS_IMPORT_POST: new Endpoint('POST', '\\/bank-transactions\\/\\d+\\/import'),
834
- BASIQ_ACCOUNTS_GET: new Endpoint('GET', '\\/basiq\\/\\accounts'),
834
+ BASIQ_ACCOUNTS_GET: new Endpoint('GET', '\\/basiq\\/accounts'),
835
+ BASIQ_TOKEN_GET: new Endpoint('GET', '\\/basiq\\/tokens'),
835
836
  CHARTS_INCOME_GET: new Endpoint('GET', '\\/charts\\/\\incomes'),
836
837
  CHARTS_EXPENSES_GET: new Endpoint('GET', '\\/charts\\/\\expenses'),
837
838
  CHART_ACCOUNTS_GET: new Endpoint('GET', '\\/chart-accounts'),
@@ -3950,8 +3951,7 @@
3950
3951
  exports.PropertyCategoryListEnum = void 0;
3951
3952
  (function (PropertyCategoryListEnum) {
3952
3953
  PropertyCategoryListEnum[PropertyCategoryListEnum["OWNER_OCCUPIED"] = 3] = "OWNER_OCCUPIED";
3953
- // @TODO prod use 5
3954
- PropertyCategoryListEnum[PropertyCategoryListEnum["VACANT_LAND"] = 6] = "VACANT_LAND";
3954
+ PropertyCategoryListEnum[PropertyCategoryListEnum["VACANT_LAND"] = 5] = "VACANT_LAND";
3955
3955
  })(exports.PropertyCategoryListEnum || (exports.PropertyCategoryListEnum = {}));
3956
3956
 
3957
3957
  exports.TaxExemptionMetadataEnum = void 0;
@@ -10461,6 +10461,14 @@
10461
10461
  }]
10462
10462
  }] });
10463
10463
 
10464
+ /**
10465
+ * Basiq consent UI initial URL. Replace USER_ID and TOKEN by user data + handle action parameter
10466
+ */
10467
+ var BASIQ_CONSENT_URL = 'https://consent.basiq.io/home?userId=USER_ID&token=TOKEN&action=connect';
10468
+ /**
10469
+ * Event message name we listen to handle basiq UI result
10470
+ */
10471
+ var FINISH_BASIQ_EVENT = 'finish-basiq';
10464
10472
  /**
10465
10473
  * basiq is a middleman between bank and user
10466
10474
  * service is responsible for fetching bank related information
@@ -10480,6 +10488,7 @@
10480
10488
  BasiqService.prototype.listenEvents = function () {
10481
10489
  this.listenToBankConnectionAdded();
10482
10490
  this.listenNotifications();
10491
+ this.listenBasiqConcentUpdated();
10483
10492
  };
10484
10493
  /**
10485
10494
  * Update user's basiq consents data on backend
@@ -10488,7 +10497,6 @@
10488
10497
  var _this = this;
10489
10498
  return this.http.put(this.environment.apiV2 + "/basiq/consents", {}).pipe(operators.map(function (isConfirmed) {
10490
10499
  _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.BASIQ_CONSENT_UPDATED, isConfirmed));
10491
- return isConfirmed;
10492
10500
  }));
10493
10501
  };
10494
10502
  /**
@@ -10509,11 +10517,15 @@
10509
10517
  return new BasiqToken(response['access_token'], new Date(now + response['expires_in'] * 1000));
10510
10518
  }))
10511
10519
  .subscribe(function (token) {
10520
+ _this.token = token;
10512
10521
  _this.tokenSubject.next(token);
10513
10522
  });
10514
10523
  }
10515
10524
  return this.tokenSubject.asObservable();
10516
10525
  };
10526
+ /**
10527
+ * Get list of user's bank conections
10528
+ */
10517
10529
  BasiqService.prototype.getConnections = function () {
10518
10530
  return this.get().pipe(operators.map(function (bankAccounts) {
10519
10531
  // get all connections
@@ -10524,6 +10536,41 @@
10524
10536
  return __spreadArray([], __read(new Map(connections.map(function (connection) { return [connection.id, connection]; })).values()));
10525
10537
  }));
10526
10538
  };
10539
+ /**
10540
+ * Listen response from basiq UI to handle result.
10541
+ * @param isBasiqConsentExist flag from User.ClientDetails - true if user confirmed basiq consent
10542
+ * @param callback function we run after basiq UI work is finished
10543
+ */
10544
+ BasiqService.prototype.listenBasiqResponse = function (isBasiqConsentExist, callback) {
10545
+ var _this = this;
10546
+ window.addEventListener('message', function (message) {
10547
+ if (message.data !== FINISH_BASIQ_EVENT) {
10548
+ return;
10549
+ }
10550
+ // update user's basiq consent confirmation status for the first basiq ui run
10551
+ if (isBasiqConsentExist) {
10552
+ _this.updateConnections().pipe(operators.take(1)).subscribe();
10553
+ }
10554
+ else {
10555
+ _this.confirmConsents().pipe(operators.take(1)).subscribe();
10556
+ }
10557
+ callback();
10558
+ });
10559
+ };
10560
+ /**
10561
+ * Get URL with filled params to run basiq UI iframe
10562
+ */
10563
+ BasiqService.prototype.generateBasiqConsentUrl = function (user) {
10564
+ return this.getToken().pipe(operators.map(function (token) {
10565
+ var url = BASIQ_CONSENT_URL;
10566
+ url = url.replace('USER_ID', user.basiqId);
10567
+ url = url.replace('TOKEN', token.value);
10568
+ if (!user.clientDetails.basiqConsentExist) {
10569
+ url = url.split('&action')[0];
10570
+ }
10571
+ return url;
10572
+ }));
10573
+ };
10527
10574
  /**
10528
10575
  * Listen to EventDispatcherService event related to added Bank connection
10529
10576
  */
@@ -10548,6 +10595,18 @@
10548
10595
  }
10549
10596
  });
10550
10597
  };
10598
+ /**
10599
+ * Update user's basiq connections when user confirmed basiq consent
10600
+ */
10601
+ BasiqService.prototype.listenBasiqConcentUpdated = function () {
10602
+ var _this = this;
10603
+ this.eventDispatcherService.on(exports.AppEventTypeEnum.BASIQ_CONSENT_UPDATED).subscribe(function (isConfirmed) {
10604
+ if (!isConfirmed) {
10605
+ return;
10606
+ }
10607
+ _this.updateConnections().pipe(operators.take(1)).subscribe();
10608
+ });
10609
+ };
10551
10610
  return BasiqService;
10552
10611
  }(RestService));
10553
10612
  BasiqService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BasiqService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });