/* C# (C Sharp) - namespace y clase para acceder a las funciones de libfacturista
una biblioteca (dll o libreria) para generar, sellar y timbrar CFDI 3.2 (XML)
Ariel Alonzo Medina Vazquez - facturista.com */


using System;
using System.Runtime.InteropServices;

namespace libfacturista {

public static class libfacturistaApi {

//the DLL strings are returned as IntPtr, you should use Marshal.PtrToStringAnsi(libfacturistaApi.dll_function()) in order to get a managed C# string







[DllImport("libfacturista.dll", CharSet=CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern 
IntPtr libfacturista_version();

[DllImport("libfacturista.dll", CharSet=CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern 
int cfdi_comprobante(string version, string serie, string folio, string fecha,
string formaDePago, string subTotal, string TipoCambio, string Moneda, string total,
string metodoDePago, string tipoDeComprobante, string LugarExpedicion, string NumCtaPago,
string FolioFiscalOrig, string SerieFolioFiscalOrig, string FechaFolioFiscalOrig, string MontoFolioFiscalOrig);

[DllImport("libfacturista.dll", CharSet=CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern 
int cfdi_emisor(int pcfdi, string rfc, string nombre);

[DllImport("libfacturista.dll", CharSet=CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern 
int cfdi_emisor_regimen(int pcfdi, string Regimen);

[DllImport("libfacturista.dll", CharSet=CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern 
int cfdi_emisor_domicilio(int pcfdi, string calle, string noExterior, string noInterior,
string colonia, string localidad, string municipio, string estado, string pais, string codigoPostal, string referencia);

[DllImport("libfacturista.dll", CharSet=CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern 
int cfdi_emisor_expedido_en(int pcfdi, string calle, string noExterior, string noInterior,
string colonia, string localidad, string municipio, string estado, string pais, string codigoPostal, string referencia);

[DllImport("libfacturista.dll", CharSet=CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern 
int cfdi_receptor(int pcfdi, string rfc, string nombre);

[DllImport("libfacturista.dll", CharSet=CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern 
int cfdi_receptor_domicilio(int pcfdi, string calle, string noExterior, string noInterior,
string colonia, string localidad, string municipio, string estado, string pais, string codigoPostal, string referencia);

[DllImport("libfacturista.dll", CharSet=CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern 
int cfdi_impuestos(int pcfdi, string totalImpuestosRetenidos, string totalImpuestosTrasladados);

[DllImport("libfacturista.dll", CharSet=CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern 
int cfdi_impuestos_retencion(int pcfdi, string impuesto, string importe);

[DllImport("libfacturista.dll", CharSet=CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern 
int cfdi_impuestos_traslado(int pcfdi, string impuesto, string importe, string tasa);

[DllImport("libfacturista.dll", CharSet=CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern 
int cfdi_concepto(int pcfdi, string cantidad, string unidad, string noIdentificacion,
string descripcion, string valorUnitario, string importe);

[DllImport("libfacturista.dll", CharSet=CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern 
int cfdi_concepto_informacionaduanera(int hc, string numero, string fecha, string aduana);

[DllImport("libfacturista.dll", CharSet=CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern 
int cfdi_concepto_cuentapredial(int hc, string numero);

[DllImport("libfacturista.dll", CharSet=CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern 
int cfdi_concepto_parte(int hc, string cantidad, string unidad, string noIdentificacion,
string descripcion, string valorUnitario, string importe);

[DllImport("libfacturista.dll", CharSet=CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern 
int cfdi_concepto_ComplementoConcepto(int hc);


[DllImport("libfacturista.dll", CharSet=CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern 
int cfdi_xml_cargar(int h, string rutaFuente);

[DllImport("libfacturista.dll", CharSet=CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern 
int cfdi_xml_guardar(int h, string rutaDestino, int decorar);

[DllImport("libfacturista.dll", CharSet=CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern 
int cfdi_xml_validar(int h, string archivoXML, string archivoXSD, string parametros);

[DllImport("libfacturista.dll", CharSet=CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern 
int cfdi_sellar_pkcs8(int h, string rutaLlavePrivada, string contrasena, string rutaCertificado, string rutaDestino, int decorar);

[DllImport("libfacturista.dll", CharSet=CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern 
int cfdi_sellar_pem(int h, string rutaLlavePrivada, string contrasena, string rutaCertificado, string rutaDestino, int decorar);

[DllImport("libfacturista.dll", CharSet=CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern 
int cfdi_sellar(int h, string rutaLlavePrivada, string rutaCertificado, string rutaDestino, int decorar);

[DllImport("libfacturista.dll", CharSet=CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern 
int cfdi_timbrar(int h, string rutaFuente, string rutaDestino, int numeroPAC, string parametros);

[DllImport("libfacturista.dll", CharSet=CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern 
int cfdi_cancelar(int h, int numeroPAC, string parametros);

[DllImport("libfacturista.dll", CharSet=CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern 
int cfdi_recuperar(int h, string rutaDestino, int numeroPAC, string parametros);

[DllImport("libfacturista.dll", CharSet=CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern 
IntPtr cfdi_estado_cuenta(int h, int numeroPAC, string parametros);

[DllImport("libfacturista.dll", CharSet=CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern 
IntPtr cfdi_error(int h);

[DllImport("libfacturista.dll", CharSet=CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern 
IntPtr cfdi_resultado(int h);


[DllImport("libfacturista.dll", CharSet=CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern 
IntPtr cfdi_xml_atributo(int h, string ruta, string nombre);

[DllImport("libfacturista.dll", CharSet=CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern 
int cfdi_xml_atributo_agregar(int h, string ruta, string nombre, string valor);

[DllImport("libfacturista.dll", CharSet=CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern 
int cfdi_xml_atributo_borrar(int h, string ruta, string nombre);

[DllImport("libfacturista.dll", CharSet=CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern 
IntPtr cfdi_cadena_original_basica(int h);

[DllImport("libfacturista.dll", CharSet=CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern 
void cfdi_usar_cadena_original_basica(int h, int usar);

[DllImport("libfacturista.dll", CharSet=CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern 
IntPtr cfdi_cadena_original(int h);

[DllImport("libfacturista.dll", CharSet=CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern 
IntPtr cfdi_cadena_original_sat(int h);

[DllImport("libfacturista.dll", CharSet=CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern 
IntPtr cfdi_uuid(int h);

[DllImport("libfacturista.dll", CharSet=CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern 
IntPtr cfdi_fecha_timbrado(int h);

[DllImport("libfacturista.dll", CharSet=CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern 
IntPtr cfdi_numero_certificado_sat(int h);

[DllImport("libfacturista.dll", CharSet=CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern 
IntPtr cfdi_sello_cfd(int h);

[DllImport("libfacturista.dll", CharSet=CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern 
IntPtr cfdi_sello_sat(int h);

[DllImport("libfacturista.dll", CharSet=CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern 
IntPtr cfdi_sello(int h);

[DllImport("libfacturista.dll", CharSet=CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern 
IntPtr cfdi_fecha(int h);

[DllImport("libfacturista.dll", CharSet=CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern 
IntPtr cfdi_numero_certificado(int h, string rutaCertificado);


[DllImport("libfacturista.dll", CharSet=CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern 
int xml_caller_charset(int h, string charset);

[DllImport("libfacturista.dll", CharSet=CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern 
int xml_node(int h, string path);

[DllImport("libfacturista.dll", CharSet=CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern 
int xml_node_children_number(int h);

[DllImport("libfacturista.dll", CharSet=CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern 
int xml_node_by_index(int h, int index);

[DllImport("libfacturista.dll", CharSet=CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern 
IntPtr xml_node_name(int h);

[DllImport("libfacturista.dll", CharSet=CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern 
int xml_node_by_name(int h, string name);

[DllImport("libfacturista.dll", CharSet=CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern 
IntPtr xml_node_attribute(int h, string name);







}

}