@esolve/ng-esolve-connect 0.21.2 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/esm2020/lib/stock/classes/esolve-stock-item-base.model.mjs +2 -2
  2. package/esm2020/lib/stock/classes/esolve-stock-price.model.mjs +8 -2
  3. package/esm2020/lib/wishlist/classes/esolve-empty-wishlist-result.model.mjs +4 -0
  4. package/esm2020/lib/wishlist/classes/esolve-wishlist-item.model.mjs +14 -0
  5. package/esm2020/lib/wishlist/classes/index.mjs +2 -0
  6. package/esm2020/lib/wishlist/esolve-wishlist.service.mjs +114 -0
  7. package/esm2020/lib/wishlist/index.mjs +6 -0
  8. package/esm2020/lib/wishlist/interfaces/esolve-wishlist-item-record.interface.mjs +2 -0
  9. package/esm2020/lib/wishlist/interfaces/esolve-wishlist-item-response.interface.mjs +2 -0
  10. package/esm2020/lib/wishlist/interfaces/esolve-wishlist-set-item.interface.mjs +2 -0
  11. package/esm2020/lib/wishlist/interfaces/index.mjs +4 -0
  12. package/esm2020/lib/wishlist/types/esolve-wishlist-set-action.type.mjs +2 -0
  13. package/esm2020/lib/wishlist/types/esolve-wishlist.type.mjs +2 -0
  14. package/esm2020/lib/wishlist/types/index.mjs +3 -0
  15. package/esm2020/public-api.mjs +3 -1
  16. package/fesm2015/esolve-ng-esolve-connect.mjs +132 -3
  17. package/fesm2015/esolve-ng-esolve-connect.mjs.map +1 -1
  18. package/fesm2020/esolve-ng-esolve-connect.mjs +130 -3
  19. package/fesm2020/esolve-ng-esolve-connect.mjs.map +1 -1
  20. package/lib/stock/classes/esolve-stock-price.model.d.ts +10 -1
  21. package/lib/wishlist/classes/esolve-empty-wishlist-result.model.d.ts +3 -0
  22. package/lib/wishlist/classes/esolve-wishlist-item.model.d.ts +13 -0
  23. package/lib/wishlist/classes/index.d.ts +1 -0
  24. package/lib/wishlist/esolve-wishlist.service.d.ts +53 -0
  25. package/lib/wishlist/index.d.ts +4 -0
  26. package/lib/wishlist/interfaces/esolve-wishlist-item-record.interface.d.ts +13 -0
  27. package/lib/wishlist/interfaces/esolve-wishlist-item-response.interface.d.ts +6 -0
  28. package/lib/wishlist/interfaces/esolve-wishlist-set-item.interface.d.ts +7 -0
  29. package/lib/wishlist/interfaces/index.d.ts +3 -0
  30. package/lib/wishlist/types/esolve-wishlist-set-action.type.d.ts +1 -0
  31. package/lib/wishlist/types/esolve-wishlist.type.d.ts +2 -0
  32. package/lib/wishlist/types/index.d.ts +2 -0
  33. package/package.json +1 -1
  34. package/public-api.d.ts +1 -0
  35. package/schematics/collection.json +0 -9
  36. package/schematics/ng-add/index.d.ts +0 -2
  37. package/schematics/ng-add/index.js +0 -30
  38. package/schematics/ng-add/index.js.map +0 -1
@@ -18,6 +18,10 @@ export declare class EsolveStockPrice {
18
18
  * Price with tax and with discounts applied if applicable
19
19
  */
20
20
  sell_price_with_tax: number;
21
+ /**
22
+ * Vat Rate for the item
23
+ */
24
+ tax_rate: number;
21
25
  taxed: boolean;
22
26
  /**
23
27
  * Create stock price instance
@@ -26,6 +30,7 @@ export declare class EsolveStockPrice {
26
30
  * @param base_price_with_tax Price with tax
27
31
  * @param sell_price Price without tax and with discounts applied if applicable
28
32
  * @param sell_price_with_tax Price with tax and with discounts applied if applicable
33
+ * @param tax_rate Tax rate of the item
29
34
  * @param taxed Whether tax has been applied
30
35
  */
31
36
  constructor(
@@ -44,5 +49,9 @@ export declare class EsolveStockPrice {
44
49
  /**
45
50
  * Price with tax and with discounts applied if applicable
46
51
  */
47
- sell_price_with_tax?: number, taxed?: boolean);
52
+ sell_price_with_tax?: number,
53
+ /**
54
+ * Vat Rate for the item
55
+ */
56
+ tax_rate?: number, taxed?: boolean);
48
57
  }
@@ -0,0 +1,3 @@
1
+ import { EsolveResponseResult } from '../../shared/response';
2
+ export declare class EsolveEmptyWishlistResult extends EsolveResponseResult {
3
+ }
@@ -0,0 +1,13 @@
1
+ import { EsolveStockItem } from '../../stock/classes/esolve-stock-item.model';
2
+ export declare class EsolveWishlistItem {
3
+ id: number;
4
+ qty: number;
5
+ vat_rate: number;
6
+ price: number;
7
+ price_incl: number;
8
+ vat_total: number;
9
+ total: number;
10
+ total_incl: number;
11
+ stock_item?: EsolveStockItem<import("@esolve/ng-esolve-connect").EsolveCustomFields> | undefined;
12
+ constructor(id: number, qty: number, vat_rate: number, price: number, price_incl: number, vat_total: number, total: number, total_incl: number, stock_item?: EsolveStockItem<import("@esolve/ng-esolve-connect").EsolveCustomFields> | undefined);
13
+ }
@@ -0,0 +1 @@
1
+ export * from './esolve-wishlist-item.model';
@@ -0,0 +1,53 @@
1
+ import { HttpClient } from '@angular/common/http';
2
+ import { Observable } from 'rxjs';
3
+ import { EsolveConnectConfig } from '../esolve-connect.config';
4
+ import { EsolveErrorHandlerService } from '../shared/errors/esolve-error-handler.service';
5
+ import { EsolveResponseHandlerService } from '../shared/response';
6
+ import { EsolveWishlistSetAction } from './types/esolve-wishlist-set-action.type';
7
+ import { EsolveWishlistItemResponse } from './interfaces/esolve-wishlist-item-response.interface';
8
+ import { EsolveWishlist } from './types/esolve-wishlist.type';
9
+ import { EsolveCustomFields } from '../shared/custom-fields';
10
+ import { EsolveWishlistSetItem } from './interfaces';
11
+ import { EsolveEmptyWishlistResult } from './classes/esolve-empty-wishlist-result.model';
12
+ import * as i0 from "@angular/core";
13
+ export declare class EsolveWishlistService<T extends EsolveCustomFields = EsolveCustomFields> {
14
+ private config;
15
+ private http;
16
+ private errorHandler;
17
+ private responseHandler;
18
+ constructor(config: EsolveConnectConfig, http: HttpClient, errorHandler: EsolveErrorHandlerService, responseHandler: EsolveResponseHandlerService);
19
+ /**
20
+ * Retrieves the current wishlist
21
+ *
22
+ * @returns An `Observable` with an array of cart items
23
+ */
24
+ getWishlist(): Observable<EsolveWishlist>;
25
+ /**
26
+ * Updates the wishlist by preforming various actions, such as adding, editing or removing items from the list.
27
+ *
28
+ * @param items An array of options to update the wishlist
29
+ * @param action The default action to preform
30
+ * @returns An `Observable` with an array of responses that gives feedback on the requested changes
31
+ */
32
+ setWishlist(items: EsolveWishlistSetItem[], default_action?: EsolveWishlistSetAction): Observable<EsolveWishlistItemResponse[]>;
33
+ /**
34
+ * Empties the wishlist for the logged in user.
35
+ *
36
+ * @returns Observable of type EsolveEmptyWishlistResult
37
+ */
38
+ setWishlistEmpty(): Observable<EsolveEmptyWishlistResult>;
39
+ /**
40
+ * Processes the eSolve wishlist records
41
+ *
42
+ * @param wishlist_item_records Records to process
43
+ * @returns An array of processed cart items
44
+ */
45
+ private processWishlist;
46
+ /**
47
+ * Retrieves stock records from HTTP params.
48
+ * @param params HTTP client parameters
49
+ */
50
+ private getWishlistRecords;
51
+ static ɵfac: i0.ɵɵFactoryDeclaration<EsolveWishlistService<any>, never>;
52
+ static ɵprov: i0.ɵɵInjectableDeclaration<EsolveWishlistService<any>>;
53
+ }
@@ -0,0 +1,4 @@
1
+ export * from './types';
2
+ export * from './classes';
3
+ export * from './interfaces';
4
+ export * from './esolve-wishlist.service';
@@ -0,0 +1,13 @@
1
+ import { EsolveStockRecord } from '../../stock/interfaces/esolve-stock-record.interface';
2
+ export interface EsolveWishlistItemRecord {
3
+ id: number;
4
+ qty: number;
5
+ vat_rate: number;
6
+ price: number;
7
+ price_description: string;
8
+ price_incl: number;
9
+ vat_total: number;
10
+ line_total: number;
11
+ line_total_incl: number;
12
+ stock_item: EsolveStockRecord;
13
+ }
@@ -0,0 +1,6 @@
1
+ import { EsolvePostResponseItem } from '../../shared/response';
2
+ export interface EsolveWishlistItemResponse extends EsolvePostResponseItem {
3
+ esolve_id: number;
4
+ updated: boolean;
5
+ current_qty: number;
6
+ }
@@ -0,0 +1,7 @@
1
+ import { EsolveWishlistSetAction } from '../types/esolve-wishlist-set-action.type';
2
+ export interface EsolveWishlistSetItem {
3
+ code: string;
4
+ id?: number;
5
+ qty?: number;
6
+ action?: EsolveWishlistSetAction;
7
+ }
@@ -0,0 +1,3 @@
1
+ export * from './esolve-wishlist-item-record.interface';
2
+ export * from './esolve-wishlist-item-response.interface';
3
+ export * from './esolve-wishlist-set-item.interface';
@@ -0,0 +1 @@
1
+ export declare type EsolveWishlistSetAction = 'add' | 'edit' | 'remove';
@@ -0,0 +1,2 @@
1
+ import { EsolveWishlistItem } from '../classes/esolve-wishlist-item.model';
2
+ export declare type EsolveWishlist = EsolveWishlistItem[];
@@ -0,0 +1,2 @@
1
+ export * from './esolve-wishlist-set-action.type';
2
+ export * from './esolve-wishlist.type';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@esolve/ng-esolve-connect",
3
- "version": "0.21.2",
3
+ "version": "0.22.0",
4
4
  "description": "An Angular library that speaks to an eSolve instance's API",
5
5
  "ng-add": {
6
6
  "save": "true"
package/public-api.d.ts CHANGED
@@ -31,3 +31,4 @@ export * from './lib/payment';
31
31
  export * from './lib/shipping';
32
32
  export * from './lib/locations';
33
33
  export * from './lib/enquiry';
34
+ export * from './lib/wishlist';
@@ -1,9 +0,0 @@
1
- {
2
- "$schema": "../../../node_modules/@angular-devkit/schematics/collection-schema.json",
3
- "schematics": {
4
- "ng-add": {
5
- "description": "Add NG eSolve Connect to project",
6
- "factory": "./ng-add/index#ngAdd"
7
- }
8
- }
9
- }
@@ -1,2 +0,0 @@
1
- import { Rule } from '@angular-devkit/schematics';
2
- export declare function ngAdd(): Rule;
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ngAdd = void 0;
4
- const schematics_1 = require("@angular-devkit/schematics");
5
- const tasks_1 = require("@angular-devkit/schematics/tasks");
6
- const change_1 = require("@schematics/angular/utility/change");
7
- const ast_utils_1 = require("@schematics/angular/utility/ast-utils");
8
- const ts = require("typescript");
9
- function ngAdd() {
10
- return (tree, context) => {
11
- context.logger.info('Adding library module to the app...');
12
- const module_path = '/src/app/app.module.ts';
13
- if (!tree.exists(module_path)) {
14
- throw new schematics_1.SchematicsException(`The file '${module_path}' doesn't exist...`);
15
- }
16
- const recorder = tree.beginUpdate(module_path);
17
- const text = tree.read(module_path);
18
- if (text === null) {
19
- throw new schematics_1.SchematicsException(`The file '${module_path}' doesn't exist...`);
20
- }
21
- const source = ts.createSourceFile(module_path, text.toString(), ts.ScriptTarget.Latest, true);
22
- (0, change_1.applyToUpdateRecorder)(recorder, (0, ast_utils_1.addImportToModule)(source, module_path, 'NgEsolveConnectModule.forRoot()', '@esolve/ng-esolve-connect'));
23
- tree.commitUpdate(recorder);
24
- context.logger.info('Installing dependencies...');
25
- context.addTask(new tasks_1.NodePackageInstallTask());
26
- return tree;
27
- };
28
- }
29
- exports.ngAdd = ngAdd;
30
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../projects/ng-esolve-connect/schematics/ng-add/index.ts"],"names":[],"mappings":";;;AAAA,2DAA+F;AAC/F,4DAA0E;AAE1E,+DAA2E;AAC3E,qEAA0E;AAE1E,iCAAiC;AAEjC,SAAgB,KAAK;IACjB,OAAO,CAAC,IAAU,EAAE,OAAyB,EAAE,EAAE;QAC7C,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,qCAAqC,CAAC,CAAC;QAC3D,MAAM,WAAW,GAAG,wBAAwB,CAAC;QAE7C,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE;YAC3B,MAAM,IAAI,gCAAmB,CAAC,aAAa,WAAW,oBAAoB,CAAC,CAAC;SAC/E;QAED,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;QAE/C,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAEpC,IAAI,IAAI,KAAK,IAAI,EAAE;YACf,MAAM,IAAI,gCAAmB,CAAC,aAAa,WAAW,oBAAoB,CAAC,CAAC;SAC/E;QAED,MAAM,MAAM,GAAG,EAAE,CAAC,gBAAgB,CAC9B,WAAW,EACX,IAAI,CAAC,QAAQ,EAAE,EACf,EAAE,CAAC,YAAY,CAAC,MAAM,EACtB,IAAI,CACP,CAAC;QAEF,IAAA,8BAAqB,EACjB,QAAQ,EACR,IAAA,6BAAiB,EACb,MAAM,EACN,WAAW,EACX,iCAAiC,EACjC,2BAA2B,CAC9B,CACJ,CAAC;QAEF,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QAE5B,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;QAClD,OAAO,CAAC,OAAO,CAAC,IAAI,8BAAsB,EAAE,CAAC,CAAC;QAE9C,OAAO,IAAI,CAAC;IAChB,CAAC,CAAC;AACN,CAAC;AAzCD,sBAyCC"}