@jackiemacklein/nettz-utils
Version:
Serviços de imagem, e-mail, códigos de barras, utilitários numéricos e componentes React para apps Node.js com TypeScript
172 lines (171 loc) • 6.79 kB
JavaScript
;
/**
* @author Jackiê Macklein
* @company Onside tecnologia/Nettz
* @copyright Todos direitos reservados.
* @description Metadados das bandeiras para transação remota (crédito/débito vem do código enviado em `paymentBrand`).
* Tabela de nomes: https://evoluservices.github.io/evoluservices-developer/docs/remote-transaction/value-table/brand
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.listEvoPaymentBrands = listEvoPaymentBrands;
exports.listEvoPaymentBrandsByKind = listEvoPaymentBrandsByKind;
exports.getEvoPaymentBrandByCode = getEvoPaymentBrandByCode;
const paymentBrandIcons_1 = require("./paymentBrandIcons");
const BRANDS = [
{
code: "VISA_CREDITO",
displayName: "Visa",
chargeKind: "credit",
iconSlug: (0, paymentBrandIcons_1.getEvoPaymentBrandIconSlug)("VISA_CREDITO"),
iconUrl: (0, paymentBrandIcons_1.getEvoPaymentBrandIconUrl)("VISA_CREDITO", "flat"),
},
{
code: "VISA_ELECTRON",
displayName: "Visa Electron (Débito)",
chargeKind: "debit",
iconSlug: (0, paymentBrandIcons_1.getEvoPaymentBrandIconSlug)("VISA_ELECTRON"),
iconUrl: (0, paymentBrandIcons_1.getEvoPaymentBrandIconUrl)("VISA_ELECTRON", "flat"),
},
{
code: "MASTERCARD",
displayName: "MasterCard",
chargeKind: "credit",
iconSlug: (0, paymentBrandIcons_1.getEvoPaymentBrandIconSlug)("MASTERCARD"),
iconUrl: (0, paymentBrandIcons_1.getEvoPaymentBrandIconUrl)("MASTERCARD", "flat"),
},
{
code: "MAESTRO",
displayName: "MasterCard Maestro (Débito)",
chargeKind: "debit",
iconSlug: (0, paymentBrandIcons_1.getEvoPaymentBrandIconSlug)("MAESTRO"),
iconUrl: (0, paymentBrandIcons_1.getEvoPaymentBrandIconUrl)("MAESTRO", "flat"),
},
{
code: "AMEX",
displayName: "American Express",
chargeKind: "credit",
iconSlug: (0, paymentBrandIcons_1.getEvoPaymentBrandIconSlug)("AMEX"),
iconUrl: (0, paymentBrandIcons_1.getEvoPaymentBrandIconUrl)("AMEX", "flat"),
},
{
code: "DINERS",
displayName: "Diners",
chargeKind: "credit",
iconSlug: (0, paymentBrandIcons_1.getEvoPaymentBrandIconSlug)("DINERS"),
iconUrl: (0, paymentBrandIcons_1.getEvoPaymentBrandIconUrl)("DINERS", "flat"),
},
{
code: "HIPERCARD",
displayName: "Hipercard",
chargeKind: "credit",
iconSlug: (0, paymentBrandIcons_1.getEvoPaymentBrandIconSlug)("HIPERCARD"),
iconUrl: (0, paymentBrandIcons_1.getEvoPaymentBrandIconUrl)("HIPERCARD", "flat"),
},
{
code: "AURA",
displayName: "Aura",
chargeKind: "credit",
iconSlug: (0, paymentBrandIcons_1.getEvoPaymentBrandIconSlug)("AURA"),
iconUrl: (0, paymentBrandIcons_1.getEvoPaymentBrandIconUrl)("AURA", "flat"),
},
{
code: "SOROCRED",
displayName: "Sorocred",
chargeKind: "credit",
iconSlug: (0, paymentBrandIcons_1.getEvoPaymentBrandIconSlug)("SOROCRED"),
iconUrl: (0, paymentBrandIcons_1.getEvoPaymentBrandIconUrl)("SOROCRED", "flat"),
},
{
code: "ELO",
displayName: "Elo",
chargeKind: "credit",
iconSlug: (0, paymentBrandIcons_1.getEvoPaymentBrandIconSlug)("ELO"),
iconUrl: (0, paymentBrandIcons_1.getEvoPaymentBrandIconUrl)("ELO", "flat"),
},
{
code: "SICREDI",
displayName: "Sicred",
chargeKind: "credit",
iconSlug: (0, paymentBrandIcons_1.getEvoPaymentBrandIconSlug)("SICREDI"),
iconUrl: (0, paymentBrandIcons_1.getEvoPaymentBrandIconUrl)("SICREDI", "flat"),
},
{
code: "ELO_DEBITO",
displayName: "Elo Débito",
chargeKind: "debit",
iconSlug: (0, paymentBrandIcons_1.getEvoPaymentBrandIconSlug)("ELO_DEBITO"),
iconUrl: (0, paymentBrandIcons_1.getEvoPaymentBrandIconUrl)("ELO_DEBITO", "flat"),
},
{
code: "HIPER",
displayName: "Hiper",
chargeKind: "credit",
iconSlug: (0, paymentBrandIcons_1.getEvoPaymentBrandIconSlug)("HIPER"),
iconUrl: (0, paymentBrandIcons_1.getEvoPaymentBrandIconUrl)("HIPER", "flat"),
},
{
code: "AGIPLAN",
displayName: "Agiplan",
chargeKind: "credit",
iconSlug: (0, paymentBrandIcons_1.getEvoPaymentBrandIconSlug)("AGIPLAN"),
iconUrl: (0, paymentBrandIcons_1.getEvoPaymentBrandIconUrl)("AGIPLAN", "flat"),
},
{
code: "BANESCARD",
displayName: "Banescard",
chargeKind: "credit",
iconSlug: (0, paymentBrandIcons_1.getEvoPaymentBrandIconSlug)("BANESCARD"),
iconUrl: (0, paymentBrandIcons_1.getEvoPaymentBrandIconUrl)("BANESCARD", "flat"),
},
{
code: "CREDZ",
displayName: "CredZ",
chargeKind: "credit",
iconSlug: (0, paymentBrandIcons_1.getEvoPaymentBrandIconSlug)("CREDZ"),
iconUrl: (0, paymentBrandIcons_1.getEvoPaymentBrandIconUrl)("CREDZ", "flat"),
},
{
code: "JCB",
displayName: "JCB",
chargeKind: "credit",
iconSlug: (0, paymentBrandIcons_1.getEvoPaymentBrandIconSlug)("JCB"),
iconUrl: (0, paymentBrandIcons_1.getEvoPaymentBrandIconUrl)("JCB", "flat"),
},
{
code: "CABAL",
displayName: "Cabal",
chargeKind: "credit",
iconSlug: (0, paymentBrandIcons_1.getEvoPaymentBrandIconSlug)("CABAL"),
iconUrl: (0, paymentBrandIcons_1.getEvoPaymentBrandIconUrl)("CABAL", "flat"),
},
{
code: "MAIS",
displayName: "Mais",
chargeKind: "credit",
iconSlug: (0, paymentBrandIcons_1.getEvoPaymentBrandIconSlug)("MAIS"),
iconUrl: (0, paymentBrandIcons_1.getEvoPaymentBrandIconUrl)("MAIS", "flat"),
},
];
function applyIconStyle(b, options) {
var _a;
const style = (_a = options === null || options === void 0 ? void 0 : options.iconStyle) !== null && _a !== void 0 ? _a : "flat";
if (style === "flat") {
return { ...b };
}
return {
...b,
iconUrl: (0, paymentBrandIcons_1.getEvoPaymentBrandIconUrl)(b.code, style),
};
}
/** Lista completa (cópia) para UI ou validação no app consumidor. */
function listEvoPaymentBrands(options) {
return BRANDS.map((b) => applyIconStyle(b, options));
}
function listEvoPaymentBrandsByKind(chargeKind, options) {
return BRANDS.filter((b) => b.chargeKind === chargeKind).map((b) => applyIconStyle(b, options));
}
/** Busca por código exato (ex.: valor vindo do banco de dados). */
function getEvoPaymentBrandByCode(code, options) {
const found = BRANDS.find((b) => b.code === code);
return found ? applyIconStyle(found, options) : undefined;
}