import { ENVIRONMENT } from '../networking'; import { AxiosError } from 'axios'; import { TrackingStatusResponse, AuthToken, InvoiceResponse, ServiceDirectoryResponse, SummaryTrackingStatusResponse, InvoiceSummaryResponse, InquiryStatusResponse, InquiryInvoiceSummary, Opperation, StatusOperation, ServiceStatusResponse, MaintenanceResponse, VerificationResponse } from './types'; export declare enum ENDPOINTS { SEED = "Autenticacion/api/Autenticacion/Semilla", VALIDATE_SEED = "autenticacion/api/Autenticacion/ValidarSemilla", SEND_INVOICE = "recepcion/api/FacturasElectronicas", SEND_SUMMARY = "recepcionfc/api/recepcion/ecf", INQUIRY_INVOICE_SUMMARY = "consultarfce/api/Consultas/Consulta", COMMERCIAL_APPROVAL = "aprobacionComercial/api/AprobacionComercial", TRACK_RESULT_STATUS = "consultaresultado/api/Consultas/Estado", INQUIRY_STATUS = "consultaestado/api/Consultas/Estado", ALL_TACKING_ECF = "ConsultaTrackIds/api/TrackIds/Consulta", DIRECTORY = "consultadirectorio/api/consultas/obtenerdirectorioporrnc", VOID = "anulacionrangos/api/operaciones/anularrango", SERVICE_STATUS = "api/estatusservicios/obtenerestatus", SERVICE_MAINTENANCE = "api/estatusservicios/obtenerventanasmantenimiento", SERVICE_VERIFICATION = "api/estatusservicios/verificarestado" } /** * Estándar de comunicación Emisor ‐ Receptor * Con el objetivo de garantizar el intercambio seguro de información entre * contribuyentes, en la presente sección se describe el estándar de comunicación que * estos deberán tener para Facturación Electrónica. */ export declare enum ENDPOINTS_SENDER_RECEIVER { SEED = "fe/autenticacion/api/semilla", VALIDATE_SEED = "fe/autenticacion/api/validacioncertificado", SEND_INVOICE = "fe/recepcion/api/ecf", SEND_COMMERCIAL_APPROVAL = "fe/aprobacioncomercial/api/ecf" } export declare const isErrorResponse: (response: T | AxiosError) => response is AxiosError; declare class RestApi { private env; constructor(env: ENVIRONMENT, accessToken?: string); private get baseApi(); private getResource; private getBuyerResource; /** * Get an initial XML payload called seed, should be signed using the certificate .p12 * @param buyerHost optional - If buyerHost is defined the authentication will be againt the buyer HOST to stablish the communication Sender<->Receiver * @returns */ getSeedApi: (buyerHost?: string) => Promise; /** * Return the token from a signed seed * @param signedSeed the seed should be signed in order to get the token * @param buyerHost optional - If buyerHost is defined the authentication will be againt the buyer HOST to stablish the communication Sender<->Receiver * @returns promise with the access token */ getAuthTokenApi: (signedSeed: string, buyerHost?: string) => Promise; /** * Send the signed invoice to DGII * @param signedXml XML signed invoice * @param fileName the composition of the file name should be RNC+e-NCF.xml example: “101672919E3100000001.xml” * @param buyerHost optional - If buyerHost is defined the authentication will be againt the buyer HOST to stablish the communication Sender<->Receiver * @returns */ sendElectronicDocumentApi: (signedInvoice: string, fileName: string, buyerHost?: string) => Promise; /** * Sign any XML document and perform the opperation like void document, receipt, commercial approval * @param signedDocument * @param fileName * @param opperation Opperation Enum * @returns */ sendSignedDocumentApi: (signedDocument: string, fileName: string, opperation: Opperation) => Promise; /** * Send the signed summary invoice to DGII (Factura de consumo) * @param signedXml XML signed invoice * @param fileName the composition of the file name should be RNC+e-NCF.xml example: “101672919E3100000001.xml” * @returns */ sendSummaryApi: (signedInvoice: string, fileName: string) => Promise; /** * Get the status using the track id generated after send a new invoice or other document * @param trackId string * @returns promise with the tracking status */ statusTrackIdApi: (trackId: string) => Promise; /** * Consulta de estado e‐CF (CONSUMO Y CRÉDITO FISCAL) *Servicio web responsable de responder la validez o estado de un e‐CF a un receptor o incluso a un emisor, a través de la presentación del RNC emisor, e‐NCF y dos campos condicionales a la vigencia del comprobante, RNC Comprador y el código de seguridad. * @param rncEmisor * @param ncfElectronico * @param rncComprador optional solo factura de consumo * @param codigoSeguridad CONSUMO: 6 digitos asignado en el resumen. CREDITO FISCAL >>> codigoSeguridad: extraído de los primeros seis (6) dígitos del * hash generado en el SignatureValue de la firma digital del e-CFrecibido. Factura de credito fiscal * @returns */ inquiryStatusApi: (rncEmisor: string, ncfElectronico: string, rncComprador?: string, codigoSeguridad?: string) => Promise; /** * Return all the tracking associated with a NCF * @param rncEmisor Receiver RNC * @param encf electronic NCF * @returns */ getAllTrackingncfApi: (rncEmisor: string, encf: string) => Promise; /** * Return the URLs for the customer if the customer is authorize to receive and approve electronic eCF * * The DGII directory service is inconsistent about the response shape: some * environments/records return an array of directory entries while others return a * single directory entry object (see PR #24). To keep the contract stable for every * consumer, the response is normalized here so this method always resolves to an * array (or `undefined` when the service returns no body). * * @param rnc * @returns Promise ServiceDirectory array of URL */ getCustomerDirectoryApi: (rnc: string) => Promise; /** * Consulta de Resumen de Factura (RFCE) * Servicio web responsable de responder la validez o estado de un ENCF a un receptor o * incluso a un emisor, a través de la presentación del RNC emisor, e‐NCF y el código de seguridad. * >>>>>>>>>>>>>> ONLY AVAILABLE ON PRODUCTION ENVIRONEMNT <<<<<<<<<<<<<<< * @param rnc_emisor * @param encf * @param cod_seguridad_eCF CONSUMO: 6 digitos asignado en el resumen. * @returns */ getSummaryInvoiceInquiryApi: (rnc_emisor: string, encf: string, cod_seguridad_eCF: string) => Promise; /** * This method combine 3 different endpoint to get the status of the service * In order to consume it need the API key given by the DGII * @param statusOperation * @param apiKey * @returns */ dgiiCloudServicesStatusApi: (statusOperation: StatusOperation, apiKey: string) => Promise; } export default RestApi;