@@ -3,21 +3,19 @@ import { Page, PagePromise } from '../pagination.js';
33import type {
44 Account ,
55 AccountListParams ,
6- AccountCreateInput ,
7- AccountUpdateInput ,
86 PaginatedResponse ,
9- RequestOptions ,
107} from '../types.js' ;
118
129export class Accounts {
1310 constructor ( private readonly _client : CyncoClient ) { }
1411
1512 /**
16- * List chart of accounts with pagination .
13+ * List chart of accounts.
1714 *
1815 * ```ts
19- * for await (const account of cynco.accounts.list({ type: 'revenue' })) {
20- * console.log(`${account.code} — ${account.name}`);
16+ * const page = await cynco.accounts.list({ account_type: 'revenue' });
17+ * for (const account of page.data) {
18+ * console.log(`${account.accountCode} — ${account.accountName}`);
2119 * }
2220 * ```
2321 */
@@ -40,39 +38,7 @@ export class Accounts {
4038
4139 /** Retrieve a single account by ID. */
4240 async retrieve ( id : string ) : Promise < Account > {
43- const response = await this . _client . get < Account > ( `/accounts/${ id } ` ) ;
44- return response . data ;
45- }
46-
47- /** Create a new account. */
48- async create (
49- data : AccountCreateInput ,
50- options ?: RequestOptions ,
51- ) : Promise < Account > {
52- const response = await this . _client . post < Account > (
53- '/accounts' ,
54- data ,
55- options ,
56- ) ;
57- return response . data ;
58- }
59-
60- /** Update an existing account. */
61- async update (
62- id : string ,
63- data : AccountUpdateInput ,
64- options ?: RequestOptions ,
65- ) : Promise < Account > {
66- const response = await this . _client . patch < Account > (
67- `/accounts/${ id } ` ,
68- data ,
69- options ,
70- ) ;
71- return response . data ;
72- }
73-
74- /** Delete an account. Only unused accounts can be deleted. */
75- async delete ( id : string , options ?: RequestOptions ) : Promise < void > {
76- await this . _client . delete ( `/accounts/${ id } ` , options ) ;
41+ const response = await this . _client . get < Account > ( `/accounts?id=${ encodeURIComponent ( id ) } ` ) ;
42+ return response . data ; // accounts uses ?id= since there's no /:id route
7743 }
7844}
0 commit comments