@esolve/ng-esolve-connect 0.8.0 → 0.10.1

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 (57) 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.service.mjs +45 -45
  14. package/esm2020/lib/locations/esolve-locations.service.mjs +15 -15
  15. package/esm2020/lib/locations/esolve-stock-location-record.mjs +1 -1
  16. package/esm2020/lib/locations/esolve-stock-location.mjs +16 -16
  17. package/esm2020/lib/media/esolve-media.service.mjs +25 -25
  18. package/esm2020/lib/menu/esolve-menu.service.mjs +1 -1
  19. package/esm2020/lib/payment/esolve-payment-method-record.mjs +1 -1
  20. package/esm2020/lib/payment/esolve-payment-method.mjs +1 -5
  21. package/esm2020/lib/payment/esolve-payment.service.mjs +21 -1
  22. package/esm2020/lib/shared/error-handler/esolve-error-handler.service.mjs +57 -24
  23. package/esm2020/lib/shared/esolve-list.mjs +9 -0
  24. package/esm2020/lib/shared/esolve-response.mjs +1 -1
  25. package/esm2020/lib/shared/esolve-result.mjs +8 -0
  26. package/esm2020/lib/topics/esolve-topic.service.mjs +11 -11
  27. package/esm2020/public-api.mjs +8 -1
  28. package/fesm2015/esolve-ng-esolve-connect.mjs +658 -312
  29. package/fesm2015/esolve-ng-esolve-connect.mjs.map +1 -1
  30. package/fesm2020/esolve-ng-esolve-connect.mjs +660 -311
  31. package/fesm2020/esolve-ng-esolve-connect.mjs.map +1 -1
  32. package/lib/account/esolve-account.service.d.ts +18 -6
  33. package/lib/account/esolve-change-password-result.d.ts +6 -0
  34. package/lib/account/esolve-forgot-password-response.d.ts +7 -0
  35. package/lib/account/esolve-reset-password-result.d.ts +9 -0
  36. package/lib/account/esolve-transaction-list.d.ts +4 -0
  37. package/lib/account/esolve-transaction-options.d.ts +8 -0
  38. package/lib/account/esolve-transaction-record.d.ts +98 -0
  39. package/lib/account/esolve-transaction.d.ts +132 -0
  40. package/lib/auth/esolve-auth.service.d.ts +1 -1
  41. package/lib/banners/esolve-banner.service.d.ts +6 -6
  42. package/lib/cart/esolve-cart.service.d.ts +12 -12
  43. package/lib/category-tree/esolve-category-tree.service.d.ts +7 -7
  44. package/lib/locations/esolve-locations.service.d.ts +5 -5
  45. package/lib/locations/esolve-stock-location-record.d.ts +1 -1
  46. package/lib/locations/esolve-stock-location.d.ts +7 -8
  47. package/lib/media/esolve-media.service.d.ts +7 -7
  48. package/lib/payment/esolve-payment-method-record.d.ts +0 -4
  49. package/lib/payment/esolve-payment-method.d.ts +0 -4
  50. package/lib/payment/esolve-payment.service.d.ts +2 -0
  51. package/lib/shared/error-handler/esolve-error-handler.service.d.ts +8 -2
  52. package/lib/shared/esolve-list.d.ts +7 -0
  53. package/lib/shared/esolve-response.d.ts +15 -9
  54. package/lib/shared/esolve-result.d.ts +6 -0
  55. package/lib/topics/esolve-topic.service.d.ts +1 -1
  56. package/package.json +1 -1
  57. package/public-api.d.ts +7 -0
@@ -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
+ getTransactions(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' });
@@ -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' });
@@ -1260,23 +1666,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImpor
1260
1666
  return [{ type: undefined, decorators: [{
1261
1667
  type: Inject,
1262
1668
  args: [ESOLVE_CONNECT_CONFIG]
1263
- }] }, { type: i1$1.HttpClient }];
1264
- } });
1265
-
1266
- class EsolveTopicService {
1267
- constructor(config, http) {
1268
- this.config = config;
1269
- this.http = http;
1270
- }
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;
1669
+ }] }, { type: i1$1.HttpClient }];
1670
+ } });
1671
+
1672
+ class EsolveTopicService {
1673
+ constructor(config, http) {
1674
+ this.config = config;
1675
+ this.http = http;
1280
1676
  }
1281
1677
  /**
1282
1678
  * Retrieves active topics from the list of topic ID's. Note that inactive or expired
@@ -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' });
@@ -1700,50 +2106,6 @@ class EsolveCategoryTreeService {
1700
2106
  this.config = config;
1701
2107
  this.http = http;
1702
2108
  }
1703
- /**
1704
- * Processes the eSolve tree records and converts them into the correct format.
1705
- * @param tree_records Records to process
1706
- */
1707
- processTree(tree_records) {
1708
- const tree_items = [];
1709
- if (tree_records) {
1710
- for (const tree_record of tree_records) {
1711
- let esolve_id = '';
1712
- let parent_id = '';
1713
- let children = [];
1714
- if (tree_record.type === 'category') {
1715
- children = this.processTree(tree_record.children);
1716
- esolve_id = tree_record.menu_id;
1717
- parent_id = tree_record.owner_menu_id;
1718
- }
1719
- else {
1720
- esolve_id = tree_record.id;
1721
- parent_id = tree_record.menu_id;
1722
- }
1723
- 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));
1724
- }
1725
- }
1726
- return tree_items;
1727
- }
1728
- processTreeItem(record) {
1729
- 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);
1730
- }
1731
- processID(id) {
1732
- let type;
1733
- let esolve_id;
1734
- const type_code_regex = /^\<\<(CAT|SUB)\>\>/g;
1735
- const match_results = id.match(type_code_regex);
1736
- if (match_results) {
1737
- const type_code = match_results[0];
1738
- type = (type_code === '<<CAT>>' ? 'category' : 'subcategory');
1739
- esolve_id = id.replace(type_code_regex, '');
1740
- return {
1741
- type,
1742
- esolve_id
1743
- };
1744
- }
1745
- return null;
1746
- }
1747
2109
  /**
1748
2110
  * Retrieves the category tree from eSolve instance and coverts it to the correct format.
1749
2111
  */
@@ -1800,6 +2162,50 @@ class EsolveCategoryTreeService {
1800
2162
  }
1801
2163
  return throwError('Invalid options');
1802
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
+ }
1803
2209
  }
1804
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 });
1805
2211
  EsolveCategoryTreeService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: EsolveCategoryTreeService, providedIn: 'root' });
@@ -1937,30 +2343,6 @@ class EsolveCartService {
1937
2343
  this.responseHandler = responseHandler;
1938
2344
  this._cached_tracking = 0;
1939
2345
  }
1940
- /**
1941
- * Processes the eSolve tree records.
1942
- * @param cart_item_records Records to process
1943
- * @returns An array of processed cart items
1944
- */
1945
- processCart(cart_item_records) {
1946
- const cart_items = [];
1947
- if (cart_item_records) {
1948
- for (const cart_item_record of cart_item_records) {
1949
- 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);
1950
- 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));
1951
- }
1952
- }
1953
- return cart_items;
1954
- }
1955
- /**
1956
- * Processes the eSolve cart totals
1957
- * @param record Data to process
1958
- * @returns Processed cart totals
1959
- */
1960
- processCartTotals(record) {
1961
- const cart_totals = new EsolveCartTotals(+record.records, +record.items, +record.total, +record.vat, +record.discount);
1962
- return cart_totals;
1963
- }
1964
2346
  /**
1965
2347
  * Retrieves the current cart
1966
2348
  * @returns An `Observable` with an array of cart items
@@ -2079,6 +2461,30 @@ class EsolveCartService {
2079
2461
  }));
2080
2462
  }));
2081
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
+ }
2082
2488
  }
2083
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 });
2084
2490
  EsolveCartService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: EsolveCartService, providedIn: 'root' });
@@ -2162,12 +2568,8 @@ class EsolvePaymentMethod {
2162
2568
  this.description = record.description;
2163
2569
  this.display_banking_details = record.display_banking_details;
2164
2570
  this.currency_code = record.currency_code;
2165
- this.terminal_id = record.terminal_id;
2166
- this.terminal_id_secondary = record.terminal_id_secondary;
2167
2571
  this.merchant_id = record.merchant_id;
2168
2572
  this.application_id = record.application_id;
2169
- this.api_username = record.api_username;
2170
- this.api_password = record.api_password;
2171
2573
  this.api_signature = record.api_signature;
2172
2574
  this.is_gateway = record.is_gateway;
2173
2575
  this.must_store_card_details = record.must_store_card_details;
@@ -2318,6 +2720,25 @@ class EsolvePaymentService {
2318
2720
  return this.errorHandler.handleHttpPostError('set-vault', errorRes);
2319
2721
  }));
2320
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
+ }
2321
2742
  /**
2322
2743
  * Sets the payment for the specified transaction using selected payment method.
2323
2744
  * @param transaction_id eSolve ID to the transaction
@@ -2523,101 +2944,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImpor
2523
2944
  }] }, { type: i1$1.HttpClient }];
2524
2945
  } });
2525
2946
 
2526
- class EsolveStockLocation {
2527
- constructor(record) {
2528
- this.id = +record.id;
2529
- this.identifier = record.identifier;
2530
- this.description = record.description;
2531
- this.head_office = record.head_office;
2532
- this.erp_identifier = record.erp_identifier;
2533
- this.external_system_code = record.external_system_code;
2534
- this.default_location_for_payment_methods = record.default_location_for_payment_methods;
2535
- this.userid = +record.userid;
2536
- this.importance = +record.importance;
2537
- this.active = record.is_active;
2538
- this.website_url = record.website_url;
2539
- this.address = new EsolveStockLocationAddress(record.street, record.suburb, record.city, record.province, record.country, record.postal_code, +record.latitude, +record.longitude);
2540
- this.pobox_address = new EsolveStockLocationPOBoxAddress(record.pobox, record.pobox_city, record.pobox_postal_code);
2541
- const telnumbers = [];
2542
- if (record.branch_telnumber.length > 0) {
2543
- telnumbers.push(record.branch_telnumber);
2544
- }
2545
- if (record.branch_telnumber_2.length > 0) {
2546
- telnumbers.push(record.branch_telnumber_2);
2547
- }
2548
- if (record.branch_telnumber_3.length > 0) {
2549
- telnumbers.push(record.branch_telnumber_3);
2550
- }
2551
- this.contact_info = new EsolveStockLocationContactInfo(telnumbers, record.branch_cellnumber, record.branch_email, record.branch_fax);
2552
- 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);
2553
- }
2554
- }
2555
- class EsolveStockLocationAddress {
2556
- constructor(street, suburb, city, province, country, postal_code, latitude, longitude) {
2557
- this.street = street;
2558
- this.suburb = suburb;
2559
- this.city = city;
2560
- this.province = province;
2561
- this.country = country;
2562
- this.postal_code = postal_code;
2563
- this.latitude = latitude;
2564
- this.longitude = longitude;
2565
- }
2566
- }
2567
- class EsolveStockLocationPOBoxAddress {
2568
- constructor(pobox, city, postal_code) {
2569
- this.pobox = pobox;
2570
- this.city = city;
2571
- this.postal_code = postal_code;
2572
- }
2573
- }
2574
- class EsolveStockLocationContactInfo {
2575
- constructor(telnumber, cellnumber, email, fax) {
2576
- this.telnumber = telnumber;
2577
- this.cellnumber = cellnumber;
2578
- this.email = email;
2579
- this.fax = fax;
2580
- }
2581
- }
2582
- class EsolveStockLocationTradingTimes {
2583
- 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 = '') {
2584
- this.trading_hours_additional_info = trading_hours_additional_info;
2585
- this.monday = new EsolveStockLocationTradingTimesDay(monday_open_time, monday_close_time);
2586
- this.tuesday = new EsolveStockLocationTradingTimesDay(tuesday_open_time, tuesday_close_time);
2587
- this.wednesday = new EsolveStockLocationTradingTimesDay(wednesday_open_time, wednesday_close_time);
2588
- this.thursday = new EsolveStockLocationTradingTimesDay(thursday_open_time, thursday_close_time);
2589
- this.friday = new EsolveStockLocationTradingTimesDay(friday_open_time, friday_close_time);
2590
- this.saturday = new EsolveStockLocationTradingTimesDay(saturday_open_time, saturday_close_time);
2591
- this.sunday = new EsolveStockLocationTradingTimesDay(sunday_open_time, sunday_close_time);
2592
- this.public_holiday = new EsolveStockLocationTradingTimesDay(public_holiday_open_time, public_holiday_close_time);
2593
- }
2594
- }
2595
- class EsolveStockLocationTradingTimesDay {
2596
- constructor(open, close) {
2597
- this.open = open;
2598
- this.close = close;
2599
- }
2600
- }
2601
-
2602
2947
  class EsolveLocationsService {
2603
2948
  constructor(config, http) {
2604
2949
  this.config = config;
2605
2950
  this.http = http;
2606
2951
  }
2607
- /**
2608
- * Processes the eSolve stock location records.
2609
- * @param records Records to process
2610
- * @returns An array of processed stock location records
2611
- */
2612
- processStockLocations(records) {
2613
- const stock_locations = [];
2614
- if (records) {
2615
- for (const record of records) {
2616
- stock_locations.push(new EsolveStockLocation(record));
2617
- }
2618
- }
2619
- return stock_locations;
2620
- }
2621
2952
  /**
2622
2953
  * Retrieves a list of stock locations
2623
2954
  * @returns An `Observable` with an array of stock locations
@@ -2632,6 +2963,20 @@ class EsolveLocationsService {
2632
2963
  return this.processStockLocations(response.records);
2633
2964
  }));
2634
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
+ }
2635
2980
  }
2636
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 });
2637
2982
  EsolveLocationsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: EsolveLocationsService, providedIn: 'root' });
@@ -2655,4 +3000,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImpor
2655
3000
  * Generated bundle index. Do not edit.
2656
3001
  */
2657
3002
 
2658
- 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 };
3004
+ //# sourceMappingURL=esolve-ng-esolve-connect.mjs.map