@@ -206,6 +206,98 @@ void retentionDraftCancelAndListUseExpectedPaths() {
206206 assertEquals ("/v2/retentions?status=draft" , listRequest .uri ().getPath () + "?" + listRequest .uri ().getQuery ());
207207 }
208208
209+ @ Test
210+ void invoiceZipRequestCanBeCreated () {
211+ StubHttpClient httpClient = new StubHttpClient ();
212+ httpClient .enqueueJson (200 , "{\" id\" :\" zip_1\" ,\" status\" :\" pending\" }" );
213+
214+ Facturapi sdk = new Facturapi (
215+ FacturapiConfig .builder ("sk_test" )
216+ .httpClient (httpClient .client ())
217+ .build ()
218+ );
219+
220+ var response = sdk .invoices ().createZipRequest (
221+ Map .of (
222+ "year" , 2025 ,
223+ "month" , 3 ,
224+ "issuer_type" , "issuing" ,
225+ "invoice_types" , java .util .List .of ("I" , "E" )
226+ )
227+ );
228+
229+ assertEquals ("zip_1" , response .get ("id" ));
230+ var request = httpClient .requests ().get (0 );
231+ assertEquals ("POST" , request .method ());
232+ assertEquals ("/v2/invoices/zip-requests" , request .uri ().getPath ());
233+ assertTrue (request .bodyUtf8 ().contains ("\" issuer_type\" :\" issuing\" " ));
234+ }
235+
236+ @ Test
237+ void invoiceZipRequestsCanBeListed () {
238+ StubHttpClient httpClient = new StubHttpClient ();
239+ httpClient .enqueueJson (
240+ 200 ,
241+ "{\" page\" :1,\" total_pages\" :1,\" total_results\" :1,\" data\" :[{\" id\" :\" zip_1\" }]}"
242+ );
243+
244+ Facturapi sdk = new Facturapi (
245+ FacturapiConfig .builder ("sk_test" )
246+ .httpClient (httpClient .client ())
247+ .build ()
248+ );
249+
250+ var response = sdk .invoices ().listZipRequests (
251+ Map .of ("year" , 2025 , "month" , 3 , "status" , "finished" , "limit" , 20 , "page" , 1 )
252+ );
253+
254+ assertEquals ("zip_1" , response .getData ().get (0 ).get ("id" ));
255+ var request = httpClient .requests ().get (0 );
256+ assertEquals ("GET" , request .method ());
257+ assertEquals ("/v2/invoices/zip-requests" , request .uri ().getPath ());
258+ assertTrue (request .uri ().getQuery ().contains ("year=2025" ));
259+ assertTrue (request .uri ().getQuery ().contains ("status=finished" ));
260+ }
261+
262+ @ Test
263+ void invoiceZipRequestCanBeRetrieved () {
264+ StubHttpClient httpClient = new StubHttpClient ();
265+ httpClient .enqueueJson (200 , "{\" id\" :\" zip_1\" ,\" status\" :\" finished\" }" );
266+
267+ Facturapi sdk = new Facturapi (
268+ FacturapiConfig .builder ("sk_test" )
269+ .httpClient (httpClient .client ())
270+ .build ()
271+ );
272+
273+ var response = sdk .invoices ().retrieveZipRequest ("zip_1" );
274+
275+ assertEquals ("finished" , response .get ("status" ));
276+ var request = httpClient .requests ().get (0 );
277+ assertEquals ("GET" , request .method ());
278+ assertEquals ("/v2/invoices/zip-requests/zip_1" , request .uri ().getPath ());
279+ }
280+
281+ @ Test
282+ void invoiceZipRequestCanBeDownloaded () throws Exception {
283+ StubHttpClient httpClient = new StubHttpClient ();
284+ httpClient .enqueueBinary (200 , "ZIP-CONTENT" .getBytes (StandardCharsets .UTF_8 ), "application/zip" );
285+
286+ Facturapi sdk = new Facturapi (
287+ FacturapiConfig .builder ("sk_test" )
288+ .httpClient (httpClient .client ())
289+ .build ()
290+ );
291+
292+ try (InputStream stream = sdk .invoices ().downloadZipRequest ("zip_1" )) {
293+ assertEquals ("ZIP-CONTENT" , new String (stream .readAllBytes (), StandardCharsets .UTF_8 ));
294+ }
295+
296+ var request = httpClient .requests ().get (0 );
297+ assertEquals ("GET" , request .method ());
298+ assertEquals ("/v2/invoices/zip-requests/zip_1/zip" , request .uri ().getPath ());
299+ }
300+
209301 @ Test
210302 void organizationUploadsAcceptBytes () {
211303 StubHttpClient httpClient = new StubHttpClient ();
0 commit comments