import { Timbrix } from "@timbrix/sdk"
const client = new Timbrix({ apiKey: "sk_test_..." })
// La organización se resuelve a partir de la key — no necesitas organizationId.
const customer = await client.customers.create({
legalName: "Cliente de Prueba SA de CV",
taxId: "DUM901231AB3",
taxSystem: "601",
email: "facturas@cliente-prueba.mx",
defaultInvoiceUse: "G01",
addressStreet: "Blvd. Atardecer",
addressExterior: "142",
addressNeighborhood: "Centro",
addressCity: "Huatabampo",
addressMunicipality: "Huatabampo",
addressZip: "86500",
addressState: "Sonora",
})
const product = await client.products.create({
description: "Servicio de prueba",
productKey: 84111506,
unitKey: "E48",
price: 100.0,
})
const invoice = await client.invoices.create({
type: "I",
series: "A",
folioNumber: "1",
date: new Date().toISOString(),
paymentForm: "01",
paymentMethod: "PUE",
use: "G03",
customerId: customer.id,
items: [{ productId: product.id, quantity: 1, amount: 100.0 }],
})
console.log(invoice.uuid) // folio fiscal asignado por el SAT vía el PAC