@esolve/ng-esolve-connect 0.53.0 → 0.54.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/esm2022/lib/account/address/classes/esolve-address-result.model.mjs +1 -1
- package/esm2022/lib/account/address/classes/esolve-session-address-result.model.mjs +11 -0
- package/esm2022/lib/account/address/classes/index.mjs +2 -1
- package/esm2022/lib/account/address/interfaces/esolve-address-response.interface.mjs +1 -1
- package/esm2022/lib/account/confirmation/esolve-account-confirmation-post-response-item.interface.mjs +1 -1
- package/esm2022/lib/account/esolve-account.service.mjs +61 -13
- package/esm2022/lib/account/esolve-geocode-response.interface.mjs +2 -0
- package/esm2022/lib/account/esolve-session-shipping-result.model.mjs +11 -0
- package/esm2022/lib/account/index.mjs +3 -1
- package/esm2022/lib/auth/esolve-auth.service.mjs +9 -7
- package/esm2022/lib/auth/interfaces/esolve-auth-data.interface.mjs +1 -1
- package/esm2022/lib/auth/types/esolve-login-response.type.mjs +2 -0
- package/esm2022/lib/auth/types/index.mjs +2 -1
- package/esm2022/lib/device/esolve-device.service.mjs +3 -3
- package/esm2022/lib/device/interfaces/esolve-device.interface.mjs +1 -1
- package/esm2022/lib/session/esolve-session.service.mjs +34 -2
- package/esm2022/lib/session/interfaces/esolve-session-data.interface.mjs +1 -1
- package/esm2022/lib/session/interfaces/esolve-session.interface.mjs +1 -1
- package/esm2022/lib/transactions/classes/esolve-transaction-item.model.mjs +5 -1
- package/esm2022/lib/transactions/interfaces/esolve-transaction-item-record.interface.mjs +1 -1
- package/fesm2022/esolve-ng-esolve-connect.mjs +1568 -1460
- package/fesm2022/esolve-ng-esolve-connect.mjs.map +1 -1
- package/lib/account/address/classes/esolve-address-result.model.d.ts +2 -2
- package/lib/account/address/classes/esolve-session-address-result.model.d.ts +5 -0
- package/lib/account/address/classes/index.d.ts +1 -0
- package/lib/account/address/interfaces/esolve-address-response.interface.d.ts +2 -2
- package/lib/account/confirmation/esolve-account-confirmation-post-response-item.interface.d.ts +2 -0
- package/lib/account/esolve-account.service.d.ts +6 -3
- package/lib/account/{esolve-geocode-result.interface.d.ts → esolve-geocode-response.interface.d.ts} +1 -1
- package/lib/account/esolve-session-shipping-result.model.d.ts +5 -0
- package/lib/account/index.d.ts +2 -0
- package/lib/auth/interfaces/esolve-auth-data.interface.d.ts +2 -0
- package/lib/auth/types/esolve-login-response.type.d.ts +4 -0
- package/lib/auth/types/index.d.ts +1 -0
- package/lib/device/interfaces/esolve-device.interface.d.ts +1 -1
- package/lib/session/esolve-session.service.d.ts +11 -1
- package/lib/session/interfaces/esolve-session-data.interface.d.ts +2 -0
- package/lib/session/interfaces/esolve-session.interface.d.ts +2 -0
- package/lib/transactions/classes/esolve-transaction-item.model.d.ts +2 -0
- package/lib/transactions/interfaces/esolve-transaction-item-record.interface.d.ts +2 -0
- package/package.json +1 -1
- package/esm2022/lib/account/esolve-geocode-result.interface.mjs +0 -2
|
@@ -65,6 +65,32 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.4", ngImpor
|
|
|
65
65
|
}]
|
|
66
66
|
}], ctorParameters: function () { return []; } });
|
|
67
67
|
|
|
68
|
+
class EsolveCookieService {
|
|
69
|
+
constructor() {
|
|
70
|
+
this.cookieService = inject(SsrCookieService);
|
|
71
|
+
}
|
|
72
|
+
check(name) {
|
|
73
|
+
return this.cookieService.check(name);
|
|
74
|
+
}
|
|
75
|
+
get(name) {
|
|
76
|
+
return this.cookieService.get(name);
|
|
77
|
+
}
|
|
78
|
+
set(name, value, expires, path, domain, secure) {
|
|
79
|
+
this.cookieService.set(name, value, expires, path, domain, secure);
|
|
80
|
+
}
|
|
81
|
+
delete(name, path, domain, secure) {
|
|
82
|
+
this.cookieService.delete(name, path, domain, secure);
|
|
83
|
+
}
|
|
84
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.4", ngImport: i0, type: EsolveCookieService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
85
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.4", ngImport: i0, type: EsolveCookieService, providedIn: 'root' }); }
|
|
86
|
+
}
|
|
87
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.4", ngImport: i0, type: EsolveCookieService, decorators: [{
|
|
88
|
+
type: Injectable,
|
|
89
|
+
args: [{
|
|
90
|
+
providedIn: 'root',
|
|
91
|
+
}]
|
|
92
|
+
}] });
|
|
93
|
+
|
|
68
94
|
class EsolveHttpError extends Error {
|
|
69
95
|
constructor(type, code, message) {
|
|
70
96
|
// Pass remaining arguments (including vendor specific ones) to parent constructor
|
|
@@ -169,138 +195,380 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.4", ngImpor
|
|
|
169
195
|
}]
|
|
170
196
|
}] });
|
|
171
197
|
|
|
172
|
-
class
|
|
173
|
-
constructor() {
|
|
174
|
-
this.
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
return this.cookieService.get(name);
|
|
181
|
-
}
|
|
182
|
-
set(name, value, expires, path, domain, secure) {
|
|
183
|
-
this.cookieService.set(name, value, expires, path, domain, secure);
|
|
198
|
+
class EsolveMultipleSelectFilter {
|
|
199
|
+
constructor(field, options) {
|
|
200
|
+
this.field = field;
|
|
201
|
+
this.type = 'multiple';
|
|
202
|
+
this.options = [];
|
|
203
|
+
if (options) {
|
|
204
|
+
this.options = options;
|
|
205
|
+
}
|
|
184
206
|
}
|
|
185
|
-
|
|
186
|
-
this.
|
|
207
|
+
setValue(values) {
|
|
208
|
+
this.values = values;
|
|
187
209
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
* It should only be used to indicate that a state has changed. It should not be
|
|
204
|
-
* used for encryption.
|
|
205
|
-
*
|
|
206
|
-
* @param values Raw strings and numbers to hash
|
|
207
|
-
*
|
|
208
|
-
* @returns Hexadecimal hash value
|
|
209
|
-
*/
|
|
210
|
-
function esolveHexHash(...values) {
|
|
211
|
-
// Add an extra value to pad out hash
|
|
212
|
-
values.push('esolve_eurus');
|
|
213
|
-
// Create a string from the values
|
|
214
|
-
const string = values.join('::');
|
|
215
|
-
let hash = 0;
|
|
216
|
-
for (let x = 0; x < string.length; x++) {
|
|
217
|
-
const ch = string.charCodeAt(x);
|
|
218
|
-
hash = (hash << 5) - hash + ch;
|
|
219
|
-
hash = hash & hash;
|
|
210
|
+
toHttpParams(http_params) {
|
|
211
|
+
if (!this.values) {
|
|
212
|
+
throw new Error('No values set');
|
|
213
|
+
}
|
|
214
|
+
const base_property = `filter[${this.field}]`;
|
|
215
|
+
const type_property = base_property + '[type]';
|
|
216
|
+
const values_property = base_property + '[values][]';
|
|
217
|
+
const params = {
|
|
218
|
+
[type_property]: this.type,
|
|
219
|
+
[values_property]: this.values,
|
|
220
|
+
};
|
|
221
|
+
if (http_params) {
|
|
222
|
+
return http_params.appendAll(params);
|
|
223
|
+
}
|
|
224
|
+
return params;
|
|
220
225
|
}
|
|
221
|
-
return Math.abs(hash).toString(16);
|
|
222
226
|
}
|
|
223
227
|
|
|
224
|
-
class
|
|
225
|
-
constructor() {
|
|
226
|
-
this.
|
|
227
|
-
this.
|
|
228
|
-
this.
|
|
229
|
-
this.
|
|
230
|
-
this.
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
this.storage_key = '';
|
|
234
|
-
/* These are RxJS subjects used for managing the expiration of the user session. */
|
|
235
|
-
this.timer_start = new Subject();
|
|
236
|
-
this.timer_stop = new Subject();
|
|
237
|
-
this.expire = new Subject();
|
|
238
|
-
this.session_end = new Subject();
|
|
239
|
-
this.setStorageKey();
|
|
240
|
-
this._session = this.initSession();
|
|
241
|
-
this.getSession()
|
|
242
|
-
.pipe(map(({ token, user_id, location_id }) => {
|
|
243
|
-
return esolveHexHash(token, user_id, location_id);
|
|
244
|
-
}))
|
|
245
|
-
.subscribe((hash) => {
|
|
246
|
-
this.state_hash = hash;
|
|
247
|
-
});
|
|
248
|
-
this.timer_start
|
|
249
|
-
.pipe(switchMap((time) => {
|
|
250
|
-
return timer(time).pipe(takeUntil(this.timer_stop));
|
|
251
|
-
}))
|
|
252
|
-
.subscribe(() => {
|
|
253
|
-
// Stored time expired. Check if session is valid
|
|
254
|
-
this.session_end.next();
|
|
255
|
-
});
|
|
256
|
-
// Kill session and reset state
|
|
257
|
-
this.onExpire().subscribe(() => {
|
|
258
|
-
this.reset();
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
initSession() {
|
|
262
|
-
const session = {
|
|
263
|
-
token: this.onTokenUpdate(),
|
|
264
|
-
user_id: this.onUserIdUpdate(),
|
|
265
|
-
location_id: this.onLocationIdUpdate(),
|
|
228
|
+
class EsolveRangeFilter {
|
|
229
|
+
constructor(field, min = 0, max = 0) {
|
|
230
|
+
this.field = field;
|
|
231
|
+
this.type = 'range';
|
|
232
|
+
this.min = 0;
|
|
233
|
+
this.max = 0;
|
|
234
|
+
this.options = {
|
|
235
|
+
min: 0,
|
|
236
|
+
max: 0,
|
|
266
237
|
};
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
238
|
+
this.options.min = min;
|
|
239
|
+
this.options.max = max;
|
|
240
|
+
if (max > 0 && min > max) {
|
|
241
|
+
this.options.min = max;
|
|
242
|
+
this.options.max = min;
|
|
243
|
+
}
|
|
273
244
|
}
|
|
274
|
-
|
|
275
|
-
|
|
245
|
+
setValue(min, max) {
|
|
246
|
+
this.min = min;
|
|
247
|
+
this.max = max;
|
|
248
|
+
if (max > 0 && min > max) {
|
|
249
|
+
this.min = max;
|
|
250
|
+
this.max = min;
|
|
251
|
+
}
|
|
276
252
|
}
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
253
|
+
toHttpParams(http_params) {
|
|
254
|
+
if (this.min <= 0 && this.max <= 0) {
|
|
255
|
+
throw new Error('No values set');
|
|
256
|
+
}
|
|
257
|
+
const base_property = `filter[${this.field}]`;
|
|
258
|
+
const type_property = base_property + '[type]';
|
|
259
|
+
const min_property = base_property + '[min]';
|
|
260
|
+
const max_property = base_property + '[max]';
|
|
261
|
+
const params = {
|
|
262
|
+
[type_property]: this.type,
|
|
263
|
+
[min_property]: this.min,
|
|
264
|
+
[max_property]: this.max,
|
|
282
265
|
};
|
|
266
|
+
if (http_params) {
|
|
267
|
+
return http_params.appendAll(params);
|
|
268
|
+
}
|
|
269
|
+
return params;
|
|
283
270
|
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
class EsolveSingleSelectFilter {
|
|
274
|
+
constructor(field, options_or_value) {
|
|
275
|
+
this.field = field;
|
|
276
|
+
this.type = 'single';
|
|
277
|
+
this.options = [];
|
|
278
|
+
if (Array.isArray(options_or_value)) {
|
|
279
|
+
this.options = options_or_value;
|
|
280
|
+
}
|
|
281
|
+
else {
|
|
282
|
+
this.setValue(options_or_value);
|
|
283
|
+
}
|
|
292
284
|
}
|
|
293
|
-
|
|
294
|
-
|
|
285
|
+
setValue(value) {
|
|
286
|
+
this.value = value;
|
|
295
287
|
}
|
|
296
|
-
|
|
297
|
-
|
|
288
|
+
toHttpParams(http_params) {
|
|
289
|
+
if (!this.value) {
|
|
290
|
+
throw new Error('No values set');
|
|
291
|
+
}
|
|
292
|
+
const base_property = `filter[${this.field}]`;
|
|
293
|
+
const type_property = base_property + '[type]';
|
|
294
|
+
const values_property = base_property + '[value]';
|
|
295
|
+
const params = {
|
|
296
|
+
[type_property]: this.type,
|
|
297
|
+
[values_property]: this.value,
|
|
298
|
+
};
|
|
299
|
+
if (http_params) {
|
|
300
|
+
return http_params.appendAll(params);
|
|
301
|
+
}
|
|
302
|
+
return params;
|
|
298
303
|
}
|
|
299
|
-
|
|
300
|
-
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
class EsolveToggleFilter {
|
|
307
|
+
constructor(field, value) {
|
|
308
|
+
this.field = field;
|
|
309
|
+
this.value = value;
|
|
310
|
+
this.type = 'toggle';
|
|
301
311
|
}
|
|
302
|
-
|
|
303
|
-
|
|
312
|
+
toHttpParams(http_params) {
|
|
313
|
+
const base_property = `filter[${this.field}]`;
|
|
314
|
+
const type_property = base_property + '[type]';
|
|
315
|
+
const values_property = base_property + '[value]';
|
|
316
|
+
const params = {
|
|
317
|
+
[type_property]: this.type,
|
|
318
|
+
[values_property]: this.value ? 1 : 0,
|
|
319
|
+
};
|
|
320
|
+
if (http_params) {
|
|
321
|
+
return http_params.appendAll(params);
|
|
322
|
+
}
|
|
323
|
+
return params;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
// Classes
|
|
328
|
+
|
|
329
|
+
// Interfaces
|
|
330
|
+
|
|
331
|
+
// Types
|
|
332
|
+
|
|
333
|
+
function createRangeWithValue(field, min = 0, max = 0) {
|
|
334
|
+
const filter = new EsolveRangeFilter(field);
|
|
335
|
+
filter.setValue(min, max);
|
|
336
|
+
return filter;
|
|
337
|
+
}
|
|
338
|
+
function createSingleSelectWithValue(field, value) {
|
|
339
|
+
const filter = new EsolveSingleSelectFilter(field, value);
|
|
340
|
+
return filter;
|
|
341
|
+
}
|
|
342
|
+
function createToggleSelectWithValue(field, value) {
|
|
343
|
+
const filter = new EsolveToggleFilter(field, value);
|
|
344
|
+
return filter;
|
|
345
|
+
}
|
|
346
|
+
function createMultipleSelectWithValue(field, value) {
|
|
347
|
+
const filter = new EsolveMultipleSelectFilter(field);
|
|
348
|
+
filter.setValue(value);
|
|
349
|
+
return filter;
|
|
350
|
+
}
|
|
351
|
+
function covertFromObj(obj) {
|
|
352
|
+
const filters = [];
|
|
353
|
+
for (const field in obj) {
|
|
354
|
+
const value = obj[field];
|
|
355
|
+
let filter = null;
|
|
356
|
+
if (Array.isArray(value)) {
|
|
357
|
+
filter = createMultipleSelectWithValue(field, value);
|
|
358
|
+
}
|
|
359
|
+
else if (typeof value === 'object') {
|
|
360
|
+
filter = createRangeWithValue(field, value.min, value.max);
|
|
361
|
+
}
|
|
362
|
+
else if (typeof value === 'boolean') {
|
|
363
|
+
filter = createToggleSelectWithValue(field, value);
|
|
364
|
+
}
|
|
365
|
+
else {
|
|
366
|
+
filter = createSingleSelectWithValue(field, value);
|
|
367
|
+
}
|
|
368
|
+
if (filter) {
|
|
369
|
+
filters.push(filter);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
return filters;
|
|
373
|
+
}
|
|
374
|
+
function convertToHttpParams(filters, http_params) {
|
|
375
|
+
if (http_params) {
|
|
376
|
+
for (const filter of filters) {
|
|
377
|
+
http_params = filter.toHttpParams(http_params);
|
|
378
|
+
}
|
|
379
|
+
return http_params;
|
|
380
|
+
}
|
|
381
|
+
let params = {};
|
|
382
|
+
for (const filter of filters) {
|
|
383
|
+
params = {
|
|
384
|
+
...params,
|
|
385
|
+
...filter.toHttpParams(),
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
return params;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
var esolveFilterFactory = /*#__PURE__*/Object.freeze({
|
|
392
|
+
__proto__: null,
|
|
393
|
+
convertToHttpParams: convertToHttpParams,
|
|
394
|
+
covertFromObj: covertFromObj,
|
|
395
|
+
createMultipleSelectWithValue: createMultipleSelectWithValue,
|
|
396
|
+
createRangeWithValue: createRangeWithValue,
|
|
397
|
+
createSingleSelectWithValue: createSingleSelectWithValue,
|
|
398
|
+
createToggleSelectWithValue: createToggleSelectWithValue
|
|
399
|
+
});
|
|
400
|
+
|
|
401
|
+
class EsolveResponseResult {
|
|
402
|
+
constructor(response) {
|
|
403
|
+
this.success_log = [];
|
|
404
|
+
this.error_log = [];
|
|
405
|
+
this.error_log.push(...response.log.filter((log_item) => log_item.type === 'error'));
|
|
406
|
+
this.success_log.push(...response.log.filter((log_item) => log_item.type === 'success'));
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
class EsolveResponseHandlerService {
|
|
411
|
+
/**
|
|
412
|
+
* Parse single HTTP response
|
|
413
|
+
*
|
|
414
|
+
* @param http_response HTTP Response to eSolve service
|
|
415
|
+
* @param resultHandler Function to parse response to a result
|
|
416
|
+
*
|
|
417
|
+
* @returns Parsed result of response
|
|
418
|
+
*/
|
|
419
|
+
validateSingleHttpResponse(http_response, resultHandler) {
|
|
420
|
+
if (http_response.responses === undefined ||
|
|
421
|
+
http_response.responses.length <= 0) {
|
|
422
|
+
throw http_response;
|
|
423
|
+
}
|
|
424
|
+
const response = http_response.responses[0];
|
|
425
|
+
if (response.status.state === 'error' ||
|
|
426
|
+
response.status.state === 'none') {
|
|
427
|
+
throw response;
|
|
428
|
+
}
|
|
429
|
+
return resultHandler(response);
|
|
430
|
+
}
|
|
431
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.4", ngImport: i0, type: EsolveResponseHandlerService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
432
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.4", ngImport: i0, type: EsolveResponseHandlerService, providedIn: 'root' }); }
|
|
433
|
+
}
|
|
434
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.4", ngImport: i0, type: EsolveResponseHandlerService, decorators: [{
|
|
435
|
+
type: Injectable,
|
|
436
|
+
args: [{
|
|
437
|
+
providedIn: 'root',
|
|
438
|
+
}]
|
|
439
|
+
}] });
|
|
440
|
+
|
|
441
|
+
// Types
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Generates a short hexadecimal hash that will be used to indicate a change in
|
|
445
|
+
* state.
|
|
446
|
+
*
|
|
447
|
+
* NOTE: Not to be confused with an actual hash checksum, like MD5 or SHA256.
|
|
448
|
+
* It should only be used to indicate that a state has changed. It should not be
|
|
449
|
+
* used for encryption.
|
|
450
|
+
*
|
|
451
|
+
* @param values Raw strings and numbers to hash
|
|
452
|
+
*
|
|
453
|
+
* @returns Hexadecimal hash value
|
|
454
|
+
*/
|
|
455
|
+
function esolveHexHash(...values) {
|
|
456
|
+
// Add an extra value to pad out hash
|
|
457
|
+
values.push('esolve_eurus');
|
|
458
|
+
// Create a string from the values
|
|
459
|
+
const string = values.join('::');
|
|
460
|
+
let hash = 0;
|
|
461
|
+
for (let x = 0; x < string.length; x++) {
|
|
462
|
+
const ch = string.charCodeAt(x);
|
|
463
|
+
hash = (hash << 5) - hash + ch;
|
|
464
|
+
hash = hash & hash;
|
|
465
|
+
}
|
|
466
|
+
return Math.abs(hash).toString(16);
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
class EsolveList {
|
|
470
|
+
constructor(items = [], page = 0, rows = 0, total = 0) {
|
|
471
|
+
this.items = items;
|
|
472
|
+
this.page = page;
|
|
473
|
+
this.rows = rows;
|
|
474
|
+
this.total = total;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
class EsolveResult {
|
|
479
|
+
constructor(status, code, message) {
|
|
480
|
+
this.status = status;
|
|
481
|
+
this.code = code;
|
|
482
|
+
this.message = message;
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
class EsolveSessionService {
|
|
487
|
+
constructor() {
|
|
488
|
+
this.is_browser = isPlatformBrowser(inject(PLATFORM_ID));
|
|
489
|
+
this.config = inject(EsolveConfigService);
|
|
490
|
+
this.cookieService = inject(EsolveCookieService);
|
|
491
|
+
this.token$ = new BehaviorSubject('');
|
|
492
|
+
this.user_id$ = new BehaviorSubject(0);
|
|
493
|
+
this.location_id$ = new BehaviorSubject(0);
|
|
494
|
+
this.addresses_id$ = new BehaviorSubject(0);
|
|
495
|
+
this.shipping_id$ = new BehaviorSubject(0);
|
|
496
|
+
this.state_hash = '';
|
|
497
|
+
this.storage_key = '';
|
|
498
|
+
/* These are RxJS subjects used for managing the expiration of the user session. */
|
|
499
|
+
this.timer_start = new Subject();
|
|
500
|
+
this.timer_stop = new Subject();
|
|
501
|
+
this.expire = new Subject();
|
|
502
|
+
this.session_end = new Subject();
|
|
503
|
+
this.setStorageKey();
|
|
504
|
+
this._session = this.initSession();
|
|
505
|
+
this.getSession()
|
|
506
|
+
.pipe(map(({ token, user_id, location_id }) => {
|
|
507
|
+
return esolveHexHash(token, user_id, location_id);
|
|
508
|
+
}))
|
|
509
|
+
.subscribe((hash) => {
|
|
510
|
+
this.state_hash = hash;
|
|
511
|
+
});
|
|
512
|
+
this.timer_start
|
|
513
|
+
.pipe(switchMap((time) => {
|
|
514
|
+
return timer(time).pipe(takeUntil(this.timer_stop));
|
|
515
|
+
}))
|
|
516
|
+
.subscribe(() => {
|
|
517
|
+
// Stored time expired. Check if session is valid
|
|
518
|
+
this.session_end.next();
|
|
519
|
+
});
|
|
520
|
+
// Kill session and reset state
|
|
521
|
+
this.onExpire().subscribe(() => {
|
|
522
|
+
this.reset();
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
initSession() {
|
|
526
|
+
const session = {
|
|
527
|
+
token: this.onTokenUpdate(),
|
|
528
|
+
user_id: this.onUserIdUpdate(),
|
|
529
|
+
location_id: this.onLocationIdUpdate(),
|
|
530
|
+
addresses_id: this.onAddressesIdUpdate(),
|
|
531
|
+
shipping_id: this.onShippingIdUpdate(),
|
|
532
|
+
};
|
|
533
|
+
return combineLatest(session).pipe(
|
|
534
|
+
// Delays the emit only slightly incase multiple values are set
|
|
535
|
+
debounceTime(10), shareReplay(1));
|
|
536
|
+
}
|
|
537
|
+
isValid() {
|
|
538
|
+
return this.getToken() !== '';
|
|
539
|
+
}
|
|
540
|
+
getSession() {
|
|
541
|
+
return this._session;
|
|
542
|
+
}
|
|
543
|
+
getSessionValue() {
|
|
544
|
+
return {
|
|
545
|
+
token: this.token$.getValue(),
|
|
546
|
+
user_id: this.user_id$.getValue(),
|
|
547
|
+
location_id: this.location_id$.getValue(),
|
|
548
|
+
addresses_id: this.addresses_id$.getValue(),
|
|
549
|
+
shipping_id: this.shipping_id$.getValue(),
|
|
550
|
+
};
|
|
551
|
+
}
|
|
552
|
+
onSessionEnd() {
|
|
553
|
+
return this.session_end.asObservable();
|
|
554
|
+
}
|
|
555
|
+
onExpire() {
|
|
556
|
+
return this.expire.asObservable();
|
|
557
|
+
}
|
|
558
|
+
expireSession() {
|
|
559
|
+
this.expire.next();
|
|
560
|
+
}
|
|
561
|
+
getToken() {
|
|
562
|
+
return this.token$.getValue();
|
|
563
|
+
}
|
|
564
|
+
onTokenUpdate() {
|
|
565
|
+
return this.token$.asObservable().pipe(filter((token) => token !== ''), distinctUntilChanged());
|
|
566
|
+
}
|
|
567
|
+
updateToken(token) {
|
|
568
|
+
this.token$.next(token);
|
|
569
|
+
}
|
|
570
|
+
getUserId() {
|
|
571
|
+
return this.user_id$.getValue();
|
|
304
572
|
}
|
|
305
573
|
onUserIdUpdate() {
|
|
306
574
|
return this.user_id$.asObservable().pipe(distinctUntilChanged());
|
|
@@ -317,6 +585,24 @@ class EsolveSessionService {
|
|
|
317
585
|
updateLocationId(location_id) {
|
|
318
586
|
this.location_id$.next(location_id);
|
|
319
587
|
}
|
|
588
|
+
getAddressesId() {
|
|
589
|
+
return this.addresses_id$.getValue();
|
|
590
|
+
}
|
|
591
|
+
onAddressesIdUpdate() {
|
|
592
|
+
return this.addresses_id$.asObservable().pipe(distinctUntilChanged());
|
|
593
|
+
}
|
|
594
|
+
updateAddressesId(addresses_id) {
|
|
595
|
+
this.addresses_id$.next(addresses_id);
|
|
596
|
+
}
|
|
597
|
+
getShippingId() {
|
|
598
|
+
return this.shipping_id$.getValue();
|
|
599
|
+
}
|
|
600
|
+
onShippingIdUpdate() {
|
|
601
|
+
return this.shipping_id$.asObservable().pipe(distinctUntilChanged());
|
|
602
|
+
}
|
|
603
|
+
updateShippingId(shipping_id) {
|
|
604
|
+
this.shipping_id$.next(shipping_id);
|
|
605
|
+
}
|
|
320
606
|
getStateHash() {
|
|
321
607
|
return this.state_hash;
|
|
322
608
|
}
|
|
@@ -339,17 +625,25 @@ class EsolveSessionService {
|
|
|
339
625
|
this.setCache(session.token, grace_expiry_date);
|
|
340
626
|
this.updateUserId(session.user_id);
|
|
341
627
|
this.updateLocationId(session.location_id);
|
|
628
|
+
this.updateAddressesId(session.addresses_id);
|
|
629
|
+
this.updateShippingId(session.shipping_id);
|
|
342
630
|
// Update token last to make sure session is correctly checked
|
|
343
631
|
this.updateToken(session.token);
|
|
344
632
|
this.startTimer(expiry_date);
|
|
345
633
|
}
|
|
346
|
-
handleUpdateSession({ user_id, location_id, }) {
|
|
634
|
+
handleUpdateSession({ user_id, location_id, addresses_id, shipping_id, }) {
|
|
347
635
|
if (typeof user_id !== 'undefined') {
|
|
348
636
|
this.updateUserId(user_id);
|
|
349
637
|
}
|
|
350
638
|
if (typeof location_id !== 'undefined') {
|
|
351
639
|
this.updateLocationId(location_id);
|
|
352
640
|
}
|
|
641
|
+
if (typeof addresses_id !== 'undefined') {
|
|
642
|
+
this.updateAddressesId(addresses_id);
|
|
643
|
+
}
|
|
644
|
+
if (typeof shipping_id !== 'undefined') {
|
|
645
|
+
this.updateShippingId(shipping_id);
|
|
646
|
+
}
|
|
353
647
|
}
|
|
354
648
|
setStorageKey() {
|
|
355
649
|
if (typeof this.config.session_storage_key === 'string' &&
|
|
@@ -391,54 +685,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.4", ngImpor
|
|
|
391
685
|
}]
|
|
392
686
|
}], ctorParameters: function () { return []; } });
|
|
393
687
|
|
|
394
|
-
class EsolveResult {
|
|
395
|
-
constructor(status, code, message) {
|
|
396
|
-
this.status = status;
|
|
397
|
-
this.code = code;
|
|
398
|
-
this.message = message;
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
class EsolveResponseResult {
|
|
403
|
-
constructor(response) {
|
|
404
|
-
this.success_log = [];
|
|
405
|
-
this.error_log = [];
|
|
406
|
-
this.error_log.push(...response.log.filter((log_item) => log_item.type === 'error'));
|
|
407
|
-
this.success_log.push(...response.log.filter((log_item) => log_item.type === 'success'));
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
class EsolveResponseHandlerService {
|
|
412
|
-
/**
|
|
413
|
-
* Parse single HTTP response
|
|
414
|
-
*
|
|
415
|
-
* @param http_response HTTP Response to eSolve service
|
|
416
|
-
* @param resultHandler Function to parse response to a result
|
|
417
|
-
*
|
|
418
|
-
* @returns Parsed result of response
|
|
419
|
-
*/
|
|
420
|
-
validateSingleHttpResponse(http_response, resultHandler) {
|
|
421
|
-
if (http_response.responses === undefined ||
|
|
422
|
-
http_response.responses.length <= 0) {
|
|
423
|
-
throw http_response;
|
|
424
|
-
}
|
|
425
|
-
const response = http_response.responses[0];
|
|
426
|
-
if (response.status.state === 'error' ||
|
|
427
|
-
response.status.state === 'none') {
|
|
428
|
-
throw response;
|
|
429
|
-
}
|
|
430
|
-
return resultHandler(response);
|
|
431
|
-
}
|
|
432
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.4", ngImport: i0, type: EsolveResponseHandlerService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
433
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.4", ngImport: i0, type: EsolveResponseHandlerService, providedIn: 'root' }); }
|
|
434
|
-
}
|
|
435
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.4", ngImport: i0, type: EsolveResponseHandlerService, decorators: [{
|
|
436
|
-
type: Injectable,
|
|
437
|
-
args: [{
|
|
438
|
-
providedIn: 'root',
|
|
439
|
-
}]
|
|
440
|
-
}] });
|
|
441
|
-
|
|
442
688
|
class EsolveSessionMetadataService {
|
|
443
689
|
constructor() {
|
|
444
690
|
this.config = inject(EsolveConfigService);
|
|
@@ -513,11 +759,7 @@ class EsolveAuthService {
|
|
|
513
759
|
.pipe(switchMap$1(() => this.checkAccessToken()), catchError(() => of(null)))
|
|
514
760
|
.subscribe((result) => {
|
|
515
761
|
if (result) {
|
|
516
|
-
this.
|
|
517
|
-
token: result.key,
|
|
518
|
-
user_id: result.user_id,
|
|
519
|
-
location_id: result.location_id,
|
|
520
|
-
}, result.expiry_time, result.grace_period);
|
|
762
|
+
this.handleAuthentication(result);
|
|
521
763
|
}
|
|
522
764
|
else {
|
|
523
765
|
this.session.expireSession();
|
|
@@ -609,6 +851,8 @@ class EsolveAuthService {
|
|
|
609
851
|
key: result.key,
|
|
610
852
|
user_id: result.user_id,
|
|
611
853
|
location_id: result.location_id,
|
|
854
|
+
addresses_id: result.addresses_id,
|
|
855
|
+
shipping_id: result.shipping_id,
|
|
612
856
|
expires: result.expires,
|
|
613
857
|
expiry_time: result.expiry_time,
|
|
614
858
|
grace_period: result.grace_period,
|
|
@@ -671,6 +915,8 @@ class EsolveAuthService {
|
|
|
671
915
|
grace_period: +additional_data.grace_period,
|
|
672
916
|
location_id: +additional_data.location_id,
|
|
673
917
|
user_id: +additional_data.user_id,
|
|
918
|
+
addresses_id: +additional_data.addresses_id,
|
|
919
|
+
shipping_id: +additional_data.shipping_id,
|
|
674
920
|
};
|
|
675
921
|
return result;
|
|
676
922
|
}
|
|
@@ -697,6 +943,8 @@ class EsolveAuthService {
|
|
|
697
943
|
token: result.key,
|
|
698
944
|
user_id: +result.user_id,
|
|
699
945
|
location_id: +result.location_id,
|
|
946
|
+
addresses_id: +result.addresses_id,
|
|
947
|
+
shipping_id: +result.shipping_id,
|
|
700
948
|
}, +result.expiry_time, +result.grace_period);
|
|
701
949
|
}
|
|
702
950
|
handleError(errorRes) {
|
|
@@ -941,220 +1189,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.4", ngImpor
|
|
|
941
1189
|
args: ['error']
|
|
942
1190
|
}] } });
|
|
943
1191
|
|
|
944
|
-
class EsolveMultipleSelectFilter {
|
|
945
|
-
constructor(field, options) {
|
|
946
|
-
this.field = field;
|
|
947
|
-
this.type = 'multiple';
|
|
948
|
-
this.options = [];
|
|
949
|
-
if (options) {
|
|
950
|
-
this.options = options;
|
|
951
|
-
}
|
|
952
|
-
}
|
|
953
|
-
setValue(values) {
|
|
954
|
-
this.values = values;
|
|
955
|
-
}
|
|
956
|
-
toHttpParams(http_params) {
|
|
957
|
-
if (!this.values) {
|
|
958
|
-
throw new Error('No values set');
|
|
959
|
-
}
|
|
960
|
-
const base_property = `filter[${this.field}]`;
|
|
961
|
-
const type_property = base_property + '[type]';
|
|
962
|
-
const values_property = base_property + '[values][]';
|
|
963
|
-
const params = {
|
|
964
|
-
[type_property]: this.type,
|
|
965
|
-
[values_property]: this.values,
|
|
966
|
-
};
|
|
967
|
-
if (http_params) {
|
|
968
|
-
return http_params.appendAll(params);
|
|
969
|
-
}
|
|
970
|
-
return params;
|
|
971
|
-
}
|
|
972
|
-
}
|
|
973
|
-
|
|
974
|
-
class EsolveRangeFilter {
|
|
975
|
-
constructor(field, min = 0, max = 0) {
|
|
976
|
-
this.field = field;
|
|
977
|
-
this.type = 'range';
|
|
978
|
-
this.min = 0;
|
|
979
|
-
this.max = 0;
|
|
980
|
-
this.options = {
|
|
981
|
-
min: 0,
|
|
982
|
-
max: 0,
|
|
983
|
-
};
|
|
984
|
-
this.options.min = min;
|
|
985
|
-
this.options.max = max;
|
|
986
|
-
if (max > 0 && min > max) {
|
|
987
|
-
this.options.min = max;
|
|
988
|
-
this.options.max = min;
|
|
989
|
-
}
|
|
990
|
-
}
|
|
991
|
-
setValue(min, max) {
|
|
992
|
-
this.min = min;
|
|
993
|
-
this.max = max;
|
|
994
|
-
if (max > 0 && min > max) {
|
|
995
|
-
this.min = max;
|
|
996
|
-
this.max = min;
|
|
997
|
-
}
|
|
998
|
-
}
|
|
999
|
-
toHttpParams(http_params) {
|
|
1000
|
-
if (this.min <= 0 && this.max <= 0) {
|
|
1001
|
-
throw new Error('No values set');
|
|
1002
|
-
}
|
|
1003
|
-
const base_property = `filter[${this.field}]`;
|
|
1004
|
-
const type_property = base_property + '[type]';
|
|
1005
|
-
const min_property = base_property + '[min]';
|
|
1006
|
-
const max_property = base_property + '[max]';
|
|
1007
|
-
const params = {
|
|
1008
|
-
[type_property]: this.type,
|
|
1009
|
-
[min_property]: this.min,
|
|
1010
|
-
[max_property]: this.max,
|
|
1011
|
-
};
|
|
1012
|
-
if (http_params) {
|
|
1013
|
-
return http_params.appendAll(params);
|
|
1014
|
-
}
|
|
1015
|
-
return params;
|
|
1016
|
-
}
|
|
1017
|
-
}
|
|
1018
|
-
|
|
1019
|
-
class EsolveSingleSelectFilter {
|
|
1020
|
-
constructor(field, options_or_value) {
|
|
1021
|
-
this.field = field;
|
|
1022
|
-
this.type = 'single';
|
|
1023
|
-
this.options = [];
|
|
1024
|
-
if (Array.isArray(options_or_value)) {
|
|
1025
|
-
this.options = options_or_value;
|
|
1026
|
-
}
|
|
1027
|
-
else {
|
|
1028
|
-
this.setValue(options_or_value);
|
|
1029
|
-
}
|
|
1030
|
-
}
|
|
1031
|
-
setValue(value) {
|
|
1032
|
-
this.value = value;
|
|
1033
|
-
}
|
|
1034
|
-
toHttpParams(http_params) {
|
|
1035
|
-
if (!this.value) {
|
|
1036
|
-
throw new Error('No values set');
|
|
1037
|
-
}
|
|
1038
|
-
const base_property = `filter[${this.field}]`;
|
|
1039
|
-
const type_property = base_property + '[type]';
|
|
1040
|
-
const values_property = base_property + '[value]';
|
|
1041
|
-
const params = {
|
|
1042
|
-
[type_property]: this.type,
|
|
1043
|
-
[values_property]: this.value,
|
|
1044
|
-
};
|
|
1045
|
-
if (http_params) {
|
|
1046
|
-
return http_params.appendAll(params);
|
|
1047
|
-
}
|
|
1048
|
-
return params;
|
|
1049
|
-
}
|
|
1050
|
-
}
|
|
1051
|
-
|
|
1052
|
-
class EsolveToggleFilter {
|
|
1053
|
-
constructor(field, value) {
|
|
1054
|
-
this.field = field;
|
|
1055
|
-
this.value = value;
|
|
1056
|
-
this.type = 'toggle';
|
|
1057
|
-
}
|
|
1058
|
-
toHttpParams(http_params) {
|
|
1059
|
-
const base_property = `filter[${this.field}]`;
|
|
1060
|
-
const type_property = base_property + '[type]';
|
|
1061
|
-
const values_property = base_property + '[value]';
|
|
1062
|
-
const params = {
|
|
1063
|
-
[type_property]: this.type,
|
|
1064
|
-
[values_property]: this.value ? 1 : 0,
|
|
1065
|
-
};
|
|
1066
|
-
if (http_params) {
|
|
1067
|
-
return http_params.appendAll(params);
|
|
1068
|
-
}
|
|
1069
|
-
return params;
|
|
1070
|
-
}
|
|
1071
|
-
}
|
|
1072
|
-
|
|
1073
|
-
// Classes
|
|
1074
|
-
|
|
1075
|
-
// Interfaces
|
|
1076
|
-
|
|
1077
|
-
// Types
|
|
1078
|
-
|
|
1079
|
-
function createRangeWithValue(field, min = 0, max = 0) {
|
|
1080
|
-
const filter = new EsolveRangeFilter(field);
|
|
1081
|
-
filter.setValue(min, max);
|
|
1082
|
-
return filter;
|
|
1083
|
-
}
|
|
1084
|
-
function createSingleSelectWithValue(field, value) {
|
|
1085
|
-
const filter = new EsolveSingleSelectFilter(field, value);
|
|
1086
|
-
return filter;
|
|
1087
|
-
}
|
|
1088
|
-
function createToggleSelectWithValue(field, value) {
|
|
1089
|
-
const filter = new EsolveToggleFilter(field, value);
|
|
1090
|
-
return filter;
|
|
1091
|
-
}
|
|
1092
|
-
function createMultipleSelectWithValue(field, value) {
|
|
1093
|
-
const filter = new EsolveMultipleSelectFilter(field);
|
|
1094
|
-
filter.setValue(value);
|
|
1095
|
-
return filter;
|
|
1096
|
-
}
|
|
1097
|
-
function covertFromObj(obj) {
|
|
1098
|
-
const filters = [];
|
|
1099
|
-
for (const field in obj) {
|
|
1100
|
-
const value = obj[field];
|
|
1101
|
-
let filter = null;
|
|
1102
|
-
if (Array.isArray(value)) {
|
|
1103
|
-
filter = createMultipleSelectWithValue(field, value);
|
|
1104
|
-
}
|
|
1105
|
-
else if (typeof value === 'object') {
|
|
1106
|
-
filter = createRangeWithValue(field, value.min, value.max);
|
|
1107
|
-
}
|
|
1108
|
-
else if (typeof value === 'boolean') {
|
|
1109
|
-
filter = createToggleSelectWithValue(field, value);
|
|
1110
|
-
}
|
|
1111
|
-
else {
|
|
1112
|
-
filter = createSingleSelectWithValue(field, value);
|
|
1113
|
-
}
|
|
1114
|
-
if (filter) {
|
|
1115
|
-
filters.push(filter);
|
|
1116
|
-
}
|
|
1117
|
-
}
|
|
1118
|
-
return filters;
|
|
1119
|
-
}
|
|
1120
|
-
function convertToHttpParams(filters, http_params) {
|
|
1121
|
-
if (http_params) {
|
|
1122
|
-
for (const filter of filters) {
|
|
1123
|
-
http_params = filter.toHttpParams(http_params);
|
|
1124
|
-
}
|
|
1125
|
-
return http_params;
|
|
1126
|
-
}
|
|
1127
|
-
let params = {};
|
|
1128
|
-
for (const filter of filters) {
|
|
1129
|
-
params = {
|
|
1130
|
-
...params,
|
|
1131
|
-
...filter.toHttpParams(),
|
|
1132
|
-
};
|
|
1133
|
-
}
|
|
1134
|
-
return params;
|
|
1135
|
-
}
|
|
1136
|
-
|
|
1137
|
-
var esolveFilterFactory = /*#__PURE__*/Object.freeze({
|
|
1138
|
-
__proto__: null,
|
|
1139
|
-
convertToHttpParams: convertToHttpParams,
|
|
1140
|
-
covertFromObj: covertFromObj,
|
|
1141
|
-
createMultipleSelectWithValue: createMultipleSelectWithValue,
|
|
1142
|
-
createRangeWithValue: createRangeWithValue,
|
|
1143
|
-
createSingleSelectWithValue: createSingleSelectWithValue,
|
|
1144
|
-
createToggleSelectWithValue: createToggleSelectWithValue
|
|
1145
|
-
});
|
|
1146
|
-
|
|
1147
|
-
// Types
|
|
1148
|
-
|
|
1149
|
-
class EsolveList {
|
|
1150
|
-
constructor(items = [], page = 0, rows = 0, total = 0) {
|
|
1151
|
-
this.items = items;
|
|
1152
|
-
this.page = page;
|
|
1153
|
-
this.rows = rows;
|
|
1154
|
-
this.total = total;
|
|
1155
|
-
}
|
|
1156
|
-
}
|
|
1157
|
-
|
|
1158
1192
|
/**
|
|
1159
1193
|
* Search Engine Optimization information.
|
|
1160
1194
|
*/
|
|
@@ -2217,6 +2251,16 @@ class EsolveAddress {
|
|
|
2217
2251
|
}
|
|
2218
2252
|
}
|
|
2219
2253
|
|
|
2254
|
+
class EsolveSessionAddressUpdateResult extends EsolveResponseResult {
|
|
2255
|
+
constructor(response) {
|
|
2256
|
+
super(response);
|
|
2257
|
+
if (typeof response.esolve_id === 'string') {
|
|
2258
|
+
throw new Error('Invalid response id.');
|
|
2259
|
+
}
|
|
2260
|
+
this.address_updated = response.esolve_id > 0;
|
|
2261
|
+
}
|
|
2262
|
+
}
|
|
2263
|
+
|
|
2220
2264
|
class EsolveUserAccountBusiness {
|
|
2221
2265
|
constructor(record) {
|
|
2222
2266
|
if (record) {
|
|
@@ -2423,61 +2467,163 @@ class EsolveLocationUpdateResult extends EsolveResponseResult {
|
|
|
2423
2467
|
}
|
|
2424
2468
|
}
|
|
2425
2469
|
|
|
2426
|
-
class
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
this.
|
|
2433
|
-
this.
|
|
2434
|
-
this.
|
|
2435
|
-
this.province = province;
|
|
2436
|
-
this.country = country;
|
|
2437
|
-
this.postal_code = postal_code;
|
|
2438
|
-
this.pobox = pobox;
|
|
2470
|
+
class EsolveEmptyCartResult extends EsolveResponseResult {
|
|
2471
|
+
}
|
|
2472
|
+
|
|
2473
|
+
class EsolveCheckoutResult extends EsolveResponseResult {
|
|
2474
|
+
constructor(response) {
|
|
2475
|
+
super(response);
|
|
2476
|
+
this.id = 0;
|
|
2477
|
+
this.id = +response.esolve_id;
|
|
2478
|
+
this.process_payment = response.process_payment ?? false;
|
|
2439
2479
|
}
|
|
2440
2480
|
}
|
|
2441
2481
|
|
|
2442
|
-
class
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
this.
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2482
|
+
class EsolveCartStockItem {
|
|
2483
|
+
/**
|
|
2484
|
+
* Path to tiny stock image
|
|
2485
|
+
*/
|
|
2486
|
+
get tiny_image_src() {
|
|
2487
|
+
return this.getImagePath('tiny');
|
|
2488
|
+
}
|
|
2489
|
+
/**
|
|
2490
|
+
* Path to thumbnail stock image
|
|
2491
|
+
*/
|
|
2492
|
+
get thumbnail_image_src() {
|
|
2493
|
+
return this.getImagePath('thumb');
|
|
2494
|
+
}
|
|
2495
|
+
/**
|
|
2496
|
+
* Path to small stock image
|
|
2497
|
+
*/
|
|
2498
|
+
get small_image_src() {
|
|
2499
|
+
return this.getImagePath('small');
|
|
2500
|
+
}
|
|
2501
|
+
/**
|
|
2502
|
+
* Path to big stock image
|
|
2503
|
+
*/
|
|
2504
|
+
get big_image_src() {
|
|
2505
|
+
return this.getImagePath('big');
|
|
2506
|
+
}
|
|
2507
|
+
/**
|
|
2508
|
+
* Path to original stock image
|
|
2509
|
+
*/
|
|
2510
|
+
get original_image_src() {
|
|
2511
|
+
return this.getImagePath('original');
|
|
2512
|
+
}
|
|
2513
|
+
constructor(record) {
|
|
2514
|
+
this.code = record.code ?? '';
|
|
2515
|
+
this.name = record.name ?? '';
|
|
2516
|
+
this.sef_name = record.sef_name ?? '';
|
|
2517
|
+
this.description = record.description ?? '';
|
|
2518
|
+
this.delivery_category = record.delivery_category ?? '';
|
|
2519
|
+
this.image_name = record.image_name ?? '';
|
|
2520
|
+
this.pack_description = record.pack_description ?? '';
|
|
2521
|
+
this.pack_size = +(record.items_in_pack ?? 0);
|
|
2522
|
+
this.onhand = +(record.onhand ?? 0);
|
|
2523
|
+
this.active = record.is_active ?? false;
|
|
2524
|
+
}
|
|
2525
|
+
getImagePath(image_size) {
|
|
2526
|
+
if (this.image_name !== '') {
|
|
2527
|
+
return `/images/stock/${image_size}/${this.image_name}`;
|
|
2528
|
+
}
|
|
2529
|
+
return '';
|
|
2452
2530
|
}
|
|
2453
2531
|
}
|
|
2454
2532
|
|
|
2455
|
-
class
|
|
2533
|
+
class EsolveCartItem {
|
|
2534
|
+
constructor(record) {
|
|
2535
|
+
this.delivery_category = record.delivery_category ?? '';
|
|
2536
|
+
this.type = record.type ?? '';
|
|
2537
|
+
this.id = +(record.id ?? 0);
|
|
2538
|
+
this.qty = +(record.qty ?? 0);
|
|
2539
|
+
this.price = +(record.price ?? 0);
|
|
2540
|
+
this.discount = +(record.discount ?? 0);
|
|
2541
|
+
this.discount_interval = +(record.discount_interval ?? 0);
|
|
2542
|
+
this.vat_rate = +(record.vat_rate ?? 0);
|
|
2543
|
+
this.price_incl = +(record.price_incl ?? 0);
|
|
2544
|
+
this.discount_price = +(record.discount_price ?? 0);
|
|
2545
|
+
this.discount_price_incl = +(record.discount_price_incl ?? 0);
|
|
2546
|
+
this.discount_total = +(record.discount_total ?? 0);
|
|
2547
|
+
this.vat_total = +(record.vat_total ?? 0);
|
|
2548
|
+
this.total = +(record.line_total ?? 0);
|
|
2549
|
+
this.total_incl = +(record.line_total_incl ?? 0);
|
|
2550
|
+
this.allow_quotes = record.allow_quotes ?? false;
|
|
2551
|
+
this.allow_orders = record.allow_orders ?? false;
|
|
2552
|
+
this.must_collect = record.must_collect ?? false;
|
|
2553
|
+
this.requested_assembly = record.requested_assembly ?? false;
|
|
2554
|
+
this.is_dependency = record.is_dependency ?? false;
|
|
2555
|
+
this.stock_item = new EsolveCartStockItem(record);
|
|
2556
|
+
}
|
|
2557
|
+
}
|
|
2558
|
+
|
|
2559
|
+
/**
|
|
2560
|
+
* Totals in cart
|
|
2561
|
+
*/
|
|
2562
|
+
class EsolveCartTotals {
|
|
2563
|
+
/**
|
|
2564
|
+
* Grand total of cart which includes discount and VAT
|
|
2565
|
+
* (NOTE: shipping and insurance is not included)
|
|
2566
|
+
*/
|
|
2567
|
+
get total() {
|
|
2568
|
+
return (this.sub_total +
|
|
2569
|
+
this.vat_total -
|
|
2570
|
+
this.discount_total -
|
|
2571
|
+
this.voucher_total);
|
|
2572
|
+
}
|
|
2456
2573
|
constructor(
|
|
2457
2574
|
/**
|
|
2458
|
-
*
|
|
2575
|
+
* Number of unique records in cart
|
|
2459
2576
|
*/
|
|
2460
|
-
|
|
2577
|
+
records = 0,
|
|
2461
2578
|
/**
|
|
2462
|
-
*
|
|
2579
|
+
* Total quantity of all items in a cart
|
|
2463
2580
|
*/
|
|
2464
|
-
|
|
2581
|
+
items = 0,
|
|
2465
2582
|
/**
|
|
2466
|
-
*
|
|
2583
|
+
* Total in cart before discount and VAT is added
|
|
2467
2584
|
*/
|
|
2468
|
-
|
|
2585
|
+
sub_total = 0,
|
|
2469
2586
|
/**
|
|
2470
|
-
*
|
|
2587
|
+
* Total VAT of all the items in the cart
|
|
2471
2588
|
*/
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2589
|
+
vat_total = 0,
|
|
2590
|
+
/**
|
|
2591
|
+
* Total discount of all the item in the cart
|
|
2592
|
+
*/
|
|
2593
|
+
discount_total = 0,
|
|
2594
|
+
/**
|
|
2595
|
+
* Total of all vouchers used
|
|
2596
|
+
*/
|
|
2597
|
+
voucher_total = 0,
|
|
2598
|
+
/**
|
|
2599
|
+
* Total of allowance
|
|
2600
|
+
*/
|
|
2601
|
+
allowance = 0) {
|
|
2602
|
+
this.records = records;
|
|
2603
|
+
this.items = items;
|
|
2604
|
+
this.sub_total = sub_total;
|
|
2605
|
+
this.vat_total = vat_total;
|
|
2606
|
+
this.discount_total = discount_total;
|
|
2607
|
+
this.voucher_total = voucher_total;
|
|
2608
|
+
this.allowance = allowance;
|
|
2477
2609
|
}
|
|
2478
2610
|
}
|
|
2479
2611
|
|
|
2480
|
-
class
|
|
2612
|
+
class EsolveTransactionAnalyticsData {
|
|
2613
|
+
constructor(record) {
|
|
2614
|
+
this.transaction_id = 0;
|
|
2615
|
+
this.transaction_type = 'order';
|
|
2616
|
+
if (record) {
|
|
2617
|
+
this.transaction_id = +(record.transaction_id ?? 0);
|
|
2618
|
+
this.transaction_type = record.transaction_type ?? 'order';
|
|
2619
|
+
if (record.analytics_data) {
|
|
2620
|
+
this.analytics_data = record.analytics_data;
|
|
2621
|
+
}
|
|
2622
|
+
}
|
|
2623
|
+
}
|
|
2624
|
+
}
|
|
2625
|
+
|
|
2626
|
+
class EsolveCartAlternative {
|
|
2481
2627
|
/**
|
|
2482
2628
|
* Path to tiny stock image
|
|
2483
2629
|
*/
|
|
@@ -2509,641 +2655,322 @@ class EsolveTransactionItem {
|
|
|
2509
2655
|
return this.getImagePath('original');
|
|
2510
2656
|
}
|
|
2511
2657
|
constructor(record) {
|
|
2512
|
-
this.
|
|
2658
|
+
this.item_id = 0;
|
|
2513
2659
|
this.code = '';
|
|
2514
2660
|
this.name = '';
|
|
2515
2661
|
this.sef_name = '';
|
|
2516
|
-
this.
|
|
2517
|
-
this.image_last_modified = '';
|
|
2662
|
+
this.items_in_pack = 0;
|
|
2518
2663
|
this.pack_description = '';
|
|
2519
|
-
this.
|
|
2520
|
-
this.
|
|
2521
|
-
this.discount = 0;
|
|
2664
|
+
this.price = 0;
|
|
2665
|
+
this.price_inclusive = 0;
|
|
2522
2666
|
this.vat_rate = 0;
|
|
2667
|
+
this.image_name = '';
|
|
2523
2668
|
if (record) {
|
|
2524
|
-
this.
|
|
2669
|
+
this.item_id = record.item_id ?? 0;
|
|
2670
|
+
this.image_name = record.image_name ?? '';
|
|
2525
2671
|
this.code = record.code ?? '';
|
|
2526
2672
|
this.name = record.name ?? '';
|
|
2527
2673
|
this.sef_name = record.sef_name ?? '';
|
|
2528
|
-
this.
|
|
2529
|
-
this.image_last_modified = record.image_last_modified ?? '';
|
|
2674
|
+
this.items_in_pack = +(record.items_in_pack ?? 0);
|
|
2530
2675
|
this.pack_description = record.pack_description ?? '';
|
|
2531
|
-
this.
|
|
2532
|
-
this.
|
|
2533
|
-
this.discount = +(record.discount ?? 0);
|
|
2676
|
+
this.price = +(record.price ?? 0);
|
|
2677
|
+
this.price_inclusive = +(record.price_inclusive ?? 0);
|
|
2534
2678
|
this.vat_rate = +(record.vat_rate ?? 0);
|
|
2535
|
-
this.price = new EsolveTransactionItemPrice(+(record.price_exclusive ?? 0), +(record.price_inclusive ?? 0), +(record.price_exclusive_after_discount ?? 0), +(record.price_inclusive_after_discount ?? 0));
|
|
2536
|
-
this.line_total = new EsolveTransactionItemPrice(+(record.line_total_exclusive ?? 0), +(record.line_total_inclusive ?? 0), +(record.line_total_exclusive_after_discount ?? 0), +(record.line_total_inclusive_after_discount ?? 0));
|
|
2537
|
-
}
|
|
2538
|
-
else {
|
|
2539
|
-
this.price = new EsolveTransactionItemPrice(0, 0, 0, 0);
|
|
2540
|
-
this.line_total = new EsolveTransactionItemPrice(0, 0, 0, 0);
|
|
2541
2679
|
}
|
|
2542
2680
|
}
|
|
2543
2681
|
getImagePath(image_size) {
|
|
2544
2682
|
if (this.image_name !== '') {
|
|
2545
|
-
|
|
2546
|
-
if (this.image_last_modified !== '') {
|
|
2547
|
-
param = `?t=${this.image_last_modified}`;
|
|
2548
|
-
}
|
|
2549
|
-
return `/images/stock/${image_size}/${this.image_name}${param}`;
|
|
2683
|
+
return `/images/stock/${image_size}/${this.image_name}`;
|
|
2550
2684
|
}
|
|
2551
2685
|
return '';
|
|
2552
2686
|
}
|
|
2553
2687
|
}
|
|
2554
2688
|
|
|
2555
|
-
class
|
|
2689
|
+
class EsolveCoupon {
|
|
2690
|
+
constructor(record) {
|
|
2691
|
+
this.id = 0;
|
|
2692
|
+
this.identifier = '';
|
|
2693
|
+
this.discount = 0;
|
|
2694
|
+
/**
|
|
2695
|
+
* Shows either the short code or the coupon key (if short code is not set)
|
|
2696
|
+
*/
|
|
2697
|
+
this.coupon_code = '';
|
|
2698
|
+
/**
|
|
2699
|
+
* Limit of the number of items it can apply to
|
|
2700
|
+
*/
|
|
2701
|
+
this.apply_on = 0;
|
|
2702
|
+
/**
|
|
2703
|
+
* Indicates if the discount does not apply to specified products, meaning
|
|
2704
|
+
* all items get the discount
|
|
2705
|
+
*/
|
|
2706
|
+
this.apply_to_full_cart = false;
|
|
2707
|
+
if (record) {
|
|
2708
|
+
this.id = +record.id;
|
|
2709
|
+
this.identifier = record.identifier;
|
|
2710
|
+
this.discount = +record.discount;
|
|
2711
|
+
this.coupon_code = record.coupon_code;
|
|
2712
|
+
this.apply_on = +record.apply_on;
|
|
2713
|
+
this.apply_to_full_cart = record.apply_to_full_cart;
|
|
2714
|
+
}
|
|
2715
|
+
}
|
|
2556
2716
|
}
|
|
2557
2717
|
|
|
2558
|
-
class
|
|
2559
|
-
constructor(street, suburb, city, province, country, postal_code, latitude, longitude) {
|
|
2560
|
-
this.street = street;
|
|
2561
|
-
this.suburb = suburb;
|
|
2562
|
-
this.city = city;
|
|
2563
|
-
this.province = province;
|
|
2564
|
-
this.country = country;
|
|
2565
|
-
this.postal_code = postal_code;
|
|
2566
|
-
this.latitude = latitude;
|
|
2567
|
-
this.longitude = longitude;
|
|
2568
|
-
}
|
|
2569
|
-
}
|
|
2570
|
-
|
|
2571
|
-
class EsolveLocationContactInfo {
|
|
2572
|
-
constructor(telnumber, cellnumber, email, fax) {
|
|
2573
|
-
this.telnumber = telnumber;
|
|
2574
|
-
this.cellnumber = cellnumber;
|
|
2575
|
-
this.email = email;
|
|
2576
|
-
this.fax = fax;
|
|
2577
|
-
}
|
|
2578
|
-
}
|
|
2579
|
-
|
|
2580
|
-
class EsolveLocationGEO {
|
|
2581
|
-
constructor(distance, range, target_description) {
|
|
2582
|
-
this.distance = distance;
|
|
2583
|
-
this.range = range;
|
|
2584
|
-
this.target_description = target_description;
|
|
2585
|
-
}
|
|
2586
|
-
}
|
|
2587
|
-
|
|
2588
|
-
class EsolveLocationPOBoxAddress {
|
|
2589
|
-
constructor(pobox, city, postal_code) {
|
|
2590
|
-
this.pobox = pobox;
|
|
2591
|
-
this.city = city;
|
|
2592
|
-
this.postal_code = postal_code;
|
|
2593
|
-
}
|
|
2594
|
-
}
|
|
2595
|
-
|
|
2596
|
-
class EsolveLocationTradingDay {
|
|
2597
|
-
constructor(open, close) {
|
|
2598
|
-
this.open = open;
|
|
2599
|
-
this.close = close;
|
|
2600
|
-
}
|
|
2601
|
-
}
|
|
2602
|
-
|
|
2603
|
-
class EsolveLocationTradingTimes {
|
|
2604
|
-
constructor(monday, tuesday, wednesday, thursday, friday, saturday, sunday, public_holiday, trading_hours_additional_info = '') {
|
|
2605
|
-
this.monday = monday;
|
|
2606
|
-
this.tuesday = tuesday;
|
|
2607
|
-
this.wednesday = wednesday;
|
|
2608
|
-
this.thursday = thursday;
|
|
2609
|
-
this.friday = friday;
|
|
2610
|
-
this.saturday = saturday;
|
|
2611
|
-
this.sunday = sunday;
|
|
2612
|
-
this.public_holiday = public_holiday;
|
|
2613
|
-
this.trading_hours_additional_info = trading_hours_additional_info;
|
|
2614
|
-
}
|
|
2615
|
-
}
|
|
2616
|
-
|
|
2617
|
-
class EsolveLocation {
|
|
2618
|
-
constructor(record) {
|
|
2619
|
-
this.id = +record.id;
|
|
2620
|
-
this.identifier = record.identifier;
|
|
2621
|
-
this.description = record.description;
|
|
2622
|
-
this.head_office = !!+record.head_office;
|
|
2623
|
-
this.erp_identifier = record.erp_identifier;
|
|
2624
|
-
this.external_system_code = record.external_system_code;
|
|
2625
|
-
this.default_location_for_payment_methods =
|
|
2626
|
-
!!+record.default_location_for_payment_methods;
|
|
2627
|
-
this.userid = +record.userid;
|
|
2628
|
-
this.importance = +record.importance;
|
|
2629
|
-
this.active = !!+record.is_active;
|
|
2630
|
-
this.dispatches_stock = !!+record.dispatches_stock;
|
|
2631
|
-
this.include_on_enquiries = !!+record.include_on_enquiries;
|
|
2632
|
-
this.include_on_store_locator = !!+record.include_on_store_locator;
|
|
2633
|
-
this.website_url = record.website_url;
|
|
2634
|
-
this.address = new EsolveLocationAddress(record.street, record.suburb, record.city, record.province, record.country, record.postal_code, +record.latitude, +record.longitude);
|
|
2635
|
-
this.pobox_address = new EsolveLocationPOBoxAddress(record.pobox, record.pobox_city, record.pobox_postal_code);
|
|
2636
|
-
const telnumbers = [];
|
|
2637
|
-
if (record.branch_telnumber.length > 0) {
|
|
2638
|
-
telnumbers.push(record.branch_telnumber);
|
|
2639
|
-
}
|
|
2640
|
-
if (record.branch_telnumber_2.length > 0) {
|
|
2641
|
-
telnumbers.push(record.branch_telnumber_2);
|
|
2642
|
-
}
|
|
2643
|
-
if (record.branch_telnumber_3.length > 0) {
|
|
2644
|
-
telnumbers.push(record.branch_telnumber_3);
|
|
2645
|
-
}
|
|
2646
|
-
this.contact_info = new EsolveLocationContactInfo(telnumbers, record.branch_cellnumber, record.branch_email, record.branch_fax);
|
|
2647
|
-
const monday = new EsolveLocationTradingDay(record.monday_open_time, record.monday_close_time);
|
|
2648
|
-
const tuesday = new EsolveLocationTradingDay(record.tuesday_open_time, record.tuesday_close_time);
|
|
2649
|
-
const wednesday = new EsolveLocationTradingDay(record.wednesday_open_time, record.wednesday_close_time);
|
|
2650
|
-
const thursday = new EsolveLocationTradingDay(record.thursday_open_time, record.thursday_close_time);
|
|
2651
|
-
const friday = new EsolveLocationTradingDay(record.friday_open_time, record.friday_close_time);
|
|
2652
|
-
const saturday = new EsolveLocationTradingDay(record.saturday_open_time, record.saturday_close_time);
|
|
2653
|
-
const sunday = new EsolveLocationTradingDay(record.sunday_open_time, record.sunday_close_time);
|
|
2654
|
-
const public_holiday = new EsolveLocationTradingDay(record.public_holiday_open_time, record.public_holiday_close_time);
|
|
2655
|
-
this.trading_times = new EsolveLocationTradingTimes(monday, tuesday, wednesday, thursday, friday, saturday, sunday, public_holiday, record.trading_hours_additional_info);
|
|
2656
|
-
this.geo = new EsolveLocationGEO(record.distance, record.range, record.target_description);
|
|
2657
|
-
if (record.custom_fields) {
|
|
2658
|
-
this.custom_fields = record.custom_fields;
|
|
2659
|
-
}
|
|
2660
|
-
}
|
|
2661
|
-
}
|
|
2662
|
-
|
|
2663
|
-
/**
|
|
2664
|
-
* Location object list
|
|
2665
|
-
*/
|
|
2666
|
-
class EsolveLocationList {
|
|
2667
|
-
constructor(locations, total, page) {
|
|
2668
|
-
this.locations = locations;
|
|
2669
|
-
this.total = total;
|
|
2670
|
-
this.page = page;
|
|
2671
|
-
}
|
|
2672
|
-
}
|
|
2673
|
-
|
|
2674
|
-
// Classes
|
|
2675
|
-
|
|
2676
|
-
// Types
|
|
2677
|
-
|
|
2678
|
-
class EsolveLocationsService {
|
|
2718
|
+
class EsolveCouponsService {
|
|
2679
2719
|
constructor() {
|
|
2680
|
-
this.
|
|
2720
|
+
this.is_browser = isPlatformBrowser(inject(PLATFORM_ID));
|
|
2681
2721
|
this.http = inject(HttpClient);
|
|
2722
|
+
this.config = inject(EsolveConfigService);
|
|
2723
|
+
this.cookieService = inject(EsolveCookieService);
|
|
2724
|
+
this.storage_key = '_ng_eslv_coupons';
|
|
2725
|
+
this.cache = new Map();
|
|
2726
|
+
this.applied = new BehaviorSubject(undefined);
|
|
2727
|
+
this.validation_error = new Subject();
|
|
2728
|
+
this.setStorageKey();
|
|
2729
|
+
this.cache = this.retrieveCache();
|
|
2682
2730
|
}
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
if (
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
params = params.set('sort', sort.field);
|
|
2701
|
-
}
|
|
2702
|
-
if (sort.order) {
|
|
2703
|
-
params = params.set('order', sort.order);
|
|
2704
|
-
}
|
|
2705
|
-
}
|
|
2706
|
-
if (options.search_phrase) {
|
|
2707
|
-
params = params.set('search_phrase', options.search_phrase);
|
|
2708
|
-
}
|
|
2709
|
-
if (options.is_active) {
|
|
2710
|
-
params = params.set('is_active', options.is_active);
|
|
2731
|
+
onValidationError() {
|
|
2732
|
+
return this.validation_error.asObservable();
|
|
2733
|
+
}
|
|
2734
|
+
onApplied() {
|
|
2735
|
+
return this.applied.asObservable();
|
|
2736
|
+
}
|
|
2737
|
+
validate(coupon_key) {
|
|
2738
|
+
return this.http
|
|
2739
|
+
.get(`${this.config.api_url}/get-validate-coupon.php`, {
|
|
2740
|
+
params: {
|
|
2741
|
+
coupon_key,
|
|
2742
|
+
},
|
|
2743
|
+
})
|
|
2744
|
+
.pipe(map$1((response) => {
|
|
2745
|
+
if (response.records === undefined ||
|
|
2746
|
+
Array.isArray(response.records)) {
|
|
2747
|
+
throw response;
|
|
2711
2748
|
}
|
|
2712
|
-
|
|
2713
|
-
|
|
2749
|
+
const valid = response.records.valid;
|
|
2750
|
+
const result = {
|
|
2751
|
+
valid,
|
|
2752
|
+
};
|
|
2753
|
+
if (!valid) {
|
|
2754
|
+
const error = response.records.error;
|
|
2755
|
+
this.validation_error.next(error);
|
|
2714
2756
|
}
|
|
2715
|
-
if (
|
|
2716
|
-
|
|
2757
|
+
else if (valid) {
|
|
2758
|
+
result.id = response.records.id;
|
|
2717
2759
|
}
|
|
2718
|
-
|
|
2719
|
-
|
|
2760
|
+
return result;
|
|
2761
|
+
}), catchError(() => {
|
|
2762
|
+
this.validation_error.next(undefined);
|
|
2763
|
+
return of({ valid: false });
|
|
2764
|
+
}));
|
|
2765
|
+
}
|
|
2766
|
+
async applyCoupon(coupon_key) {
|
|
2767
|
+
try {
|
|
2768
|
+
if (coupon_key.trim() === '') {
|
|
2769
|
+
return false;
|
|
2720
2770
|
}
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
filters = covertFromObj(filters);
|
|
2725
|
-
}
|
|
2726
|
-
params = convertToHttpParams(filters, params);
|
|
2771
|
+
const result = await firstValueFrom(this.validate(coupon_key));
|
|
2772
|
+
if (result.valid && result.id) {
|
|
2773
|
+
this.addCoupon(result.id, coupon_key);
|
|
2727
2774
|
}
|
|
2775
|
+
return result.valid;
|
|
2776
|
+
}
|
|
2777
|
+
catch (error) {
|
|
2778
|
+
return false;
|
|
2728
2779
|
}
|
|
2729
|
-
return this.getLocationRecords(params).pipe(map$1((response) => {
|
|
2730
|
-
if (response.records === undefined ||
|
|
2731
|
-
response.records.length <= 0) {
|
|
2732
|
-
throw response;
|
|
2733
|
-
}
|
|
2734
|
-
const locations = [];
|
|
2735
|
-
response.records.forEach((locationRecord) => {
|
|
2736
|
-
locations.push(this.processLocation(locationRecord));
|
|
2737
|
-
});
|
|
2738
|
-
return new EsolveLocationList(locations, +response.additional_data.total_records, options?.page ?? 0);
|
|
2739
|
-
}));
|
|
2740
2780
|
}
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
*/
|
|
2752
|
-
getStockLocationsGeo(addresses_id = 0, latitude = 0, longitude = 0) {
|
|
2781
|
+
removeCoupon(id) {
|
|
2782
|
+
this.cache.delete(id);
|
|
2783
|
+
this.cacheCoupons();
|
|
2784
|
+
this.applied.next();
|
|
2785
|
+
}
|
|
2786
|
+
getAppliedCouponKeys() {
|
|
2787
|
+
return [...this.cache.values()];
|
|
2788
|
+
}
|
|
2789
|
+
getAppliedCoupons() {
|
|
2790
|
+
const coupon_ids = [...this.cache.keys()];
|
|
2753
2791
|
return this.http
|
|
2754
|
-
.get(`${this.config.api_url}/get-
|
|
2792
|
+
.get(`${this.config.api_url}/get-applied-coupons.php`, {
|
|
2755
2793
|
params: {
|
|
2756
|
-
|
|
2757
|
-
latitude,
|
|
2758
|
-
longitude,
|
|
2794
|
+
coupons: coupon_ids.join(','),
|
|
2759
2795
|
},
|
|
2760
2796
|
})
|
|
2761
2797
|
.pipe(map$1((response) => {
|
|
2762
2798
|
if (response.records === undefined) {
|
|
2763
2799
|
throw response;
|
|
2764
2800
|
}
|
|
2765
|
-
return this.
|
|
2801
|
+
return this.processCoupons(response.records);
|
|
2766
2802
|
}));
|
|
2767
2803
|
}
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
.pipe(map$1((response) => {
|
|
2779
|
-
if (response.records === undefined) {
|
|
2780
|
-
throw response;
|
|
2781
|
-
}
|
|
2782
|
-
const filters = [];
|
|
2783
|
-
for (const record of response.records) {
|
|
2784
|
-
let filter = null;
|
|
2785
|
-
if (record.type === 'range') {
|
|
2786
|
-
filter = new EsolveRangeFilter(record.field, +record.min, +record.max);
|
|
2787
|
-
}
|
|
2788
|
-
else if (record.type === 'single') {
|
|
2789
|
-
filter = new EsolveSingleSelectFilter(record.field, record.values);
|
|
2790
|
-
}
|
|
2791
|
-
else if (record.type === 'multiple') {
|
|
2792
|
-
filter = new EsolveMultipleSelectFilter(record.field, record.values);
|
|
2793
|
-
}
|
|
2794
|
-
if (filter) {
|
|
2795
|
-
filters.push(filter);
|
|
2804
|
+
reset() {
|
|
2805
|
+
this.deleteCoupons();
|
|
2806
|
+
}
|
|
2807
|
+
retrieveCache() {
|
|
2808
|
+
if (this.cookieService.check(this.storage_key) || this.getBackup()) {
|
|
2809
|
+
let coupons_json = this.cookieService.get(this.storage_key);
|
|
2810
|
+
if (coupons_json === '') {
|
|
2811
|
+
const local_store_data = this.getBackup();
|
|
2812
|
+
if (local_store_data) {
|
|
2813
|
+
coupons_json = local_store_data;
|
|
2796
2814
|
}
|
|
2797
2815
|
}
|
|
2798
|
-
|
|
2799
|
-
|
|
2816
|
+
try {
|
|
2817
|
+
return this.jsonDecodeMap(coupons_json);
|
|
2818
|
+
}
|
|
2819
|
+
catch (error) {
|
|
2820
|
+
// soft error
|
|
2821
|
+
}
|
|
2822
|
+
}
|
|
2823
|
+
return new Map();
|
|
2800
2824
|
}
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2825
|
+
cacheCoupons() {
|
|
2826
|
+
if (this.cache.size > 0) {
|
|
2827
|
+
const coupons_json = this.jsonEncodeMap(this.cache);
|
|
2828
|
+
this.cookieService.set(this.storage_key, coupons_json, undefined, '/');
|
|
2829
|
+
this.setBackup(coupons_json);
|
|
2830
|
+
}
|
|
2831
|
+
else {
|
|
2832
|
+
this.deleteCoupons();
|
|
2833
|
+
}
|
|
2807
2834
|
}
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
for (const record of records) {
|
|
2817
|
-
locations.push(this.processLocation(record));
|
|
2835
|
+
deleteCoupons() {
|
|
2836
|
+
this.cache.clear();
|
|
2837
|
+
this.cookieService.delete(this.storage_key, '/');
|
|
2838
|
+
this.removeBackup();
|
|
2839
|
+
}
|
|
2840
|
+
getBackup() {
|
|
2841
|
+
if (!this.is_browser) {
|
|
2842
|
+
return null;
|
|
2818
2843
|
}
|
|
2819
|
-
|
|
2844
|
+
if (!localStorage) {
|
|
2845
|
+
return null;
|
|
2846
|
+
}
|
|
2847
|
+
return localStorage.getItem(this.storage_key);
|
|
2820
2848
|
}
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2849
|
+
setBackup(data) {
|
|
2850
|
+
if (!this.is_browser) {
|
|
2851
|
+
return;
|
|
2852
|
+
}
|
|
2853
|
+
if (!localStorage) {
|
|
2854
|
+
return;
|
|
2855
|
+
}
|
|
2856
|
+
localStorage.setItem(this.storage_key, data);
|
|
2828
2857
|
}
|
|
2829
|
-
|
|
2830
|
-
|
|
2858
|
+
removeBackup() {
|
|
2859
|
+
if (!this.is_browser) {
|
|
2860
|
+
return;
|
|
2861
|
+
}
|
|
2862
|
+
if (!localStorage) {
|
|
2863
|
+
return;
|
|
2864
|
+
}
|
|
2865
|
+
localStorage.removeItem(this.storage_key);
|
|
2866
|
+
}
|
|
2867
|
+
addCoupon(id, key) {
|
|
2868
|
+
if (!this.cache.has(id)) {
|
|
2869
|
+
this.cache.set(id, key);
|
|
2870
|
+
this.cacheCoupons();
|
|
2871
|
+
}
|
|
2872
|
+
this.applied.next();
|
|
2873
|
+
}
|
|
2874
|
+
setStorageKey() {
|
|
2875
|
+
if (typeof this.config.coupon_storage_key === 'string' &&
|
|
2876
|
+
this.config.coupon_storage_key !== '') {
|
|
2877
|
+
this.storage_key = this.config.coupon_storage_key;
|
|
2878
|
+
}
|
|
2879
|
+
}
|
|
2880
|
+
jsonEncodeMap(data) {
|
|
2881
|
+
if (!(data instanceof Map)) {
|
|
2882
|
+
throw new Error('Invalid map type');
|
|
2883
|
+
}
|
|
2884
|
+
return JSON.stringify(data, (key, value) => {
|
|
2885
|
+
if (value instanceof Map) {
|
|
2886
|
+
return {
|
|
2887
|
+
dataType: 'Map',
|
|
2888
|
+
value: [...value],
|
|
2889
|
+
};
|
|
2890
|
+
}
|
|
2891
|
+
else {
|
|
2892
|
+
return value;
|
|
2893
|
+
}
|
|
2894
|
+
});
|
|
2895
|
+
}
|
|
2896
|
+
jsonDecodeMap(json_data) {
|
|
2897
|
+
const data = JSON.parse(json_data, (key, value) => {
|
|
2898
|
+
if (typeof value === 'object' && value !== null) {
|
|
2899
|
+
if (value.dataType === 'Map') {
|
|
2900
|
+
return new Map(value.value);
|
|
2901
|
+
}
|
|
2902
|
+
}
|
|
2903
|
+
return value;
|
|
2904
|
+
});
|
|
2905
|
+
if (data instanceof Map) {
|
|
2906
|
+
return data;
|
|
2907
|
+
}
|
|
2908
|
+
throw new Error('Invalid map type');
|
|
2909
|
+
}
|
|
2910
|
+
processCoupons(records) {
|
|
2911
|
+
const coupons = [];
|
|
2912
|
+
if (records) {
|
|
2913
|
+
for (const record of records) {
|
|
2914
|
+
const coupon = new EsolveCoupon(record);
|
|
2915
|
+
coupons.push(coupon);
|
|
2916
|
+
}
|
|
2917
|
+
}
|
|
2918
|
+
return coupons;
|
|
2919
|
+
}
|
|
2920
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.4", ngImport: i0, type: EsolveCouponsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2921
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.4", ngImport: i0, type: EsolveCouponsService, providedIn: 'root' }); }
|
|
2831
2922
|
}
|
|
2832
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.4", ngImport: i0, type:
|
|
2923
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.4", ngImport: i0, type: EsolveCouponsService, decorators: [{
|
|
2833
2924
|
type: Injectable,
|
|
2834
2925
|
args: [{
|
|
2835
2926
|
providedIn: 'root',
|
|
2836
2927
|
}]
|
|
2837
|
-
}] });
|
|
2838
|
-
|
|
2839
|
-
class EsolveTransactionLocation extends EsolveLocation {
|
|
2840
|
-
}
|
|
2841
|
-
|
|
2842
|
-
class EsolveTransactionPaymentMethod {
|
|
2843
|
-
constructor(id, name, description, integration_type, service_provider) {
|
|
2844
|
-
this.id = id;
|
|
2845
|
-
this.name = name;
|
|
2846
|
-
this.description = description;
|
|
2847
|
-
this.integration_type = integration_type;
|
|
2848
|
-
this.service_provider = service_provider;
|
|
2849
|
-
}
|
|
2850
|
-
}
|
|
2851
|
-
|
|
2852
|
-
class EsolveTransactionShippingMethod {
|
|
2853
|
-
constructor(id, name, delivery_category, location, description, pricing, client_to_collect) {
|
|
2854
|
-
this.id = id;
|
|
2855
|
-
this.name = name;
|
|
2856
|
-
this.delivery_category = delivery_category;
|
|
2857
|
-
this.location = location;
|
|
2858
|
-
this.description = description;
|
|
2859
|
-
this.pricing = pricing;
|
|
2860
|
-
this.client_to_collect = client_to_collect;
|
|
2861
|
-
}
|
|
2862
|
-
}
|
|
2863
|
-
|
|
2864
|
-
class EsolveTransactionUser {
|
|
2865
|
-
constructor(id, email, first_name, last_name, tel_number, cell_number) {
|
|
2866
|
-
this.id = id;
|
|
2867
|
-
this.email = email;
|
|
2868
|
-
this.first_name = first_name;
|
|
2869
|
-
this.last_name = last_name;
|
|
2870
|
-
this.tel_number = tel_number;
|
|
2871
|
-
this.cell_number = cell_number;
|
|
2872
|
-
}
|
|
2873
|
-
}
|
|
2928
|
+
}], ctorParameters: function () { return []; } });
|
|
2874
2929
|
|
|
2875
|
-
|
|
2876
|
-
}
|
|
2930
|
+
// Classes
|
|
2877
2931
|
|
|
2878
|
-
class
|
|
2879
|
-
constructor(
|
|
2880
|
-
super(response);
|
|
2932
|
+
class EsolveVoucher {
|
|
2933
|
+
constructor(record) {
|
|
2881
2934
|
this.id = 0;
|
|
2882
|
-
this.
|
|
2883
|
-
this.
|
|
2935
|
+
this.identifier = '';
|
|
2936
|
+
this.value = 0;
|
|
2937
|
+
/**
|
|
2938
|
+
* Shows either the short code or the coupon key (if short code is not set)
|
|
2939
|
+
*/
|
|
2940
|
+
this.voucher_code = '';
|
|
2941
|
+
if (record) {
|
|
2942
|
+
this.id = +record.id;
|
|
2943
|
+
this.identifier = record.identifier;
|
|
2944
|
+
this.value = +record.value;
|
|
2945
|
+
this.voucher_code = record.voucher_code;
|
|
2946
|
+
}
|
|
2884
2947
|
}
|
|
2885
2948
|
}
|
|
2886
2949
|
|
|
2887
|
-
class
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2950
|
+
class EsolveVouchersService {
|
|
2951
|
+
constructor() {
|
|
2952
|
+
this.is_browser = isPlatformBrowser(inject(PLATFORM_ID));
|
|
2953
|
+
this.http = inject(HttpClient);
|
|
2954
|
+
this.config = inject(EsolveConfigService);
|
|
2955
|
+
this.cookieService = inject(EsolveCookieService);
|
|
2956
|
+
this.storage_key = '_ng_eslv_vouchers';
|
|
2957
|
+
this.cache = new Map();
|
|
2958
|
+
this.applied = new BehaviorSubject(undefined);
|
|
2959
|
+
this.validation_error = new Subject();
|
|
2960
|
+
this.setStorageKey();
|
|
2961
|
+
this.cache = this.retrieveCache();
|
|
2893
2962
|
}
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
*/
|
|
2897
|
-
get thumbnail_image_src() {
|
|
2898
|
-
return this.getImagePath('thumb');
|
|
2963
|
+
onValidationError() {
|
|
2964
|
+
return this.validation_error.asObservable();
|
|
2899
2965
|
}
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
*/
|
|
2903
|
-
get small_image_src() {
|
|
2904
|
-
return this.getImagePath('small');
|
|
2966
|
+
onApplied() {
|
|
2967
|
+
return this.applied.asObservable();
|
|
2905
2968
|
}
|
|
2906
|
-
|
|
2907
|
-
* Path to big stock image
|
|
2908
|
-
*/
|
|
2909
|
-
get big_image_src() {
|
|
2910
|
-
return this.getImagePath('big');
|
|
2911
|
-
}
|
|
2912
|
-
/**
|
|
2913
|
-
* Path to original stock image
|
|
2914
|
-
*/
|
|
2915
|
-
get original_image_src() {
|
|
2916
|
-
return this.getImagePath('original');
|
|
2917
|
-
}
|
|
2918
|
-
constructor(record) {
|
|
2919
|
-
this.code = record.code ?? '';
|
|
2920
|
-
this.name = record.name ?? '';
|
|
2921
|
-
this.sef_name = record.sef_name ?? '';
|
|
2922
|
-
this.description = record.description ?? '';
|
|
2923
|
-
this.delivery_category = record.delivery_category ?? '';
|
|
2924
|
-
this.image_name = record.image_name ?? '';
|
|
2925
|
-
this.pack_description = record.pack_description ?? '';
|
|
2926
|
-
this.pack_size = +(record.items_in_pack ?? 0);
|
|
2927
|
-
this.onhand = +(record.onhand ?? 0);
|
|
2928
|
-
this.active = record.is_active ?? false;
|
|
2929
|
-
}
|
|
2930
|
-
getImagePath(image_size) {
|
|
2931
|
-
if (this.image_name !== '') {
|
|
2932
|
-
return `/images/stock/${image_size}/${this.image_name}`;
|
|
2933
|
-
}
|
|
2934
|
-
return '';
|
|
2935
|
-
}
|
|
2936
|
-
}
|
|
2937
|
-
|
|
2938
|
-
class EsolveCartItem {
|
|
2939
|
-
constructor(record) {
|
|
2940
|
-
this.delivery_category = record.delivery_category ?? '';
|
|
2941
|
-
this.type = record.type ?? '';
|
|
2942
|
-
this.id = +(record.id ?? 0);
|
|
2943
|
-
this.qty = +(record.qty ?? 0);
|
|
2944
|
-
this.price = +(record.price ?? 0);
|
|
2945
|
-
this.discount = +(record.discount ?? 0);
|
|
2946
|
-
this.discount_interval = +(record.discount_interval ?? 0);
|
|
2947
|
-
this.vat_rate = +(record.vat_rate ?? 0);
|
|
2948
|
-
this.price_incl = +(record.price_incl ?? 0);
|
|
2949
|
-
this.discount_price = +(record.discount_price ?? 0);
|
|
2950
|
-
this.discount_price_incl = +(record.discount_price_incl ?? 0);
|
|
2951
|
-
this.discount_total = +(record.discount_total ?? 0);
|
|
2952
|
-
this.vat_total = +(record.vat_total ?? 0);
|
|
2953
|
-
this.total = +(record.line_total ?? 0);
|
|
2954
|
-
this.total_incl = +(record.line_total_incl ?? 0);
|
|
2955
|
-
this.allow_quotes = record.allow_quotes ?? false;
|
|
2956
|
-
this.allow_orders = record.allow_orders ?? false;
|
|
2957
|
-
this.must_collect = record.must_collect ?? false;
|
|
2958
|
-
this.requested_assembly = record.requested_assembly ?? false;
|
|
2959
|
-
this.is_dependency = record.is_dependency ?? false;
|
|
2960
|
-
this.stock_item = new EsolveCartStockItem(record);
|
|
2961
|
-
}
|
|
2962
|
-
}
|
|
2963
|
-
|
|
2964
|
-
/**
|
|
2965
|
-
* Totals in cart
|
|
2966
|
-
*/
|
|
2967
|
-
class EsolveCartTotals {
|
|
2968
|
-
/**
|
|
2969
|
-
* Grand total of cart which includes discount and VAT
|
|
2970
|
-
* (NOTE: shipping and insurance is not included)
|
|
2971
|
-
*/
|
|
2972
|
-
get total() {
|
|
2973
|
-
return (this.sub_total +
|
|
2974
|
-
this.vat_total -
|
|
2975
|
-
this.discount_total -
|
|
2976
|
-
this.voucher_total);
|
|
2977
|
-
}
|
|
2978
|
-
constructor(
|
|
2979
|
-
/**
|
|
2980
|
-
* Number of unique records in cart
|
|
2981
|
-
*/
|
|
2982
|
-
records = 0,
|
|
2983
|
-
/**
|
|
2984
|
-
* Total quantity of all items in a cart
|
|
2985
|
-
*/
|
|
2986
|
-
items = 0,
|
|
2987
|
-
/**
|
|
2988
|
-
* Total in cart before discount and VAT is added
|
|
2989
|
-
*/
|
|
2990
|
-
sub_total = 0,
|
|
2991
|
-
/**
|
|
2992
|
-
* Total VAT of all the items in the cart
|
|
2993
|
-
*/
|
|
2994
|
-
vat_total = 0,
|
|
2995
|
-
/**
|
|
2996
|
-
* Total discount of all the item in the cart
|
|
2997
|
-
*/
|
|
2998
|
-
discount_total = 0,
|
|
2999
|
-
/**
|
|
3000
|
-
* Total of all vouchers used
|
|
3001
|
-
*/
|
|
3002
|
-
voucher_total = 0,
|
|
3003
|
-
/**
|
|
3004
|
-
* Total of allowance
|
|
3005
|
-
*/
|
|
3006
|
-
allowance = 0) {
|
|
3007
|
-
this.records = records;
|
|
3008
|
-
this.items = items;
|
|
3009
|
-
this.sub_total = sub_total;
|
|
3010
|
-
this.vat_total = vat_total;
|
|
3011
|
-
this.discount_total = discount_total;
|
|
3012
|
-
this.voucher_total = voucher_total;
|
|
3013
|
-
this.allowance = allowance;
|
|
3014
|
-
}
|
|
3015
|
-
}
|
|
3016
|
-
|
|
3017
|
-
class EsolveTransactionAnalyticsData {
|
|
3018
|
-
constructor(record) {
|
|
3019
|
-
this.transaction_id = 0;
|
|
3020
|
-
this.transaction_type = 'order';
|
|
3021
|
-
if (record) {
|
|
3022
|
-
this.transaction_id = +(record.transaction_id ?? 0);
|
|
3023
|
-
this.transaction_type = record.transaction_type ?? 'order';
|
|
3024
|
-
if (record.analytics_data) {
|
|
3025
|
-
this.analytics_data = record.analytics_data;
|
|
3026
|
-
}
|
|
3027
|
-
}
|
|
3028
|
-
}
|
|
3029
|
-
}
|
|
3030
|
-
|
|
3031
|
-
class EsolveCartAlternative {
|
|
3032
|
-
/**
|
|
3033
|
-
* Path to tiny stock image
|
|
3034
|
-
*/
|
|
3035
|
-
get tiny_image_src() {
|
|
3036
|
-
return this.getImagePath('tiny');
|
|
3037
|
-
}
|
|
3038
|
-
/**
|
|
3039
|
-
* Path to thumbnail stock image
|
|
3040
|
-
*/
|
|
3041
|
-
get thumbnail_image_src() {
|
|
3042
|
-
return this.getImagePath('thumb');
|
|
3043
|
-
}
|
|
3044
|
-
/**
|
|
3045
|
-
* Path to small stock image
|
|
3046
|
-
*/
|
|
3047
|
-
get small_image_src() {
|
|
3048
|
-
return this.getImagePath('small');
|
|
3049
|
-
}
|
|
3050
|
-
/**
|
|
3051
|
-
* Path to big stock image
|
|
3052
|
-
*/
|
|
3053
|
-
get big_image_src() {
|
|
3054
|
-
return this.getImagePath('big');
|
|
3055
|
-
}
|
|
3056
|
-
/**
|
|
3057
|
-
* Path to original stock image
|
|
3058
|
-
*/
|
|
3059
|
-
get original_image_src() {
|
|
3060
|
-
return this.getImagePath('original');
|
|
3061
|
-
}
|
|
3062
|
-
constructor(record) {
|
|
3063
|
-
this.item_id = 0;
|
|
3064
|
-
this.code = '';
|
|
3065
|
-
this.name = '';
|
|
3066
|
-
this.sef_name = '';
|
|
3067
|
-
this.items_in_pack = 0;
|
|
3068
|
-
this.pack_description = '';
|
|
3069
|
-
this.price = 0;
|
|
3070
|
-
this.price_inclusive = 0;
|
|
3071
|
-
this.vat_rate = 0;
|
|
3072
|
-
this.image_name = '';
|
|
3073
|
-
if (record) {
|
|
3074
|
-
this.item_id = record.item_id ?? 0;
|
|
3075
|
-
this.image_name = record.image_name ?? '';
|
|
3076
|
-
this.code = record.code ?? '';
|
|
3077
|
-
this.name = record.name ?? '';
|
|
3078
|
-
this.sef_name = record.sef_name ?? '';
|
|
3079
|
-
this.items_in_pack = +(record.items_in_pack ?? 0);
|
|
3080
|
-
this.pack_description = record.pack_description ?? '';
|
|
3081
|
-
this.price = +(record.price ?? 0);
|
|
3082
|
-
this.price_inclusive = +(record.price_inclusive ?? 0);
|
|
3083
|
-
this.vat_rate = +(record.vat_rate ?? 0);
|
|
3084
|
-
}
|
|
3085
|
-
}
|
|
3086
|
-
getImagePath(image_size) {
|
|
3087
|
-
if (this.image_name !== '') {
|
|
3088
|
-
return `/images/stock/${image_size}/${this.image_name}`;
|
|
3089
|
-
}
|
|
3090
|
-
return '';
|
|
3091
|
-
}
|
|
3092
|
-
}
|
|
3093
|
-
|
|
3094
|
-
class EsolveCoupon {
|
|
3095
|
-
constructor(record) {
|
|
3096
|
-
this.id = 0;
|
|
3097
|
-
this.identifier = '';
|
|
3098
|
-
this.discount = 0;
|
|
3099
|
-
/**
|
|
3100
|
-
* Shows either the short code or the coupon key (if short code is not set)
|
|
3101
|
-
*/
|
|
3102
|
-
this.coupon_code = '';
|
|
3103
|
-
/**
|
|
3104
|
-
* Limit of the number of items it can apply to
|
|
3105
|
-
*/
|
|
3106
|
-
this.apply_on = 0;
|
|
3107
|
-
/**
|
|
3108
|
-
* Indicates if the discount does not apply to specified products, meaning
|
|
3109
|
-
* all items get the discount
|
|
3110
|
-
*/
|
|
3111
|
-
this.apply_to_full_cart = false;
|
|
3112
|
-
if (record) {
|
|
3113
|
-
this.id = +record.id;
|
|
3114
|
-
this.identifier = record.identifier;
|
|
3115
|
-
this.discount = +record.discount;
|
|
3116
|
-
this.coupon_code = record.coupon_code;
|
|
3117
|
-
this.apply_on = +record.apply_on;
|
|
3118
|
-
this.apply_to_full_cart = record.apply_to_full_cart;
|
|
3119
|
-
}
|
|
3120
|
-
}
|
|
3121
|
-
}
|
|
3122
|
-
|
|
3123
|
-
class EsolveCouponsService {
|
|
3124
|
-
constructor() {
|
|
3125
|
-
this.is_browser = isPlatformBrowser(inject(PLATFORM_ID));
|
|
3126
|
-
this.http = inject(HttpClient);
|
|
3127
|
-
this.config = inject(EsolveConfigService);
|
|
3128
|
-
this.cookieService = inject(EsolveCookieService);
|
|
3129
|
-
this.storage_key = '_ng_eslv_coupons';
|
|
3130
|
-
this.cache = new Map();
|
|
3131
|
-
this.applied = new BehaviorSubject(undefined);
|
|
3132
|
-
this.validation_error = new Subject();
|
|
3133
|
-
this.setStorageKey();
|
|
3134
|
-
this.cache = this.retrieveCache();
|
|
3135
|
-
}
|
|
3136
|
-
onValidationError() {
|
|
3137
|
-
return this.validation_error.asObservable();
|
|
3138
|
-
}
|
|
3139
|
-
onApplied() {
|
|
3140
|
-
return this.applied.asObservable();
|
|
3141
|
-
}
|
|
3142
|
-
validate(coupon_key) {
|
|
2969
|
+
validate(voucher_key) {
|
|
3143
2970
|
return this.http
|
|
3144
|
-
.get(`${this.config.api_url}/get-validate-
|
|
2971
|
+
.get(`${this.config.api_url}/get-validate-voucher.php`, {
|
|
3145
2972
|
params: {
|
|
3146
|
-
|
|
2973
|
+
voucher_key,
|
|
3147
2974
|
},
|
|
3148
2975
|
})
|
|
3149
2976
|
.pipe(map$1((response) => {
|
|
@@ -3165,17 +2992,17 @@ class EsolveCouponsService {
|
|
|
3165
2992
|
return result;
|
|
3166
2993
|
}), catchError(() => {
|
|
3167
2994
|
this.validation_error.next(undefined);
|
|
3168
|
-
return
|
|
2995
|
+
return [{ valid: false }];
|
|
3169
2996
|
}));
|
|
3170
2997
|
}
|
|
3171
|
-
async
|
|
2998
|
+
async applyVoucher(voucher_key) {
|
|
3172
2999
|
try {
|
|
3173
|
-
if (
|
|
3000
|
+
if (voucher_key.trim() === '') {
|
|
3174
3001
|
return false;
|
|
3175
3002
|
}
|
|
3176
|
-
const result = await firstValueFrom(this.validate(
|
|
3003
|
+
const result = await firstValueFrom(this.validate(voucher_key));
|
|
3177
3004
|
if (result.valid && result.id) {
|
|
3178
|
-
this.
|
|
3005
|
+
this.addVoucher(result.id, voucher_key);
|
|
3179
3006
|
}
|
|
3180
3007
|
return result.valid;
|
|
3181
3008
|
}
|
|
@@ -3183,43 +3010,43 @@ class EsolveCouponsService {
|
|
|
3183
3010
|
return false;
|
|
3184
3011
|
}
|
|
3185
3012
|
}
|
|
3186
|
-
|
|
3013
|
+
removeVoucher(id) {
|
|
3187
3014
|
this.cache.delete(id);
|
|
3188
|
-
this.
|
|
3015
|
+
this.cacheVouchers();
|
|
3189
3016
|
this.applied.next();
|
|
3190
3017
|
}
|
|
3191
|
-
|
|
3018
|
+
getAppliedVoucherKeys() {
|
|
3192
3019
|
return [...this.cache.values()];
|
|
3193
3020
|
}
|
|
3194
|
-
|
|
3195
|
-
const
|
|
3196
|
-
return this.http
|
|
3197
|
-
.get(`${this.config.api_url}/get-applied-
|
|
3021
|
+
getAppliedVouchers() {
|
|
3022
|
+
const voucher_ids = [...this.cache.keys()];
|
|
3023
|
+
return this.http
|
|
3024
|
+
.get(`${this.config.api_url}/get-applied-vouchers.php`, {
|
|
3198
3025
|
params: {
|
|
3199
|
-
|
|
3026
|
+
vouchers: voucher_ids.join(','),
|
|
3200
3027
|
},
|
|
3201
3028
|
})
|
|
3202
3029
|
.pipe(map$1((response) => {
|
|
3203
3030
|
if (response.records === undefined) {
|
|
3204
3031
|
throw response;
|
|
3205
3032
|
}
|
|
3206
|
-
return this.
|
|
3033
|
+
return this.processVouchers(response.records);
|
|
3207
3034
|
}));
|
|
3208
3035
|
}
|
|
3209
3036
|
reset() {
|
|
3210
|
-
this.
|
|
3037
|
+
this.deleteVouchers();
|
|
3211
3038
|
}
|
|
3212
3039
|
retrieveCache() {
|
|
3213
3040
|
if (this.cookieService.check(this.storage_key) || this.getBackup()) {
|
|
3214
|
-
let
|
|
3215
|
-
if (
|
|
3041
|
+
let vouchers_json = this.cookieService.get(this.storage_key);
|
|
3042
|
+
if (vouchers_json === '') {
|
|
3216
3043
|
const local_store_data = this.getBackup();
|
|
3217
3044
|
if (local_store_data) {
|
|
3218
|
-
|
|
3045
|
+
vouchers_json = local_store_data;
|
|
3219
3046
|
}
|
|
3220
3047
|
}
|
|
3221
3048
|
try {
|
|
3222
|
-
return this.jsonDecodeMap(
|
|
3049
|
+
return this.jsonDecodeMap(vouchers_json);
|
|
3223
3050
|
}
|
|
3224
3051
|
catch (error) {
|
|
3225
3052
|
// soft error
|
|
@@ -3227,17 +3054,17 @@ class EsolveCouponsService {
|
|
|
3227
3054
|
}
|
|
3228
3055
|
return new Map();
|
|
3229
3056
|
}
|
|
3230
|
-
|
|
3057
|
+
cacheVouchers() {
|
|
3231
3058
|
if (this.cache.size > 0) {
|
|
3232
|
-
const
|
|
3233
|
-
this.cookieService.set(this.storage_key,
|
|
3234
|
-
this.setBackup(
|
|
3059
|
+
const vouchers_json = this.jsonEncodeMap(this.cache);
|
|
3060
|
+
this.cookieService.set(this.storage_key, vouchers_json, undefined, '/');
|
|
3061
|
+
this.setBackup(vouchers_json);
|
|
3235
3062
|
}
|
|
3236
3063
|
else {
|
|
3237
|
-
this.
|
|
3064
|
+
this.deleteVouchers();
|
|
3238
3065
|
}
|
|
3239
3066
|
}
|
|
3240
|
-
|
|
3067
|
+
deleteVouchers() {
|
|
3241
3068
|
this.cache.clear();
|
|
3242
3069
|
this.cookieService.delete(this.storage_key, '/');
|
|
3243
3070
|
this.removeBackup();
|
|
@@ -3269,17 +3096,17 @@ class EsolveCouponsService {
|
|
|
3269
3096
|
}
|
|
3270
3097
|
localStorage.removeItem(this.storage_key);
|
|
3271
3098
|
}
|
|
3272
|
-
|
|
3099
|
+
addVoucher(id, key) {
|
|
3273
3100
|
if (!this.cache.has(id)) {
|
|
3274
3101
|
this.cache.set(id, key);
|
|
3275
|
-
this.
|
|
3102
|
+
this.cacheVouchers();
|
|
3276
3103
|
}
|
|
3277
3104
|
this.applied.next();
|
|
3278
3105
|
}
|
|
3279
3106
|
setStorageKey() {
|
|
3280
|
-
if (typeof this.config.
|
|
3281
|
-
this.config.
|
|
3282
|
-
this.storage_key = this.config.
|
|
3107
|
+
if (typeof this.config.voucher_storage_key === 'string' &&
|
|
3108
|
+
this.config.voucher_storage_key !== '') {
|
|
3109
|
+
this.storage_key = this.config.voucher_storage_key;
|
|
3283
3110
|
}
|
|
3284
3111
|
}
|
|
3285
3112
|
jsonEncodeMap(data) {
|
|
@@ -3312,20 +3139,20 @@ class EsolveCouponsService {
|
|
|
3312
3139
|
}
|
|
3313
3140
|
throw new Error('Invalid map type');
|
|
3314
3141
|
}
|
|
3315
|
-
|
|
3316
|
-
const
|
|
3142
|
+
processVouchers(records) {
|
|
3143
|
+
const vouchers = [];
|
|
3317
3144
|
if (records) {
|
|
3318
3145
|
for (const record of records) {
|
|
3319
|
-
const
|
|
3320
|
-
|
|
3146
|
+
const voucher = new EsolveVoucher(record);
|
|
3147
|
+
vouchers.push(voucher);
|
|
3321
3148
|
}
|
|
3322
3149
|
}
|
|
3323
|
-
return
|
|
3150
|
+
return vouchers;
|
|
3324
3151
|
}
|
|
3325
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.4", ngImport: i0, type:
|
|
3326
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.4", ngImport: i0, type:
|
|
3152
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.4", ngImport: i0, type: EsolveVouchersService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
3153
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.4", ngImport: i0, type: EsolveVouchersService, providedIn: 'root' }); }
|
|
3327
3154
|
}
|
|
3328
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.4", ngImport: i0, type:
|
|
3155
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.4", ngImport: i0, type: EsolveVouchersService, decorators: [{
|
|
3329
3156
|
type: Injectable,
|
|
3330
3157
|
args: [{
|
|
3331
3158
|
providedIn: 'root',
|
|
@@ -3334,530 +3161,751 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.4", ngImpor
|
|
|
3334
3161
|
|
|
3335
3162
|
// Classes
|
|
3336
3163
|
|
|
3337
|
-
class
|
|
3338
|
-
constructor(record) {
|
|
3339
|
-
this.id = 0;
|
|
3340
|
-
this.identifier = '';
|
|
3341
|
-
this.value = 0;
|
|
3342
|
-
/**
|
|
3343
|
-
* Shows either the short code or the coupon key (if short code is not set)
|
|
3344
|
-
*/
|
|
3345
|
-
this.voucher_code = '';
|
|
3346
|
-
if (record) {
|
|
3347
|
-
this.id = +record.id;
|
|
3348
|
-
this.identifier = record.identifier;
|
|
3349
|
-
this.value = +record.value;
|
|
3350
|
-
this.voucher_code = record.voucher_code;
|
|
3351
|
-
}
|
|
3352
|
-
}
|
|
3353
|
-
}
|
|
3354
|
-
|
|
3355
|
-
class EsolveVouchersService {
|
|
3164
|
+
class EsolveCartService {
|
|
3356
3165
|
constructor() {
|
|
3357
|
-
this.is_browser = isPlatformBrowser(inject(PLATFORM_ID));
|
|
3358
|
-
this.http = inject(HttpClient);
|
|
3359
3166
|
this.config = inject(EsolveConfigService);
|
|
3360
|
-
this.
|
|
3361
|
-
this.
|
|
3362
|
-
this.
|
|
3363
|
-
this.
|
|
3364
|
-
this.
|
|
3365
|
-
this.
|
|
3366
|
-
this.cache = this.retrieveCache();
|
|
3167
|
+
this.http = inject(HttpClient);
|
|
3168
|
+
this.errorHandler = inject(EsolveErrorHandlerService);
|
|
3169
|
+
this.responseHandler = inject(EsolveResponseHandlerService);
|
|
3170
|
+
this.coupons = inject(EsolveCouponsService);
|
|
3171
|
+
this.vouchers = inject(EsolveVouchersService);
|
|
3172
|
+
this._cached_tracking = 0;
|
|
3367
3173
|
}
|
|
3368
|
-
|
|
3369
|
-
|
|
3174
|
+
/**
|
|
3175
|
+
* Retrieves the current cart
|
|
3176
|
+
*
|
|
3177
|
+
* @returns An `Observable` with an array of cart items
|
|
3178
|
+
*/
|
|
3179
|
+
getCart() {
|
|
3180
|
+
let params = new HttpParams();
|
|
3181
|
+
const coupons = this.coupons.getAppliedCouponKeys();
|
|
3182
|
+
if (coupons.length > 0) {
|
|
3183
|
+
params = params.set('coupons', coupons.join(','));
|
|
3184
|
+
}
|
|
3185
|
+
return this.http
|
|
3186
|
+
.get(`${this.config.api_url}/get-cart.php`, { params })
|
|
3187
|
+
.pipe(map$1((response) => {
|
|
3188
|
+
if (response.records === undefined) {
|
|
3189
|
+
throw response;
|
|
3190
|
+
}
|
|
3191
|
+
return this.processCart(response.records);
|
|
3192
|
+
}));
|
|
3370
3193
|
}
|
|
3371
|
-
|
|
3372
|
-
|
|
3194
|
+
/**
|
|
3195
|
+
* Updates the cart by preforming various actions, such as adding, editing or removing items from the cart.
|
|
3196
|
+
*
|
|
3197
|
+
* @param items An array of options to update the cart
|
|
3198
|
+
* @param action The default action to preform
|
|
3199
|
+
*
|
|
3200
|
+
* @returns An `Observable` with an array of responses that gives feedback on the requested changes
|
|
3201
|
+
*/
|
|
3202
|
+
setCart(items, action = 'add') {
|
|
3203
|
+
const body = {
|
|
3204
|
+
items,
|
|
3205
|
+
action,
|
|
3206
|
+
};
|
|
3207
|
+
return this.http
|
|
3208
|
+
.post(`${this.config.api_url}/set-cart-item.php`, body, {
|
|
3209
|
+
headers: {
|
|
3210
|
+
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;',
|
|
3211
|
+
},
|
|
3212
|
+
responseType: 'json',
|
|
3213
|
+
observe: 'body',
|
|
3214
|
+
})
|
|
3215
|
+
.pipe(map$1((response) => {
|
|
3216
|
+
if (response.responses === undefined) {
|
|
3217
|
+
throw response;
|
|
3218
|
+
}
|
|
3219
|
+
return response.responses;
|
|
3220
|
+
}));
|
|
3373
3221
|
}
|
|
3374
|
-
|
|
3222
|
+
setCartEmpty(type, additional_where) {
|
|
3223
|
+
const body = {
|
|
3224
|
+
type,
|
|
3225
|
+
additional_where,
|
|
3226
|
+
};
|
|
3375
3227
|
return this.http
|
|
3376
|
-
.
|
|
3377
|
-
|
|
3378
|
-
|
|
3228
|
+
.post(`${this.config.api_url}/set-cart-empty.php`, body, {
|
|
3229
|
+
headers: {
|
|
3230
|
+
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;',
|
|
3379
3231
|
},
|
|
3232
|
+
responseType: 'json',
|
|
3233
|
+
observe: 'body',
|
|
3380
3234
|
})
|
|
3235
|
+
.pipe(map$1((http_response) => this.responseHandler.validateSingleHttpResponse(http_response, (response) => {
|
|
3236
|
+
this._cached_tracking = 0;
|
|
3237
|
+
return new EsolveEmptyCartResult(response);
|
|
3238
|
+
})), catchError((errorRes) => {
|
|
3239
|
+
return this.errorHandler.handleHttpPostError('set-cart-empty', errorRes);
|
|
3240
|
+
}));
|
|
3241
|
+
}
|
|
3242
|
+
/**
|
|
3243
|
+
* Retrieves the totals of the cart with all the totals calculated
|
|
3244
|
+
*
|
|
3245
|
+
* @returns An `Observable` with an object containing cart totals
|
|
3246
|
+
*/
|
|
3247
|
+
getTotals(type) {
|
|
3248
|
+
let params = new HttpParams({
|
|
3249
|
+
fromObject: {
|
|
3250
|
+
type: type ?? '',
|
|
3251
|
+
},
|
|
3252
|
+
});
|
|
3253
|
+
const vouchers = this.vouchers.getAppliedVoucherKeys();
|
|
3254
|
+
if (vouchers.length > 0) {
|
|
3255
|
+
params = params.set('vouchers', vouchers.join(','));
|
|
3256
|
+
}
|
|
3257
|
+
return this.http
|
|
3258
|
+
.get(`${this.config.api_url}/get-cart-totals.php`, { params })
|
|
3381
3259
|
.pipe(map$1((response) => {
|
|
3382
3260
|
if (response.records === undefined ||
|
|
3383
3261
|
Array.isArray(response.records)) {
|
|
3384
3262
|
throw response;
|
|
3385
3263
|
}
|
|
3386
|
-
|
|
3387
|
-
const result = {
|
|
3388
|
-
valid,
|
|
3389
|
-
};
|
|
3390
|
-
if (!valid) {
|
|
3391
|
-
const error = response.records.error;
|
|
3392
|
-
this.validation_error.next(error);
|
|
3393
|
-
}
|
|
3394
|
-
else if (valid) {
|
|
3395
|
-
result.id = response.records.id;
|
|
3396
|
-
}
|
|
3397
|
-
return result;
|
|
3398
|
-
}), catchError(() => {
|
|
3399
|
-
this.validation_error.next(undefined);
|
|
3400
|
-
return [{ valid: false }];
|
|
3264
|
+
return this.processCartTotals(response.records);
|
|
3401
3265
|
}));
|
|
3402
3266
|
}
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3267
|
+
/**
|
|
3268
|
+
* Retrieves a tracking code for the cart
|
|
3269
|
+
*
|
|
3270
|
+
* @returns An `Observable` with the cart tracking code
|
|
3271
|
+
*/
|
|
3272
|
+
getTrackingCode() {
|
|
3273
|
+
return iif(() => this._cached_tracking > 0, of(this._cached_tracking), this.http
|
|
3274
|
+
.get(`${this.config.api_url}/get-checkout-tracking.php`)
|
|
3275
|
+
.pipe(map$1((response) => {
|
|
3276
|
+
if (response.records === undefined ||
|
|
3277
|
+
Array.isArray(response.records)) {
|
|
3278
|
+
throw response;
|
|
3411
3279
|
}
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
return false;
|
|
3416
|
-
}
|
|
3417
|
-
}
|
|
3418
|
-
removeVoucher(id) {
|
|
3419
|
-
this.cache.delete(id);
|
|
3420
|
-
this.cacheVouchers();
|
|
3421
|
-
this.applied.next();
|
|
3422
|
-
}
|
|
3423
|
-
getAppliedVoucherKeys() {
|
|
3424
|
-
return [...this.cache.values()];
|
|
3280
|
+
this._cached_tracking = response.records.tracking;
|
|
3281
|
+
return response.records.tracking;
|
|
3282
|
+
})));
|
|
3425
3283
|
}
|
|
3426
|
-
|
|
3427
|
-
|
|
3284
|
+
/**
|
|
3285
|
+
* Get the data of the transaction for the analytics
|
|
3286
|
+
*
|
|
3287
|
+
* @param transaction_id ID of the transaction used in eSolve
|
|
3288
|
+
*
|
|
3289
|
+
* @returns An `Observable` with the analytics data
|
|
3290
|
+
*/
|
|
3291
|
+
getTransactionAnalyticsData(transaction_id) {
|
|
3428
3292
|
return this.http
|
|
3429
|
-
.get(`${this.config.api_url}/get-
|
|
3293
|
+
.get(`${this.config.api_url}/get-transaction-analytics-data.php`, {
|
|
3430
3294
|
params: {
|
|
3431
|
-
|
|
3295
|
+
transaction_id,
|
|
3432
3296
|
},
|
|
3433
3297
|
})
|
|
3434
3298
|
.pipe(map$1((response) => {
|
|
3435
|
-
if (response.records === undefined
|
|
3299
|
+
if (response.records === undefined ||
|
|
3300
|
+
Array.isArray(response.records)) {
|
|
3436
3301
|
throw response;
|
|
3437
3302
|
}
|
|
3438
|
-
return
|
|
3303
|
+
return new EsolveTransactionAnalyticsData(response.records);
|
|
3439
3304
|
}));
|
|
3440
3305
|
}
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3306
|
+
/**
|
|
3307
|
+
* Initiates checkout of the cart items
|
|
3308
|
+
*
|
|
3309
|
+
* @param type The cart type that needs to be checked out
|
|
3310
|
+
* @param addresses_id The ID of the delivery address
|
|
3311
|
+
* @param shipping_id The ID of the shipping method
|
|
3312
|
+
* @param payment_method_id The ID of the selected payment method
|
|
3313
|
+
* @param location_id The ID of the selected branch from with shipping needs to be calculated
|
|
3314
|
+
* @param comments Additional comments on the cart
|
|
3315
|
+
*
|
|
3316
|
+
* @returns An `Observable` with the transaction ID
|
|
3317
|
+
*/
|
|
3318
|
+
checkout(type, addresses_id, shipping_id, payment_method_id = 0, location_id = 0, comments = '', time_slot) {
|
|
3319
|
+
const body = {
|
|
3320
|
+
type,
|
|
3321
|
+
addresses_id,
|
|
3322
|
+
shipping_id,
|
|
3323
|
+
payment_method_id,
|
|
3324
|
+
location_id,
|
|
3325
|
+
comments,
|
|
3326
|
+
tracking: 0,
|
|
3327
|
+
time_slot,
|
|
3328
|
+
};
|
|
3329
|
+
return this.getTrackingCode().pipe(switchMap$1((tracking) => {
|
|
3330
|
+
if (tracking <= 0) {
|
|
3331
|
+
throw tracking;
|
|
3452
3332
|
}
|
|
3453
|
-
|
|
3454
|
-
|
|
3333
|
+
body.tracking = tracking;
|
|
3334
|
+
const voucher_keys = this.vouchers.getAppliedVoucherKeys();
|
|
3335
|
+
if (voucher_keys.length > 0) {
|
|
3336
|
+
body.vouchers = voucher_keys;
|
|
3455
3337
|
}
|
|
3456
|
-
|
|
3457
|
-
|
|
3338
|
+
return this.http
|
|
3339
|
+
.post(`${this.config.api_url}/set-checkout.php`, body, {
|
|
3340
|
+
headers: {
|
|
3341
|
+
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;',
|
|
3342
|
+
},
|
|
3343
|
+
responseType: 'json',
|
|
3344
|
+
observe: 'body',
|
|
3345
|
+
})
|
|
3346
|
+
.pipe(map$1((http_response) => this.responseHandler.validateSingleHttpResponse(http_response, (response) => {
|
|
3347
|
+
this._cached_tracking = 0;
|
|
3348
|
+
this.coupons.reset();
|
|
3349
|
+
this.vouchers.reset();
|
|
3350
|
+
return new EsolveCheckoutResult(response);
|
|
3351
|
+
})), catchError((errorRes) => {
|
|
3352
|
+
return this.errorHandler.handleHttpPostError('set-checkout', errorRes);
|
|
3353
|
+
}));
|
|
3354
|
+
}));
|
|
3355
|
+
}
|
|
3356
|
+
getCartAlternatives() {
|
|
3357
|
+
return this.http
|
|
3358
|
+
.get(`${this.config.api_url}/get-cart-alternatives.php`)
|
|
3359
|
+
.pipe(map$1((response) => {
|
|
3360
|
+
if (response.records === undefined) {
|
|
3361
|
+
throw response;
|
|
3458
3362
|
}
|
|
3459
|
-
|
|
3460
|
-
|
|
3363
|
+
return this.processCartAlternatives(response.records);
|
|
3364
|
+
}));
|
|
3461
3365
|
}
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
|
|
3366
|
+
/**
|
|
3367
|
+
* Set an alternative stock item to current cart item
|
|
3368
|
+
*
|
|
3369
|
+
* @param id It is used to identify the specific cart item for which the alternative is being set
|
|
3370
|
+
* @param alternative The alternative value that you want to set for a specific cart item.
|
|
3371
|
+
* @returns an Observable of type EsolveResponseResult.
|
|
3372
|
+
*/
|
|
3373
|
+
setCartAlternative(id, alternative) {
|
|
3374
|
+
return this.http
|
|
3375
|
+
.post(`${this.config.api_url}/set-cart-alternatives.php`, {
|
|
3376
|
+
cart_id: id,
|
|
3377
|
+
alternative: alternative,
|
|
3378
|
+
}, {
|
|
3379
|
+
headers: {
|
|
3380
|
+
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;',
|
|
3381
|
+
},
|
|
3382
|
+
responseType: 'json',
|
|
3383
|
+
observe: 'body',
|
|
3384
|
+
})
|
|
3385
|
+
.pipe(map$1((http_response) => this.responseHandler.validateSingleHttpResponse(http_response, (response) => new EsolveResponseResult(response))), catchError((errorRes) => {
|
|
3386
|
+
return this.errorHandler.handleHttpPostError('set-cart-alternatives', errorRes);
|
|
3387
|
+
}));
|
|
3471
3388
|
}
|
|
3472
|
-
|
|
3473
|
-
this.
|
|
3474
|
-
|
|
3475
|
-
|
|
3389
|
+
deleteCartAlternative(id) {
|
|
3390
|
+
return this.http
|
|
3391
|
+
.delete(`${this.config.api_url}/delete-cart-alternative.php`, {
|
|
3392
|
+
params: { id },
|
|
3393
|
+
responseType: 'json',
|
|
3394
|
+
observe: 'body',
|
|
3395
|
+
})
|
|
3396
|
+
.pipe(map$1((http_response) => {
|
|
3397
|
+
if (http_response.result === undefined ||
|
|
3398
|
+
http_response.result === null ||
|
|
3399
|
+
http_response.result.status !== 'success') {
|
|
3400
|
+
throw http_response;
|
|
3401
|
+
}
|
|
3402
|
+
return new EsolveResult(http_response.result.status, http_response.result.code, http_response.result.message);
|
|
3403
|
+
}), catchError((errorRes) => {
|
|
3404
|
+
return this.errorHandler.handleHttpDeleteError('delete-cart-alternative', errorRes);
|
|
3405
|
+
}));
|
|
3476
3406
|
}
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3407
|
+
/**
|
|
3408
|
+
* Processes the eSolve tree records
|
|
3409
|
+
*
|
|
3410
|
+
* @param cart_item_records Records to process
|
|
3411
|
+
* @returns An array of processed cart items
|
|
3412
|
+
*/
|
|
3413
|
+
processCart(cart_item_records) {
|
|
3414
|
+
const cart_items = [];
|
|
3415
|
+
if (cart_item_records) {
|
|
3416
|
+
for (const cart_item_record of cart_item_records) {
|
|
3417
|
+
cart_items.push(new EsolveCartItem(cart_item_record));
|
|
3418
|
+
}
|
|
3480
3419
|
}
|
|
3481
|
-
|
|
3482
|
-
|
|
3420
|
+
return cart_items;
|
|
3421
|
+
}
|
|
3422
|
+
/**
|
|
3423
|
+
* Processes the eSolve cart alternatives records
|
|
3424
|
+
*
|
|
3425
|
+
* @param records Records to process
|
|
3426
|
+
*
|
|
3427
|
+
* @returns A `Map` of processed cart alternatives
|
|
3428
|
+
*/
|
|
3429
|
+
processCartAlternatives(records) {
|
|
3430
|
+
const alternatives = new Map();
|
|
3431
|
+
for (const record of records) {
|
|
3432
|
+
alternatives.set(record.item_id, new EsolveCartAlternative(record));
|
|
3483
3433
|
}
|
|
3484
|
-
return
|
|
3434
|
+
return alternatives;
|
|
3485
3435
|
}
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3436
|
+
/**
|
|
3437
|
+
* Processes the eSolve cart totals
|
|
3438
|
+
*
|
|
3439
|
+
* @param record Data to process
|
|
3440
|
+
* @returns Processed cart totals
|
|
3441
|
+
*/
|
|
3442
|
+
processCartTotals(record) {
|
|
3443
|
+
const cart_totals = new EsolveCartTotals(+record.records, +record.items, +record.total, +record.vat, +record.discount, +record.vouchers, +record.allowance);
|
|
3444
|
+
return cart_totals;
|
|
3445
|
+
}
|
|
3446
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.4", ngImport: i0, type: EsolveCartService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
3447
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.4", ngImport: i0, type: EsolveCartService, providedIn: 'root' }); }
|
|
3448
|
+
}
|
|
3449
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.4", ngImport: i0, type: EsolveCartService, decorators: [{
|
|
3450
|
+
type: Injectable,
|
|
3451
|
+
args: [{
|
|
3452
|
+
providedIn: 'root',
|
|
3453
|
+
}]
|
|
3454
|
+
}] });
|
|
3455
|
+
|
|
3456
|
+
class EsolveTransactionAddress {
|
|
3457
|
+
constructor(recipient, address_type, address_description, street_number, street, suburb, city, province, country, postal_code, pobox) {
|
|
3458
|
+
this.recipient = recipient;
|
|
3459
|
+
this.address_type = address_type;
|
|
3460
|
+
this.address_description = address_description;
|
|
3461
|
+
this.street_number = street_number;
|
|
3462
|
+
this.street = street;
|
|
3463
|
+
this.suburb = suburb;
|
|
3464
|
+
this.city = city;
|
|
3465
|
+
this.province = province;
|
|
3466
|
+
this.country = country;
|
|
3467
|
+
this.postal_code = postal_code;
|
|
3468
|
+
this.pobox = pobox;
|
|
3469
|
+
}
|
|
3470
|
+
}
|
|
3471
|
+
|
|
3472
|
+
class EsolveTransactionClient {
|
|
3473
|
+
constructor(id, account, company_name, branch_code, email, first_name, last_name, contact_number) {
|
|
3474
|
+
this.id = id;
|
|
3475
|
+
this.account = account;
|
|
3476
|
+
this.company_name = company_name;
|
|
3477
|
+
this.branch_code = branch_code;
|
|
3478
|
+
this.email = email;
|
|
3479
|
+
this.first_name = first_name;
|
|
3480
|
+
this.last_name = last_name;
|
|
3481
|
+
this.contact_number = contact_number;
|
|
3482
|
+
}
|
|
3483
|
+
}
|
|
3484
|
+
|
|
3485
|
+
class EsolveTransactionItemPrice {
|
|
3486
|
+
constructor(
|
|
3487
|
+
/**
|
|
3488
|
+
* Price without tax
|
|
3489
|
+
*/
|
|
3490
|
+
price,
|
|
3491
|
+
/**
|
|
3492
|
+
* Price with tax
|
|
3493
|
+
*/
|
|
3494
|
+
price_with_tax,
|
|
3495
|
+
/**
|
|
3496
|
+
* Price without tax and with discounts applied if applicable
|
|
3497
|
+
*/
|
|
3498
|
+
price_discounted,
|
|
3499
|
+
/**
|
|
3500
|
+
* Price with tax and with discounts applied if applicable
|
|
3501
|
+
*/
|
|
3502
|
+
price_with_tax_discounted) {
|
|
3503
|
+
this.price = price;
|
|
3504
|
+
this.price_with_tax = price_with_tax;
|
|
3505
|
+
this.price_discounted = price_discounted;
|
|
3506
|
+
this.price_with_tax_discounted = price_with_tax_discounted;
|
|
3507
|
+
}
|
|
3508
|
+
}
|
|
3509
|
+
|
|
3510
|
+
class EsolveTransactionItem {
|
|
3511
|
+
/**
|
|
3512
|
+
* Path to tiny stock image
|
|
3513
|
+
*/
|
|
3514
|
+
get tiny_image_src() {
|
|
3515
|
+
return this.getImagePath('tiny');
|
|
3516
|
+
}
|
|
3517
|
+
/**
|
|
3518
|
+
* Path to thumbnail stock image
|
|
3519
|
+
*/
|
|
3520
|
+
get thumbnail_image_src() {
|
|
3521
|
+
return this.getImagePath('thumb');
|
|
3522
|
+
}
|
|
3523
|
+
/**
|
|
3524
|
+
* Path to small stock image
|
|
3525
|
+
*/
|
|
3526
|
+
get small_image_src() {
|
|
3527
|
+
return this.getImagePath('small');
|
|
3528
|
+
}
|
|
3529
|
+
/**
|
|
3530
|
+
* Path to big stock image
|
|
3531
|
+
*/
|
|
3532
|
+
get big_image_src() {
|
|
3533
|
+
return this.getImagePath('big');
|
|
3534
|
+
}
|
|
3535
|
+
/**
|
|
3536
|
+
* Path to original stock image
|
|
3537
|
+
*/
|
|
3538
|
+
get original_image_src() {
|
|
3539
|
+
return this.getImagePath('original');
|
|
3540
|
+
}
|
|
3541
|
+
constructor(record) {
|
|
3542
|
+
this.id = 0;
|
|
3543
|
+
this.code = '';
|
|
3544
|
+
this.name = '';
|
|
3545
|
+
this.sef_name = '';
|
|
3546
|
+
this.image_name = '';
|
|
3547
|
+
this.image_last_modified = '';
|
|
3548
|
+
this.category_description = '';
|
|
3549
|
+
this.subcategory_description = '';
|
|
3550
|
+
this.pack_description = '';
|
|
3551
|
+
this.pack_size = 0;
|
|
3552
|
+
this.qty = 0;
|
|
3553
|
+
this.discount = 0;
|
|
3554
|
+
this.vat_rate = 0;
|
|
3555
|
+
if (record) {
|
|
3556
|
+
this.id = record.id ?? 0;
|
|
3557
|
+
this.code = record.code ?? '';
|
|
3558
|
+
this.name = record.name ?? '';
|
|
3559
|
+
this.sef_name = record.sef_name ?? '';
|
|
3560
|
+
this.image_name = record.image_name ?? '';
|
|
3561
|
+
this.image_last_modified = record.image_last_modified ?? '';
|
|
3562
|
+
this.category_description = record.category_description ?? '';
|
|
3563
|
+
this.subcategory_description = record.subcategory_description ?? '';
|
|
3564
|
+
this.pack_description = record.pack_description ?? '';
|
|
3565
|
+
this.pack_size = +(record.items_in_pack ?? 0);
|
|
3566
|
+
this.qty = +(record.qty ?? 0);
|
|
3567
|
+
this.discount = +(record.discount ?? 0);
|
|
3568
|
+
this.vat_rate = +(record.vat_rate ?? 0);
|
|
3569
|
+
this.price = new EsolveTransactionItemPrice(+(record.price_exclusive ?? 0), +(record.price_inclusive ?? 0), +(record.price_exclusive_after_discount ?? 0), +(record.price_inclusive_after_discount ?? 0));
|
|
3570
|
+
this.line_total = new EsolveTransactionItemPrice(+(record.line_total_exclusive ?? 0), +(record.line_total_inclusive ?? 0), +(record.line_total_exclusive_after_discount ?? 0), +(record.line_total_inclusive_after_discount ?? 0));
|
|
3489
3571
|
}
|
|
3490
|
-
|
|
3491
|
-
|
|
3572
|
+
else {
|
|
3573
|
+
this.price = new EsolveTransactionItemPrice(0, 0, 0, 0);
|
|
3574
|
+
this.line_total = new EsolveTransactionItemPrice(0, 0, 0, 0);
|
|
3492
3575
|
}
|
|
3493
|
-
localStorage.setItem(this.storage_key, data);
|
|
3494
3576
|
}
|
|
3495
|
-
|
|
3496
|
-
if (
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3577
|
+
getImagePath(image_size) {
|
|
3578
|
+
if (this.image_name !== '') {
|
|
3579
|
+
let param = '';
|
|
3580
|
+
if (this.image_last_modified !== '') {
|
|
3581
|
+
param = `?t=${this.image_last_modified}`;
|
|
3582
|
+
}
|
|
3583
|
+
return `/images/stock/${image_size}/${this.image_name}${param}`;
|
|
3501
3584
|
}
|
|
3502
|
-
|
|
3585
|
+
return '';
|
|
3503
3586
|
}
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3587
|
+
}
|
|
3588
|
+
|
|
3589
|
+
class EsolveTransactionList extends EsolveList {
|
|
3590
|
+
}
|
|
3591
|
+
|
|
3592
|
+
class EsolveLocationAddress {
|
|
3593
|
+
constructor(street, suburb, city, province, country, postal_code, latitude, longitude) {
|
|
3594
|
+
this.street = street;
|
|
3595
|
+
this.suburb = suburb;
|
|
3596
|
+
this.city = city;
|
|
3597
|
+
this.province = province;
|
|
3598
|
+
this.country = country;
|
|
3599
|
+
this.postal_code = postal_code;
|
|
3600
|
+
this.latitude = latitude;
|
|
3601
|
+
this.longitude = longitude;
|
|
3602
|
+
}
|
|
3603
|
+
}
|
|
3604
|
+
|
|
3605
|
+
class EsolveLocationContactInfo {
|
|
3606
|
+
constructor(telnumber, cellnumber, email, fax) {
|
|
3607
|
+
this.telnumber = telnumber;
|
|
3608
|
+
this.cellnumber = cellnumber;
|
|
3609
|
+
this.email = email;
|
|
3610
|
+
this.fax = fax;
|
|
3611
|
+
}
|
|
3612
|
+
}
|
|
3613
|
+
|
|
3614
|
+
class EsolveLocationGEO {
|
|
3615
|
+
constructor(distance, range, target_description) {
|
|
3616
|
+
this.distance = distance;
|
|
3617
|
+
this.range = range;
|
|
3618
|
+
this.target_description = target_description;
|
|
3619
|
+
}
|
|
3620
|
+
}
|
|
3621
|
+
|
|
3622
|
+
class EsolveLocationPOBoxAddress {
|
|
3623
|
+
constructor(pobox, city, postal_code) {
|
|
3624
|
+
this.pobox = pobox;
|
|
3625
|
+
this.city = city;
|
|
3626
|
+
this.postal_code = postal_code;
|
|
3627
|
+
}
|
|
3628
|
+
}
|
|
3629
|
+
|
|
3630
|
+
class EsolveLocationTradingDay {
|
|
3631
|
+
constructor(open, close) {
|
|
3632
|
+
this.open = open;
|
|
3633
|
+
this.close = close;
|
|
3634
|
+
}
|
|
3635
|
+
}
|
|
3636
|
+
|
|
3637
|
+
class EsolveLocationTradingTimes {
|
|
3638
|
+
constructor(monday, tuesday, wednesday, thursday, friday, saturday, sunday, public_holiday, trading_hours_additional_info = '') {
|
|
3639
|
+
this.monday = monday;
|
|
3640
|
+
this.tuesday = tuesday;
|
|
3641
|
+
this.wednesday = wednesday;
|
|
3642
|
+
this.thursday = thursday;
|
|
3643
|
+
this.friday = friday;
|
|
3644
|
+
this.saturday = saturday;
|
|
3645
|
+
this.sunday = sunday;
|
|
3646
|
+
this.public_holiday = public_holiday;
|
|
3647
|
+
this.trading_hours_additional_info = trading_hours_additional_info;
|
|
3648
|
+
}
|
|
3649
|
+
}
|
|
3650
|
+
|
|
3651
|
+
class EsolveLocation {
|
|
3652
|
+
constructor(record) {
|
|
3653
|
+
this.id = +record.id;
|
|
3654
|
+
this.identifier = record.identifier;
|
|
3655
|
+
this.description = record.description;
|
|
3656
|
+
this.head_office = !!+record.head_office;
|
|
3657
|
+
this.erp_identifier = record.erp_identifier;
|
|
3658
|
+
this.external_system_code = record.external_system_code;
|
|
3659
|
+
this.default_location_for_payment_methods =
|
|
3660
|
+
!!+record.default_location_for_payment_methods;
|
|
3661
|
+
this.userid = +record.userid;
|
|
3662
|
+
this.importance = +record.importance;
|
|
3663
|
+
this.active = !!+record.is_active;
|
|
3664
|
+
this.dispatches_stock = !!+record.dispatches_stock;
|
|
3665
|
+
this.include_on_enquiries = !!+record.include_on_enquiries;
|
|
3666
|
+
this.include_on_store_locator = !!+record.include_on_store_locator;
|
|
3667
|
+
this.website_url = record.website_url;
|
|
3668
|
+
this.address = new EsolveLocationAddress(record.street, record.suburb, record.city, record.province, record.country, record.postal_code, +record.latitude, +record.longitude);
|
|
3669
|
+
this.pobox_address = new EsolveLocationPOBoxAddress(record.pobox, record.pobox_city, record.pobox_postal_code);
|
|
3670
|
+
const telnumbers = [];
|
|
3671
|
+
if (record.branch_telnumber.length > 0) {
|
|
3672
|
+
telnumbers.push(record.branch_telnumber);
|
|
3508
3673
|
}
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
setStorageKey() {
|
|
3512
|
-
if (typeof this.config.voucher_storage_key === 'string' &&
|
|
3513
|
-
this.config.voucher_storage_key !== '') {
|
|
3514
|
-
this.storage_key = this.config.voucher_storage_key;
|
|
3674
|
+
if (record.branch_telnumber_2.length > 0) {
|
|
3675
|
+
telnumbers.push(record.branch_telnumber_2);
|
|
3515
3676
|
}
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
if (!(data instanceof Map)) {
|
|
3519
|
-
throw new Error('Invalid map type');
|
|
3677
|
+
if (record.branch_telnumber_3.length > 0) {
|
|
3678
|
+
telnumbers.push(record.branch_telnumber_3);
|
|
3520
3679
|
}
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
const data = JSON.parse(json_data, (key, value) => {
|
|
3535
|
-
if (typeof value === 'object' && value !== null) {
|
|
3536
|
-
if (value.dataType === 'Map') {
|
|
3537
|
-
return new Map(value.value);
|
|
3538
|
-
}
|
|
3539
|
-
}
|
|
3540
|
-
return value;
|
|
3541
|
-
});
|
|
3542
|
-
if (data instanceof Map) {
|
|
3543
|
-
return data;
|
|
3680
|
+
this.contact_info = new EsolveLocationContactInfo(telnumbers, record.branch_cellnumber, record.branch_email, record.branch_fax);
|
|
3681
|
+
const monday = new EsolveLocationTradingDay(record.monday_open_time, record.monday_close_time);
|
|
3682
|
+
const tuesday = new EsolveLocationTradingDay(record.tuesday_open_time, record.tuesday_close_time);
|
|
3683
|
+
const wednesday = new EsolveLocationTradingDay(record.wednesday_open_time, record.wednesday_close_time);
|
|
3684
|
+
const thursday = new EsolveLocationTradingDay(record.thursday_open_time, record.thursday_close_time);
|
|
3685
|
+
const friday = new EsolveLocationTradingDay(record.friday_open_time, record.friday_close_time);
|
|
3686
|
+
const saturday = new EsolveLocationTradingDay(record.saturday_open_time, record.saturday_close_time);
|
|
3687
|
+
const sunday = new EsolveLocationTradingDay(record.sunday_open_time, record.sunday_close_time);
|
|
3688
|
+
const public_holiday = new EsolveLocationTradingDay(record.public_holiday_open_time, record.public_holiday_close_time);
|
|
3689
|
+
this.trading_times = new EsolveLocationTradingTimes(monday, tuesday, wednesday, thursday, friday, saturday, sunday, public_holiday, record.trading_hours_additional_info);
|
|
3690
|
+
this.geo = new EsolveLocationGEO(record.distance, record.range, record.target_description);
|
|
3691
|
+
if (record.custom_fields) {
|
|
3692
|
+
this.custom_fields = record.custom_fields;
|
|
3544
3693
|
}
|
|
3545
|
-
throw new Error('Invalid map type');
|
|
3546
3694
|
}
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3695
|
+
}
|
|
3696
|
+
|
|
3697
|
+
/**
|
|
3698
|
+
* Location object list
|
|
3699
|
+
*/
|
|
3700
|
+
class EsolveLocationList {
|
|
3701
|
+
constructor(locations, total, page) {
|
|
3702
|
+
this.locations = locations;
|
|
3703
|
+
this.total = total;
|
|
3704
|
+
this.page = page;
|
|
3556
3705
|
}
|
|
3557
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.4", ngImport: i0, type: EsolveVouchersService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
3558
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.4", ngImport: i0, type: EsolveVouchersService, providedIn: 'root' }); }
|
|
3559
3706
|
}
|
|
3560
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.4", ngImport: i0, type: EsolveVouchersService, decorators: [{
|
|
3561
|
-
type: Injectable,
|
|
3562
|
-
args: [{
|
|
3563
|
-
providedIn: 'root',
|
|
3564
|
-
}]
|
|
3565
|
-
}], ctorParameters: function () { return []; } });
|
|
3566
3707
|
|
|
3567
3708
|
// Classes
|
|
3568
3709
|
|
|
3569
|
-
|
|
3710
|
+
// Types
|
|
3711
|
+
|
|
3712
|
+
class EsolveLocationsService {
|
|
3570
3713
|
constructor() {
|
|
3571
3714
|
this.config = inject(EsolveConfigService);
|
|
3572
3715
|
this.http = inject(HttpClient);
|
|
3573
|
-
this.errorHandler = inject(EsolveErrorHandlerService);
|
|
3574
|
-
this.responseHandler = inject(EsolveResponseHandlerService);
|
|
3575
|
-
this.coupons = inject(EsolveCouponsService);
|
|
3576
|
-
this.vouchers = inject(EsolveVouchersService);
|
|
3577
|
-
this._cached_tracking = 0;
|
|
3578
3716
|
}
|
|
3579
3717
|
/**
|
|
3580
|
-
* Retrieves
|
|
3718
|
+
* Retrieves a list of stock locations
|
|
3581
3719
|
*
|
|
3582
|
-
* @returns An `Observable` with an array of
|
|
3720
|
+
* @returns An `Observable` with an array of stock locations
|
|
3583
3721
|
*/
|
|
3584
|
-
|
|
3722
|
+
getStockLocations(options) {
|
|
3585
3723
|
let params = new HttpParams();
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
}
|
|
3590
|
-
return this.http
|
|
3591
|
-
.get(`${this.config.api_url}/get-cart.php`, { params })
|
|
3592
|
-
.pipe(map$1((response) => {
|
|
3593
|
-
if (response.records === undefined) {
|
|
3594
|
-
throw response;
|
|
3595
|
-
}
|
|
3596
|
-
return this.processCart(response.records);
|
|
3597
|
-
}));
|
|
3598
|
-
}
|
|
3599
|
-
/**
|
|
3600
|
-
* Updates the cart by preforming various actions, such as adding, editing or removing items from the cart.
|
|
3601
|
-
*
|
|
3602
|
-
* @param items An array of options to update the cart
|
|
3603
|
-
* @param action The default action to preform
|
|
3604
|
-
*
|
|
3605
|
-
* @returns An `Observable` with an array of responses that gives feedback on the requested changes
|
|
3606
|
-
*/
|
|
3607
|
-
setCart(items, action = 'add') {
|
|
3608
|
-
const body = {
|
|
3609
|
-
items,
|
|
3610
|
-
action,
|
|
3611
|
-
};
|
|
3612
|
-
return this.http
|
|
3613
|
-
.post(`${this.config.api_url}/set-cart-item.php`, body, {
|
|
3614
|
-
headers: {
|
|
3615
|
-
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;',
|
|
3616
|
-
},
|
|
3617
|
-
responseType: 'json',
|
|
3618
|
-
observe: 'body',
|
|
3619
|
-
})
|
|
3620
|
-
.pipe(map$1((response) => {
|
|
3621
|
-
if (response.responses === undefined) {
|
|
3622
|
-
throw response;
|
|
3724
|
+
if (options) {
|
|
3725
|
+
if (options.page) {
|
|
3726
|
+
params = params.set('page', options.page);
|
|
3623
3727
|
}
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
}
|
|
3627
|
-
setCartEmpty(type, additional_where) {
|
|
3628
|
-
const body = {
|
|
3629
|
-
type,
|
|
3630
|
-
additional_where,
|
|
3631
|
-
};
|
|
3632
|
-
return this.http
|
|
3633
|
-
.post(`${this.config.api_url}/set-cart-empty.php`, body, {
|
|
3634
|
-
headers: {
|
|
3635
|
-
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;',
|
|
3636
|
-
},
|
|
3637
|
-
responseType: 'json',
|
|
3638
|
-
observe: 'body',
|
|
3639
|
-
})
|
|
3640
|
-
.pipe(map$1((http_response) => this.responseHandler.validateSingleHttpResponse(http_response, (response) => {
|
|
3641
|
-
this._cached_tracking = 0;
|
|
3642
|
-
return new EsolveEmptyCartResult(response);
|
|
3643
|
-
})), catchError((errorRes) => {
|
|
3644
|
-
return this.errorHandler.handleHttpPostError('set-cart-empty', errorRes);
|
|
3645
|
-
}));
|
|
3646
|
-
}
|
|
3647
|
-
/**
|
|
3648
|
-
* Retrieves the totals of the cart with all the totals calculated
|
|
3649
|
-
*
|
|
3650
|
-
* @returns An `Observable` with an object containing cart totals
|
|
3651
|
-
*/
|
|
3652
|
-
getTotals(type) {
|
|
3653
|
-
let params = new HttpParams({
|
|
3654
|
-
fromObject: {
|
|
3655
|
-
type: type ?? '',
|
|
3656
|
-
},
|
|
3657
|
-
});
|
|
3658
|
-
const vouchers = this.vouchers.getAppliedVoucherKeys();
|
|
3659
|
-
if (vouchers.length > 0) {
|
|
3660
|
-
params = params.set('vouchers', vouchers.join(','));
|
|
3661
|
-
}
|
|
3662
|
-
return this.http
|
|
3663
|
-
.get(`${this.config.api_url}/get-cart-totals.php`, { params })
|
|
3664
|
-
.pipe(map$1((response) => {
|
|
3665
|
-
if (response.records === undefined ||
|
|
3666
|
-
Array.isArray(response.records)) {
|
|
3667
|
-
throw response;
|
|
3728
|
+
if (options.rows) {
|
|
3729
|
+
params = params.set('rows', options.rows);
|
|
3668
3730
|
}
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
getTrackingCode() {
|
|
3678
|
-
return iif(() => this._cached_tracking > 0, of(this._cached_tracking), this.http
|
|
3679
|
-
.get(`${this.config.api_url}/get-checkout-tracking.php`)
|
|
3680
|
-
.pipe(map$1((response) => {
|
|
3681
|
-
if (response.records === undefined ||
|
|
3682
|
-
Array.isArray(response.records)) {
|
|
3683
|
-
throw response;
|
|
3731
|
+
if (options.sort) {
|
|
3732
|
+
const sort = options.sort;
|
|
3733
|
+
if (sort.field) {
|
|
3734
|
+
params = params.set('sort', sort.field);
|
|
3735
|
+
}
|
|
3736
|
+
if (sort.order) {
|
|
3737
|
+
params = params.set('order', sort.order);
|
|
3738
|
+
}
|
|
3684
3739
|
}
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
})));
|
|
3688
|
-
}
|
|
3689
|
-
/**
|
|
3690
|
-
* Get the data of the transaction for the analytics
|
|
3691
|
-
*
|
|
3692
|
-
* @param transaction_id ID of the transaction used in eSolve
|
|
3693
|
-
*
|
|
3694
|
-
* @returns An `Observable` with the analytics data
|
|
3695
|
-
*/
|
|
3696
|
-
getTransactionAnalyticsData(transaction_id) {
|
|
3697
|
-
return this.http
|
|
3698
|
-
.get(`${this.config.api_url}/get-transaction-analytics-data.php`, {
|
|
3699
|
-
params: {
|
|
3700
|
-
transaction_id,
|
|
3701
|
-
},
|
|
3702
|
-
})
|
|
3703
|
-
.pipe(map$1((response) => {
|
|
3704
|
-
if (response.records === undefined ||
|
|
3705
|
-
Array.isArray(response.records)) {
|
|
3706
|
-
throw response;
|
|
3740
|
+
if (options.search_phrase) {
|
|
3741
|
+
params = params.set('search_phrase', options.search_phrase);
|
|
3707
3742
|
}
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
}
|
|
3711
|
-
/**
|
|
3712
|
-
* Initiates checkout of the cart items
|
|
3713
|
-
*
|
|
3714
|
-
* @param type The cart type that needs to be checked out
|
|
3715
|
-
* @param addresses_id The ID of the delivery address
|
|
3716
|
-
* @param shipping_id The ID of the shipping method
|
|
3717
|
-
* @param payment_method_id The ID of the selected payment method
|
|
3718
|
-
* @param location_id The ID of the selected branch from with shipping needs to be calculated
|
|
3719
|
-
* @param comments Additional comments on the cart
|
|
3720
|
-
*
|
|
3721
|
-
* @returns An `Observable` with the transaction ID
|
|
3722
|
-
*/
|
|
3723
|
-
checkout(type, addresses_id, shipping_id, payment_method_id = 0, location_id = 0, comments = '', time_slot) {
|
|
3724
|
-
const body = {
|
|
3725
|
-
type,
|
|
3726
|
-
addresses_id,
|
|
3727
|
-
shipping_id,
|
|
3728
|
-
payment_method_id,
|
|
3729
|
-
location_id,
|
|
3730
|
-
comments,
|
|
3731
|
-
tracking: 0,
|
|
3732
|
-
time_slot,
|
|
3733
|
-
};
|
|
3734
|
-
return this.getTrackingCode().pipe(switchMap$1((tracking) => {
|
|
3735
|
-
if (tracking <= 0) {
|
|
3736
|
-
throw tracking;
|
|
3743
|
+
if (options.is_active) {
|
|
3744
|
+
params = params.set('is_active', options.is_active);
|
|
3737
3745
|
}
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
if (voucher_keys.length > 0) {
|
|
3741
|
-
body.vouchers = voucher_keys;
|
|
3746
|
+
if (options.dispatches_stock) {
|
|
3747
|
+
params = params.set('dispatches_stock', options.dispatches_stock);
|
|
3742
3748
|
}
|
|
3743
|
-
|
|
3744
|
-
.
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
}
|
|
3761
|
-
getCartAlternatives() {
|
|
3762
|
-
return this.http
|
|
3763
|
-
.get(`${this.config.api_url}/get-cart-alternatives.php`)
|
|
3764
|
-
.pipe(map$1((response) => {
|
|
3765
|
-
if (response.records === undefined) {
|
|
3749
|
+
if (options.province) {
|
|
3750
|
+
params = params.set('province', options.province);
|
|
3751
|
+
}
|
|
3752
|
+
if (options.country) {
|
|
3753
|
+
params = params.set('country', options.country);
|
|
3754
|
+
}
|
|
3755
|
+
if (options.filters) {
|
|
3756
|
+
let filters = options.filters;
|
|
3757
|
+
if (!Array.isArray(filters)) {
|
|
3758
|
+
filters = covertFromObj(filters);
|
|
3759
|
+
}
|
|
3760
|
+
params = convertToHttpParams(filters, params);
|
|
3761
|
+
}
|
|
3762
|
+
}
|
|
3763
|
+
return this.getLocationRecords(params).pipe(map$1((response) => {
|
|
3764
|
+
if (response.records === undefined ||
|
|
3765
|
+
response.records.length <= 0) {
|
|
3766
3766
|
throw response;
|
|
3767
3767
|
}
|
|
3768
|
-
|
|
3768
|
+
const locations = [];
|
|
3769
|
+
response.records.forEach((locationRecord) => {
|
|
3770
|
+
locations.push(this.processLocation(locationRecord));
|
|
3771
|
+
});
|
|
3772
|
+
return new EsolveLocationList(locations, +response.additional_data.total_records, options?.page ?? 0);
|
|
3769
3773
|
}));
|
|
3770
3774
|
}
|
|
3771
3775
|
/**
|
|
3772
|
-
*
|
|
3776
|
+
* Retrieves a list of stock locations using the address_id as parameter or the latitude and longitude.
|
|
3777
|
+
* Set the addresses_id to 0 and the gps coordinates in order to retrieve the locations list when the address isn't
|
|
3778
|
+
* yet saved.
|
|
3773
3779
|
*
|
|
3774
|
-
* @param
|
|
3775
|
-
* @param
|
|
3776
|
-
* @
|
|
3780
|
+
* @param addresses_id if supplied, the latitude and longitude on the address will be used.
|
|
3781
|
+
* @param latitude if supplied and address_id > 0, the value is ignored.
|
|
3782
|
+
* @param longitude if supplied and address_id > 0, the value is ignored.
|
|
3783
|
+
*
|
|
3784
|
+
* @returns An `Observable` with an array of stock locations
|
|
3777
3785
|
*/
|
|
3778
|
-
|
|
3786
|
+
getStockLocationsGeo(addresses_id = 0, latitude = 0, longitude = 0) {
|
|
3779
3787
|
return this.http
|
|
3780
|
-
.
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;',
|
|
3788
|
+
.get(`${this.config.api_url}/get-locations-geo.php`, {
|
|
3789
|
+
params: {
|
|
3790
|
+
addresses_id,
|
|
3791
|
+
latitude,
|
|
3792
|
+
longitude,
|
|
3786
3793
|
},
|
|
3787
|
-
responseType: 'json',
|
|
3788
|
-
observe: 'body',
|
|
3789
3794
|
})
|
|
3790
|
-
.pipe(map$1((
|
|
3791
|
-
|
|
3795
|
+
.pipe(map$1((response) => {
|
|
3796
|
+
if (response.records === undefined) {
|
|
3797
|
+
throw response;
|
|
3798
|
+
}
|
|
3799
|
+
return this.processStockLocations(response.records);
|
|
3792
3800
|
}));
|
|
3793
3801
|
}
|
|
3794
|
-
|
|
3802
|
+
getLocationFilters(options) {
|
|
3803
|
+
const params = new HttpParams({
|
|
3804
|
+
fromObject: {
|
|
3805
|
+
country: options.country ?? '',
|
|
3806
|
+
province: options.province ?? '',
|
|
3807
|
+
fields: options.fields.join(','),
|
|
3808
|
+
},
|
|
3809
|
+
});
|
|
3795
3810
|
return this.http
|
|
3796
|
-
.
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
})
|
|
3801
|
-
.pipe(map$1((http_response) => {
|
|
3802
|
-
if (http_response.result === undefined ||
|
|
3803
|
-
http_response.result === null ||
|
|
3804
|
-
http_response.result.status !== 'success') {
|
|
3805
|
-
throw http_response;
|
|
3811
|
+
.get(`${this.config.api_url}/get-location-filters.php`, { params })
|
|
3812
|
+
.pipe(map$1((response) => {
|
|
3813
|
+
if (response.records === undefined) {
|
|
3814
|
+
throw response;
|
|
3806
3815
|
}
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3816
|
+
const filters = [];
|
|
3817
|
+
for (const record of response.records) {
|
|
3818
|
+
let filter = null;
|
|
3819
|
+
if (record.type === 'range') {
|
|
3820
|
+
filter = new EsolveRangeFilter(record.field, +record.min, +record.max);
|
|
3821
|
+
}
|
|
3822
|
+
else if (record.type === 'single') {
|
|
3823
|
+
filter = new EsolveSingleSelectFilter(record.field, record.values);
|
|
3824
|
+
}
|
|
3825
|
+
else if (record.type === 'multiple') {
|
|
3826
|
+
filter = new EsolveMultipleSelectFilter(record.field, record.values);
|
|
3827
|
+
}
|
|
3828
|
+
if (filter) {
|
|
3829
|
+
filters.push(filter);
|
|
3830
|
+
}
|
|
3831
|
+
}
|
|
3832
|
+
return filters;
|
|
3810
3833
|
}));
|
|
3811
3834
|
}
|
|
3812
3835
|
/**
|
|
3813
|
-
*
|
|
3814
|
-
*
|
|
3815
|
-
* @param cart_item_records Records to process
|
|
3816
|
-
* @returns An array of processed cart items
|
|
3836
|
+
* Retrieves location records from HTTP params.
|
|
3837
|
+
* @param params HTTP client parameters
|
|
3817
3838
|
*/
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
if (cart_item_records) {
|
|
3821
|
-
for (const cart_item_record of cart_item_records) {
|
|
3822
|
-
cart_items.push(new EsolveCartItem(cart_item_record));
|
|
3823
|
-
}
|
|
3824
|
-
}
|
|
3825
|
-
return cart_items;
|
|
3839
|
+
getLocationRecords(params) {
|
|
3840
|
+
return this.http.get(`${this.config.api_url}/get-locations.php`, { params });
|
|
3826
3841
|
}
|
|
3827
3842
|
/**
|
|
3828
|
-
* Processes the eSolve
|
|
3843
|
+
* Processes the eSolve stock location records.
|
|
3829
3844
|
*
|
|
3830
3845
|
* @param records Records to process
|
|
3831
|
-
*
|
|
3832
|
-
* @returns A `Map` of processed cart alternatives
|
|
3846
|
+
* @returns An array of processed stock location records
|
|
3833
3847
|
*/
|
|
3834
|
-
|
|
3835
|
-
const
|
|
3848
|
+
processStockLocations(records) {
|
|
3849
|
+
const locations = [];
|
|
3836
3850
|
for (const record of records) {
|
|
3837
|
-
|
|
3851
|
+
locations.push(this.processLocation(record));
|
|
3838
3852
|
}
|
|
3839
|
-
return
|
|
3853
|
+
return locations;
|
|
3840
3854
|
}
|
|
3841
3855
|
/**
|
|
3842
|
-
* Processes the eSolve
|
|
3856
|
+
* Processes the eSolve stock item record and converts it to an object.
|
|
3843
3857
|
*
|
|
3844
|
-
* @param record
|
|
3845
|
-
* @returns Processed cart totals
|
|
3858
|
+
* @param record eSolve stock item record
|
|
3846
3859
|
*/
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
return cart_totals;
|
|
3860
|
+
processLocation(record) {
|
|
3861
|
+
return new EsolveLocation(record);
|
|
3850
3862
|
}
|
|
3851
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.4", ngImport: i0, type:
|
|
3852
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.4", ngImport: i0, type:
|
|
3863
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.4", ngImport: i0, type: EsolveLocationsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
3864
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.4", ngImport: i0, type: EsolveLocationsService, providedIn: 'root' }); }
|
|
3853
3865
|
}
|
|
3854
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.4", ngImport: i0, type:
|
|
3866
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.4", ngImport: i0, type: EsolveLocationsService, decorators: [{
|
|
3855
3867
|
type: Injectable,
|
|
3856
3868
|
args: [{
|
|
3857
3869
|
providedIn: 'root',
|
|
3858
3870
|
}]
|
|
3859
3871
|
}] });
|
|
3860
3872
|
|
|
3873
|
+
class EsolveTransactionLocation extends EsolveLocation {
|
|
3874
|
+
}
|
|
3875
|
+
|
|
3876
|
+
class EsolveTransactionPaymentMethod {
|
|
3877
|
+
constructor(id, name, description, integration_type, service_provider) {
|
|
3878
|
+
this.id = id;
|
|
3879
|
+
this.name = name;
|
|
3880
|
+
this.description = description;
|
|
3881
|
+
this.integration_type = integration_type;
|
|
3882
|
+
this.service_provider = service_provider;
|
|
3883
|
+
}
|
|
3884
|
+
}
|
|
3885
|
+
|
|
3886
|
+
class EsolveTransactionShippingMethod {
|
|
3887
|
+
constructor(id, name, delivery_category, location, description, pricing, client_to_collect) {
|
|
3888
|
+
this.id = id;
|
|
3889
|
+
this.name = name;
|
|
3890
|
+
this.delivery_category = delivery_category;
|
|
3891
|
+
this.location = location;
|
|
3892
|
+
this.description = description;
|
|
3893
|
+
this.pricing = pricing;
|
|
3894
|
+
this.client_to_collect = client_to_collect;
|
|
3895
|
+
}
|
|
3896
|
+
}
|
|
3897
|
+
|
|
3898
|
+
class EsolveTransactionUser {
|
|
3899
|
+
constructor(id, email, first_name, last_name, tel_number, cell_number) {
|
|
3900
|
+
this.id = id;
|
|
3901
|
+
this.email = email;
|
|
3902
|
+
this.first_name = first_name;
|
|
3903
|
+
this.last_name = last_name;
|
|
3904
|
+
this.tel_number = tel_number;
|
|
3905
|
+
this.cell_number = cell_number;
|
|
3906
|
+
}
|
|
3907
|
+
}
|
|
3908
|
+
|
|
3861
3909
|
class EsolveTransaction {
|
|
3862
3910
|
constructor(record) {
|
|
3863
3911
|
// Transaction Items
|
|
@@ -4035,6 +4083,16 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.4", ngImpor
|
|
|
4035
4083
|
}]
|
|
4036
4084
|
}], ctorParameters: function () { return []; } });
|
|
4037
4085
|
|
|
4086
|
+
class EsolveSessionShippingUpdateResult extends EsolveResponseResult {
|
|
4087
|
+
constructor(response) {
|
|
4088
|
+
super(response);
|
|
4089
|
+
if (typeof response.esolve_id === 'string') {
|
|
4090
|
+
throw new Error('Invalid response id.');
|
|
4091
|
+
}
|
|
4092
|
+
this.shipping_updated = response.esolve_id > 0;
|
|
4093
|
+
}
|
|
4094
|
+
}
|
|
4095
|
+
|
|
4038
4096
|
class EsolveAccountService {
|
|
4039
4097
|
get user_id() {
|
|
4040
4098
|
return this._user_id;
|
|
@@ -4170,9 +4228,12 @@ class EsolveAccountService {
|
|
|
4170
4228
|
})
|
|
4171
4229
|
.pipe(map$1((http_response) => this.responseHandler.validateSingleHttpResponse(http_response, (response) => {
|
|
4172
4230
|
if (response.auto_login) {
|
|
4231
|
+
const session_data = response.session_data;
|
|
4173
4232
|
this.sessionService.handleUpdateSession({
|
|
4174
4233
|
user_id: +response.esolve_id,
|
|
4175
|
-
location_id: +
|
|
4234
|
+
location_id: +session_data.location_id,
|
|
4235
|
+
addresses_id: +session_data.addresses_id,
|
|
4236
|
+
shipping_id: +session_data.shipping_id,
|
|
4176
4237
|
});
|
|
4177
4238
|
}
|
|
4178
4239
|
return new EsolveRegistrationResult(response);
|
|
@@ -4224,6 +4285,8 @@ class EsolveAccountService {
|
|
|
4224
4285
|
this.sessionService.handleUpdateSession({
|
|
4225
4286
|
user_id: +response.esolve_id,
|
|
4226
4287
|
location_id: +response.location_id,
|
|
4288
|
+
addresses_id: +response.addresses_id,
|
|
4289
|
+
shipping_id: +response.shipping_id,
|
|
4227
4290
|
});
|
|
4228
4291
|
}
|
|
4229
4292
|
return new EsolveAccountConfirmationResult(response);
|
|
@@ -4258,9 +4321,12 @@ class EsolveAccountService {
|
|
|
4258
4321
|
})
|
|
4259
4322
|
.pipe(map$1((http_response) => this.responseHandler.validateSingleHttpResponse(http_response, (response) => {
|
|
4260
4323
|
if (!response.login_required) {
|
|
4324
|
+
const session_data = response.session_data;
|
|
4261
4325
|
this.sessionService.handleUpdateSession({
|
|
4262
4326
|
user_id: +response.esolve_id,
|
|
4263
|
-
location_id: +
|
|
4327
|
+
location_id: +session_data.location_id,
|
|
4328
|
+
addresses_id: +session_data.addresses_id,
|
|
4329
|
+
shipping_id: +session_data.shipping_id,
|
|
4264
4330
|
});
|
|
4265
4331
|
}
|
|
4266
4332
|
return new EsolveResetPasswordResult(response);
|
|
@@ -4274,6 +4340,48 @@ class EsolveAccountService {
|
|
|
4274
4340
|
updateLocationOnErp(erp) {
|
|
4275
4341
|
return this.updateUserLocation({ erp });
|
|
4276
4342
|
}
|
|
4343
|
+
updateSessionAddress(addresses_id) {
|
|
4344
|
+
return this.http
|
|
4345
|
+
.post(`${this.config.api_url}/set-session-address.php`, {
|
|
4346
|
+
addresses_id,
|
|
4347
|
+
}, {
|
|
4348
|
+
headers: {
|
|
4349
|
+
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;',
|
|
4350
|
+
},
|
|
4351
|
+
responseType: 'json',
|
|
4352
|
+
observe: 'body',
|
|
4353
|
+
})
|
|
4354
|
+
.pipe(map$1((http_response) => this.responseHandler.validateSingleHttpResponse(http_response, (response) => {
|
|
4355
|
+
if (typeof response.esolve_id === 'string') {
|
|
4356
|
+
throw new Error('Invalid response id.');
|
|
4357
|
+
}
|
|
4358
|
+
this.sessionService.handleUpdateSession({
|
|
4359
|
+
addresses_id: +response.esolve_id,
|
|
4360
|
+
});
|
|
4361
|
+
return new EsolveSessionAddressUpdateResult(response);
|
|
4362
|
+
})));
|
|
4363
|
+
}
|
|
4364
|
+
updateSessionShipping(shipping_id) {
|
|
4365
|
+
return this.http
|
|
4366
|
+
.post(`${this.config.api_url}/set-session-shipping.php`, {
|
|
4367
|
+
shipping_id,
|
|
4368
|
+
}, {
|
|
4369
|
+
headers: {
|
|
4370
|
+
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;',
|
|
4371
|
+
},
|
|
4372
|
+
responseType: 'json',
|
|
4373
|
+
observe: 'body',
|
|
4374
|
+
})
|
|
4375
|
+
.pipe(map$1((http_response) => this.responseHandler.validateSingleHttpResponse(http_response, (response) => {
|
|
4376
|
+
if (typeof response.esolve_id === 'string') {
|
|
4377
|
+
throw new Error('Invalid response id.');
|
|
4378
|
+
}
|
|
4379
|
+
this.sessionService.handleUpdateSession({
|
|
4380
|
+
shipping_id: +response.esolve_id,
|
|
4381
|
+
});
|
|
4382
|
+
return new EsolveSessionShippingUpdateResult(response);
|
|
4383
|
+
})));
|
|
4384
|
+
}
|
|
4277
4385
|
/**
|
|
4278
4386
|
* @deprecated Use EsolveTransactionsService for future transaction requests
|
|
4279
4387
|
*/
|
|
@@ -4424,7 +4532,7 @@ class EsolveAccountService {
|
|
|
4424
4532
|
throw new Error('Invalid response id.');
|
|
4425
4533
|
}
|
|
4426
4534
|
this.sessionService.handleUpdateSession({
|
|
4427
|
-
location_id: response.esolve_id,
|
|
4535
|
+
location_id: +response.esolve_id,
|
|
4428
4536
|
});
|
|
4429
4537
|
return new EsolveLocationUpdateResult(response);
|
|
4430
4538
|
})));
|
|
@@ -6901,7 +7009,7 @@ class EsolveDeviceService {
|
|
|
6901
7009
|
device,
|
|
6902
7010
|
};
|
|
6903
7011
|
return this.http
|
|
6904
|
-
.post(`${this.config.api_url}/set-
|
|
7012
|
+
.post(`${this.config.api_url}/set-device.php`, body, {
|
|
6905
7013
|
headers: {
|
|
6906
7014
|
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;',
|
|
6907
7015
|
},
|
|
@@ -6909,7 +7017,7 @@ class EsolveDeviceService {
|
|
|
6909
7017
|
observe: 'body',
|
|
6910
7018
|
})
|
|
6911
7019
|
.pipe(map((http_response) => this.responseHandler.validateSingleHttpResponse(http_response, (response) => new EsolveSetDeviceResult(response))), catchError$1((errorRes) => {
|
|
6912
|
-
return this.errorHandler.handleHttpPostError('set-
|
|
7020
|
+
return this.errorHandler.handleHttpPostError('set-device', errorRes);
|
|
6913
7021
|
}));
|
|
6914
7022
|
}
|
|
6915
7023
|
getUserDevices(options) {
|
|
@@ -6961,5 +7069,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.4", ngImpor
|
|
|
6961
7069
|
* Generated bundle index. Do not edit.
|
|
6962
7070
|
*/
|
|
6963
7071
|
|
|
6964
|
-
export { ESOLVE_CONNECT_CONFIG, ESOLVE_EURUS_AUTO_LOGIN, EsolveAccountConfirmationResult, EsolveAccountService, EsolveAdditionalStockImage, EsolveAddress, EsolveAddressResult, EsolveAsset, EsolveAssetsService, EsolveAuthInterceptorService, EsolveAuthService, EsolveBankingDetails, EsolveBanner, EsolveBannerImage, EsolveBannerImageHotspot, EsolveBannerService, EsolveCartAlternative, EsolveCartItem, EsolveCartService, EsolveCartStockItem, EsolveCartTotals, EsolveCategoryTreeItem, EsolveCategoryTreeService, EsolveCdnSrcDirective, EsolveChangePasswordResult, EsolveCheckoutResult, EsolveColour, EsolveConfigService, EsolveCookieService, EsolveCoupon, EsolveCouponsService, EsolveDependantItem, EsolveDeviceService, EsolveEmptyCartResult, EsolveEmptyWishlistResult, EsolveEnquiryResult, EsolveEnquiryService, EsolveErrorHandlerService, esolveFilterFactory as EsolveFilterFactory, EsolveGeocodeAddressResult, EsolveGeocodeCoordsResult, EsolveGeocodeResult, EsolveGeocoderService, EsolveHttpError, EsolveLinkedAsset, EsolveLinkedStockItem, EsolveList, EsolveLocation, EsolveLocationAddress, EsolveLocationContactInfo, EsolveLocationGEO, EsolveLocationList, EsolveLocationPOBoxAddress, EsolveLocationTradingDay, EsolveLocationTradingTimes, EsolveLocationUpdateResult, 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, EsolveSessionMetadataService, EsolveSessionService, EsolveSetDeviceResult, EsolveShippingCost, EsolveShippingMethod, EsolveShippingService, EsolveShippingTotals, EsolveSingleSelectFilter, EsolveSpecial, EsolveSpecialDates, EsolveSpecialImage, EsolveSpecialImageCollection, EsolveSpecialsService, EsolveStatement, EsolveStatementAgeing, EsolveStatementBalances, EsolveStatementTransaction, EsolveStockBadge, EsolveStockGroup, EsolveStockGroupItem, EsolveStockImage, EsolveStockImageCollection, EsolveStockItem, EsolveStockItemBase, EsolveStockItemList, EsolveStockLeadTimes, EsolveStockPrice, EsolveStockService, EsolveSupplier, EsolveSuppliersService, EsolveTag, EsolveTagsService, EsolveTimeSlot, EsolveTimeSlotConfig, EsolveTimeSlotDate, EsolveTimeSlotDays, EsolveTimeSlotTimes, EsolveToggleFilter, EsolveTopic, EsolveTopicService, EsolveTransaction, EsolveTransactionAddress, EsolveTransactionAnalyticsData, EsolveTransactionClient, EsolveTransactionItem, EsolveTransactionItemPrice, EsolveTransactionList, EsolveTransactionLocation, EsolveTransactionPaymentMethod, EsolveTransactionShippingMethod, EsolveTransactionUser, EsolveTransactionsService, EsolveUserAccount, EsolveUserAccountBusiness, EsolveUserAccountContact, EsolveUserAccountResult, EsolveUserClientAccount, EsolveUserClientAccountBalances, EsolveUserDevice, EsolveVaultItem, EsolveVaultItemResult, EsolveVoucher, EsolveVouchersService, EsolveWishlistItem, EsolveWishlistService, NgEsolveConnectModule, esolveHexHash, isEsolveCdnPath, isFtgCdnPath, isLegacyEsolveCdnPath, processEsolveImageSrc, provideEsolveImageLoader, provideNgEsolveConnect };
|
|
7072
|
+
export { ESOLVE_CONNECT_CONFIG, ESOLVE_EURUS_AUTO_LOGIN, EsolveAccountConfirmationResult, EsolveAccountService, EsolveAdditionalStockImage, EsolveAddress, EsolveAddressResult, EsolveAsset, EsolveAssetsService, EsolveAuthInterceptorService, EsolveAuthService, EsolveBankingDetails, EsolveBanner, EsolveBannerImage, EsolveBannerImageHotspot, EsolveBannerService, EsolveCartAlternative, EsolveCartItem, EsolveCartService, EsolveCartStockItem, EsolveCartTotals, EsolveCategoryTreeItem, EsolveCategoryTreeService, EsolveCdnSrcDirective, EsolveChangePasswordResult, EsolveCheckoutResult, EsolveColour, EsolveConfigService, EsolveCookieService, EsolveCoupon, EsolveCouponsService, EsolveDependantItem, EsolveDeviceService, EsolveEmptyCartResult, EsolveEmptyWishlistResult, EsolveEnquiryResult, EsolveEnquiryService, EsolveErrorHandlerService, esolveFilterFactory as EsolveFilterFactory, EsolveGeocodeAddressResult, EsolveGeocodeCoordsResult, EsolveGeocodeResult, EsolveGeocoderService, EsolveHttpError, EsolveLinkedAsset, EsolveLinkedStockItem, EsolveList, EsolveLocation, EsolveLocationAddress, EsolveLocationContactInfo, EsolveLocationGEO, EsolveLocationList, EsolveLocationPOBoxAddress, EsolveLocationTradingDay, EsolveLocationTradingTimes, EsolveLocationUpdateResult, 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, EsolveSessionAddressUpdateResult, EsolveSessionMetadataService, EsolveSessionService, EsolveSessionShippingUpdateResult, EsolveSetDeviceResult, EsolveShippingCost, EsolveShippingMethod, EsolveShippingService, EsolveShippingTotals, EsolveSingleSelectFilter, EsolveSpecial, EsolveSpecialDates, EsolveSpecialImage, EsolveSpecialImageCollection, EsolveSpecialsService, EsolveStatement, EsolveStatementAgeing, EsolveStatementBalances, EsolveStatementTransaction, EsolveStockBadge, EsolveStockGroup, EsolveStockGroupItem, EsolveStockImage, EsolveStockImageCollection, EsolveStockItem, EsolveStockItemBase, EsolveStockItemList, EsolveStockLeadTimes, EsolveStockPrice, EsolveStockService, EsolveSupplier, EsolveSuppliersService, EsolveTag, EsolveTagsService, EsolveTimeSlot, EsolveTimeSlotConfig, EsolveTimeSlotDate, EsolveTimeSlotDays, EsolveTimeSlotTimes, EsolveToggleFilter, EsolveTopic, EsolveTopicService, EsolveTransaction, EsolveTransactionAddress, EsolveTransactionAnalyticsData, EsolveTransactionClient, EsolveTransactionItem, EsolveTransactionItemPrice, EsolveTransactionList, EsolveTransactionLocation, EsolveTransactionPaymentMethod, EsolveTransactionShippingMethod, EsolveTransactionUser, EsolveTransactionsService, EsolveUserAccount, EsolveUserAccountBusiness, EsolveUserAccountContact, EsolveUserAccountResult, EsolveUserClientAccount, EsolveUserClientAccountBalances, EsolveUserDevice, EsolveVaultItem, EsolveVaultItemResult, EsolveVoucher, EsolveVouchersService, EsolveWishlistItem, EsolveWishlistService, NgEsolveConnectModule, esolveHexHash, isEsolveCdnPath, isFtgCdnPath, isLegacyEsolveCdnPath, processEsolveImageSrc, provideEsolveImageLoader, provideNgEsolveConnect };
|
|
6965
7073
|
//# sourceMappingURL=esolve-ng-esolve-connect.mjs.map
|