1 package fr.paris.lutece.plugins.facturationbo.rs;
2
3 import com.fasterxml.jackson.core.type.TypeReference;
4 import com.fasterxml.jackson.databind.DeserializationFeature;
5 import com.fasterxml.jackson.databind.ObjectMapper;
6 import fr.paris.lutece.plugins.facturationbo.business.model.DocumentFacturationRestResponse;
7 import fr.paris.lutece.portal.service.util.AppLogService;
8 import fr.paris.lutece.util.httpaccess.HttpAccess;
9 import fr.paris.lutece.util.httpaccess.HttpAccessException;
10
11 import java.io.IOException;
12 import java.util.ArrayList;
13 import java.util.List;
14 import java.util.Map;
15
16
17
18
19
20 public class DocumentsFacturationRestClientService extends AbstractWSFacturation
21 {
22 private final ObjectMapper _objectMapper;
23
24 @Deprecated
25 public DocumentsFacturationRestClientService(String referentielBaseUrl )
26 {
27 super( referentielBaseUrl );
28 _objectMapper = new ObjectMapper( );
29 _objectMapper.configure( DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false );
30 }
31 public DocumentsFacturationRestClientService(String referentielBaseUrl, String xGraviteeApiKey )
32 {
33 super( referentielBaseUrl, xGraviteeApiKey );
34 _objectMapper = new ObjectMapper( );
35 _objectMapper.configure( DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false );
36 }
37
38
39
40
41
42
43 public List<DocumentFacturationRestResponse> recupererListDocumentsFacturationParDebiteur(String cuid )
44 {
45 HttpAccess httpAccess = new HttpAccess( );
46
47 try
48 {
49 String apiUrl = getReferentielBaseUrl( ) + Constants.RECUPERATION_FACTURES_INDIVIDU_AVEC_GUID_V1 + cuid;
50 Map<String, String> mapHeadersRequest = genereHeaderGravitee( null );
51 String response = httpAccess.doGet( apiUrl, null, null, mapHeadersRequest );
52 return _objectMapper.readValue(response, new TypeReference<List<DocumentFacturationRestResponse>>(){});
53 }
54 catch( IOException | HttpAccessException e )
55 {
56 AppLogService.error("error during mapping response", e);
57 return new ArrayList<>( );
58 }
59 }
60 }