Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 8x 8x 8x 5x 5x 5x 5x 2x 3x 3x 3x 3x 3x 3x | import { AbstractPaymentDetailsStrategy } from "../../core/strategies/abstractPaymentDetailsStrategy"; import CardOperation from "../../core/types/cardOperation"; import PaymentDetailsProcessingError from "../../core/errors/paymentDetailsProcessingError"; export default class GmailCardOperationStrategy extends AbstractPaymentDetailsStrategy<CardOperation> { public tryCreate(paymentDetailsRaw: string[], additionalDetailsRaw: string[]): CardOperation { const raw = paymentDetailsRaw.join(''); const regex = /^(?<instrument>[^\d]+)\s(?<sum>[^\s]+)\s(?<currency>\w*)[,]?\sавт.код:(?:[^\s,-]*)[\s]*[-]?[,]?[\s]?(?<merchant>[^\/]+(?<! ))/; const regexResult = regex.exec(raw); if (regexResult === null) { throw new PaymentDetailsProcessingError(`Failed to execute regex on input '${raw}'`); } const instrument = regexResult.groups?.instrument; const sum = regexResult.groups?.sum; const currency = regexResult.groups?.currency; const merchant = regexResult.groups?.merchant; Iif (instrument === undefined || sum === undefined || currency === undefined || merchant === undefined) { throw new PaymentDetailsProcessingError(`Failed to read regex capture group`); } return this.paymentDetailsFactory.cardOperation(merchant, instrument, sum, currency); } } |