@labdigital/commercetools-mock 0.5.19 → 0.5.22
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 +478 -335
- 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 +478 -335
- package/dist/commercetools-mock.esm.js.map +1 -1
- package/dist/repositories/customer.d.ts +5 -1
- package/dist/repositories/order.d.ts +2 -1
- package/dist/repositories/store.d.ts +1 -0
- package/dist/services/cart.d.ts +3 -0
- package/dist/services/customer.d.ts +1 -0
- package/dist/services/my-customer.d.ts +1 -0
- package/dist/services/my-order.d.ts +10 -0
- package/dist/services/store.d.ts +3 -1
- package/dist/types.d.ts +1 -1
- package/package.json +1 -1
- package/src/.env +0 -0
- package/src/ctMock.ts +2 -0
- package/src/lib/masking.ts +1 -3
- package/src/repositories/abstract.ts +1 -0
- package/src/repositories/category.ts +6 -6
- package/src/repositories/customer.ts +14 -0
- package/src/repositories/helpers.ts +0 -1
- package/src/repositories/order.ts +22 -0
- package/src/repositories/product-type.ts +3 -3
- package/src/repositories/project.ts +0 -1
- package/src/repositories/shipping-method.ts +11 -12
- package/src/repositories/store.ts +15 -0
- package/src/repositories/subscription.ts +2 -2
- package/src/repositories/tax-category.ts +1 -1
- package/src/repositories/type.ts +10 -10
- package/src/repositories/zone.ts +3 -1
- package/src/services/cart.ts +32 -0
- package/src/services/customer.ts +21 -0
- package/src/services/my-customer.ts +25 -0
- package/src/services/my-order.ts +35 -0
- package/src/services/product.test.ts +1 -5
- package/src/services/project.ts +1 -1
- package/src/services/shipping-method.ts +1 -1
- package/src/services/store.ts +16 -1
- package/src/types.ts +1 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import AbstractService from './abstract'
|
|
2
|
+
import { Router } from 'express'
|
|
3
|
+
import { AbstractStorage } from '../storage'
|
|
4
|
+
import { OrderRepository } from '../repositories/order'
|
|
5
|
+
|
|
6
|
+
export class MyOrderService extends AbstractService {
|
|
7
|
+
public repository: OrderRepository
|
|
8
|
+
|
|
9
|
+
constructor(parent: Router, storage: AbstractStorage) {
|
|
10
|
+
super(parent)
|
|
11
|
+
this.repository = new OrderRepository(storage)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
getBasePath() {
|
|
15
|
+
return 'me'
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
registerRoutes(parent: Router) {
|
|
19
|
+
// Overwrite this function to be able to handle /me/active-cart path.
|
|
20
|
+
const basePath = this.getBasePath()
|
|
21
|
+
const router = Router({ mergeParams: true })
|
|
22
|
+
|
|
23
|
+
this.extraRoutes(router)
|
|
24
|
+
|
|
25
|
+
router.get('/orders/', this.get.bind(this))
|
|
26
|
+
router.get('/orders/:id', this.getWithId.bind(this))
|
|
27
|
+
|
|
28
|
+
router.delete('/orders/:id', this.deletewithId.bind(this))
|
|
29
|
+
|
|
30
|
+
router.post('/orders/', this.post.bind(this))
|
|
31
|
+
router.post('/orders/:id', this.postWithId.bind(this))
|
|
32
|
+
|
|
33
|
+
parent.use(`/${basePath}`, router)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CentPrecisionMoney,
|
|
3
|
-
Product,
|
|
4
|
-
ProductDraft,
|
|
5
|
-
} from '@commercetools/platform-sdk'
|
|
1
|
+
import { Product, ProductDraft } from '@commercetools/platform-sdk'
|
|
6
2
|
import supertest from 'supertest'
|
|
7
3
|
import { CommercetoolsMock } from '../index'
|
|
8
4
|
import assert from 'assert'
|
package/src/services/project.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ShippingMethodRepository } from '../repositories/shipping-method'
|
|
2
2
|
import AbstractService from './abstract'
|
|
3
3
|
import { AbstractStorage } from '../storage'
|
|
4
|
-
import {
|
|
4
|
+
import { Router } from 'express'
|
|
5
5
|
|
|
6
6
|
export class ShippingMethodService extends AbstractService {
|
|
7
7
|
public repository: ShippingMethodRepository
|
package/src/services/store.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import AbstractService from './abstract'
|
|
2
|
-
import { Router } from 'express'
|
|
2
|
+
import { Router, Request, Response } from 'express'
|
|
3
3
|
import { StoreRepository } from '../repositories/store'
|
|
4
4
|
import { AbstractStorage } from '../storage'
|
|
5
5
|
|
|
@@ -14,4 +14,19 @@ export class StoreService extends AbstractService {
|
|
|
14
14
|
getBasePath() {
|
|
15
15
|
return 'stores'
|
|
16
16
|
}
|
|
17
|
+
|
|
18
|
+
extraRoutes(router: Router) {
|
|
19
|
+
router.get('/key=:key', this.getWithKey.bind(this))
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
getWithKey(request: Request, response: Response) {
|
|
23
|
+
const resource = this.repository.getWithKey(
|
|
24
|
+
request.params.projectKey,
|
|
25
|
+
request.params.key
|
|
26
|
+
)
|
|
27
|
+
if (resource) {
|
|
28
|
+
return response.status(200).send(resource)
|
|
29
|
+
}
|
|
30
|
+
return response.status(404).send('Not found')
|
|
31
|
+
}
|
|
17
32
|
}
|