@esolve/ng-esolve-connect 0.6.1 → 0.7.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.
Files changed (175) hide show
  1. package/{esm2015/esolve-ng-esolve-connect.js → esm2020/esolve-ng-esolve-connect.mjs} +0 -0
  2. package/esm2020/lib/account/esolve-account.service.mjs +161 -0
  3. package/esm2020/lib/account/esolve-address-record.mjs +2 -0
  4. package/esm2020/lib/account/esolve-address-response.mjs +2 -0
  5. package/esm2020/lib/account/esolve-address-result.mjs +11 -0
  6. package/esm2020/lib/account/esolve-address-set-data.mjs +2 -0
  7. package/esm2020/lib/account/esolve-address.mjs +19 -0
  8. package/esm2020/lib/account/esolve-geocode-result.mjs +2 -0
  9. package/esm2020/lib/account/esolve-registration-data.mjs +2 -0
  10. package/esm2020/lib/account/esolve-registration-post-response-item.mjs +2 -0
  11. package/esm2020/lib/account/esolve-registration-result.mjs +11 -0
  12. package/esm2020/lib/account/esolve-user-account-data.mjs +2 -0
  13. package/esm2020/lib/account/esolve-user-account-record.mjs +2 -0
  14. package/esm2020/lib/account/esolve-user-account-result.mjs +9 -0
  15. package/esm2020/lib/account/esolve-user-account.mjs +29 -0
  16. package/{esm2015/lib/auth/esolve-auth-interceptor.service.js → esm2020/lib/auth/esolve-auth-interceptor.service.mjs} +7 -7
  17. package/esm2020/lib/auth/esolve-auth.service.mjs +163 -0
  18. package/{esm2015/lib/banners/esolve-banner-image-hotspot-record.js → esm2020/lib/banners/esolve-banner-image-hotspot-record.mjs} +0 -0
  19. package/{esm2015/lib/banners/esolve-banner-image-hotspot.js → esm2020/lib/banners/esolve-banner-image-hotspot.mjs} +0 -0
  20. package/{esm2015/lib/banners/esolve-banner-image-record.js → esm2020/lib/banners/esolve-banner-image-record.mjs} +0 -0
  21. package/{esm2015/lib/banners/esolve-banner-image.js → esm2020/lib/banners/esolve-banner-image.mjs} +0 -0
  22. package/{esm2015/lib/banners/esolve-banner-record.js → esm2020/lib/banners/esolve-banner-record.mjs} +0 -0
  23. package/{esm2015/lib/banners/esolve-banner-type.js → esm2020/lib/banners/esolve-banner-type.mjs} +0 -0
  24. package/{esm2015/lib/banners/esolve-banner.js → esm2020/lib/banners/esolve-banner.mjs} +0 -0
  25. package/{esm2015/lib/banners/esolve-banner.service.js → esm2020/lib/banners/esolve-banner.service.mjs} +3 -3
  26. package/{esm2015/lib/cart/esolve-cart-item-record.js → esm2020/lib/cart/esolve-cart-item-record.mjs} +0 -0
  27. package/{esm2015/lib/cart/esolve-cart-item-response.js → esm2020/lib/cart/esolve-cart-item-response.mjs} +0 -0
  28. package/{esm2015/lib/cart/esolve-cart-item.js → esm2020/lib/cart/esolve-cart-item.mjs} +0 -0
  29. package/{esm2015/lib/cart/esolve-cart-stock-item.js → esm2020/lib/cart/esolve-cart-stock-item.mjs} +0 -0
  30. package/{esm2015/lib/cart/esolve-cart-totals-record.js → esm2020/lib/cart/esolve-cart-totals-record.mjs} +0 -0
  31. package/{esm2015/lib/cart/esolve-cart-totals.js → esm2020/lib/cart/esolve-cart-totals.mjs} +0 -0
  32. package/esm2020/lib/cart/esolve-cart.service.mjs +172 -0
  33. package/esm2020/lib/cart/esolve-checkout-result.mjs +9 -0
  34. package/{esm2015/lib/cart/esolve-checkout.js → esm2020/lib/cart/esolve-checkout.mjs} +0 -0
  35. package/{esm2015/lib/category-tree/esolve-category-tree-item-record.js → esm2020/lib/category-tree/esolve-category-tree-item-record.mjs} +0 -0
  36. package/{esm2015/lib/category-tree/esolve-category-tree-item.js → esm2020/lib/category-tree/esolve-category-tree-item.mjs} +0 -0
  37. package/{esm2015/lib/category-tree/esolve-category-tree.service.js → esm2020/lib/category-tree/esolve-category-tree.service.mjs} +3 -3
  38. package/{esm2015/lib/esolve-connect.config.js → esm2020/lib/esolve-connect.config.mjs} +0 -0
  39. package/esm2020/lib/locations/esolve-locations.service.mjs +53 -0
  40. package/esm2020/lib/locations/esolve-stock-location-record.mjs +2 -0
  41. package/esm2020/lib/locations/esolve-stock-location.mjs +76 -0
  42. package/{esm2015/lib/media/esolve-media-article.js → esm2020/lib/media/esolve-media-article.mjs} +0 -0
  43. package/{esm2015/lib/media/esolve-media-record.js → esm2020/lib/media/esolve-media-record.mjs} +0 -0
  44. package/{esm2015/lib/media/esolve-media.service.js → esm2020/lib/media/esolve-media.service.mjs} +3 -3
  45. package/{esm2015/lib/menu/esolve-menu-item.js → esm2020/lib/menu/esolve-menu-item.mjs} +0 -0
  46. package/{esm2015/lib/menu/esolve-menu-tree-record.js → esm2020/lib/menu/esolve-menu-tree-record.mjs} +0 -0
  47. package/{esm2015/lib/menu/esolve-menu.service.js → esm2020/lib/menu/esolve-menu.service.mjs} +3 -3
  48. package/{esm2015/lib/news/esolve-news-article-author-record.js → esm2020/lib/news/esolve-news-article-author-record.mjs} +0 -0
  49. package/{esm2015/lib/news/esolve-news-article-author.js → esm2020/lib/news/esolve-news-article-author.mjs} +0 -0
  50. package/{esm2015/lib/news/esolve-news-article-list.js → esm2020/lib/news/esolve-news-article-list.mjs} +0 -0
  51. package/{esm2015/lib/news/esolve-news-article-record.js → esm2020/lib/news/esolve-news-article-record.mjs} +0 -0
  52. package/{esm2015/lib/news/esolve-news-article.js → esm2020/lib/news/esolve-news-article.mjs} +0 -0
  53. package/{esm2015/lib/news/esolve-news-group-record.js → esm2020/lib/news/esolve-news-group-record.mjs} +0 -0
  54. package/{esm2015/lib/news/esolve-news-group.js → esm2020/lib/news/esolve-news-group.mjs} +0 -0
  55. package/{esm2015/lib/news/esolve-news-manufacturer-record.js → esm2020/lib/news/esolve-news-manufacturer-record.mjs} +0 -0
  56. package/{esm2015/lib/news/esolve-news-range-record.js → esm2020/lib/news/esolve-news-range-record.mjs} +0 -0
  57. package/{esm2015/lib/news/esolve-news.service.js → esm2020/lib/news/esolve-news.service.mjs} +3 -3
  58. package/esm2020/lib/ng-esolve-connect.module.mjs +45 -0
  59. package/esm2020/lib/payment/esolve-card-data.mjs +2 -0
  60. package/esm2020/lib/payment/esolve-payment-method-options.mjs +2 -0
  61. package/esm2020/lib/payment/esolve-payment-method-record.mjs +2 -0
  62. package/esm2020/lib/payment/esolve-payment-method.mjs +49 -0
  63. package/esm2020/lib/payment/esolve-payment-response.mjs +2 -0
  64. package/esm2020/lib/payment/esolve-payment-result.mjs +22 -0
  65. package/esm2020/lib/payment/esolve-payment.service.mjs +178 -0
  66. package/esm2020/lib/payment/esolve-vault-item-result.mjs +20 -0
  67. package/esm2020/lib/payment/esolve-vault-item.mjs +19 -0
  68. package/esm2020/lib/payment/esolve-vault-record.mjs +2 -0
  69. package/esm2020/lib/payment/esolve-vault-response.mjs +2 -0
  70. package/esm2020/lib/session/esolve-session.mjs +27 -0
  71. package/esm2020/lib/session/esolve-session.service.mjs +79 -0
  72. package/esm2020/lib/session/esolve-stored-session.mjs +2 -0
  73. package/esm2020/lib/shared/error-handler/esolve-error-handler.service.mjs +58 -0
  74. package/{esm2015/lib/shared/error-handler/esolve-http-error.js → esm2020/lib/shared/error-handler/esolve-http-error.mjs} +0 -0
  75. package/{esm2015/lib/shared/esolve-response.js → esm2020/lib/shared/esolve-response.mjs} +1 -1
  76. package/{esm2015/lib/shared/esolve-url-target.js → esm2020/lib/shared/esolve-url-target.mjs} +0 -0
  77. package/esm2020/lib/shared/response-handler/esolve-response-handler.service.mjs +32 -0
  78. package/esm2020/lib/shared/response-handler/esolve-response-result.mjs +9 -0
  79. package/{esm2015/lib/shared/seo/esolve-seo-info.js → esm2020/lib/shared/seo/esolve-seo-info.mjs} +0 -0
  80. package/{esm2015/lib/shared/seo/esolve-seo.service.js → esm2020/lib/shared/seo/esolve-seo.service.mjs} +3 -3
  81. package/esm2020/lib/shipping/esolve-shipping-cost-record.mjs +2 -0
  82. package/esm2020/lib/shipping/esolve-shipping-cost.mjs +18 -0
  83. package/esm2020/lib/shipping/esolve-shipping-method-options.mjs +2 -0
  84. package/esm2020/lib/shipping/esolve-shipping-method-record.mjs +2 -0
  85. package/esm2020/lib/shipping/esolve-shipping-method.mjs +33 -0
  86. package/esm2020/lib/shipping/esolve-shipping.service.mjs +108 -0
  87. package/{esm2015/lib/stock/esolve-stock-badge-record.js → esm2020/lib/stock/esolve-stock-badge-record.mjs} +0 -0
  88. package/{esm2015/lib/stock/esolve-stock-badge.js → esm2020/lib/stock/esolve-stock-badge.mjs} +0 -0
  89. package/{esm2015/lib/stock/esolve-stock-item-list.js → esm2020/lib/stock/esolve-stock-item-list.mjs} +0 -0
  90. package/{esm2015/lib/stock/esolve-stock-item-options.js → esm2020/lib/stock/esolve-stock-item-options.mjs} +0 -0
  91. package/{esm2015/lib/stock/esolve-stock-item.js → esm2020/lib/stock/esolve-stock-item.mjs} +0 -0
  92. package/{esm2015/lib/stock/esolve-stock-price.js → esm2020/lib/stock/esolve-stock-price.mjs} +0 -0
  93. package/{esm2015/lib/stock/esolve-stock-record.js → esm2020/lib/stock/esolve-stock-record.mjs} +0 -0
  94. package/{esm2015/lib/stock/esolve-stock.service.js → esm2020/lib/stock/esolve-stock.service.mjs} +5 -6
  95. package/{esm2015/lib/tags/esolve-tag-record.js → esm2020/lib/tags/esolve-tag-record.mjs} +0 -0
  96. package/{esm2015/lib/tags/esolve-tag.js → esm2020/lib/tags/esolve-tag.mjs} +0 -0
  97. package/{esm2015/lib/topics/esolve-topic-record.js → esm2020/lib/topics/esolve-topic-record.mjs} +0 -0
  98. package/{esm2015/lib/topics/esolve-topic.js → esm2020/lib/topics/esolve-topic.mjs} +0 -0
  99. package/{esm2015/lib/topics/esolve-topic.service.js → esm2020/lib/topics/esolve-topic.service.mjs} +3 -3
  100. package/esm2020/public-api.mjs +78 -0
  101. package/fesm2015/esolve-ng-esolve-connect.mjs +2651 -0
  102. package/fesm2015/esolve-ng-esolve-connect.mjs.map +1 -0
  103. package/{fesm2015/esolve-ng-esolve-connect.js → fesm2020/esolve-ng-esolve-connect.mjs} +838 -461
  104. package/fesm2020/esolve-ng-esolve-connect.mjs.map +1 -0
  105. package/lib/account/esolve-account.service.d.ts +35 -0
  106. package/lib/{auth → account}/esolve-address-record.d.ts +0 -0
  107. package/lib/account/esolve-address-response.d.ts +8 -0
  108. package/lib/account/esolve-address-result.d.ts +10 -0
  109. package/lib/account/esolve-address-set-data.d.ts +17 -0
  110. package/lib/{auth → account}/esolve-address.d.ts +0 -0
  111. package/lib/account/esolve-geocode-result.d.ts +16 -0
  112. package/lib/{auth → account}/esolve-registration-data.d.ts +0 -0
  113. package/lib/account/esolve-registration-post-response-item.d.ts +7 -0
  114. package/lib/account/esolve-registration-result.d.ts +9 -0
  115. package/lib/account/esolve-user-account-data.d.ts +17 -0
  116. package/lib/account/esolve-user-account-record.d.ts +21 -0
  117. package/lib/account/esolve-user-account-result.d.ts +6 -0
  118. package/lib/account/esolve-user-account.d.ts +29 -0
  119. package/lib/auth/esolve-auth-interceptor.service.d.ts +1 -1
  120. package/lib/auth/esolve-auth.service.d.ts +5 -3
  121. package/lib/cart/esolve-cart.service.d.ts +6 -55
  122. package/lib/cart/esolve-checkout-result.d.ts +6 -0
  123. package/lib/locations/esolve-locations.service.d.ts +23 -0
  124. package/lib/{cart → locations}/esolve-stock-location-record.d.ts +0 -0
  125. package/lib/{cart → locations}/esolve-stock-location.d.ts +0 -0
  126. package/lib/payment/esolve-card-data.d.ts +7 -0
  127. package/lib/payment/esolve-payment-method-options.d.ts +5 -0
  128. package/lib/{cart → payment}/esolve-payment-method-record.d.ts +0 -5
  129. package/lib/{cart → payment}/esolve-payment-method.d.ts +2 -2
  130. package/lib/payment/esolve-payment-response.d.ts +13 -0
  131. package/lib/payment/esolve-payment-result.d.ts +10 -0
  132. package/lib/payment/esolve-payment.service.d.ts +61 -0
  133. package/lib/payment/esolve-vault-item-result.d.ts +10 -0
  134. package/lib/payment/esolve-vault-item.d.ts +10 -0
  135. package/lib/payment/esolve-vault-record.d.ts +11 -0
  136. package/lib/payment/esolve-vault-response.d.ts +9 -0
  137. package/lib/{auth → session}/esolve-session.d.ts +0 -0
  138. package/lib/{auth → session}/esolve-session.service.d.ts +0 -0
  139. package/lib/{auth → session}/esolve-stored-session.d.ts +0 -0
  140. package/lib/shared/error-handler/esolve-error-handler.service.d.ts +1 -1
  141. package/lib/shared/esolve-response.d.ts +5 -5
  142. package/lib/shared/response-handler/esolve-response-handler.service.d.ts +15 -0
  143. package/lib/shared/response-handler/esolve-response-result.d.ts +6 -0
  144. package/lib/{cart → shipping}/esolve-shipping-cost-record.d.ts +0 -5
  145. package/lib/{cart → shipping}/esolve-shipping-cost.d.ts +0 -0
  146. package/lib/shipping/esolve-shipping-method-options.d.ts +4 -0
  147. package/lib/{cart → shipping}/esolve-shipping-method-record.d.ts +0 -4
  148. package/lib/{cart → shipping}/esolve-shipping-method.d.ts +0 -0
  149. package/lib/shipping/esolve-shipping.service.d.ts +37 -0
  150. package/package.json +22 -8
  151. package/public-api.d.ts +24 -9
  152. package/bundles/esolve-ng-esolve-connect.umd.js +0 -3064
  153. package/bundles/esolve-ng-esolve-connect.umd.js.map +0 -1
  154. package/esm2015/lib/auth/esolve-account.service.js +0 -103
  155. package/esm2015/lib/auth/esolve-address-record.js +0 -2
  156. package/esm2015/lib/auth/esolve-address.js +0 -19
  157. package/esm2015/lib/auth/esolve-auth.service.js +0 -163
  158. package/esm2015/lib/auth/esolve-registration-data.js +0 -2
  159. package/esm2015/lib/auth/esolve-session.js +0 -27
  160. package/esm2015/lib/auth/esolve-session.service.js +0 -79
  161. package/esm2015/lib/auth/esolve-stored-session.js +0 -2
  162. package/esm2015/lib/cart/esolve-cart.service.js +0 -326
  163. package/esm2015/lib/cart/esolve-payment-method-record.js +0 -2
  164. package/esm2015/lib/cart/esolve-payment-method.js +0 -49
  165. package/esm2015/lib/cart/esolve-shipping-cost-record.js +0 -2
  166. package/esm2015/lib/cart/esolve-shipping-cost.js +0 -18
  167. package/esm2015/lib/cart/esolve-shipping-method-record.js +0 -2
  168. package/esm2015/lib/cart/esolve-shipping-method.js +0 -33
  169. package/esm2015/lib/cart/esolve-stock-location-record.js +0 -2
  170. package/esm2015/lib/cart/esolve-stock-location.js +0 -76
  171. package/esm2015/lib/ng-esolve-connect.module.js +0 -43
  172. package/esm2015/lib/shared/error-handler/esolve-error-handler.service.js +0 -58
  173. package/esm2015/public-api.js +0 -58
  174. package/fesm2015/esolve-ng-esolve-connect.js.map +0 -1
  175. package/lib/auth/esolve-account.service.d.ts +0 -23
@@ -1,3064 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/common/http'), require('rxjs'), require('@angular/platform-browser'), require('rxjs/operators')) :
3
- typeof define === 'function' && define.amd ? define('@esolve/ng-esolve-connect', ['exports', '@angular/core', '@angular/common', '@angular/common/http', 'rxjs', '@angular/platform-browser', 'rxjs/operators'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.esolve = global.esolve || {}, global.esolve['ng-esolve-connect'] = {}), global.ng.core, global.ng.common, global.ng.common.http, global.rxjs, global.ng.platformBrowser, global.rxjs.operators));
5
- }(this, (function (exports, i0, common, i1, rxjs, i1$1, operators) { 'use strict';
6
-
7
- function _interopNamespace(e) {
8
- if (e && e.__esModule) return e;
9
- var n = Object.create(null);
10
- if (e) {
11
- Object.keys(e).forEach(function (k) {
12
- if (k !== 'default') {
13
- var d = Object.getOwnPropertyDescriptor(e, k);
14
- Object.defineProperty(n, k, d.get ? d : {
15
- enumerable: true,
16
- get: function () {
17
- return e[k];
18
- }
19
- });
20
- }
21
- });
22
- }
23
- n['default'] = e;
24
- return Object.freeze(n);
25
- }
26
-
27
- var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
28
- var i1__namespace$1 = /*#__PURE__*/_interopNamespace(i1);
29
- var i1__namespace = /*#__PURE__*/_interopNamespace(i1$1);
30
-
31
- var ESOLVE_CONNECT_CONFIG = new i0.InjectionToken('esolve.connect.config');
32
- // For future development
33
- // export const GLOBAL_CONFIG = {
34
- // images_url: '',
35
- // media_path: '/media',
36
- // stock_path: '/stock',
37
- // banner_path: '/banners'
38
- // };
39
-
40
- var EsolveSession = /** @class */ (function () {
41
- function EsolveSession(id, _key, _key_expiration_date) {
42
- if (id === void 0) { id = -1; }
43
- if (_key === void 0) { _key = ''; }
44
- this.id = id;
45
- this._key = _key;
46
- this._key_expiration_date = _key_expiration_date;
47
- }
48
- Object.defineProperty(EsolveSession.prototype, "key", {
49
- get: function () {
50
- return this._key;
51
- },
52
- enumerable: false,
53
- configurable: true
54
- });
55
- Object.defineProperty(EsolveSession.prototype, "expired", {
56
- get: function () {
57
- var current_date = new Date();
58
- return ((this._key_expiration_date === undefined) ||
59
- (current_date >= this._key_expiration_date));
60
- },
61
- enumerable: false,
62
- configurable: true
63
- });
64
- Object.defineProperty(EsolveSession.prototype, "authenticated", {
65
- get: function () {
66
- return (this.id > 0);
67
- },
68
- enumerable: false,
69
- configurable: true
70
- });
71
- Object.defineProperty(EsolveSession.prototype, "valid", {
72
- get: function () {
73
- return ((this._key !== '') &&
74
- (this._key_expiration_date !== undefined) &&
75
- (this.id >= 0));
76
- },
77
- enumerable: false,
78
- configurable: true
79
- });
80
- EsolveSession.prototype.updateUser = function (user_id) {
81
- this.id = user_id;
82
- };
83
- return EsolveSession;
84
- }());
85
-
86
- var EsolveSessionService = /** @class */ (function () {
87
- function EsolveSessionService(config) {
88
- this.config = config;
89
- this.storage_key = 'ngEslvUserSession';
90
- this.setStorageKey();
91
- this._session = new rxjs.BehaviorSubject(new EsolveSession(0, ''));
92
- this.session = this._session.asObservable();
93
- }
94
- Object.defineProperty(EsolveSessionService.prototype, "currentSession", {
95
- get: function () {
96
- return this._session.value;
97
- },
98
- enumerable: false,
99
- configurable: true
100
- });
101
- EsolveSessionService.prototype.setStorageKey = function () {
102
- if ((typeof this.config.user_session_storage_key === 'string') &&
103
- (this.config.user_session_storage_key !== '')) {
104
- this.storage_key = this.config.user_session_storage_key;
105
- }
106
- };
107
- EsolveSessionService.prototype.startTimer = function (callback, duration) {
108
- this.key_expiration_timer = setTimeout(callback, duration);
109
- };
110
- EsolveSessionService.prototype.clearTimer = function () {
111
- if (this.key_expiration_timer) {
112
- clearTimeout(this.key_expiration_timer);
113
- }
114
- };
115
- EsolveSessionService.prototype.restore = function (expirationCallback, invalidSessionCallback) {
116
- if (!this.currentSession.valid) {
117
- var stored_session_json = localStorage.getItem(this.storage_key);
118
- var stored_session = (stored_session_json ? JSON.parse(stored_session_json) : null);
119
- if (!stored_session) {
120
- invalidSessionCallback();
121
- return;
122
- }
123
- var expiration_date = new Date(stored_session._key_expiration_date);
124
- var loaded_session = new EsolveSession(stored_session.id, stored_session._key, expiration_date);
125
- if (!loaded_session.expired) {
126
- this._session.next(loaded_session);
127
- var expiration_duration = expiration_date.getTime() - new Date().getTime();
128
- this.startTimer(expirationCallback, expiration_duration);
129
- }
130
- else {
131
- expirationCallback(loaded_session);
132
- }
133
- }
134
- };
135
- EsolveSessionService.prototype.handleSession = function (user_id, key, expiry_time, expires, expirationCallback) {
136
- var expiration_date = new Date(expiry_time * 1000);
137
- var session = new EsolveSession(user_id, key, expiration_date);
138
- localStorage.setItem(this.storage_key, JSON.stringify(session));
139
- this._session.next(session);
140
- this.startTimer(expirationCallback, expires * 1000);
141
- };
142
- EsolveSessionService.prototype.handleUpdateSession = function (user_id, callback) {
143
- var current_session = this.currentSession;
144
- current_session.updateUser(user_id);
145
- localStorage.setItem(this.storage_key, JSON.stringify(current_session));
146
- this._session.next(current_session);
147
- if (typeof callback === 'function') {
148
- callback();
149
- }
150
- };
151
- return EsolveSessionService;
152
- }());
153
- EsolveSessionService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.0", ngImport: i0__namespace, type: EsolveSessionService, deps: [{ token: ESOLVE_CONNECT_CONFIG }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
154
- EsolveSessionService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.0", ngImport: i0__namespace, type: EsolveSessionService, providedIn: 'root' });
155
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.0", ngImport: i0__namespace, type: EsolveSessionService, decorators: [{
156
- type: i0.Injectable,
157
- args: [{
158
- providedIn: 'root'
159
- }]
160
- }], ctorParameters: function () {
161
- return [{ type: undefined, decorators: [{
162
- type: i0.Inject,
163
- args: [ESOLVE_CONNECT_CONFIG]
164
- }] }];
165
- } });
166
-
167
- var EsolveAuthInterceptorService = /** @class */ (function () {
168
- function EsolveAuthInterceptorService(config, session) {
169
- this.config = config;
170
- this.session = session;
171
- }
172
- EsolveAuthInterceptorService.prototype.intercept = function (req, next) {
173
- if (req.url.startsWith(this.config.api_url + "/service/")) {
174
- var service_identifier = req.url.replace(this.config.api_url + "/service/", '');
175
- var old_parms_keys = req.params.keys();
176
- var modified_url = req.url;
177
- var params_1 = new i1.HttpParams();
178
- var session = this.session.currentSession;
179
- if (session.valid) {
180
- if (service_identifier !== 'get-access-token.php') {
181
- params_1 = params_1.set('key', session.key);
182
- }
183
- }
184
- old_parms_keys.forEach(function (key) {
185
- params_1 = params_1.set(key, req.params.get(key) || '');
186
- });
187
- var modified_req = req.clone({
188
- url: modified_url,
189
- params: params_1
190
- });
191
- return next.handle(modified_req);
192
- }
193
- return next.handle(req);
194
- };
195
- return EsolveAuthInterceptorService;
196
- }());
197
- EsolveAuthInterceptorService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.0", ngImport: i0__namespace, type: EsolveAuthInterceptorService, deps: [{ token: ESOLVE_CONNECT_CONFIG }, { token: EsolveSessionService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
198
- EsolveAuthInterceptorService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.0", ngImport: i0__namespace, type: EsolveAuthInterceptorService });
199
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.0", ngImport: i0__namespace, type: EsolveAuthInterceptorService, decorators: [{
200
- type: i0.Injectable
201
- }], ctorParameters: function () {
202
- return [{ type: undefined, decorators: [{
203
- type: i0.Inject,
204
- args: [ESOLVE_CONNECT_CONFIG]
205
- }] }, { type: EsolveSessionService }];
206
- } });
207
-
208
- var NgEsolveConnectModule = /** @class */ (function () {
209
- function NgEsolveConnectModule() {
210
- }
211
- NgEsolveConnectModule.forRoot = function (config) {
212
- return {
213
- ngModule: NgEsolveConnectModule,
214
- providers: [
215
- {
216
- provide: ESOLVE_CONNECT_CONFIG,
217
- useValue: config
218
- },
219
- {
220
- provide: i1.HTTP_INTERCEPTORS,
221
- useClass: EsolveAuthInterceptorService,
222
- multi: true
223
- }
224
- ]
225
- };
226
- };
227
- return NgEsolveConnectModule;
228
- }());
229
- NgEsolveConnectModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.0", ngImport: i0__namespace, type: NgEsolveConnectModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
230
- NgEsolveConnectModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.0", ngImport: i0__namespace, type: NgEsolveConnectModule, imports: [common.CommonModule,
231
- i1.HttpClientModule] });
232
- NgEsolveConnectModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.0", ngImport: i0__namespace, type: NgEsolveConnectModule, imports: [[
233
- common.CommonModule,
234
- i1.HttpClientModule
235
- ]] });
236
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.0", ngImport: i0__namespace, type: NgEsolveConnectModule, decorators: [{
237
- type: i0.NgModule,
238
- args: [{
239
- declarations: [],
240
- imports: [
241
- common.CommonModule,
242
- i1.HttpClientModule
243
- ],
244
- exports: []
245
- }]
246
- }] });
247
-
248
- var EsolveHttpError = /** @class */ (function () {
249
- function EsolveHttpError(type, message, error_code) {
250
- this.type = type;
251
- this.message = message;
252
- this.error_code = error_code;
253
- }
254
- return EsolveHttpError;
255
- }());
256
-
257
- var EsolveErrorHandlerService = /** @class */ (function () {
258
- function EsolveErrorHandlerService() {
259
- }
260
- EsolveErrorHandlerService.prototype.parseException = function (exception) {
261
- var error = new EsolveHttpError('exception', exception.message || 'Unknown exception has occurred', exception.additional_data.exception_type || 'unknown');
262
- return error;
263
- };
264
- EsolveErrorHandlerService.prototype.parseErrors = function (response) {
265
- var error = new EsolveHttpError('error', 'Unknown error has occurred', 'unknown');
266
- if ((response.status.state === 'none') && (response.log.length > 0)) {
267
- error.error_code = 'no_response';
268
- error.message = 'Response was provided';
269
- }
270
- else if (response.status.state === 'error') {
271
- var login_error_log = response.log[0];
272
- error.error_code = login_error_log.message_code;
273
- error.message = login_error_log.message;
274
- }
275
- return error;
276
- };
277
- EsolveErrorHandlerService.prototype.handleHttpError = function (service_type, errorRes) {
278
- if (errorRes instanceof i1.HttpErrorResponse) {
279
- if (errorRes.status === 500) {
280
- var server_error = errorRes.error;
281
- if ((server_error.service_type === service_type) ||
282
- (server_error.type !== undefined) ||
283
- (server_error.message !== undefined) ||
284
- (server_error.additional_data !== undefined)) {
285
- return rxjs.throwError(this.parseException(server_error));
286
- }
287
- }
288
- }
289
- else {
290
- if (errorRes.type !== undefined) {
291
- if (errorRes.type === 'exception') {
292
- return rxjs.throwError(this.parseException(errorRes));
293
- }
294
- }
295
- else if (errorRes.transaction_type !== undefined) {
296
- return rxjs.throwError(this.parseErrors(errorRes));
297
- }
298
- }
299
- return rxjs.throwError(errorRes);
300
- };
301
- return EsolveErrorHandlerService;
302
- }());
303
- EsolveErrorHandlerService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.0", ngImport: i0__namespace, type: EsolveErrorHandlerService, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
304
- EsolveErrorHandlerService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.0", ngImport: i0__namespace, type: EsolveErrorHandlerService, providedIn: 'root' });
305
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.0", ngImport: i0__namespace, type: EsolveErrorHandlerService, decorators: [{
306
- type: i0.Injectable,
307
- args: [{
308
- providedIn: 'root'
309
- }]
310
- }], ctorParameters: function () { return []; } });
311
-
312
- /**
313
- * Search Engine Optimization information.
314
- */
315
- var EsolveSEOInfo = /** @class */ (function () {
316
- function EsolveSEOInfo(title, description, keywords) {
317
- if (title === void 0) { title = ''; }
318
- if (description === void 0) { description = ''; }
319
- if (keywords === void 0) { keywords = ''; }
320
- this.title = title;
321
- this.description = description;
322
- this.keywords = keywords;
323
- }
324
- return EsolveSEOInfo;
325
- }());
326
-
327
- /*! *****************************************************************************
328
- Copyright (c) Microsoft Corporation.
329
-
330
- Permission to use, copy, modify, and/or distribute this software for any
331
- purpose with or without fee is hereby granted.
332
-
333
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
334
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
335
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
336
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
337
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
338
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
339
- PERFORMANCE OF THIS SOFTWARE.
340
- ***************************************************************************** */
341
- /* global Reflect, Promise */
342
- var extendStatics = function (d, b) {
343
- extendStatics = Object.setPrototypeOf ||
344
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
345
- function (d, b) { for (var p in b)
346
- if (Object.prototype.hasOwnProperty.call(b, p))
347
- d[p] = b[p]; };
348
- return extendStatics(d, b);
349
- };
350
- function __extends(d, b) {
351
- if (typeof b !== "function" && b !== null)
352
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
353
- extendStatics(d, b);
354
- function __() { this.constructor = d; }
355
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
356
- }
357
- var __assign = function () {
358
- __assign = Object.assign || function __assign(t) {
359
- for (var s, i = 1, n = arguments.length; i < n; i++) {
360
- s = arguments[i];
361
- for (var p in s)
362
- if (Object.prototype.hasOwnProperty.call(s, p))
363
- t[p] = s[p];
364
- }
365
- return t;
366
- };
367
- return __assign.apply(this, arguments);
368
- };
369
- function __rest(s, e) {
370
- var t = {};
371
- for (var p in s)
372
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
373
- t[p] = s[p];
374
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
375
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
376
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
377
- t[p[i]] = s[p[i]];
378
- }
379
- return t;
380
- }
381
- function __decorate(decorators, target, key, desc) {
382
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
383
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
384
- r = Reflect.decorate(decorators, target, key, desc);
385
- else
386
- for (var i = decorators.length - 1; i >= 0; i--)
387
- if (d = decorators[i])
388
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
389
- return c > 3 && r && Object.defineProperty(target, key, r), r;
390
- }
391
- function __param(paramIndex, decorator) {
392
- return function (target, key) { decorator(target, key, paramIndex); };
393
- }
394
- function __metadata(metadataKey, metadataValue) {
395
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
396
- return Reflect.metadata(metadataKey, metadataValue);
397
- }
398
- function __awaiter(thisArg, _arguments, P, generator) {
399
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
400
- return new (P || (P = Promise))(function (resolve, reject) {
401
- function fulfilled(value) { try {
402
- step(generator.next(value));
403
- }
404
- catch (e) {
405
- reject(e);
406
- } }
407
- function rejected(value) { try {
408
- step(generator["throw"](value));
409
- }
410
- catch (e) {
411
- reject(e);
412
- } }
413
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
414
- step((generator = generator.apply(thisArg, _arguments || [])).next());
415
- });
416
- }
417
- function __generator(thisArg, body) {
418
- var _ = { label: 0, sent: function () { if (t[0] & 1)
419
- throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
420
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
421
- function verb(n) { return function (v) { return step([n, v]); }; }
422
- function step(op) {
423
- if (f)
424
- throw new TypeError("Generator is already executing.");
425
- while (_)
426
- try {
427
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
428
- return t;
429
- if (y = 0, t)
430
- op = [op[0] & 2, t.value];
431
- switch (op[0]) {
432
- case 0:
433
- case 1:
434
- t = op;
435
- break;
436
- case 4:
437
- _.label++;
438
- return { value: op[1], done: false };
439
- case 5:
440
- _.label++;
441
- y = op[1];
442
- op = [0];
443
- continue;
444
- case 7:
445
- op = _.ops.pop();
446
- _.trys.pop();
447
- continue;
448
- default:
449
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
450
- _ = 0;
451
- continue;
452
- }
453
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
454
- _.label = op[1];
455
- break;
456
- }
457
- if (op[0] === 6 && _.label < t[1]) {
458
- _.label = t[1];
459
- t = op;
460
- break;
461
- }
462
- if (t && _.label < t[2]) {
463
- _.label = t[2];
464
- _.ops.push(op);
465
- break;
466
- }
467
- if (t[2])
468
- _.ops.pop();
469
- _.trys.pop();
470
- continue;
471
- }
472
- op = body.call(thisArg, _);
473
- }
474
- catch (e) {
475
- op = [6, e];
476
- y = 0;
477
- }
478
- finally {
479
- f = t = 0;
480
- }
481
- if (op[0] & 5)
482
- throw op[1];
483
- return { value: op[0] ? op[1] : void 0, done: true };
484
- }
485
- }
486
- var __createBinding = Object.create ? (function (o, m, k, k2) {
487
- if (k2 === undefined)
488
- k2 = k;
489
- Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
490
- }) : (function (o, m, k, k2) {
491
- if (k2 === undefined)
492
- k2 = k;
493
- o[k2] = m[k];
494
- });
495
- function __exportStar(m, o) {
496
- for (var p in m)
497
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
498
- __createBinding(o, m, p);
499
- }
500
- function __values(o) {
501
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
502
- if (m)
503
- return m.call(o);
504
- if (o && typeof o.length === "number")
505
- return {
506
- next: function () {
507
- if (o && i >= o.length)
508
- o = void 0;
509
- return { value: o && o[i++], done: !o };
510
- }
511
- };
512
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
513
- }
514
- function __read(o, n) {
515
- var m = typeof Symbol === "function" && o[Symbol.iterator];
516
- if (!m)
517
- return o;
518
- var i = m.call(o), r, ar = [], e;
519
- try {
520
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
521
- ar.push(r.value);
522
- }
523
- catch (error) {
524
- e = { error: error };
525
- }
526
- finally {
527
- try {
528
- if (r && !r.done && (m = i["return"]))
529
- m.call(i);
530
- }
531
- finally {
532
- if (e)
533
- throw e.error;
534
- }
535
- }
536
- return ar;
537
- }
538
- /** @deprecated */
539
- function __spread() {
540
- for (var ar = [], i = 0; i < arguments.length; i++)
541
- ar = ar.concat(__read(arguments[i]));
542
- return ar;
543
- }
544
- /** @deprecated */
545
- function __spreadArrays() {
546
- for (var s = 0, i = 0, il = arguments.length; i < il; i++)
547
- s += arguments[i].length;
548
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
549
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
550
- r[k] = a[j];
551
- return r;
552
- }
553
- function __spreadArray(to, from, pack) {
554
- if (pack || arguments.length === 2)
555
- for (var i = 0, l = from.length, ar; i < l; i++) {
556
- if (ar || !(i in from)) {
557
- if (!ar)
558
- ar = Array.prototype.slice.call(from, 0, i);
559
- ar[i] = from[i];
560
- }
561
- }
562
- return to.concat(ar || from);
563
- }
564
- function __await(v) {
565
- return this instanceof __await ? (this.v = v, this) : new __await(v);
566
- }
567
- function __asyncGenerator(thisArg, _arguments, generator) {
568
- if (!Symbol.asyncIterator)
569
- throw new TypeError("Symbol.asyncIterator is not defined.");
570
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
571
- return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
572
- function verb(n) { if (g[n])
573
- i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
574
- function resume(n, v) { try {
575
- step(g[n](v));
576
- }
577
- catch (e) {
578
- settle(q[0][3], e);
579
- } }
580
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
581
- function fulfill(value) { resume("next", value); }
582
- function reject(value) { resume("throw", value); }
583
- function settle(f, v) { if (f(v), q.shift(), q.length)
584
- resume(q[0][0], q[0][1]); }
585
- }
586
- function __asyncDelegator(o) {
587
- var i, p;
588
- return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
589
- function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
590
- }
591
- function __asyncValues(o) {
592
- if (!Symbol.asyncIterator)
593
- throw new TypeError("Symbol.asyncIterator is not defined.");
594
- var m = o[Symbol.asyncIterator], i;
595
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
596
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
597
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
598
- }
599
- function __makeTemplateObject(cooked, raw) {
600
- if (Object.defineProperty) {
601
- Object.defineProperty(cooked, "raw", { value: raw });
602
- }
603
- else {
604
- cooked.raw = raw;
605
- }
606
- return cooked;
607
- }
608
- ;
609
- var __setModuleDefault = Object.create ? (function (o, v) {
610
- Object.defineProperty(o, "default", { enumerable: true, value: v });
611
- }) : function (o, v) {
612
- o["default"] = v;
613
- };
614
- function __importStar(mod) {
615
- if (mod && mod.__esModule)
616
- return mod;
617
- var result = {};
618
- if (mod != null)
619
- for (var k in mod)
620
- if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
621
- __createBinding(result, mod, k);
622
- __setModuleDefault(result, mod);
623
- return result;
624
- }
625
- function __importDefault(mod) {
626
- return (mod && mod.__esModule) ? mod : { default: mod };
627
- }
628
- function __classPrivateFieldGet(receiver, state, kind, f) {
629
- if (kind === "a" && !f)
630
- throw new TypeError("Private accessor was defined without a getter");
631
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
632
- throw new TypeError("Cannot read private member from an object whose class did not declare it");
633
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
634
- }
635
- function __classPrivateFieldSet(receiver, state, value, kind, f) {
636
- if (kind === "m")
637
- throw new TypeError("Private method is not writable");
638
- if (kind === "a" && !f)
639
- throw new TypeError("Private accessor was defined without a setter");
640
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
641
- throw new TypeError("Cannot write private member to an object whose class did not declare it");
642
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
643
- }
644
-
645
- var EsolveSeoService = /** @class */ (function () {
646
- function EsolveSeoService(config, title, meta) {
647
- this.config = config;
648
- this.title = title;
649
- this.meta = meta;
650
- this.title_prefix = '';
651
- this.title_suffix = '';
652
- this.title_separator = '|';
653
- this.default_seo_title = '';
654
- this.default_seo_description = '';
655
- this.default_seo_keywords = '';
656
- this.init();
657
- }
658
- EsolveSeoService.prototype.init = function () {
659
- if (typeof this.config.title_prefix !== 'undefined') {
660
- this.title_prefix = this.config.title_prefix;
661
- }
662
- if (typeof this.config.title_suffix !== 'undefined') {
663
- this.title_suffix = this.config.title_suffix;
664
- }
665
- if (typeof this.config.title_separator !== 'undefined') {
666
- this.title_separator = this.config.title_separator;
667
- }
668
- if (typeof this.config.default_seo_title !== 'undefined') {
669
- this.default_seo_title = this.config.default_seo_title;
670
- }
671
- if (typeof this.config.default_seo_description !== 'undefined') {
672
- this.default_seo_description = this.config.default_seo_description;
673
- }
674
- if (typeof this.config.default_seo_keywords !== 'undefined') {
675
- this.default_seo_keywords = this.config.default_seo_keywords;
676
- }
677
- };
678
- EsolveSeoService.prototype.setPageTitleTags = function (title) {
679
- this.title.setTitle(title);
680
- this.meta.updateTag({ property: 'og:title', content: title });
681
- };
682
- EsolveSeoService.prototype.setPageDescriptionTags = function (description) {
683
- this.meta.updateTag({ name: 'description', content: description });
684
- this.meta.updateTag({ property: 'og:description', content: description });
685
- };
686
- EsolveSeoService.prototype.setPageKeywordsTags = function (keywords) {
687
- this.meta.updateTag({ name: 'keywords', content: keywords });
688
- };
689
- EsolveSeoService.prototype.validateAndSanitizeSeoInfo = function (seoInfo) {
690
- var e_1, _a;
691
- var pageSeo = new EsolveSEOInfo(this.default_seo_title, this.default_seo_description, this.default_seo_keywords);
692
- if (seoInfo.description.trim() !== '') {
693
- pageSeo.description = seoInfo.description;
694
- }
695
- if (seoInfo.title.trim() !== '') {
696
- var titlePartsArray = [];
697
- if (this.title_prefix !== '') {
698
- titlePartsArray.push(this.title_prefix);
699
- if (this.title_separator !== '') {
700
- titlePartsArray.push(this.title_separator);
701
- }
702
- }
703
- titlePartsArray.push(seoInfo.title);
704
- if (this.title_suffix !== '') {
705
- if (this.title_separator !== '') {
706
- titlePartsArray.push(this.title_separator);
707
- }
708
- titlePartsArray.push(this.title_suffix);
709
- }
710
- pageSeo.title = titlePartsArray.join(' ');
711
- if (seoInfo.keywords.trim() === '') {
712
- var clean_title = seoInfo.title.replace(/[^a-zA-Z0-9\. ]+/gi, '').trim();
713
- var keywords = clean_title.split(' ');
714
- var clean_keywords = [];
715
- try {
716
- for (var keywords_1 = __values(keywords), keywords_1_1 = keywords_1.next(); !keywords_1_1.done; keywords_1_1 = keywords_1.next()) {
717
- var keyword = keywords_1_1.value;
718
- keyword = keyword.trim();
719
- if (keyword.length > 2) {
720
- keyword = keyword.toLocaleLowerCase();
721
- if (!clean_keywords.includes(keyword)) {
722
- clean_keywords.push(keyword);
723
- }
724
- }
725
- }
726
- }
727
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
728
- finally {
729
- try {
730
- if (keywords_1_1 && !keywords_1_1.done && (_a = keywords_1.return)) _a.call(keywords_1);
731
- }
732
- finally { if (e_1) throw e_1.error; }
733
- }
734
- seoInfo.keywords = clean_keywords.join(',');
735
- }
736
- }
737
- if (seoInfo.keywords.trim() !== '') {
738
- pageSeo.keywords = seoInfo.keywords;
739
- }
740
- return pageSeo;
741
- };
742
- /**
743
- * Sets SEO tags for page
744
- * @param seoInfo SEO object
745
- */
746
- EsolveSeoService.prototype.setTags = function (seoInfo) {
747
- seoInfo = this.validateAndSanitizeSeoInfo(seoInfo);
748
- this.setPageTitleTags(seoInfo.title);
749
- this.setPageDescriptionTags(seoInfo.description);
750
- this.setPageKeywordsTags(seoInfo.keywords);
751
- };
752
- return EsolveSeoService;
753
- }());
754
- EsolveSeoService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.0", ngImport: i0__namespace, type: EsolveSeoService, deps: [{ token: ESOLVE_CONNECT_CONFIG }, { token: i1__namespace.Title }, { token: i1__namespace.Meta }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
755
- EsolveSeoService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.0", ngImport: i0__namespace, type: EsolveSeoService, providedIn: 'root' });
756
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.0", ngImport: i0__namespace, type: EsolveSeoService, decorators: [{
757
- type: i0.Injectable,
758
- args: [{
759
- providedIn: 'root'
760
- }]
761
- }], ctorParameters: function () {
762
- return [{ type: undefined, decorators: [{
763
- type: i0.Inject,
764
- args: [ESOLVE_CONNECT_CONFIG]
765
- }] }, { type: i1__namespace.Title }, { type: i1__namespace.Meta }];
766
- } });
767
-
768
- var EsolveAddress = /** @class */ (function () {
769
- function EsolveAddress(id, recipient, address_type, pobox, place_name, street_number, street, suburb, city, province, country, postal_code, latitude, longitude) {
770
- this.id = id;
771
- this.recipient = recipient;
772
- this.address_type = address_type;
773
- this.pobox = pobox;
774
- this.place_name = place_name;
775
- this.street_number = street_number;
776
- this.street = street;
777
- this.suburb = suburb;
778
- this.city = city;
779
- this.province = province;
780
- this.country = country;
781
- this.postal_code = postal_code;
782
- this.latitude = latitude;
783
- this.longitude = longitude;
784
- }
785
- return EsolveAddress;
786
- }());
787
-
788
- var EsolveAuthService = /** @class */ (function () {
789
- function EsolveAuthService(config, http, session, errorHandler) {
790
- this.config = config;
791
- this.http = http;
792
- this.session = session;
793
- this.errorHandler = errorHandler;
794
- }
795
- EsolveAuthService.prototype.checkAccessToken = function (session) {
796
- var _a;
797
- session = session || this.session.currentSession;
798
- var token = (_a = session === null || session === void 0 ? void 0 : session.key) !== null && _a !== void 0 ? _a : '';
799
- var params = new i1.HttpParams({
800
- fromObject: {
801
- key: token,
802
- ws_id: this.config.wsid
803
- }
804
- });
805
- return this.http.get(this.config.api_url + "/service/get-access-token.php", {
806
- params: params,
807
- headers: new i1.HttpHeaders({
808
- 'Accept-Language': '*'
809
- })
810
- }).pipe(operators.map(function (responseData) {
811
- if ((responseData.type === 'error') ||
812
- (responseData.type === 'exception') ||
813
- (!responseData.additional_data.key_okay)) {
814
- throw responseData;
815
- }
816
- responseData.additional_data.key = token;
817
- return responseData;
818
- })).toPromise();
819
- };
820
- EsolveAuthService.prototype.getAccessToken = function (email, password, anonymous) {
821
- var _this = this;
822
- if (anonymous === void 0) { anonymous = false; }
823
- var params = new i1.HttpParams();
824
- if (anonymous) {
825
- params = params.set('anonymous', '1');
826
- }
827
- if (email !== '') {
828
- params = params.set('email', email);
829
- }
830
- if (password !== '') {
831
- params = params.set('password', password);
832
- }
833
- params = params.set('ws_id', this.config.wsid);
834
- return this.http.get(this.config.api_url + "/service/get-access-token.php", {
835
- params: params,
836
- headers: new i1.HttpHeaders({
837
- 'Accept-Language': '*'
838
- })
839
- }).pipe(operators.tap(function (responseData) {
840
- if ((responseData.type === 'error') ||
841
- (responseData.type === 'exception')) {
842
- throw responseData;
843
- }
844
- }), operators.catchError(this.handleError), operators.tap(function (responseData) {
845
- _this.handleAuthentication(responseData);
846
- }));
847
- };
848
- EsolveAuthService.prototype.autoLogin = function () {
849
- var _this = this;
850
- this.session.restore(this.handleExpiration(), function () {
851
- _this.getAccessToken('', '', true).toPromise().then(function (_) { }, function (error) {
852
- console.log(error);
853
- });
854
- });
855
- };
856
- EsolveAuthService.prototype.login = function (email, password) {
857
- var _this = this;
858
- var body = {
859
- login: {
860
- email: email,
861
- password: password
862
- }
863
- };
864
- return this.http.post(this.config.api_url + "/service/set-login.php", body, {
865
- headers: {
866
- 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;'
867
- },
868
- params: {
869
- ws_id: this.config.wsid
870
- },
871
- responseType: 'json',
872
- observe: 'body'
873
- }).pipe(operators.map(function (response) {
874
- var e_1, _b;
875
- if ((response.responses === undefined) ||
876
- (response.responses.length <= 0)) {
877
- throw response;
878
- }
879
- var login_response = response.responses[0];
880
- if ((login_response.status.state !== 'success') &&
881
- (login_response.status.state !== 'warning')) {
882
- throw login_response;
883
- }
884
- try {
885
- for (var _c = __values(login_response.log), _d = _c.next(); !_d.done; _d = _c.next()) {
886
- var response_log = _d.value;
887
- if ((response_log.type === 'success') && (response_log.message_code === 'login_success')) {
888
- _this.session.handleUpdateSession(login_response.esolve_id);
889
- return login_response.esolve_id;
890
- }
891
- }
892
- }
893
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
894
- finally {
895
- try {
896
- if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
897
- }
898
- finally { if (e_1) throw e_1.error; }
899
- }
900
- throw login_response;
901
- }), operators.catchError(function (errorRes) {
902
- return _this.errorHandler.handleHttpError('set-login', errorRes);
903
- }));
904
- };
905
- EsolveAuthService.prototype.logout = function () {
906
- this.session.clearTimer();
907
- this.getAccessToken('', '', true).toPromise().then(function (_) { }, function (error) {
908
- console.log(error);
909
- });
910
- };
911
- // Handlers
912
- EsolveAuthService.prototype.handleExpiration = function () {
913
- var _this = this;
914
- return function (session) {
915
- _this.checkAccessToken(session).then(function (response) {
916
- _this.handleAuthentication(response);
917
- }, function () {
918
- _this.logout();
919
- });
920
- };
921
- };
922
- EsolveAuthService.prototype.handleAuthentication = function (responseData) {
923
- if (responseData.additional_data.key) {
924
- this.session.handleSession(responseData.additional_data.user_id, responseData.additional_data.key, +responseData.additional_data.expiry_time, +responseData.additional_data.expires, this.handleExpiration());
925
- }
926
- };
927
- EsolveAuthService.prototype.handleError = function (errorRes) {
928
- var error = {
929
- message: 'An unknown error occurred',
930
- data: {}
931
- };
932
- if ((!errorRes.type) ||
933
- (!errorRes.service_type) ||
934
- (!errorRes.message)) {
935
- return rxjs.throwError(error);
936
- }
937
- if (errorRes.message.trim() !== '') {
938
- error.message = errorRes.message;
939
- }
940
- if (errorRes.additional_data) {
941
- error.data = errorRes.additional_data;
942
- }
943
- return rxjs.throwError(error);
944
- };
945
- return EsolveAuthService;
946
- }());
947
- EsolveAuthService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.0", ngImport: i0__namespace, type: EsolveAuthService, deps: [{ token: ESOLVE_CONNECT_CONFIG }, { token: i1__namespace$1.HttpClient }, { token: EsolveSessionService }, { token: EsolveErrorHandlerService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
948
- EsolveAuthService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.0", ngImport: i0__namespace, type: EsolveAuthService, providedIn: 'root' });
949
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.0", ngImport: i0__namespace, type: EsolveAuthService, decorators: [{
950
- type: i0.Injectable,
951
- args: [{
952
- providedIn: 'root'
953
- }]
954
- }], ctorParameters: function () {
955
- return [{ type: undefined, decorators: [{
956
- type: i0.Inject,
957
- args: [ESOLVE_CONNECT_CONFIG]
958
- }] }, { type: i1__namespace$1.HttpClient }, { type: EsolveSessionService }, { type: EsolveErrorHandlerService }];
959
- } });
960
-
961
- var EsolveAccountService = /** @class */ (function () {
962
- function EsolveAccountService(config, http, sessionService, errorHandler) {
963
- var _this = this;
964
- this.config = config;
965
- this.http = http;
966
- this.sessionService = sessionService;
967
- this.errorHandler = errorHandler;
968
- this._user_id = 0;
969
- this.sessionService.session.subscribe(function (session) {
970
- if (session.key !== '') {
971
- _this.user_id = session.id;
972
- }
973
- });
974
- }
975
- Object.defineProperty(EsolveAccountService.prototype, "user_id", {
976
- get: function () {
977
- return this._user_id;
978
- },
979
- set: function (value) {
980
- value = ((value > 0) ? value : 0);
981
- if (this._user_id !== value) {
982
- this._user_id = value;
983
- }
984
- },
985
- enumerable: false,
986
- configurable: true
987
- });
988
- EsolveAccountService.prototype.processUserAddress = function (records) {
989
- var e_1, _a;
990
- var user_addresses = [];
991
- if (records && (this._user_id > 0)) {
992
- try {
993
- for (var records_1 = __values(records), records_1_1 = records_1.next(); !records_1_1.done; records_1_1 = records_1.next()) {
994
- var record = records_1_1.value;
995
- if (+record.userid === this._user_id) {
996
- user_addresses.push(new EsolveAddress(+record.id, record.recipient, record.address_type, record.pobox, record.place_name, record.street_number, record.street, record.suburb, record.city, record.province, record.country, record.postal_code, +record.latitude, +record.longitude));
997
- }
998
- }
999
- }
1000
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1001
- finally {
1002
- try {
1003
- if (records_1_1 && !records_1_1.done && (_a = records_1.return)) _a.call(records_1);
1004
- }
1005
- finally { if (e_1) throw e_1.error; }
1006
- }
1007
- }
1008
- return user_addresses;
1009
- };
1010
- EsolveAccountService.prototype.getAddress = function () {
1011
- var _this = this;
1012
- var params = new i1.HttpParams();
1013
- params = params.set('ws_id', this.config.wsid);
1014
- params = params.set('user_id', this.user_id.toString());
1015
- return rxjs.iif(function () { return (_this.user_id > 0); }, this.http.get(this.config.api_url + "/service/get-addresses.php", { params: params }).pipe(operators.map(function (response) {
1016
- if (response.records === undefined) {
1017
- throw response;
1018
- }
1019
- return _this.processUserAddress(response.records);
1020
- }), operators.catchError(function (err) {
1021
- return rxjs.throwError(err);
1022
- })), rxjs.throwError('Log in is required'));
1023
- };
1024
- EsolveAccountService.prototype.register = function (user_registration) {
1025
- var _this = this;
1026
- var body = {
1027
- user: user_registration
1028
- };
1029
- return this.http.post(this.config.api_url + "/service/set-registration.php", body, {
1030
- headers: {
1031
- 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;'
1032
- },
1033
- params: {
1034
- ws_id: this.config.wsid
1035
- },
1036
- responseType: 'json',
1037
- observe: 'body'
1038
- }).pipe(operators.map(function (response) {
1039
- var e_2, _a;
1040
- if ((response.responses === undefined) ||
1041
- (response.responses.length <= 0)) {
1042
- throw response;
1043
- }
1044
- var registration_response = response.responses[0];
1045
- if ((registration_response.status.state !== 'success') &&
1046
- (registration_response.status.state !== 'warning')) {
1047
- throw registration_response;
1048
- }
1049
- try {
1050
- for (var _b = __values(registration_response.log), _c = _b.next(); !_c.done; _c = _b.next()) {
1051
- var response_log = _c.value;
1052
- if ((response_log.type === 'success') && (response_log.message_code === 'registration_success')) {
1053
- _this.sessionService.handleUpdateSession(registration_response.esolve_id);
1054
- return registration_response.esolve_id;
1055
- }
1056
- }
1057
- }
1058
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
1059
- finally {
1060
- try {
1061
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1062
- }
1063
- finally { if (e_2) throw e_2.error; }
1064
- }
1065
- throw registration_response;
1066
- }), operators.catchError(function (errorRes) {
1067
- return _this.errorHandler.handleHttpError('set-registration', errorRes);
1068
- }));
1069
- };
1070
- return EsolveAccountService;
1071
- }());
1072
- EsolveAccountService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.0", ngImport: i0__namespace, type: EsolveAccountService, deps: [{ token: ESOLVE_CONNECT_CONFIG }, { token: i1__namespace$1.HttpClient }, { token: EsolveSessionService }, { token: EsolveErrorHandlerService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1073
- EsolveAccountService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.0", ngImport: i0__namespace, type: EsolveAccountService, providedIn: 'root' });
1074
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.0", ngImport: i0__namespace, type: EsolveAccountService, decorators: [{
1075
- type: i0.Injectable,
1076
- args: [{
1077
- providedIn: 'root'
1078
- }]
1079
- }], ctorParameters: function () {
1080
- return [{ type: undefined, decorators: [{
1081
- type: i0.Inject,
1082
- args: [ESOLVE_CONNECT_CONFIG]
1083
- }] }, { type: i1__namespace$1.HttpClient }, { type: EsolveSessionService }, { type: EsolveErrorHandlerService }];
1084
- } });
1085
-
1086
- var EsolveMediaArticle = /** @class */ (function () {
1087
- function EsolveMediaArticle(identifier, title, article, image_url, tags, topics, seo_title, seo_keywords, seo_description) {
1088
- if (image_url === void 0) { image_url = ''; }
1089
- if (tags === void 0) { tags = []; }
1090
- if (topics === void 0) { topics = []; }
1091
- if (seo_title === void 0) { seo_title = ''; }
1092
- if (seo_keywords === void 0) { seo_keywords = ''; }
1093
- if (seo_description === void 0) { seo_description = ''; }
1094
- this.identifier = identifier;
1095
- this.title = title;
1096
- this.article = article;
1097
- this.image_url = image_url;
1098
- this.tags = tags;
1099
- this.topics = topics;
1100
- if (seo_title.trim() === '') {
1101
- seo_title = this.title;
1102
- }
1103
- this.seo_details = new EsolveSEOInfo(seo_title, seo_description, seo_keywords);
1104
- }
1105
- return EsolveMediaArticle;
1106
- }());
1107
-
1108
- var EsolveTag = /** @class */ (function () {
1109
- function EsolveTag(id, tag_phrase, tag_weight, description) {
1110
- this.id = id;
1111
- this.tag_phrase = tag_phrase;
1112
- this.tag_weight = tag_weight;
1113
- this.description = description;
1114
- }
1115
- return EsolveTag;
1116
- }());
1117
-
1118
- var EsolveTopic = /** @class */ (function () {
1119
- function EsolveTopic(id, name, short_description, sort_priority) {
1120
- this.id = id;
1121
- this.name = name;
1122
- this.short_description = short_description;
1123
- this.sort_priority = sort_priority;
1124
- }
1125
- return EsolveTopic;
1126
- }());
1127
-
1128
- var EsolveMediaService = /** @class */ (function () {
1129
- function EsolveMediaService(config, http) {
1130
- this.config = config;
1131
- this.http = http;
1132
- }
1133
- EsolveMediaService.prototype.processMediaRecord = function (record) {
1134
- var e_1, _a, e_2, _b;
1135
- var tags = [];
1136
- var topics = [];
1137
- if ((record.tags) && (record.tags.length > 0)) {
1138
- try {
1139
- for (var _c = __values(record.tags), _d = _c.next(); !_d.done; _d = _c.next()) {
1140
- var tag = _d.value;
1141
- tags.push(new EsolveTag(+tag.id, tag.tag_phrase, +tag.tag_weight, tag.description));
1142
- }
1143
- }
1144
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1145
- finally {
1146
- try {
1147
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
1148
- }
1149
- finally { if (e_1) throw e_1.error; }
1150
- }
1151
- }
1152
- if ((record.topics) && (record.topics.length > 0)) {
1153
- try {
1154
- for (var _e = __values(record.topics), _f = _e.next(); !_f.done; _f = _e.next()) {
1155
- var topic = _f.value;
1156
- topics.push(new EsolveTopic(+topic.id, topic.name, topic.short_description, +topic.sort_priority));
1157
- }
1158
- }
1159
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
1160
- finally {
1161
- try {
1162
- if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
1163
- }
1164
- finally { if (e_2) throw e_2.error; }
1165
- }
1166
- }
1167
- return new EsolveMediaArticle(record.identifier, record.title, record.article, record.image_url, tags, topics, record.seo_page_title, record.seo_keywords, record.seo_description);
1168
- };
1169
- /**
1170
- * Retrieves media records from eSolve instance.
1171
- * @param params Header params
1172
- */
1173
- EsolveMediaService.prototype.getMediaRecords = function (params) {
1174
- params = params.set('ws_id', this.config.wsid);
1175
- return this.http.get(this.config.api_url + "/service/get-media.php", { params: params });
1176
- };
1177
- /**
1178
- * Retrieves the media record from the eSolve instance using the identifier.
1179
- * @param identifier String representing the eSolve media indentifier
1180
- */
1181
- EsolveMediaService.prototype.getMediaArticle = function (identifier) {
1182
- var _this = this;
1183
- var params = new i1.HttpParams({
1184
- fromObject: {
1185
- identifier: identifier
1186
- }
1187
- });
1188
- // TODO: Error Handling
1189
- return this.getMediaRecords(params).pipe(operators.map(function (response) {
1190
- if ((response.records === undefined) || (response.records.length <= 0)) {
1191
- throw response;
1192
- }
1193
- var mediaRecord = response.records[0];
1194
- if (!mediaRecord.active) {
1195
- throw response;
1196
- }
1197
- return _this.processMediaRecord(mediaRecord);
1198
- }));
1199
- };
1200
- /**
1201
- * Retrieves a group of media records from the eSolve instance linked to a group.
1202
- * @param media_group String representing the eSolve media group
1203
- */
1204
- EsolveMediaService.prototype.getGroupedMediaArticles = function (media_group) {
1205
- var _this = this;
1206
- var params = new i1.HttpParams({
1207
- fromObject: {
1208
- media_group_sef: media_group
1209
- }
1210
- });
1211
- return this.getMediaRecords(params).pipe(operators.map(function (response) {
1212
- var e_3, _a;
1213
- var mediaArticles = [];
1214
- if ((response.records !== undefined) && (response.records.length > 0)) {
1215
- try {
1216
- for (var _b = __values(response.records), _c = _b.next(); !_c.done; _c = _b.next()) {
1217
- var mediaRecord = _c.value;
1218
- if (mediaRecord.active) {
1219
- mediaArticles.push(_this.processMediaRecord(mediaRecord));
1220
- }
1221
- }
1222
- }
1223
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
1224
- finally {
1225
- try {
1226
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1227
- }
1228
- finally { if (e_3) throw e_3.error; }
1229
- }
1230
- }
1231
- return mediaArticles;
1232
- }));
1233
- };
1234
- return EsolveMediaService;
1235
- }());
1236
- EsolveMediaService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.0", ngImport: i0__namespace, type: EsolveMediaService, deps: [{ token: ESOLVE_CONNECT_CONFIG }, { token: i1__namespace$1.HttpClient }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1237
- EsolveMediaService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.0", ngImport: i0__namespace, type: EsolveMediaService, providedIn: 'root' });
1238
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.0", ngImport: i0__namespace, type: EsolveMediaService, decorators: [{
1239
- type: i0.Injectable,
1240
- args: [{
1241
- providedIn: 'root'
1242
- }]
1243
- }], ctorParameters: function () {
1244
- return [{ type: undefined, decorators: [{
1245
- type: i0.Inject,
1246
- args: [ESOLVE_CONNECT_CONFIG]
1247
- }] }, { type: i1__namespace$1.HttpClient }];
1248
- } });
1249
-
1250
- var EsolveNewsArticle = /** @class */ (function () {
1251
- function EsolveNewsArticle(id, title, sef_title, article, short_description, txdate, active, image, featured, author, seo_title, seo_keywords) {
1252
- if (seo_title === void 0) { seo_title = ''; }
1253
- if (seo_keywords === void 0) { seo_keywords = ''; }
1254
- this.id = id;
1255
- this.title = title;
1256
- this.sef_title = sef_title;
1257
- this.article = article;
1258
- this.short_description = short_description;
1259
- this.txdate = txdate;
1260
- this.active = active;
1261
- this.image = image;
1262
- this.featured = featured;
1263
- this.author = author;
1264
- if (seo_title.trim() === '') {
1265
- seo_title = this.title;
1266
- }
1267
- this.seo_details = new EsolveSEOInfo(seo_title, short_description, seo_keywords);
1268
- }
1269
- return EsolveNewsArticle;
1270
- }());
1271
-
1272
- var EsolveNewsGroup = /** @class */ (function () {
1273
- function EsolveNewsGroup(id, name, description, sef_name) {
1274
- this.id = id;
1275
- this.name = name;
1276
- this.description = description;
1277
- this.sef_name = sef_name;
1278
- }
1279
- return EsolveNewsGroup;
1280
- }());
1281
-
1282
- var EsolveNewsArticleList = /** @class */ (function () {
1283
- function EsolveNewsArticleList(newsArticles, total, page) {
1284
- this.newsArticles = newsArticles;
1285
- this.total = total;
1286
- this.page = page;
1287
- }
1288
- return EsolveNewsArticleList;
1289
- }());
1290
-
1291
- var EsolveNewsArticleAuthor = /** @class */ (function () {
1292
- function EsolveNewsArticleAuthor(userid, email, firstname, surname) {
1293
- this.userid = userid;
1294
- this.email = email;
1295
- this.firstname = firstname;
1296
- this.surname = surname;
1297
- }
1298
- return EsolveNewsArticleAuthor;
1299
- }());
1300
-
1301
- var EsolveNewsService = /** @class */ (function () {
1302
- function EsolveNewsService(config, http) {
1303
- this.config = config;
1304
- this.http = http;
1305
- }
1306
- EsolveNewsService.prototype.getNewsRecords = function (params) {
1307
- params = params.set('ws_id', this.config.wsid);
1308
- return this.http.get(this.config.api_url + "/service/get-news.php", { params: params });
1309
- };
1310
- EsolveNewsService.prototype.getNewsArticle = function (identifier) {
1311
- var _this = this;
1312
- var params = new i1.HttpParams({
1313
- fromObject: {
1314
- sef_title: identifier
1315
- }
1316
- });
1317
- return this.getNewsRecords(params).pipe(operators.map(function (response) {
1318
- if ((response.records === undefined) || (response.records.length <= 0)) {
1319
- throw response;
1320
- }
1321
- var newsRecord = response.records[0];
1322
- if (!newsRecord.active) {
1323
- throw response;
1324
- }
1325
- return _this.processNewsArticle(newsRecord);
1326
- }));
1327
- };
1328
- EsolveNewsService.prototype.getNewsArticles = function (options) {
1329
- var _this = this;
1330
- var params = new i1.HttpParams();
1331
- if (options.news_group_id) {
1332
- params = params.set('news_group_id', options.news_group_id.toString());
1333
- }
1334
- else if (options.news_group_sef) {
1335
- params = params.set('news_group_sef', options.news_group_sef.toString());
1336
- }
1337
- if (options.page) {
1338
- params = params.set('page', options.page.toString());
1339
- }
1340
- if (options.rows) {
1341
- params = params.set('rows', options.rows.toString());
1342
- }
1343
- if (options.feature_only) {
1344
- params = params.set('feature_only', options.feature_only.toString());
1345
- }
1346
- if (options.manufacturers_id) {
1347
- params = params.set('manufacturers_id', options.manufacturers_id.toString());
1348
- }
1349
- if (options.ranges_id) {
1350
- params = params.set('ranges_id', options.ranges_id.toString());
1351
- }
1352
- if (options.from_date) {
1353
- params = params.set('from_date', options.from_date.toString());
1354
- }
1355
- if (options.to_date) {
1356
- params = params.set('to_date', options.to_date.toString());
1357
- }
1358
- return this.getNewsRecords(params).pipe(operators.map(function (response) {
1359
- if (response.records === undefined) {
1360
- throw response;
1361
- }
1362
- var newsArticles = [];
1363
- response.records.forEach(function (newsArticleRecord) {
1364
- newsArticles.push(_this.processNewsArticle(newsArticleRecord));
1365
- });
1366
- return new EsolveNewsArticleList(newsArticles, response.additional_data.total_records, options.page || 0);
1367
- }));
1368
- };
1369
- EsolveNewsService.prototype.getNewsGroups = function () {
1370
- var params = new i1.HttpParams();
1371
- params = params.set('ws_id', this.config.wsid);
1372
- return this.http.get(this.config.api_url + "/service/get-news-groups.php", { params: params }).pipe(operators.map(function (response) {
1373
- if (response.records === undefined) {
1374
- throw response;
1375
- }
1376
- var newsGroups = [];
1377
- response.records.forEach(function (newsGroupRecord) {
1378
- newsGroups.push(new EsolveNewsGroup(newsGroupRecord.id, newsGroupRecord.name, newsGroupRecord.description, newsGroupRecord.sef_name));
1379
- });
1380
- return newsGroups;
1381
- }));
1382
- };
1383
- EsolveNewsService.prototype.processNewsArticle = function (newsRecord) {
1384
- var author = new EsolveNewsArticleAuthor(newsRecord.user.userid, newsRecord.user.email, newsRecord.user.firstname, newsRecord.user.surname);
1385
- return new EsolveNewsArticle(newsRecord.id, newsRecord.title, newsRecord.sef_title, newsRecord.article, newsRecord.short_description, newsRecord.txdate, newsRecord.active, newsRecord.image, newsRecord.featured, author, newsRecord.seo_page_title, newsRecord.seo_keywords);
1386
- };
1387
- return EsolveNewsService;
1388
- }());
1389
- EsolveNewsService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.0", ngImport: i0__namespace, type: EsolveNewsService, deps: [{ token: ESOLVE_CONNECT_CONFIG }, { token: i1__namespace$1.HttpClient }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1390
- EsolveNewsService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.0", ngImport: i0__namespace, type: EsolveNewsService, providedIn: 'root' });
1391
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.0", ngImport: i0__namespace, type: EsolveNewsService, decorators: [{
1392
- type: i0.Injectable,
1393
- args: [{
1394
- providedIn: 'root'
1395
- }]
1396
- }], ctorParameters: function () {
1397
- return [{ type: undefined, decorators: [{
1398
- type: i0.Inject,
1399
- args: [ESOLVE_CONNECT_CONFIG]
1400
- }] }, { type: i1__namespace$1.HttpClient }];
1401
- } });
1402
-
1403
- var EsolveBanner = /** @class */ (function () {
1404
- function EsolveBanner(id, banner_display_container, identifier, type, title, article, sort_priority, link, images) {
1405
- this.id = id;
1406
- this.banner_display_container = banner_display_container;
1407
- this.identifier = identifier;
1408
- this.type = type;
1409
- this.title = title;
1410
- this.article = article;
1411
- this.sort_priority = sort_priority;
1412
- this.link = link;
1413
- this.desktop_images = [];
1414
- this.mobile_images = [];
1415
- this.sub_images = [];
1416
- if (images.desktop) {
1417
- this.desktop_images = images.desktop;
1418
- }
1419
- if (images.mobile) {
1420
- this.mobile_images = images.mobile;
1421
- }
1422
- if (images.sub) {
1423
- this.sub_images = images.sub;
1424
- }
1425
- }
1426
- return EsolveBanner;
1427
- }());
1428
-
1429
- var EsolveBannerImage = /** @class */ (function () {
1430
- function EsolveBannerImage(id, image_type, width, height, filename, hotspots) {
1431
- this.id = id;
1432
- this.image_type = image_type;
1433
- this.width = width;
1434
- this.height = height;
1435
- this.filename = filename;
1436
- this.hotspots = hotspots;
1437
- }
1438
- Object.defineProperty(EsolveBannerImage.prototype, "src", {
1439
- get: function () {
1440
- return '/images/banners/' + this.filename;
1441
- },
1442
- enumerable: false,
1443
- configurable: true
1444
- });
1445
- return EsolveBannerImage;
1446
- }());
1447
-
1448
- var EsolveBannerImageHotspot = /** @class */ (function () {
1449
- function EsolveBannerImageHotspot(url, target, coords, coords_string) {
1450
- this.url = url;
1451
- this.target = target;
1452
- this.coords = coords;
1453
- this.coords_string = coords_string;
1454
- }
1455
- return EsolveBannerImageHotspot;
1456
- }());
1457
-
1458
- var EsolveBannerService = /** @class */ (function () {
1459
- function EsolveBannerService(config, http) {
1460
- this.config = config;
1461
- this.http = http;
1462
- }
1463
- EsolveBannerService.prototype.processBannerImageHotspots = function (hotspot_records) {
1464
- var e_1, _a;
1465
- var hotspots = [];
1466
- if (hotspot_records.length > 0) {
1467
- try {
1468
- for (var hotspot_records_1 = __values(hotspot_records), hotspot_records_1_1 = hotspot_records_1.next(); !hotspot_records_1_1.done; hotspot_records_1_1 = hotspot_records_1.next()) {
1469
- var hotspot_record = hotspot_records_1_1.value;
1470
- var hotspot = new EsolveBannerImageHotspot(hotspot_record.url, hotspot_record.target, hotspot_record.coords, hotspot_record.coords_string);
1471
- hotspots.push(hotspot);
1472
- }
1473
- }
1474
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1475
- finally {
1476
- try {
1477
- if (hotspot_records_1_1 && !hotspot_records_1_1.done && (_a = hotspot_records_1.return)) _a.call(hotspot_records_1);
1478
- }
1479
- finally { if (e_1) throw e_1.error; }
1480
- }
1481
- }
1482
- return hotspots;
1483
- };
1484
- EsolveBannerService.prototype.processBannerImages = function (image_records, banner_type) {
1485
- var e_2, _a;
1486
- var images = [];
1487
- if (image_records.length > 0) {
1488
- try {
1489
- for (var image_records_1 = __values(image_records), image_records_1_1 = image_records_1.next(); !image_records_1_1.done; image_records_1_1 = image_records_1.next()) {
1490
- var image_record = image_records_1_1.value;
1491
- var image = new EsolveBannerImage(+image_record.id, image_record.image_type, +image_record.width, +image_record.height, image_record.filename);
1492
- if ((banner_type === 'hotspot') && (image_record.hotspots)) {
1493
- var hotspots = this.processBannerImageHotspots(image_record.hotspots);
1494
- image.hotspots = hotspots;
1495
- }
1496
- images.push(image);
1497
- }
1498
- }
1499
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
1500
- finally {
1501
- try {
1502
- if (image_records_1_1 && !image_records_1_1.done && (_a = image_records_1.return)) _a.call(image_records_1);
1503
- }
1504
- finally { if (e_2) throw e_2.error; }
1505
- }
1506
- }
1507
- return images;
1508
- };
1509
- /**
1510
- * Process banner records into banner objects
1511
- * @param records Array of records
1512
- * @returns List of banners
1513
- */
1514
- EsolveBannerService.prototype.processBanners = function (records) {
1515
- var e_3, _a;
1516
- var banners = [];
1517
- if ((records) && (records.length > 0)) {
1518
- try {
1519
- for (var records_1 = __values(records), records_1_1 = records_1.next(); !records_1_1.done; records_1_1 = records_1.next()) {
1520
- var record = records_1_1.value;
1521
- var image_sets = {};
1522
- if (record.images.desktop) {
1523
- image_sets.desktop = this.processBannerImages(record.images.desktop, record.type);
1524
- }
1525
- if (record.images.mobile) {
1526
- image_sets.mobile = this.processBannerImages(record.images.mobile, record.type);
1527
- }
1528
- if (record.images.sub) {
1529
- image_sets.sub = this.processBannerImages(record.images.sub, record.type);
1530
- }
1531
- var banner = new EsolveBanner(+record.id, record.banner_display_container, record.identifier, record.type, record.title, record.article, +record.sort_priority, {
1532
- url: record.link.url,
1533
- target: record.link.target
1534
- }, image_sets);
1535
- banners.push(banner);
1536
- }
1537
- }
1538
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
1539
- finally {
1540
- try {
1541
- if (records_1_1 && !records_1_1.done && (_a = records_1.return)) _a.call(records_1);
1542
- }
1543
- finally { if (e_3) throw e_3.error; }
1544
- }
1545
- }
1546
- return banners;
1547
- };
1548
- /**
1549
- * Retrieves banners records from eSolve instance
1550
- *
1551
- * @returns An observable of eSolve banners.
1552
- */
1553
- EsolveBannerService.prototype.getBanners = function (identifier, banner_display_container, enable_date_filter) {
1554
- var _this = this;
1555
- if (enable_date_filter === void 0) { enable_date_filter = false; }
1556
- var params = new i1.HttpParams({
1557
- fromObject: {
1558
- ws_id: this.config.wsid,
1559
- enable_date_filter: enable_date_filter
1560
- }
1561
- });
1562
- if (identifier) {
1563
- params = params.set('identifier', identifier);
1564
- }
1565
- if (banner_display_container) {
1566
- params = params.set('banner_display_container', banner_display_container);
1567
- }
1568
- return this.http.get(this.config.api_url + "/service/get-banners.php", { params: params }).pipe(operators.map(function (response) {
1569
- if (response.records === undefined) {
1570
- throw response;
1571
- }
1572
- return _this.processBanners(response.records);
1573
- }));
1574
- };
1575
- return EsolveBannerService;
1576
- }());
1577
- EsolveBannerService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.0", ngImport: i0__namespace, type: EsolveBannerService, deps: [{ token: ESOLVE_CONNECT_CONFIG }, { token: i1__namespace$1.HttpClient }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1578
- EsolveBannerService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.0", ngImport: i0__namespace, type: EsolveBannerService, providedIn: 'root' });
1579
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.0", ngImport: i0__namespace, type: EsolveBannerService, decorators: [{
1580
- type: i0.Injectable,
1581
- args: [{
1582
- providedIn: 'root'
1583
- }]
1584
- }], ctorParameters: function () {
1585
- return [{ type: undefined, decorators: [{
1586
- type: i0.Inject,
1587
- args: [ESOLVE_CONNECT_CONFIG]
1588
- }] }, { type: i1__namespace$1.HttpClient }];
1589
- } });
1590
-
1591
- var EsolveMenuItem = /** @class */ (function () {
1592
- function EsolveMenuItem(url, name, target, children) {
1593
- if (children === void 0) { children = []; }
1594
- this.url = url;
1595
- this.name = name;
1596
- this.target = target;
1597
- this.children = children;
1598
- }
1599
- return EsolveMenuItem;
1600
- }());
1601
-
1602
- var EsolveMenuService = /** @class */ (function () {
1603
- function EsolveMenuService(config, http) {
1604
- this.config = config;
1605
- this.http = http;
1606
- }
1607
- EsolveMenuService.prototype.getMenuTree = function (identifier) {
1608
- var _this = this;
1609
- var menuParams = new i1.HttpParams();
1610
- menuParams = menuParams.set('identifier', identifier);
1611
- menuParams = menuParams.set('ws_id', this.config.wsid);
1612
- return this.http.get(this.config.api_url + "/service/get-menu-tree.php", { params: menuParams }).pipe(operators.map(function (response) {
1613
- if ((!response) || (response.records === undefined)) {
1614
- throw response;
1615
- }
1616
- else if (response.records.length === 0) {
1617
- return [];
1618
- }
1619
- return _this.handleMenu(response.records);
1620
- }));
1621
- };
1622
- EsolveMenuService.prototype.handleMenu = function (records) {
1623
- var e_1, _a;
1624
- var menu = [];
1625
- if (typeof records !== 'undefined') {
1626
- try {
1627
- for (var records_1 = __values(records), records_1_1 = records_1.next(); !records_1_1.done; records_1_1 = records_1.next()) {
1628
- var menuTreeRecord = records_1_1.value;
1629
- menu.push(new EsolveMenuItem(menuTreeRecord.sef_url, menuTreeRecord.name, menuTreeRecord.target, this.handleMenu(menuTreeRecord.children)));
1630
- }
1631
- }
1632
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1633
- finally {
1634
- try {
1635
- if (records_1_1 && !records_1_1.done && (_a = records_1.return)) _a.call(records_1);
1636
- }
1637
- finally { if (e_1) throw e_1.error; }
1638
- }
1639
- }
1640
- return menu;
1641
- };
1642
- return EsolveMenuService;
1643
- }());
1644
- EsolveMenuService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.0", ngImport: i0__namespace, type: EsolveMenuService, deps: [{ token: ESOLVE_CONNECT_CONFIG }, { token: i1__namespace$1.HttpClient }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1645
- EsolveMenuService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.0", ngImport: i0__namespace, type: EsolveMenuService, providedIn: 'root' });
1646
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.0", ngImport: i0__namespace, type: EsolveMenuService, decorators: [{
1647
- type: i0.Injectable,
1648
- args: [{
1649
- providedIn: 'root'
1650
- }]
1651
- }], ctorParameters: function () {
1652
- return [{ type: undefined, decorators: [{
1653
- type: i0.Inject,
1654
- args: [ESOLVE_CONNECT_CONFIG]
1655
- }] }, { type: i1__namespace$1.HttpClient }];
1656
- } });
1657
-
1658
- var EsolveTopicService = /** @class */ (function () {
1659
- function EsolveTopicService(config, http) {
1660
- this.config = config;
1661
- this.http = http;
1662
- }
1663
- EsolveTopicService.prototype.processTopics = function (records) {
1664
- var e_1, _a;
1665
- var topics = [];
1666
- if (records) {
1667
- try {
1668
- for (var records_1 = __values(records), records_1_1 = records_1.next(); !records_1_1.done; records_1_1 = records_1.next()) {
1669
- var record = records_1_1.value;
1670
- var topic = new EsolveTopic(+record.id, record.name, record.short_description, +record.sort_priority);
1671
- topics.push(topic);
1672
- }
1673
- }
1674
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1675
- finally {
1676
- try {
1677
- if (records_1_1 && !records_1_1.done && (_a = records_1.return)) _a.call(records_1);
1678
- }
1679
- finally { if (e_1) throw e_1.error; }
1680
- }
1681
- }
1682
- return topics;
1683
- };
1684
- /**
1685
- * Retrieves active topics from the list of topic ID's. Note that inactive or expired
1686
- * topics will not be retrieved.
1687
- *
1688
- * @param topic_id_list List of topic ID's that need to be retrieved
1689
- */
1690
- EsolveTopicService.prototype.getTopics = function (topic_id_list) {
1691
- var _this = this;
1692
- if (topic_id_list === void 0) { topic_id_list = []; }
1693
- var params = new i1.HttpParams({
1694
- fromObject: {
1695
- ws_id: this.config.wsid
1696
- }
1697
- });
1698
- if (topic_id_list.length > 0) {
1699
- params = params.append('topic_id', topic_id_list.join(','));
1700
- }
1701
- return this.http.get(this.config.api_url + "/service/get-topics.php", { params: params }).pipe(operators.map(function (response) {
1702
- if (response.records === undefined) {
1703
- throw response;
1704
- }
1705
- return _this.processTopics(response.records);
1706
- }));
1707
- };
1708
- return EsolveTopicService;
1709
- }());
1710
- EsolveTopicService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.0", ngImport: i0__namespace, type: EsolveTopicService, deps: [{ token: ESOLVE_CONNECT_CONFIG }, { token: i1__namespace$1.HttpClient }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1711
- EsolveTopicService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.0", ngImport: i0__namespace, type: EsolveTopicService, providedIn: 'root' });
1712
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.0", ngImport: i0__namespace, type: EsolveTopicService, decorators: [{
1713
- type: i0.Injectable,
1714
- args: [{
1715
- providedIn: 'root'
1716
- }]
1717
- }], ctorParameters: function () {
1718
- return [{ type: undefined, decorators: [{
1719
- type: i0.Inject,
1720
- args: [ESOLVE_CONNECT_CONFIG]
1721
- }] }, { type: i1__namespace$1.HttpClient }];
1722
- } });
1723
-
1724
- var EsolveStockBadge = /** @class */ (function () {
1725
- function EsolveStockBadge(id, text, identifier, font_colour, badge_colour, sort_priority) {
1726
- this.id = id;
1727
- this.text = text;
1728
- this.identifier = identifier;
1729
- this.font_colour = font_colour;
1730
- this.badge_colour = badge_colour;
1731
- this.sort_priority = sort_priority;
1732
- }
1733
- return EsolveStockBadge;
1734
- }());
1735
-
1736
- /**
1737
- * Price of eSolve stock item
1738
- */
1739
- var EsolveStockPrice = /** @class */ (function () {
1740
- /**
1741
- * Create stock price instance
1742
- * @param base_price Price without tax
1743
- * @param base_price_with_tax Price with tax
1744
- * @param sell_price Price without tax and with discounts applied if appilcable
1745
- * @param sell_price_with_tax Price with tax and with discounts applied if appilcable
1746
- */
1747
- function EsolveStockPrice(
1748
- /**
1749
- * Price without tax
1750
- */
1751
- base_price,
1752
- /**
1753
- * Price with tax
1754
- */
1755
- base_price_with_tax,
1756
- /**
1757
- * Price without tax and with discounts applied if appilcable
1758
- */
1759
- sell_price,
1760
- /**
1761
- * Price with tax and with discounts applied if appilcable
1762
- */
1763
- sell_price_with_tax) {
1764
- this.base_price = base_price;
1765
- this.base_price_with_tax = base_price_with_tax;
1766
- this.sell_price = sell_price;
1767
- this.sell_price_with_tax = sell_price_with_tax;
1768
- if ((this.base_price === 0) && (this.sell_price > 0)) {
1769
- this.base_price = this.sell_price;
1770
- this.base_price_with_tax = this.sell_price_with_tax;
1771
- }
1772
- else if ((this.base_price > 0) && (this.sell_price === 0)) {
1773
- this.sell_price = this.base_price;
1774
- this.sell_price_with_tax = this.base_price_with_tax;
1775
- }
1776
- }
1777
- return EsolveStockPrice;
1778
- }());
1779
-
1780
- /**
1781
- * Stock Item object. It can be a service or a product (physical and/or digital).
1782
- */
1783
- var EsolveStockItem = /** @class */ (function () {
1784
- /**
1785
- * Constructs an instance of EsolveStockItem
1786
- *
1787
- * @param id eSolve Generated ID
1788
- * @param code Code identifying the stock item
1789
- * @param name Name of the stock item
1790
- * @param sef_name Search engine friendly name
1791
- * @param description Short description of stock item
1792
- * @param active Active state
1793
- * @param featured Featured state
1794
- * @param image_name Image filename
1795
- * @param price Default price
1796
- * @param tags Linked tags
1797
- * @param topics Linked topics
1798
- * @param seo_title SEO page title
1799
- * @param seo_keywords SEO page keywords
1800
- */
1801
- function EsolveStockItem(
1802
- /**
1803
- * eSolve Generated ID
1804
- */
1805
- id,
1806
- /**
1807
- * Code identifying the stock item
1808
- */
1809
- code,
1810
- /**
1811
- * Name of the stock item
1812
- */
1813
- name,
1814
- /**
1815
- * Search engine friendly name
1816
- */
1817
- sef_name,
1818
- /**
1819
- * Short description of stock item
1820
- */
1821
- description,
1822
- /**
1823
- * Active state
1824
- */
1825
- active,
1826
- /**
1827
- * Featured state
1828
- */
1829
- featured,
1830
- /**
1831
- * Image filename
1832
- */
1833
- image_name,
1834
- /**
1835
- * Default price
1836
- */
1837
- price,
1838
- /**
1839
- * Linked tags
1840
- */
1841
- tags,
1842
- /**
1843
- * Linked topics
1844
- */
1845
- topics,
1846
- /**
1847
- * Stock badges
1848
- */
1849
- badges,
1850
- /**
1851
- * ID of default category linked to the stock item
1852
- */
1853
- category_id,
1854
- /**
1855
- * ID of default subcategory linked to the stock item
1856
- */
1857
- subcategory_id, seo_title, seo_keywords) {
1858
- if (seo_title === void 0) { seo_title = ''; }
1859
- if (seo_keywords === void 0) { seo_keywords = ''; }
1860
- this.id = id;
1861
- this.code = code;
1862
- this.name = name;
1863
- this.sef_name = sef_name;
1864
- this.description = description;
1865
- this.active = active;
1866
- this.featured = featured;
1867
- this.image_name = image_name;
1868
- this.price = price;
1869
- this.tags = tags;
1870
- this.topics = topics;
1871
- this.badges = badges;
1872
- this.category_id = category_id;
1873
- this.subcategory_id = subcategory_id;
1874
- if (seo_title.trim() === '') {
1875
- seo_title = this.name;
1876
- }
1877
- this.seo_details = new EsolveSEOInfo(seo_title, description, seo_keywords);
1878
- }
1879
- Object.defineProperty(EsolveStockItem.prototype, "tiny_image_src", {
1880
- /**
1881
- * Path to tiny stock image
1882
- */
1883
- get: function () {
1884
- return '/images/' + (this.image_name ? 'stock/tiny/' + this.image_name : 'no_image.jpg');
1885
- },
1886
- enumerable: false,
1887
- configurable: true
1888
- });
1889
- Object.defineProperty(EsolveStockItem.prototype, "thumbnail_image_src", {
1890
- /**
1891
- * Path to thumbnail stock image
1892
- */
1893
- get: function () {
1894
- return '/images/' + (this.image_name ? 'stock/thumb/' + this.image_name : 'no_image.jpg');
1895
- },
1896
- enumerable: false,
1897
- configurable: true
1898
- });
1899
- Object.defineProperty(EsolveStockItem.prototype, "small_image_src", {
1900
- /**
1901
- * Path to small stock image
1902
- */
1903
- get: function () {
1904
- return '/images/' + (this.image_name ? 'stock/small/' + this.image_name : 'no_image.jpg');
1905
- },
1906
- enumerable: false,
1907
- configurable: true
1908
- });
1909
- Object.defineProperty(EsolveStockItem.prototype, "big_image_src", {
1910
- /**
1911
- * Path to big stock image
1912
- */
1913
- get: function () {
1914
- return '/images/' + (this.image_name ? 'stock/big/' + this.image_name : 'no_image.jpg');
1915
- },
1916
- enumerable: false,
1917
- configurable: true
1918
- });
1919
- Object.defineProperty(EsolveStockItem.prototype, "original_image_src", {
1920
- /**
1921
- * Path to original stock image
1922
- */
1923
- get: function () {
1924
- return '/images/' + (this.image_name ? 'stock/original/' + this.image_name : 'no_image.jpg');
1925
- },
1926
- enumerable: false,
1927
- configurable: true
1928
- });
1929
- return EsolveStockItem;
1930
- }());
1931
-
1932
- /**
1933
- * Stock item object list
1934
- */
1935
- var EsolveStockItemList = /** @class */ (function () {
1936
- function EsolveStockItemList(stock_items, total, page) {
1937
- this.stock_items = stock_items;
1938
- this.total = total;
1939
- this.page = page;
1940
- }
1941
- return EsolveStockItemList;
1942
- }());
1943
-
1944
- var EsolveStockService = /** @class */ (function () {
1945
- function EsolveStockService(config, http) {
1946
- this.config = config;
1947
- this.http = http;
1948
- }
1949
- /**
1950
- * Processes the eSolve stock item record and converts it to StockItem object.
1951
- * @param record eSolve stock item record
1952
- */
1953
- EsolveStockService.prototype.processStockItem = function (record) {
1954
- var e_1, _b, e_2, _c, e_3, _d;
1955
- var tags = [];
1956
- var topics = [];
1957
- var badges = [];
1958
- if ((record.tags) && (record.tags.length > 0)) {
1959
- try {
1960
- for (var _e = __values(record.tags), _f = _e.next(); !_f.done; _f = _e.next()) {
1961
- var tag = _f.value;
1962
- tags.push(new EsolveTag(+tag.id, tag.tag_phrase, +tag.tag_weight, tag.description));
1963
- }
1964
- }
1965
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1966
- finally {
1967
- try {
1968
- if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
1969
- }
1970
- finally { if (e_1) throw e_1.error; }
1971
- }
1972
- }
1973
- if ((record.topics) && (record.topics.length > 0)) {
1974
- try {
1975
- for (var _g = __values(record.topics), _h = _g.next(); !_h.done; _h = _g.next()) {
1976
- var topic = _h.value;
1977
- topics.push(new EsolveTopic(+topic.id, topic.name, topic.short_description, +topic.sort_priority));
1978
- }
1979
- }
1980
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
1981
- finally {
1982
- try {
1983
- if (_h && !_h.done && (_c = _g.return)) _c.call(_g);
1984
- }
1985
- finally { if (e_2) throw e_2.error; }
1986
- }
1987
- }
1988
- if ((record.badges) && (record.badges.length > 0)) {
1989
- try {
1990
- for (var _j = __values(record.badges), _k = _j.next(); !_k.done; _k = _j.next()) {
1991
- var badge = _k.value;
1992
- badges.push(new EsolveStockBadge(+badge.id, badge.text, badge.identifier, badge.font_colour, badge.badge_colour, +badge.sort_priority));
1993
- }
1994
- }
1995
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
1996
- finally {
1997
- try {
1998
- if (_k && !_k.done && (_d = _j.return)) _d.call(_j);
1999
- }
2000
- finally { if (e_3) throw e_3.error; }
2001
- }
2002
- }
2003
- var price = new EsolveStockPrice(record.regular_sellprice, record.regular_sellprice_inclusive, record.sellprice, record.sellprice_inclusive);
2004
- return new EsolveStockItem(+record.id, record.code, record.name, record.sef_name, record.description, !!+record.is_active, !!+record.is_featured, record.image_name, price, tags, topics, badges, record.category_id, +record.subcategory_id, record.seo_page_title, record.seo_keywords);
2005
- };
2006
- /**
2007
- * Retrieves stock records from HTTP params.
2008
- * @param params HTTP client parameters
2009
- */
2010
- EsolveStockService.prototype.getStockRecords = function (params) {
2011
- params = params.set('ws_id', this.config.wsid);
2012
- return this.http.get(this.config.api_url + "/service/get-items.php", { params: params });
2013
- };
2014
- /**
2015
- * Retrieves the stock record from the eSolve instance using the code.
2016
- * @param code eSolve stock code
2017
- */
2018
- EsolveStockService.prototype.getStockItem = function (code) {
2019
- var _this = this;
2020
- var params = new i1.HttpParams({
2021
- fromObject: {
2022
- code: code
2023
- }
2024
- });
2025
- return this.getStockRecords(params).pipe(operators.map(function (response) {
2026
- if ((response.records === undefined) || (response.records.length <= 0)) {
2027
- throw response;
2028
- }
2029
- var stockRecord = response.records[0];
2030
- return _this.processStockItem(stockRecord);
2031
- }));
2032
- };
2033
- /**
2034
- * Retrieves the stock record from the eSolve instance using the SEF name.
2035
- * @param sef_name SEF name of the stock item
2036
- */
2037
- EsolveStockService.prototype.getStockItemFromSEF = function (sef_name) {
2038
- var _this = this;
2039
- var params = new i1.HttpParams({
2040
- fromObject: {
2041
- sef_name: sef_name
2042
- }
2043
- });
2044
- return this.getStockRecords(params).pipe(operators.map(function (response) {
2045
- if ((response.records === undefined) || (response.records.length <= 0)) {
2046
- throw response;
2047
- }
2048
- var stockRecord = response.records[0];
2049
- return _this.processStockItem(stockRecord);
2050
- }));
2051
- };
2052
- /**
2053
- * Retrieves list of stock from the eSolve instance using info provided
2054
- * @param options Stock filter options
2055
- */
2056
- EsolveStockService.prototype.getStockItems = function (options) {
2057
- var _this = this;
2058
- var params = new i1.HttpParams();
2059
- if (options.page) {
2060
- params = params.set('page', options.page);
2061
- }
2062
- if (options.rows) {
2063
- params = params.set('rows', options.rows);
2064
- }
2065
- if (options.display_only) {
2066
- params = params.set('display_only', options.display_only);
2067
- }
2068
- if (options.is_active) {
2069
- params = params.set('is_active', options.is_active);
2070
- }
2071
- if (options.category_id) {
2072
- params = params.set('category_id', options.category_id);
2073
- }
2074
- if (options.subcategory_id) {
2075
- params = params.set('subcategory_id', options.subcategory_id);
2076
- }
2077
- if (options.tag_id_list) {
2078
- if (options.tag_id_list.length > 0) {
2079
- params = params.set('tag_id', options.tag_id_list.join(','));
2080
- }
2081
- }
2082
- if (options.topic_id_list) {
2083
- if (options.topic_id_list.length > 0) {
2084
- params = params.set('topic_id', options.topic_id_list.join(','));
2085
- }
2086
- }
2087
- return this.getStockRecords(params).pipe(operators.map(function (response) {
2088
- var _a;
2089
- if ((response.records === undefined) || (response.records.length <= 0)) {
2090
- throw response;
2091
- }
2092
- var stockItems = [];
2093
- response.records.forEach(function (stockRecord) {
2094
- stockItems.push(_this.processStockItem(stockRecord));
2095
- });
2096
- return new EsolveStockItemList(stockItems, +response.additional_data.total_records, (_a = options.page) !== null && _a !== void 0 ? _a : 0);
2097
- }));
2098
- };
2099
- return EsolveStockService;
2100
- }());
2101
- EsolveStockService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.0", ngImport: i0__namespace, type: EsolveStockService, deps: [{ token: ESOLVE_CONNECT_CONFIG }, { token: i1__namespace$1.HttpClient }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
2102
- EsolveStockService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.0", ngImport: i0__namespace, type: EsolveStockService, providedIn: 'root' });
2103
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.0", ngImport: i0__namespace, type: EsolveStockService, decorators: [{
2104
- type: i0.Injectable,
2105
- args: [{
2106
- providedIn: 'root'
2107
- }]
2108
- }], ctorParameters: function () {
2109
- return [{ type: undefined, decorators: [{
2110
- type: i0.Inject,
2111
- args: [ESOLVE_CONNECT_CONFIG]
2112
- }] }, { type: i1__namespace$1.HttpClient }];
2113
- } });
2114
-
2115
- var EsolveCategoryTreeItem = /** @class */ (function () {
2116
- function EsolveCategoryTreeItem(type, esolve_id, parent_id, description, sef_description, short_description, sort_priority, active, display_only, image_name, seo_title, seo_keywords, seo_description, children) {
2117
- this.type = type;
2118
- this.esolve_id = esolve_id;
2119
- this.parent_id = parent_id;
2120
- this.description = description;
2121
- this.sef_description = sef_description;
2122
- this.short_description = short_description;
2123
- this.sort_priority = sort_priority;
2124
- this.active = active;
2125
- this.display_only = display_only;
2126
- this.image_name = image_name;
2127
- this.image_path = '';
2128
- this.id = '';
2129
- if (this.type === 'category') {
2130
- this.id = "<<CAT>>" + this.esolve_id;
2131
- if (children != null) {
2132
- this.children = children;
2133
- }
2134
- this.image_path = '/images/categories/';
2135
- }
2136
- else {
2137
- this.id = "<<SUB>>" + this.esolve_id;
2138
- this.image_path = '/images/subcategories/';
2139
- }
2140
- if (seo_title.trim() === '') {
2141
- seo_title = this.description;
2142
- }
2143
- this.seo_details = new EsolveSEOInfo(seo_title, seo_description, seo_keywords);
2144
- }
2145
- EsolveCategoryTreeItem.prototype.generateImagePath = function (image_size) {
2146
- if (this.image_name !== '') {
2147
- return "" + this.image_path + image_size + "/" + this.image_name;
2148
- }
2149
- return '';
2150
- };
2151
- Object.defineProperty(EsolveCategoryTreeItem.prototype, "small_image_src", {
2152
- get: function () {
2153
- return this.generateImagePath('small');
2154
- },
2155
- enumerable: false,
2156
- configurable: true
2157
- });
2158
- Object.defineProperty(EsolveCategoryTreeItem.prototype, "thumbnail_image_src", {
2159
- get: function () {
2160
- return this.generateImagePath('thumb');
2161
- },
2162
- enumerable: false,
2163
- configurable: true
2164
- });
2165
- Object.defineProperty(EsolveCategoryTreeItem.prototype, "tiny_image_src", {
2166
- get: function () {
2167
- return this.generateImagePath('tiny');
2168
- },
2169
- enumerable: false,
2170
- configurable: true
2171
- });
2172
- return EsolveCategoryTreeItem;
2173
- }());
2174
-
2175
- var EsolveCategoryTreeService = /** @class */ (function () {
2176
- function EsolveCategoryTreeService(config, http) {
2177
- this.config = config;
2178
- this.http = http;
2179
- }
2180
- /**
2181
- * Processes the eSolve tree records and converts them into the correct format.
2182
- * @param tree_records Records to process
2183
- */
2184
- EsolveCategoryTreeService.prototype.processTree = function (tree_records) {
2185
- var e_1, _a;
2186
- var tree_items = [];
2187
- if (tree_records) {
2188
- try {
2189
- for (var tree_records_1 = __values(tree_records), tree_records_1_1 = tree_records_1.next(); !tree_records_1_1.done; tree_records_1_1 = tree_records_1.next()) {
2190
- var tree_record = tree_records_1_1.value;
2191
- var esolve_id = '';
2192
- var parent_id = '';
2193
- var children = [];
2194
- if (tree_record.type === 'category') {
2195
- children = this.processTree(tree_record.children);
2196
- esolve_id = tree_record.menu_id;
2197
- parent_id = tree_record.owner_menu_id;
2198
- }
2199
- else {
2200
- esolve_id = tree_record.id;
2201
- parent_id = tree_record.menu_id;
2202
- }
2203
- tree_items.push(new EsolveCategoryTreeItem(tree_record.type, esolve_id, parent_id, tree_record.description, tree_record.sef_description, tree_record.seo_description, tree_record.sort_priority, tree_record.active, tree_record.display_only, tree_record.image, tree_record.seo_page_title, tree_record.seo_keywords, tree_record.short_description, children));
2204
- }
2205
- }
2206
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
2207
- finally {
2208
- try {
2209
- if (tree_records_1_1 && !tree_records_1_1.done && (_a = tree_records_1.return)) _a.call(tree_records_1);
2210
- }
2211
- finally { if (e_1) throw e_1.error; }
2212
- }
2213
- }
2214
- return tree_items;
2215
- };
2216
- EsolveCategoryTreeService.prototype.processTreeItem = function (record) {
2217
- return new EsolveCategoryTreeItem(record.type, record.id, record.parent_id, record.description, record.sef_description, record.short_description, record.sort_priority, record.active, record.display_only, '', record.seo_page_title, record.seo_keywords, record.seo_description);
2218
- };
2219
- EsolveCategoryTreeService.prototype.processID = function (id) {
2220
- var type;
2221
- var esolve_id;
2222
- var type_code_regex = /^\<\<(CAT|SUB)\>\>/g;
2223
- var match_results = id.match(type_code_regex);
2224
- if (match_results) {
2225
- var type_code = match_results[0];
2226
- type = (type_code === '<<CAT>>' ? 'category' : 'subcategory');
2227
- esolve_id = id.replace(type_code_regex, '');
2228
- return {
2229
- type: type,
2230
- esolve_id: esolve_id
2231
- };
2232
- }
2233
- return null;
2234
- };
2235
- /**
2236
- * Retrieves the category tree from eSolve instance and coverts it to the correct format.
2237
- */
2238
- EsolveCategoryTreeService.prototype.getCategoryTree = function () {
2239
- var _this = this;
2240
- var params = new i1.HttpParams();
2241
- params = params.set('ws_id', this.config.wsid);
2242
- return this.http.get(this.config.api_url + "/service/get-tree.php", { params: params }).pipe(operators.map(function (response) {
2243
- if (response.records === undefined) {
2244
- throw response;
2245
- }
2246
- return _this.processTree(response.records);
2247
- }));
2248
- };
2249
- /**
2250
- * Retrieve the details of a category tree item from the eSolve instance and converts it to the correct format.
2251
- * @param options Filter options
2252
- */
2253
- EsolveCategoryTreeService.prototype.getCategoryTreeItem = function (options) {
2254
- var _this = this;
2255
- var type;
2256
- var esolve_id;
2257
- var sef_description;
2258
- if (options.id) {
2259
- var categoryIdentifier = this.processID(options.id);
2260
- if (categoryIdentifier) {
2261
- type = categoryIdentifier.type;
2262
- esolve_id = categoryIdentifier.esolve_id;
2263
- }
2264
- }
2265
- else if (options.type) {
2266
- type = options.type;
2267
- if (options.esolve_id) {
2268
- esolve_id = options.esolve_id;
2269
- }
2270
- else if (options.sef_description) {
2271
- sef_description = options.sef_description;
2272
- }
2273
- }
2274
- if (type && (esolve_id || sef_description)) {
2275
- var params = new i1.HttpParams();
2276
- params = params.set('ws_id', this.config.wsid.toString());
2277
- params = params.set('type', type.toString());
2278
- if (esolve_id) {
2279
- params = params.set('id', esolve_id.toString());
2280
- }
2281
- if (sef_description) {
2282
- params = params.set('sef_description', sef_description.toString());
2283
- }
2284
- return this.http.get(this.config.api_url + "/service/get-tree-item.php", { params: params }).pipe(operators.map(function (response) {
2285
- if ((response.records === undefined) || (response.records.length <= 0)) {
2286
- throw response;
2287
- }
2288
- return _this.processTreeItem(response.records[0]);
2289
- }));
2290
- }
2291
- return rxjs.throwError('Invalid options');
2292
- };
2293
- return EsolveCategoryTreeService;
2294
- }());
2295
- EsolveCategoryTreeService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.0", ngImport: i0__namespace, type: EsolveCategoryTreeService, deps: [{ token: ESOLVE_CONNECT_CONFIG }, { token: i1__namespace$1.HttpClient }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
2296
- EsolveCategoryTreeService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.0", ngImport: i0__namespace, type: EsolveCategoryTreeService, providedIn: 'root' });
2297
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.0", ngImport: i0__namespace, type: EsolveCategoryTreeService, decorators: [{
2298
- type: i0.Injectable,
2299
- args: [{
2300
- providedIn: 'root'
2301
- }]
2302
- }], ctorParameters: function () {
2303
- return [{ type: undefined, decorators: [{
2304
- type: i0.Inject,
2305
- args: [ESOLVE_CONNECT_CONFIG]
2306
- }] }, { type: i1__namespace$1.HttpClient }];
2307
- } });
2308
-
2309
- var EsolveStockLocation = /** @class */ (function () {
2310
- function EsolveStockLocation(record) {
2311
- this.id = +record.id;
2312
- this.identifier = record.identifier;
2313
- this.description = record.description;
2314
- this.head_office = record.head_office;
2315
- this.erp_identifier = record.erp_identifier;
2316
- this.external_system_code = record.external_system_code;
2317
- this.default_location_for_payment_methods = record.default_location_for_payment_methods;
2318
- this.userid = +record.userid;
2319
- this.importance = +record.importance;
2320
- this.active = record.is_active;
2321
- this.website_url = record.website_url;
2322
- this.address = new EsolveStockLocationAddress(record.street, record.suburb, record.city, record.province, record.country, record.postal_code, +record.latitude, +record.longitude);
2323
- this.pobox_address = new EsolveStockLocationPOBoxAddress(record.pobox, record.pobox_city, record.pobox_postal_code);
2324
- var telnumbers = [];
2325
- if (record.branch_telnumber.length > 0) {
2326
- telnumbers.push(record.branch_telnumber);
2327
- }
2328
- if (record.branch_telnumber_2.length > 0) {
2329
- telnumbers.push(record.branch_telnumber_2);
2330
- }
2331
- if (record.branch_telnumber_3.length > 0) {
2332
- telnumbers.push(record.branch_telnumber_3);
2333
- }
2334
- this.contact_info = new EsolveStockLocationContactInfo(telnumbers, record.branch_cellnumber, record.branch_email, record.branch_fax);
2335
- this.trading_times = new EsolveStockLocationTradingTimes(record.monday_open_time, record.monday_close_time, record.tuesday_open_time, record.tuesday_close_time, record.wednesday_open_time, record.wednesday_close_time, record.thursday_open_time, record.thursday_close_time, record.friday_open_time, record.friday_close_time, record.saturday_open_time, record.saturday_close_time, record.sunday_open_time, record.sunday_close_time, record.public_holiday_open_time, record.public_holiday_close_time, record.trading_hours_additional_in);
2336
- }
2337
- return EsolveStockLocation;
2338
- }());
2339
- var EsolveStockLocationAddress = /** @class */ (function () {
2340
- function EsolveStockLocationAddress(street, suburb, city, province, country, postal_code, latitude, longitude) {
2341
- this.street = street;
2342
- this.suburb = suburb;
2343
- this.city = city;
2344
- this.province = province;
2345
- this.country = country;
2346
- this.postal_code = postal_code;
2347
- this.latitude = latitude;
2348
- this.longitude = longitude;
2349
- }
2350
- return EsolveStockLocationAddress;
2351
- }());
2352
- var EsolveStockLocationPOBoxAddress = /** @class */ (function () {
2353
- function EsolveStockLocationPOBoxAddress(pobox, city, postal_code) {
2354
- this.pobox = pobox;
2355
- this.city = city;
2356
- this.postal_code = postal_code;
2357
- }
2358
- return EsolveStockLocationPOBoxAddress;
2359
- }());
2360
- var EsolveStockLocationContactInfo = /** @class */ (function () {
2361
- function EsolveStockLocationContactInfo(telnumber, cellnumber, email, fax) {
2362
- this.telnumber = telnumber;
2363
- this.cellnumber = cellnumber;
2364
- this.email = email;
2365
- this.fax = fax;
2366
- }
2367
- return EsolveStockLocationContactInfo;
2368
- }());
2369
- var EsolveStockLocationTradingTimes = /** @class */ (function () {
2370
- function EsolveStockLocationTradingTimes(monday_open_time, monday_close_time, tuesday_open_time, tuesday_close_time, wednesday_open_time, wednesday_close_time, thursday_open_time, thursday_close_time, friday_open_time, friday_close_time, saturday_open_time, saturday_close_time, sunday_open_time, sunday_close_time, public_holiday_open_time, public_holiday_close_time, trading_hours_additional_info) {
2371
- if (trading_hours_additional_info === void 0) { trading_hours_additional_info = ''; }
2372
- this.trading_hours_additional_info = trading_hours_additional_info;
2373
- this.monday = new EsolveStockLocationTradingTimesDay(monday_open_time, monday_close_time);
2374
- this.tuesday = new EsolveStockLocationTradingTimesDay(tuesday_open_time, tuesday_close_time);
2375
- this.wednesday = new EsolveStockLocationTradingTimesDay(wednesday_open_time, wednesday_close_time);
2376
- this.thursday = new EsolveStockLocationTradingTimesDay(thursday_open_time, thursday_close_time);
2377
- this.friday = new EsolveStockLocationTradingTimesDay(friday_open_time, friday_close_time);
2378
- this.saturday = new EsolveStockLocationTradingTimesDay(saturday_open_time, saturday_close_time);
2379
- this.sunday = new EsolveStockLocationTradingTimesDay(sunday_open_time, sunday_close_time);
2380
- this.public_holiday = new EsolveStockLocationTradingTimesDay(public_holiday_open_time, public_holiday_close_time);
2381
- }
2382
- return EsolveStockLocationTradingTimes;
2383
- }());
2384
- var EsolveStockLocationTradingTimesDay = /** @class */ (function () {
2385
- function EsolveStockLocationTradingTimesDay(open, close) {
2386
- this.open = open;
2387
- this.close = close;
2388
- }
2389
- return EsolveStockLocationTradingTimesDay;
2390
- }());
2391
-
2392
- var EsolveCartItem = /** @class */ (function () {
2393
- function EsolveCartItem(id, stock_item, qty, type, price, discount, discount_interval, vat_rate, allow_quotes, allow_orders, must_collect, requested_assembly, price_incl, discount_price, discount_price_incl, discount_total, vat_total, total, total_incl) {
2394
- this.id = id;
2395
- this.stock_item = stock_item;
2396
- this.qty = qty;
2397
- this.type = type;
2398
- this.price = price;
2399
- this.discount = discount;
2400
- this.discount_interval = discount_interval;
2401
- this.vat_rate = vat_rate;
2402
- this.allow_quotes = allow_quotes;
2403
- this.allow_orders = allow_orders;
2404
- this.must_collect = must_collect;
2405
- this.requested_assembly = requested_assembly;
2406
- this.price_incl = price_incl;
2407
- this.discount_price = discount_price;
2408
- this.discount_price_incl = discount_price_incl;
2409
- this.discount_total = discount_total;
2410
- this.vat_total = vat_total;
2411
- this.total = total;
2412
- this.total_incl = total_incl;
2413
- }
2414
- return EsolveCartItem;
2415
- }());
2416
-
2417
- var EsolveShippingMethod = /** @class */ (function () {
2418
- function EsolveShippingMethod(id, carrier_name, delivery_category, description, location, pricing, link_to_carrier_website, days_to_deliver, shipping_cost_calculation_method, insurance_cost_calculation_method, insurance_cost_percentage, metric_factor, allow_immediate_payment_processing, allow_postal_address, allow_physical_address, client_to_collect, is_default, location_id, use_zones, min_distance, max_distance, shipping_surge_condition, shipping_surge_percentage, sort_priority, shipping_group, shipping_slot_identifier, shipping_slot_delay_hours, image_url) {
2419
- this.id = id;
2420
- this.carrier_name = carrier_name;
2421
- this.delivery_category = delivery_category;
2422
- this.description = description;
2423
- this.location = location;
2424
- this.pricing = pricing;
2425
- this.link_to_carrier_website = link_to_carrier_website;
2426
- this.days_to_deliver = days_to_deliver;
2427
- this.shipping_cost_calculation_method = shipping_cost_calculation_method;
2428
- this.insurance_cost_calculation_method = insurance_cost_calculation_method;
2429
- this.insurance_cost_percentage = insurance_cost_percentage;
2430
- this.metric_factor = metric_factor;
2431
- this.allow_immediate_payment_processing = allow_immediate_payment_processing;
2432
- this.allow_postal_address = allow_postal_address;
2433
- this.allow_physical_address = allow_physical_address;
2434
- this.client_to_collect = client_to_collect;
2435
- this.is_default = is_default;
2436
- this.location_id = location_id;
2437
- this.use_zones = use_zones;
2438
- this.min_distance = min_distance;
2439
- this.max_distance = max_distance;
2440
- this.shipping_surge_condition = shipping_surge_condition;
2441
- this.shipping_surge_percentage = shipping_surge_percentage;
2442
- this.sort_priority = sort_priority;
2443
- this.shipping_group = shipping_group;
2444
- this.shipping_slot_identifier = shipping_slot_identifier;
2445
- this.shipping_slot_delay_hours = shipping_slot_delay_hours;
2446
- this.image_url = image_url;
2447
- }
2448
- return EsolveShippingMethod;
2449
- }());
2450
-
2451
- var EsolvePaymentMethod = /** @class */ (function () {
2452
- function EsolvePaymentMethod(record) {
2453
- this.id = +record.id;
2454
- this.location_id = +record.location_id;
2455
- this.paymethod_name = record.paymethod_name;
2456
- this.description = record.description;
2457
- this.display_banking_details = record.display_banking_details;
2458
- this.currency_code = record.currency_code;
2459
- this.terminal_id = record.terminal_id;
2460
- this.terminal_id_secondary = record.terminal_id_secondary;
2461
- this.merchant_id = record.merchant_id;
2462
- this.application_id = record.application_id;
2463
- this.api_username = record.api_username;
2464
- this.api_password = record.api_password;
2465
- this.api_signature = record.api_signature;
2466
- this.is_gateway = record.is_gateway;
2467
- this.must_store_card_details = record.must_store_card_details;
2468
- this.allow_budget = record.allow_budget;
2469
- this.integration_type = record.integration_type;
2470
- this.bank_gateway_id = record.bank_gateway_id;
2471
- this.accepted_card_types = record.accepted_card_types;
2472
- this.post_transactions_to_gateway = record.post_transactions_to_gateway;
2473
- this.three_d_secure_url = record.three_d_secure_url;
2474
- this.gateway_url = record.gateway_url;
2475
- this.generate_token_url = record.generate_token_url;
2476
- this.widget_url = record.widget_url;
2477
- this.successful_url = record.successful_url;
2478
- this.failed_url = record.failed_url;
2479
- this.enable_callback = record.enable_callback;
2480
- this.live = record.live;
2481
- this.default_module_id = +record.default_module_id;
2482
- this.service_provider = record.service_provider;
2483
- this.on_account = record.on_account;
2484
- this.sort_priority = +record.sort_priority;
2485
- this.image_url = record.image_url;
2486
- this.banking_details = new BankingDetails(record.bank_name, record.account_holder, record.account, record.account_type, record.swift_number, record.branch_code);
2487
- }
2488
- return EsolvePaymentMethod;
2489
- }());
2490
- var BankingDetails = /** @class */ (function () {
2491
- function BankingDetails(bank_name, account_holder, account, account_type, swift_number, branch_code) {
2492
- this.bank_name = bank_name;
2493
- this.account_holder = account_holder;
2494
- this.account = account;
2495
- this.account_type = account_type;
2496
- this.swift_number = swift_number;
2497
- this.branch_code = branch_code;
2498
- }
2499
- return BankingDetails;
2500
- }());
2501
-
2502
- var EsolveShippingCost = /** @class */ (function () {
2503
- function EsolveShippingCost(
2504
- // Shipping
2505
- shipping_total, shipping_vat, shipping_total_savings,
2506
- // Insurance
2507
- insurance_total, insurance_vat, insurance_total_savings) {
2508
- if (shipping_total === void 0) { shipping_total = 0; }
2509
- if (shipping_vat === void 0) { shipping_vat = 0; }
2510
- if (shipping_total_savings === void 0) { shipping_total_savings = 0; }
2511
- if (insurance_total === void 0) { insurance_total = 0; }
2512
- if (insurance_vat === void 0) { insurance_vat = 0; }
2513
- if (insurance_total_savings === void 0) { insurance_total_savings = 0; }
2514
- this.shipping = new EsolveShippingTotals(shipping_total, shipping_vat, shipping_total_savings);
2515
- this.insurance = new EsolveShippingTotals(insurance_total, insurance_vat, insurance_total_savings);
2516
- }
2517
- return EsolveShippingCost;
2518
- }());
2519
- var EsolveShippingTotals = /** @class */ (function () {
2520
- function EsolveShippingTotals(total, vat, savings) {
2521
- this.total = total;
2522
- this.vat = vat;
2523
- this.savings = savings;
2524
- }
2525
- return EsolveShippingTotals;
2526
- }());
2527
-
2528
- /**
2529
- * Totals in cart
2530
- */
2531
- var EsolveCartTotals = /** @class */ (function () {
2532
- function EsolveCartTotals(
2533
- /**
2534
- * Number of unique records in cart
2535
- */
2536
- records,
2537
- /**
2538
- * Total quantity of all items in a cart
2539
- */
2540
- items,
2541
- /**
2542
- * Total in cart before discount and VAT is added
2543
- */
2544
- sub_total,
2545
- /**
2546
- * Total VAT of all the items in the cart
2547
- */
2548
- vat_total,
2549
- /**
2550
- * Total discount of all the item in the cart
2551
- */
2552
- discount_total) {
2553
- if (records === void 0) { records = 0; }
2554
- if (items === void 0) { items = 0; }
2555
- if (sub_total === void 0) { sub_total = 0; }
2556
- if (vat_total === void 0) { vat_total = 0; }
2557
- if (discount_total === void 0) { discount_total = 0; }
2558
- this.records = records;
2559
- this.items = items;
2560
- this.sub_total = sub_total;
2561
- this.vat_total = vat_total;
2562
- this.discount_total = discount_total;
2563
- }
2564
- Object.defineProperty(EsolveCartTotals.prototype, "total", {
2565
- /**
2566
- * Grand total of cart which includes discount and VAT (NOTE: shipping and insurance is not included)
2567
- */
2568
- get: function () {
2569
- return this.sub_total + this.vat_total - this.discount_total;
2570
- },
2571
- enumerable: false,
2572
- configurable: true
2573
- });
2574
- return EsolveCartTotals;
2575
- }());
2576
-
2577
- var EsolveCartStockItem = /** @class */ (function () {
2578
- function EsolveCartStockItem(code, name, sef_name, description, active, items_in_pack, delivery_category, image_name) {
2579
- this.code = code;
2580
- this.name = name;
2581
- this.sef_name = sef_name;
2582
- this.description = description;
2583
- this.active = active;
2584
- this.items_in_pack = items_in_pack;
2585
- this.delivery_category = delivery_category;
2586
- this.image_name = image_name;
2587
- }
2588
- Object.defineProperty(EsolveCartStockItem.prototype, "tiny_image_src", {
2589
- /**
2590
- * Path to tiny stock image
2591
- */
2592
- get: function () {
2593
- return '/images/' + (this.image_name ? 'stock/tiny/' + this.image_name : 'no_image.jpg');
2594
- },
2595
- enumerable: false,
2596
- configurable: true
2597
- });
2598
- Object.defineProperty(EsolveCartStockItem.prototype, "thumbnail_image_src", {
2599
- /**
2600
- * Path to thumbnail stock image
2601
- */
2602
- get: function () {
2603
- return '/images/' + (this.image_name ? 'stock/thumb/' + this.image_name : 'no_image.jpg');
2604
- },
2605
- enumerable: false,
2606
- configurable: true
2607
- });
2608
- Object.defineProperty(EsolveCartStockItem.prototype, "small_image_src", {
2609
- /**
2610
- * Path to small stock image
2611
- */
2612
- get: function () {
2613
- return '/images/' + (this.image_name ? 'stock/small/' + this.image_name : 'no_image.jpg');
2614
- },
2615
- enumerable: false,
2616
- configurable: true
2617
- });
2618
- Object.defineProperty(EsolveCartStockItem.prototype, "big_image_src", {
2619
- /**
2620
- * Path to big stock image
2621
- */
2622
- get: function () {
2623
- return '/images/' + (this.image_name ? 'stock/big/' + this.image_name : 'no_image.jpg');
2624
- },
2625
- enumerable: false,
2626
- configurable: true
2627
- });
2628
- Object.defineProperty(EsolveCartStockItem.prototype, "original_image_src", {
2629
- /**
2630
- * Path to original stock image
2631
- */
2632
- get: function () {
2633
- return 'images/' + (this.image_name ? 'stock/original/' + this.image_name : 'no_image.jpg');
2634
- },
2635
- enumerable: false,
2636
- configurable: true
2637
- });
2638
- return EsolveCartStockItem;
2639
- }());
2640
-
2641
- var EsolveCartService = /** @class */ (function () {
2642
- function EsolveCartService(config, http, errorHandler) {
2643
- this.config = config;
2644
- this.http = http;
2645
- this.errorHandler = errorHandler;
2646
- this._cached_tracking = 0;
2647
- }
2648
- /**
2649
- * Processes the eSolve tree records.
2650
- * @param cart_item_records Records to process
2651
- * @returns An array of processed cart items
2652
- */
2653
- EsolveCartService.prototype.processCart = function (cart_item_records) {
2654
- var e_1, _a;
2655
- var cart_items = [];
2656
- if (cart_item_records) {
2657
- try {
2658
- for (var cart_item_records_1 = __values(cart_item_records), cart_item_records_1_1 = cart_item_records_1.next(); !cart_item_records_1_1.done; cart_item_records_1_1 = cart_item_records_1.next()) {
2659
- var cart_item_record = cart_item_records_1_1.value;
2660
- var cart_stock_item = new EsolveCartStockItem(cart_item_record.code, cart_item_record.name, cart_item_record.sef_name, cart_item_record.description, cart_item_record.is_active, +cart_item_record.items_in_pack, cart_item_record.delivery_category, cart_item_record.image_name);
2661
- cart_items.push(new EsolveCartItem(+cart_item_record.id, cart_stock_item, +cart_item_record.qty, cart_item_record.type, +cart_item_record.price, +cart_item_record.discount, +cart_item_record.discount_interval, cart_item_record.vat_rate, cart_item_record.allow_quotes, cart_item_record.allow_orders, cart_item_record.must_collect, cart_item_record.requested_assembly, +cart_item_record.price_incl, +cart_item_record.discount_price, +cart_item_record.discount_price_incl, +cart_item_record.discount_total, +cart_item_record.vat_total, +cart_item_record.line_total, +cart_item_record.line_total_incl));
2662
- }
2663
- }
2664
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
2665
- finally {
2666
- try {
2667
- if (cart_item_records_1_1 && !cart_item_records_1_1.done && (_a = cart_item_records_1.return)) _a.call(cart_item_records_1);
2668
- }
2669
- finally { if (e_1) throw e_1.error; }
2670
- }
2671
- }
2672
- return cart_items;
2673
- };
2674
- /**
2675
- * Processes the eSolve stock location records.
2676
- * @param records Records to process
2677
- * @returns An array of processed stock location records
2678
- */
2679
- EsolveCartService.prototype.processStockLocations = function (records) {
2680
- var e_2, _a;
2681
- var stock_locations = [];
2682
- if (records) {
2683
- try {
2684
- for (var records_1 = __values(records), records_1_1 = records_1.next(); !records_1_1.done; records_1_1 = records_1.next()) {
2685
- var record = records_1_1.value;
2686
- stock_locations.push(new EsolveStockLocation(record));
2687
- }
2688
- }
2689
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
2690
- finally {
2691
- try {
2692
- if (records_1_1 && !records_1_1.done && (_a = records_1.return)) _a.call(records_1);
2693
- }
2694
- finally { if (e_2) throw e_2.error; }
2695
- }
2696
- }
2697
- return stock_locations;
2698
- };
2699
- /**
2700
- * Processes the eSolve shipping method records.
2701
- * @param records Records to process
2702
- * @returns An array of processed shipping methods
2703
- */
2704
- EsolveCartService.prototype.processShippingMethods = function (records) {
2705
- var e_3, _a;
2706
- var shipping_methods = [];
2707
- if (records) {
2708
- try {
2709
- for (var records_2 = __values(records), records_2_1 = records_2.next(); !records_2_1.done; records_2_1 = records_2.next()) {
2710
- var record = records_2_1.value;
2711
- var shipping_method = new EsolveShippingMethod(+record.id, record.carrier_name, record.delivery_category, record.description, record.location, record.pricing, record.link_to_carrier_website, +record.days_to_deliver, record.shipping_cost_calculation_method, record.insurance_cost_calculation_method, +record.insurance_cost_percentage, +record.metric_factor, record.allow_immediate_payment_processing, record.allow_postal_address, record.allow_physical_address, record.client_to_collect, record.is_default_shipping_method, +record.location_id, record.use_zones, +record.min_distance, +record.max_distance, +record.shipping_surge_condition, +record.shipping_surge_percentage, +record.sort_priority, record.shipping_group, record.shipping_slot_identifier, +record.shipping_slot_delay_hours, record.image_url);
2712
- shipping_methods.push(shipping_method);
2713
- }
2714
- }
2715
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
2716
- finally {
2717
- try {
2718
- if (records_2_1 && !records_2_1.done && (_a = records_2.return)) _a.call(records_2);
2719
- }
2720
- finally { if (e_3) throw e_3.error; }
2721
- }
2722
- }
2723
- return shipping_methods;
2724
- };
2725
- /**
2726
- * Processes the eSolve payment method records.
2727
- * @param records Records to process
2728
- * @returns An array of processed payment methods.
2729
- */
2730
- EsolveCartService.prototype.processPaymentMethods = function (records) {
2731
- var e_4, _a;
2732
- var payment_methods = [];
2733
- if (records) {
2734
- try {
2735
- for (var records_3 = __values(records), records_3_1 = records_3.next(); !records_3_1.done; records_3_1 = records_3.next()) {
2736
- var record = records_3_1.value;
2737
- var payment_method = new EsolvePaymentMethod(record);
2738
- payment_methods.push(payment_method);
2739
- }
2740
- }
2741
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
2742
- finally {
2743
- try {
2744
- if (records_3_1 && !records_3_1.done && (_a = records_3.return)) _a.call(records_3);
2745
- }
2746
- finally { if (e_4) throw e_4.error; }
2747
- }
2748
- }
2749
- return payment_methods;
2750
- };
2751
- /**
2752
- * Processes the eSolve shipping costs record.
2753
- * @param record Data to process
2754
- * @returns Processed shipping costs
2755
- */
2756
- EsolveCartService.prototype.processShippingCost = function (record) {
2757
- var shipping_cost = new EsolveShippingCost(+record.shipping_total, +record.vat_on_shipping, +record.total_saving_on_shipping, +record.insurance_total, +record.vat_on_insurance, +record.total_saving_on_insurance);
2758
- return shipping_cost;
2759
- };
2760
- /**
2761
- * Processes the eSolve cart totals
2762
- * @param record Data to process
2763
- * @returns Processed cart totals
2764
- */
2765
- EsolveCartService.prototype.processCartTotals = function (record) {
2766
- var cart_totals = new EsolveCartTotals(+record.records, +record.items, +record.total, +record.vat, +record.discount);
2767
- return cart_totals;
2768
- };
2769
- /**
2770
- * Retrieves the current cart
2771
- * @returns An `Observable` with an array of cart items
2772
- */
2773
- EsolveCartService.prototype.getCart = function () {
2774
- var _this = this;
2775
- var params = new i1.HttpParams();
2776
- params = params.set('ws_id', this.config.wsid);
2777
- return this.http.get(this.config.api_url + "/service/get-cart.php", { params: params }).pipe(operators.map(function (response) {
2778
- if (response.records === undefined) {
2779
- throw response;
2780
- }
2781
- return _this.processCart(response.records);
2782
- }));
2783
- };
2784
- /**
2785
- * Updates the cart by preforming various actions, such as adding, editing or removing items from the cart.
2786
- * @param items An array of options to update the cart
2787
- * @param action The default action to preform
2788
- * @returns An `Observable` with an array of responses that gives feedback on the requested changes
2789
- */
2790
- EsolveCartService.prototype.setCart = function (items, action) {
2791
- if (action === void 0) { action = 'add'; }
2792
- var body = {
2793
- items: items,
2794
- action: action
2795
- };
2796
- return this.http.post(this.config.api_url + "/service/set-cart-item.php", body, {
2797
- headers: {
2798
- 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;'
2799
- },
2800
- params: {
2801
- ws_id: this.config.wsid
2802
- },
2803
- responseType: 'json',
2804
- observe: 'body'
2805
- }).pipe(operators.map(function (response) {
2806
- if (response.responses === undefined) {
2807
- throw response;
2808
- }
2809
- return response.responses;
2810
- }));
2811
- };
2812
- /**
2813
- * Retrieves a list of stock locations
2814
- * @returns An `Observable` with an array of stock locations
2815
- */
2816
- EsolveCartService.prototype.getStockLocations = function () {
2817
- var _this = this;
2818
- var params = new i1.HttpParams();
2819
- params = params.set('ws_id', this.config.wsid);
2820
- return this.http.get(this.config.api_url + "/service/get-locations.php", { params: params }).pipe(operators.map(function (response) {
2821
- if (response.records === undefined) {
2822
- throw response;
2823
- }
2824
- return _this.processStockLocations(response.records);
2825
- }));
2826
- };
2827
- /**
2828
- * Retrieves a list of shipping methods
2829
- * @returns An `Observable` with an array of shipping methods
2830
- */
2831
- EsolveCartService.prototype.getShippingMethods = function (options) {
2832
- var _this = this;
2833
- var params = new i1.HttpParams();
2834
- params = params.set('ws_id', this.config.wsid);
2835
- if (options) {
2836
- if (typeof options.addresses_id !== 'undefined') {
2837
- params = params.set('addresses_id', options.addresses_id.toString());
2838
- }
2839
- if (typeof options.location_id !== 'undefined') {
2840
- params = params.set('location_id', options.location_id.toString());
2841
- }
2842
- }
2843
- return this.http.get(this.config.api_url + "/service/get-shipping-methods.php", { params: params }).pipe(operators.map(function (response) {
2844
- if (response.records === undefined) {
2845
- throw response;
2846
- }
2847
- return _this.processShippingMethods(response.records);
2848
- }));
2849
- };
2850
- /**
2851
- * Retrieves a list of payment methods
2852
- * @returns An `Observable` with an array of payment methods
2853
- */
2854
- EsolveCartService.prototype.getPaymentMethods = function (options) {
2855
- var _this = this;
2856
- var params = new i1.HttpParams();
2857
- params = params.set('ws_id', this.config.wsid);
2858
- if (options) {
2859
- if (typeof options.live !== 'undefined') {
2860
- params = params.set('live', options.live.toString());
2861
- }
2862
- if (typeof options.location_id !== 'undefined') {
2863
- params = params.set('location_id', options.location_id.toString());
2864
- }
2865
- if (typeof options.is_gateway !== 'undefined') {
2866
- params = params.set('is_gateway', options.is_gateway.toString());
2867
- }
2868
- }
2869
- return this.http.get(this.config.api_url + "/service/get-payment-methods.php", { params: params }).pipe(operators.map(function (response) {
2870
- if (response.records === undefined) {
2871
- throw response;
2872
- }
2873
- return _this.processPaymentMethods(response.records);
2874
- }));
2875
- };
2876
- /**
2877
- * Retrieves the shipping costs
2878
- * @param options Shipping cost options
2879
- * @returns An `Observable` with the shipping costs
2880
- */
2881
- EsolveCartService.prototype.getShippingCost = function (options) {
2882
- var _this = this;
2883
- var params = new i1.HttpParams();
2884
- params = params.set('ws_id', this.config.wsid);
2885
- if (options) {
2886
- if (typeof options.addresses_id !== 'undefined') {
2887
- params = params.set('addresses_id', options.addresses_id.toString());
2888
- }
2889
- else {
2890
- return rxjs.throwError(new Error('Address ID is required'));
2891
- }
2892
- if (typeof options.shipping_id !== 'undefined') {
2893
- params = params.set('shipping_id', options.shipping_id.toString());
2894
- }
2895
- else {
2896
- return rxjs.throwError(new Error('Shipping ID is required'));
2897
- }
2898
- if (typeof options.location_id !== 'undefined') {
2899
- params = params.set('location_id', options.location_id.toString());
2900
- }
2901
- }
2902
- else {
2903
- return rxjs.throwError(new Error('Options are invalid'));
2904
- }
2905
- return this.http.get(this.config.api_url + "/service/get-shipping-cost.php", { params: params }).pipe(operators.map(function (response) {
2906
- if (response.records === undefined) {
2907
- throw response;
2908
- }
2909
- return _this.processShippingCost(response.records[0]);
2910
- }));
2911
- };
2912
- /**
2913
- * Retrieves the totals of the cart with all the totals calculated
2914
- * @returns An `Observable` with an object containing cart totals
2915
- */
2916
- EsolveCartService.prototype.getTotals = function () {
2917
- var _this = this;
2918
- var params = new i1.HttpParams();
2919
- params = params.set('ws_id', this.config.wsid);
2920
- return this.http.get(this.config.api_url + "/service/get-cart-totals.php", { params: params }).pipe(operators.map(function (response) {
2921
- if (response.records === undefined) {
2922
- throw response;
2923
- }
2924
- return _this.processCartTotals(response.records);
2925
- }));
2926
- };
2927
- /**
2928
- * Retrieves a tracking code for the cart
2929
- * @returns An `Observable` with the cart tracking code
2930
- */
2931
- EsolveCartService.prototype.getTrackingCode = function () {
2932
- var _this = this;
2933
- var params = new i1.HttpParams();
2934
- params = params.set('ws_id', this.config.wsid);
2935
- return rxjs.iif(function () { return _this._cached_tracking > 0; }, rxjs.of(this._cached_tracking), this.http.get(this.config.api_url + "/service/get-checkout-tracking.php", { params: params }).pipe(operators.map(function (response) {
2936
- if (response.records === undefined) {
2937
- throw response;
2938
- }
2939
- _this._cached_tracking = response.records.tracking;
2940
- return response.records.tracking;
2941
- })));
2942
- };
2943
- /**
2944
- * Initiates checkout of the cart items
2945
- * @param type The cart type that needs to be checked out
2946
- * @param addresses_id The ID of the delivery address
2947
- * @param shipping_id The ID of the shipping method
2948
- * @param payment_method_id The ID of the selected payment method
2949
- * @param location_id The ID of the selected branch from with shipping needs to be calculated
2950
- * @param comments Additional comments on the cart
2951
- * @returns An `Observable` with the transaction ID
2952
- */
2953
- EsolveCartService.prototype.checkout = function (type, addresses_id, shipping_id, payment_method_id, location_id, comments) {
2954
- var _this = this;
2955
- if (payment_method_id === void 0) { payment_method_id = 0; }
2956
- if (location_id === void 0) { location_id = 0; }
2957
- if (comments === void 0) { comments = ''; }
2958
- var body = {
2959
- type: type,
2960
- addresses_id: addresses_id,
2961
- shipping_id: shipping_id,
2962
- payment_method_id: payment_method_id,
2963
- location_id: location_id,
2964
- comments: comments,
2965
- tracking: 0
2966
- };
2967
- return this.getTrackingCode().pipe(operators.switchMap(function (tracking) {
2968
- if (tracking <= 0) {
2969
- throw tracking;
2970
- }
2971
- body.tracking = tracking;
2972
- return _this.http.post(_this.config.api_url + "/service/set-checkout.php", body, {
2973
- headers: {
2974
- 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;'
2975
- },
2976
- params: {
2977
- ws_id: _this.config.wsid
2978
- },
2979
- responseType: 'json',
2980
- observe: 'body'
2981
- }).pipe(operators.map(function (response) {
2982
- if ((response.responses === undefined) || (response.responses.length <= 0)) {
2983
- throw response;
2984
- }
2985
- var checkout_result = response.responses[0];
2986
- if (checkout_result.status.state !== 'success') {
2987
- throw checkout_result;
2988
- }
2989
- return checkout_result.esolve_id;
2990
- }), operators.catchError(function (errorRes) {
2991
- return _this.errorHandler.handleHttpError('set-checkout', errorRes);
2992
- }));
2993
- }));
2994
- };
2995
- return EsolveCartService;
2996
- }());
2997
- EsolveCartService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.0", ngImport: i0__namespace, type: EsolveCartService, deps: [{ token: ESOLVE_CONNECT_CONFIG }, { token: i1__namespace$1.HttpClient }, { token: EsolveErrorHandlerService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
2998
- EsolveCartService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.0", ngImport: i0__namespace, type: EsolveCartService, providedIn: 'root' });
2999
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.0", ngImport: i0__namespace, type: EsolveCartService, decorators: [{
3000
- type: i0.Injectable,
3001
- args: [{
3002
- providedIn: 'root'
3003
- }]
3004
- }], ctorParameters: function () {
3005
- return [{ type: undefined, decorators: [{
3006
- type: i0.Inject,
3007
- args: [ESOLVE_CONNECT_CONFIG]
3008
- }] }, { type: i1__namespace$1.HttpClient }, { type: EsolveErrorHandlerService }];
3009
- } });
3010
-
3011
- /*
3012
- * Public API Surface of ng-esolve-connect
3013
- */
3014
-
3015
- /**
3016
- * Generated bundle index. Do not edit.
3017
- */
3018
-
3019
- exports.BankingDetails = BankingDetails;
3020
- exports.EsolveAccountService = EsolveAccountService;
3021
- exports.EsolveAddress = EsolveAddress;
3022
- exports.EsolveAuthService = EsolveAuthService;
3023
- exports.EsolveBanner = EsolveBanner;
3024
- exports.EsolveBannerImage = EsolveBannerImage;
3025
- exports.EsolveBannerImageHotspot = EsolveBannerImageHotspot;
3026
- exports.EsolveBannerService = EsolveBannerService;
3027
- exports.EsolveCartItem = EsolveCartItem;
3028
- exports.EsolveCartService = EsolveCartService;
3029
- exports.EsolveCartTotals = EsolveCartTotals;
3030
- exports.EsolveCategoryTreeItem = EsolveCategoryTreeItem;
3031
- exports.EsolveCategoryTreeService = EsolveCategoryTreeService;
3032
- exports.EsolveErrorHandlerService = EsolveErrorHandlerService;
3033
- exports.EsolveHttpError = EsolveHttpError;
3034
- exports.EsolveMediaArticle = EsolveMediaArticle;
3035
- exports.EsolveMediaService = EsolveMediaService;
3036
- exports.EsolveMenuItem = EsolveMenuItem;
3037
- exports.EsolveMenuService = EsolveMenuService;
3038
- exports.EsolveNewsArticle = EsolveNewsArticle;
3039
- exports.EsolveNewsArticleAuthor = EsolveNewsArticleAuthor;
3040
- exports.EsolveNewsArticleList = EsolveNewsArticleList;
3041
- exports.EsolveNewsGroup = EsolveNewsGroup;
3042
- exports.EsolveNewsService = EsolveNewsService;
3043
- exports.EsolvePaymentMethod = EsolvePaymentMethod;
3044
- exports.EsolveSEOInfo = EsolveSEOInfo;
3045
- exports.EsolveSeoService = EsolveSeoService;
3046
- exports.EsolveSession = EsolveSession;
3047
- exports.EsolveSessionService = EsolveSessionService;
3048
- exports.EsolveShippingCost = EsolveShippingCost;
3049
- exports.EsolveShippingMethod = EsolveShippingMethod;
3050
- exports.EsolveStockBadge = EsolveStockBadge;
3051
- exports.EsolveStockItem = EsolveStockItem;
3052
- exports.EsolveStockItemList = EsolveStockItemList;
3053
- exports.EsolveStockLocation = EsolveStockLocation;
3054
- exports.EsolveStockPrice = EsolveStockPrice;
3055
- exports.EsolveStockService = EsolveStockService;
3056
- exports.EsolveTag = EsolveTag;
3057
- exports.EsolveTopic = EsolveTopic;
3058
- exports.EsolveTopicService = EsolveTopicService;
3059
- exports.NgEsolveConnectModule = NgEsolveConnectModule;
3060
-
3061
- Object.defineProperty(exports, '__esModule', { value: true });
3062
-
3063
- })));
3064
- //# sourceMappingURL=esolve-ng-esolve-connect.umd.js.map