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
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,11 @@ public String getByIds(Set<String> pedidos) throws IOException, PJBankException
return responseObject.getString("linkBoleto");
}

public List<ExtratoBoleto> get(Date inicio, Date fim, StatusPagamentoBoleto pago) throws URISyntaxException, IOException, PJBankException, java.text.ParseException {
public List<ExtratoBoleto> get(Date inicio, Date fim, StatusPagamentoBoleto pago, Integer pagina) throws URISyntaxException, IOException, PJBankException, java.text.ParseException {
PJBankClient client = new PJBankClient(this.endPoint.concat("/transacoes"));
HttpGet httpGet = client.getHttpGetClient();
httpGet.addHeader("x-chave", this.getChave());
this.adicionarFiltros(httpGet, inicio, fim, pago);
this.adicionarFiltros(httpGet, inicio, fim, pago, pagina);

String response = EntityUtils.toString(client.doRequest(httpGet).getEntity());
JSONArray extratoObject = new JSONArray(response);
Expand Down Expand Up @@ -152,14 +152,15 @@ public List<ExtratoBoleto> get(Date inicio, Date fim, StatusPagamentoBoleto pago
return extratos;
}

private void adicionarFiltros(HttpRequestBase httpRequestClient, Date inicio, Date fim, StatusPagamentoBoleto pago)
private void adicionarFiltros(HttpRequestBase httpRequestClient, Date inicio, Date fim, StatusPagamentoBoleto pago, Integer pagina)
throws URISyntaxException {
SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
URIBuilder uriBuilder = new URIBuilder(httpRequestClient.getURI());

uriBuilder.addParameter("data_inicio", formatter.format(inicio));
uriBuilder.addParameter("data_fim", formatter.format(fim));
uriBuilder.addParameter("pago", pago.getName());
uriBuilder.addParameter("pagina", pagina.toString());

httpRequestClient.setURI(uriBuilder.build());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,12 @@ public void get() throws IOException, JSONException, PJBankException, ParseExcep
BoletosManager manager = new BoletosManager(this.credencial, this.chave);
LocalDate inicio = LocalDate.of(2001, 1, 29);
LocalDate fim = LocalDate.now();
List<ExtratoBoleto> extratos = manager.get(Date.from(inicio.atStartOfDay(ZoneId.systemDefault()).toInstant()), Date.from(fim.atStartOfDay(ZoneId.systemDefault()).toInstant()), StatusPagamentoBoleto.ABERTO);
List<ExtratoBoleto> extratos = manager.get(Date.from(inicio.atStartOfDay(ZoneId.systemDefault()).toInstant()), Date.from(fim.atStartOfDay(ZoneId.systemDefault()).toInstant()), StatusPagamentoBoleto.ABERTO, 1);
for (ExtratoBoleto extrato : extratos) {
Assert.assertThat(extrato.getDataPagamento(), nullValue(Date.class));
}

extratos = manager.get(Date.from(inicio.atStartOfDay(ZoneId.systemDefault()).toInstant()), Date.from(fim.atStartOfDay(ZoneId.systemDefault()).toInstant()), StatusPagamentoBoleto.PAGO);
extratos = manager.get(Date.from(inicio.atStartOfDay(ZoneId.systemDefault()).toInstant()), Date.from(fim.atStartOfDay(ZoneId.systemDefault()).toInstant()), StatusPagamentoBoleto.PAGO, 1);
for (ExtratoBoleto extrato : extratos) {
Assert.assertThat(extrato.getDataPagamento(), not(nullValue(Date.class)));
}
Expand Down