@labdigital/commercetools-mock 0.5.18 → 0.5.19
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 +72 -2
- 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 +71 -1
- package/dist/commercetools-mock.esm.js.map +1 -1
- package/dist/repositories/payment.d.ts +3 -1
- package/package.json +1 -1
- package/src/ctMock.ts +1 -1
- package/src/repositories/category.ts +1 -0
- package/src/repositories/payment.ts +38 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Payment, PaymentAddTransactionAction, PaymentDraft, PaymentSetCustomFieldAction, PaymentSetCustomTypeAction, ReferenceTypeId, TransactionDraft } from '@commercetools/platform-sdk';
|
|
1
|
+
import { Payment, PaymentAddTransactionAction, PaymentChangeTransactionStateAction, PaymentDraft, PaymentSetCustomFieldAction, PaymentSetCustomTypeAction, PaymentTransitionStateAction, ReferenceTypeId, TransactionDraft } from '@commercetools/platform-sdk';
|
|
2
2
|
import { AbstractResourceRepository } from './abstract';
|
|
3
3
|
import { Writable } from '../types';
|
|
4
4
|
export declare class PaymentRepository extends AbstractResourceRepository {
|
|
@@ -17,5 +17,7 @@ export declare class PaymentRepository extends AbstractResourceRepository {
|
|
|
17
17
|
setCustomField: (projectKey: string, resource: Payment, { name, value }: PaymentSetCustomFieldAction) => void;
|
|
18
18
|
setCustomType: (projectKey: string, resource: Writable<Payment>, { type, fields }: PaymentSetCustomTypeAction) => void;
|
|
19
19
|
addTransaction: (projectKey: string, resource: Writable<Payment>, { transaction }: PaymentAddTransactionAction) => void;
|
|
20
|
+
changeTransactionState: (_projectKey: string, resource: Writable<Payment>, { transactionId, state }: PaymentChangeTransactionStateAction) => void;
|
|
21
|
+
transitionState: (projectKey: string, resource: Writable<Payment>, { state }: PaymentTransitionStateAction) => void;
|
|
20
22
|
};
|
|
21
23
|
}
|
package/package.json
CHANGED
package/src/ctMock.ts
CHANGED
|
@@ -37,7 +37,7 @@ import { SubscriptionService } from './services/subscription'
|
|
|
37
37
|
import { TaxCategoryService } from './services/tax-category'
|
|
38
38
|
import { TypeService } from './services/type'
|
|
39
39
|
import { ZoneService } from './services/zone'
|
|
40
|
-
import { MyCustomerService } from 'services/my-customer'
|
|
40
|
+
import { MyCustomerService } from './services/my-customer'
|
|
41
41
|
|
|
42
42
|
export type CommercetoolsMockOptions = {
|
|
43
43
|
validateCredentials: boolean
|
|
@@ -30,6 +30,7 @@ export class CategoryRepository extends AbstractResourceRepository {
|
|
|
30
30
|
name: draft.name,
|
|
31
31
|
slug: draft.slug,
|
|
32
32
|
orderHint: draft.orderHint || '',
|
|
33
|
+
externalId: draft.externalId || '',
|
|
33
34
|
parent: draft.parent
|
|
34
35
|
? { typeId: 'category', id: draft.parent.id! }
|
|
35
36
|
: undefined,
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Payment,
|
|
3
3
|
PaymentAddTransactionAction,
|
|
4
|
+
PaymentChangeTransactionStateAction,
|
|
4
5
|
PaymentDraft,
|
|
5
6
|
PaymentSetCustomFieldAction,
|
|
6
7
|
PaymentSetCustomTypeAction,
|
|
8
|
+
PaymentTransitionStateAction,
|
|
7
9
|
ReferenceTypeId,
|
|
10
|
+
State,
|
|
8
11
|
StateReference,
|
|
12
|
+
Transaction,
|
|
9
13
|
TransactionDraft,
|
|
10
14
|
} from '@commercetools/platform-sdk'
|
|
11
15
|
import { AbstractResourceRepository } from './abstract'
|
|
@@ -111,10 +115,43 @@ export class PaymentRepository extends AbstractResourceRepository {
|
|
|
111
115
|
this.transactionFromTransactionDraft(transaction, projectKey),
|
|
112
116
|
]
|
|
113
117
|
},
|
|
118
|
+
changeTransactionState: (
|
|
119
|
+
_projectKey: string,
|
|
120
|
+
resource: Writable<Payment>,
|
|
121
|
+
{ transactionId, state }: PaymentChangeTransactionStateAction
|
|
122
|
+
) => {
|
|
123
|
+
const index = resource.transactions.findIndex(
|
|
124
|
+
(e: Transaction) => e.id === transactionId
|
|
125
|
+
)
|
|
126
|
+
const updatedTransaction: Transaction = {
|
|
127
|
+
...resource.transactions[index],
|
|
128
|
+
state,
|
|
129
|
+
}
|
|
130
|
+
resource.transactions[index] = updatedTransaction
|
|
131
|
+
},
|
|
132
|
+
transitionState: (
|
|
133
|
+
projectKey: string,
|
|
134
|
+
resource: Writable<Payment>,
|
|
135
|
+
{ state }: PaymentTransitionStateAction
|
|
136
|
+
) => {
|
|
137
|
+
const stateObj = this._storage.getByResourceIdentifier(
|
|
138
|
+
projectKey,
|
|
139
|
+
state
|
|
140
|
+
) as State | null
|
|
141
|
+
|
|
142
|
+
if (!stateObj) {
|
|
143
|
+
throw new Error(`State ${state} not found`)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
resource.paymentStatus.state = {
|
|
147
|
+
typeId: 'state',
|
|
148
|
+
id: stateObj.id,
|
|
149
|
+
obj: stateObj,
|
|
150
|
+
}
|
|
151
|
+
},
|
|
114
152
|
// addInterfaceInteraction: () => {},
|
|
115
153
|
// changeAmountPlanned: () => {},
|
|
116
154
|
// changeTransactionInteractionId: () => {},
|
|
117
|
-
// changeTransactionState: () => {},
|
|
118
155
|
// changeTransactionTimestamp: () => {},
|
|
119
156
|
// setAmountPaid: () => {},
|
|
120
157
|
// setAmountRefunded: () => {},
|
|
@@ -129,6 +166,5 @@ export class PaymentRepository extends AbstractResourceRepository {
|
|
|
129
166
|
// setMethodInfoName: () => {},
|
|
130
167
|
// setStatusInterfaceCode: () => {},
|
|
131
168
|
// setStatusInterfaceText: () => {},
|
|
132
|
-
// transitionState: () => {},
|
|
133
169
|
}
|
|
134
170
|
}
|