UNPKG

declastruct-stripe-sdk

Version:

declarative control of stripe constructs, via declastruct

24 lines 1.1 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.castToDeclaredStripeCustomer = void 0; const helpful_errors_1 = require("helpful-errors"); const type_fns_1 = require("type-fns"); const DeclaredStripeCustomer_1 = require("../../domain/objects/DeclaredStripeCustomer"); const castToDeclaredStripeCustomer = (input) => { return new DeclaredStripeCustomer_1.DeclaredStripeCustomer({ id: input.id, email: input.email ?? helpful_errors_1.UnexpectedCodePathError.throw('no email found for customer. not a valid declared stripe customer', { input }), description: input.description ?? null, name: input.name ?? null, phone: input.phone ?? null, metadata: (() => { const obj = input.metadata ? (0, type_fns_1.omit)(input.metadata, ['exid']) : {}; if (Object.keys(obj).length === 0) return null; return obj; })(), }); }; exports.castToDeclaredStripeCustomer = castToDeclaredStripeCustomer; //# sourceMappingURL=castToDeclaredStripeCustomer.js.map