@esolve/ng-esolve-connect 0.7.5 → 0.10.0

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 (66) hide show
  1. package/esm2020/lib/account/esolve-account.service.mjs +160 -36
  2. package/esm2020/lib/account/esolve-change-password-result.mjs +8 -0
  3. package/esm2020/lib/account/esolve-forgot-password-response.mjs +2 -0
  4. package/esm2020/lib/account/esolve-reset-password-result.mjs +11 -0
  5. package/esm2020/lib/account/esolve-transaction-list.mjs +4 -0
  6. package/esm2020/lib/account/esolve-transaction-options.mjs +2 -0
  7. package/esm2020/lib/account/esolve-transaction-record.mjs +2 -0
  8. package/esm2020/lib/account/esolve-transaction.mjs +145 -0
  9. package/esm2020/lib/auth/esolve-auth-interceptor.service.mjs +1 -1
  10. package/esm2020/lib/auth/esolve-auth.service.mjs +25 -25
  11. package/esm2020/lib/banners/esolve-banner.service.mjs +26 -26
  12. package/esm2020/lib/cart/esolve-cart.service.mjs +25 -25
  13. package/esm2020/lib/category-tree/esolve-category-tree-item-options.mjs +2 -0
  14. package/esm2020/lib/category-tree/esolve-category-tree.service.mjs +45 -45
  15. package/esm2020/lib/locations/esolve-locations.service.mjs +15 -15
  16. package/esm2020/lib/locations/esolve-stock-location-record.mjs +1 -1
  17. package/esm2020/lib/locations/esolve-stock-location.mjs +16 -16
  18. package/esm2020/lib/media/esolve-media.service.mjs +25 -25
  19. package/esm2020/lib/menu/esolve-menu.service.mjs +1 -1
  20. package/esm2020/lib/news/esolve-news-article-options.mjs +2 -0
  21. package/esm2020/lib/news/esolve-news.service.mjs +1 -1
  22. package/esm2020/lib/payment/esolve-payment-method-record.mjs +1 -1
  23. package/esm2020/lib/payment/esolve-payment-method.mjs +1 -5
  24. package/esm2020/lib/payment/esolve-payment.service.mjs +21 -1
  25. package/esm2020/lib/shared/error-handler/esolve-error-handler.service.mjs +57 -24
  26. package/esm2020/lib/shared/esolve-list.mjs +9 -0
  27. package/esm2020/lib/shared/esolve-response.mjs +1 -1
  28. package/esm2020/lib/shared/esolve-result.mjs +8 -0
  29. package/esm2020/lib/stock/esolve-stock-item-options.mjs +1 -1
  30. package/esm2020/lib/stock/esolve-stock.service.mjs +4 -1
  31. package/esm2020/lib/topics/esolve-topic.service.mjs +11 -11
  32. package/esm2020/public-api.mjs +16 -3
  33. package/fesm2015/esolve-ng-esolve-connect.mjs +670 -322
  34. package/fesm2015/esolve-ng-esolve-connect.mjs.map +1 -1
  35. package/fesm2020/esolve-ng-esolve-connect.mjs +672 -321
  36. package/fesm2020/esolve-ng-esolve-connect.mjs.map +1 -1
  37. package/lib/account/esolve-account.service.d.ts +18 -6
  38. package/lib/account/esolve-change-password-result.d.ts +6 -0
  39. package/lib/account/esolve-forgot-password-response.d.ts +7 -0
  40. package/lib/account/esolve-reset-password-result.d.ts +9 -0
  41. package/lib/account/esolve-transaction-list.d.ts +4 -0
  42. package/lib/account/esolve-transaction-options.d.ts +8 -0
  43. package/lib/account/esolve-transaction-record.d.ts +98 -0
  44. package/lib/account/esolve-transaction.d.ts +132 -0
  45. package/lib/auth/esolve-auth.service.d.ts +1 -1
  46. package/lib/banners/esolve-banner.service.d.ts +6 -6
  47. package/lib/cart/esolve-cart.service.d.ts +12 -12
  48. package/lib/category-tree/esolve-category-tree-item-options.d.ts +18 -0
  49. package/lib/category-tree/esolve-category-tree.service.d.ts +8 -26
  50. package/lib/locations/esolve-locations.service.d.ts +5 -5
  51. package/lib/locations/esolve-stock-location-record.d.ts +1 -1
  52. package/lib/locations/esolve-stock-location.d.ts +7 -8
  53. package/lib/media/esolve-media.service.d.ts +7 -7
  54. package/lib/news/esolve-news-article-options.d.ts +11 -0
  55. package/lib/news/esolve-news.service.d.ts +1 -12
  56. package/lib/payment/esolve-payment-method-record.d.ts +0 -4
  57. package/lib/payment/esolve-payment-method.d.ts +0 -4
  58. package/lib/payment/esolve-payment.service.d.ts +2 -0
  59. package/lib/shared/error-handler/esolve-error-handler.service.d.ts +8 -2
  60. package/lib/shared/esolve-list.d.ts +7 -0
  61. package/lib/shared/esolve-response.d.ts +15 -9
  62. package/lib/shared/esolve-result.d.ts +6 -0
  63. package/lib/stock/esolve-stock-item-options.d.ts +1 -0
  64. package/lib/topics/esolve-topic.service.d.ts +1 -1
  65. package/package.json +1 -1
  66. package/public-api.d.ts +15 -2
@@ -7,7 +7,7 @@ import * as i4 from 'ngx-cookie-service';
7
7
  import { CookieService } from 'ngx-cookie-service';
8
8
  import { BehaviorSubject, throwError, iif, of } from 'rxjs';
9
9
  import * as i1 from '@angular/platform-browser';
10
- import { map, tap, catchError, switchMap } from 'rxjs/operators';
10
+ import { tap, catchError, map, switchMap } from 'rxjs/operators';
11
11
 
12
12
  const ESOLVE_CONNECT_CONFIG = new InjectionToken('esolve.connect.config');
13
13
  // For future development
@@ -199,6 +199,23 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImpor
199
199
  }]
200
200
  }] });
201
201
 
202
+ class EsolveList {
203
+ constructor(items = [], page = 0, rows = 0, total = 0) {
204
+ this.items = items;
205
+ this.page = page;
206
+ this.rows = rows;
207
+ this.total = total;
208
+ }
209
+ }
210
+
211
+ class EsolveResult {
212
+ constructor(status, code, message) {
213
+ this.status = status;
214
+ this.code = code;
215
+ this.message = message;
216
+ }
217
+ }
218
+
202
219
  class EsolveHttpError {
203
220
  constructor(type, message, error_code) {
204
221
  this.type = type;
@@ -209,11 +226,65 @@ class EsolveHttpError {
209
226
 
210
227
  class EsolveErrorHandlerService {
211
228
  constructor() { }
229
+ emitError(code, message) {
230
+ throw new EsolveHttpError('error', message, code);
231
+ }
232
+ handleHttpPostError(service_type, errorRes) {
233
+ if (!(errorRes instanceof HttpErrorResponse) &&
234
+ !('service_type' in errorRes) &&
235
+ (('id' in errorRes) &&
236
+ ('esolve_id' in errorRes) &&
237
+ ('transaction_type' in errorRes) &&
238
+ ('status' in errorRes) &&
239
+ ('log' in errorRes))) {
240
+ return throwError(this.parsePostErrors(errorRes));
241
+ }
242
+ return this.handleHttpError(service_type, errorRes);
243
+ }
244
+ handleHttpDeleteError(service_type, errorRes) {
245
+ const is_not_base = (!(errorRes instanceof HttpErrorResponse) &&
246
+ !('service_type' in errorRes) &&
247
+ (('id' in errorRes) &&
248
+ ('status' in errorRes) &&
249
+ ('message' in errorRes) &&
250
+ ('code' in errorRes)));
251
+ if (is_not_base) {
252
+ return throwError(this.parseDeleteError(errorRes));
253
+ }
254
+ return this.handleHttpError(service_type, errorRes);
255
+ }
256
+ handleHttpError(service_type, errorRes) {
257
+ if (errorRes instanceof HttpErrorResponse) {
258
+ if (errorRes.status === 500) {
259
+ const server_error = errorRes.error;
260
+ if (('service_type' in server_error) &&
261
+ (server_error.service_type === service_type)) {
262
+ return throwError(this.parseException(server_error));
263
+ }
264
+ }
265
+ }
266
+ else {
267
+ if (('service_type' in errorRes) &&
268
+ (errorRes.service_type === service_type)) {
269
+ if (errorRes.type === 'exception') {
270
+ return throwError(this.parseException(errorRes));
271
+ }
272
+ else if (errorRes.type === 'error') {
273
+ return throwError(this.parseResponseError(errorRes));
274
+ }
275
+ }
276
+ }
277
+ return throwError(errorRes);
278
+ }
212
279
  parseException(exception) {
213
280
  const error = new EsolveHttpError('exception', exception.message || 'Unknown exception has occurred', exception.additional_data.exception_type || 'unknown');
214
281
  return error;
215
282
  }
216
- parseErrors(response) {
283
+ parseResponseError(exception) {
284
+ const error = new EsolveHttpError('error', exception.message || 'Unknown error has occurred', exception.code || 'unknown');
285
+ return error;
286
+ }
287
+ parsePostErrors(response) {
217
288
  const error = new EsolveHttpError('error', 'Unknown error has occurred', 'unknown');
218
289
  if ((response.status.state === 'none') && (response.log.length > 0)) {
219
290
  error.error_code = 'no_response';
@@ -226,29 +297,8 @@ class EsolveErrorHandlerService {
226
297
  }
227
298
  return error;
228
299
  }
229
- handleHttpPostError(service_type, errorRes) {
230
- if (errorRes instanceof HttpErrorResponse) {
231
- if (errorRes.status === 500) {
232
- const server_error = errorRes.error;
233
- if ((server_error.service_type === service_type) ||
234
- (server_error.type !== undefined) ||
235
- (server_error.message !== undefined) ||
236
- (server_error.additional_data !== undefined)) {
237
- return throwError(this.parseException(server_error));
238
- }
239
- }
240
- }
241
- else {
242
- if (errorRes.type !== undefined) {
243
- if ((errorRes.type === 'exception') || (errorRes.type === 'error')) {
244
- return throwError(this.parseException(errorRes));
245
- }
246
- }
247
- else if (errorRes.transaction_type !== undefined) {
248
- return throwError(this.parseErrors(errorRes));
249
- }
250
- }
251
- return throwError(errorRes);
300
+ parseDeleteError(result) {
301
+ return new EsolveHttpError('error', result.message, result.code);
252
302
  }
253
303
  }
254
304
  EsolveErrorHandlerService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: EsolveErrorHandlerService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
@@ -429,31 +479,6 @@ class EsolveAuthService {
429
479
  this.errorHandler = errorHandler;
430
480
  this.cookieService = cookieService;
431
481
  }
432
- checkAccessToken(session) {
433
- var _a;
434
- session = session || this.session.currentSession;
435
- const token = (_a = session === null || session === void 0 ? void 0 : session.key) !== null && _a !== void 0 ? _a : '';
436
- const params = new HttpParams({
437
- fromObject: {
438
- key: token,
439
- ws_id: this.config.wsid
440
- }
441
- });
442
- return this.http.get(`${this.config.api_url}/service/get-access-token.php`, {
443
- params,
444
- headers: new HttpHeaders({
445
- 'Accept-Language': '*'
446
- })
447
- }).pipe(map(responseData => {
448
- if ((responseData.type === 'error') ||
449
- (responseData.type === 'exception') ||
450
- (!responseData.additional_data.key_okay)) {
451
- throw responseData;
452
- }
453
- responseData.additional_data.key = token;
454
- return responseData;
455
- })).toPromise();
456
- }
457
482
  getAccessToken(email, password, anonymous = false) {
458
483
  let params = new HttpParams();
459
484
  if (anonymous) {
@@ -529,6 +554,31 @@ class EsolveAuthService {
529
554
  this.cookieService.delete('_ws_id');
530
555
  return this.getAccessToken('', '', true).toPromise();
531
556
  }
557
+ checkAccessToken(session) {
558
+ var _a;
559
+ session = session || this.session.currentSession;
560
+ const token = (_a = session === null || session === void 0 ? void 0 : session.key) !== null && _a !== void 0 ? _a : '';
561
+ const params = new HttpParams({
562
+ fromObject: {
563
+ key: token,
564
+ ws_id: this.config.wsid
565
+ }
566
+ });
567
+ return this.http.get(`${this.config.api_url}/service/get-access-token.php`, {
568
+ params,
569
+ headers: new HttpHeaders({
570
+ 'Accept-Language': '*'
571
+ })
572
+ }).pipe(map(responseData => {
573
+ if ((responseData.type === 'error') ||
574
+ (responseData.type === 'exception') ||
575
+ (!responseData.additional_data.key_okay)) {
576
+ throw responseData;
577
+ }
578
+ responseData.additional_data.key = token;
579
+ return responseData;
580
+ })).toPromise();
581
+ }
532
582
  // Handlers
533
583
  handleExpiration() {
534
584
  return (session) => {
@@ -643,6 +693,229 @@ class EsolveUserAccountResult extends EsolveResponseResult {
643
693
  }
644
694
  }
645
695
 
696
+ class EsolveStockLocation {
697
+ constructor(record) {
698
+ this.id = +record.id;
699
+ this.identifier = record.identifier;
700
+ this.description = record.description;
701
+ this.head_office = record.head_office;
702
+ this.erp_identifier = record.erp_identifier;
703
+ this.external_system_code = record.external_system_code;
704
+ this.default_location_for_payment_methods = record.default_location_for_payment_methods;
705
+ this.userid = +record.userid;
706
+ this.importance = +record.importance;
707
+ this.active = record.is_active;
708
+ this.website_url = record.website_url;
709
+ this.address = new EsolveStockLocationAddress(record.street, record.suburb, record.city, record.province, record.country, record.postal_code, +record.latitude, +record.longitude);
710
+ this.pobox_address = new EsolveStockLocationPOBoxAddress(record.pobox, record.pobox_city, record.pobox_postal_code);
711
+ const telnumbers = [];
712
+ if (record.branch_telnumber.length > 0) {
713
+ telnumbers.push(record.branch_telnumber);
714
+ }
715
+ if (record.branch_telnumber_2.length > 0) {
716
+ telnumbers.push(record.branch_telnumber_2);
717
+ }
718
+ if (record.branch_telnumber_3.length > 0) {
719
+ telnumbers.push(record.branch_telnumber_3);
720
+ }
721
+ this.contact_info = new EsolveStockLocationContactInfo(telnumbers, record.branch_cellnumber, record.branch_email, record.branch_fax);
722
+ this.trading_times = new EsolveStockLocationTradingTimes(new EsolveStockLocationTradingTimesDay(record.monday_open_time, record.monday_close_time), new EsolveStockLocationTradingTimesDay(record.tuesday_open_time, record.tuesday_close_time), new EsolveStockLocationTradingTimesDay(record.wednesday_open_time, record.wednesday_close_time), new EsolveStockLocationTradingTimesDay(record.thursday_open_time, record.thursday_close_time), new EsolveStockLocationTradingTimesDay(record.friday_open_time, record.friday_close_time), new EsolveStockLocationTradingTimesDay(record.saturday_open_time, record.saturday_close_time), new EsolveStockLocationTradingTimesDay(record.sunday_open_time, record.sunday_close_time), new EsolveStockLocationTradingTimesDay(record.public_holiday_open_time, record.public_holiday_close_time), record.trading_hours_additional_info);
723
+ }
724
+ }
725
+ class EsolveStockLocationAddress {
726
+ constructor(street, suburb, city, province, country, postal_code, latitude, longitude) {
727
+ this.street = street;
728
+ this.suburb = suburb;
729
+ this.city = city;
730
+ this.province = province;
731
+ this.country = country;
732
+ this.postal_code = postal_code;
733
+ this.latitude = latitude;
734
+ this.longitude = longitude;
735
+ }
736
+ }
737
+ class EsolveStockLocationPOBoxAddress {
738
+ constructor(pobox, city, postal_code) {
739
+ this.pobox = pobox;
740
+ this.city = city;
741
+ this.postal_code = postal_code;
742
+ }
743
+ }
744
+ class EsolveStockLocationContactInfo {
745
+ constructor(telnumber, cellnumber, email, fax) {
746
+ this.telnumber = telnumber;
747
+ this.cellnumber = cellnumber;
748
+ this.email = email;
749
+ this.fax = fax;
750
+ }
751
+ }
752
+ class EsolveStockLocationTradingTimes {
753
+ constructor(monday, tuesday, wednesday, thursday, friday, saturday, sunday, public_holiday, trading_hours_additional_info = '') {
754
+ this.monday = monday;
755
+ this.tuesday = tuesday;
756
+ this.wednesday = wednesday;
757
+ this.thursday = thursday;
758
+ this.friday = friday;
759
+ this.saturday = saturday;
760
+ this.sunday = sunday;
761
+ this.public_holiday = public_holiday;
762
+ this.trading_hours_additional_info = trading_hours_additional_info;
763
+ }
764
+ }
765
+ class EsolveStockLocationTradingTimesDay {
766
+ constructor(open, close) {
767
+ this.open = open;
768
+ this.close = close;
769
+ }
770
+ }
771
+
772
+ class EsolveTransaction {
773
+ constructor(record) {
774
+ // Transaction Items
775
+ this.items = [];
776
+ this.id = +record.id;
777
+ this.type = record.transaction_type;
778
+ this.status = record.status;
779
+ this.loyalty_number = record.loyaltynumber;
780
+ this.external_order_number = record.external_order_number;
781
+ this.external_invoice_number = record.external_invoice_number;
782
+ this.date = new Date(+record.txdate_timestamp * 1000);
783
+ this.expected_date = new Date(+record.expected_date_timestamp * 1000);
784
+ this.invoice_amount = +record.invoice_amount;
785
+ this.vat = +record.vat;
786
+ this.discount = +record.discount;
787
+ this.total = +record.total;
788
+ this.shipping_total = +record.shipping_total;
789
+ this.insurance_total = +record.insurance_total;
790
+ this.payment = +record.payment;
791
+ this.payment_reference = record.payment_reference;
792
+ this.payment_description = record.payment_description;
793
+ this.gateway_transaction_id = record.gateway_transaction_id;
794
+ this.address = new EsolveTransactionAddress(record.recipient, record.address_type, record.address_description, record.street_number, record.street, record.suburb, record.city, record.province, record.country, record.postal_code, record.pobox);
795
+ if (record.user) {
796
+ this.user = new EsolveTransactionUser(+record.user.id, record.user.email, record.user.firstname, record.user.surname, record.user.telnumber, record.user.cellnumber);
797
+ }
798
+ if (record.client) {
799
+ this.client = new EsolveTransactionClient(+record.client.id, record.client.account, record.client.company_name, record.client.branch_code, record.client.email, record.client.firstname, record.client.surname, record.client.contact_number);
800
+ }
801
+ if (record.location_details) {
802
+ this.location = new EsolveTransactionLocation(record.location_details);
803
+ }
804
+ if (record.payment_method_details) {
805
+ this.payment_method = new EsolveTransactionPaymentMethod(record.payment_method_details.id, record.payment_method_details.paymethod_name, record.payment_method_details.description, record.payment_method_details.integration_type, record.payment_method_details.service_provider);
806
+ }
807
+ if (record.shipping_method_details) {
808
+ this.shipping_method = new EsolveTransactionShippingMethod(+record.shipping_method_details.id, record.shipping_method_details.carrier_name, record.shipping_method_details.delivery_category, record.shipping_method_details.location, record.shipping_method_details.description, record.shipping_method_details.pricing, !!record.shipping_method_details.client_to_collect);
809
+ }
810
+ this.parseTransactionItems(record.transaction_items);
811
+ }
812
+ parseTransactionItems(record_items) {
813
+ for (const record_item of record_items) {
814
+ const price = new EsolveTransactionItemPrice(+record_item.price_exclusive, +record_item.price_inclusive, +record_item.price_exclusive_after_discount, +record_item.price_inclusive_after_discount);
815
+ const line_total = new EsolveTransactionItemPrice(+record_item.line_total_exclusive, +record_item.line_total_inclusive, +record_item.line_total_exclusive_after_discount, +record_item.line_total_inclusive_after_discount);
816
+ const item = new EsolveTransactionItem(record_item.code, record_item.name, +record_item.qty, +record_item.discount, +record_item.vat_rate, price, line_total);
817
+ this.items.push(item);
818
+ }
819
+ }
820
+ }
821
+ class EsolveTransactionClient {
822
+ constructor(id, account, company_name, branch_code, email, first_name, last_name, contact_number) {
823
+ this.id = id;
824
+ this.account = account;
825
+ this.company_name = company_name;
826
+ this.branch_code = branch_code;
827
+ this.email = email;
828
+ this.first_name = first_name;
829
+ this.last_name = last_name;
830
+ this.contact_number = contact_number;
831
+ }
832
+ }
833
+ class EsolveTransactionUser {
834
+ constructor(id, email, first_name, last_name, tel_number, cell_number) {
835
+ this.id = id;
836
+ this.email = email;
837
+ this.first_name = first_name;
838
+ this.last_name = last_name;
839
+ this.tel_number = tel_number;
840
+ this.cell_number = cell_number;
841
+ }
842
+ }
843
+ class EsolveTransactionLocation extends EsolveStockLocation {
844
+ }
845
+ class EsolveTransactionPaymentMethod {
846
+ constructor(id, name, description, integration_type, service_provider) {
847
+ this.id = id;
848
+ this.name = name;
849
+ this.description = description;
850
+ this.integration_type = integration_type;
851
+ this.service_provider = service_provider;
852
+ }
853
+ }
854
+ class EsolveTransactionShippingMethod {
855
+ constructor(id, name, delivery_category, location, description, pricing, client_to_collect) {
856
+ this.id = id;
857
+ this.name = name;
858
+ this.delivery_category = delivery_category;
859
+ this.location = location;
860
+ this.description = description;
861
+ this.pricing = pricing;
862
+ this.client_to_collect = client_to_collect;
863
+ }
864
+ }
865
+ class EsolveTransactionAddress {
866
+ constructor(recipient, address_type, address_description, street_number, street, suburb, city, province, country, postal_code, pobox) {
867
+ this.recipient = recipient;
868
+ this.address_type = address_type;
869
+ this.address_description = address_description;
870
+ this.street_number = street_number;
871
+ this.street = street;
872
+ this.suburb = suburb;
873
+ this.city = city;
874
+ this.province = province;
875
+ this.country = country;
876
+ this.postal_code = postal_code;
877
+ this.pobox = pobox;
878
+ }
879
+ }
880
+ class EsolveTransactionItem {
881
+ constructor(code, name, qty, discount, vat_rate, price, line_total) {
882
+ this.code = code;
883
+ this.name = name;
884
+ this.qty = qty;
885
+ this.discount = discount;
886
+ this.vat_rate = vat_rate;
887
+ this.price = price;
888
+ this.line_total = line_total;
889
+ }
890
+ }
891
+ class EsolveTransactionItemPrice {
892
+ constructor(
893
+ /**
894
+ * Price without tax
895
+ */
896
+ price,
897
+ /**
898
+ * Price with tax
899
+ */
900
+ price_with_tax,
901
+ /**
902
+ * Price without tax and with discounts applied if appilcable
903
+ */
904
+ price_discounted,
905
+ /**
906
+ * Price with tax and with discounts applied if appilcable
907
+ */
908
+ price_with_tax_discounted) {
909
+ this.price = price;
910
+ this.price_with_tax = price_with_tax;
911
+ this.price_discounted = price_discounted;
912
+ this.price_with_tax_discounted = price_with_tax_discounted;
913
+ }
914
+ }
915
+
916
+ class EsolveTransactionList extends EsolveList {
917
+ }
918
+
646
919
  class EsolveRegistrationResult extends EsolveResponseResult {
647
920
  constructor(response) {
648
921
  super(response);
@@ -653,6 +926,23 @@ class EsolveRegistrationResult extends EsolveResponseResult {
653
926
  }
654
927
  }
655
928
 
929
+ class EsolveChangePasswordResult extends EsolveResponseResult {
930
+ constructor(response) {
931
+ super(response);
932
+ this.password_updated = (response.status.state === 'success');
933
+ }
934
+ }
935
+
936
+ class EsolveResetPasswordResult extends EsolveResponseResult {
937
+ constructor(response) {
938
+ super(response);
939
+ this.id = response.esolve_id;
940
+ this.reset_success = response.reset_success;
941
+ this.password_matches_old = response.password_matches_old;
942
+ this.login_required = response.login_required;
943
+ }
944
+ }
945
+
656
946
  class EsolveAccountService {
657
947
  constructor(config, http, sessionService, errorHandler, responseHandler) {
658
948
  this.config = config;
@@ -676,31 +966,6 @@ class EsolveAccountService {
676
966
  this._user_id = value;
677
967
  }
678
968
  }
679
- processUserAccount(record) {
680
- if (!record) {
681
- throw new Error('Invalid record');
682
- }
683
- if (+record.userid !== this._user_id) {
684
- throw new Error('Invalid user account retrieved');
685
- }
686
- const user_account = new EsolveUserAccount(+record.userid, record.email, record.registration_type, record.title, record.firstname, record.surname, record.initials, record.gender, record.idnumber);
687
- user_account.contact_details = new EsolveUserAccountContact(record.telnumber, record.cellnumber, record.fax);
688
- user_account.business_details = new EsolveUserAccountBusiness(record.busname, record.vatnum, record.busdescript, record.business_type);
689
- return user_account;
690
- }
691
- processUserAddress(records) {
692
- const user_addresses = [];
693
- if (!records || (this._user_id === 0)) {
694
- return user_addresses;
695
- }
696
- for (const record of records) {
697
- if (+record.userid !== this._user_id) {
698
- continue;
699
- }
700
- 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));
701
- }
702
- return user_addresses;
703
- }
704
969
  updateUserAccount(user_account_data) {
705
970
  const body = {
706
971
  account: user_account_data
@@ -750,19 +1015,41 @@ class EsolveAccountService {
750
1015
  }));
751
1016
  }
752
1017
  getAddresses() {
753
- if (this.user_id <= 0) {
754
- return throwError('Log in is required');
1018
+ try {
1019
+ this.loginGuard();
1020
+ return this.http.get(`${this.config.api_url}/service/get-addresses.php`, {
1021
+ params: {
1022
+ ws_id: this.config.wsid,
1023
+ user_id: this.user_id
1024
+ }
1025
+ }).pipe(map(response => {
1026
+ if (response.records === undefined) {
1027
+ throw response;
1028
+ }
1029
+ return this.processUserAddress(response.records);
1030
+ }));
755
1031
  }
756
- return this.http.get(`${this.config.api_url}/service/get-addresses.php`, {
1032
+ catch (error) {
1033
+ return throwError(error);
1034
+ }
1035
+ }
1036
+ deleteAddress(id) {
1037
+ return this.http.delete(`${this.config.api_url}/service/delete-address.php`, {
757
1038
  params: {
758
1039
  ws_id: this.config.wsid,
759
- user_id: this.user_id
760
- }
761
- }).pipe(map(response => {
762
- if (response.records === undefined) {
763
- throw response;
1040
+ id: id
1041
+ },
1042
+ responseType: 'json',
1043
+ observe: 'body'
1044
+ }).pipe(map(http_response => {
1045
+ if ((http_response.result === undefined) ||
1046
+ (http_response.result === null) ||
1047
+ (http_response.result.status !== 'success')) {
1048
+ throw http_response;
764
1049
  }
765
- return this.processUserAddress(response.records);
1050
+ return new EsolveResult(http_response.result.status, http_response.result.code, http_response.result.message);
1051
+ }), catchError((errorRes) => {
1052
+ return this.errorHandler.handleHttpDeleteError('delete-address', errorRes);
766
1053
  }));
767
1054
  }
768
1055
  register(user_registration) {
@@ -787,6 +1074,125 @@ class EsolveAccountService {
787
1074
  return this.errorHandler.handleHttpPostError('set-registration', errorRes);
788
1075
  }));
789
1076
  }
1077
+ changePassword(password, confirm_password) {
1078
+ const body = {
1079
+ password,
1080
+ confirm_password
1081
+ };
1082
+ return this.http.post(`${this.config.api_url}/service/set-change-password.php`, body, {
1083
+ headers: {
1084
+ 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;'
1085
+ },
1086
+ params: {
1087
+ ws_id: this.config.wsid
1088
+ },
1089
+ responseType: 'json',
1090
+ observe: 'body'
1091
+ }).pipe(map(http_response => this.responseHandler.validateSingleHttpResponse(http_response, (response) => {
1092
+ return new EsolveChangePasswordResult(response);
1093
+ })), catchError((errorRes) => {
1094
+ return this.errorHandler.handleHttpPostError('set-change-password', errorRes);
1095
+ }));
1096
+ }
1097
+ sendForgotPasswordRequest(email) {
1098
+ return this.http.get(`${this.config.api_url}/service/get-forgot-password.php`, {
1099
+ params: {
1100
+ ws_id: this.config.wsid,
1101
+ email: email
1102
+ }
1103
+ }).pipe(map(response => {
1104
+ if ((response.records === undefined) ||
1105
+ !('reset_link_sent' in response.records)) {
1106
+ throw response;
1107
+ }
1108
+ return response.records.reset_link_sent;
1109
+ }));
1110
+ }
1111
+ resetPassword(reset_key, password, confirm_password, auto_login = true) {
1112
+ return this.http.post(`${this.config.api_url}/service/set-forgot-password.php`, {
1113
+ reset_key,
1114
+ password,
1115
+ confirm_password,
1116
+ auto_login
1117
+ }, {
1118
+ headers: {
1119
+ 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;'
1120
+ },
1121
+ params: {
1122
+ ws_id: this.config.wsid
1123
+ },
1124
+ responseType: 'json',
1125
+ observe: 'body'
1126
+ }).pipe(map(http_response => this.responseHandler.validateSingleHttpResponse(http_response, (response) => {
1127
+ if (!response.login_required) {
1128
+ this.sessionService.handleUpdateSession(response.esolve_id);
1129
+ }
1130
+ return new EsolveResetPasswordResult(response);
1131
+ })), catchError((errorRes) => {
1132
+ return this.errorHandler.handleHttpPostError('set-forgot-password', errorRes);
1133
+ }));
1134
+ }
1135
+ getTranscations(options = {}) {
1136
+ try {
1137
+ this.loginGuard();
1138
+ return this.http.get(`${this.config.api_url}/service/get-transactions.php`, {
1139
+ params: Object.assign({ ws_id: this.config.wsid, user_id: this.user_id }, options)
1140
+ }).pipe(map(response => {
1141
+ var _a, _b;
1142
+ if (response.records === undefined) {
1143
+ throw response;
1144
+ }
1145
+ const items = this.processTransactions(response.records);
1146
+ const total = (_a = +response.additional_data.total_records) !== null && _a !== void 0 ? _a : 0;
1147
+ const rows = (_b = options.rows) !== null && _b !== void 0 ? _b : total;
1148
+ const page = options.page || 1;
1149
+ return new EsolveTransactionList(items, page, rows, total);
1150
+ }));
1151
+ }
1152
+ catch (error) {
1153
+ return throwError(error);
1154
+ }
1155
+ }
1156
+ processUserAccount(record) {
1157
+ if (!record) {
1158
+ throw new Error('Invalid record');
1159
+ }
1160
+ if (+record.userid !== this._user_id) {
1161
+ throw new Error('Invalid user account retrieved');
1162
+ }
1163
+ const user_account = new EsolveUserAccount(+record.userid, record.email, record.registration_type, record.title, record.firstname, record.surname, record.initials, record.gender, record.idnumber);
1164
+ user_account.contact_details = new EsolveUserAccountContact(record.telnumber, record.cellnumber, record.fax);
1165
+ user_account.business_details = new EsolveUserAccountBusiness(record.busname, record.vatnum, record.busdescript, record.business_type);
1166
+ return user_account;
1167
+ }
1168
+ processUserAddress(records) {
1169
+ const user_addresses = [];
1170
+ if (!records || (this._user_id === 0)) {
1171
+ return user_addresses;
1172
+ }
1173
+ for (const record of records) {
1174
+ if (+record.userid !== this._user_id) {
1175
+ continue;
1176
+ }
1177
+ 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));
1178
+ }
1179
+ return user_addresses;
1180
+ }
1181
+ processTransactions(records) {
1182
+ const transactions = [];
1183
+ if (records) {
1184
+ for (const record of records) {
1185
+ const transaction = new EsolveTransaction(record);
1186
+ transactions.push(transaction);
1187
+ }
1188
+ }
1189
+ return transactions;
1190
+ }
1191
+ loginGuard() {
1192
+ if (this.user_id <= 0) {
1193
+ this.errorHandler.emitError('login_required', 'Login is required');
1194
+ }
1195
+ }
790
1196
  }
791
1197
  EsolveAccountService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: EsolveAccountService, deps: [{ token: ESOLVE_CONNECT_CONFIG }, { token: i1$1.HttpClient }, { token: EsolveSessionService }, { token: EsolveErrorHandlerService }, { token: EsolveResponseHandlerService }], target: i0.ɵɵFactoryTarget.Injectable });
792
1198
  EsolveAccountService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: EsolveAccountService, providedIn: 'root' });
@@ -840,29 +1246,6 @@ class EsolveMediaService {
840
1246
  this.config = config;
841
1247
  this.http = http;
842
1248
  }
843
- processMediaRecord(record) {
844
- const tags = [];
845
- const topics = [];
846
- if ((record.tags) && (record.tags.length > 0)) {
847
- for (const tag of record.tags) {
848
- tags.push(new EsolveTag(+tag.id, tag.tag_phrase, +tag.tag_weight, tag.description));
849
- }
850
- }
851
- if ((record.topics) && (record.topics.length > 0)) {
852
- for (const topic of record.topics) {
853
- topics.push(new EsolveTopic(+topic.id, topic.name, topic.short_description, +topic.sort_priority));
854
- }
855
- }
856
- return new EsolveMediaArticle(record.identifier, record.title, record.article, record.image_url, tags, topics, record.seo_page_title, record.seo_keywords, record.seo_description);
857
- }
858
- /**
859
- * Retrieves media records from eSolve instance.
860
- * @param params Header params
861
- */
862
- getMediaRecords(params) {
863
- params = params.set('ws_id', this.config.wsid);
864
- return this.http.get(`${this.config.api_url}/service/get-media.php`, { params });
865
- }
866
1249
  /**
867
1250
  * Retrieves the media record from the eSolve instance using the identifier.
868
1251
  * @param identifier String representing the eSolve media indentifier
@@ -907,6 +1290,29 @@ class EsolveMediaService {
907
1290
  return mediaArticles;
908
1291
  }));
909
1292
  }
1293
+ processMediaRecord(record) {
1294
+ const tags = [];
1295
+ const topics = [];
1296
+ if ((record.tags) && (record.tags.length > 0)) {
1297
+ for (const tag of record.tags) {
1298
+ tags.push(new EsolveTag(+tag.id, tag.tag_phrase, +tag.tag_weight, tag.description));
1299
+ }
1300
+ }
1301
+ if ((record.topics) && (record.topics.length > 0)) {
1302
+ for (const topic of record.topics) {
1303
+ topics.push(new EsolveTopic(+topic.id, topic.name, topic.short_description, +topic.sort_priority));
1304
+ }
1305
+ }
1306
+ return new EsolveMediaArticle(record.identifier, record.title, record.article, record.image_url, tags, topics, record.seo_page_title, record.seo_keywords, record.seo_description);
1307
+ }
1308
+ /**
1309
+ * Retrieves media records from eSolve instance.
1310
+ * @param params Header params
1311
+ */
1312
+ getMediaRecords(params) {
1313
+ params = params.set('ws_id', this.config.wsid);
1314
+ return this.http.get(`${this.config.api_url}/service/get-media.php`, { params });
1315
+ }
910
1316
  }
911
1317
  EsolveMediaService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: EsolveMediaService, deps: [{ token: ESOLVE_CONNECT_CONFIG }, { token: i1$1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
912
1318
  EsolveMediaService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: EsolveMediaService, providedIn: 'root' });
@@ -922,6 +1328,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImpor
922
1328
  }] }, { type: i1$1.HttpClient }];
923
1329
  } });
924
1330
 
1331
+ class EsolveNewsGroup {
1332
+ constructor(id, name, description, sef_name) {
1333
+ this.id = id;
1334
+ this.name = name;
1335
+ this.description = description;
1336
+ this.sef_name = sef_name;
1337
+ }
1338
+ }
1339
+
925
1340
  class EsolveNewsArticle {
926
1341
  constructor(id, title, sef_title, article, short_description, txdate, active, image, featured, author, seo_title = '', seo_keywords = '') {
927
1342
  this.id = id;
@@ -941,15 +1356,6 @@ class EsolveNewsArticle {
941
1356
  }
942
1357
  }
943
1358
 
944
- class EsolveNewsGroup {
945
- constructor(id, name, description, sef_name) {
946
- this.id = id;
947
- this.name = name;
948
- this.description = description;
949
- this.sef_name = sef_name;
950
- }
951
- }
952
-
953
1359
  class EsolveNewsArticleList {
954
1360
  constructor(newsArticles, total, page) {
955
1361
  this.newsArticles = newsArticles;
@@ -1119,6 +1525,31 @@ class EsolveBannerService {
1119
1525
  this.config = config;
1120
1526
  this.http = http;
1121
1527
  }
1528
+ /**
1529
+ * Retrieves banners records from eSolve instance
1530
+ *
1531
+ * @returns An observable of eSolve banners.
1532
+ */
1533
+ getBanners(identifier, banner_display_container, enable_date_filter = false) {
1534
+ let params = new HttpParams({
1535
+ fromObject: {
1536
+ ws_id: this.config.wsid,
1537
+ enable_date_filter
1538
+ }
1539
+ });
1540
+ if (identifier) {
1541
+ params = params.set('identifier', identifier);
1542
+ }
1543
+ if (banner_display_container) {
1544
+ params = params.set('banner_display_container', banner_display_container);
1545
+ }
1546
+ return this.http.get(`${this.config.api_url}/service/get-banners.php`, { params }).pipe(map(response => {
1547
+ if (response.records === undefined) {
1548
+ throw response;
1549
+ }
1550
+ return this.processBanners(response.records);
1551
+ }));
1552
+ }
1122
1553
  processBannerImageHotspots(hotspot_records) {
1123
1554
  const hotspots = [];
1124
1555
  if (hotspot_records.length > 0) {
@@ -1171,31 +1602,6 @@ class EsolveBannerService {
1171
1602
  }
1172
1603
  return banners;
1173
1604
  }
1174
- /**
1175
- * Retrieves banners records from eSolve instance
1176
- *
1177
- * @returns An observable of eSolve banners.
1178
- */
1179
- getBanners(identifier, banner_display_container, enable_date_filter = false) {
1180
- let params = new HttpParams({
1181
- fromObject: {
1182
- ws_id: this.config.wsid,
1183
- enable_date_filter
1184
- }
1185
- });
1186
- if (identifier) {
1187
- params = params.set('identifier', identifier);
1188
- }
1189
- if (banner_display_container) {
1190
- params = params.set('banner_display_container', banner_display_container);
1191
- }
1192
- return this.http.get(`${this.config.api_url}/service/get-banners.php`, { params }).pipe(map(response => {
1193
- if (response.records === undefined) {
1194
- throw response;
1195
- }
1196
- return this.processBanners(response.records);
1197
- }));
1198
- }
1199
1605
  }
1200
1606
  EsolveBannerService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: EsolveBannerService, deps: [{ token: ESOLVE_CONNECT_CONFIG }, { token: i1$1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
1201
1607
  EsolveBannerService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: EsolveBannerService, providedIn: 'root' });
@@ -1268,16 +1674,6 @@ class EsolveTopicService {
1268
1674
  this.config = config;
1269
1675
  this.http = http;
1270
1676
  }
1271
- processTopics(records) {
1272
- const topics = [];
1273
- if (records) {
1274
- for (const record of records) {
1275
- const topic = new EsolveTopic(+record.id, record.name, record.short_description, +record.sort_priority);
1276
- topics.push(topic);
1277
- }
1278
- }
1279
- return topics;
1280
- }
1281
1677
  /**
1282
1678
  * Retrieves active topics from the list of topic ID's. Note that inactive or expired
1283
1679
  * topics will not be retrieved.
@@ -1300,6 +1696,16 @@ class EsolveTopicService {
1300
1696
  return this.processTopics(response.records);
1301
1697
  }));
1302
1698
  }
1699
+ processTopics(records) {
1700
+ const topics = [];
1701
+ if (records) {
1702
+ for (const record of records) {
1703
+ const topic = new EsolveTopic(+record.id, record.name, record.short_description, +record.sort_priority);
1704
+ topics.push(topic);
1705
+ }
1706
+ }
1707
+ return topics;
1708
+ }
1303
1709
  }
1304
1710
  EsolveTopicService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: EsolveTopicService, deps: [{ token: ESOLVE_CONNECT_CONFIG }, { token: i1$1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
1305
1711
  EsolveTopicService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: EsolveTopicService, providedIn: 'root' });
@@ -1596,6 +2002,9 @@ class EsolveStockService {
1596
2002
  if (options.rows) {
1597
2003
  params = params.set('rows', options.rows);
1598
2004
  }
2005
+ if (options.search_phrase) {
2006
+ params = params.set('search_phrase', options.search_phrase);
2007
+ }
1599
2008
  if (options.display_only) {
1600
2009
  params = params.set('display_only', options.display_only);
1601
2010
  }
@@ -1697,50 +2106,6 @@ class EsolveCategoryTreeService {
1697
2106
  this.config = config;
1698
2107
  this.http = http;
1699
2108
  }
1700
- /**
1701
- * Processes the eSolve tree records and converts them into the correct format.
1702
- * @param tree_records Records to process
1703
- */
1704
- processTree(tree_records) {
1705
- const tree_items = [];
1706
- if (tree_records) {
1707
- for (const tree_record of tree_records) {
1708
- let esolve_id = '';
1709
- let parent_id = '';
1710
- let children = [];
1711
- if (tree_record.type === 'category') {
1712
- children = this.processTree(tree_record.children);
1713
- esolve_id = tree_record.menu_id;
1714
- parent_id = tree_record.owner_menu_id;
1715
- }
1716
- else {
1717
- esolve_id = tree_record.id;
1718
- parent_id = tree_record.menu_id;
1719
- }
1720
- 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));
1721
- }
1722
- }
1723
- return tree_items;
1724
- }
1725
- processTreeItem(record) {
1726
- 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);
1727
- }
1728
- processID(id) {
1729
- let type;
1730
- let esolve_id;
1731
- const type_code_regex = /^\<\<(CAT|SUB)\>\>/g;
1732
- const match_results = id.match(type_code_regex);
1733
- if (match_results) {
1734
- const type_code = match_results[0];
1735
- type = (type_code === '<<CAT>>' ? 'category' : 'subcategory');
1736
- esolve_id = id.replace(type_code_regex, '');
1737
- return {
1738
- type,
1739
- esolve_id
1740
- };
1741
- }
1742
- return null;
1743
- }
1744
2109
  /**
1745
2110
  * Retrieves the category tree from eSolve instance and coverts it to the correct format.
1746
2111
  */
@@ -1797,6 +2162,50 @@ class EsolveCategoryTreeService {
1797
2162
  }
1798
2163
  return throwError('Invalid options');
1799
2164
  }
2165
+ /**
2166
+ * Processes the eSolve tree records and converts them into the correct format.
2167
+ * @param tree_records Records to process
2168
+ */
2169
+ processTree(tree_records) {
2170
+ const tree_items = [];
2171
+ if (tree_records) {
2172
+ for (const tree_record of tree_records) {
2173
+ let esolve_id = '';
2174
+ let parent_id = '';
2175
+ let children = [];
2176
+ if (tree_record.type === 'category') {
2177
+ children = this.processTree(tree_record.children);
2178
+ esolve_id = tree_record.menu_id;
2179
+ parent_id = tree_record.owner_menu_id;
2180
+ }
2181
+ else {
2182
+ esolve_id = tree_record.id;
2183
+ parent_id = tree_record.menu_id;
2184
+ }
2185
+ 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));
2186
+ }
2187
+ }
2188
+ return tree_items;
2189
+ }
2190
+ processTreeItem(record) {
2191
+ 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);
2192
+ }
2193
+ processID(id) {
2194
+ let type;
2195
+ let esolve_id;
2196
+ const type_code_regex = /^\<\<(CAT|SUB)\>\>/g;
2197
+ const match_results = id.match(type_code_regex);
2198
+ if (match_results) {
2199
+ const type_code = match_results[0];
2200
+ type = (type_code === '<<CAT>>' ? 'category' : 'subcategory');
2201
+ esolve_id = id.replace(type_code_regex, '');
2202
+ return {
2203
+ type,
2204
+ esolve_id
2205
+ };
2206
+ }
2207
+ return null;
2208
+ }
1800
2209
  }
1801
2210
  EsolveCategoryTreeService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: EsolveCategoryTreeService, deps: [{ token: ESOLVE_CONNECT_CONFIG }, { token: i1$1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
1802
2211
  EsolveCategoryTreeService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: EsolveCategoryTreeService, providedIn: 'root' });
@@ -1812,6 +2221,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImpor
1812
2221
  }] }, { type: i1$1.HttpClient }];
1813
2222
  } });
1814
2223
 
2224
+ class EsolveCheckoutResult extends EsolveResponseResult {
2225
+ constructor(response) {
2226
+ super(response);
2227
+ this.id = 0;
2228
+ this.id = +response.esolve_id;
2229
+ }
2230
+ }
2231
+
1815
2232
  class EsolveCartItem {
1816
2233
  constructor(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) {
1817
2234
  this.id = id;
@@ -1875,14 +2292,6 @@ class EsolveCartTotals {
1875
2292
  }
1876
2293
  }
1877
2294
 
1878
- class EsolveCheckoutResult extends EsolveResponseResult {
1879
- constructor(response) {
1880
- super(response);
1881
- this.id = 0;
1882
- this.id = +response.esolve_id;
1883
- }
1884
- }
1885
-
1886
2295
  class EsolveCartStockItem {
1887
2296
  constructor(code, name, sef_name, description, active, items_in_pack, delivery_category, image_name) {
1888
2297
  this.code = code;
@@ -1934,30 +2343,6 @@ class EsolveCartService {
1934
2343
  this.responseHandler = responseHandler;
1935
2344
  this._cached_tracking = 0;
1936
2345
  }
1937
- /**
1938
- * Processes the eSolve tree records.
1939
- * @param cart_item_records Records to process
1940
- * @returns An array of processed cart items
1941
- */
1942
- processCart(cart_item_records) {
1943
- const cart_items = [];
1944
- if (cart_item_records) {
1945
- for (const cart_item_record of cart_item_records) {
1946
- const 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);
1947
- 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));
1948
- }
1949
- }
1950
- return cart_items;
1951
- }
1952
- /**
1953
- * Processes the eSolve cart totals
1954
- * @param record Data to process
1955
- * @returns Processed cart totals
1956
- */
1957
- processCartTotals(record) {
1958
- const cart_totals = new EsolveCartTotals(+record.records, +record.items, +record.total, +record.vat, +record.discount);
1959
- return cart_totals;
1960
- }
1961
2346
  /**
1962
2347
  * Retrieves the current cart
1963
2348
  * @returns An `Observable` with an array of cart items
@@ -2076,6 +2461,30 @@ class EsolveCartService {
2076
2461
  }));
2077
2462
  }));
2078
2463
  }
2464
+ /**
2465
+ * Processes the eSolve tree records.
2466
+ * @param cart_item_records Records to process
2467
+ * @returns An array of processed cart items
2468
+ */
2469
+ processCart(cart_item_records) {
2470
+ const cart_items = [];
2471
+ if (cart_item_records) {
2472
+ for (const cart_item_record of cart_item_records) {
2473
+ const 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);
2474
+ 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));
2475
+ }
2476
+ }
2477
+ return cart_items;
2478
+ }
2479
+ /**
2480
+ * Processes the eSolve cart totals
2481
+ * @param record Data to process
2482
+ * @returns Processed cart totals
2483
+ */
2484
+ processCartTotals(record) {
2485
+ const cart_totals = new EsolveCartTotals(+record.records, +record.items, +record.total, +record.vat, +record.discount);
2486
+ return cart_totals;
2487
+ }
2079
2488
  }
2080
2489
  EsolveCartService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: EsolveCartService, deps: [{ token: ESOLVE_CONNECT_CONFIG }, { token: i1$1.HttpClient }, { token: EsolveErrorHandlerService }, { token: EsolveResponseHandlerService }], target: i0.ɵɵFactoryTarget.Injectable });
2081
2490
  EsolveCartService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: EsolveCartService, providedIn: 'root' });
@@ -2159,12 +2568,8 @@ class EsolvePaymentMethod {
2159
2568
  this.description = record.description;
2160
2569
  this.display_banking_details = record.display_banking_details;
2161
2570
  this.currency_code = record.currency_code;
2162
- this.terminal_id = record.terminal_id;
2163
- this.terminal_id_secondary = record.terminal_id_secondary;
2164
2571
  this.merchant_id = record.merchant_id;
2165
2572
  this.application_id = record.application_id;
2166
- this.api_username = record.api_username;
2167
- this.api_password = record.api_password;
2168
2573
  this.api_signature = record.api_signature;
2169
2574
  this.is_gateway = record.is_gateway;
2170
2575
  this.must_store_card_details = record.must_store_card_details;
@@ -2315,6 +2720,25 @@ class EsolvePaymentService {
2315
2720
  return this.errorHandler.handleHttpPostError('set-vault', errorRes);
2316
2721
  }));
2317
2722
  }
2723
+ deleteVaultItem(id) {
2724
+ return this.http.delete(`${this.config.api_url}/service/delete-vault.php`, {
2725
+ params: {
2726
+ ws_id: this.config.wsid,
2727
+ id: id
2728
+ },
2729
+ responseType: 'json',
2730
+ observe: 'body'
2731
+ }).pipe(map(http_response => {
2732
+ if ((http_response.result === undefined) ||
2733
+ (http_response.result === null) ||
2734
+ (http_response.result.status !== 'success')) {
2735
+ throw http_response;
2736
+ }
2737
+ return new EsolveResult(http_response.result.status, http_response.result.code, http_response.result.message);
2738
+ }), catchError((errorRes) => {
2739
+ return this.errorHandler.handleHttpDeleteError('delete-vault', errorRes);
2740
+ }));
2741
+ }
2318
2742
  /**
2319
2743
  * Sets the payment for the specified transaction using selected payment method.
2320
2744
  * @param transaction_id eSolve ID to the transaction
@@ -2520,101 +2944,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImpor
2520
2944
  }] }, { type: i1$1.HttpClient }];
2521
2945
  } });
2522
2946
 
2523
- class EsolveStockLocation {
2524
- constructor(record) {
2525
- this.id = +record.id;
2526
- this.identifier = record.identifier;
2527
- this.description = record.description;
2528
- this.head_office = record.head_office;
2529
- this.erp_identifier = record.erp_identifier;
2530
- this.external_system_code = record.external_system_code;
2531
- this.default_location_for_payment_methods = record.default_location_for_payment_methods;
2532
- this.userid = +record.userid;
2533
- this.importance = +record.importance;
2534
- this.active = record.is_active;
2535
- this.website_url = record.website_url;
2536
- this.address = new EsolveStockLocationAddress(record.street, record.suburb, record.city, record.province, record.country, record.postal_code, +record.latitude, +record.longitude);
2537
- this.pobox_address = new EsolveStockLocationPOBoxAddress(record.pobox, record.pobox_city, record.pobox_postal_code);
2538
- const telnumbers = [];
2539
- if (record.branch_telnumber.length > 0) {
2540
- telnumbers.push(record.branch_telnumber);
2541
- }
2542
- if (record.branch_telnumber_2.length > 0) {
2543
- telnumbers.push(record.branch_telnumber_2);
2544
- }
2545
- if (record.branch_telnumber_3.length > 0) {
2546
- telnumbers.push(record.branch_telnumber_3);
2547
- }
2548
- this.contact_info = new EsolveStockLocationContactInfo(telnumbers, record.branch_cellnumber, record.branch_email, record.branch_fax);
2549
- 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);
2550
- }
2551
- }
2552
- class EsolveStockLocationAddress {
2553
- constructor(street, suburb, city, province, country, postal_code, latitude, longitude) {
2554
- this.street = street;
2555
- this.suburb = suburb;
2556
- this.city = city;
2557
- this.province = province;
2558
- this.country = country;
2559
- this.postal_code = postal_code;
2560
- this.latitude = latitude;
2561
- this.longitude = longitude;
2562
- }
2563
- }
2564
- class EsolveStockLocationPOBoxAddress {
2565
- constructor(pobox, city, postal_code) {
2566
- this.pobox = pobox;
2567
- this.city = city;
2568
- this.postal_code = postal_code;
2569
- }
2570
- }
2571
- class EsolveStockLocationContactInfo {
2572
- constructor(telnumber, cellnumber, email, fax) {
2573
- this.telnumber = telnumber;
2574
- this.cellnumber = cellnumber;
2575
- this.email = email;
2576
- this.fax = fax;
2577
- }
2578
- }
2579
- class EsolveStockLocationTradingTimes {
2580
- constructor(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 = '') {
2581
- this.trading_hours_additional_info = trading_hours_additional_info;
2582
- this.monday = new EsolveStockLocationTradingTimesDay(monday_open_time, monday_close_time);
2583
- this.tuesday = new EsolveStockLocationTradingTimesDay(tuesday_open_time, tuesday_close_time);
2584
- this.wednesday = new EsolveStockLocationTradingTimesDay(wednesday_open_time, wednesday_close_time);
2585
- this.thursday = new EsolveStockLocationTradingTimesDay(thursday_open_time, thursday_close_time);
2586
- this.friday = new EsolveStockLocationTradingTimesDay(friday_open_time, friday_close_time);
2587
- this.saturday = new EsolveStockLocationTradingTimesDay(saturday_open_time, saturday_close_time);
2588
- this.sunday = new EsolveStockLocationTradingTimesDay(sunday_open_time, sunday_close_time);
2589
- this.public_holiday = new EsolveStockLocationTradingTimesDay(public_holiday_open_time, public_holiday_close_time);
2590
- }
2591
- }
2592
- class EsolveStockLocationTradingTimesDay {
2593
- constructor(open, close) {
2594
- this.open = open;
2595
- this.close = close;
2596
- }
2597
- }
2598
-
2599
2947
  class EsolveLocationsService {
2600
2948
  constructor(config, http) {
2601
2949
  this.config = config;
2602
2950
  this.http = http;
2603
2951
  }
2604
- /**
2605
- * Processes the eSolve stock location records.
2606
- * @param records Records to process
2607
- * @returns An array of processed stock location records
2608
- */
2609
- processStockLocations(records) {
2610
- const stock_locations = [];
2611
- if (records) {
2612
- for (const record of records) {
2613
- stock_locations.push(new EsolveStockLocation(record));
2614
- }
2615
- }
2616
- return stock_locations;
2617
- }
2618
2952
  /**
2619
2953
  * Retrieves a list of stock locations
2620
2954
  * @returns An `Observable` with an array of stock locations
@@ -2629,6 +2963,20 @@ class EsolveLocationsService {
2629
2963
  return this.processStockLocations(response.records);
2630
2964
  }));
2631
2965
  }
2966
+ /**
2967
+ * Processes the eSolve stock location records.
2968
+ * @param records Records to process
2969
+ * @returns An array of processed stock location records
2970
+ */
2971
+ processStockLocations(records) {
2972
+ const stock_locations = [];
2973
+ if (records) {
2974
+ for (const record of records) {
2975
+ stock_locations.push(new EsolveStockLocation(record));
2976
+ }
2977
+ }
2978
+ return stock_locations;
2979
+ }
2632
2980
  }
2633
2981
  EsolveLocationsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: EsolveLocationsService, deps: [{ token: ESOLVE_CONNECT_CONFIG }, { token: i1$1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
2634
2982
  EsolveLocationsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: EsolveLocationsService, providedIn: 'root' });
@@ -2652,5 +3000,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImpor
2652
3000
  * Generated bundle index. Do not edit.
2653
3001
  */
2654
3002
 
2655
- export { EsolveAccountService, EsolveAddress, EsolveAddressResult, EsolveAuthService, EsolveBankingDetails, EsolveBanner, EsolveBannerImage, EsolveBannerImageHotspot, EsolveBannerService, EsolveCartItem, EsolveCartService, EsolveCartTotals, EsolveCategoryTreeItem, EsolveCategoryTreeService, EsolveCheckoutResult, EsolveErrorHandlerService, EsolveHttpError, EsolveLocationsService, EsolveMediaArticle, EsolveMediaService, EsolveMenuItem, EsolveMenuService, EsolveNewsArticle, EsolveNewsArticleAuthor, EsolveNewsArticleList, EsolveNewsGroup, EsolveNewsService, EsolvePaymentMethod, EsolvePaymentResult, EsolvePaymentService, EsolveRegistrationResult, EsolveResponseHandlerService, EsolveResponseResult, EsolveSEOInfo, EsolveSeoService, EsolveSession, EsolveSessionService, EsolveShippingCost, EsolveShippingMethod, EsolveShippingService, EsolveStockBadge, EsolveStockItem, EsolveStockItemList, EsolveStockLocation, EsolveStockPrice, EsolveStockService, EsolveTag, EsolveTopic, EsolveTopicService, EsolveUserAccount, EsolveUserAccountBusiness, EsolveUserAccountContact, EsolveUserAccountResult, EsolveVaultItem, EsolveVaultItemResult, NgEsolveConnectModule };
3003
+ export { EsolveAccountService, EsolveAddress, EsolveAddressResult, EsolveAuthService, EsolveBankingDetails, EsolveBanner, EsolveBannerImage, EsolveBannerImageHotspot, EsolveBannerService, EsolveCartItem, EsolveCartService, EsolveCartTotals, EsolveCategoryTreeItem, EsolveCategoryTreeService, EsolveChangePasswordResult, EsolveCheckoutResult, EsolveErrorHandlerService, EsolveHttpError, EsolveList, EsolveLocationsService, EsolveMediaArticle, EsolveMediaService, EsolveMenuItem, EsolveMenuService, EsolveNewsArticle, EsolveNewsArticleAuthor, EsolveNewsArticleList, EsolveNewsGroup, EsolveNewsService, EsolvePaymentMethod, EsolvePaymentResult, EsolvePaymentService, EsolveRegistrationResult, EsolveResetPasswordResult, EsolveResponseHandlerService, EsolveResponseResult, EsolveResult, EsolveSEOInfo, EsolveSeoService, EsolveSession, EsolveSessionService, EsolveShippingCost, EsolveShippingMethod, EsolveShippingService, EsolveStockBadge, EsolveStockItem, EsolveStockItemList, EsolveStockLocation, EsolveStockLocationAddress, EsolveStockLocationContactInfo, EsolveStockLocationPOBoxAddress, EsolveStockLocationTradingTimes, EsolveStockLocationTradingTimesDay, EsolveStockPrice, EsolveStockService, EsolveTag, EsolveTopic, EsolveTopicService, EsolveTransaction, EsolveTransactionAddress, EsolveTransactionClient, EsolveTransactionItem, EsolveTransactionItemPrice, EsolveTransactionList, EsolveTransactionLocation, EsolveTransactionPaymentMethod, EsolveTransactionShippingMethod, EsolveTransactionUser, EsolveUserAccount, EsolveUserAccountBusiness, EsolveUserAccountContact, EsolveUserAccountResult, EsolveVaultItem, EsolveVaultItemResult, NgEsolveConnectModule };
2656
3004
  //# sourceMappingURL=esolve-ng-esolve-connect.mjs.map