@infrab4a/connect-angular 3.4.0-beta.2 → 3.4.0-beta.3

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.
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs'), require('rxjs/operators'), require('@angular/fire/auth'), require('@infrab4a/connect'), require('js-cookie'), require('ts-custom-error'), require('@angular/fire/firestore'), require('@angular/common/http'), require('@angular/fire')) :
3
- typeof define === 'function' && define.amd ? define('@infrab4a/connect-angular', ['exports', '@angular/core', 'rxjs', 'rxjs/operators', '@angular/fire/auth', '@infrab4a/connect', 'js-cookie', 'ts-custom-error', '@angular/fire/firestore', '@angular/common/http', '@angular/fire'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.infrab4a = global.infrab4a || {}, global.infrab4a["connect-angular"] = {}), global.ng.core, global.rxjs, global.rxjs.operators, global.ng.fire.auth, global["@infrab4a/connect"], global["js-cookie"], global["ts-custom-error"], global.ng.fire.firestore, global.ng.common.http, global.ng.fire));
5
- })(this, (function (exports, i0, rxjs, operators, i1, i1$1, cookie, tsCustomError, i1$2, i1$3, fire) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs'), require('rxjs/operators'), require('@angular/fire/auth'), require('@infrab4a/connect'), require('js-cookie'), require('ts-custom-error'), require('@angular/fire/firestore'), require('@infrab4a/connect/src'), require('@angular/common/http'), require('@angular/fire')) :
3
+ typeof define === 'function' && define.amd ? define('@infrab4a/connect-angular', ['exports', '@angular/core', 'rxjs', 'rxjs/operators', '@angular/fire/auth', '@infrab4a/connect', 'js-cookie', 'ts-custom-error', '@angular/fire/firestore', '@infrab4a/connect/src', '@angular/common/http', '@angular/fire'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.infrab4a = global.infrab4a || {}, global.infrab4a["connect-angular"] = {}), global.ng.core, global.rxjs, global.rxjs.operators, global.ng.fire.auth, global["@infrab4a/connect"], global["js-cookie"], global["ts-custom-error"], global.ng.fire.firestore, global.src, global.ng.common.http, global.ng.fire));
5
+ })(this, (function (exports, i0, rxjs, operators, i1, i1$1, cookie, tsCustomError, i1$2, src, i1$3, fire) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -31,7 +31,7 @@
31
31
  var i1__namespace$2 = /*#__PURE__*/_interopNamespace(i1$2);
32
32
  var i1__namespace$3 = /*#__PURE__*/_interopNamespace(i1$3);
33
33
 
34
- /*! *****************************************************************************
34
+ /******************************************************************************
35
35
  Copyright (c) Microsoft Corporation.
36
36
 
37
37
  Permission to use, copy, modify, and/or distribute this software for any
@@ -98,6 +98,64 @@
98
98
  function __param(paramIndex, decorator) {
99
99
  return function (target, key) { decorator(target, key, paramIndex); };
100
100
  }
101
+ function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
102
+ function accept(f) { if (f !== void 0 && typeof f !== "function")
103
+ throw new TypeError("Function expected"); return f; }
104
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
105
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
106
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
107
+ var _, done = false;
108
+ for (var i = decorators.length - 1; i >= 0; i--) {
109
+ var context = {};
110
+ for (var p in contextIn)
111
+ context[p] = p === "access" ? {} : contextIn[p];
112
+ for (var p in contextIn.access)
113
+ context.access[p] = contextIn.access[p];
114
+ context.addInitializer = function (f) { if (done)
115
+ throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
116
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
117
+ if (kind === "accessor") {
118
+ if (result === void 0)
119
+ continue;
120
+ if (result === null || typeof result !== "object")
121
+ throw new TypeError("Object expected");
122
+ if (_ = accept(result.get))
123
+ descriptor.get = _;
124
+ if (_ = accept(result.set))
125
+ descriptor.set = _;
126
+ if (_ = accept(result.init))
127
+ initializers.push(_);
128
+ }
129
+ else if (_ = accept(result)) {
130
+ if (kind === "field")
131
+ initializers.push(_);
132
+ else
133
+ descriptor[key] = _;
134
+ }
135
+ }
136
+ if (target)
137
+ Object.defineProperty(target, contextIn.name, descriptor);
138
+ done = true;
139
+ }
140
+ ;
141
+ function __runInitializers(thisArg, initializers, value) {
142
+ var useValue = arguments.length > 2;
143
+ for (var i = 0; i < initializers.length; i++) {
144
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
145
+ }
146
+ return useValue ? value : void 0;
147
+ }
148
+ ;
149
+ function __propKey(x) {
150
+ return typeof x === "symbol" ? x : "".concat(x);
151
+ }
152
+ ;
153
+ function __setFunctionName(f, name, prefix) {
154
+ if (typeof name === "symbol")
155
+ name = name.description ? "[".concat(name.description, "]") : "";
156
+ return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
157
+ }
158
+ ;
101
159
  function __metadata(metadataKey, metadataValue) {
102
160
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
103
161
  return Reflect.metadata(metadataKey, metadataValue);
@@ -129,7 +187,7 @@
129
187
  function step(op) {
130
188
  if (f)
131
189
  throw new TypeError("Generator is already executing.");
132
- while (_)
190
+ while (g && (g = 0, op[0] && (_ = 0)), _)
133
191
  try {
134
192
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
135
193
  return t;
@@ -193,7 +251,11 @@
193
251
  var __createBinding = Object.create ? (function (o, m, k, k2) {
194
252
  if (k2 === undefined)
195
253
  k2 = k;
196
- Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
254
+ var desc = Object.getOwnPropertyDescriptor(m, k);
255
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
256
+ desc = { enumerable: true, get: function () { return m[k]; } };
257
+ }
258
+ Object.defineProperty(o, k2, desc);
197
259
  }) : (function (o, m, k, k2) {
198
260
  if (k2 === undefined)
199
261
  k2 = k;
@@ -293,7 +355,7 @@
293
355
  function __asyncDelegator(o) {
294
356
  var i, p;
295
357
  return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
296
- function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
358
+ function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }
297
359
  }
298
360
  function __asyncValues(o) {
299
361
  if (!Symbol.asyncIterator)
@@ -347,6 +409,11 @@
347
409
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
348
410
  throw new TypeError("Cannot write private member to an object whose class did not declare it");
349
411
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
412
+ }
413
+ function __classPrivateFieldIn(state, receiver) {
414
+ if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function"))
415
+ throw new TypeError("Cannot use 'in' operator on non-object");
416
+ return typeof state === "function" ? receiver === state : state.has(receiver);
350
417
  }
351
418
 
352
419
  var AuthService = /** @class */ (function () {
@@ -1223,51 +1290,90 @@
1223
1290
  } });
1224
1291
 
1225
1292
  var ShippingService = /** @class */ (function () {
1226
- function ShippingService(http, apiUrl) {
1293
+ function ShippingService(http, homeService, apiUrl) {
1227
1294
  this.http = http;
1295
+ this.homeService = homeService;
1228
1296
  this.apiUrl = apiUrl;
1229
1297
  }
1230
- ShippingService.prototype.getMensShippingMethods = function (zip, weightGrams, totalPrice, personId, subscriptionPlan) {
1298
+ ShippingService.prototype.getMensShippingMethods = function (zip, weightGrams, totalPrice, personId, shop, subscriptionPlan) {
1299
+ var _this = this;
1300
+ rxjs.combineLatest([
1301
+ this.homeService.getHomeData(),
1302
+ this.http.get(this.apiUrl + "open/checkshippingcompany?personId=" + personId + "&postalCode=" + zip + "&weightGrams=" + weightGrams)
1303
+ ]).pipe(operators.map(function (datas, shippings) { return console.log('combineLatest', datas, shippings); }));
1231
1304
  return this.http.get(this.apiUrl + "open/checkshippingcompany?personId=" + personId + "&postalCode=" + zip + "&weightGrams=" + weightGrams)
1232
- .pipe(operators.map(function (data) { return data.result; }), operators.map(function (shippingMethods) {
1233
- var shippingMethodsResponse = [];
1234
- if (!shippingMethods.length)
1235
- return [];
1236
- if (totalPrice >= 200) {
1237
- return shippingMethods.map(function (s) {
1238
- if (s.serviceName !== 'Same Day')
1239
- return Object.assign(Object.assign({}, s), { totalPrice: 0 });
1240
- else
1241
- return s;
1242
- });
1243
- }
1244
- if (subscriptionPlan && subscriptionPlan == 'SELECT') {
1245
- return shippingMethods.map(function (s) {
1246
- if (s.serviceName !== 'Same Day')
1247
- return Object.assign(Object.assign({}, s), { totalPrice: 0 });
1248
- else
1249
- return s;
1250
- });
1251
- }
1252
- if (subscriptionPlan && subscriptionPlan == 'PRIME') {
1253
- return shippingMethods.map(function (s) {
1254
- if (s.serviceName !== 'Same Day')
1255
- return Object.assign(Object.assign({}, s), { totalPrice: s.totalPrice / 2 });
1256
- else
1257
- return s;
1258
- });
1259
- }
1260
- return shippingMethodsResponse;
1261
- }));
1305
+ .pipe(operators.map(function (data) { return data.result; }), operators.map(function (shippingMethods) { return __awaiter(_this, void 0, void 0, function () {
1306
+ var shippingMethodsResponse, datas;
1307
+ return __generator(this, function (_a) {
1308
+ switch (_a.label) {
1309
+ case 0:
1310
+ shippingMethodsResponse = shippingMethods;
1311
+ console.log('shippingMethods', shippingMethods);
1312
+ if (!shippingMethods.length)
1313
+ return [2 /*return*/, []];
1314
+ return [4 /*yield*/, this.homeService.getHomeData().toPromise().then(function (data) { return data.sameDayNotAvaliable; })];
1315
+ case 1:
1316
+ datas = _a.sent();
1317
+ if (this.isHolidays(datas)) {
1318
+ shippingMethodsResponse = shippingMethods.filter(function (method) { return method.ShippingCompanyName !== 'Same Day'; });
1319
+ }
1320
+ if (totalPrice >= 200 || this.isFreeShippingBySubscription(shop, subscriptionPlan)) {
1321
+ return [2 /*return*/, shippingMethodsResponse.map(function (s) {
1322
+ if (s.serviceName !== 'Same Day')
1323
+ return Object.assign(Object.assign({}, s), { totalPrice: 0 });
1324
+ else
1325
+ return s;
1326
+ })];
1327
+ }
1328
+ if (this.isFreeShippingBySubscription(shop, subscriptionPlan)) {
1329
+ return [2 /*return*/, shippingMethodsResponse.map(function (s) {
1330
+ if (s.serviceName !== 'Same Day')
1331
+ return Object.assign(Object.assign({}, s), { totalPrice: s.totalPrice / 2 });
1332
+ else
1333
+ return s;
1334
+ })];
1335
+ }
1336
+ return [2 /*return*/, shippingMethodsResponse];
1337
+ }
1338
+ });
1339
+ }); }));
1340
+ };
1341
+ ShippingService.prototype.isFreeShippingBySubscription = function (shop, subscriptionPlan) {
1342
+ if (!subscriptionPlan)
1343
+ return false;
1344
+ if (shop == src.Shops.MENSMARKET && subscriptionPlan == 'SELECT') {
1345
+ return true;
1346
+ }
1347
+ return false;
1348
+ };
1349
+ ShippingService.prototype.isHalfShippingBySubscription = function (shop, subscriptionPlan) {
1350
+ if (!subscriptionPlan)
1351
+ return false;
1352
+ if (shop == src.Shops.MENSMARKET && subscriptionPlan == 'PRIME') {
1353
+ return true;
1354
+ }
1355
+ return false;
1356
+ };
1357
+ ShippingService.prototype.isHolidays = function (datas) {
1358
+ var today = new Date();
1359
+ for (var key in datas) {
1360
+ var start = new Date(today.getFullYear() + "-" + datas[key].beginDate);
1361
+ var end = new Date(today.getFullYear() + "-" + datas[key].endDate);
1362
+ if (start > end)
1363
+ end = new Date(today.getFullYear() + 1 + "-" + datas[key].endDate);
1364
+ if (today >= start && today <= end)
1365
+ return true;
1366
+ }
1367
+ return false;
1262
1368
  };
1263
1369
  return ShippingService;
1264
1370
  }());
1265
- ShippingService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: ShippingService, deps: [{ token: i1__namespace$3.HttpClient }, { token: API_URL }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1371
+ ShippingService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: ShippingService, deps: [{ token: i1__namespace$3.HttpClient }, { token: HomeShopService }, { token: API_URL }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1266
1372
  ShippingService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: ShippingService });
1267
1373
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: ShippingService, decorators: [{
1268
1374
  type: i0.Injectable
1269
1375
  }], ctorParameters: function () {
1270
- return [{ type: i1__namespace$3.HttpClient }, { type: undefined, decorators: [{
1376
+ return [{ type: i1__namespace$3.HttpClient }, { type: HomeShopService }, { type: undefined, decorators: [{
1271
1377
  type: i0.Inject,
1272
1378
  args: [API_URL]
1273
1379
  }] }];