@Post
  public Representation criarContaAPagar(Representation r) throws IOException, JSONException {
    String tipoConta = (String) getRequestAttributes().get("tipoConta");
    JsonRepresentation jsonRep = new JsonRepresentation(r);
    JSONObject json = jsonRep.getJsonObject();

    Promissoria p = new Promissoria();

    String numero = json.getString("numeroDocumento");
    String dataEmissao = json.getString("dataEmissao");
    String dataPagamento = json.getString("dataPagamento");
    String descricao = json.getString("descricao");
    String fornecedor = json.getString("fornecedor");

    if (tipoConta.equals("promissoria")) {
      p = new Promissoria();
    } else {
      String banco = json.getString("banco");
      Duplicata d = new Duplicata();
      d.setBanco(BancoDePagamento.valueOf(banco));
      p = d;
    }

    p.setNumeroDocumento(numero);
    p.setDataEmissao(dataEmissao);
    p.setDataPagamento(dataPagamento);
    p.setDescricao(descricao);
    p.setFornecedor(fornecedor);
    // p.setStatus(Status.valueOf(status));

    boolean result = contaDao.cadastroConta(p);
    if (result == true) {
      return new StringRepresentation("true");
    } else {
      return new StringRepresentation("false");
    }
  }