@@ -81,6 +81,9 @@ interface Sign {
8181 position : string ;
8282}
8383
84+ /**
85+ * Service for managing digital signatures and electronic signature requests
86+ */
8487export class FirmaDigitale implements Service {
8588 client : AxiosInstance ;
8689 readonly service = 'firmaDigitale' ;
@@ -92,47 +95,85 @@ export class FirmaDigitale implements Service {
9295 this . environment = environment ;
9396 }
9497
98+ /**
99+ * Retrieves the list of available digital signature products
100+ */
95101 async getProducts ( ) : Promise < Array < Prodotto > > {
102+ // TODO: Add error handling for failed API requests with user-friendly messages
96103 return await ( await this . client . get ( this . url + '/prodotti' ) ) . data . data
97104 }
98105
106+ /**
107+ * Gets details of a specific digital signature request
108+ * @param id - The request ID
109+ */
99110 async getRequest ( id : string ) {
111+ // TODO: Add validation for empty/invalid ID and graceful error message
100112 return await ( await this . client . get ( this . url + '/richiesta/' + id ) ) . data . data
101113 }
102114
115+ /**
116+ * Lists all digital signature requests
117+ */
103118 async listRequests ( ) : Promise < Array < any > > {
119+ // TODO: Add error handling for API failures
104120 return await ( await this . client . get ( this . url + '/richiesta/' ) ) . data . data
105121 }
106122
123+ /**
124+ * Downloads the request module/form for a specific request
125+ * @param id - The request ID
126+ */
107127 async getRequestModule ( id : string ) : Promise < Buffer > {
128+ // TODO: Add validation and error handling for invalid ID or missing module
108129 return await this . client . get ( this . url + '/richiesta/' + id + '/modulo' ) ;
109130 }
110131
111132 /**
112- *
113- * @param codProdotto il codice del prodotto da richiedere: https://developers.openapi.it/services/firmadigitale
114- * @param data dati aggiuntivi richiesti dallo specifico prodotto richiesto
133+ * Requests a digital signature product
134+ * @param codProdotto - Product code to request (see https://developers.openapi.it/services/firmadigitale)
135+ * @param data - Additional data required by the specific product
136+ * @param assistenza - Whether to request assistance
137+ * @param callback - Optional callback configuration
115138 */
116139 async requestProduct ( codProdotto : string , data : any , assistenza ?: boolean , callback ?: Callback ) {
140+ // TODO: Add validation for codProdotto and data parameters with clear error messages
117141 const body = { ...data } ;
118142 if ( assistenza ) body . assistenza = assistenza ;
119143 if ( callback ) body . callback = callback ;
120144
145+ // TODO: Handle API errors with descriptive messages (invalid product code, missing required fields, etc.)
121146 return await ( await this . client . post ( this . url + '/richiesta/' + codProdotto , JSON . stringify ( body ) ) ) . data . data
122147 }
123148
124149 /**
125- * Firma digitale
150+ * Gets details of a specific electronic signature request
151+ * @param id - The electronic signature ID
126152 */
127153 async getFirmaElettronica ( id : string ) : Promise < FirmaElettronica > {
154+ // TODO: Add error handling for invalid ID or not found cases
128155 return await ( await this . client . get ( this . url + '/firma_elettronica/' + id ) ) . data . data ;
129156 }
130157
158+ /**
159+ * Lists all electronic signature requests
160+ */
131161 async listFirmaElettronica ( ) : Promise < FirmaElettronica [ ] > {
162+ // TODO: Add error handling for API failures
132163 return await ( await this . client . get ( this . url + '/firma_elettronica/' ) ) . data . data ;
133164 }
134165
166+ /**
167+ * Creates a new electronic signature request
168+ * @param filename - Name of the file to be signed
169+ * @param content - Base64 encoded file content
170+ * @param members - Array of signers with their details and signature positions
171+ * @param callback - Optional callback configuration for status updates
172+ * @param title - Optional title for the signature request
173+ * @param description - Optional description
174+ */
135175 async createFirmaElettronica ( filename : string , content : string , members : FesMember [ ] , callback ?: FesCallback , title ?: string , description ?: string ) : Promise < FirmaElettronica > {
176+ // TODO: Validate required fields (filename, content, members) and provide clear error messages
136177 let body : any = {
137178 filename,
138179 content,
@@ -143,13 +184,23 @@ export class FirmaDigitale implements Service {
143184 if ( title ) body . title = title ;
144185 if ( description ) body . description = description ;
145186
187+ // TODO: Handle API errors (invalid file format, missing member info, etc.) with user-friendly messages
146188 return await ( await this . client . post ( this . url + '/firma_elettronica/base' , JSON . stringify ( body ) ) ) . data . data ;
147189 }
148190
191+ /**
192+ * Downloads the signed document
193+ * @param id - The electronic signature ID
194+ * @returns Base64 encoded signed document
195+ */
149196 async downloadFirmaElettronica ( id : string ) : Promise < string > {
197+ // TODO: Add error handling for invalid ID or document not ready cases
150198 return await ( await this . client . get ( this . url + '/firma_elettronica/' + id + '/download' ) ) . data . content ;
151199 }
152200
201+ /**
202+ * Gets the full service URL based on environment
203+ */
153204 get url ( ) {
154205 return getBaseUrl ( this . environment , this . baseUrl )
155206 }
0 commit comments