@labdigital/commercetools-mock 0.5.17 → 0.5.18
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/dist/commercetools-mock.cjs.development.js +19 -4
- package/dist/commercetools-mock.cjs.development.js.map +1 -1
- package/dist/commercetools-mock.cjs.production.min.js +1 -1
- package/dist/commercetools-mock.cjs.production.min.js.map +1 -1
- package/dist/commercetools-mock.esm.js +19 -4
- package/dist/commercetools-mock.esm.js.map +1 -1
- package/dist/repositories/customer.d.ts +1 -0
- package/dist/services/my-customer.d.ts +12 -0
- package/dist/services/shipping-method.d.ts +2 -1
- package/dist/types.d.ts +1 -1
- package/package.json +2 -16
- package/src/ctMock.ts +2 -0
- package/src/repositories/customer.ts +9 -1
- package/src/repositories/discount-code.ts +0 -1
- package/src/repositories/project.ts +0 -1
- package/src/services/abstract.ts +0 -1
- package/src/services/my-customer.test.ts +51 -0
- package/src/services/my-customer.ts +46 -0
- package/src/services/shipping-method.test.ts +27 -0
- package/src/services/shipping-method.ts +6 -1
- package/src/types.ts +5 -1
|
@@ -17,6 +17,7 @@ var bodyParser = _interopDefault(require('body-parser'));
|
|
|
17
17
|
var crypto = require('crypto');
|
|
18
18
|
var uuid = require('uuid');
|
|
19
19
|
var deepEqual = _interopDefault(require('deep-equal'));
|
|
20
|
+
var myCustomer = require('services/my-customer');
|
|
20
21
|
|
|
21
22
|
const parseExpandClause = clause => {
|
|
22
23
|
const result = {
|
|
@@ -1005,7 +1006,6 @@ class AbstractService {
|
|
|
1005
1006
|
return response.status(404).send();
|
|
1006
1007
|
}
|
|
1007
1008
|
|
|
1008
|
-
console.log(JSON.stringify(result, null, 4));
|
|
1009
1009
|
return response.status(200).send(result);
|
|
1010
1010
|
}
|
|
1011
1011
|
|
|
@@ -1814,7 +1814,7 @@ class CustomerRepository extends AbstractResourceRepository {
|
|
|
1814
1814
|
create(projectKey, draft) {
|
|
1815
1815
|
const resource = { ...getBaseResourceProperties(),
|
|
1816
1816
|
email: draft.email,
|
|
1817
|
-
password: draft.password,
|
|
1817
|
+
password: Buffer.from(draft.password).toString('base64'),
|
|
1818
1818
|
isEmailVerified: draft.isEmailVerified || false,
|
|
1819
1819
|
addresses: []
|
|
1820
1820
|
};
|
|
@@ -1822,6 +1822,17 @@ class CustomerRepository extends AbstractResourceRepository {
|
|
|
1822
1822
|
return resource;
|
|
1823
1823
|
}
|
|
1824
1824
|
|
|
1825
|
+
getMe(projectKey) {
|
|
1826
|
+
const results = this._storage.query(projectKey, this.getTypeId(), {}); // grab the first customer you can find
|
|
1827
|
+
|
|
1828
|
+
|
|
1829
|
+
if (results.count > 0) {
|
|
1830
|
+
return results.results[0];
|
|
1831
|
+
}
|
|
1832
|
+
|
|
1833
|
+
return;
|
|
1834
|
+
}
|
|
1835
|
+
|
|
1825
1836
|
}
|
|
1826
1837
|
|
|
1827
1838
|
class CustomerService extends AbstractService {
|
|
@@ -1997,7 +2008,6 @@ class DiscountCodeRepository extends AbstractResourceRepository {
|
|
|
1997
2008
|
}
|
|
1998
2009
|
|
|
1999
2010
|
create(projectKey, draft) {
|
|
2000
|
-
console.log(draft);
|
|
2001
2011
|
const resource = { ...getBaseResourceProperties(),
|
|
2002
2012
|
applicationVersion: 1,
|
|
2003
2013
|
cartDiscounts: draft.cartDiscounts.map(obj => ({
|
|
@@ -3085,7 +3095,6 @@ class ProjectRepository extends AbstractRepository {
|
|
|
3085
3095
|
changeCartsConfiguration: (projectKey, resource, {
|
|
3086
3096
|
cartsConfiguration
|
|
3087
3097
|
}) => {
|
|
3088
|
-
console.log(cartsConfiguration);
|
|
3089
3098
|
resource.carts = cartsConfiguration || {
|
|
3090
3099
|
countryTaxRateFallbackEnabled: false,
|
|
3091
3100
|
deleteDaysAfterLastModification: 90
|
|
@@ -3289,12 +3298,17 @@ class ShippingMethodService extends AbstractService {
|
|
|
3289
3298
|
constructor(parent, storage) {
|
|
3290
3299
|
super(parent);
|
|
3291
3300
|
this.repository = new ShippingMethodRepository(storage);
|
|
3301
|
+
this.registerRoutes(parent);
|
|
3292
3302
|
}
|
|
3293
3303
|
|
|
3294
3304
|
getBasePath() {
|
|
3295
3305
|
return 'shipping-methods';
|
|
3296
3306
|
}
|
|
3297
3307
|
|
|
3308
|
+
extraRoutes(parent) {
|
|
3309
|
+
parent.get('/matching-cart', this.get.bind(this));
|
|
3310
|
+
}
|
|
3311
|
+
|
|
3298
3312
|
}
|
|
3299
3313
|
|
|
3300
3314
|
class ShoppingListRepository extends AbstractResourceRepository {
|
|
@@ -3924,6 +3938,7 @@ class CommercetoolsMock {
|
|
|
3924
3938
|
order: new OrderService(projectRouter, this._storage),
|
|
3925
3939
|
payment: new PaymentService(projectRouter, this._storage),
|
|
3926
3940
|
'my-cart': new MyCartService(projectRouter, this._storage),
|
|
3941
|
+
'my-customer': new myCustomer.MyCustomerService(projectRouter, this._storage),
|
|
3927
3942
|
'my-payment': new MyPaymentService(projectRouter, this._storage),
|
|
3928
3943
|
'shipping-method': new ShippingMethodService(projectRouter, this._storage),
|
|
3929
3944
|
'product-type': new ProductTypeService(projectRouter, this._storage),
|