Biblioteca Java para acessar a API do Cobre Gratis
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();
}
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();
}
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();
}
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();
}
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();
}
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();
}
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();
}