Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [4.19.0] 2026-07-01

### Added

- Add draft support methods for retentions: `retentions.updateDraft`, `retentions.copyToDraft`, and `retentions.stampDraft`.

## [4.18.0] 2026-06-06
### Added
- Expose structured API error metadata through `FacturapiError`, including `status`, `code`, `path`, `location`, `errors`, `logId`, and response `headers`.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "facturapi",
"version": "4.18.0",
"version": "4.19.0",
"description": "SDK oficial de Facturapi para Node.js y navegadores. Integra facturación electrónica en México (CFDI) de forma simple y obtén una perspectiva fiscal completa de tu operación, con búsquedas indexadas, envío de documentos y trazabilidad.",
"main": "dist/index.cjs.js",
"module": "dist/index.es.js",
Expand Down
56 changes: 42 additions & 14 deletions src/resources/retentions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import {
Retention,
SearchResult,
SendEmailBody,
} from '../types';
import { WrapperClient } from '../wrapper';
} from '../types'
import { WrapperClient } from '../wrapper'

export default class Retentions {
client: WrapperClient;
client: WrapperClient
constructor(client: WrapperClient) {
this.client = client;
this.client = client
}

/**
Expand All @@ -19,7 +19,7 @@ export default class Retentions {
* @returns
*/
create(data: Record<string, any>): Promise<Retention> {
return this.client.post('/retentions', { body: data });
return this.client.post('/retentions', { body: data })
}

/**
Expand All @@ -28,8 +28,8 @@ export default class Retentions {
* @returns
*/
list(params?: Record<string, any> | null): Promise<SearchResult<Retention>> {
if (!params) params = {};
return this.client.get('/retentions', { params });
if (!params) params = {}
return this.client.get('/retentions', { params })
}

/**
Expand All @@ -38,8 +38,8 @@ export default class Retentions {
* @returns
*/
retrieve(id: string): Promise<Retention> {
if (!id) return Promise.reject(new Error('id is required'));
return this.client.get('/retentions/' + id);
if (!id) return Promise.reject(new Error('id is required'))
return this.client.get('/retentions/' + id)
}

/**
Expand All @@ -49,7 +49,35 @@ export default class Retentions {
* @returns
*/
cancel(id: string, params?: Record<string, any>): Promise<Retention> {
return this.client.delete('/retentions/' + id, { params });
return this.client.delete('/retentions/' + id, { params })
}

/**
* Edits a retention with "draft" status.
* @param id Retention Id
* @param data Retention data to edit
* @returns Edited retention
*/
updateDraft(id: string, data: Record<string, any>): Promise<Retention> {
return this.client.put('/retentions/' + id, { body: data })
}

/**
* Stamps a retention with "draft" status.
* @param id Retention Id
* @returns Stamped retention
*/
stampDraft(id: string): Promise<Retention> {
return this.client.post('/retentions/' + id + '/stamp')
}
Comment on lines +65 to +72

/**
* Creates a draft retention from any other retention.
* @param id Retention Id
* @returns Draft retention
*/
copyToDraft(id: string): Promise<Retention> {
return this.client.post('/retentions/' + id + '/copy')
}

/**
Expand All @@ -60,7 +88,7 @@ export default class Retentions {
* @returns
*/
sendByEmail(id: string, data?: SendEmailBody): Promise<GenericResponse> {
return this.client.post('/retentions/' + id + '/email', { body: data });
return this.client.post('/retentions/' + id + '/email', { body: data })
}

/**
Expand All @@ -69,7 +97,7 @@ export default class Retentions {
* @returns PDF file in a stream (Node.js) or Blob (browser)
*/
downloadPdf(id: string): Promise<BinaryDownload> {
return this.client.get('/retentions/' + id + '/pdf');
return this.client.get('/retentions/' + id + '/pdf')
}

/**
Expand All @@ -78,7 +106,7 @@ export default class Retentions {
* @returns XML file in a stream (Node.js) or Blob (browser)
*/
downloadXml(id: string): Promise<BinaryDownload> {
return this.client.get('/retentions/' + id + '/xml');
return this.client.get('/retentions/' + id + '/xml')
}

/**
Expand All @@ -87,6 +115,6 @@ export default class Retentions {
* @returns ZIP file in a stream (Node.js) or Blob (browser)
*/
downloadZip(id: string): Promise<BinaryDownload> {
return this.client.get('/retentions/' + id + '/zip');
return this.client.get('/retentions/' + id + '/zip')
}
}