-
-
Notifications
You must be signed in to change notification settings - Fork 935
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(admin-ui): Add support for payment method relation custom field.…
… add payment method service
- Loading branch information
1 parent
b40aa88
commit 101704b
Showing
36 changed files
with
414 additions
and
250 deletions.
There are no files selected for viewing
121 changes: 59 additions & 62 deletions
121
packages/admin-ui/src/lib/core/src/common/generated-types.ts
Large diffs are not rendered by default.
Oops, something went wrong.
97 changes: 97 additions & 0 deletions
97
packages/admin-ui/src/lib/core/src/data/definitions/payment-method-definitions.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import { gql } from 'apollo-angular'; | ||
|
||
import { CONFIGURABLE_OPERATION_DEF_FRAGMENT, CONFIGURABLE_OPERATION_FRAGMENT } from './shared-definitions'; | ||
|
||
export const PAYMENT_METHOD_FRAGMENT = gql` | ||
fragment PaymentMethod on PaymentMethod { | ||
id | ||
createdAt | ||
updatedAt | ||
name | ||
code | ||
description | ||
enabled | ||
translations { | ||
id | ||
languageCode | ||
name | ||
description | ||
} | ||
checker { | ||
...ConfigurableOperation | ||
} | ||
handler { | ||
...ConfigurableOperation | ||
} | ||
} | ||
${CONFIGURABLE_OPERATION_FRAGMENT} | ||
`; | ||
|
||
export const GET_PAYMENT_METHOD_OPERATIONS = gql` | ||
query GetPaymentMethodOperations { | ||
paymentMethodEligibilityCheckers { | ||
...ConfigurableOperationDef | ||
} | ||
paymentMethodHandlers { | ||
...ConfigurableOperationDef | ||
} | ||
} | ||
${CONFIGURABLE_OPERATION_DEF_FRAGMENT} | ||
`; | ||
|
||
export const GET_PAYMENT_METHOD_LIST = gql` | ||
query GetPaymentMethodList($options: PaymentMethodListOptions!) { | ||
paymentMethods(options: $options) { | ||
items { | ||
...PaymentMethod | ||
} | ||
totalItems | ||
} | ||
} | ||
${PAYMENT_METHOD_FRAGMENT} | ||
`; | ||
|
||
export const GET_PAYMENT_METHOD = gql` | ||
query GetPaymentMethod($id: ID!) { | ||
paymentMethod(id: $id) { | ||
...PaymentMethod | ||
} | ||
} | ||
${PAYMENT_METHOD_FRAGMENT} | ||
`; | ||
|
||
export const CREATE_PAYMENT_METHOD = gql` | ||
mutation CreatePaymentMethod($input: CreatePaymentMethodInput!) { | ||
createPaymentMethod(input: $input) { | ||
...PaymentMethod | ||
} | ||
} | ||
${PAYMENT_METHOD_FRAGMENT} | ||
`; | ||
|
||
export const UPDATE_PAYMENT_METHOD = gql` | ||
mutation UpdatePaymentMethod($input: UpdatePaymentMethodInput!) { | ||
updatePaymentMethod(input: $input) { | ||
...PaymentMethod | ||
} | ||
} | ||
${PAYMENT_METHOD_FRAGMENT} | ||
`; | ||
|
||
export const DELETE_PAYMENT_METHOD = gql` | ||
mutation DeletePaymentMethod($id: ID!, $force: Boolean) { | ||
deletePaymentMethod(id: $id, force: $force) { | ||
result | ||
message | ||
} | ||
} | ||
`; | ||
|
||
export const DELETE_PAYMENT_METHODS = gql` | ||
mutation DeletePaymentMethods($ids: [ID!]!, $force: Boolean) { | ||
deletePaymentMethods(ids: $ids, force: $force) { | ||
result | ||
message | ||
} | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
packages/admin-ui/src/lib/core/src/data/providers/payment-method-data.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import { pick } from '@vendure/common/lib/pick'; | ||
import * as Codegen from '../../common/generated-types'; | ||
import { | ||
GET_PAYMENT_METHOD, | ||
GET_PAYMENT_METHOD_LIST, | ||
CREATE_PAYMENT_METHOD, | ||
DELETE_PAYMENT_METHOD, | ||
DELETE_PAYMENT_METHODS, | ||
GET_PAYMENT_METHOD_OPERATIONS, | ||
UPDATE_PAYMENT_METHOD, | ||
} from '../definitions/payment-method-definitions'; | ||
import { BaseDataService } from './base-data.service'; | ||
|
||
export class PaymentMethodDataService { | ||
constructor(private baseDataService: BaseDataService) {} | ||
|
||
getPaymentMethods(options: Codegen.PaymentMethodListOptions) { | ||
return this.baseDataService.query< | ||
Codegen.GetPaymentMethodListQuery, | ||
Codegen.GetPaymentMethodListQueryVariables | ||
>(GET_PAYMENT_METHOD_LIST, { | ||
options, | ||
}); | ||
} | ||
|
||
getPaymentMethod(id: string) { | ||
return this.baseDataService.query< | ||
Codegen.GetPaymentMethodQuery, | ||
Codegen.GetPaymentMethodQueryVariables | ||
>(GET_PAYMENT_METHOD, { id }); | ||
} | ||
|
||
createPaymentMethod(input: Codegen.CreatePaymentMethodInput) { | ||
return this.baseDataService.mutate< | ||
Codegen.CreatePaymentMethodMutation, | ||
Codegen.CreatePaymentMethodMutationVariables | ||
>(CREATE_PAYMENT_METHOD, { | ||
input: pick(input, ['code', 'checker', 'handler', 'enabled', 'translations', 'customFields']), | ||
}); | ||
} | ||
|
||
updatePaymentMethod(input: Codegen.UpdatePaymentMethodInput) { | ||
return this.baseDataService.mutate< | ||
Codegen.UpdatePaymentMethodMutation, | ||
Codegen.UpdatePaymentMethodMutationVariables | ||
>(UPDATE_PAYMENT_METHOD, { | ||
input: pick(input, [ | ||
'id', | ||
'code', | ||
'checker', | ||
'handler', | ||
'enabled', | ||
'translations', | ||
'customFields', | ||
]), | ||
}); | ||
} | ||
|
||
deletePaymentMethod(id: string, force: boolean) { | ||
return this.baseDataService.mutate< | ||
Codegen.DeletePaymentMethodMutation, | ||
Codegen.DeletePaymentMethodMutationVariables | ||
>(DELETE_PAYMENT_METHOD, { | ||
id, | ||
force, | ||
}); | ||
} | ||
|
||
deletePaymentMethods(ids: string[], force: boolean) { | ||
return this.baseDataService.mutate< | ||
Codegen.DeletePaymentMethodsMutation, | ||
Codegen.DeletePaymentMethodsMutationVariables | ||
>(DELETE_PAYMENT_METHODS, { | ||
ids, | ||
force, | ||
}); | ||
} | ||
|
||
getPaymentMethodOperations() { | ||
return this.baseDataService.query<Codegen.GetPaymentMethodOperationsQuery>( | ||
GET_PAYMENT_METHOD_OPERATIONS, | ||
); | ||
} | ||
} |
Oops, something went wrong.