本文整理匯總了Java中org.apache.http.client.methods.HttpGet.removeHeaders方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpGet.removeHeaders方法的具體用法?Java HttpGet.removeHeaders怎麽用?Java HttpGet.removeHeaders使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.http.client.methods.HttpGet
的用法示例。
在下文中一共展示了HttpGet.removeHeaders方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: get
import org.apache.http.client.methods.HttpGet; //導入方法依賴的package包/類
/**
* Retorna o extrato de transações da Conta Digital em formato JSON ou CNAB 240 [Desabilitado]
* @param dataInicio: Data de início do extrato desejado
* @param dataFim: Data de fim do extrato desejado
* @param formato: Formato de extrato desejado (JSON ou CNAB 240 [Desabilitado])
* @return List<TransacaoExtrato>
*/
public List<TransacaoExtrato> get(Date dataInicio, Date dataFim, FormatoExtrato formato) throws IOException, ParseException, URISyntaxException, PJBankException {
PJBankClient client = new PJBankClient(this.endPoint.concat("/transacoes"));
HttpGet httpGet = client.getHttpGetClient();
httpGet.addHeader("x-chave-conta", this.chave);
if (!formato.equals(FormatoExtrato.JSON))
httpGet.removeHeaders("Accept");
URIBuilder uriBuilder = new URIBuilder(httpGet.getURI());
DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
uriBuilder.addParameter("data_inicio", dateFormat.format(dataInicio));
uriBuilder.addParameter("data_fim", dateFormat.format(dataFim));
uriBuilder.addParameter("formato", formato.getName());
httpGet.setURI(uriBuilder.build());
String response = EntityUtils.toString(client.doRequest(httpGet).getEntity());
JSONArray responseArray = new JSONArray(response);
List<TransacaoExtrato> transacoesExtrato = new ArrayList<>();
for(int i = 0; i < responseArray.length(); i++) {
JSONObject responseObject = (JSONObject) responseArray.get(i);
TransacaoExtrato transacaoExtrato = new TransacaoExtrato();
transacaoExtrato.setIdTransacao(responseObject.getString("id_operacao"));
transacaoExtrato.setIdentificador(responseObject.getString("identificador"));
transacaoExtrato.setNomeFavorecido(responseObject.getString("nome_favorecido"));
transacaoExtrato.setCnpjFavorecido(responseObject.getString("cnpj_favorecido"));
transacaoExtrato.setDataPagamento(dateFormat.parse(responseObject.getString("data_pagamento")));
transacaoExtrato.setValor(responseObject.getDouble("valor"));
transacaoExtrato.setHistorico(responseObject.getString("historico"));
transacaoExtrato.setTipo(TipoTransacao.fromString(responseObject.getString("tipo_transacao")));
transacoesExtrato.add(transacaoExtrato);
}
return transacoesExtrato;
}