@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
|
@@ -10,6 +10,7 @@ import bodyParser from 'body-parser';
|
|
|
10
10
|
import { randomBytes } from 'crypto';
|
|
11
11
|
import { v4 } from 'uuid';
|
|
12
12
|
import deepEqual from 'deep-equal';
|
|
13
|
+
import { MyCustomerService } from 'services/my-customer';
|
|
13
14
|
|
|
14
15
|
const parseExpandClause = clause => {
|
|
15
16
|
const result = {
|
|
@@ -998,7 +999,6 @@ class AbstractService {
|
|
|
998
999
|
return response.status(404).send();
|
|
999
1000
|
}
|
|
1000
1001
|
|
|
1001
|
-
console.log(JSON.stringify(result, null, 4));
|
|
1002
1002
|
return response.status(200).send(result);
|
|
1003
1003
|
}
|
|
1004
1004
|
|
|
@@ -1807,7 +1807,7 @@ class CustomerRepository extends AbstractResourceRepository {
|
|
|
1807
1807
|
create(projectKey, draft) {
|
|
1808
1808
|
const resource = { ...getBaseResourceProperties(),
|
|
1809
1809
|
email: draft.email,
|
|
1810
|
-
password: draft.password,
|
|
1810
|
+
password: Buffer.from(draft.password).toString('base64'),
|
|
1811
1811
|
isEmailVerified: draft.isEmailVerified || false,
|
|
1812
1812
|
addresses: []
|
|
1813
1813
|
};
|
|
@@ -1815,6 +1815,17 @@ class CustomerRepository extends AbstractResourceRepository {
|
|
|
1815
1815
|
return resource;
|
|
1816
1816
|
}
|
|
1817
1817
|
|
|
1818
|
+
getMe(projectKey) {
|
|
1819
|
+
const results = this._storage.query(projectKey, this.getTypeId(), {}); // grab the first customer you can find
|
|
1820
|
+
|
|
1821
|
+
|
|
1822
|
+
if (results.count > 0) {
|
|
1823
|
+
return results.results[0];
|
|
1824
|
+
}
|
|
1825
|
+
|
|
1826
|
+
return;
|
|
1827
|
+
}
|
|
1828
|
+
|
|
1818
1829
|
}
|
|
1819
1830
|
|
|
1820
1831
|
class CustomerService extends AbstractService {
|
|
@@ -1990,7 +2001,6 @@ class DiscountCodeRepository extends AbstractResourceRepository {
|
|
|
1990
2001
|
}
|
|
1991
2002
|
|
|
1992
2003
|
create(projectKey, draft) {
|
|
1993
|
-
console.log(draft);
|
|
1994
2004
|
const resource = { ...getBaseResourceProperties(),
|
|
1995
2005
|
applicationVersion: 1,
|
|
1996
2006
|
cartDiscounts: draft.cartDiscounts.map(obj => ({
|
|
@@ -3078,7 +3088,6 @@ class ProjectRepository extends AbstractRepository {
|
|
|
3078
3088
|
changeCartsConfiguration: (projectKey, resource, {
|
|
3079
3089
|
cartsConfiguration
|
|
3080
3090
|
}) => {
|
|
3081
|
-
console.log(cartsConfiguration);
|
|
3082
3091
|
resource.carts = cartsConfiguration || {
|
|
3083
3092
|
countryTaxRateFallbackEnabled: false,
|
|
3084
3093
|
deleteDaysAfterLastModification: 90
|
|
@@ -3282,12 +3291,17 @@ class ShippingMethodService extends AbstractService {
|
|
|
3282
3291
|
constructor(parent, storage) {
|
|
3283
3292
|
super(parent);
|
|
3284
3293
|
this.repository = new ShippingMethodRepository(storage);
|
|
3294
|
+
this.registerRoutes(parent);
|
|
3285
3295
|
}
|
|
3286
3296
|
|
|
3287
3297
|
getBasePath() {
|
|
3288
3298
|
return 'shipping-methods';
|
|
3289
3299
|
}
|
|
3290
3300
|
|
|
3301
|
+
extraRoutes(parent) {
|
|
3302
|
+
parent.get('/matching-cart', this.get.bind(this));
|
|
3303
|
+
}
|
|
3304
|
+
|
|
3291
3305
|
}
|
|
3292
3306
|
|
|
3293
3307
|
class ShoppingListRepository extends AbstractResourceRepository {
|
|
@@ -3917,6 +3931,7 @@ class CommercetoolsMock {
|
|
|
3917
3931
|
order: new OrderService(projectRouter, this._storage),
|
|
3918
3932
|
payment: new PaymentService(projectRouter, this._storage),
|
|
3919
3933
|
'my-cart': new MyCartService(projectRouter, this._storage),
|
|
3934
|
+
'my-customer': new MyCustomerService(projectRouter, this._storage),
|
|
3920
3935
|
'my-payment': new MyPaymentService(projectRouter, this._storage),
|
|
3921
3936
|
'shipping-method': new ShippingMethodService(projectRouter, this._storage),
|
|
3922
3937
|
'product-type': new ProductTypeService(projectRouter, this._storage),
|