Awesome
Depend�ncias (Incluidas tamb�m na pasta lib)
Campos dispon�veis
Download
cobregratis-java-1.2.1.jar
Utilizando
Exemplo para pegar um determinado boleto
import br.com.cobregratis.CobreGratis;
import br.com.cobregratis.models.BankBillet;
CobreGratis cobreGratis = new CobreGratis("SEU_TOKEN", "api_name");
try{
BankBillet billet = cobreGratis.getBankBillet(74899);
System.out.println(billet.getName());
} catch (Exception e) {
e.printStackTrace();
}
Ou identificando as exceptions
import br.com.cobregratis.CobreGratis;
import br.com.cobregratis.models.BankBillet;
import br.com.cobregratis.exceptions.CobreGratisBadRequestException;
import br.com.cobregratis.exceptions.CobreGratisForbiddenException;
import br.com.cobregratis.exceptions.CobreGratisInternalServerErrorException;
import br.com.cobregratis.exceptions.CobreGratisNotFoundException;
import br.com.cobregratis.exceptions.CobreGratisServiceUnavailableException;
import br.com.cobregratis.exceptions.CobreGratisTooManyRequestsException;
import br.com.cobregratis.exceptions.CobreGratisUnauthorizedException;
CobreGratis cobreGratis = new CobreGratis("SEU_TOKEN", "api_name");
try{
BankBillet billet = cobreGratis.getBankBillet(74899);
System.out.println(billet.getName());
} catch (CobreGratisBadRequestException e) {
e.printStackTrace();
} catch (CobreGratisUnauthorizedException e) {
e.printStackTrace();
} catch (CobreGratisForbiddenException e) {
e.printStackTrace();
} catch (CobreGratisServiceUnavailableException e) {
e.printStackTrace();
} catch (CobreGratisInternalServerErrorException e) {
e.printStackTrace();
} catch (CobreGratisNotFoundException e) {
e.printStackTrace();
} catch (CobreGratisTooManyRequestsException e) {
e.printStackTrace();
}
Criando um boleto
import br.com.cobregratis.CobreGratis;
import br.com.cobregratis.models.BankBillet;
import br.com.cobregratis.exceptions.CobreGratisBadRequestException;
import br.com.cobregratis.exceptions.CobreGratisForbiddenException;
import br.com.cobregratis.exceptions.CobreGratisInternalServerErrorException;
import br.com.cobregratis.exceptions.CobreGratisNotFoundException;
import br.com.cobregratis.exceptions.CobreGratisServiceUnavailableException;
import br.com.cobregratis.exceptions.CobreGratisTooManyRequestsException;
import br.com.cobregratis.exceptions.CobreGratisUnauthorizedException;
CobreGratis cobreGratis = new CobreGratis("SEU_TOKEN", "api_name");
try{
BankBillet billet = new BankBillet();
billet.setAmount(new BigDecimal(230.00));
Calendar calExpire = Calendar.getInstance();
calExpire.set(25, 3, 2013, 0, 0,0);
billet.setExpireAt(calExpire.getTime());
billet.setName("Carlos Ribeiro - sacado");
billet = cobreGratis.save(billet);
System.out.println(billet.getOurNumber());
} catch (CobreGratisBadRequestException e) {
e.printStackTrace();
} catch (CobreGratisUnauthorizedException e) {
e.printStackTrace();
} catch (CobreGratisForbiddenException e) {
e.printStackTrace();
} catch (CobreGratisServiceUnavailableException e) {
e.printStackTrace();
} catch (CobreGratisInternalServerErrorException e) {
e.printStackTrace();
} catch (CobreGratisNotFoundException e) {
e.printStackTrace();
} catch (CobreGratisTooManyRequestsException e) {
e.printStackTrace();
}
Atualizar um boleto (apenas boletos em rascunho)
import br.com.cobregratis.CobreGratis;
import br.com.cobregratis.models.BankBillet;
import br.com.cobregratis.exceptions.CobreGratisBadRequestException;
import br.com.cobregratis.exceptions.CobreGratisForbiddenException;
import br.com.cobregratis.exceptions.CobreGratisInternalServerErrorException;
import br.com.cobregratis.exceptions.CobreGratisNotFoundException;
import br.com.cobregratis.exceptions.CobreGratisServiceUnavailableException;
import br.com.cobregratis.exceptions.CobreGratisTooManyRequestsException;
import br.com.cobregratis.exceptions.CobreGratisUnauthorizedException;
CobreGratis cobreGratis = new CobreGratis("SEU_TOKEN", "api_name");
try{
BankBillet billet = cobreGratis.getBankBillet(108874);
billet.setAmount(billet.getAmount().add(new BigDecimal(10)));
cobreGratis.update(billet);
System.out.println(billet.getAmount());
} catch (Exception e) {
e.printStackTrace();
}
Excluir um boleto
import br.com.cobregratis.CobreGratis;
import br.com.cobregratis.models.BankBillet;
import br.com.cobregratis.exceptions.CobreGratisBadRequestException;
import br.com.cobregratis.exceptions.CobreGratisForbiddenException;
import br.com.cobregratis.exceptions.CobreGratisInternalServerErrorException;
import br.com.cobregratis.exceptions.CobreGratisNotFoundException;
import br.com.cobregratis.exceptions.CobreGratisServiceUnavailableException;
import br.com.cobregratis.exceptions.CobreGratisTooManyRequestsException;
import br.com.cobregratis.exceptions.CobreGratisUnauthorizedException;
CobreGratis cobreGratis = new CobreGratis("SEU_TOKEN", "api_name");
try{
BankBillet billet = cobreGratis.getBankBillet(108874);
cobreGratis.delete(billet);
} catch (Exception e) {
e.printStackTrace();
}
Listar Boletos
import br.com.cobregratis.CobreGratis;
import br.com.cobregratis.models.BankBillet;
import br.com.cobregratis.exceptions.CobreGratisBadRequestException;
import br.com.cobregratis.exceptions.CobreGratisForbiddenException;
import br.com.cobregratis.exceptions.CobreGratisInternalServerErrorException;
import br.com.cobregratis.exceptions.CobreGratisNotFoundException;
import br.com.cobregratis.exceptions.CobreGratisServiceUnavailableException;
import br.com.cobregratis.exceptions.CobreGratisTooManyRequestsException;
import br.com.cobregratis.exceptions.CobreGratisUnauthorizedException;
CobreGratis cobreGratis = new CobreGratis("SEU_TOKEN", "api_name");
try{
List<BankBillet> list = cobreGratis.getBankBillets(2);
System.out.println(list.get(0).getOurNumber());
} catch (CobreGratisBadRequestException e) {
e.printStackTrace();
} catch (CobreGratisUnauthorizedException e) {
e.printStackTrace();
} catch (CobreGratisForbiddenException e) {
e.printStackTrace();
} catch (CobreGratisServiceUnavailableException e) {
e.printStackTrace();
} catch (CobreGratisInternalServerErrorException e) {
e.printStackTrace();
} catch (CobreGratisNotFoundException e) {
e.printStackTrace();
} catch (CobreGratisTooManyRequestsException e) {
e.printStackTrace();
}
Quitar um boleto
CobreGratis cobreGratis = new CobreGratis("SEU_TOKEN", "api_name");
try{
BankBillet billet = cobreGratis.getBankBillet(108874);
cobreGratis.pay(billet, new Date(), new BigDecimal(300.00) );
} catch (Exception e) {
e.printStackTrace();
}