@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
@@ -3003,6 +3003,7 @@ class EsolveStockPrice {
3003
3003
  * @param base_price_with_tax Price with tax
3004
3004
  * @param sell_price Price without tax and with discounts applied if applicable
3005
3005
  * @param sell_price_with_tax Price with tax and with discounts applied if applicable
3006
+ * @param tax_rate Tax rate of the item
3006
3007
  * @param taxed Whether tax has been applied
3007
3008
  */
3008
3009
  constructor(
@@ -3021,11 +3022,16 @@ class EsolveStockPrice {
3021
3022
  /**
3022
3023
  * Price with tax and with discounts applied if applicable
3023
3024
  */
3024
- sell_price_with_tax = 0, taxed) {
3025
+ sell_price_with_tax = 0,
3026
+ /**
3027
+ * Vat Rate for the item
3028
+ */
3029
+ tax_rate = 0, taxed) {
3025
3030
  this.base_price = base_price;
3026
3031
  this.base_price_with_tax = base_price_with_tax;
3027
3032
  this.sell_price = sell_price;
3028
3033
  this.sell_price_with_tax = sell_price_with_tax;
3034
+ this.tax_rate = tax_rate;
3029
3035
  if ((this.base_price === 0) && (this.sell_price > 0)) {
3030
3036
  this.base_price = this.sell_price;
3031
3037
  this.base_price_with_tax = this.sell_price_with_tax;
@@ -3253,7 +3259,7 @@ class EsolveStockItemBase {
3253
3259
  seo_title = (_4 = record.seo_page_title) !== null && _4 !== void 0 ? _4 : '';
3254
3260
  seo_keywords = (_5 = record.seo_keywords) !== null && _5 !== void 0 ? _5 : '';
3255
3261
  }
3256
- this.price = new EsolveStockPrice(base_price, base_price_with_tax, sell_price, sell_price_with_tax, record.vat_item);
3262
+ this.price = new EsolveStockPrice(base_price, base_price_with_tax, sell_price, sell_price_with_tax, record.vat_rate, record.vat_item);
3257
3263
  if (seo_title.trim() === '') {
3258
3264
  seo_title = this.name;
3259
3265
  }
@@ -4267,6 +4273,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImpo
4267
4273
  }] }, { type: i1$2.HttpClient }, { type: EsolveErrorHandlerService }, { type: EsolveResponseHandlerService }];
4268
4274
  } });
4269
4275
 
4276
+ // TODO: Spilt folder to file types
4277
+
4270
4278
  // Only export the types that are accessible to the public API
4271
4279
 
4272
4280
  class EsolveBankingDetails {
@@ -4820,6 +4828,132 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImpo
4820
4828
  }] }, { type: i1$2.HttpClient }, { type: EsolveErrorHandlerService }, { type: EsolveResponseHandlerService }];
4821
4829
  } });
4822
4830
 
4831
+ class EsolveWishlistItem {
4832
+ constructor(id, qty, vat_rate, price, price_incl, vat_total, total, total_incl, stock_item) {
4833
+ this.id = id;
4834
+ this.qty = qty;
4835
+ this.vat_rate = vat_rate;
4836
+ this.price = price;
4837
+ this.price_incl = price_incl;
4838
+ this.vat_total = vat_total;
4839
+ this.total = total;
4840
+ this.total_incl = total_incl;
4841
+ this.stock_item = stock_item;
4842
+ }
4843
+ }
4844
+
4845
+ class EsolveEmptyWishlistResult extends EsolveResponseResult {
4846
+ }
4847
+
4848
+ class EsolveWishlistService {
4849
+ constructor(config, http, errorHandler, responseHandler) {
4850
+ this.config = config;
4851
+ this.http = http;
4852
+ this.errorHandler = errorHandler;
4853
+ this.responseHandler = responseHandler;
4854
+ }
4855
+ /**
4856
+ * Retrieves the current wishlist
4857
+ *
4858
+ * @returns An `Observable` with an array of cart items
4859
+ */
4860
+ getWishlist() {
4861
+ return this.getWishlistRecords().pipe(map((response) => {
4862
+ if (response.records === undefined) {
4863
+ throw response;
4864
+ }
4865
+ return this.processWishlist(response.records);
4866
+ }));
4867
+ }
4868
+ /**
4869
+ * Updates the wishlist by preforming various actions, such as adding, editing or removing items from the list.
4870
+ *
4871
+ * @param items An array of options to update the wishlist
4872
+ * @param default_action The default action to preform
4873
+ *
4874
+ * @returns An `Observable` with an array of responses that gives feedback on the requested changes
4875
+ */
4876
+ setWishlist(items, default_action = 'add') {
4877
+ const body = {
4878
+ items,
4879
+ default_action,
4880
+ };
4881
+ return this.http
4882
+ .post(`${this.config.api_url}/set-wishlist-item.php`, body, {
4883
+ headers: {
4884
+ 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;',
4885
+ },
4886
+ responseType: 'json',
4887
+ observe: 'body',
4888
+ })
4889
+ .pipe(map((response) => {
4890
+ if (response.responses === undefined) {
4891
+ throw response;
4892
+ }
4893
+ return response.responses;
4894
+ }));
4895
+ }
4896
+ /**
4897
+ * Empties the wishlist for the logged in user.
4898
+ *
4899
+ * @returns Observable of type EsolveEmptyWishlistResult
4900
+ */
4901
+ setWishlistEmpty() {
4902
+ return this.http
4903
+ .post(`${this.config.api_url}/set-wishlist-empty.php`, null, {
4904
+ headers: {
4905
+ 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;',
4906
+ },
4907
+ responseType: 'json',
4908
+ observe: 'body',
4909
+ })
4910
+ .pipe(map((http_response) => this.responseHandler.validateSingleHttpResponse(http_response, (response) => {
4911
+ return new EsolveEmptyWishlistResult(response);
4912
+ })), catchError((errorRes) => {
4913
+ return this.errorHandler.handleHttpPostError('set-wishlist-empty', errorRes);
4914
+ }));
4915
+ }
4916
+ /**
4917
+ * Processes the eSolve wishlist records
4918
+ *
4919
+ * @param wishlist_item_records Records to process
4920
+ *
4921
+ * @returns An array of processed cart items
4922
+ */
4923
+ processWishlist(wishlist_item_records) {
4924
+ const wishlist_items = [];
4925
+ if (wishlist_item_records) {
4926
+ for (const item of wishlist_item_records) {
4927
+ const stock_item = new EsolveStockItem(item.stock_item);
4928
+ 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);
4929
+ wishlist_items.push(wishlist_item);
4930
+ }
4931
+ }
4932
+ return wishlist_items;
4933
+ }
4934
+ /**
4935
+ * Retrieves stock records from HTTP params.
4936
+ *
4937
+ * @param params HTTP client parameters
4938
+ */
4939
+ getWishlistRecords(params) {
4940
+ return this.http.get(`${this.config.api_url}/get-wishlist.php`, { params });
4941
+ }
4942
+ }
4943
+ 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 });
4944
+ EsolveWishlistService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: EsolveWishlistService, providedIn: 'root' });
4945
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: EsolveWishlistService, decorators: [{
4946
+ type: Injectable,
4947
+ args: [{
4948
+ providedIn: 'root',
4949
+ }]
4950
+ }], ctorParameters: function () {
4951
+ return [{ type: undefined, decorators: [{
4952
+ type: Inject,
4953
+ args: [ESOLVE_CONNECT_CONFIG]
4954
+ }] }, { type: i1$2.HttpClient }, { type: EsolveErrorHandlerService }, { type: EsolveResponseHandlerService }];
4955
+ } });
4956
+
4823
4957
  /*
4824
4958
  * Public API Surface of ng-esolve-connect
4825
4959
  */
@@ -4828,5 +4962,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImpo
4828
4962
  * Generated bundle index. Do not edit.
4829
4963
  */
4830
4964
 
4831
- 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 };
4965
+ 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 };
4832
4966
  //# sourceMappingURL=esolve-ng-esolve-connect.mjs.map