@esolve/ng-esolve-connect 0.15.2 → 0.16.2
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.
- package/esm2020/lib/account/registration/esolve-registration-data.interface.mjs +1 -1
- package/esm2020/lib/manufacturers/esolve-manufacturer-image-size.type.mjs +2 -0
- package/esm2020/lib/manufacturers/esolve-manufacturer.model.mjs +30 -13
- package/esm2020/lib/manufacturers/esolve-manufacturers.service.mjs +2 -2
- package/esm2020/lib/manufacturers/index.mjs +7 -2
- package/esm2020/lib/media/esolve-media.service.mjs +3 -3
- package/esm2020/lib/news/esolve-news-article-options.interface.mjs +1 -1
- package/esm2020/lib/news/esolve-news-article-record.interface.mjs +1 -1
- package/esm2020/lib/news/esolve-news-article.model.mjs +66 -13
- package/esm2020/lib/news/esolve-news.service.mjs +56 -46
- package/esm2020/lib/news/index.mjs +1 -3
- package/esm2020/lib/ranges/esolve-range.model.mjs +35 -14
- package/esm2020/lib/ranges/esolve-ranges.service.mjs +2 -2
- package/esm2020/lib/shared/assets/esolve-asset-list.type.mjs +2 -0
- package/esm2020/lib/shared/assets/esolve-asset-options.interface.mjs +2 -0
- package/esm2020/lib/shared/assets/esolve-asset-record.interface.mjs +2 -0
- package/esm2020/lib/shared/assets/esolve-asset.model.mjs +77 -0
- package/esm2020/lib/shared/assets/esolve-assets.service.mjs +102 -0
- package/esm2020/lib/shared/assets/index.mjs +11 -2
- package/esm2020/lib/shared/sort/esolve-sort-order.type.mjs +2 -0
- package/esm2020/lib/shared/sort/esolve-sort.interface.mjs +2 -0
- package/esm2020/lib/shared/sort/index.mjs +5 -0
- package/esm2020/lib/stock/classes/esolve-additional-stock-image.model.mjs +21 -0
- package/esm2020/lib/stock/classes/esolve-colour.model.mjs +8 -0
- package/esm2020/lib/stock/classes/esolve-linked-stock-item.model.mjs +9 -0
- package/esm2020/lib/stock/classes/esolve-media-stock-item.model.mjs +7 -0
- package/esm2020/lib/stock/classes/esolve-recipe-stock-item.model.mjs +9 -0
- package/esm2020/lib/stock/classes/esolve-stock-badge.model.mjs +11 -0
- package/esm2020/lib/stock/classes/esolve-stock-group-item.model.mjs +7 -0
- package/esm2020/lib/stock/classes/esolve-stock-group.model.mjs +13 -0
- package/esm2020/lib/stock/classes/esolve-stock-image-collection.model.mjs +26 -0
- package/esm2020/lib/stock/classes/esolve-stock-image.model.mjs +45 -0
- package/esm2020/lib/stock/classes/esolve-stock-item-base.model.mjs +224 -0
- package/esm2020/lib/stock/classes/esolve-stock-item-list.model.mjs +11 -0
- package/esm2020/lib/stock/classes/esolve-stock-item.model.mjs +17 -0
- package/esm2020/lib/stock/classes/esolve-stock-lead-times.model.mjs +9 -0
- package/esm2020/lib/stock/classes/esolve-stock-price.model.mjs +43 -0
- package/esm2020/lib/stock/classes/index.mjs +17 -0
- package/esm2020/lib/stock/esolve-stock.service.mjs +40 -9
- package/esm2020/lib/stock/index.mjs +4 -35
- package/esm2020/lib/stock/interfaces/esolve-additional-stock-image-record.interface.mjs +2 -0
- package/esm2020/lib/stock/interfaces/esolve-colour-record.interface.mjs +2 -0
- package/esm2020/lib/stock/interfaces/esolve-linked-stock-record.interface.mjs +2 -0
- package/esm2020/lib/stock/interfaces/esolve-media-stock-item-options.interface.mjs +2 -0
- package/esm2020/lib/stock/interfaces/esolve-media-stock-item-record.interface.mjs +2 -0
- package/esm2020/lib/stock/interfaces/esolve-recipe-item-record.interface.mjs +2 -0
- package/esm2020/lib/stock/interfaces/esolve-recipe-stock-options.interface.mjs +2 -0
- package/esm2020/lib/stock/interfaces/esolve-stock-badge-record.interface.mjs +2 -0
- package/esm2020/lib/stock/interfaces/esolve-stock-base-record.interface.mjs +2 -0
- package/esm2020/lib/stock/interfaces/esolve-stock-group-item-record.interface.mjs +2 -0
- package/esm2020/lib/stock/interfaces/esolve-stock-image-collection-record.interface.mjs +3 -0
- package/esm2020/lib/stock/interfaces/esolve-stock-item-options.interface.mjs +2 -0
- package/esm2020/lib/stock/interfaces/esolve-stock-lead-times-record.interface.mjs +2 -0
- package/esm2020/lib/stock/interfaces/esolve-stock-linked-category-record.interface.mjs +2 -0
- package/esm2020/lib/stock/interfaces/esolve-stock-record.interface.mjs +2 -0
- package/esm2020/lib/stock/interfaces/index.mjs +17 -0
- package/esm2020/lib/stock/types/esolve-media-stock-item-list.type.mjs +2 -0
- package/esm2020/lib/stock/types/esolve-media-stock-sort-field.type.mjs +2 -0
- package/esm2020/lib/stock/types/esolve-stock-image-size.type.mjs +2 -0
- package/esm2020/lib/stock/types/esolve-stock-sort-field.type.mjs +2 -0
- package/esm2020/lib/stock/types/esolve-stock-unit-of-measure.type.mjs +2 -0
- package/esm2020/lib/stock/types/index.mjs +7 -0
- package/esm2020/lib/tags/esolve-tag-options.interface.mjs +2 -0
- package/esm2020/lib/tags/esolve-tag-phrase-match-mode.type.mjs +2 -0
- package/esm2020/lib/tags/esolve-tag-record.interface.mjs +1 -1
- package/esm2020/lib/tags/esolve-tag.model.mjs +32 -6
- package/esm2020/lib/tags/esolve-tags.service.mjs +76 -0
- package/esm2020/lib/tags/index.mjs +9 -2
- package/esm2020/lib/topics/esolve-topic.model.mjs +12 -6
- package/esm2020/lib/topics/esolve-topic.service.mjs +2 -2
- package/esm2020/public-api.mjs +2 -1
- package/fesm2015/esolve-ng-esolve-connect.mjs +1902 -1452
- package/fesm2015/esolve-ng-esolve-connect.mjs.map +1 -1
- package/fesm2020/esolve-ng-esolve-connect.mjs +1875 -1437
- package/fesm2020/esolve-ng-esolve-connect.mjs.map +1 -1
- package/lib/account/registration/esolve-registration-data.interface.d.ts +3 -0
- package/lib/manufacturers/esolve-manufacturer-image-size.type.d.ts +1 -0
- package/lib/manufacturers/esolve-manufacturer.model.d.ts +4 -3
- package/lib/manufacturers/index.d.ts +2 -1
- package/lib/news/esolve-news-article-options.interface.d.ts +1 -0
- package/lib/news/esolve-news-article-record.interface.d.ts +8 -4
- package/lib/news/esolve-news-article.model.d.ts +13 -2
- package/lib/news/esolve-news.service.d.ts +2 -1
- package/lib/news/index.d.ts +0 -2
- package/lib/ranges/esolve-range.model.d.ts +2 -2
- package/lib/shared/assets/esolve-asset-list.type.d.ts +3 -0
- package/lib/shared/assets/esolve-asset-options.interface.d.ts +15 -0
- package/lib/shared/assets/esolve-asset-record.interface.d.ts +27 -0
- package/lib/shared/assets/esolve-asset.model.d.ts +39 -0
- package/lib/shared/assets/esolve-assets.service.d.ts +19 -0
- package/lib/shared/assets/index.d.ts +6 -1
- package/lib/shared/sort/esolve-sort-order.type.d.ts +1 -0
- package/lib/shared/sort/esolve-sort.interface.d.ts +5 -0
- package/lib/shared/sort/index.d.ts +2 -0
- package/lib/stock/{esolve-additional-stock-image.model.d.ts → classes/esolve-additional-stock-image.model.d.ts} +1 -1
- package/lib/stock/{esolve-colour.model.d.ts → classes/esolve-colour.model.d.ts} +1 -1
- package/lib/stock/{esolve-linked-stock-item.model.d.ts → classes/esolve-linked-stock-item.model.d.ts} +2 -2
- package/lib/stock/{esolve-media-stock-item.model.d.ts → classes/esolve-media-stock-item.model.d.ts} +2 -2
- package/lib/stock/{esolve-recipe-stock-item.model.d.ts → classes/esolve-recipe-stock-item.model.d.ts} +2 -2
- package/lib/stock/{esolve-stock-badge.model.d.ts → classes/esolve-stock-badge.model.d.ts} +0 -0
- package/lib/stock/{esolve-stock-group-item.model.d.ts → classes/esolve-stock-group-item.model.d.ts} +2 -2
- package/lib/stock/{esolve-stock-group.model.d.ts → classes/esolve-stock-group.model.d.ts} +2 -2
- package/lib/stock/{esolve-stock-image-collection.model.d.ts → classes/esolve-stock-image-collection.model.d.ts} +1 -1
- package/lib/stock/{esolve-stock-image.model.d.ts → classes/esolve-stock-image.model.d.ts} +1 -1
- package/lib/stock/{esolve-stock-item-base.model.d.ts → classes/esolve-stock-item-base.model.d.ts} +29 -9
- package/lib/stock/{esolve-stock-item-list.model.d.ts → classes/esolve-stock-item-list.model.d.ts} +1 -1
- package/lib/stock/{esolve-stock-item.model.d.ts → classes/esolve-stock-item.model.d.ts} +2 -2
- package/lib/stock/{esolve-stock-lead-times.model.d.ts → classes/esolve-stock-lead-times.model.d.ts} +1 -1
- package/lib/stock/{esolve-stock-price.model.d.ts → classes/esolve-stock-price.model.d.ts} +0 -0
- package/lib/stock/classes/index.d.ts +15 -0
- package/lib/stock/esolve-stock.service.d.ts +4 -9
- package/lib/stock/index.d.ts +3 -31
- package/lib/stock/{esolve-additional-stock-image-record.interface.d.ts → interfaces/esolve-additional-stock-image-record.interface.d.ts} +0 -0
- package/lib/stock/{esolve-colour-record.interface.d.ts → interfaces/esolve-colour-record.interface.d.ts} +0 -0
- package/lib/stock/{esolve-linked-stock-record.interface.d.ts → interfaces/esolve-linked-stock-record.interface.d.ts} +1 -1
- package/lib/stock/{esolve-media-stock-item-options.interface.d.ts → interfaces/esolve-media-stock-item-options.interface.d.ts} +3 -0
- package/lib/stock/{esolve-media-stock-item-record.interface.d.ts → interfaces/esolve-media-stock-item-record.interface.d.ts} +1 -1
- package/lib/stock/{esolve-recipe-item-record.interface.d.ts → interfaces/esolve-recipe-item-record.interface.d.ts} +1 -1
- package/lib/stock/interfaces/esolve-recipe-stock-options.interface.d.ts +7 -0
- package/lib/stock/{esolve-stock-badge-record.interface.d.ts → interfaces/esolve-stock-badge-record.interface.d.ts} +0 -0
- package/lib/stock/{esolve-stock-base-record.interface.d.ts → interfaces/esolve-stock-base-record.interface.d.ts} +12 -6
- package/lib/stock/{esolve-stock-group-item-record.interface.d.ts → interfaces/esolve-stock-group-item-record.interface.d.ts} +1 -1
- package/lib/stock/{esolve-stock-image-collection-record.interface.d.ts → interfaces/esolve-stock-image-collection-record.interface.d.ts} +0 -0
- package/lib/stock/{esolve-stock-item-options.interface.d.ts → interfaces/esolve-stock-item-options.interface.d.ts} +3 -0
- package/lib/stock/{esolve-stock-lead-times-record.interface.d.ts → interfaces/esolve-stock-lead-times-record.interface.d.ts} +0 -0
- package/lib/stock/{esolve-stock-linked-category-record.interface.d.ts → interfaces/esolve-stock-linked-category-record.interface.d.ts} +0 -0
- package/lib/stock/{esolve-stock-record.interface.d.ts → interfaces/esolve-stock-record.interface.d.ts} +1 -1
- package/lib/stock/interfaces/index.d.ts +15 -0
- package/lib/stock/types/esolve-media-stock-item-list.type.d.ts +7 -0
- package/lib/stock/types/esolve-media-stock-sort-field.type.d.ts +2 -0
- package/lib/stock/{esolve-stock-image-size.type.d.ts → types/esolve-stock-image-size.type.d.ts} +0 -0
- package/lib/stock/types/esolve-stock-sort-field.type.d.ts +1 -0
- package/lib/stock/types/esolve-stock-unit-of-measure.type.d.ts +1 -0
- package/lib/stock/types/index.d.ts +5 -0
- package/lib/tags/esolve-tag-options.interface.d.ts +6 -0
- package/lib/tags/esolve-tag-phrase-match-mode.type.d.ts +1 -0
- package/lib/tags/esolve-tag-record.interface.d.ts +1 -0
- package/lib/tags/esolve-tag.model.d.ts +14 -3
- package/lib/tags/esolve-tags.service.d.ts +22 -0
- package/lib/tags/index.d.ts +4 -1
- package/lib/topics/esolve-topic.model.d.ts +1 -1
- package/package.json +1 -1
- package/public-api.d.ts +1 -0
- package/esm2020/lib/news/esolve-news-manufacturer-record.interface.mjs +0 -2
- package/esm2020/lib/news/esolve-news-range-record.interface.mjs +0 -2
- package/esm2020/lib/stock/esolve-additional-stock-image-record.interface.mjs +0 -2
- package/esm2020/lib/stock/esolve-additional-stock-image.model.mjs +0 -21
- package/esm2020/lib/stock/esolve-colour-record.interface.mjs +0 -2
- package/esm2020/lib/stock/esolve-colour.model.mjs +0 -8
- package/esm2020/lib/stock/esolve-linked-stock-item.model.mjs +0 -9
- package/esm2020/lib/stock/esolve-linked-stock-record.interface.mjs +0 -2
- package/esm2020/lib/stock/esolve-media-stock-item-list.type.mjs +0 -2
- package/esm2020/lib/stock/esolve-media-stock-item-options.interface.mjs +0 -2
- package/esm2020/lib/stock/esolve-media-stock-item-record.interface.mjs +0 -2
- package/esm2020/lib/stock/esolve-media-stock-item.model.mjs +0 -7
- package/esm2020/lib/stock/esolve-recipe-item-record.interface.mjs +0 -2
- package/esm2020/lib/stock/esolve-recipe-stock-item.model.mjs +0 -9
- package/esm2020/lib/stock/esolve-stock-badge-record.interface.mjs +0 -2
- package/esm2020/lib/stock/esolve-stock-badge.model.mjs +0 -11
- package/esm2020/lib/stock/esolve-stock-base-record.interface.mjs +0 -2
- package/esm2020/lib/stock/esolve-stock-group-item-record.interface.mjs +0 -2
- package/esm2020/lib/stock/esolve-stock-group-item.model.mjs +0 -7
- package/esm2020/lib/stock/esolve-stock-group.model.mjs +0 -13
- package/esm2020/lib/stock/esolve-stock-image-collection-record.interface.mjs +0 -3
- package/esm2020/lib/stock/esolve-stock-image-collection.model.mjs +0 -26
- package/esm2020/lib/stock/esolve-stock-image-size.type.mjs +0 -2
- package/esm2020/lib/stock/esolve-stock-image.model.mjs +0 -45
- package/esm2020/lib/stock/esolve-stock-item-base.model.mjs +0 -197
- package/esm2020/lib/stock/esolve-stock-item-list.model.mjs +0 -11
- package/esm2020/lib/stock/esolve-stock-item-options.interface.mjs +0 -2
- package/esm2020/lib/stock/esolve-stock-item.model.mjs +0 -17
- package/esm2020/lib/stock/esolve-stock-lead-times-record.interface.mjs +0 -2
- package/esm2020/lib/stock/esolve-stock-lead-times.model.mjs +0 -9
- package/esm2020/lib/stock/esolve-stock-linked-category-record.interface.mjs +0 -2
- package/esm2020/lib/stock/esolve-stock-price.model.mjs +0 -43
- package/esm2020/lib/stock/esolve-stock-record.interface.mjs +0 -2
- package/lib/news/esolve-news-manufacturer-record.interface.d.ts +0 -8
- package/lib/news/esolve-news-range-record.interface.d.ts +0 -9
- package/lib/stock/esolve-media-stock-item-list.type.d.ts +0 -7
|
@@ -7,7 +7,7 @@ import * as i1 from 'ngx-cookie-service';
|
|
|
7
7
|
import { CookieService } from 'ngx-cookie-service';
|
|
8
8
|
import { BehaviorSubject, throwError, of, iif } from 'rxjs';
|
|
9
9
|
import * as i1$1 from '@angular/platform-browser';
|
|
10
|
-
import { map,
|
|
10
|
+
import { map, catchError, tap, switchMap } from 'rxjs/operators';
|
|
11
11
|
|
|
12
12
|
const ESOLVE_CONNECT_CONFIG = new InjectionToken('esolve.connect.config');
|
|
13
13
|
|
|
@@ -461,6 +461,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImpor
|
|
|
461
461
|
}]
|
|
462
462
|
}], ctorParameters: function () { return []; } });
|
|
463
463
|
|
|
464
|
+
// Types
|
|
465
|
+
|
|
464
466
|
/**
|
|
465
467
|
* Search Engine Optimization information.
|
|
466
468
|
*/
|
|
@@ -682,433 +684,516 @@ class EsolveLinkedAsset {
|
|
|
682
684
|
}
|
|
683
685
|
}
|
|
684
686
|
|
|
685
|
-
class
|
|
686
|
-
constructor(
|
|
687
|
-
this.
|
|
688
|
-
this.
|
|
689
|
-
this.
|
|
690
|
-
this.
|
|
691
|
-
this.
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
687
|
+
class EsolveCategoryTreeItem {
|
|
688
|
+
constructor(type, esolve_id, parent_id, description, sef_description, short_description, sort_priority, active, display_only, image_name, seo_title, seo_keywords, seo_description, children) {
|
|
689
|
+
this.type = type;
|
|
690
|
+
this.esolve_id = esolve_id;
|
|
691
|
+
this.parent_id = parent_id;
|
|
692
|
+
this.description = description;
|
|
693
|
+
this.sef_description = sef_description;
|
|
694
|
+
this.short_description = short_description;
|
|
695
|
+
this.sort_priority = sort_priority;
|
|
696
|
+
this.active = active;
|
|
697
|
+
this.display_only = display_only;
|
|
698
|
+
this.image_name = image_name;
|
|
699
|
+
this.id = '';
|
|
700
|
+
this.image_path = '';
|
|
701
|
+
if (this.type === 'category') {
|
|
702
|
+
this.id = `<<CAT>>${this.esolve_id}`;
|
|
703
|
+
if (children != null) {
|
|
704
|
+
this.children = children;
|
|
705
|
+
}
|
|
706
|
+
this.image_path = '/images/categories/';
|
|
697
707
|
}
|
|
698
|
-
|
|
699
|
-
|
|
708
|
+
else {
|
|
709
|
+
this.id = `<<SUB>>${this.esolve_id}`;
|
|
710
|
+
this.image_path = '/images/subcategories/';
|
|
700
711
|
}
|
|
701
|
-
if (
|
|
702
|
-
|
|
712
|
+
if (seo_title.trim() === '') {
|
|
713
|
+
seo_title = this.description;
|
|
703
714
|
}
|
|
704
|
-
|
|
705
|
-
.get(`${this.config.api_url}/get-access-token.php`, {
|
|
706
|
-
params,
|
|
707
|
-
headers: new HttpHeaders({
|
|
708
|
-
'Accept-Language': '*',
|
|
709
|
-
}),
|
|
710
|
-
})
|
|
711
|
-
.pipe(tap((responseData) => {
|
|
712
|
-
if ((responseData.type === 'error') ||
|
|
713
|
-
(responseData.type === 'exception')) {
|
|
714
|
-
throw responseData;
|
|
715
|
-
}
|
|
716
|
-
}), catchError(this.handleError), tap((responseData) => {
|
|
717
|
-
this.handleAuthentication(responseData.additional_data);
|
|
718
|
-
}));
|
|
715
|
+
this.seo_details = new EsolveSeoInfo(seo_title, seo_description, seo_keywords);
|
|
719
716
|
}
|
|
720
|
-
|
|
721
|
-
this.
|
|
722
|
-
this.getAccessToken('', '', true).toPromise().then(() => { }, (error) => {
|
|
723
|
-
console.error(error);
|
|
724
|
-
});
|
|
725
|
-
});
|
|
717
|
+
get small_image_src() {
|
|
718
|
+
return this.getImagePath('small');
|
|
726
719
|
}
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
720
|
+
get thumbnail_image_src() {
|
|
721
|
+
return this.getImagePath('thumb');
|
|
722
|
+
}
|
|
723
|
+
get tiny_image_src() {
|
|
724
|
+
return this.getImagePath('tiny');
|
|
725
|
+
}
|
|
726
|
+
getImagePath(image_size) {
|
|
727
|
+
if (this.image_name !== '') {
|
|
728
|
+
return `${this.image_path}${image_size}/${this.image_name}`;
|
|
729
|
+
}
|
|
730
|
+
return '';
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
class EsolveCategoryTreeService {
|
|
735
|
+
constructor(config, http) {
|
|
736
|
+
this.config = config;
|
|
737
|
+
this.http = http;
|
|
738
|
+
}
|
|
739
|
+
/**
|
|
740
|
+
* Retrieves the category tree from eSolve instance and coverts it to the correct format.
|
|
741
|
+
*/
|
|
742
|
+
getCategoryTree() {
|
|
734
743
|
return this.http
|
|
735
|
-
.
|
|
736
|
-
headers: {
|
|
737
|
-
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;'
|
|
738
|
-
},
|
|
739
|
-
responseType: 'json',
|
|
740
|
-
observe: 'body'
|
|
741
|
-
})
|
|
744
|
+
.get(`${this.config.api_url}/get-tree.php`)
|
|
742
745
|
.pipe(map((response) => {
|
|
743
|
-
if (
|
|
744
|
-
(response.responses.length <= 0)) {
|
|
746
|
+
if (response.records === undefined) {
|
|
745
747
|
throw response;
|
|
746
748
|
}
|
|
747
|
-
|
|
748
|
-
if ((login_response.status.state !== 'success') &&
|
|
749
|
-
(login_response.status.state !== 'warning')) {
|
|
750
|
-
throw login_response;
|
|
751
|
-
}
|
|
752
|
-
for (const response_log of login_response.log) {
|
|
753
|
-
if ((response_log.type === 'success') &&
|
|
754
|
-
(response_log.message_code === 'login_success')) {
|
|
755
|
-
const session_data = login_response.session_data;
|
|
756
|
-
const user_id = +login_response.esolve_id;
|
|
757
|
-
const location_id = +session_data.location_id;
|
|
758
|
-
this.session.handleUpdateSession({
|
|
759
|
-
user_id: user_id,
|
|
760
|
-
location_id: location_id
|
|
761
|
-
});
|
|
762
|
-
return user_id;
|
|
763
|
-
}
|
|
764
|
-
}
|
|
765
|
-
throw login_response;
|
|
766
|
-
}), catchError((errorRes) => {
|
|
767
|
-
return this.errorHandler.handleHttpPostError('set-login', errorRes);
|
|
749
|
+
return this.processTree(response.records);
|
|
768
750
|
}));
|
|
769
751
|
}
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
.pipe(map((responseData) => {
|
|
786
|
-
if ((responseData.type === 'error') ||
|
|
787
|
-
(responseData.type === 'exception') ||
|
|
788
|
-
(!responseData.additional_data.key_okay)) {
|
|
789
|
-
throw responseData;
|
|
752
|
+
/**
|
|
753
|
+
* Retrieve the details of a category tree item from the eSolve instance and
|
|
754
|
+
* converts it to the correct format.
|
|
755
|
+
*
|
|
756
|
+
* @param options Filter options
|
|
757
|
+
*/
|
|
758
|
+
getCategoryTreeItem(options) {
|
|
759
|
+
let type;
|
|
760
|
+
let esolve_id;
|
|
761
|
+
let sef_description;
|
|
762
|
+
if (options.id) {
|
|
763
|
+
const categoryIdentifier = this.processID(options.id);
|
|
764
|
+
if (categoryIdentifier) {
|
|
765
|
+
type = categoryIdentifier.type;
|
|
766
|
+
esolve_id = categoryIdentifier.esolve_id;
|
|
790
767
|
}
|
|
791
|
-
const additional_data = responseData.additional_data;
|
|
792
|
-
const result = {
|
|
793
|
-
key: token,
|
|
794
|
-
expires: additional_data.expires,
|
|
795
|
-
expiry_time: additional_data.expiry_time,
|
|
796
|
-
location_id: additional_data.location_id,
|
|
797
|
-
user_id: additional_data.user_id,
|
|
798
|
-
};
|
|
799
|
-
return result;
|
|
800
|
-
}))
|
|
801
|
-
.toPromise();
|
|
802
|
-
}
|
|
803
|
-
// Handlers
|
|
804
|
-
handleExpiration() {
|
|
805
|
-
return (session) => {
|
|
806
|
-
this.checkAccessToken(session).then((response) => {
|
|
807
|
-
this.handleAuthentication(response);
|
|
808
|
-
}, () => {
|
|
809
|
-
this.logout();
|
|
810
|
-
});
|
|
811
|
-
};
|
|
812
|
-
}
|
|
813
|
-
handleAuthentication(result) {
|
|
814
|
-
if (!result.key) {
|
|
815
|
-
return;
|
|
816
|
-
}
|
|
817
|
-
this.session.handleSession(+result.user_id, +result.location_id, result.key, +result.expiry_time, +result.expires, this.handleExpiration());
|
|
818
|
-
}
|
|
819
|
-
handleError(errorRes) {
|
|
820
|
-
const error = {
|
|
821
|
-
message: 'An unknown error occurred',
|
|
822
|
-
data: {},
|
|
823
|
-
};
|
|
824
|
-
if ((!errorRes.type) ||
|
|
825
|
-
(!errorRes.service_type) ||
|
|
826
|
-
(!errorRes.message)) {
|
|
827
|
-
return throwError(error);
|
|
828
768
|
}
|
|
829
|
-
if (
|
|
830
|
-
|
|
769
|
+
else if (options.type) {
|
|
770
|
+
type = options.type;
|
|
771
|
+
if (options.esolve_id) {
|
|
772
|
+
esolve_id = options.esolve_id;
|
|
773
|
+
}
|
|
774
|
+
else if (options.sef_description) {
|
|
775
|
+
sef_description = options.sef_description;
|
|
776
|
+
}
|
|
831
777
|
}
|
|
832
|
-
if (
|
|
833
|
-
|
|
778
|
+
if (type && (esolve_id || sef_description)) {
|
|
779
|
+
let params = new HttpParams();
|
|
780
|
+
params = params.set('type', type);
|
|
781
|
+
if (esolve_id) {
|
|
782
|
+
params = params.set('id', esolve_id);
|
|
783
|
+
}
|
|
784
|
+
if (sef_description) {
|
|
785
|
+
params = params.set('sef_description', sef_description);
|
|
786
|
+
}
|
|
787
|
+
return this.http
|
|
788
|
+
.get(`${this.config.api_url}/get-tree-item.php`, { params })
|
|
789
|
+
.pipe(map((response) => {
|
|
790
|
+
if ((response.records === undefined) ||
|
|
791
|
+
(response.records.length <= 0)) {
|
|
792
|
+
throw response;
|
|
793
|
+
}
|
|
794
|
+
return this.processTreeItem(response.records[0]);
|
|
795
|
+
}));
|
|
834
796
|
}
|
|
835
|
-
return throwError(
|
|
797
|
+
return throwError('Invalid options');
|
|
836
798
|
}
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
this.country = country;
|
|
863
|
-
this.postal_code = postal_code;
|
|
864
|
-
this.latitude = latitude;
|
|
865
|
-
this.longitude = longitude;
|
|
799
|
+
/**
|
|
800
|
+
* Processes the eSolve tree records and converts them into the correct format.
|
|
801
|
+
*
|
|
802
|
+
* @param tree_records Records to process
|
|
803
|
+
*/
|
|
804
|
+
processTree(tree_records) {
|
|
805
|
+
const tree_items = [];
|
|
806
|
+
if (tree_records) {
|
|
807
|
+
for (const tree_record of tree_records) {
|
|
808
|
+
let esolve_id = '';
|
|
809
|
+
let parent_id = '';
|
|
810
|
+
let children = [];
|
|
811
|
+
if (tree_record.type === 'category') {
|
|
812
|
+
children = this.processTree(tree_record.children);
|
|
813
|
+
esolve_id = tree_record.menu_id;
|
|
814
|
+
parent_id = tree_record.owner_menu_id;
|
|
815
|
+
}
|
|
816
|
+
else {
|
|
817
|
+
esolve_id = tree_record.id;
|
|
818
|
+
parent_id = tree_record.menu_id;
|
|
819
|
+
}
|
|
820
|
+
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));
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
return tree_items;
|
|
866
824
|
}
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
class EsolveAddressResult extends EsolveResponseResult {
|
|
870
|
-
constructor(response) {
|
|
871
|
-
super(response);
|
|
872
|
-
this.id = response.esolve_id;
|
|
873
|
-
this.address_validated = response.address_validated;
|
|
874
|
-
this.geocode_status = response.geocode_status;
|
|
875
|
-
this.geocode_result = response.geocode_result;
|
|
825
|
+
processTreeItem(record) {
|
|
826
|
+
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.image, record.seo_page_title, record.seo_keywords, record.seo_description);
|
|
876
827
|
}
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
828
|
+
processID(id) {
|
|
829
|
+
let type;
|
|
830
|
+
let esolve_id;
|
|
831
|
+
const type_code_regex = /^\<\<(CAT|SUB)\>\>/g;
|
|
832
|
+
const match_results = id.match(type_code_regex);
|
|
833
|
+
if (match_results) {
|
|
834
|
+
const type_code = match_results[0];
|
|
835
|
+
type = (type_code === '<<CAT>>' ? 'category' : 'subcategory');
|
|
836
|
+
esolve_id = id.replace(type_code_regex, '');
|
|
837
|
+
return {
|
|
838
|
+
type,
|
|
839
|
+
esolve_id
|
|
840
|
+
};
|
|
841
|
+
}
|
|
842
|
+
return null;
|
|
890
843
|
}
|
|
891
|
-
}
|
|
844
|
+
}
|
|
845
|
+
EsolveCategoryTreeService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveCategoryTreeService, deps: [{ token: ESOLVE_CONNECT_CONFIG }, { token: i1$2.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
846
|
+
EsolveCategoryTreeService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveCategoryTreeService, providedIn: 'root' });
|
|
847
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveCategoryTreeService, decorators: [{
|
|
848
|
+
type: Injectable,
|
|
849
|
+
args: [{
|
|
850
|
+
providedIn: 'root',
|
|
851
|
+
}]
|
|
852
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
853
|
+
type: Inject,
|
|
854
|
+
args: [ESOLVE_CONNECT_CONFIG]
|
|
855
|
+
}] }, { type: i1$2.HttpClient }]; } });
|
|
892
856
|
|
|
893
|
-
class
|
|
894
|
-
constructor(
|
|
895
|
-
super(response);
|
|
857
|
+
class EsolveManufacturer {
|
|
858
|
+
constructor(record) {
|
|
896
859
|
this.id = 0;
|
|
897
|
-
this.
|
|
860
|
+
this.manufacturer = '';
|
|
861
|
+
this.sef_manufacturer = '';
|
|
862
|
+
this.title = '';
|
|
863
|
+
this.article = '';
|
|
864
|
+
this.sort_priority = 0;
|
|
865
|
+
this.is_active = false;
|
|
866
|
+
this.featured = false;
|
|
867
|
+
this.image_name = '';
|
|
868
|
+
let seo_title = '';
|
|
869
|
+
let seo_keywords = '';
|
|
870
|
+
let seo_description = '';
|
|
871
|
+
if (record) {
|
|
872
|
+
this.id = +(record.id ?? 0);
|
|
873
|
+
this.manufacturer = record.manufacturer ?? '';
|
|
874
|
+
this.sef_manufacturer = record.sef_manufacturer ?? '';
|
|
875
|
+
this.title = record.title ?? '';
|
|
876
|
+
this.article = record.article ?? '';
|
|
877
|
+
this.sort_priority = +(record.sort_priority ?? 0);
|
|
878
|
+
this.image_name = record.image_name ?? '';
|
|
879
|
+
if (record.is_active) {
|
|
880
|
+
this.is_active = !!+record.is_active;
|
|
881
|
+
}
|
|
882
|
+
if (record.featured) {
|
|
883
|
+
this.featured = !!+record.featured;
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
if (this.title.trim() === '') {
|
|
887
|
+
this.title = this.manufacturer;
|
|
888
|
+
}
|
|
889
|
+
if (seo_title.trim() === '') {
|
|
890
|
+
seo_title = this.title;
|
|
891
|
+
}
|
|
892
|
+
this.seo_details = new EsolveSeoInfo(seo_title, seo_description, seo_keywords);
|
|
898
893
|
}
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
class EsolveUserAccountBusiness {
|
|
902
|
-
constructor(name, vat_number, description, type) {
|
|
903
|
-
this.name = name;
|
|
904
|
-
this.vat_number = vat_number;
|
|
905
|
-
this.description = description;
|
|
906
|
-
this.type = type;
|
|
894
|
+
get original_image_src() {
|
|
895
|
+
return this.getImagePath('original');
|
|
907
896
|
}
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
class EsolveUserAccountContact {
|
|
911
|
-
constructor(tel_number, cell_number, fax_number) {
|
|
912
|
-
this.tel_number = tel_number;
|
|
913
|
-
this.cell_number = cell_number;
|
|
914
|
-
this.fax_number = fax_number;
|
|
897
|
+
get small_image_src() {
|
|
898
|
+
return this.getImagePath('small');
|
|
915
899
|
}
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
class EsolveTransactionAddress {
|
|
919
|
-
constructor(recipient, address_type, address_description, street_number, street, suburb, city, province, country, postal_code, pobox) {
|
|
920
|
-
this.recipient = recipient;
|
|
921
|
-
this.address_type = address_type;
|
|
922
|
-
this.address_description = address_description;
|
|
923
|
-
this.street_number = street_number;
|
|
924
|
-
this.street = street;
|
|
925
|
-
this.suburb = suburb;
|
|
926
|
-
this.city = city;
|
|
927
|
-
this.province = province;
|
|
928
|
-
this.country = country;
|
|
929
|
-
this.postal_code = postal_code;
|
|
930
|
-
this.pobox = pobox;
|
|
900
|
+
get thumbnail_image_src() {
|
|
901
|
+
return this.getImagePath('thumb');
|
|
931
902
|
}
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
class EsolveTransactionClient {
|
|
935
|
-
constructor(id, account, company_name, branch_code, email, first_name, last_name, contact_number) {
|
|
936
|
-
this.id = id;
|
|
937
|
-
this.account = account;
|
|
938
|
-
this.company_name = company_name;
|
|
939
|
-
this.branch_code = branch_code;
|
|
940
|
-
this.email = email;
|
|
941
|
-
this.first_name = first_name;
|
|
942
|
-
this.last_name = last_name;
|
|
943
|
-
this.contact_number = contact_number;
|
|
903
|
+
get tiny_image_src() {
|
|
904
|
+
return this.getImagePath('tiny');
|
|
944
905
|
}
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
this.name = name;
|
|
951
|
-
this.qty = qty;
|
|
952
|
-
this.discount = discount;
|
|
953
|
-
this.vat_rate = vat_rate;
|
|
954
|
-
this.price = price;
|
|
955
|
-
this.line_total = line_total;
|
|
906
|
+
getImagePath(image_size) {
|
|
907
|
+
if (this.image_name !== '') {
|
|
908
|
+
return `/images/manufacturers/${image_size}/${this.image_name}`;
|
|
909
|
+
}
|
|
910
|
+
return '';
|
|
956
911
|
}
|
|
957
912
|
}
|
|
958
913
|
|
|
959
|
-
class
|
|
960
|
-
constructor(
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
*/
|
|
964
|
-
price,
|
|
965
|
-
/**
|
|
966
|
-
* Price with tax
|
|
967
|
-
*/
|
|
968
|
-
price_with_tax,
|
|
969
|
-
/**
|
|
970
|
-
* Price without tax and with discounts applied if applicable
|
|
971
|
-
*/
|
|
972
|
-
price_discounted,
|
|
973
|
-
/**
|
|
974
|
-
* Price with tax and with discounts applied if applicable
|
|
975
|
-
*/
|
|
976
|
-
price_with_tax_discounted) {
|
|
977
|
-
this.price = price;
|
|
978
|
-
this.price_with_tax = price_with_tax;
|
|
979
|
-
this.price_discounted = price_discounted;
|
|
980
|
-
this.price_with_tax_discounted = price_with_tax_discounted;
|
|
914
|
+
class EsolveManufacturersService {
|
|
915
|
+
constructor(config, http) {
|
|
916
|
+
this.config = config;
|
|
917
|
+
this.http = http;
|
|
981
918
|
}
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
this.
|
|
987
|
-
this.suburb = suburb;
|
|
988
|
-
this.city = city;
|
|
989
|
-
this.province = province;
|
|
990
|
-
this.country = country;
|
|
991
|
-
this.postal_code = postal_code;
|
|
992
|
-
this.latitude = latitude;
|
|
993
|
-
this.longitude = longitude;
|
|
919
|
+
getManufacturer(id) {
|
|
920
|
+
const params = new HttpParams({
|
|
921
|
+
fromObject: { manufacturers_id: id }
|
|
922
|
+
});
|
|
923
|
+
return this.getManufacturerSingle(params);
|
|
994
924
|
}
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
this.
|
|
1000
|
-
this.cellnumber = cellnumber;
|
|
1001
|
-
this.email = email;
|
|
1002
|
-
this.fax = fax;
|
|
925
|
+
getManufacturerFromSEF(sef_manufacturer) {
|
|
926
|
+
const params = new HttpParams({
|
|
927
|
+
fromObject: { sef_manufacturer }
|
|
928
|
+
});
|
|
929
|
+
return this.getManufacturerSingle(params);
|
|
1003
930
|
}
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
this.
|
|
1010
|
-
|
|
931
|
+
getManufacturers(options) {
|
|
932
|
+
let params = new HttpParams();
|
|
933
|
+
if (options?.featured_only) {
|
|
934
|
+
params = params.set('featured_only', options.featured_only);
|
|
935
|
+
}
|
|
936
|
+
return this.getManufacturerRecords(params).pipe(map((records) => {
|
|
937
|
+
const manufacturers = [];
|
|
938
|
+
for (const record of records) {
|
|
939
|
+
manufacturers.push(this.processManufacturer(record));
|
|
940
|
+
}
|
|
941
|
+
return manufacturers;
|
|
942
|
+
}), catchError(() => {
|
|
943
|
+
return of([]);
|
|
944
|
+
}));
|
|
1011
945
|
}
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
this.tuesday = tuesday;
|
|
1018
|
-
this.wednesday = wednesday;
|
|
1019
|
-
this.thursday = thursday;
|
|
1020
|
-
this.friday = friday;
|
|
1021
|
-
this.saturday = saturday;
|
|
1022
|
-
this.sunday = sunday;
|
|
1023
|
-
this.public_holiday = public_holiday;
|
|
1024
|
-
this.trading_hours_additional_info = trading_hours_additional_info;
|
|
946
|
+
getManufacturerSingle(params) {
|
|
947
|
+
return this.getManufacturerRecords(params).pipe(map((records) => {
|
|
948
|
+
const record = records[0];
|
|
949
|
+
return this.processManufacturer(record);
|
|
950
|
+
}));
|
|
1025
951
|
}
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
952
|
+
getManufacturerRecords(params) {
|
|
953
|
+
return this.http
|
|
954
|
+
.get(`${this.config.api_url}/get-manufacturers.php`, { params })
|
|
955
|
+
.pipe(map((response) => {
|
|
956
|
+
if ((response.records === undefined) ||
|
|
957
|
+
(response.records.length <= 0)) {
|
|
958
|
+
throw response;
|
|
959
|
+
}
|
|
960
|
+
return response.records;
|
|
961
|
+
}));
|
|
1032
962
|
}
|
|
1033
|
-
|
|
963
|
+
processManufacturer(record) {
|
|
964
|
+
return new EsolveManufacturer(record);
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
EsolveManufacturersService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveManufacturersService, deps: [{ token: ESOLVE_CONNECT_CONFIG }, { token: i1$2.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
968
|
+
EsolveManufacturersService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveManufacturersService, providedIn: 'root' });
|
|
969
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveManufacturersService, decorators: [{
|
|
970
|
+
type: Injectable,
|
|
971
|
+
args: [{
|
|
972
|
+
providedIn: 'root',
|
|
973
|
+
}]
|
|
974
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
975
|
+
type: Inject,
|
|
976
|
+
args: [ESOLVE_CONNECT_CONFIG]
|
|
977
|
+
}] }, { type: i1$2.HttpClient }]; } });
|
|
1034
978
|
|
|
1035
|
-
|
|
979
|
+
// Types
|
|
980
|
+
|
|
981
|
+
class EsolveRange {
|
|
1036
982
|
constructor(record) {
|
|
1037
|
-
this.id =
|
|
1038
|
-
this.
|
|
1039
|
-
this.
|
|
1040
|
-
this.
|
|
1041
|
-
this.
|
|
1042
|
-
this.
|
|
1043
|
-
this.
|
|
1044
|
-
this.
|
|
1045
|
-
this.
|
|
1046
|
-
this.
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
983
|
+
this.id = 0;
|
|
984
|
+
this.range = '';
|
|
985
|
+
this.sef_range = '';
|
|
986
|
+
this.manufacturers_id = 0;
|
|
987
|
+
this.title = '';
|
|
988
|
+
this.article = '';
|
|
989
|
+
this.is_active = false;
|
|
990
|
+
this.featured = false;
|
|
991
|
+
this.sort_priority = 0;
|
|
992
|
+
this.image_name = '';
|
|
993
|
+
let seo_title = '';
|
|
994
|
+
let seo_keywords = '';
|
|
995
|
+
let seo_description = '';
|
|
996
|
+
if (record) {
|
|
997
|
+
this.id = +(record.id ?? 0);
|
|
998
|
+
this.range = record.range ?? '';
|
|
999
|
+
this.sef_range = record.sef_range ?? '';
|
|
1000
|
+
this.manufacturers_id = +(record.manufacturers_id ?? 0);
|
|
1001
|
+
this.title = record.title ?? '';
|
|
1002
|
+
this.article = record.article ?? '';
|
|
1003
|
+
this.sort_priority = +(record.sort_priority ?? 0);
|
|
1004
|
+
this.image_name = record.image_name ?? '';
|
|
1005
|
+
if (record.is_active) {
|
|
1006
|
+
this.is_active = !!+record.is_active;
|
|
1007
|
+
}
|
|
1008
|
+
if (record.featured) {
|
|
1009
|
+
this.featured = !!+record.featured;
|
|
1010
|
+
}
|
|
1011
|
+
seo_title = record.seo_page_title ?? '';
|
|
1012
|
+
seo_keywords = record.seo_keywords ?? '';
|
|
1013
|
+
seo_description = record.seo_description ?? '';
|
|
1053
1014
|
}
|
|
1054
|
-
if (
|
|
1055
|
-
|
|
1015
|
+
if (this.title.trim() === '') {
|
|
1016
|
+
this.title = this.range;
|
|
1056
1017
|
}
|
|
1057
|
-
if (
|
|
1058
|
-
|
|
1018
|
+
if (seo_title.trim() === '') {
|
|
1019
|
+
seo_title = this.title;
|
|
1059
1020
|
}
|
|
1060
|
-
this.
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1021
|
+
this.seo_details = new EsolveSeoInfo(seo_title, seo_description, seo_keywords);
|
|
1022
|
+
}
|
|
1023
|
+
get image_src() {
|
|
1024
|
+
return this.getImagePath();
|
|
1025
|
+
}
|
|
1026
|
+
getImagePath() {
|
|
1027
|
+
if (this.image_name !== '') {
|
|
1028
|
+
return `/images/ranges/${this.image_name}`;
|
|
1029
|
+
}
|
|
1030
|
+
return '';
|
|
1070
1031
|
}
|
|
1071
1032
|
}
|
|
1072
1033
|
|
|
1073
|
-
class
|
|
1034
|
+
class EsolveRangesService {
|
|
1074
1035
|
constructor(config, http) {
|
|
1075
1036
|
this.config = config;
|
|
1076
1037
|
this.http = http;
|
|
1077
1038
|
}
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1039
|
+
getRange(id) {
|
|
1040
|
+
const params = new HttpParams({
|
|
1041
|
+
fromObject: { ranges_id: id }
|
|
1042
|
+
});
|
|
1043
|
+
return this.getRangeSingle(params);
|
|
1044
|
+
}
|
|
1045
|
+
getRangeFromSEF(sef_range) {
|
|
1046
|
+
const params = new HttpParams({
|
|
1047
|
+
fromObject: { sef_range }
|
|
1048
|
+
});
|
|
1049
|
+
return this.getRangeSingle(params);
|
|
1050
|
+
}
|
|
1051
|
+
getRanges(options) {
|
|
1052
|
+
let params = new HttpParams();
|
|
1053
|
+
if (options?.featured_only) {
|
|
1054
|
+
params = params.set('featured_only', options.featured_only);
|
|
1055
|
+
}
|
|
1056
|
+
if (options?.manufacturers_id) {
|
|
1057
|
+
params = params.set('manufacturers_id', options.manufacturers_id);
|
|
1058
|
+
}
|
|
1059
|
+
return this.getRangeRecords(params).pipe(map((records) => {
|
|
1060
|
+
const ranges = [];
|
|
1061
|
+
for (const record of records) {
|
|
1062
|
+
ranges.push(this.processRange(record));
|
|
1063
|
+
}
|
|
1064
|
+
return ranges;
|
|
1065
|
+
}), catchError(() => {
|
|
1066
|
+
return of([]);
|
|
1067
|
+
}));
|
|
1068
|
+
}
|
|
1069
|
+
getRangeSingle(params) {
|
|
1070
|
+
return this.getRangeRecords(params).pipe(map((records) => {
|
|
1071
|
+
const record = records[0];
|
|
1072
|
+
return this.processRange(record);
|
|
1073
|
+
}));
|
|
1074
|
+
}
|
|
1075
|
+
getRangeRecords(params) {
|
|
1084
1076
|
return this.http
|
|
1085
|
-
.get(`${this.config.api_url}/get-
|
|
1077
|
+
.get(`${this.config.api_url}/get-ranges.php`, { params })
|
|
1086
1078
|
.pipe(map((response) => {
|
|
1087
|
-
if (response.records === undefined)
|
|
1079
|
+
if ((response.records === undefined) ||
|
|
1080
|
+
(response.records.length <= 0)) {
|
|
1088
1081
|
throw response;
|
|
1089
1082
|
}
|
|
1090
|
-
return
|
|
1083
|
+
return response.records;
|
|
1091
1084
|
}));
|
|
1092
1085
|
}
|
|
1086
|
+
processRange(record) {
|
|
1087
|
+
return new EsolveRange(record);
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
EsolveRangesService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveRangesService, deps: [{ token: ESOLVE_CONNECT_CONFIG }, { token: i1$2.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1091
|
+
EsolveRangesService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveRangesService, providedIn: 'root' });
|
|
1092
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveRangesService, decorators: [{
|
|
1093
|
+
type: Injectable,
|
|
1094
|
+
args: [{
|
|
1095
|
+
providedIn: 'root',
|
|
1096
|
+
}]
|
|
1097
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1098
|
+
type: Inject,
|
|
1099
|
+
args: [ESOLVE_CONNECT_CONFIG]
|
|
1100
|
+
}] }, { type: i1$2.HttpClient }]; } });
|
|
1101
|
+
|
|
1102
|
+
class EsolveTag {
|
|
1103
|
+
constructor(record) {
|
|
1104
|
+
this.id = 0;
|
|
1105
|
+
this.phrase = '';
|
|
1106
|
+
this.weight = 0;
|
|
1107
|
+
this.description = '';
|
|
1108
|
+
this.image_name = '';
|
|
1109
|
+
if (record) {
|
|
1110
|
+
this.id = +(record.id ?? 0);
|
|
1111
|
+
this.phrase = record.tag_phrase ?? '';
|
|
1112
|
+
this.weight = +(record.tag_weight ?? 0);
|
|
1113
|
+
this.description = record.description ?? '';
|
|
1114
|
+
this.image_name = record.image_name ?? '';
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1093
1117
|
/**
|
|
1094
|
-
*
|
|
1118
|
+
* @deprecated To be removed in the future. Use `EsolveTag.phrase` instead
|
|
1119
|
+
*/
|
|
1120
|
+
get tag_phrase() {
|
|
1121
|
+
return this.phrase;
|
|
1122
|
+
}
|
|
1123
|
+
/**
|
|
1124
|
+
* @deprecated To be removed in the future. Use `EsolveTag.weight` instead
|
|
1125
|
+
*/
|
|
1126
|
+
get tag_weight() {
|
|
1127
|
+
return this.weight;
|
|
1128
|
+
}
|
|
1129
|
+
getImagePath() {
|
|
1130
|
+
if (this.image_name !== '') {
|
|
1131
|
+
return `/images/tags/${this.image_name}`;
|
|
1132
|
+
}
|
|
1133
|
+
return '';
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
class EsolveTagsService {
|
|
1138
|
+
constructor(config, http) {
|
|
1139
|
+
this.config = config;
|
|
1140
|
+
this.http = http;
|
|
1141
|
+
}
|
|
1142
|
+
/**
|
|
1143
|
+
* Retrieves active topics from the list of topic ID's. Note that inactive or expired
|
|
1144
|
+
* topics will not be retrieved.
|
|
1095
1145
|
*
|
|
1096
|
-
* @param
|
|
1097
|
-
* @returns An array of processed stock location records
|
|
1146
|
+
* @param options Tag filters
|
|
1098
1147
|
*/
|
|
1099
|
-
|
|
1100
|
-
const
|
|
1148
|
+
getTags(options) {
|
|
1149
|
+
const params = this.parseOptions(options);
|
|
1150
|
+
return this.http.get(`${this.config.api_url}/get-tags.php`, { params }).pipe(map(response => {
|
|
1151
|
+
if (response.records === undefined) {
|
|
1152
|
+
throw response;
|
|
1153
|
+
}
|
|
1154
|
+
return this.processTags(response.records);
|
|
1155
|
+
}));
|
|
1156
|
+
}
|
|
1157
|
+
parseOptions(options) {
|
|
1158
|
+
let params = new HttpParams();
|
|
1159
|
+
if (options) {
|
|
1160
|
+
if (options.tags_id) {
|
|
1161
|
+
if (Array.isArray(options.tags_id)) {
|
|
1162
|
+
const tag_list = options.tags_id;
|
|
1163
|
+
if (tag_list.length > 0) {
|
|
1164
|
+
params = params.append('tags_id', tag_list.join(','));
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
else {
|
|
1168
|
+
params = params.append('tags_id', options.tags_id);
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
else {
|
|
1172
|
+
if (options.phrase && options.phrase !== '') {
|
|
1173
|
+
params = params.append('phrase', options.phrase);
|
|
1174
|
+
const phrase_match_mode = options.phrase_match_mode;
|
|
1175
|
+
if (phrase_match_mode) {
|
|
1176
|
+
params = params.append('phrase_match_mode', phrase_match_mode);
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
return params;
|
|
1182
|
+
}
|
|
1183
|
+
processTags(records) {
|
|
1184
|
+
const tags = [];
|
|
1101
1185
|
if (records) {
|
|
1102
1186
|
for (const record of records) {
|
|
1103
|
-
|
|
1187
|
+
const tag = new EsolveTag(record);
|
|
1188
|
+
tags.push(tag);
|
|
1104
1189
|
}
|
|
1105
1190
|
}
|
|
1106
|
-
return
|
|
1191
|
+
return tags;
|
|
1107
1192
|
}
|
|
1108
1193
|
}
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type:
|
|
1194
|
+
EsolveTagsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveTagsService, deps: [{ token: ESOLVE_CONNECT_CONFIG }, { token: i1$2.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1195
|
+
EsolveTagsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveTagsService, providedIn: 'root' });
|
|
1196
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveTagsService, decorators: [{
|
|
1112
1197
|
type: Injectable,
|
|
1113
1198
|
args: [{
|
|
1114
1199
|
providedIn: 'root',
|
|
@@ -1118,422 +1203,664 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImpor
|
|
|
1118
1203
|
args: [ESOLVE_CONNECT_CONFIG]
|
|
1119
1204
|
}] }, { type: i1$2.HttpClient }]; } });
|
|
1120
1205
|
|
|
1121
|
-
|
|
1122
|
-
}
|
|
1206
|
+
// Types
|
|
1123
1207
|
|
|
1124
|
-
class
|
|
1125
|
-
constructor(
|
|
1126
|
-
this.id =
|
|
1127
|
-
this.name =
|
|
1128
|
-
this.
|
|
1129
|
-
this.
|
|
1130
|
-
|
|
1208
|
+
class EsolveTopic {
|
|
1209
|
+
constructor(record) {
|
|
1210
|
+
this.id = 0;
|
|
1211
|
+
this.name = '';
|
|
1212
|
+
this.short_description = '';
|
|
1213
|
+
this.sort_priority = 0;
|
|
1214
|
+
if (record) {
|
|
1215
|
+
this.id = +(record.id ?? 0);
|
|
1216
|
+
this.name = record.name ?? '';
|
|
1217
|
+
this.short_description = record.short_description ?? '';
|
|
1218
|
+
this.sort_priority = +(record.sort_priority ?? 0);
|
|
1219
|
+
}
|
|
1131
1220
|
}
|
|
1132
1221
|
}
|
|
1133
1222
|
|
|
1134
|
-
class
|
|
1135
|
-
constructor(
|
|
1136
|
-
this.
|
|
1137
|
-
this.
|
|
1138
|
-
this.delivery_category = delivery_category;
|
|
1139
|
-
this.location = location;
|
|
1140
|
-
this.description = description;
|
|
1141
|
-
this.pricing = pricing;
|
|
1142
|
-
this.client_to_collect = client_to_collect;
|
|
1223
|
+
class EsolveTopicService {
|
|
1224
|
+
constructor(config, http) {
|
|
1225
|
+
this.config = config;
|
|
1226
|
+
this.http = http;
|
|
1143
1227
|
}
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1228
|
+
/**
|
|
1229
|
+
* Retrieves active topics from the list of topic ID's. Note that inactive or expired
|
|
1230
|
+
* topics will not be retrieved.
|
|
1231
|
+
*
|
|
1232
|
+
* @param topic_id_list List of topic ID's that need to be retrieved
|
|
1233
|
+
*/
|
|
1234
|
+
getTopics(topic_id_list = []) {
|
|
1235
|
+
let params = new HttpParams();
|
|
1236
|
+
if (topic_id_list.length > 0) {
|
|
1237
|
+
params = params.append('topic_id', topic_id_list.join(','));
|
|
1238
|
+
}
|
|
1239
|
+
return this.http.get(`${this.config.api_url}/get-topics.php`, { params }).pipe(map(response => {
|
|
1240
|
+
if (response.records === undefined) {
|
|
1241
|
+
throw response;
|
|
1242
|
+
}
|
|
1243
|
+
return this.processTopics(response.records);
|
|
1244
|
+
}));
|
|
1154
1245
|
}
|
|
1155
|
-
|
|
1246
|
+
processTopics(records) {
|
|
1247
|
+
const topics = [];
|
|
1248
|
+
if (records) {
|
|
1249
|
+
for (const record of records) {
|
|
1250
|
+
const topic = new EsolveTopic(record);
|
|
1251
|
+
topics.push(topic);
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
return topics;
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
1257
|
+
EsolveTopicService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveTopicService, deps: [{ token: ESOLVE_CONNECT_CONFIG }, { token: i1$2.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1258
|
+
EsolveTopicService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveTopicService, providedIn: 'root' });
|
|
1259
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveTopicService, decorators: [{
|
|
1260
|
+
type: Injectable,
|
|
1261
|
+
args: [{
|
|
1262
|
+
providedIn: 'root',
|
|
1263
|
+
}]
|
|
1264
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1265
|
+
type: Inject,
|
|
1266
|
+
args: [ESOLVE_CONNECT_CONFIG]
|
|
1267
|
+
}] }, { type: i1$2.HttpClient }]; } });
|
|
1156
1268
|
|
|
1157
|
-
class
|
|
1269
|
+
class EsolveAsset {
|
|
1158
1270
|
constructor(record) {
|
|
1159
|
-
|
|
1160
|
-
this.
|
|
1271
|
+
this.id = 0;
|
|
1272
|
+
this.src = '';
|
|
1273
|
+
this.name = '';
|
|
1274
|
+
this.description = '';
|
|
1275
|
+
this.document_number = '';
|
|
1276
|
+
this.document_type = '';
|
|
1277
|
+
this.area_of_application = '';
|
|
1278
|
+
this.asset_category = '';
|
|
1279
|
+
this.asset_sub_category = '';
|
|
1280
|
+
this.sort_priority = 0;
|
|
1281
|
+
this.topics = [];
|
|
1282
|
+
this.tags = [];
|
|
1283
|
+
this.image_name = '';
|
|
1161
1284
|
this.id = +record.id;
|
|
1162
|
-
this.
|
|
1163
|
-
this.
|
|
1164
|
-
this.
|
|
1165
|
-
this.
|
|
1166
|
-
this.
|
|
1167
|
-
this.
|
|
1168
|
-
this.
|
|
1169
|
-
this.
|
|
1170
|
-
this.
|
|
1171
|
-
this.
|
|
1172
|
-
this.
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
this.payment = +record.payment;
|
|
1176
|
-
this.payment_reference = record.payment_reference;
|
|
1177
|
-
this.payment_description = record.payment_description;
|
|
1178
|
-
this.gateway_transaction_id = record.gateway_transaction_id;
|
|
1179
|
-
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);
|
|
1180
|
-
if (record.user) {
|
|
1181
|
-
this.user = new EsolveTransactionUser(+record.user.id, record.user.email, record.user.firstname, record.user.surname, record.user.telnumber, record.user.cellnumber);
|
|
1285
|
+
this.src = record.src;
|
|
1286
|
+
this.name = record.name;
|
|
1287
|
+
this.type = record.type;
|
|
1288
|
+
this.description = record.description;
|
|
1289
|
+
this.document_number = record.document_number ?? '';
|
|
1290
|
+
this.document_type = record.document_type ?? '';
|
|
1291
|
+
this.area_of_application = record.area_of_application ?? '';
|
|
1292
|
+
this.asset_category = record.asset_category ?? '';
|
|
1293
|
+
this.asset_sub_category = record.asset_sub_category ?? '';
|
|
1294
|
+
this.sort_priority = +(record.sort_priority ?? '');
|
|
1295
|
+
this.image_name = record.image_name ?? '';
|
|
1296
|
+
if (record.created) {
|
|
1297
|
+
this.created = record.created;
|
|
1182
1298
|
}
|
|
1183
|
-
if (record.
|
|
1184
|
-
this.
|
|
1299
|
+
if (record.category) {
|
|
1300
|
+
this.category = new EsolveCategoryTreeItem(record.category.type, record.category.id, record.category.parent_id, record.category.description, record.category.sef_description, record.category.short_description, record.category.sort_priority, record.category.active, record.category.display_only, record.category.image, record.category.seo_page_title, record.category.seo_keywords, record.category.seo_description);
|
|
1185
1301
|
}
|
|
1186
|
-
if (record.
|
|
1187
|
-
this.
|
|
1302
|
+
if (record.subcategory) {
|
|
1303
|
+
this.subcategory = new EsolveCategoryTreeItem(record.subcategory.type, record.subcategory.id, record.subcategory.parent_id, record.subcategory.description, record.subcategory.sef_description, record.subcategory.short_description, record.subcategory.sort_priority, record.subcategory.active, record.subcategory.display_only, record.subcategory.image, record.subcategory.seo_page_title, record.subcategory.seo_keywords, record.subcategory.seo_description);
|
|
1188
1304
|
}
|
|
1189
|
-
if (record.
|
|
1190
|
-
this.
|
|
1305
|
+
if (record.manufacturer) {
|
|
1306
|
+
this.manufacturer = new EsolveManufacturer(record.manufacturer);
|
|
1191
1307
|
}
|
|
1192
|
-
if (record.
|
|
1193
|
-
this.
|
|
1308
|
+
if (record.range) {
|
|
1309
|
+
this.range = new EsolveRange(record.range);
|
|
1194
1310
|
}
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1311
|
+
if (record.topics && record.topics.length > 0) {
|
|
1312
|
+
for (const topic of record.topics) {
|
|
1313
|
+
this.topics.push(new EsolveTopic(topic));
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
if (record.tags && record.tags.length > 0) {
|
|
1317
|
+
for (const tag of record.tags) {
|
|
1318
|
+
this.tags.push(new EsolveTag(tag));
|
|
1319
|
+
}
|
|
1203
1320
|
}
|
|
1204
1321
|
}
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
// Classes
|
|
1211
|
-
|
|
1212
|
-
class EsolveChangePasswordResult extends EsolveResponseResult {
|
|
1213
|
-
constructor(response) {
|
|
1214
|
-
super(response);
|
|
1215
|
-
this.password_updated = (response.status.state === 'success');
|
|
1216
|
-
}
|
|
1217
|
-
}
|
|
1218
|
-
|
|
1219
|
-
class EsolveResetPasswordResult extends EsolveResponseResult {
|
|
1220
|
-
constructor(response) {
|
|
1221
|
-
super(response);
|
|
1222
|
-
this.id = response.esolve_id;
|
|
1223
|
-
this.reset_success = response.reset_success;
|
|
1224
|
-
this.password_matches_old = response.password_matches_old;
|
|
1225
|
-
this.login_required = response.login_required;
|
|
1226
|
-
}
|
|
1227
|
-
}
|
|
1228
|
-
|
|
1229
|
-
class EsolveRegistrationResult extends EsolveResponseResult {
|
|
1230
|
-
constructor(response) {
|
|
1231
|
-
super(response);
|
|
1232
|
-
this.user_id = response.esolve_id;
|
|
1233
|
-
this.guest = response.guest;
|
|
1234
|
-
this.auto_login = response.auto_login;
|
|
1235
|
-
this.authentication_required = response.authentication_required;
|
|
1236
|
-
this.location_id = response.session_data.location_id;
|
|
1322
|
+
/**
|
|
1323
|
+
* Shortcut to `getImagePath()`
|
|
1324
|
+
*/
|
|
1325
|
+
get image_src() {
|
|
1326
|
+
return this.getImagePath();
|
|
1237
1327
|
}
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1328
|
+
/**
|
|
1329
|
+
* Retrieve image path
|
|
1330
|
+
*
|
|
1331
|
+
* @returns Image path on CDN, else empty string if no image exists
|
|
1332
|
+
*/
|
|
1333
|
+
getImagePath() {
|
|
1334
|
+
if (this.image_name !== '') {
|
|
1335
|
+
return `/images/documents/${this.image_name}`;
|
|
1336
|
+
}
|
|
1337
|
+
return '';
|
|
1244
1338
|
}
|
|
1245
1339
|
}
|
|
1246
1340
|
|
|
1247
|
-
class
|
|
1248
|
-
constructor(config, http
|
|
1341
|
+
class EsolveAssetsService {
|
|
1342
|
+
constructor(config, http) {
|
|
1249
1343
|
this.config = config;
|
|
1250
1344
|
this.http = http;
|
|
1251
|
-
this.sessionService = sessionService;
|
|
1252
|
-
this.errorHandler = errorHandler;
|
|
1253
|
-
this.responseHandler = responseHandler;
|
|
1254
|
-
this._user_id = 0;
|
|
1255
|
-
this.sessionService.session.subscribe((session) => {
|
|
1256
|
-
if (session.key !== '') {
|
|
1257
|
-
this.user_id = session.id;
|
|
1258
|
-
}
|
|
1259
|
-
});
|
|
1260
|
-
}
|
|
1261
|
-
get user_id() {
|
|
1262
|
-
return this._user_id;
|
|
1263
|
-
}
|
|
1264
|
-
set user_id(value) {
|
|
1265
|
-
value = ((value > 0) ? value : 0);
|
|
1266
|
-
if (this._user_id !== value) {
|
|
1267
|
-
this._user_id = value;
|
|
1268
|
-
}
|
|
1269
|
-
}
|
|
1270
|
-
updateUserAccount(user_account_data) {
|
|
1271
|
-
const body = {
|
|
1272
|
-
account: user_account_data
|
|
1273
|
-
};
|
|
1274
|
-
return this.http
|
|
1275
|
-
.post(`${this.config.api_url}/set-user-account.php`, body, {
|
|
1276
|
-
headers: {
|
|
1277
|
-
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;'
|
|
1278
|
-
},
|
|
1279
|
-
responseType: 'json',
|
|
1280
|
-
observe: 'body'
|
|
1281
|
-
})
|
|
1282
|
-
.pipe(map((http_response) => this.responseHandler.validateSingleHttpResponse(http_response, (response) => new EsolveUserAccountResult(response))), catchError((errorRes) => {
|
|
1283
|
-
return this.errorHandler.handleHttpPostError('set-user-account', errorRes);
|
|
1284
|
-
}));
|
|
1285
1345
|
}
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
.pipe(map((response) => {
|
|
1346
|
+
getAsset(id) {
|
|
1347
|
+
const params = new HttpParams({ fromObject: { assets_id: id } });
|
|
1348
|
+
return this.getAssetRecords(params).pipe(map((response) => {
|
|
1290
1349
|
if ((response.records === undefined) ||
|
|
1291
|
-
(response.records.length
|
|
1350
|
+
(response.records.length <= 0)) {
|
|
1292
1351
|
throw response;
|
|
1293
1352
|
}
|
|
1294
1353
|
const record = response.records[0];
|
|
1295
|
-
return this.
|
|
1354
|
+
return this.processAsset(record);
|
|
1296
1355
|
}));
|
|
1297
1356
|
}
|
|
1298
|
-
|
|
1299
|
-
const
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
return
|
|
1357
|
+
getAssets(options) {
|
|
1358
|
+
const params = this.parseOptions(options);
|
|
1359
|
+
return this.getAssetRecords(params).pipe(map((response) => {
|
|
1360
|
+
if (response.records === undefined) {
|
|
1361
|
+
throw response;
|
|
1362
|
+
}
|
|
1363
|
+
const assets = [];
|
|
1364
|
+
for (const record of response.records) {
|
|
1365
|
+
assets.push(this.processAsset(record));
|
|
1366
|
+
}
|
|
1367
|
+
const page = options?.page ?? 0;
|
|
1368
|
+
const rows = options?.rows ?? 0;
|
|
1369
|
+
const total = +response.additional_data.total_records;
|
|
1370
|
+
return new EsolveList(assets, page, rows, total);
|
|
1312
1371
|
}));
|
|
1313
1372
|
}
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
this.loginGuard();
|
|
1317
|
-
return this.http
|
|
1318
|
-
.get(`${this.config.api_url}/get-addresses.php`, {
|
|
1319
|
-
params: { user_id: this.user_id }
|
|
1320
|
-
})
|
|
1321
|
-
.pipe(map((response) => {
|
|
1322
|
-
if (response.records === undefined) {
|
|
1323
|
-
throw response;
|
|
1324
|
-
}
|
|
1325
|
-
return this.processUserAddress(response.records);
|
|
1326
|
-
}));
|
|
1327
|
-
}
|
|
1328
|
-
catch (error) {
|
|
1329
|
-
return throwError(error);
|
|
1330
|
-
}
|
|
1373
|
+
processAsset(record) {
|
|
1374
|
+
return new EsolveAsset(record);
|
|
1331
1375
|
}
|
|
1332
|
-
|
|
1333
|
-
return this.http
|
|
1334
|
-
.delete(`${this.config.api_url}/delete-address.php`, {
|
|
1335
|
-
params: { id },
|
|
1336
|
-
responseType: 'json',
|
|
1337
|
-
observe: 'body'
|
|
1338
|
-
})
|
|
1339
|
-
.pipe(map((http_response) => {
|
|
1340
|
-
if ((http_response.result === undefined) ||
|
|
1341
|
-
(http_response.result === null) ||
|
|
1342
|
-
(http_response.result.status !== 'success')) {
|
|
1343
|
-
throw http_response;
|
|
1344
|
-
}
|
|
1345
|
-
return new EsolveResult(http_response.result.status, http_response.result.code, http_response.result.message);
|
|
1346
|
-
}), catchError((errorRes) => {
|
|
1347
|
-
return this.errorHandler.handleHttpDeleteError('delete-address', errorRes);
|
|
1348
|
-
}));
|
|
1376
|
+
getAssetRecords(params) {
|
|
1377
|
+
return this.http.get(`${this.config.api_url}/get-assets.php`, { params });
|
|
1349
1378
|
}
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1379
|
+
parseOptions(options) {
|
|
1380
|
+
let params = new HttpParams();
|
|
1381
|
+
if (!options) {
|
|
1382
|
+
return params;
|
|
1383
|
+
}
|
|
1384
|
+
if (options.page) {
|
|
1385
|
+
params = params.set('page', options.page);
|
|
1386
|
+
}
|
|
1387
|
+
if (options.rows) {
|
|
1388
|
+
params = params.set('rows', options.rows);
|
|
1389
|
+
}
|
|
1390
|
+
if (options.asset_type) {
|
|
1391
|
+
params = params.set('asset_type', options.asset_type);
|
|
1392
|
+
}
|
|
1393
|
+
if (options.category_id) {
|
|
1394
|
+
params = params.set('category_id', options.category_id);
|
|
1395
|
+
}
|
|
1396
|
+
if (options.subcategory_id) {
|
|
1397
|
+
params = params.set('subcategory_id', options.subcategory_id);
|
|
1398
|
+
}
|
|
1399
|
+
if (options.manufacturers_id) {
|
|
1400
|
+
params = params.set('manufacturers_id', options.manufacturers_id);
|
|
1401
|
+
}
|
|
1402
|
+
if (options.ranges_id) {
|
|
1403
|
+
params = params.set('ranges_id', options.ranges_id);
|
|
1404
|
+
}
|
|
1405
|
+
if (options.asset_category) {
|
|
1406
|
+
params = params.set('asset_category', options.asset_category);
|
|
1407
|
+
}
|
|
1408
|
+
if (options.asset_sub_category) {
|
|
1409
|
+
params = params.set('asset_sub_category', options.asset_sub_category);
|
|
1410
|
+
}
|
|
1411
|
+
if (options.document_number) {
|
|
1412
|
+
params = params.set('document_number', options.document_number);
|
|
1413
|
+
}
|
|
1414
|
+
if (options.document_type) {
|
|
1415
|
+
params = params.set('document_type', options.document_type);
|
|
1416
|
+
}
|
|
1417
|
+
if (options.area_of_application) {
|
|
1418
|
+
params = params.set('area_of_application', options.area_of_application);
|
|
1419
|
+
}
|
|
1420
|
+
return params;
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
EsolveAssetsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveAssetsService, deps: [{ token: ESOLVE_CONNECT_CONFIG }, { token: i1$2.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1424
|
+
EsolveAssetsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveAssetsService, providedIn: 'root' });
|
|
1425
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveAssetsService, decorators: [{
|
|
1426
|
+
type: Injectable,
|
|
1427
|
+
args: [{
|
|
1428
|
+
providedIn: 'root',
|
|
1429
|
+
}]
|
|
1430
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1431
|
+
type: Inject,
|
|
1432
|
+
args: [ESOLVE_CONNECT_CONFIG]
|
|
1433
|
+
}] }, { type: i1$2.HttpClient }]; } });
|
|
1434
|
+
|
|
1435
|
+
// Types
|
|
1436
|
+
|
|
1437
|
+
class EsolveAuthService {
|
|
1438
|
+
constructor(config, http, session, errorHandler, cookieService) {
|
|
1439
|
+
this.config = config;
|
|
1440
|
+
this.http = http;
|
|
1441
|
+
this.session = session;
|
|
1442
|
+
this.errorHandler = errorHandler;
|
|
1443
|
+
this.cookieService = cookieService;
|
|
1444
|
+
}
|
|
1445
|
+
getAccessToken(email, password, anonymous = false) {
|
|
1446
|
+
let params = new HttpParams();
|
|
1447
|
+
if (anonymous) {
|
|
1448
|
+
params = params.set('anonymous', true);
|
|
1449
|
+
}
|
|
1450
|
+
if (email !== '') {
|
|
1451
|
+
params = params.set('email', email);
|
|
1452
|
+
}
|
|
1453
|
+
if (password !== '') {
|
|
1454
|
+
params = params.set('password', password);
|
|
1455
|
+
}
|
|
1354
1456
|
return this.http
|
|
1355
|
-
.
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
observe: 'body'
|
|
1457
|
+
.get(`${this.config.api_url}/get-access-token.php`, {
|
|
1458
|
+
params,
|
|
1459
|
+
headers: new HttpHeaders({
|
|
1460
|
+
'Accept-Language': '*',
|
|
1461
|
+
}),
|
|
1361
1462
|
})
|
|
1362
|
-
.pipe(
|
|
1363
|
-
if (
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
location_id: +response.session_data.location_id,
|
|
1367
|
-
});
|
|
1463
|
+
.pipe(tap((responseData) => {
|
|
1464
|
+
if ((responseData.type === 'error') ||
|
|
1465
|
+
(responseData.type === 'exception')) {
|
|
1466
|
+
throw responseData;
|
|
1368
1467
|
}
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
return this.errorHandler.handleHttpPostError('set-registration', errorRes);
|
|
1468
|
+
}), catchError(this.handleError), tap((responseData) => {
|
|
1469
|
+
this.handleAuthentication(responseData.additional_data);
|
|
1372
1470
|
}));
|
|
1373
1471
|
}
|
|
1374
|
-
|
|
1472
|
+
autoLogin() {
|
|
1473
|
+
this.session.restore(this.handleExpiration(), () => {
|
|
1474
|
+
this.getAccessToken('', '', true).toPromise().then(() => { }, (error) => {
|
|
1475
|
+
console.error(error);
|
|
1476
|
+
});
|
|
1477
|
+
});
|
|
1478
|
+
}
|
|
1479
|
+
login(email, password) {
|
|
1375
1480
|
const body = {
|
|
1376
|
-
|
|
1377
|
-
|
|
1481
|
+
login: {
|
|
1482
|
+
email,
|
|
1483
|
+
password
|
|
1484
|
+
}
|
|
1378
1485
|
};
|
|
1379
1486
|
return this.http
|
|
1380
|
-
.post(`${this.config.api_url}/set-
|
|
1487
|
+
.post(`${this.config.api_url}/set-login.php`, body, {
|
|
1381
1488
|
headers: {
|
|
1382
1489
|
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;'
|
|
1383
1490
|
},
|
|
1384
1491
|
responseType: 'json',
|
|
1385
1492
|
observe: 'body'
|
|
1386
1493
|
})
|
|
1387
|
-
.pipe(map((http_response) => this.responseHandler.validateSingleHttpResponse(http_response, (response) => {
|
|
1388
|
-
return new EsolveChangePasswordResult(response);
|
|
1389
|
-
})), catchError((errorRes) => {
|
|
1390
|
-
return this.errorHandler.handleHttpPostError('set-change-password', errorRes);
|
|
1391
|
-
}));
|
|
1392
|
-
}
|
|
1393
|
-
sendForgotPasswordRequest(email) {
|
|
1394
|
-
return this.http
|
|
1395
|
-
.get(`${this.config.api_url}/get-forgot-password.php`, { params: { email } })
|
|
1396
1494
|
.pipe(map((response) => {
|
|
1397
|
-
if ((response.
|
|
1398
|
-
|
|
1495
|
+
if ((response.responses === undefined) ||
|
|
1496
|
+
(response.responses.length <= 0)) {
|
|
1399
1497
|
throw response;
|
|
1400
1498
|
}
|
|
1401
|
-
|
|
1499
|
+
const login_response = response.responses[0];
|
|
1500
|
+
if ((login_response.status.state !== 'success') &&
|
|
1501
|
+
(login_response.status.state !== 'warning')) {
|
|
1502
|
+
throw login_response;
|
|
1503
|
+
}
|
|
1504
|
+
for (const response_log of login_response.log) {
|
|
1505
|
+
if ((response_log.type === 'success') &&
|
|
1506
|
+
(response_log.message_code === 'login_success')) {
|
|
1507
|
+
const session_data = login_response.session_data;
|
|
1508
|
+
const user_id = +login_response.esolve_id;
|
|
1509
|
+
const location_id = +session_data.location_id;
|
|
1510
|
+
this.session.handleUpdateSession({
|
|
1511
|
+
user_id: user_id,
|
|
1512
|
+
location_id: location_id
|
|
1513
|
+
});
|
|
1514
|
+
return user_id;
|
|
1515
|
+
}
|
|
1516
|
+
}
|
|
1517
|
+
throw login_response;
|
|
1518
|
+
}), catchError((errorRes) => {
|
|
1519
|
+
return this.errorHandler.handleHttpPostError('set-login', errorRes);
|
|
1402
1520
|
}));
|
|
1403
1521
|
}
|
|
1404
|
-
|
|
1522
|
+
logout() {
|
|
1523
|
+
this.session.clearTimer();
|
|
1524
|
+
this.cookieService.delete('_ws_id');
|
|
1525
|
+
return this.getAccessToken('', '', true).toPromise();
|
|
1526
|
+
}
|
|
1527
|
+
checkAccessToken(session) {
|
|
1528
|
+
session = session || this.session.currentSession;
|
|
1529
|
+
const token = session?.key ?? '';
|
|
1405
1530
|
return this.http
|
|
1406
|
-
.
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
}, {
|
|
1412
|
-
headers: {
|
|
1413
|
-
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;'
|
|
1414
|
-
},
|
|
1415
|
-
responseType: 'json',
|
|
1416
|
-
observe: 'body'
|
|
1531
|
+
.get(`${this.config.api_url}/get-access-token.php`, {
|
|
1532
|
+
params: { key: token },
|
|
1533
|
+
headers: new HttpHeaders({
|
|
1534
|
+
'Accept-Language': '*'
|
|
1535
|
+
}),
|
|
1417
1536
|
})
|
|
1418
|
-
.pipe(map((
|
|
1419
|
-
if (
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
});
|
|
1537
|
+
.pipe(map((responseData) => {
|
|
1538
|
+
if ((responseData.type === 'error') ||
|
|
1539
|
+
(responseData.type === 'exception') ||
|
|
1540
|
+
(!responseData.additional_data.key_okay)) {
|
|
1541
|
+
throw responseData;
|
|
1424
1542
|
}
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1543
|
+
const additional_data = responseData.additional_data;
|
|
1544
|
+
const result = {
|
|
1545
|
+
key: token,
|
|
1546
|
+
expires: additional_data.expires,
|
|
1547
|
+
expiry_time: additional_data.expiry_time,
|
|
1548
|
+
location_id: additional_data.location_id,
|
|
1549
|
+
user_id: additional_data.user_id,
|
|
1550
|
+
};
|
|
1551
|
+
return result;
|
|
1552
|
+
}))
|
|
1553
|
+
.toPromise();
|
|
1429
1554
|
}
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
return
|
|
1433
|
-
.
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
})
|
|
1440
|
-
.pipe(map((http_response) => this.responseHandler.validateSingleHttpResponse(http_response, (response) => {
|
|
1441
|
-
this.sessionService.handleUpdateSession({ location_id });
|
|
1442
|
-
return new EsolveLocationUpdateResult(response);
|
|
1443
|
-
})));
|
|
1555
|
+
// Handlers
|
|
1556
|
+
handleExpiration() {
|
|
1557
|
+
return (session) => {
|
|
1558
|
+
this.checkAccessToken(session).then((response) => {
|
|
1559
|
+
this.handleAuthentication(response);
|
|
1560
|
+
}, () => {
|
|
1561
|
+
this.logout();
|
|
1562
|
+
});
|
|
1563
|
+
};
|
|
1444
1564
|
}
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
return this.http
|
|
1449
|
-
.get(`${this.config.api_url}/get-transactions.php`, {
|
|
1450
|
-
params: {
|
|
1451
|
-
user_id: this.user_id,
|
|
1452
|
-
...options,
|
|
1453
|
-
}
|
|
1454
|
-
})
|
|
1455
|
-
.pipe(map((response) => {
|
|
1456
|
-
if (response.records === undefined) {
|
|
1457
|
-
throw response;
|
|
1458
|
-
}
|
|
1459
|
-
const items = this.processTransactions(response.records);
|
|
1460
|
-
const total = +response.additional_data.total_records ?? 0;
|
|
1461
|
-
const rows = options.rows ?? total;
|
|
1462
|
-
const page = options.page || 1;
|
|
1463
|
-
return new EsolveTransactionList(items, page, rows, total);
|
|
1464
|
-
}));
|
|
1565
|
+
handleAuthentication(result) {
|
|
1566
|
+
if (!result.key) {
|
|
1567
|
+
return;
|
|
1465
1568
|
}
|
|
1466
|
-
|
|
1569
|
+
this.session.handleSession(+result.user_id, +result.location_id, result.key, +result.expiry_time, +result.expires, this.handleExpiration());
|
|
1570
|
+
}
|
|
1571
|
+
handleError(errorRes) {
|
|
1572
|
+
const error = {
|
|
1573
|
+
message: 'An unknown error occurred',
|
|
1574
|
+
data: {},
|
|
1575
|
+
};
|
|
1576
|
+
if ((!errorRes.type) ||
|
|
1577
|
+
(!errorRes.service_type) ||
|
|
1578
|
+
(!errorRes.message)) {
|
|
1467
1579
|
return throwError(error);
|
|
1468
1580
|
}
|
|
1581
|
+
if (errorRes.message.trim() !== '') {
|
|
1582
|
+
error.message = errorRes.message;
|
|
1583
|
+
}
|
|
1584
|
+
if (errorRes.additional_data) {
|
|
1585
|
+
error.data = errorRes.additional_data;
|
|
1586
|
+
}
|
|
1587
|
+
return throwError(error);
|
|
1588
|
+
}
|
|
1589
|
+
}
|
|
1590
|
+
EsolveAuthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveAuthService, deps: [{ token: ESOLVE_CONNECT_CONFIG }, { token: i1$2.HttpClient }, { token: EsolveSessionService }, { token: EsolveErrorHandlerService }, { token: EsolveCookieService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1591
|
+
EsolveAuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveAuthService, providedIn: 'root' });
|
|
1592
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveAuthService, decorators: [{
|
|
1593
|
+
type: Injectable,
|
|
1594
|
+
args: [{
|
|
1595
|
+
providedIn: 'root',
|
|
1596
|
+
}]
|
|
1597
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1598
|
+
type: Inject,
|
|
1599
|
+
args: [ESOLVE_CONNECT_CONFIG]
|
|
1600
|
+
}] }, { type: i1$2.HttpClient }, { type: EsolveSessionService }, { type: EsolveErrorHandlerService }, { type: EsolveCookieService }]; } });
|
|
1601
|
+
|
|
1602
|
+
class EsolveAddress {
|
|
1603
|
+
constructor(id, recipient, address_type, pobox, place_name, street_number, street, suburb, city, province, country, postal_code, latitude, longitude) {
|
|
1604
|
+
this.id = id;
|
|
1605
|
+
this.recipient = recipient;
|
|
1606
|
+
this.address_type = address_type;
|
|
1607
|
+
this.pobox = pobox;
|
|
1608
|
+
this.place_name = place_name;
|
|
1609
|
+
this.street_number = street_number;
|
|
1610
|
+
this.street = street;
|
|
1611
|
+
this.suburb = suburb;
|
|
1612
|
+
this.city = city;
|
|
1613
|
+
this.province = province;
|
|
1614
|
+
this.country = country;
|
|
1615
|
+
this.postal_code = postal_code;
|
|
1616
|
+
this.latitude = latitude;
|
|
1617
|
+
this.longitude = longitude;
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
|
|
1621
|
+
class EsolveAddressResult extends EsolveResponseResult {
|
|
1622
|
+
constructor(response) {
|
|
1623
|
+
super(response);
|
|
1624
|
+
this.id = response.esolve_id;
|
|
1625
|
+
this.address_validated = response.address_validated;
|
|
1626
|
+
this.geocode_status = response.geocode_status;
|
|
1627
|
+
this.geocode_result = response.geocode_result;
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1630
|
+
|
|
1631
|
+
class EsolveUserAccount {
|
|
1632
|
+
constructor(esolve_id, email, registration_type, title, first_name, last_name, initials, gender, identification_number) {
|
|
1633
|
+
this.esolve_id = esolve_id;
|
|
1634
|
+
this.email = email;
|
|
1635
|
+
this.registration_type = registration_type;
|
|
1636
|
+
this.title = title;
|
|
1637
|
+
this.first_name = first_name;
|
|
1638
|
+
this.last_name = last_name;
|
|
1639
|
+
this.initials = initials;
|
|
1640
|
+
this.gender = gender;
|
|
1641
|
+
this.identification_number = identification_number;
|
|
1642
|
+
}
|
|
1643
|
+
}
|
|
1644
|
+
|
|
1645
|
+
class EsolveUserAccountResult extends EsolveResponseResult {
|
|
1646
|
+
constructor(response) {
|
|
1647
|
+
super(response);
|
|
1648
|
+
this.id = 0;
|
|
1649
|
+
this.id = +response.esolve_id;
|
|
1650
|
+
}
|
|
1651
|
+
}
|
|
1652
|
+
|
|
1653
|
+
class EsolveUserAccountBusiness {
|
|
1654
|
+
constructor(name, vat_number, description, type) {
|
|
1655
|
+
this.name = name;
|
|
1656
|
+
this.vat_number = vat_number;
|
|
1657
|
+
this.description = description;
|
|
1658
|
+
this.type = type;
|
|
1659
|
+
}
|
|
1660
|
+
}
|
|
1661
|
+
|
|
1662
|
+
class EsolveUserAccountContact {
|
|
1663
|
+
constructor(tel_number, cell_number, fax_number) {
|
|
1664
|
+
this.tel_number = tel_number;
|
|
1665
|
+
this.cell_number = cell_number;
|
|
1666
|
+
this.fax_number = fax_number;
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
|
|
1670
|
+
class EsolveTransactionAddress {
|
|
1671
|
+
constructor(recipient, address_type, address_description, street_number, street, suburb, city, province, country, postal_code, pobox) {
|
|
1672
|
+
this.recipient = recipient;
|
|
1673
|
+
this.address_type = address_type;
|
|
1674
|
+
this.address_description = address_description;
|
|
1675
|
+
this.street_number = street_number;
|
|
1676
|
+
this.street = street;
|
|
1677
|
+
this.suburb = suburb;
|
|
1678
|
+
this.city = city;
|
|
1679
|
+
this.province = province;
|
|
1680
|
+
this.country = country;
|
|
1681
|
+
this.postal_code = postal_code;
|
|
1682
|
+
this.pobox = pobox;
|
|
1683
|
+
}
|
|
1684
|
+
}
|
|
1685
|
+
|
|
1686
|
+
class EsolveTransactionClient {
|
|
1687
|
+
constructor(id, account, company_name, branch_code, email, first_name, last_name, contact_number) {
|
|
1688
|
+
this.id = id;
|
|
1689
|
+
this.account = account;
|
|
1690
|
+
this.company_name = company_name;
|
|
1691
|
+
this.branch_code = branch_code;
|
|
1692
|
+
this.email = email;
|
|
1693
|
+
this.first_name = first_name;
|
|
1694
|
+
this.last_name = last_name;
|
|
1695
|
+
this.contact_number = contact_number;
|
|
1696
|
+
}
|
|
1697
|
+
}
|
|
1698
|
+
|
|
1699
|
+
class EsolveTransactionItem {
|
|
1700
|
+
constructor(code, name, qty, discount, vat_rate, price, line_total) {
|
|
1701
|
+
this.code = code;
|
|
1702
|
+
this.name = name;
|
|
1703
|
+
this.qty = qty;
|
|
1704
|
+
this.discount = discount;
|
|
1705
|
+
this.vat_rate = vat_rate;
|
|
1706
|
+
this.price = price;
|
|
1707
|
+
this.line_total = line_total;
|
|
1708
|
+
}
|
|
1709
|
+
}
|
|
1710
|
+
|
|
1711
|
+
class EsolveTransactionItemPrice {
|
|
1712
|
+
constructor(
|
|
1713
|
+
/**
|
|
1714
|
+
* Price without tax
|
|
1715
|
+
*/
|
|
1716
|
+
price,
|
|
1717
|
+
/**
|
|
1718
|
+
* Price with tax
|
|
1719
|
+
*/
|
|
1720
|
+
price_with_tax,
|
|
1721
|
+
/**
|
|
1722
|
+
* Price without tax and with discounts applied if applicable
|
|
1723
|
+
*/
|
|
1724
|
+
price_discounted,
|
|
1725
|
+
/**
|
|
1726
|
+
* Price with tax and with discounts applied if applicable
|
|
1727
|
+
*/
|
|
1728
|
+
price_with_tax_discounted) {
|
|
1729
|
+
this.price = price;
|
|
1730
|
+
this.price_with_tax = price_with_tax;
|
|
1731
|
+
this.price_discounted = price_discounted;
|
|
1732
|
+
this.price_with_tax_discounted = price_with_tax_discounted;
|
|
1733
|
+
}
|
|
1734
|
+
}
|
|
1735
|
+
|
|
1736
|
+
class EsolveLocationAddress {
|
|
1737
|
+
constructor(street, suburb, city, province, country, postal_code, latitude, longitude) {
|
|
1738
|
+
this.street = street;
|
|
1739
|
+
this.suburb = suburb;
|
|
1740
|
+
this.city = city;
|
|
1741
|
+
this.province = province;
|
|
1742
|
+
this.country = country;
|
|
1743
|
+
this.postal_code = postal_code;
|
|
1744
|
+
this.latitude = latitude;
|
|
1745
|
+
this.longitude = longitude;
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1748
|
+
|
|
1749
|
+
class EsolveLocationContactInfo {
|
|
1750
|
+
constructor(telnumber, cellnumber, email, fax) {
|
|
1751
|
+
this.telnumber = telnumber;
|
|
1752
|
+
this.cellnumber = cellnumber;
|
|
1753
|
+
this.email = email;
|
|
1754
|
+
this.fax = fax;
|
|
1755
|
+
}
|
|
1756
|
+
}
|
|
1757
|
+
|
|
1758
|
+
class EsolveLocationPOBoxAddress {
|
|
1759
|
+
constructor(pobox, city, postal_code) {
|
|
1760
|
+
this.pobox = pobox;
|
|
1761
|
+
this.city = city;
|
|
1762
|
+
this.postal_code = postal_code;
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1765
|
+
|
|
1766
|
+
class EsolveLocationTradingTimes {
|
|
1767
|
+
constructor(monday, tuesday, wednesday, thursday, friday, saturday, sunday, public_holiday, trading_hours_additional_info = '') {
|
|
1768
|
+
this.monday = monday;
|
|
1769
|
+
this.tuesday = tuesday;
|
|
1770
|
+
this.wednesday = wednesday;
|
|
1771
|
+
this.thursday = thursday;
|
|
1772
|
+
this.friday = friday;
|
|
1773
|
+
this.saturday = saturday;
|
|
1774
|
+
this.sunday = sunday;
|
|
1775
|
+
this.public_holiday = public_holiday;
|
|
1776
|
+
this.trading_hours_additional_info = trading_hours_additional_info;
|
|
1469
1777
|
}
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
user_id: this.user_id,
|
|
1477
|
-
transaction_id: id,
|
|
1478
|
-
}
|
|
1479
|
-
})
|
|
1480
|
-
.pipe(map((response) => {
|
|
1481
|
-
if ((response.records === undefined) ||
|
|
1482
|
-
(response.records.length <= 0)) {
|
|
1483
|
-
throw response;
|
|
1484
|
-
}
|
|
1485
|
-
const items = this.processTransactions(response.records);
|
|
1486
|
-
return items[0];
|
|
1487
|
-
}));
|
|
1488
|
-
}
|
|
1489
|
-
catch (error) {
|
|
1490
|
-
return throwError(error);
|
|
1491
|
-
}
|
|
1778
|
+
}
|
|
1779
|
+
|
|
1780
|
+
class EsolveLocationTradingDay {
|
|
1781
|
+
constructor(open, close) {
|
|
1782
|
+
this.open = open;
|
|
1783
|
+
this.close = close;
|
|
1492
1784
|
}
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1785
|
+
}
|
|
1786
|
+
|
|
1787
|
+
class EsolveLocation {
|
|
1788
|
+
constructor(record) {
|
|
1789
|
+
this.id = +record.id;
|
|
1790
|
+
this.identifier = record.identifier;
|
|
1791
|
+
this.description = record.description;
|
|
1792
|
+
this.head_office = record.head_office;
|
|
1793
|
+
this.erp_identifier = record.erp_identifier;
|
|
1794
|
+
this.external_system_code = record.external_system_code;
|
|
1795
|
+
this.default_location_for_payment_methods = record.default_location_for_payment_methods;
|
|
1796
|
+
this.userid = +record.userid;
|
|
1797
|
+
this.importance = +record.importance;
|
|
1798
|
+
this.active = record.is_active;
|
|
1799
|
+
this.website_url = record.website_url;
|
|
1800
|
+
this.address = new EsolveLocationAddress(record.street, record.suburb, record.city, record.province, record.country, record.postal_code, +record.latitude, +record.longitude);
|
|
1801
|
+
this.pobox_address = new EsolveLocationPOBoxAddress(record.pobox, record.pobox_city, record.pobox_postal_code);
|
|
1802
|
+
const telnumbers = [];
|
|
1803
|
+
if (record.branch_telnumber.length > 0) {
|
|
1804
|
+
telnumbers.push(record.branch_telnumber);
|
|
1496
1805
|
}
|
|
1497
|
-
if (
|
|
1498
|
-
|
|
1806
|
+
if (record.branch_telnumber_2.length > 0) {
|
|
1807
|
+
telnumbers.push(record.branch_telnumber_2);
|
|
1499
1808
|
}
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
user_account.business_details = new EsolveUserAccountBusiness(record.busname, record.vatnum, record.busdescript, record.business_type);
|
|
1503
|
-
return user_account;
|
|
1504
|
-
}
|
|
1505
|
-
processUserAddress(records) {
|
|
1506
|
-
const user_addresses = [];
|
|
1507
|
-
if (!records || (this._user_id === 0)) {
|
|
1508
|
-
return user_addresses;
|
|
1809
|
+
if (record.branch_telnumber_3.length > 0) {
|
|
1810
|
+
telnumbers.push(record.branch_telnumber_3);
|
|
1509
1811
|
}
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1812
|
+
this.contact_info = new EsolveLocationContactInfo(telnumbers, record.branch_cellnumber, record.branch_email, record.branch_fax);
|
|
1813
|
+
const monday = new EsolveLocationTradingDay(record.monday_open_time, record.monday_close_time);
|
|
1814
|
+
const tuesday = new EsolveLocationTradingDay(record.tuesday_open_time, record.tuesday_close_time);
|
|
1815
|
+
const wednesday = new EsolveLocationTradingDay(record.wednesday_open_time, record.wednesday_close_time);
|
|
1816
|
+
const thursday = new EsolveLocationTradingDay(record.thursday_open_time, record.thursday_close_time);
|
|
1817
|
+
const friday = new EsolveLocationTradingDay(record.friday_open_time, record.friday_close_time);
|
|
1818
|
+
const saturday = new EsolveLocationTradingDay(record.saturday_open_time, record.saturday_close_time);
|
|
1819
|
+
const sunday = new EsolveLocationTradingDay(record.sunday_open_time, record.sunday_close_time);
|
|
1820
|
+
const public_holiday = new EsolveLocationTradingDay(record.public_holiday_open_time, record.public_holiday_close_time);
|
|
1821
|
+
this.trading_times = new EsolveLocationTradingTimes(monday, tuesday, wednesday, thursday, friday, saturday, sunday, public_holiday, record.trading_hours_additional_info);
|
|
1822
|
+
}
|
|
1823
|
+
}
|
|
1824
|
+
|
|
1825
|
+
class EsolveLocationsService {
|
|
1826
|
+
constructor(config, http) {
|
|
1827
|
+
this.config = config;
|
|
1828
|
+
this.http = http;
|
|
1829
|
+
}
|
|
1830
|
+
/**
|
|
1831
|
+
* Retrieves a list of stock locations
|
|
1832
|
+
*
|
|
1833
|
+
* @returns An `Observable` with an array of stock locations
|
|
1834
|
+
*/
|
|
1835
|
+
getStockLocations() {
|
|
1836
|
+
return this.http
|
|
1837
|
+
.get(`${this.config.api_url}/get-locations.php`)
|
|
1838
|
+
.pipe(map((response) => {
|
|
1839
|
+
if (response.records === undefined) {
|
|
1840
|
+
throw response;
|
|
1513
1841
|
}
|
|
1514
|
-
|
|
1515
|
-
}
|
|
1516
|
-
return user_addresses;
|
|
1842
|
+
return this.processStockLocations(response.records);
|
|
1843
|
+
}));
|
|
1517
1844
|
}
|
|
1518
|
-
|
|
1519
|
-
|
|
1845
|
+
/**
|
|
1846
|
+
* Processes the eSolve stock location records.
|
|
1847
|
+
*
|
|
1848
|
+
* @param records Records to process
|
|
1849
|
+
* @returns An array of processed stock location records
|
|
1850
|
+
*/
|
|
1851
|
+
processStockLocations(records) {
|
|
1852
|
+
const stock_locations = [];
|
|
1520
1853
|
if (records) {
|
|
1521
1854
|
for (const record of records) {
|
|
1522
|
-
|
|
1523
|
-
transactions.push(transaction);
|
|
1855
|
+
stock_locations.push(new EsolveLocation(record));
|
|
1524
1856
|
}
|
|
1525
1857
|
}
|
|
1526
|
-
return
|
|
1527
|
-
}
|
|
1528
|
-
loginGuard() {
|
|
1529
|
-
if (this.user_id <= 0) {
|
|
1530
|
-
this.errorHandler.throwError('login_required', 'Login is required');
|
|
1531
|
-
}
|
|
1858
|
+
return stock_locations;
|
|
1532
1859
|
}
|
|
1533
1860
|
}
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type:
|
|
1861
|
+
EsolveLocationsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveLocationsService, deps: [{ token: ESOLVE_CONNECT_CONFIG }, { token: i1$2.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1862
|
+
EsolveLocationsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveLocationsService, providedIn: 'root' });
|
|
1863
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveLocationsService, decorators: [{
|
|
1537
1864
|
type: Injectable,
|
|
1538
1865
|
args: [{
|
|
1539
1866
|
providedIn: 'root',
|
|
@@ -1541,397 +1868,424 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImpor
|
|
|
1541
1868
|
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1542
1869
|
type: Inject,
|
|
1543
1870
|
args: [ESOLVE_CONNECT_CONFIG]
|
|
1544
|
-
}] }, { type: i1$2.HttpClient }
|
|
1871
|
+
}] }, { type: i1$2.HttpClient }]; } });
|
|
1545
1872
|
|
|
1546
|
-
class
|
|
1547
|
-
|
|
1873
|
+
class EsolveTransactionLocation extends EsolveLocation {
|
|
1874
|
+
}
|
|
1875
|
+
|
|
1876
|
+
class EsolveTransactionPaymentMethod {
|
|
1877
|
+
constructor(id, name, description, integration_type, service_provider) {
|
|
1548
1878
|
this.id = id;
|
|
1549
|
-
this.
|
|
1550
|
-
this.
|
|
1551
|
-
this.
|
|
1552
|
-
this.
|
|
1553
|
-
this.article = article;
|
|
1554
|
-
this.sort_priority = sort_priority;
|
|
1555
|
-
this.link = link;
|
|
1556
|
-
this.desktop_images = [];
|
|
1557
|
-
this.mobile_images = [];
|
|
1558
|
-
this.sub_images = [];
|
|
1559
|
-
if (images.desktop) {
|
|
1560
|
-
this.desktop_images = images.desktop;
|
|
1561
|
-
}
|
|
1562
|
-
if (images.mobile) {
|
|
1563
|
-
this.mobile_images = images.mobile;
|
|
1564
|
-
}
|
|
1565
|
-
if (images.sub) {
|
|
1566
|
-
this.sub_images = images.sub;
|
|
1567
|
-
}
|
|
1879
|
+
this.name = name;
|
|
1880
|
+
this.description = description;
|
|
1881
|
+
this.integration_type = integration_type;
|
|
1882
|
+
this.service_provider = service_provider;
|
|
1568
1883
|
}
|
|
1569
1884
|
}
|
|
1570
1885
|
|
|
1571
|
-
class
|
|
1572
|
-
constructor(id,
|
|
1886
|
+
class EsolveTransactionShippingMethod {
|
|
1887
|
+
constructor(id, name, delivery_category, location, description, pricing, client_to_collect) {
|
|
1573
1888
|
this.id = id;
|
|
1574
|
-
this.
|
|
1575
|
-
this.
|
|
1576
|
-
this.
|
|
1577
|
-
this.
|
|
1578
|
-
this.
|
|
1579
|
-
|
|
1580
|
-
get src() {
|
|
1581
|
-
return '/images/banners/' + this.filename;
|
|
1889
|
+
this.name = name;
|
|
1890
|
+
this.delivery_category = delivery_category;
|
|
1891
|
+
this.location = location;
|
|
1892
|
+
this.description = description;
|
|
1893
|
+
this.pricing = pricing;
|
|
1894
|
+
this.client_to_collect = client_to_collect;
|
|
1582
1895
|
}
|
|
1583
1896
|
}
|
|
1584
1897
|
|
|
1585
|
-
class
|
|
1586
|
-
constructor(
|
|
1587
|
-
this.
|
|
1588
|
-
this.
|
|
1589
|
-
this.
|
|
1590
|
-
this.
|
|
1898
|
+
class EsolveTransactionUser {
|
|
1899
|
+
constructor(id, email, first_name, last_name, tel_number, cell_number) {
|
|
1900
|
+
this.id = id;
|
|
1901
|
+
this.email = email;
|
|
1902
|
+
this.first_name = first_name;
|
|
1903
|
+
this.last_name = last_name;
|
|
1904
|
+
this.tel_number = tel_number;
|
|
1905
|
+
this.cell_number = cell_number;
|
|
1591
1906
|
}
|
|
1592
1907
|
}
|
|
1593
1908
|
|
|
1594
|
-
class
|
|
1595
|
-
constructor(
|
|
1596
|
-
|
|
1597
|
-
this.
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
}
|
|
1620
|
-
return this.processBanners(response.records);
|
|
1621
|
-
}));
|
|
1622
|
-
}
|
|
1623
|
-
processBannerImageHotspots(hotspot_records) {
|
|
1624
|
-
const hotspots = [];
|
|
1625
|
-
if (hotspot_records.length > 0) {
|
|
1626
|
-
for (const hotspot_record of hotspot_records) {
|
|
1627
|
-
const hotspot = new EsolveBannerImageHotspot(hotspot_record.url, hotspot_record.target, hotspot_record.coords, hotspot_record.coords_string);
|
|
1628
|
-
hotspots.push(hotspot);
|
|
1629
|
-
}
|
|
1909
|
+
class EsolveTransaction {
|
|
1910
|
+
constructor(record) {
|
|
1911
|
+
// Transaction Items
|
|
1912
|
+
this.items = [];
|
|
1913
|
+
this.id = +record.id;
|
|
1914
|
+
this.type = record.transaction_type;
|
|
1915
|
+
this.status = record.status;
|
|
1916
|
+
this.loyalty_number = record.loyaltynumber;
|
|
1917
|
+
this.external_order_number = record.external_order_number;
|
|
1918
|
+
this.external_invoice_number = record.external_invoice_number;
|
|
1919
|
+
this.date = new Date(+record.txdate_timestamp * 1000);
|
|
1920
|
+
this.expected_date = new Date(+record.expected_date_timestamp * 1000);
|
|
1921
|
+
this.invoice_amount = +record.invoice_amount;
|
|
1922
|
+
this.vat = +record.vat;
|
|
1923
|
+
this.discount = +record.discount;
|
|
1924
|
+
this.total = +record.total;
|
|
1925
|
+
this.shipping_total = +record.shipping_total;
|
|
1926
|
+
this.insurance_total = +record.insurance_total;
|
|
1927
|
+
this.payment = +record.payment;
|
|
1928
|
+
this.payment_reference = record.payment_reference;
|
|
1929
|
+
this.payment_description = record.payment_description;
|
|
1930
|
+
this.gateway_transaction_id = record.gateway_transaction_id;
|
|
1931
|
+
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);
|
|
1932
|
+
if (record.user) {
|
|
1933
|
+
this.user = new EsolveTransactionUser(+record.user.id, record.user.email, record.user.firstname, record.user.surname, record.user.telnumber, record.user.cellnumber);
|
|
1630
1934
|
}
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
processBannerImages(image_records, banner_type) {
|
|
1634
|
-
const images = [];
|
|
1635
|
-
if (image_records.length > 0) {
|
|
1636
|
-
for (const image_record of image_records) {
|
|
1637
|
-
const image = new EsolveBannerImage(+image_record.id, image_record.image_type, +image_record.width, +image_record.height, image_record.filename);
|
|
1638
|
-
if ((banner_type === 'hotspot') && (image_record.hotspots)) {
|
|
1639
|
-
const hotspots = this.processBannerImageHotspots(image_record.hotspots);
|
|
1640
|
-
image.hotspots = hotspots;
|
|
1641
|
-
}
|
|
1642
|
-
images.push(image);
|
|
1643
|
-
}
|
|
1935
|
+
if (record.client) {
|
|
1936
|
+
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);
|
|
1644
1937
|
}
|
|
1645
|
-
|
|
1938
|
+
if (record.location_details) {
|
|
1939
|
+
this.location = new EsolveTransactionLocation(record.location_details);
|
|
1940
|
+
}
|
|
1941
|
+
if (record.payment_method_details) {
|
|
1942
|
+
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);
|
|
1943
|
+
}
|
|
1944
|
+
if (record.shipping_method_details) {
|
|
1945
|
+
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);
|
|
1946
|
+
}
|
|
1947
|
+
this.parseTransactionItems(record.transaction_items);
|
|
1646
1948
|
}
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
const banners = [];
|
|
1654
|
-
if ((records) && (records.length > 0)) {
|
|
1655
|
-
for (const record of records) {
|
|
1656
|
-
const image_sets = {};
|
|
1657
|
-
if (record.images.desktop) {
|
|
1658
|
-
image_sets.desktop = this.processBannerImages(record.images.desktop, record.type);
|
|
1659
|
-
}
|
|
1660
|
-
if (record.images.mobile) {
|
|
1661
|
-
image_sets.mobile = this.processBannerImages(record.images.mobile, record.type);
|
|
1662
|
-
}
|
|
1663
|
-
if (record.images.sub) {
|
|
1664
|
-
image_sets.sub = this.processBannerImages(record.images.sub, record.type);
|
|
1665
|
-
}
|
|
1666
|
-
const banner = new EsolveBanner(+record.id, record.banner_display_container, record.identifier, record.type, record.title, record.article, +record.sort_priority, {
|
|
1667
|
-
url: record.link.url,
|
|
1668
|
-
target: record.link.target
|
|
1669
|
-
}, image_sets);
|
|
1670
|
-
banners.push(banner);
|
|
1671
|
-
}
|
|
1949
|
+
parseTransactionItems(record_items) {
|
|
1950
|
+
for (const record_item of record_items) {
|
|
1951
|
+
const price = new EsolveTransactionItemPrice(+record_item.price_exclusive, +record_item.price_inclusive, +record_item.price_exclusive_after_discount, +record_item.price_inclusive_after_discount);
|
|
1952
|
+
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);
|
|
1953
|
+
const item = new EsolveTransactionItem(record_item.code, record_item.name, +record_item.qty, +record_item.discount, +record_item.vat_rate, price, line_total);
|
|
1954
|
+
this.items.push(item);
|
|
1672
1955
|
}
|
|
1673
|
-
return banners;
|
|
1674
1956
|
}
|
|
1675
|
-
}
|
|
1676
|
-
EsolveBannerService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveBannerService, deps: [{ token: ESOLVE_CONNECT_CONFIG }, { token: i1$2.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1677
|
-
EsolveBannerService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveBannerService, providedIn: 'root' });
|
|
1678
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveBannerService, decorators: [{
|
|
1679
|
-
type: Injectable,
|
|
1680
|
-
args: [{
|
|
1681
|
-
providedIn: 'root',
|
|
1682
|
-
}]
|
|
1683
|
-
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1684
|
-
type: Inject,
|
|
1685
|
-
args: [ESOLVE_CONNECT_CONFIG]
|
|
1686
|
-
}] }, { type: i1$2.HttpClient }]; } });
|
|
1957
|
+
}
|
|
1687
1958
|
|
|
1688
|
-
|
|
1959
|
+
class EsolveTransactionList extends EsolveList {
|
|
1960
|
+
}
|
|
1689
1961
|
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1962
|
+
// Classes
|
|
1963
|
+
|
|
1964
|
+
class EsolveChangePasswordResult extends EsolveResponseResult {
|
|
1965
|
+
constructor(response) {
|
|
1966
|
+
super(response);
|
|
1967
|
+
this.password_updated = (response.status.state === 'success');
|
|
1694
1968
|
}
|
|
1695
1969
|
}
|
|
1696
1970
|
|
|
1697
|
-
class
|
|
1698
|
-
constructor(
|
|
1699
|
-
|
|
1700
|
-
this.
|
|
1701
|
-
this.
|
|
1702
|
-
this.
|
|
1703
|
-
this.
|
|
1704
|
-
this.topics = topics;
|
|
1705
|
-
if (seo_title.trim() === '') {
|
|
1706
|
-
seo_title = this.title;
|
|
1707
|
-
}
|
|
1708
|
-
this.seo_details = new EsolveSeoInfo(seo_title, seo_description, seo_keywords);
|
|
1971
|
+
class EsolveResetPasswordResult extends EsolveResponseResult {
|
|
1972
|
+
constructor(response) {
|
|
1973
|
+
super(response);
|
|
1974
|
+
this.id = response.esolve_id;
|
|
1975
|
+
this.reset_success = response.reset_success;
|
|
1976
|
+
this.password_matches_old = response.password_matches_old;
|
|
1977
|
+
this.login_required = response.login_required;
|
|
1709
1978
|
}
|
|
1710
1979
|
}
|
|
1711
1980
|
|
|
1712
|
-
class
|
|
1713
|
-
constructor(
|
|
1714
|
-
|
|
1715
|
-
this.
|
|
1716
|
-
this.
|
|
1717
|
-
this.
|
|
1981
|
+
class EsolveRegistrationResult extends EsolveResponseResult {
|
|
1982
|
+
constructor(response) {
|
|
1983
|
+
super(response);
|
|
1984
|
+
this.user_id = response.esolve_id;
|
|
1985
|
+
this.guest = response.guest;
|
|
1986
|
+
this.auto_login = response.auto_login;
|
|
1987
|
+
this.authentication_required = response.authentication_required;
|
|
1988
|
+
this.location_id = response.session_data.location_id;
|
|
1718
1989
|
}
|
|
1719
1990
|
}
|
|
1720
1991
|
|
|
1721
|
-
class
|
|
1722
|
-
constructor(
|
|
1723
|
-
|
|
1724
|
-
this.
|
|
1725
|
-
this.short_description = short_description;
|
|
1726
|
-
this.sort_priority = sort_priority;
|
|
1992
|
+
class EsolveLocationUpdateResult extends EsolveResponseResult {
|
|
1993
|
+
constructor(response) {
|
|
1994
|
+
super(response);
|
|
1995
|
+
this.location_updated = (response.esolve_id > 0);
|
|
1727
1996
|
}
|
|
1728
1997
|
}
|
|
1729
1998
|
|
|
1730
|
-
class
|
|
1731
|
-
constructor(config, http) {
|
|
1999
|
+
class EsolveAccountService {
|
|
2000
|
+
constructor(config, http, sessionService, errorHandler, responseHandler) {
|
|
1732
2001
|
this.config = config;
|
|
1733
2002
|
this.http = http;
|
|
2003
|
+
this.sessionService = sessionService;
|
|
2004
|
+
this.errorHandler = errorHandler;
|
|
2005
|
+
this.responseHandler = responseHandler;
|
|
2006
|
+
this._user_id = 0;
|
|
2007
|
+
this.sessionService.session.subscribe((session) => {
|
|
2008
|
+
if (session.key !== '') {
|
|
2009
|
+
this.user_id = session.id;
|
|
2010
|
+
}
|
|
2011
|
+
});
|
|
1734
2012
|
}
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
let params = new HttpParams();
|
|
1743
|
-
if (topic_id_list.length > 0) {
|
|
1744
|
-
params = params.append('topic_id', topic_id_list.join(','));
|
|
2013
|
+
get user_id() {
|
|
2014
|
+
return this._user_id;
|
|
2015
|
+
}
|
|
2016
|
+
set user_id(value) {
|
|
2017
|
+
value = ((value > 0) ? value : 0);
|
|
2018
|
+
if (this._user_id !== value) {
|
|
2019
|
+
this._user_id = value;
|
|
1745
2020
|
}
|
|
1746
|
-
|
|
1747
|
-
|
|
2021
|
+
}
|
|
2022
|
+
updateUserAccount(user_account_data) {
|
|
2023
|
+
const body = {
|
|
2024
|
+
account: user_account_data
|
|
2025
|
+
};
|
|
2026
|
+
return this.http
|
|
2027
|
+
.post(`${this.config.api_url}/set-user-account.php`, body, {
|
|
2028
|
+
headers: {
|
|
2029
|
+
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;'
|
|
2030
|
+
},
|
|
2031
|
+
responseType: 'json',
|
|
2032
|
+
observe: 'body'
|
|
2033
|
+
})
|
|
2034
|
+
.pipe(map((http_response) => this.responseHandler.validateSingleHttpResponse(http_response, (response) => new EsolveUserAccountResult(response))), catchError((errorRes) => {
|
|
2035
|
+
return this.errorHandler.handleHttpPostError('set-user-account', errorRes);
|
|
2036
|
+
}));
|
|
2037
|
+
}
|
|
2038
|
+
getUserAccount() {
|
|
2039
|
+
return this.http
|
|
2040
|
+
.get(`${this.config.api_url}/get-account.php`)
|
|
2041
|
+
.pipe(map((response) => {
|
|
2042
|
+
if ((response.records === undefined) ||
|
|
2043
|
+
(response.records.length === 0)) {
|
|
1748
2044
|
throw response;
|
|
1749
2045
|
}
|
|
1750
|
-
|
|
2046
|
+
const record = response.records[0];
|
|
2047
|
+
return this.processUserAccount(record);
|
|
2048
|
+
}));
|
|
2049
|
+
}
|
|
2050
|
+
setAddress(address_post_data) {
|
|
2051
|
+
const body = {
|
|
2052
|
+
address: address_post_data
|
|
2053
|
+
};
|
|
2054
|
+
return this.http
|
|
2055
|
+
.post(`${this.config.api_url}/set-address.php`, body, {
|
|
2056
|
+
headers: {
|
|
2057
|
+
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;',
|
|
2058
|
+
},
|
|
2059
|
+
responseType: 'json',
|
|
2060
|
+
observe: 'body',
|
|
2061
|
+
})
|
|
2062
|
+
.pipe(map((http_response) => this.responseHandler.validateSingleHttpResponse(http_response, (response) => new EsolveAddressResult(response))), catchError((errorRes) => {
|
|
2063
|
+
return this.errorHandler.handleHttpPostError('set-registration', errorRes);
|
|
2064
|
+
}));
|
|
2065
|
+
}
|
|
2066
|
+
getAddresses() {
|
|
2067
|
+
try {
|
|
2068
|
+
this.loginGuard();
|
|
2069
|
+
return this.http
|
|
2070
|
+
.get(`${this.config.api_url}/get-addresses.php`, {
|
|
2071
|
+
params: { user_id: this.user_id }
|
|
2072
|
+
})
|
|
2073
|
+
.pipe(map((response) => {
|
|
2074
|
+
if (response.records === undefined) {
|
|
2075
|
+
throw response;
|
|
2076
|
+
}
|
|
2077
|
+
return this.processUserAddress(response.records);
|
|
2078
|
+
}));
|
|
2079
|
+
}
|
|
2080
|
+
catch (error) {
|
|
2081
|
+
return throwError(error);
|
|
2082
|
+
}
|
|
2083
|
+
}
|
|
2084
|
+
deleteAddress(id) {
|
|
2085
|
+
return this.http
|
|
2086
|
+
.delete(`${this.config.api_url}/delete-address.php`, {
|
|
2087
|
+
params: { id },
|
|
2088
|
+
responseType: 'json',
|
|
2089
|
+
observe: 'body'
|
|
2090
|
+
})
|
|
2091
|
+
.pipe(map((http_response) => {
|
|
2092
|
+
if ((http_response.result === undefined) ||
|
|
2093
|
+
(http_response.result === null) ||
|
|
2094
|
+
(http_response.result.status !== 'success')) {
|
|
2095
|
+
throw http_response;
|
|
2096
|
+
}
|
|
2097
|
+
return new EsolveResult(http_response.result.status, http_response.result.code, http_response.result.message);
|
|
2098
|
+
}), catchError((errorRes) => {
|
|
2099
|
+
return this.errorHandler.handleHttpDeleteError('delete-address', errorRes);
|
|
2100
|
+
}));
|
|
2101
|
+
}
|
|
2102
|
+
register(user_registration) {
|
|
2103
|
+
const body = {
|
|
2104
|
+
user: user_registration
|
|
2105
|
+
};
|
|
2106
|
+
return this.http
|
|
2107
|
+
.post(`${this.config.api_url}/set-registration.php`, body, {
|
|
2108
|
+
headers: {
|
|
2109
|
+
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;'
|
|
2110
|
+
},
|
|
2111
|
+
responseType: 'json',
|
|
2112
|
+
observe: 'body'
|
|
2113
|
+
})
|
|
2114
|
+
.pipe(map((http_response) => this.responseHandler.validateSingleHttpResponse(http_response, (response) => {
|
|
2115
|
+
if (response.auto_login) {
|
|
2116
|
+
this.sessionService.handleUpdateSession({
|
|
2117
|
+
user_id: +response.esolve_id,
|
|
2118
|
+
location_id: +response.session_data.location_id,
|
|
2119
|
+
});
|
|
2120
|
+
}
|
|
2121
|
+
return new EsolveRegistrationResult(response);
|
|
2122
|
+
})), catchError((errorRes) => {
|
|
2123
|
+
return this.errorHandler.handleHttpPostError('set-registration', errorRes);
|
|
1751
2124
|
}));
|
|
1752
2125
|
}
|
|
1753
|
-
|
|
1754
|
-
const
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
}
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1772
|
-
type: Inject,
|
|
1773
|
-
args: [ESOLVE_CONNECT_CONFIG]
|
|
1774
|
-
}] }, { type: i1$2.HttpClient }]; } });
|
|
1775
|
-
|
|
1776
|
-
class EsolveMediaService {
|
|
1777
|
-
constructor(config, http) {
|
|
1778
|
-
this.config = config;
|
|
1779
|
-
this.http = http;
|
|
2126
|
+
changePassword(password, confirm_password) {
|
|
2127
|
+
const body = {
|
|
2128
|
+
password,
|
|
2129
|
+
confirm_password
|
|
2130
|
+
};
|
|
2131
|
+
return this.http
|
|
2132
|
+
.post(`${this.config.api_url}/set-change-password.php`, body, {
|
|
2133
|
+
headers: {
|
|
2134
|
+
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;'
|
|
2135
|
+
},
|
|
2136
|
+
responseType: 'json',
|
|
2137
|
+
observe: 'body'
|
|
2138
|
+
})
|
|
2139
|
+
.pipe(map((http_response) => this.responseHandler.validateSingleHttpResponse(http_response, (response) => {
|
|
2140
|
+
return new EsolveChangePasswordResult(response);
|
|
2141
|
+
})), catchError((errorRes) => {
|
|
2142
|
+
return this.errorHandler.handleHttpPostError('set-change-password', errorRes);
|
|
2143
|
+
}));
|
|
1780
2144
|
}
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
*/
|
|
1786
|
-
getMediaArticle(identifier) {
|
|
1787
|
-
const params = new HttpParams({ fromObject: { identifier } });
|
|
1788
|
-
// TODO: Error Handling
|
|
1789
|
-
return this.getMediaRecords(params).pipe(map((response) => {
|
|
2145
|
+
sendForgotPasswordRequest(email) {
|
|
2146
|
+
return this.http
|
|
2147
|
+
.get(`${this.config.api_url}/get-forgot-password.php`, { params: { email } })
|
|
2148
|
+
.pipe(map((response) => {
|
|
1790
2149
|
if ((response.records === undefined) ||
|
|
1791
|
-
(response.records
|
|
1792
|
-
throw response;
|
|
1793
|
-
}
|
|
1794
|
-
const mediaRecord = response.records[0];
|
|
1795
|
-
if (!mediaRecord.active) {
|
|
2150
|
+
!('reset_link_sent' in response.records)) {
|
|
1796
2151
|
throw response;
|
|
1797
2152
|
}
|
|
1798
|
-
return
|
|
2153
|
+
return response.records.reset_link_sent;
|
|
1799
2154
|
}));
|
|
1800
2155
|
}
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
2156
|
+
resetPassword(reset_key, password, confirm_password, auto_login = true) {
|
|
2157
|
+
return this.http
|
|
2158
|
+
.post(`${this.config.api_url}/set-forgot-password.php`, {
|
|
2159
|
+
reset_key,
|
|
2160
|
+
password,
|
|
2161
|
+
confirm_password,
|
|
2162
|
+
auto_login
|
|
2163
|
+
}, {
|
|
2164
|
+
headers: {
|
|
2165
|
+
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;'
|
|
2166
|
+
},
|
|
2167
|
+
responseType: 'json',
|
|
2168
|
+
observe: 'body'
|
|
2169
|
+
})
|
|
2170
|
+
.pipe(map((http_response) => this.responseHandler.validateSingleHttpResponse(http_response, (response) => {
|
|
2171
|
+
if (!response.login_required) {
|
|
2172
|
+
this.sessionService.handleUpdateSession({
|
|
2173
|
+
user_id: +response.esolve_id,
|
|
2174
|
+
location_id: +response.session_data.location_id,
|
|
2175
|
+
});
|
|
1819
2176
|
}
|
|
1820
|
-
return
|
|
2177
|
+
return new EsolveResetPasswordResult(response);
|
|
2178
|
+
})), catchError((errorRes) => {
|
|
2179
|
+
return this.errorHandler.handleHttpPostError('set-forgot-password', errorRes);
|
|
1821
2180
|
}));
|
|
1822
2181
|
}
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
*
|
|
1826
|
-
* @param identifiers Array of strings representing the eSolve heading identifiers
|
|
1827
|
-
*/
|
|
1828
|
-
getHeadings(identifiers) {
|
|
2182
|
+
updateLocation(location_id) {
|
|
2183
|
+
const body = { location_id };
|
|
1829
2184
|
return this.http
|
|
1830
|
-
.
|
|
1831
|
-
|
|
1832
|
-
|
|
2185
|
+
.post(`${this.config.api_url}/set-session-location.php`, body, {
|
|
2186
|
+
headers: {
|
|
2187
|
+
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;'
|
|
1833
2188
|
},
|
|
2189
|
+
responseType: 'json',
|
|
2190
|
+
observe: 'body',
|
|
1834
2191
|
})
|
|
1835
|
-
.pipe(map((response) => {
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
for (const heading_record of response.records) {
|
|
1840
|
-
headings.push(this.processHeadingRecord(heading_record));
|
|
1841
|
-
}
|
|
1842
|
-
}
|
|
1843
|
-
return headings;
|
|
1844
|
-
}));
|
|
2192
|
+
.pipe(map((http_response) => this.responseHandler.validateSingleHttpResponse(http_response, (response) => {
|
|
2193
|
+
this.sessionService.handleUpdateSession({ location_id });
|
|
2194
|
+
return new EsolveLocationUpdateResult(response);
|
|
2195
|
+
})));
|
|
1845
2196
|
}
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
2197
|
+
getTransactions(options = {}) {
|
|
2198
|
+
try {
|
|
2199
|
+
this.loginGuard();
|
|
2200
|
+
return this.http
|
|
2201
|
+
.get(`${this.config.api_url}/get-transactions.php`, {
|
|
2202
|
+
params: {
|
|
2203
|
+
user_id: this.user_id,
|
|
2204
|
+
...options,
|
|
2205
|
+
}
|
|
2206
|
+
})
|
|
2207
|
+
.pipe(map((response) => {
|
|
2208
|
+
if (response.records === undefined) {
|
|
2209
|
+
throw response;
|
|
2210
|
+
}
|
|
2211
|
+
const items = this.processTransactions(response.records);
|
|
2212
|
+
const total = +response.additional_data.total_records ?? 0;
|
|
2213
|
+
const rows = options.rows ?? total;
|
|
2214
|
+
const page = options.page || 1;
|
|
2215
|
+
return new EsolveTransactionList(items, page, rows, total);
|
|
2216
|
+
}));
|
|
1858
2217
|
}
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
topics.push(new EsolveTopic(+topic.id, topic.name, topic.short_description, +topic.sort_priority));
|
|
1862
|
-
}
|
|
2218
|
+
catch (error) {
|
|
2219
|
+
return throwError(error);
|
|
1863
2220
|
}
|
|
1864
|
-
return new EsolveMediaArticle(record.identifier, record.title, record.article, record.image_url, tags, topics, record.seo_page_title, record.seo_keywords, record.seo_description);
|
|
1865
|
-
}
|
|
1866
|
-
/**
|
|
1867
|
-
* Processes media heading record
|
|
1868
|
-
*
|
|
1869
|
-
* @param record Record from eSolve instance
|
|
1870
|
-
*/
|
|
1871
|
-
processHeadingRecord(record) {
|
|
1872
|
-
return new EsolveHeading(record.identifier, record.value);
|
|
1873
|
-
}
|
|
1874
|
-
/**
|
|
1875
|
-
* Retrieves media records from eSolve instance.
|
|
1876
|
-
*
|
|
1877
|
-
* @param params HTTP params
|
|
1878
|
-
*/
|
|
1879
|
-
getMediaRecords(params) {
|
|
1880
|
-
return this.http.get(`${this.config.api_url}/get-media.php`, { params });
|
|
1881
2221
|
}
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
2222
|
+
getTransaction(id) {
|
|
2223
|
+
try {
|
|
2224
|
+
this.loginGuard();
|
|
2225
|
+
return this.http
|
|
2226
|
+
.get(`${this.config.api_url}/get-transactions.php`, {
|
|
2227
|
+
params: {
|
|
2228
|
+
user_id: this.user_id,
|
|
2229
|
+
transaction_id: id,
|
|
2230
|
+
}
|
|
2231
|
+
})
|
|
2232
|
+
.pipe(map((response) => {
|
|
2233
|
+
if ((response.records === undefined) ||
|
|
2234
|
+
(response.records.length <= 0)) {
|
|
2235
|
+
throw response;
|
|
2236
|
+
}
|
|
2237
|
+
const items = this.processTransactions(response.records);
|
|
2238
|
+
return items[0];
|
|
2239
|
+
}));
|
|
2240
|
+
}
|
|
2241
|
+
catch (error) {
|
|
2242
|
+
return throwError(error);
|
|
2243
|
+
}
|
|
1901
2244
|
}
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
this.
|
|
1907
|
-
|
|
2245
|
+
processUserAccount(record) {
|
|
2246
|
+
if (!record) {
|
|
2247
|
+
throw new Error('Invalid record');
|
|
2248
|
+
}
|
|
2249
|
+
if (+record.userid !== this._user_id) {
|
|
2250
|
+
throw new Error('Invalid user account retrieved');
|
|
2251
|
+
}
|
|
2252
|
+
const user_account = new EsolveUserAccount(+record.userid, record.email, record.registration_type, record.title, record.firstname, record.surname, record.initials, record.gender, record.idnumber);
|
|
2253
|
+
user_account.contact_details = new EsolveUserAccountContact(record.telnumber, record.cellnumber, record.fax);
|
|
2254
|
+
user_account.business_details = new EsolveUserAccountBusiness(record.busname, record.vatnum, record.busdescript, record.business_type);
|
|
2255
|
+
return user_account;
|
|
1908
2256
|
}
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
return [];
|
|
2257
|
+
processUserAddress(records) {
|
|
2258
|
+
const user_addresses = [];
|
|
2259
|
+
if (!records || (this._user_id === 0)) {
|
|
2260
|
+
return user_addresses;
|
|
2261
|
+
}
|
|
2262
|
+
for (const record of records) {
|
|
2263
|
+
if (+record.userid !== this._user_id) {
|
|
2264
|
+
continue;
|
|
1918
2265
|
}
|
|
1919
|
-
|
|
1920
|
-
}
|
|
2266
|
+
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));
|
|
2267
|
+
}
|
|
2268
|
+
return user_addresses;
|
|
1921
2269
|
}
|
|
1922
|
-
|
|
1923
|
-
const
|
|
1924
|
-
if (
|
|
1925
|
-
for (const
|
|
1926
|
-
|
|
2270
|
+
processTransactions(records) {
|
|
2271
|
+
const transactions = [];
|
|
2272
|
+
if (records) {
|
|
2273
|
+
for (const record of records) {
|
|
2274
|
+
const transaction = new EsolveTransaction(record);
|
|
2275
|
+
transactions.push(transaction);
|
|
1927
2276
|
}
|
|
1928
2277
|
}
|
|
1929
|
-
return
|
|
2278
|
+
return transactions;
|
|
2279
|
+
}
|
|
2280
|
+
loginGuard() {
|
|
2281
|
+
if (this.user_id <= 0) {
|
|
2282
|
+
this.errorHandler.throwError('login_required', 'Login is required');
|
|
2283
|
+
}
|
|
1930
2284
|
}
|
|
1931
2285
|
}
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type:
|
|
2286
|
+
EsolveAccountService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveAccountService, deps: [{ token: ESOLVE_CONNECT_CONFIG }, { token: i1$2.HttpClient }, { token: EsolveSessionService }, { token: EsolveErrorHandlerService }, { token: EsolveResponseHandlerService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2287
|
+
EsolveAccountService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveAccountService, providedIn: 'root' });
|
|
2288
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveAccountService, decorators: [{
|
|
1935
2289
|
type: Injectable,
|
|
1936
2290
|
args: [{
|
|
1937
2291
|
providedIn: 'root',
|
|
@@ -1939,315 +2293,284 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImpor
|
|
|
1939
2293
|
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1940
2294
|
type: Inject,
|
|
1941
2295
|
args: [ESOLVE_CONNECT_CONFIG]
|
|
1942
|
-
}] }, { type: i1$2.HttpClient }]; } });
|
|
1943
|
-
|
|
1944
|
-
class EsolveNewsGroup {
|
|
1945
|
-
constructor(id, name, description, sef_name) {
|
|
1946
|
-
this.id = id;
|
|
1947
|
-
this.name = name;
|
|
1948
|
-
this.description = description;
|
|
1949
|
-
this.sef_name = sef_name;
|
|
1950
|
-
}
|
|
1951
|
-
}
|
|
2296
|
+
}] }, { type: i1$2.HttpClient }, { type: EsolveSessionService }, { type: EsolveErrorHandlerService }, { type: EsolveResponseHandlerService }]; } });
|
|
1952
2297
|
|
|
1953
|
-
class
|
|
1954
|
-
constructor(id,
|
|
2298
|
+
class EsolveBanner {
|
|
2299
|
+
constructor(id, banner_display_container, identifier, type, title, article, sort_priority, link, images) {
|
|
1955
2300
|
this.id = id;
|
|
2301
|
+
this.banner_display_container = banner_display_container;
|
|
2302
|
+
this.identifier = identifier;
|
|
2303
|
+
this.type = type;
|
|
1956
2304
|
this.title = title;
|
|
1957
|
-
this.sef_title = sef_title;
|
|
1958
2305
|
this.article = article;
|
|
1959
|
-
this.
|
|
1960
|
-
this.
|
|
1961
|
-
this.
|
|
1962
|
-
this.
|
|
1963
|
-
this.
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
2306
|
+
this.sort_priority = sort_priority;
|
|
2307
|
+
this.link = link;
|
|
2308
|
+
this.desktop_images = [];
|
|
2309
|
+
this.mobile_images = [];
|
|
2310
|
+
this.sub_images = [];
|
|
2311
|
+
if (images.desktop) {
|
|
2312
|
+
this.desktop_images = images.desktop;
|
|
2313
|
+
}
|
|
2314
|
+
if (images.mobile) {
|
|
2315
|
+
this.mobile_images = images.mobile;
|
|
2316
|
+
}
|
|
2317
|
+
if (images.sub) {
|
|
2318
|
+
this.sub_images = images.sub;
|
|
1967
2319
|
}
|
|
1968
|
-
this.seo_details = new EsolveSeoInfo(seo_title, short_description, seo_keywords);
|
|
1969
2320
|
}
|
|
1970
2321
|
}
|
|
1971
2322
|
|
|
1972
|
-
class
|
|
1973
|
-
constructor(
|
|
1974
|
-
this.
|
|
1975
|
-
this.
|
|
1976
|
-
this.
|
|
2323
|
+
class EsolveBannerImage {
|
|
2324
|
+
constructor(id, image_type, width, height, filename, hotspots) {
|
|
2325
|
+
this.id = id;
|
|
2326
|
+
this.image_type = image_type;
|
|
2327
|
+
this.width = width;
|
|
2328
|
+
this.height = height;
|
|
2329
|
+
this.filename = filename;
|
|
2330
|
+
this.hotspots = hotspots;
|
|
2331
|
+
}
|
|
2332
|
+
get src() {
|
|
2333
|
+
return '/images/banners/' + this.filename;
|
|
1977
2334
|
}
|
|
1978
2335
|
}
|
|
1979
2336
|
|
|
1980
|
-
class
|
|
1981
|
-
constructor(
|
|
1982
|
-
this.
|
|
1983
|
-
this.
|
|
1984
|
-
this.
|
|
1985
|
-
this.
|
|
2337
|
+
class EsolveBannerImageHotspot {
|
|
2338
|
+
constructor(url, target, coords, coords_string) {
|
|
2339
|
+
this.url = url;
|
|
2340
|
+
this.target = target;
|
|
2341
|
+
this.coords = coords;
|
|
2342
|
+
this.coords_string = coords_string;
|
|
1986
2343
|
}
|
|
1987
2344
|
}
|
|
1988
2345
|
|
|
1989
|
-
class
|
|
2346
|
+
class EsolveBannerService {
|
|
1990
2347
|
constructor(config, http) {
|
|
1991
2348
|
this.config = config;
|
|
1992
2349
|
this.http = http;
|
|
1993
2350
|
}
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
return this.processNewsArticle(newsRecord);
|
|
2006
|
-
}));
|
|
2007
|
-
}
|
|
2008
|
-
getNewsArticles(options) {
|
|
2009
|
-
let params = new HttpParams();
|
|
2010
|
-
if (options.news_group_id) {
|
|
2011
|
-
params = params.set('news_group_id', options.news_group_id.toString());
|
|
2012
|
-
}
|
|
2013
|
-
else if (options.news_group_sef) {
|
|
2014
|
-
params = params.set('news_group_sef', options.news_group_sef.toString());
|
|
2015
|
-
}
|
|
2016
|
-
if (options.page) {
|
|
2017
|
-
params = params.set('page', options.page.toString());
|
|
2018
|
-
}
|
|
2019
|
-
if (options.rows) {
|
|
2020
|
-
params = params.set('rows', options.rows.toString());
|
|
2021
|
-
}
|
|
2022
|
-
if (options.feature_only) {
|
|
2023
|
-
params = params.set('feature_only', options.feature_only.toString());
|
|
2024
|
-
}
|
|
2025
|
-
if (options.manufacturers_id) {
|
|
2026
|
-
params = params.set('manufacturers_id', options.manufacturers_id.toString());
|
|
2027
|
-
}
|
|
2028
|
-
if (options.ranges_id) {
|
|
2029
|
-
params = params.set('ranges_id', options.ranges_id.toString());
|
|
2030
|
-
}
|
|
2031
|
-
if (options.from_date) {
|
|
2032
|
-
params = params.set('from_date', options.from_date.toString());
|
|
2351
|
+
/**
|
|
2352
|
+
* Retrieves banners records from eSolve instance
|
|
2353
|
+
*
|
|
2354
|
+
* @returns An observable of eSolve banners.
|
|
2355
|
+
*/
|
|
2356
|
+
getBanners(identifier, banner_display_container, enable_date_filter = false) {
|
|
2357
|
+
let params = new HttpParams({
|
|
2358
|
+
fromObject: { enable_date_filter }
|
|
2359
|
+
});
|
|
2360
|
+
if (identifier) {
|
|
2361
|
+
params = params.set('identifier', identifier);
|
|
2033
2362
|
}
|
|
2034
|
-
if (
|
|
2035
|
-
params = params.set('
|
|
2363
|
+
if (banner_display_container) {
|
|
2364
|
+
params = params.set('banner_display_container', banner_display_container);
|
|
2036
2365
|
}
|
|
2037
|
-
return this.getNewsRecords(params).pipe(map(response => {
|
|
2038
|
-
if (response.records === undefined) {
|
|
2039
|
-
throw response;
|
|
2040
|
-
}
|
|
2041
|
-
const newsArticles = [];
|
|
2042
|
-
response.records.forEach(newsArticleRecord => {
|
|
2043
|
-
newsArticles.push(this.processNewsArticle(newsArticleRecord));
|
|
2044
|
-
});
|
|
2045
|
-
return new EsolveNewsArticleList(newsArticles, response.additional_data.total_records, options.page || 0);
|
|
2046
|
-
}));
|
|
2047
|
-
}
|
|
2048
|
-
getNewsGroups() {
|
|
2049
2366
|
return this.http
|
|
2050
|
-
.get(`${this.config.api_url}/get-
|
|
2367
|
+
.get(`${this.config.api_url}/get-banners.php`, { params })
|
|
2051
2368
|
.pipe(map((response) => {
|
|
2052
2369
|
if (response.records === undefined) {
|
|
2053
2370
|
throw response;
|
|
2054
2371
|
}
|
|
2055
|
-
|
|
2056
|
-
response.records.forEach(newsGroupRecord => {
|
|
2057
|
-
newsGroups.push(new EsolveNewsGroup(newsGroupRecord.id, newsGroupRecord.name, newsGroupRecord.description, newsGroupRecord.sef_name));
|
|
2058
|
-
});
|
|
2059
|
-
return newsGroups;
|
|
2372
|
+
return this.processBanners(response.records);
|
|
2060
2373
|
}));
|
|
2061
2374
|
}
|
|
2062
|
-
|
|
2063
|
-
const
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
}
|
|
2069
|
-
}
|
|
2070
|
-
EsolveNewsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveNewsService, deps: [{ token: ESOLVE_CONNECT_CONFIG }, { token: i1$2.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2071
|
-
EsolveNewsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveNewsService, providedIn: 'root' });
|
|
2072
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveNewsService, decorators: [{
|
|
2073
|
-
type: Injectable,
|
|
2074
|
-
args: [{
|
|
2075
|
-
providedIn: 'root',
|
|
2076
|
-
}]
|
|
2077
|
-
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
2078
|
-
type: Inject,
|
|
2079
|
-
args: [ESOLVE_CONNECT_CONFIG]
|
|
2080
|
-
}] }, { type: i1$2.HttpClient }]; } });
|
|
2081
|
-
|
|
2082
|
-
class EsolveColour {
|
|
2083
|
-
constructor(record) {
|
|
2084
|
-
this.id = record.id ?? 0;
|
|
2085
|
-
this.colour = record.colour ?? '';
|
|
2086
|
-
this.description = record.description ?? '';
|
|
2087
|
-
}
|
|
2088
|
-
}
|
|
2089
|
-
|
|
2090
|
-
class EsolveCategoryTreeItem {
|
|
2091
|
-
constructor(type, esolve_id, parent_id, description, sef_description, short_description, sort_priority, active, display_only, image_name, seo_title, seo_keywords, seo_description, children) {
|
|
2092
|
-
this.type = type;
|
|
2093
|
-
this.esolve_id = esolve_id;
|
|
2094
|
-
this.parent_id = parent_id;
|
|
2095
|
-
this.description = description;
|
|
2096
|
-
this.sef_description = sef_description;
|
|
2097
|
-
this.short_description = short_description;
|
|
2098
|
-
this.sort_priority = sort_priority;
|
|
2099
|
-
this.active = active;
|
|
2100
|
-
this.display_only = display_only;
|
|
2101
|
-
this.image_name = image_name;
|
|
2102
|
-
this.id = '';
|
|
2103
|
-
this.image_path = '';
|
|
2104
|
-
if (this.type === 'category') {
|
|
2105
|
-
this.id = `<<CAT>>${this.esolve_id}`;
|
|
2106
|
-
if (children != null) {
|
|
2107
|
-
this.children = children;
|
|
2375
|
+
processBannerImageHotspots(hotspot_records) {
|
|
2376
|
+
const hotspots = [];
|
|
2377
|
+
if (hotspot_records.length > 0) {
|
|
2378
|
+
for (const hotspot_record of hotspot_records) {
|
|
2379
|
+
const hotspot = new EsolveBannerImageHotspot(hotspot_record.url, hotspot_record.target, hotspot_record.coords, hotspot_record.coords_string);
|
|
2380
|
+
hotspots.push(hotspot);
|
|
2108
2381
|
}
|
|
2109
|
-
this.image_path = '/images/categories/';
|
|
2110
2382
|
}
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2383
|
+
return hotspots;
|
|
2384
|
+
}
|
|
2385
|
+
processBannerImages(image_records, banner_type) {
|
|
2386
|
+
const images = [];
|
|
2387
|
+
if (image_records.length > 0) {
|
|
2388
|
+
for (const image_record of image_records) {
|
|
2389
|
+
const image = new EsolveBannerImage(+image_record.id, image_record.image_type, +image_record.width, +image_record.height, image_record.filename);
|
|
2390
|
+
if ((banner_type === 'hotspot') && (image_record.hotspots)) {
|
|
2391
|
+
const hotspots = this.processBannerImageHotspots(image_record.hotspots);
|
|
2392
|
+
image.hotspots = hotspots;
|
|
2393
|
+
}
|
|
2394
|
+
images.push(image);
|
|
2395
|
+
}
|
|
2114
2396
|
}
|
|
2115
|
-
|
|
2116
|
-
|
|
2397
|
+
return images;
|
|
2398
|
+
}
|
|
2399
|
+
/**
|
|
2400
|
+
* Process banner records into banner objects
|
|
2401
|
+
* @param records Array of records
|
|
2402
|
+
* @returns List of banners
|
|
2403
|
+
*/
|
|
2404
|
+
processBanners(records) {
|
|
2405
|
+
const banners = [];
|
|
2406
|
+
if ((records) && (records.length > 0)) {
|
|
2407
|
+
for (const record of records) {
|
|
2408
|
+
const image_sets = {};
|
|
2409
|
+
if (record.images.desktop) {
|
|
2410
|
+
image_sets.desktop = this.processBannerImages(record.images.desktop, record.type);
|
|
2411
|
+
}
|
|
2412
|
+
if (record.images.mobile) {
|
|
2413
|
+
image_sets.mobile = this.processBannerImages(record.images.mobile, record.type);
|
|
2414
|
+
}
|
|
2415
|
+
if (record.images.sub) {
|
|
2416
|
+
image_sets.sub = this.processBannerImages(record.images.sub, record.type);
|
|
2417
|
+
}
|
|
2418
|
+
const banner = new EsolveBanner(+record.id, record.banner_display_container, record.identifier, record.type, record.title, record.article, +record.sort_priority, {
|
|
2419
|
+
url: record.link.url,
|
|
2420
|
+
target: record.link.target
|
|
2421
|
+
}, image_sets);
|
|
2422
|
+
banners.push(banner);
|
|
2423
|
+
}
|
|
2117
2424
|
}
|
|
2118
|
-
|
|
2119
|
-
}
|
|
2120
|
-
get small_image_src() {
|
|
2121
|
-
return this.getImagePath('small');
|
|
2122
|
-
}
|
|
2123
|
-
get thumbnail_image_src() {
|
|
2124
|
-
return this.getImagePath('thumb');
|
|
2425
|
+
return banners;
|
|
2125
2426
|
}
|
|
2126
|
-
|
|
2127
|
-
|
|
2427
|
+
}
|
|
2428
|
+
EsolveBannerService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveBannerService, deps: [{ token: ESOLVE_CONNECT_CONFIG }, { token: i1$2.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2429
|
+
EsolveBannerService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveBannerService, providedIn: 'root' });
|
|
2430
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveBannerService, decorators: [{
|
|
2431
|
+
type: Injectable,
|
|
2432
|
+
args: [{
|
|
2433
|
+
providedIn: 'root',
|
|
2434
|
+
}]
|
|
2435
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
2436
|
+
type: Inject,
|
|
2437
|
+
args: [ESOLVE_CONNECT_CONFIG]
|
|
2438
|
+
}] }, { type: i1$2.HttpClient }]; } });
|
|
2439
|
+
|
|
2440
|
+
// Types
|
|
2441
|
+
|
|
2442
|
+
class EsolveHeading {
|
|
2443
|
+
constructor(identifier, value) {
|
|
2444
|
+
this.identifier = identifier;
|
|
2445
|
+
this.value = value;
|
|
2128
2446
|
}
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2447
|
+
}
|
|
2448
|
+
|
|
2449
|
+
class EsolveMediaArticle {
|
|
2450
|
+
constructor(identifier, title, article, image_url = '', tags = [], topics = [], seo_title = '', seo_keywords = '', seo_description = '') {
|
|
2451
|
+
this.identifier = identifier;
|
|
2452
|
+
this.title = title;
|
|
2453
|
+
this.article = article;
|
|
2454
|
+
this.image_url = image_url;
|
|
2455
|
+
this.tags = tags;
|
|
2456
|
+
this.topics = topics;
|
|
2457
|
+
if (seo_title.trim() === '') {
|
|
2458
|
+
seo_title = this.title;
|
|
2132
2459
|
}
|
|
2133
|
-
|
|
2460
|
+
this.seo_details = new EsolveSeoInfo(seo_title, seo_description, seo_keywords);
|
|
2134
2461
|
}
|
|
2135
2462
|
}
|
|
2136
2463
|
|
|
2137
|
-
class
|
|
2464
|
+
class EsolveMediaService {
|
|
2138
2465
|
constructor(config, http) {
|
|
2139
2466
|
this.config = config;
|
|
2140
2467
|
this.http = http;
|
|
2141
2468
|
}
|
|
2142
2469
|
/**
|
|
2143
|
-
* Retrieves the
|
|
2470
|
+
* Retrieves the media record from the eSolve instance using the identifier
|
|
2471
|
+
*
|
|
2472
|
+
* @param identifier String representing the eSolve media identifier
|
|
2144
2473
|
*/
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
if (response.records === undefined)
|
|
2474
|
+
getMediaArticle(identifier) {
|
|
2475
|
+
const params = new HttpParams({ fromObject: { identifier } });
|
|
2476
|
+
// TODO: Error Handling
|
|
2477
|
+
return this.getMediaRecords(params).pipe(map((response) => {
|
|
2478
|
+
if ((response.records === undefined) ||
|
|
2479
|
+
(response.records.length <= 0)) {
|
|
2150
2480
|
throw response;
|
|
2151
2481
|
}
|
|
2152
|
-
|
|
2482
|
+
const mediaRecord = response.records[0];
|
|
2483
|
+
if (!mediaRecord.active) {
|
|
2484
|
+
throw response;
|
|
2485
|
+
}
|
|
2486
|
+
return this.processMediaRecord(mediaRecord);
|
|
2153
2487
|
}));
|
|
2154
2488
|
}
|
|
2155
2489
|
/**
|
|
2156
|
-
*
|
|
2157
|
-
* converts it to the correct format.
|
|
2490
|
+
* Retrieves a group of media records from the eSolve instance linked to a group
|
|
2158
2491
|
*
|
|
2159
|
-
* @param
|
|
2492
|
+
* @param media_group String representing the eSolve media group
|
|
2160
2493
|
*/
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
const
|
|
2167
|
-
if (
|
|
2168
|
-
|
|
2169
|
-
|
|
2494
|
+
getGroupedMediaArticles(media_group) {
|
|
2495
|
+
const params = new HttpParams({
|
|
2496
|
+
fromObject: { media_group_sef: media_group }
|
|
2497
|
+
});
|
|
2498
|
+
return this.getMediaRecords(params).pipe(map((response) => {
|
|
2499
|
+
const mediaArticles = [];
|
|
2500
|
+
if ((response.records !== undefined) &&
|
|
2501
|
+
(response.records.length > 0)) {
|
|
2502
|
+
for (const mediaRecord of response.records) {
|
|
2503
|
+
if (mediaRecord.active) {
|
|
2504
|
+
mediaArticles.push(this.processMediaRecord(mediaRecord));
|
|
2505
|
+
}
|
|
2506
|
+
}
|
|
2170
2507
|
}
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2508
|
+
return mediaArticles;
|
|
2509
|
+
}));
|
|
2510
|
+
}
|
|
2511
|
+
/**
|
|
2512
|
+
* Retrieves the media heading records from the eSolve instance using the identifiers
|
|
2513
|
+
*
|
|
2514
|
+
* @param identifiers Array of strings representing the eSolve heading identifiers
|
|
2515
|
+
*/
|
|
2516
|
+
getHeadings(identifiers) {
|
|
2517
|
+
return this.http
|
|
2518
|
+
.get(`${this.config.api_url}/get-headings.php`, {
|
|
2519
|
+
params: {
|
|
2520
|
+
identifier: identifiers.join(','),
|
|
2521
|
+
},
|
|
2522
|
+
})
|
|
2523
|
+
.pipe(map((response) => {
|
|
2524
|
+
const headings = [];
|
|
2525
|
+
if ((response.records !== undefined) &&
|
|
2526
|
+
(response.records.length > 0)) {
|
|
2527
|
+
for (const heading_record of response.records) {
|
|
2528
|
+
headings.push(this.processHeadingRecord(heading_record));
|
|
2529
|
+
}
|
|
2176
2530
|
}
|
|
2177
|
-
|
|
2178
|
-
|
|
2531
|
+
return headings;
|
|
2532
|
+
}));
|
|
2533
|
+
}
|
|
2534
|
+
/**
|
|
2535
|
+
* Processes media article record
|
|
2536
|
+
*
|
|
2537
|
+
* @param record Record from eSolve instance
|
|
2538
|
+
*/
|
|
2539
|
+
processMediaRecord(record) {
|
|
2540
|
+
const tags = [];
|
|
2541
|
+
const topics = [];
|
|
2542
|
+
if ((record.tags) && (record.tags.length > 0)) {
|
|
2543
|
+
for (const tag of record.tags) {
|
|
2544
|
+
tags.push(new EsolveTag(tag));
|
|
2179
2545
|
}
|
|
2180
2546
|
}
|
|
2181
|
-
if (
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
if (esolve_id) {
|
|
2185
|
-
params = params.set('id', esolve_id);
|
|
2186
|
-
}
|
|
2187
|
-
if (sef_description) {
|
|
2188
|
-
params = params.set('sef_description', sef_description);
|
|
2547
|
+
if ((record.topics) && (record.topics.length > 0)) {
|
|
2548
|
+
for (const topic of record.topics) {
|
|
2549
|
+
topics.push(new EsolveTopic(topic));
|
|
2189
2550
|
}
|
|
2190
|
-
return this.http
|
|
2191
|
-
.get(`${this.config.api_url}/get-tree-item.php`, { params })
|
|
2192
|
-
.pipe(map((response) => {
|
|
2193
|
-
if ((response.records === undefined) ||
|
|
2194
|
-
(response.records.length <= 0)) {
|
|
2195
|
-
throw response;
|
|
2196
|
-
}
|
|
2197
|
-
return this.processTreeItem(response.records[0]);
|
|
2198
|
-
}));
|
|
2199
2551
|
}
|
|
2200
|
-
return
|
|
2552
|
+
return new EsolveMediaArticle(record.identifier, record.title, record.article, record.image_url, tags, topics, record.seo_page_title, record.seo_keywords, record.seo_description);
|
|
2201
2553
|
}
|
|
2202
2554
|
/**
|
|
2203
|
-
* Processes
|
|
2555
|
+
* Processes media heading record
|
|
2204
2556
|
*
|
|
2205
|
-
* @param
|
|
2557
|
+
* @param record Record from eSolve instance
|
|
2206
2558
|
*/
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
if (tree_records) {
|
|
2210
|
-
for (const tree_record of tree_records) {
|
|
2211
|
-
let esolve_id = '';
|
|
2212
|
-
let parent_id = '';
|
|
2213
|
-
let children = [];
|
|
2214
|
-
if (tree_record.type === 'category') {
|
|
2215
|
-
children = this.processTree(tree_record.children);
|
|
2216
|
-
esolve_id = tree_record.menu_id;
|
|
2217
|
-
parent_id = tree_record.owner_menu_id;
|
|
2218
|
-
}
|
|
2219
|
-
else {
|
|
2220
|
-
esolve_id = tree_record.id;
|
|
2221
|
-
parent_id = tree_record.menu_id;
|
|
2222
|
-
}
|
|
2223
|
-
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));
|
|
2224
|
-
}
|
|
2225
|
-
}
|
|
2226
|
-
return tree_items;
|
|
2227
|
-
}
|
|
2228
|
-
processTreeItem(record) {
|
|
2229
|
-
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.image, record.seo_page_title, record.seo_keywords, record.seo_description);
|
|
2559
|
+
processHeadingRecord(record) {
|
|
2560
|
+
return new EsolveHeading(record.identifier, record.value);
|
|
2230
2561
|
}
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
type = (type_code === '<<CAT>>' ? 'category' : 'subcategory');
|
|
2239
|
-
esolve_id = id.replace(type_code_regex, '');
|
|
2240
|
-
return {
|
|
2241
|
-
type,
|
|
2242
|
-
esolve_id
|
|
2243
|
-
};
|
|
2244
|
-
}
|
|
2245
|
-
return null;
|
|
2562
|
+
/**
|
|
2563
|
+
* Retrieves media records from eSolve instance.
|
|
2564
|
+
*
|
|
2565
|
+
* @param params HTTP params
|
|
2566
|
+
*/
|
|
2567
|
+
getMediaRecords(params) {
|
|
2568
|
+
return this.http.get(`${this.config.api_url}/get-media.php`, { params });
|
|
2246
2569
|
}
|
|
2247
2570
|
}
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type:
|
|
2571
|
+
EsolveMediaService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveMediaService, deps: [{ token: ESOLVE_CONNECT_CONFIG }, { token: i1$2.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2572
|
+
EsolveMediaService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveMediaService, providedIn: 'root' });
|
|
2573
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveMediaService, decorators: [{
|
|
2251
2574
|
type: Injectable,
|
|
2252
2575
|
args: [{
|
|
2253
2576
|
providedIn: 'root',
|
|
@@ -2257,102 +2580,46 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImpor
|
|
|
2257
2580
|
args: [ESOLVE_CONNECT_CONFIG]
|
|
2258
2581
|
}] }, { type: i1$2.HttpClient }]; } });
|
|
2259
2582
|
|
|
2260
|
-
class
|
|
2261
|
-
constructor(
|
|
2262
|
-
this.
|
|
2263
|
-
this.
|
|
2264
|
-
this.
|
|
2265
|
-
this.
|
|
2266
|
-
this.article = article;
|
|
2267
|
-
this.sort_priority = sort_priority;
|
|
2268
|
-
this.is_active = is_active;
|
|
2269
|
-
this.featured = featured;
|
|
2270
|
-
this.image_name = image_name;
|
|
2271
|
-
this.image_path = '/images/manufacturers/';
|
|
2272
|
-
if (this.title.trim() === '') {
|
|
2273
|
-
this.title = this.manufacturer;
|
|
2274
|
-
}
|
|
2275
|
-
if (seo_title.trim() === '') {
|
|
2276
|
-
seo_title = this.title;
|
|
2277
|
-
}
|
|
2278
|
-
this.seo_details = new EsolveSeoInfo(seo_title, seo_description, seo_keywords);
|
|
2279
|
-
}
|
|
2280
|
-
get original_image_src() {
|
|
2281
|
-
return this.getImagePath('original');
|
|
2282
|
-
}
|
|
2283
|
-
get small_image_src() {
|
|
2284
|
-
return this.getImagePath('small');
|
|
2285
|
-
}
|
|
2286
|
-
get thumbnail_image_src() {
|
|
2287
|
-
return this.getImagePath('thumb');
|
|
2288
|
-
}
|
|
2289
|
-
get tiny_image_src() {
|
|
2290
|
-
return this.getImagePath('tiny');
|
|
2291
|
-
}
|
|
2292
|
-
getImagePath(image_size) {
|
|
2293
|
-
if (this.image_name !== '') {
|
|
2294
|
-
return `${this.image_path}${image_size}/${this.image_name}`;
|
|
2295
|
-
}
|
|
2296
|
-
return '';
|
|
2583
|
+
class EsolveMenuItem {
|
|
2584
|
+
constructor(url, name, target, children = []) {
|
|
2585
|
+
this.url = url;
|
|
2586
|
+
this.name = name;
|
|
2587
|
+
this.target = target;
|
|
2588
|
+
this.children = children;
|
|
2297
2589
|
}
|
|
2298
2590
|
}
|
|
2299
2591
|
|
|
2300
|
-
class
|
|
2592
|
+
class EsolveMenuService {
|
|
2301
2593
|
constructor(config, http) {
|
|
2302
2594
|
this.config = config;
|
|
2303
2595
|
this.http = http;
|
|
2304
2596
|
}
|
|
2305
|
-
|
|
2306
|
-
const params = new HttpParams({
|
|
2307
|
-
fromObject: { manufacturers_id: id }
|
|
2308
|
-
});
|
|
2309
|
-
return this.getManufacturerSingle(params);
|
|
2310
|
-
}
|
|
2311
|
-
getManufacturerFromSEF(sef_manufacturer) {
|
|
2312
|
-
const params = new HttpParams({
|
|
2313
|
-
fromObject: { sef_manufacturer }
|
|
2314
|
-
});
|
|
2315
|
-
return this.getManufacturerSingle(params);
|
|
2316
|
-
}
|
|
2317
|
-
getManufacturers(options) {
|
|
2318
|
-
let params = new HttpParams();
|
|
2319
|
-
if (options?.featured_only) {
|
|
2320
|
-
params = params.set('featured_only', options.featured_only);
|
|
2321
|
-
}
|
|
2322
|
-
return this.getManufacturerRecords(params).pipe(map((records) => {
|
|
2323
|
-
const manufacturers = [];
|
|
2324
|
-
for (const record of records) {
|
|
2325
|
-
manufacturers.push(this.processManufacturer(record));
|
|
2326
|
-
}
|
|
2327
|
-
return manufacturers;
|
|
2328
|
-
}), catchError(() => {
|
|
2329
|
-
return of([]);
|
|
2330
|
-
}));
|
|
2331
|
-
}
|
|
2332
|
-
getManufacturerSingle(params) {
|
|
2333
|
-
return this.getManufacturerRecords(params).pipe(map((records) => {
|
|
2334
|
-
const record = records[0];
|
|
2335
|
-
return this.processManufacturer(record);
|
|
2336
|
-
}));
|
|
2337
|
-
}
|
|
2338
|
-
getManufacturerRecords(params) {
|
|
2597
|
+
getMenuTree(identifier) {
|
|
2339
2598
|
return this.http
|
|
2340
|
-
.get(`${this.config.api_url}/get-
|
|
2599
|
+
.get(`${this.config.api_url}/get-menu-tree.php`, { params: { identifier } })
|
|
2341
2600
|
.pipe(map((response) => {
|
|
2342
|
-
if ((response.records === undefined)
|
|
2343
|
-
(response.records.length <= 0)) {
|
|
2601
|
+
if ((!response) || (response.records === undefined)) {
|
|
2344
2602
|
throw response;
|
|
2345
2603
|
}
|
|
2346
|
-
|
|
2604
|
+
else if (response.records.length === 0) {
|
|
2605
|
+
return [];
|
|
2606
|
+
}
|
|
2607
|
+
return this.handleMenu(response.records);
|
|
2347
2608
|
}));
|
|
2348
2609
|
}
|
|
2349
|
-
|
|
2350
|
-
|
|
2610
|
+
handleMenu(records) {
|
|
2611
|
+
const menu = [];
|
|
2612
|
+
if (typeof records !== 'undefined') {
|
|
2613
|
+
for (const menuTreeRecord of records) {
|
|
2614
|
+
menu.push(new EsolveMenuItem(menuTreeRecord.sef_url, menuTreeRecord.name, menuTreeRecord.target, this.handleMenu(menuTreeRecord.children)));
|
|
2615
|
+
}
|
|
2616
|
+
}
|
|
2617
|
+
return menu;
|
|
2351
2618
|
}
|
|
2352
2619
|
}
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type:
|
|
2620
|
+
EsolveMenuService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveMenuService, deps: [{ token: ESOLVE_CONNECT_CONFIG }, { token: i1$2.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2621
|
+
EsolveMenuService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveMenuService, providedIn: 'root' });
|
|
2622
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveMenuService, decorators: [{
|
|
2356
2623
|
type: Injectable,
|
|
2357
2624
|
args: [{
|
|
2358
2625
|
providedIn: 'root',
|
|
@@ -2362,97 +2629,193 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImpor
|
|
|
2362
2629
|
args: [ESOLVE_CONNECT_CONFIG]
|
|
2363
2630
|
}] }, { type: i1$2.HttpClient }]; } });
|
|
2364
2631
|
|
|
2365
|
-
class
|
|
2366
|
-
constructor(id,
|
|
2632
|
+
class EsolveNewsGroup {
|
|
2633
|
+
constructor(id, name, description, sef_name) {
|
|
2367
2634
|
this.id = id;
|
|
2368
|
-
this.
|
|
2369
|
-
this.
|
|
2370
|
-
this.
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
this.
|
|
2377
|
-
this.
|
|
2378
|
-
|
|
2379
|
-
|
|
2635
|
+
this.name = name;
|
|
2636
|
+
this.description = description;
|
|
2637
|
+
this.sef_name = sef_name;
|
|
2638
|
+
}
|
|
2639
|
+
}
|
|
2640
|
+
|
|
2641
|
+
class EsolveNewsArticleAuthor {
|
|
2642
|
+
constructor(userid, email, firstname, surname) {
|
|
2643
|
+
this.userid = userid;
|
|
2644
|
+
this.email = email;
|
|
2645
|
+
this.firstname = firstname;
|
|
2646
|
+
this.surname = surname;
|
|
2647
|
+
}
|
|
2648
|
+
}
|
|
2649
|
+
|
|
2650
|
+
class EsolveNewsArticle {
|
|
2651
|
+
constructor(record) {
|
|
2652
|
+
this.id = 0;
|
|
2653
|
+
this.title = '';
|
|
2654
|
+
this.sef_title = '';
|
|
2655
|
+
this.article = '';
|
|
2656
|
+
this.short_description = '';
|
|
2657
|
+
this.txdate = '';
|
|
2658
|
+
this.active = false;
|
|
2659
|
+
this.image = '';
|
|
2660
|
+
this.featured = false;
|
|
2661
|
+
this.topics = [];
|
|
2662
|
+
this.tags = [];
|
|
2663
|
+
let seo_title = '';
|
|
2664
|
+
let seo_description = '';
|
|
2665
|
+
let seo_keywords = '';
|
|
2666
|
+
if (record) {
|
|
2667
|
+
this.id = +(record.id ?? 0);
|
|
2668
|
+
this.title = record.title ?? '';
|
|
2669
|
+
this.sef_title = record.sef_title ?? '';
|
|
2670
|
+
this.article = record.article ?? '';
|
|
2671
|
+
this.txdate = record.txdate ?? '';
|
|
2672
|
+
this.image = record.image ?? '';
|
|
2673
|
+
this.short_description = record.short_description ?? '';
|
|
2674
|
+
if (record.active) {
|
|
2675
|
+
this.active = !!+record.active;
|
|
2676
|
+
}
|
|
2677
|
+
if (record.featured) {
|
|
2678
|
+
this.featured = !!+record.featured;
|
|
2679
|
+
}
|
|
2680
|
+
seo_title = record.seo_page_title ?? '';
|
|
2681
|
+
seo_description = record.short_description ?? '';
|
|
2682
|
+
seo_keywords = record.seo_keywords ?? '';
|
|
2683
|
+
if (record.news_group) {
|
|
2684
|
+
const group_record = record.news_group;
|
|
2685
|
+
this.group = new EsolveNewsGroup(+group_record.id, group_record.name, group_record.description, group_record.sef_name);
|
|
2686
|
+
}
|
|
2687
|
+
if (record.user) {
|
|
2688
|
+
this.author = new EsolveNewsArticleAuthor(record.user.userid, record.user.email, record.user.firstname, record.user.surname);
|
|
2689
|
+
}
|
|
2690
|
+
if (record.manufacturer) {
|
|
2691
|
+
this.manufacturer = new EsolveManufacturer(record.manufacturer);
|
|
2692
|
+
}
|
|
2693
|
+
if (record.range) {
|
|
2694
|
+
this.range = new EsolveRange(record.range);
|
|
2695
|
+
}
|
|
2696
|
+
if (record.topics && record.topics.length > 0) {
|
|
2697
|
+
const topics = record.topics;
|
|
2698
|
+
for (const topic of topics) {
|
|
2699
|
+
this.topics.push(new EsolveTopic(topic));
|
|
2700
|
+
}
|
|
2701
|
+
}
|
|
2702
|
+
if (record.tags && record.tags.length > 0) {
|
|
2703
|
+
const tags = record.tags;
|
|
2704
|
+
for (const tag of tags) {
|
|
2705
|
+
this.tags.push(new EsolveTag(tag));
|
|
2706
|
+
}
|
|
2707
|
+
}
|
|
2380
2708
|
}
|
|
2381
2709
|
if (seo_title.trim() === '') {
|
|
2382
2710
|
seo_title = this.title;
|
|
2383
2711
|
}
|
|
2384
2712
|
this.seo_details = new EsolveSeoInfo(seo_title, seo_description, seo_keywords);
|
|
2385
2713
|
}
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
return '';
|
|
2714
|
+
}
|
|
2715
|
+
|
|
2716
|
+
class EsolveNewsArticleList {
|
|
2717
|
+
constructor(newsArticles, total, page) {
|
|
2718
|
+
this.newsArticles = newsArticles;
|
|
2719
|
+
this.total = total;
|
|
2720
|
+
this.page = page;
|
|
2394
2721
|
}
|
|
2395
2722
|
}
|
|
2396
2723
|
|
|
2397
|
-
class
|
|
2724
|
+
class EsolveNewsService {
|
|
2398
2725
|
constructor(config, http) {
|
|
2399
2726
|
this.config = config;
|
|
2400
2727
|
this.http = http;
|
|
2401
2728
|
}
|
|
2402
|
-
|
|
2403
|
-
const params = new HttpParams({
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
getRangeFromSEF(sef_range) {
|
|
2409
|
-
const params = new HttpParams({
|
|
2410
|
-
fromObject: { sef_range }
|
|
2411
|
-
});
|
|
2412
|
-
return this.getRangeSingle(params);
|
|
2413
|
-
}
|
|
2414
|
-
getRanges(options) {
|
|
2415
|
-
let params = new HttpParams();
|
|
2416
|
-
if (options?.featured_only) {
|
|
2417
|
-
params = params.set('featured_only', options.featured_only);
|
|
2418
|
-
}
|
|
2419
|
-
if (options?.manufacturers_id) {
|
|
2420
|
-
params = params.set('manufacturers_id', options.manufacturers_id);
|
|
2421
|
-
}
|
|
2422
|
-
return this.getRangeRecords(params).pipe(map((records) => {
|
|
2423
|
-
const ranges = [];
|
|
2424
|
-
for (const record of records) {
|
|
2425
|
-
ranges.push(this.processRange(record));
|
|
2729
|
+
getNewsArticle(identifier) {
|
|
2730
|
+
const params = new HttpParams({ fromObject: { sef_title: identifier } });
|
|
2731
|
+
return this.getNewsRecords(params).pipe(map((response) => {
|
|
2732
|
+
if ((response.records === undefined) ||
|
|
2733
|
+
(response.records.length <= 0)) {
|
|
2734
|
+
throw response;
|
|
2426
2735
|
}
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2736
|
+
const record = response.records[0];
|
|
2737
|
+
if (!record.active) {
|
|
2738
|
+
throw response;
|
|
2739
|
+
}
|
|
2740
|
+
return this.processNewsArticle(record);
|
|
2430
2741
|
}));
|
|
2431
2742
|
}
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2743
|
+
getNewsArticles(options) {
|
|
2744
|
+
const params = this.parseOptions(options);
|
|
2745
|
+
return this.getNewsRecords(params).pipe(map((response) => {
|
|
2746
|
+
if (response.records === undefined) {
|
|
2747
|
+
throw response;
|
|
2748
|
+
}
|
|
2749
|
+
const news_articles = [];
|
|
2750
|
+
for (const record of response.records) {
|
|
2751
|
+
news_articles.push(this.processNewsArticle(record));
|
|
2752
|
+
}
|
|
2753
|
+
const page = options?.page ?? 0;
|
|
2754
|
+
const total_records = +response.additional_data.total_records;
|
|
2755
|
+
return new EsolveNewsArticleList(news_articles, total_records, page);
|
|
2436
2756
|
}));
|
|
2437
2757
|
}
|
|
2438
|
-
|
|
2758
|
+
getNewsGroups() {
|
|
2439
2759
|
return this.http
|
|
2440
|
-
.get(`${this.config.api_url}/get-
|
|
2760
|
+
.get(`${this.config.api_url}/get-news-groups.php`)
|
|
2441
2761
|
.pipe(map((response) => {
|
|
2442
|
-
if (
|
|
2443
|
-
(response.records.length <= 0)) {
|
|
2762
|
+
if (response.records === undefined) {
|
|
2444
2763
|
throw response;
|
|
2445
2764
|
}
|
|
2446
|
-
|
|
2765
|
+
const news_groups = [];
|
|
2766
|
+
for (const record of response.records) {
|
|
2767
|
+
news_groups.push(new EsolveNewsGroup(record.id, record.name, record.description, record.sef_name));
|
|
2768
|
+
}
|
|
2769
|
+
return news_groups;
|
|
2447
2770
|
}));
|
|
2448
2771
|
}
|
|
2449
|
-
|
|
2450
|
-
return new
|
|
2772
|
+
processNewsArticle(record) {
|
|
2773
|
+
return new EsolveNewsArticle(record);
|
|
2774
|
+
}
|
|
2775
|
+
getNewsRecords(params) {
|
|
2776
|
+
return this.http.get(`${this.config.api_url}/get-news.php`, { params });
|
|
2777
|
+
}
|
|
2778
|
+
parseOptions(options) {
|
|
2779
|
+
let params = new HttpParams();
|
|
2780
|
+
if (!options) {
|
|
2781
|
+
return params;
|
|
2782
|
+
}
|
|
2783
|
+
if (options.news_group_id) {
|
|
2784
|
+
params = params.set('news_group_id', options.news_group_id);
|
|
2785
|
+
}
|
|
2786
|
+
else if (options.news_group_sef) {
|
|
2787
|
+
params = params.set('news_group_sef', options.news_group_sef);
|
|
2788
|
+
}
|
|
2789
|
+
if (options.page) {
|
|
2790
|
+
params = params.set('page', options.page);
|
|
2791
|
+
}
|
|
2792
|
+
if (options.rows) {
|
|
2793
|
+
params = params.set('rows', options.rows);
|
|
2794
|
+
}
|
|
2795
|
+
if (options.feature_only) {
|
|
2796
|
+
params = params.set('feature_only', options.feature_only);
|
|
2797
|
+
}
|
|
2798
|
+
if (options.manufacturers_id) {
|
|
2799
|
+
params = params.set('manufacturers_id', options.manufacturers_id);
|
|
2800
|
+
}
|
|
2801
|
+
if (options.ranges_id) {
|
|
2802
|
+
params = params.set('ranges_id', options.ranges_id);
|
|
2803
|
+
}
|
|
2804
|
+
if (options.from_date) {
|
|
2805
|
+
params = params.set('from_date', options.from_date);
|
|
2806
|
+
}
|
|
2807
|
+
if (options.to_date) {
|
|
2808
|
+
params = params.set('to_date', options.to_date);
|
|
2809
|
+
}
|
|
2810
|
+
if (options.search_phrase) {
|
|
2811
|
+
params = params.set('search_phrase', options.search_phrase);
|
|
2812
|
+
}
|
|
2813
|
+
return params;
|
|
2451
2814
|
}
|
|
2452
2815
|
}
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type:
|
|
2816
|
+
EsolveNewsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveNewsService, deps: [{ token: ESOLVE_CONNECT_CONFIG }, { token: i1$2.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2817
|
+
EsolveNewsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveNewsService, providedIn: 'root' });
|
|
2818
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: EsolveNewsService, decorators: [{
|
|
2456
2819
|
type: Injectable,
|
|
2457
2820
|
args: [{
|
|
2458
2821
|
providedIn: 'root',
|
|
@@ -2462,6 +2825,16 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImpor
|
|
|
2462
2825
|
args: [ESOLVE_CONNECT_CONFIG]
|
|
2463
2826
|
}] }, { type: i1$2.HttpClient }]; } });
|
|
2464
2827
|
|
|
2828
|
+
// Types
|
|
2829
|
+
|
|
2830
|
+
class EsolveColour {
|
|
2831
|
+
constructor(record) {
|
|
2832
|
+
this.id = record.id ?? 0;
|
|
2833
|
+
this.colour = record.colour ?? '';
|
|
2834
|
+
this.description = record.description ?? '';
|
|
2835
|
+
}
|
|
2836
|
+
}
|
|
2837
|
+
|
|
2465
2838
|
class EsolveStockBadge {
|
|
2466
2839
|
constructor(id, text, identifier, font_colour, badge_colour, sort_priority) {
|
|
2467
2840
|
this.id = id;
|
|
@@ -2559,6 +2932,26 @@ class EsolveStockItemBase {
|
|
|
2559
2932
|
* Featured state
|
|
2560
2933
|
*/
|
|
2561
2934
|
this.featured = false;
|
|
2935
|
+
/**
|
|
2936
|
+
* Height measured in meters (m)
|
|
2937
|
+
*/
|
|
2938
|
+
this.height = 0;
|
|
2939
|
+
/**
|
|
2940
|
+
* Width measured in meters (m)
|
|
2941
|
+
*/
|
|
2942
|
+
this.width = 0;
|
|
2943
|
+
/**
|
|
2944
|
+
* Length / depth measured in meters (m)
|
|
2945
|
+
*/
|
|
2946
|
+
this.length = 0;
|
|
2947
|
+
/**
|
|
2948
|
+
* Weight measured in kilograms (kg)
|
|
2949
|
+
*/
|
|
2950
|
+
this.weight = 0;
|
|
2951
|
+
/**
|
|
2952
|
+
* Units used to measure the quantity
|
|
2953
|
+
*/
|
|
2954
|
+
this.unit_of_measure = 'unit';
|
|
2562
2955
|
/**
|
|
2563
2956
|
* ID of default category linked to the stock item
|
|
2564
2957
|
*
|
|
@@ -2623,18 +3016,25 @@ class EsolveStockItemBase {
|
|
|
2623
3016
|
this.ranges_id = +(record.ranges_id ?? 0);
|
|
2624
3017
|
this.active = !!+(record.is_active ?? false);
|
|
2625
3018
|
this.featured = !!+(record.is_featured ?? false);
|
|
3019
|
+
this.height = +(record.height ?? 0);
|
|
3020
|
+
this.width = +(record.width ?? 0);
|
|
3021
|
+
this.length = +(record.length ?? 0);
|
|
3022
|
+
this.weight = +(record.weight ?? 0);
|
|
3023
|
+
if (record.unit_of_measure) {
|
|
3024
|
+
this.unit_of_measure = record.unit_of_measure;
|
|
3025
|
+
}
|
|
2626
3026
|
base_price = +(record.regular_sellprice ?? 0);
|
|
2627
3027
|
base_price_with_tax = +(record.regular_sellprice_inclusive ?? 0);
|
|
2628
3028
|
sell_price = +(record.sellprice ?? 0);
|
|
2629
3029
|
sell_price_with_tax = +(record.sellprice_inclusive ?? 0);
|
|
2630
3030
|
if ((record.tags) && (record.tags.length > 0)) {
|
|
2631
3031
|
for (const tag of record.tags) {
|
|
2632
|
-
this.tags.push(new EsolveTag(
|
|
3032
|
+
this.tags.push(new EsolveTag(tag));
|
|
2633
3033
|
}
|
|
2634
3034
|
}
|
|
2635
3035
|
if ((record.topics) && (record.topics.length > 0)) {
|
|
2636
3036
|
for (const topic of record.topics) {
|
|
2637
|
-
this.topics.push(new EsolveTopic(
|
|
3037
|
+
this.topics.push(new EsolveTopic(topic));
|
|
2638
3038
|
}
|
|
2639
3039
|
}
|
|
2640
3040
|
if ((record.badges) && (record.badges.length > 0)) {
|
|
@@ -2649,10 +3049,10 @@ class EsolveStockItemBase {
|
|
|
2649
3049
|
this.subcategory = new EsolveCategoryTreeItem(record.subcategory.type, record.subcategory.id, record.subcategory.parent_id, record.subcategory.description, record.subcategory.sef_description, record.subcategory.short_description, record.subcategory.sort_priority, record.subcategory.active, record.subcategory.display_only, record.subcategory.image, record.subcategory.seo_page_title, record.subcategory.seo_keywords, record.subcategory.seo_description);
|
|
2650
3050
|
}
|
|
2651
3051
|
if (record.manufacturer) {
|
|
2652
|
-
this.manufacturer = new EsolveManufacturer(record.manufacturer
|
|
3052
|
+
this.manufacturer = new EsolveManufacturer(record.manufacturer);
|
|
2653
3053
|
}
|
|
2654
3054
|
if (record.range) {
|
|
2655
|
-
this.range = new EsolveRange(record.range
|
|
3055
|
+
this.range = new EsolveRange(record.range);
|
|
2656
3056
|
}
|
|
2657
3057
|
if (record.colours && record.colours.length > 0) {
|
|
2658
3058
|
for (const colour of record.colours) {
|
|
@@ -2868,8 +3268,12 @@ class EsolveStockImageCollection {
|
|
|
2868
3268
|
}
|
|
2869
3269
|
;
|
|
2870
3270
|
|
|
3271
|
+
// Classes
|
|
3272
|
+
|
|
2871
3273
|
;
|
|
2872
3274
|
|
|
3275
|
+
// Interfaces
|
|
3276
|
+
|
|
2873
3277
|
class EsolveStockService {
|
|
2874
3278
|
constructor(config, http) {
|
|
2875
3279
|
this.config = config;
|
|
@@ -2928,6 +3332,15 @@ class EsolveStockService {
|
|
|
2928
3332
|
if (options.rows) {
|
|
2929
3333
|
params = params.set('rows', options.rows);
|
|
2930
3334
|
}
|
|
3335
|
+
if (options.sort) {
|
|
3336
|
+
const sort = options.sort;
|
|
3337
|
+
if (sort.field) {
|
|
3338
|
+
params = params.set('sort', sort.field);
|
|
3339
|
+
}
|
|
3340
|
+
if (sort.order) {
|
|
3341
|
+
params = params.set('order', sort.order);
|
|
3342
|
+
}
|
|
3343
|
+
}
|
|
2931
3344
|
if (options.search_phrase) {
|
|
2932
3345
|
params = params.set('search_phrase', options.search_phrase);
|
|
2933
3346
|
}
|
|
@@ -2995,9 +3408,27 @@ class EsolveStockService {
|
|
|
2995
3408
|
*
|
|
2996
3409
|
* @param code Stock item code
|
|
2997
3410
|
*/
|
|
2998
|
-
getRecipeItems(code) {
|
|
3411
|
+
getRecipeItems(code, options) {
|
|
3412
|
+
let params = new HttpParams().set('code', code);
|
|
3413
|
+
if (options) {
|
|
3414
|
+
if (options.page) {
|
|
3415
|
+
params = params.set('page', options.page);
|
|
3416
|
+
}
|
|
3417
|
+
if (options.rows) {
|
|
3418
|
+
params = params.set('rows', options.rows);
|
|
3419
|
+
}
|
|
3420
|
+
if (options.sort) {
|
|
3421
|
+
const sort = options.sort;
|
|
3422
|
+
if (sort.field) {
|
|
3423
|
+
params = params.set('sort', sort.field);
|
|
3424
|
+
}
|
|
3425
|
+
if (sort.order) {
|
|
3426
|
+
params = params.set('order', sort.order);
|
|
3427
|
+
}
|
|
3428
|
+
}
|
|
3429
|
+
}
|
|
2999
3430
|
return this.http
|
|
3000
|
-
.get(`${this.config.api_url}/get-recipe-items.php`, { params
|
|
3431
|
+
.get(`${this.config.api_url}/get-recipe-items.php`, { params })
|
|
3001
3432
|
.pipe(map((response) => {
|
|
3002
3433
|
if ((response.records === undefined) ||
|
|
3003
3434
|
(response.records.length <= 0)) {
|
|
@@ -3022,6 +3453,15 @@ class EsolveStockService {
|
|
|
3022
3453
|
is_active: options.is_active ?? true,
|
|
3023
3454
|
},
|
|
3024
3455
|
});
|
|
3456
|
+
if (options.sort) {
|
|
3457
|
+
const sort = options.sort;
|
|
3458
|
+
if (sort.field) {
|
|
3459
|
+
params = params.set('sort', sort.field);
|
|
3460
|
+
}
|
|
3461
|
+
if (sort.order) {
|
|
3462
|
+
params = params.set('order', sort.order);
|
|
3463
|
+
}
|
|
3464
|
+
}
|
|
3025
3465
|
if (options.media_identifier) {
|
|
3026
3466
|
params = params.append('media_identifier', options.media_identifier);
|
|
3027
3467
|
}
|
|
@@ -3125,8 +3565,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImpor
|
|
|
3125
3565
|
args: [ESOLVE_CONNECT_CONFIG]
|
|
3126
3566
|
}] }, { type: i1$2.HttpClient }]; } });
|
|
3127
3567
|
|
|
3128
|
-
// Types
|
|
3129
|
-
|
|
3130
3568
|
class EsolveSpecialImage {
|
|
3131
3569
|
constructor(record) {
|
|
3132
3570
|
this.id = +record.id;
|
|
@@ -4042,5 +4480,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImpor
|
|
|
4042
4480
|
* Generated bundle index. Do not edit.
|
|
4043
4481
|
*/
|
|
4044
4482
|
|
|
4045
|
-
export { EsolveAccountService, EsolveAdditionalStockImage, EsolveAddress, EsolveAddressResult, EsolveAuthService, EsolveBankingDetails, EsolveBanner, EsolveBannerImage, EsolveBannerImageHotspot, EsolveBannerService, EsolveCartItem, EsolveCartService, EsolveCartStockItem, EsolveCartTotals, EsolveCategoryTreeItem, EsolveCategoryTreeService, EsolveChangePasswordResult, EsolveCheckoutResult, EsolveColour, EsolveCookieService, EsolveEnquiryResult, EsolveEnquiryService, EsolveErrorHandlerService, EsolveGeocodeAddressResult, EsolveGeocodeCoordsResult, EsolveGeocodeResult, EsolveGeocoderService, EsolveHeading, EsolveHttpError, EsolveLinkedAsset, EsolveLinkedStockItem, EsolveList, EsolveLocation, EsolveLocationAddress, EsolveLocationContactInfo, EsolveLocationPOBoxAddress, EsolveLocationTradingDay, EsolveLocationTradingTimes, EsolveLocationsService, EsolveManufacturer, EsolveManufacturersService, EsolveMediaArticle, EsolveMediaService, EsolveMediaStockItem, EsolveMenuItem, EsolveMenuService, EsolveNewsArticle, EsolveNewsArticleAuthor, EsolveNewsArticleList, EsolveNewsGroup, EsolveNewsService, EsolvePaymentMethod, EsolvePaymentResult, EsolvePaymentService, EsolveRange, EsolveRangesService, EsolveRecipeStockItem, EsolveRegistrationResult, EsolveResetPasswordResult, EsolveResponseHandlerService, EsolveResponseResult, EsolveResult, EsolveSeoInfo, EsolveSeoService, EsolveSession, EsolveSessionService, EsolveShippingCost, EsolveShippingMethod, EsolveShippingService, EsolveShippingTotals, EsolveSpecial, EsolveSpecialImage, EsolveSpecialImageCollection, EsolveSpecialsService, EsolveStockBadge, EsolveStockGroup, EsolveStockGroupItem, EsolveStockImage, EsolveStockImageCollection, EsolveStockItem, EsolveStockItemBase, EsolveStockItemList, EsolveStockLeadTimes, EsolveStockPrice, EsolveStockService, EsolveTag, EsolveTopic, EsolveTopicService, EsolveTransaction, EsolveTransactionAddress, EsolveTransactionClient, EsolveTransactionItem, EsolveTransactionItemPrice, EsolveTransactionList, EsolveTransactionLocation, EsolveTransactionPaymentMethod, EsolveTransactionShippingMethod, EsolveTransactionUser, EsolveUserAccount, EsolveUserAccountBusiness, EsolveUserAccountContact, EsolveUserAccountResult, EsolveVaultItem, EsolveVaultItemResult, NgEsolveConnectModule };
|
|
4483
|
+
export { EsolveAccountService, EsolveAdditionalStockImage, EsolveAddress, EsolveAddressResult, EsolveAsset, EsolveAssetsService, EsolveAuthService, EsolveBankingDetails, EsolveBanner, EsolveBannerImage, EsolveBannerImageHotspot, EsolveBannerService, EsolveCartItem, EsolveCartService, EsolveCartStockItem, EsolveCartTotals, EsolveCategoryTreeItem, EsolveCategoryTreeService, EsolveChangePasswordResult, EsolveCheckoutResult, EsolveColour, EsolveCookieService, EsolveEnquiryResult, EsolveEnquiryService, EsolveErrorHandlerService, EsolveGeocodeAddressResult, EsolveGeocodeCoordsResult, EsolveGeocodeResult, EsolveGeocoderService, EsolveHeading, EsolveHttpError, EsolveLinkedAsset, EsolveLinkedStockItem, EsolveList, EsolveLocation, EsolveLocationAddress, EsolveLocationContactInfo, EsolveLocationPOBoxAddress, EsolveLocationTradingDay, EsolveLocationTradingTimes, EsolveLocationsService, EsolveManufacturer, EsolveManufacturersService, EsolveMediaArticle, EsolveMediaService, EsolveMediaStockItem, EsolveMenuItem, EsolveMenuService, EsolveNewsArticle, EsolveNewsArticleAuthor, EsolveNewsArticleList, EsolveNewsGroup, EsolveNewsService, EsolvePaymentMethod, EsolvePaymentResult, EsolvePaymentService, EsolveRange, EsolveRangesService, EsolveRecipeStockItem, EsolveRegistrationResult, EsolveResetPasswordResult, EsolveResponseHandlerService, EsolveResponseResult, EsolveResult, EsolveSeoInfo, EsolveSeoService, EsolveSession, EsolveSessionService, EsolveShippingCost, EsolveShippingMethod, EsolveShippingService, EsolveShippingTotals, EsolveSpecial, EsolveSpecialImage, EsolveSpecialImageCollection, EsolveSpecialsService, EsolveStockBadge, EsolveStockGroup, EsolveStockGroupItem, EsolveStockImage, EsolveStockImageCollection, EsolveStockItem, EsolveStockItemBase, EsolveStockItemList, EsolveStockLeadTimes, EsolveStockPrice, EsolveStockService, EsolveTag, EsolveTagsService, EsolveTopic, EsolveTopicService, EsolveTransaction, EsolveTransactionAddress, EsolveTransactionClient, EsolveTransactionItem, EsolveTransactionItemPrice, EsolveTransactionList, EsolveTransactionLocation, EsolveTransactionPaymentMethod, EsolveTransactionShippingMethod, EsolveTransactionUser, EsolveUserAccount, EsolveUserAccountBusiness, EsolveUserAccountContact, EsolveUserAccountResult, EsolveVaultItem, EsolveVaultItemResult, NgEsolveConnectModule };
|
|
4046
4484
|
//# sourceMappingURL=esolve-ng-esolve-connect.mjs.map
|