@esolve/ng-esolve-connect 0.21.2 → 0.22.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.
Files changed (35) hide show
  1. package/esm2020/lib/cart/index.mjs +2 -1
  2. package/esm2020/lib/stock/classes/esolve-stock-item-base.model.mjs +2 -2
  3. package/esm2020/lib/stock/classes/esolve-stock-price.model.mjs +8 -2
  4. package/esm2020/lib/wishlist/classes/esolve-empty-wishlist-result.model.mjs +4 -0
  5. package/esm2020/lib/wishlist/classes/esolve-wishlist-item.model.mjs +14 -0
  6. package/esm2020/lib/wishlist/classes/index.mjs +3 -0
  7. package/esm2020/lib/wishlist/esolve-wishlist.service.mjs +116 -0
  8. package/esm2020/lib/wishlist/index.mjs +6 -0
  9. package/esm2020/lib/wishlist/interfaces/esolve-wishlist-item-record.interface.mjs +2 -0
  10. package/esm2020/lib/wishlist/interfaces/esolve-wishlist-item-response.interface.mjs +2 -0
  11. package/esm2020/lib/wishlist/interfaces/esolve-wishlist-set-item.interface.mjs +2 -0
  12. package/esm2020/lib/wishlist/interfaces/index.mjs +4 -0
  13. package/esm2020/lib/wishlist/types/esolve-wishlist-set-action.type.mjs +2 -0
  14. package/esm2020/lib/wishlist/types/esolve-wishlist.type.mjs +2 -0
  15. package/esm2020/lib/wishlist/types/index.mjs +3 -0
  16. package/esm2020/public-api.mjs +3 -1
  17. package/fesm2015/esolve-ng-esolve-connect.mjs +137 -3
  18. package/fesm2015/esolve-ng-esolve-connect.mjs.map +1 -1
  19. package/fesm2020/esolve-ng-esolve-connect.mjs +135 -3
  20. package/fesm2020/esolve-ng-esolve-connect.mjs.map +1 -1
  21. package/lib/stock/classes/esolve-stock-price.model.d.ts +10 -1
  22. package/lib/wishlist/classes/esolve-empty-wishlist-result.model.d.ts +3 -0
  23. package/lib/wishlist/classes/esolve-wishlist-item.model.d.ts +13 -0
  24. package/lib/wishlist/classes/index.d.ts +2 -0
  25. package/lib/wishlist/esolve-wishlist.service.d.ts +54 -0
  26. package/lib/wishlist/index.d.ts +4 -0
  27. package/lib/wishlist/interfaces/esolve-wishlist-item-record.interface.d.ts +13 -0
  28. package/lib/wishlist/interfaces/esolve-wishlist-item-response.interface.d.ts +6 -0
  29. package/lib/wishlist/interfaces/esolve-wishlist-set-item.interface.d.ts +7 -0
  30. package/lib/wishlist/interfaces/index.d.ts +3 -0
  31. package/lib/wishlist/types/esolve-wishlist-set-action.type.d.ts +1 -0
  32. package/lib/wishlist/types/esolve-wishlist.type.d.ts +2 -0
  33. package/lib/wishlist/types/index.d.ts +2 -0
  34. package/package.json +1 -1
  35. package/public-api.d.ts +1 -0
@@ -2960,6 +2960,7 @@ class EsolveStockPrice {
2960
2960
  * @param base_price_with_tax Price with tax
2961
2961
  * @param sell_price Price without tax and with discounts applied if applicable
2962
2962
  * @param sell_price_with_tax Price with tax and with discounts applied if applicable
2963
+ * @param tax_rate Tax rate of the item
2963
2964
  * @param taxed Whether tax has been applied
2964
2965
  */
2965
2966
  constructor(
@@ -2978,11 +2979,16 @@ class EsolveStockPrice {
2978
2979
  /**
2979
2980
  * Price with tax and with discounts applied if applicable
2980
2981
  */
2981
- sell_price_with_tax = 0, taxed) {
2982
+ sell_price_with_tax = 0,
2983
+ /**
2984
+ * Vat Rate for the item
2985
+ */
2986
+ tax_rate = 0, taxed) {
2982
2987
  this.base_price = base_price;
2983
2988
  this.base_price_with_tax = base_price_with_tax;
2984
2989
  this.sell_price = sell_price;
2985
2990
  this.sell_price_with_tax = sell_price_with_tax;
2991
+ this.tax_rate = tax_rate;
2986
2992
  if ((this.base_price === 0) && (this.sell_price > 0)) {
2987
2993
  this.base_price = this.sell_price;
2988
2994
  this.base_price_with_tax = this.sell_price_with_tax;
@@ -3209,7 +3215,7 @@ class EsolveStockItemBase {
3209
3215
  seo_title = record.seo_page_title ?? '';
3210
3216
  seo_keywords = record.seo_keywords ?? '';
3211
3217
  }
3212
- this.price = new EsolveStockPrice(base_price, base_price_with_tax, sell_price, sell_price_with_tax, record.vat_item);
3218
+ this.price = new EsolveStockPrice(base_price, base_price_with_tax, sell_price, sell_price_with_tax, record.vat_rate, record.vat_item);
3213
3219
  if (seo_title.trim() === '') {
3214
3220
  seo_title = this.name;
3215
3221
  }
@@ -4210,6 +4216,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImpo
4210
4216
  args: [ESOLVE_CONNECT_CONFIG]
4211
4217
  }] }, { type: i1$2.HttpClient }, { type: EsolveErrorHandlerService }, { type: EsolveResponseHandlerService }]; } });
4212
4218
 
4219
+ // TODO: Spilt folder to file types
4220
+
4213
4221
  // Only export the types that are accessible to the public API
4214
4222
 
4215
4223
  class EsolveBankingDetails {
@@ -4756,6 +4764,130 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImpo
4756
4764
  args: [ESOLVE_CONNECT_CONFIG]
4757
4765
  }] }, { type: i1$2.HttpClient }, { type: EsolveErrorHandlerService }, { type: EsolveResponseHandlerService }]; } });
4758
4766
 
4767
+ class EsolveWishlistItem {
4768
+ constructor(id, qty, vat_rate, price, price_incl, vat_total, total, total_incl, stock_item) {
4769
+ this.id = id;
4770
+ this.qty = qty;
4771
+ this.vat_rate = vat_rate;
4772
+ this.price = price;
4773
+ this.price_incl = price_incl;
4774
+ this.vat_total = vat_total;
4775
+ this.total = total;
4776
+ this.total_incl = total_incl;
4777
+ this.stock_item = stock_item;
4778
+ }
4779
+ }
4780
+
4781
+ class EsolveEmptyWishlistResult extends EsolveResponseResult {
4782
+ }
4783
+
4784
+ class EsolveWishlistService {
4785
+ constructor(config, http, errorHandler, responseHandler) {
4786
+ this.config = config;
4787
+ this.http = http;
4788
+ this.errorHandler = errorHandler;
4789
+ this.responseHandler = responseHandler;
4790
+ }
4791
+ /**
4792
+ * Retrieves the current wishlist
4793
+ *
4794
+ * @returns An `Observable` with an array of cart items
4795
+ */
4796
+ getWishlist() {
4797
+ return this.getWishlistRecords().pipe(map((response) => {
4798
+ if (response.records === undefined) {
4799
+ throw response;
4800
+ }
4801
+ return this.processWishlist(response.records);
4802
+ }));
4803
+ }
4804
+ /**
4805
+ * Updates the wishlist by preforming various actions, such as adding, editing or removing items from the list.
4806
+ *
4807
+ * @param items An array of options to update the wishlist
4808
+ * @param default_action The default action to preform
4809
+ *
4810
+ * @returns An `Observable` with an array of responses that gives feedback on the requested changes
4811
+ */
4812
+ setWishlist(items, default_action = 'add') {
4813
+ const body = {
4814
+ items,
4815
+ default_action,
4816
+ };
4817
+ return this.http
4818
+ .post(`${this.config.api_url}/set-wishlist-item.php`, body, {
4819
+ headers: {
4820
+ 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;',
4821
+ },
4822
+ responseType: 'json',
4823
+ observe: 'body',
4824
+ })
4825
+ .pipe(map((response) => {
4826
+ if (response.responses === undefined) {
4827
+ throw response;
4828
+ }
4829
+ return response.responses;
4830
+ }));
4831
+ }
4832
+ /**
4833
+ * Empties the wishlist for the logged in user.
4834
+ *
4835
+ * @returns Observable of type EsolveEmptyWishlistResult
4836
+ */
4837
+ setWishlistEmpty() {
4838
+ return this.http
4839
+ .post(`${this.config.api_url}/set-wishlist-empty.php`, null, {
4840
+ headers: {
4841
+ 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;',
4842
+ },
4843
+ responseType: 'json',
4844
+ observe: 'body',
4845
+ })
4846
+ .pipe(map((http_response) => this.responseHandler.validateSingleHttpResponse(http_response, (response) => {
4847
+ return new EsolveEmptyWishlistResult(response);
4848
+ })), catchError((errorRes) => {
4849
+ return this.errorHandler.handleHttpPostError('set-wishlist-empty', errorRes);
4850
+ }));
4851
+ }
4852
+ /**
4853
+ * Processes the eSolve wishlist records
4854
+ *
4855
+ * @param wishlist_item_records Records to process
4856
+ *
4857
+ * @returns An array of processed cart items
4858
+ */
4859
+ processWishlist(wishlist_item_records) {
4860
+ const wishlist_items = [];
4861
+ if (wishlist_item_records) {
4862
+ for (const item of wishlist_item_records) {
4863
+ const stock_item = new EsolveStockItem(item.stock_item);
4864
+ const wishlist_item = new EsolveWishlistItem(+item.id, +item.qty, +item.vat_rate, +item.price, +item.price_incl, +item.vat_total, +item.line_total, +item.line_total_incl, stock_item);
4865
+ wishlist_items.push(wishlist_item);
4866
+ }
4867
+ }
4868
+ return wishlist_items;
4869
+ }
4870
+ /**
4871
+ * Retrieves stock records from HTTP params.
4872
+ *
4873
+ * @param params HTTP client parameters
4874
+ */
4875
+ getWishlistRecords(params) {
4876
+ return this.http.get(`${this.config.api_url}/get-wishlist.php`, { params });
4877
+ }
4878
+ }
4879
+ EsolveWishlistService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: EsolveWishlistService, deps: [{ token: ESOLVE_CONNECT_CONFIG }, { token: i1$2.HttpClient }, { token: EsolveErrorHandlerService }, { token: EsolveResponseHandlerService }], target: i0.ɵɵFactoryTarget.Injectable });
4880
+ EsolveWishlistService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: EsolveWishlistService, providedIn: 'root' });
4881
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: EsolveWishlistService, decorators: [{
4882
+ type: Injectable,
4883
+ args: [{
4884
+ providedIn: 'root',
4885
+ }]
4886
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
4887
+ type: Inject,
4888
+ args: [ESOLVE_CONNECT_CONFIG]
4889
+ }] }, { type: i1$2.HttpClient }, { type: EsolveErrorHandlerService }, { type: EsolveResponseHandlerService }]; } });
4890
+
4759
4891
  /*
4760
4892
  * Public API Surface of ng-esolve-connect
4761
4893
  */
@@ -4764,5 +4896,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImpo
4764
4896
  * Generated bundle index. Do not edit.
4765
4897
  */
4766
4898
 
4767
- export { ESOLVE_CONNECT_CONFIG, EsolveAccountService, EsolveAdditionalStockImage, EsolveAddress, EsolveAddressResult, EsolveAsset, EsolveAssetsService, EsolveAuthService, EsolveBankingDetails, EsolveBanner, EsolveBannerImage, EsolveBannerImageHotspot, EsolveBannerService, EsolveCartItem, EsolveCartService, EsolveCartStockItem, EsolveCartTotals, EsolveCategoryTreeItem, EsolveCategoryTreeService, EsolveChangePasswordResult, EsolveCheckoutResult, EsolveColour, EsolveCookieService, EsolveEmptyCartResult, EsolveEnquiryResult, EsolveEnquiryService, EsolveErrorHandlerService, EsolveFilterFactory, EsolveGeocodeAddressResult, EsolveGeocodeCoordsResult, EsolveGeocodeResult, EsolveGeocoderService, EsolveHttpError, EsolveLinkedAsset, EsolveLinkedStockItem, EsolveList, EsolveLocation, EsolveLocationAddress, EsolveLocationContactInfo, EsolveLocationPOBoxAddress, EsolveLocationTradingDay, EsolveLocationTradingTimes, EsolveLocationsService, EsolveManufacturer, EsolveManufacturersService, EsolveMediaStockItem, EsolveMenuItem, EsolveMenuService, EsolveMultipleSelectFilter, EsolveNewsArticle, EsolveNewsArticleAuthor, EsolveNewsArticleList, EsolveNewsGroup, EsolveNewsService, EsolvePaymentMethod, EsolvePaymentResult, EsolvePaymentService, EsolveRange, EsolveRangeFilter, EsolveRangesService, EsolveRecipeStockItem, EsolveRegistrationResult, EsolveResetPasswordResult, EsolveResponseHandlerService, EsolveResponseResult, EsolveResult, EsolveSeoInfo, EsolveSeoService, EsolveSession, EsolveSessionService, EsolveShippingCost, EsolveShippingMethod, EsolveShippingService, EsolveShippingTotals, EsolveSingleSelectFilter, EsolveSpecial, EsolveSpecialDates, 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 };
4899
+ export { ESOLVE_CONNECT_CONFIG, EsolveAccountService, EsolveAdditionalStockImage, EsolveAddress, EsolveAddressResult, EsolveAsset, EsolveAssetsService, EsolveAuthService, EsolveBankingDetails, EsolveBanner, EsolveBannerImage, EsolveBannerImageHotspot, EsolveBannerService, EsolveCartItem, EsolveCartService, EsolveCartStockItem, EsolveCartTotals, EsolveCategoryTreeItem, EsolveCategoryTreeService, EsolveChangePasswordResult, EsolveCheckoutResult, EsolveColour, EsolveCookieService, EsolveEmptyCartResult, EsolveEmptyWishlistResult, EsolveEnquiryResult, EsolveEnquiryService, EsolveErrorHandlerService, EsolveFilterFactory, EsolveGeocodeAddressResult, EsolveGeocodeCoordsResult, EsolveGeocodeResult, EsolveGeocoderService, EsolveHttpError, EsolveLinkedAsset, EsolveLinkedStockItem, EsolveList, EsolveLocation, EsolveLocationAddress, EsolveLocationContactInfo, EsolveLocationPOBoxAddress, EsolveLocationTradingDay, EsolveLocationTradingTimes, EsolveLocationsService, EsolveManufacturer, EsolveManufacturersService, EsolveMediaStockItem, EsolveMenuItem, EsolveMenuService, EsolveMultipleSelectFilter, EsolveNewsArticle, EsolveNewsArticleAuthor, EsolveNewsArticleList, EsolveNewsGroup, EsolveNewsService, EsolvePaymentMethod, EsolvePaymentResult, EsolvePaymentService, EsolveRange, EsolveRangeFilter, EsolveRangesService, EsolveRecipeStockItem, EsolveRegistrationResult, EsolveResetPasswordResult, EsolveResponseHandlerService, EsolveResponseResult, EsolveResult, EsolveSeoInfo, EsolveSeoService, EsolveSession, EsolveSessionService, EsolveShippingCost, EsolveShippingMethod, EsolveShippingService, EsolveShippingTotals, EsolveSingleSelectFilter, EsolveSpecial, EsolveSpecialDates, 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, EsolveWishlistItem, EsolveWishlistService, NgEsolveConnectModule };
4768
4900
  //# sourceMappingURL=esolve-ng-esolve-connect.mjs.map