taxtank-core 0.8.2 → 0.8.3

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.
@@ -11406,17 +11406,24 @@
11406
11406
  }] });
11407
11407
 
11408
11408
  var SubscriptionService = /** @class */ (function () {
11409
- function SubscriptionService(http, eventDispatcherService, environment) {
11409
+ function SubscriptionService(http, eventDispatcherService, sseService, environment) {
11410
11410
  this.http = http;
11411
11411
  this.eventDispatcherService = eventDispatcherService;
11412
+ this.sseService = sseService;
11412
11413
  this.environment = environment;
11413
11414
  this.serviceSubscriptionSubject = new rxjs.ReplaySubject(1);
11414
11415
  this.serviceSubscriptionsSubject = new rxjs.ReplaySubject(1);
11415
11416
  this.servicePaymentsSubject = new rxjs.ReplaySubject(1);
11417
+ this.subscriptionChangeSubject = new rxjs.BehaviorSubject(null);
11418
+ this.listenEvents();
11416
11419
  }
11417
- SubscriptionService.prototype.getSubscription = function () {
11420
+ SubscriptionService.prototype.listenEvents = function () {
11421
+ this.listenSubscriptions();
11422
+ };
11423
+ SubscriptionService.prototype.getSubscription = function (force) {
11418
11424
  var _this = this;
11419
- if (!this._serviceSubscription) {
11425
+ if (force === void 0) { force = false; }
11426
+ if (!this._serviceSubscription || force) {
11420
11427
  this.http.get(this.environment.apiV2 + "/subscriptions/last")
11421
11428
  .pipe(operators.map(function (response) {
11422
11429
  return classTransformer.plainToClass(ServiceSubscription, response);
@@ -11443,8 +11450,18 @@
11443
11450
  .subscribe(function (prices) {
11444
11451
  _this._serviceSubscriptions = new ServiceSubscriptionCollection([
11445
11452
  classTransformer.plainToClass(ServiceSubscription, { items: [] }),
11446
- classTransformer.plainToClass(ServiceSubscription, { items: [classTransformer.plainToClass(ServiceSubscriptionItem, { price: prices.property, quantity: 2 })] }),
11447
- classTransformer.plainToClass(ServiceSubscription, { items: [classTransformer.plainToClass(ServiceSubscriptionItem, { price: prices.property, quantity: 3 })] })
11453
+ classTransformer.plainToClass(ServiceSubscription, {
11454
+ items: [classTransformer.plainToClass(ServiceSubscriptionItem, {
11455
+ price: prices.property,
11456
+ quantity: 2
11457
+ })]
11458
+ }),
11459
+ classTransformer.plainToClass(ServiceSubscription, {
11460
+ items: [classTransformer.plainToClass(ServiceSubscriptionItem, {
11461
+ price: prices.property,
11462
+ quantity: 3
11463
+ })]
11464
+ })
11448
11465
  ]);
11449
11466
  _this._serviceSubscriptions.items.forEach(function (subscription) {
11450
11467
  subscription.items.push(classTransformer.plainToClass(ServiceSubscriptionItem, { price: prices.work, quantity: 1 }));
@@ -11514,19 +11531,21 @@
11514
11531
  * Change subscription plan
11515
11532
  */
11516
11533
  SubscriptionService.prototype.changeSubscription = function (items) {
11534
+ return this.http.put(this.environment.apiV2 + "/subscriptions/items", items);
11535
+ };
11536
+ SubscriptionService.prototype.listenSubscriptions = function () {
11517
11537
  var _this = this;
11518
- return this.http.put(this.environment.apiV2 + "/subscriptions/items", items).pipe(operators.map(function () {
11519
- // Set cache value as null and fire request to backend to get updated subscription value
11520
- _this._serviceSubscription = null;
11521
- _this.serviceSubscriptionSubject.next(_this._serviceSubscription);
11522
- // update property list
11538
+ this.sseService.on("serviceSubscriptions")
11539
+ .pipe(operators.map(function (event) { return classTransformer.plainToClass(ServiceSubscription, event); }))
11540
+ .subscribe(function (subscription) {
11541
+ _this.getSubscription(true).subscribe();
11542
+ _this.subscriptionChangeSubject.next(subscription);
11523
11543
  _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.SERVICE_SUBSCRIPTION_UPDATED, null));
11524
- _this.getSubscription().subscribe();
11525
- }));
11544
+ });
11526
11545
  };
11527
11546
  return SubscriptionService;
11528
11547
  }());
11529
- SubscriptionService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SubscriptionService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
11548
+ SubscriptionService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SubscriptionService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: SseService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
11530
11549
  SubscriptionService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SubscriptionService, providedIn: 'root' });
11531
11550
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SubscriptionService, decorators: [{
11532
11551
  type: i0.Injectable,
@@ -11534,7 +11553,7 @@
11534
11553
  providedIn: 'root'
11535
11554
  }]
11536
11555
  }], ctorParameters: function () {
11537
- return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
11556
+ return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: SseService }, { type: undefined, decorators: [{
11538
11557
  type: i0.Inject,
11539
11558
  args: ['environment']
11540
11559
  }] }];