72 lines
2.0 KiB
Go
72 lines
2.0 KiB
Go
package discovery
|
|
|
|
import "strings"
|
|
|
|
const (
|
|
OperationDiscoveryLookup = "discovery.lookup"
|
|
|
|
OperationDocumentsBatchResolve = "documents.batch_resolve"
|
|
OperationDocumentsGet = "documents.get"
|
|
OperationFeeCalc = "fee.calc"
|
|
OperationNotifySend = "notify.send"
|
|
OperationFXQuote = "fx.quote"
|
|
OperationFXIngest = "fx.ingest"
|
|
|
|
OperationPaymentInitiate = "payment.initiate"
|
|
OperationPaymentQuote = "payment.quote"
|
|
OperationPaymentMultiQuote = "payment.multiquote"
|
|
OperationPaymentMethodsManage = "payment_methods.manage"
|
|
OperationPaymentMethodsRead = "payment_methods.read"
|
|
|
|
OperationBalanceRead = "balance.read"
|
|
|
|
OperationLedgerDebit = "ledger.debit"
|
|
OperationLedgerCredit = "ledger.credit"
|
|
OperationLedgerTransfer = "ledger.transfer"
|
|
OperationLedgerFX = "ledger.fx"
|
|
OperationExternalDebit = "external.debit"
|
|
OperationExternalCredit = "external.credit"
|
|
|
|
OperationSend = "send"
|
|
OperationFee = "fee"
|
|
OperationObserveConfirm = "observe.confirm"
|
|
OperationFXConvert = "fx.convert"
|
|
)
|
|
|
|
// NormalizeOperation canonicalizes an operation string for comparisons.
|
|
func NormalizeOperation(value string) string {
|
|
return strings.ToLower(strings.TrimSpace(value))
|
|
}
|
|
|
|
// HasAnyOperation reports whether ops contains any of required operations.
|
|
func HasAnyOperation(ops []string, required []string) bool {
|
|
if len(required) == 0 {
|
|
return true
|
|
}
|
|
for _, op := range ops {
|
|
normalized := NormalizeOperation(op)
|
|
if normalized == "" {
|
|
continue
|
|
}
|
|
for _, target := range required {
|
|
if normalized == NormalizeOperation(target) {
|
|
return true
|
|
}
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
// LedgerServiceOperations returns canonical operations announced by ledger.
|
|
func LedgerServiceOperations() []string {
|
|
return []string{
|
|
OperationBalanceRead,
|
|
OperationLedgerDebit,
|
|
OperationLedgerCredit,
|
|
OperationLedgerTransfer,
|
|
OperationLedgerFX,
|
|
OperationExternalCredit,
|
|
OperationExternalDebit,
|
|
}
|
|
}
|