Search in sources :

Example 1 with TransactionResponse

use of uk.gov.pay.api.model.TransactionResponse in project pay-publicapi by alphagov.

the class TransactionSearchService method processResponse.

private TransactionSearchResults processResponse(Response connectorResponse) {
    PaymentSearchResponse<TransactionResponse> response;
    try {
        response = connectorResponse.readEntity(new GenericType<PaymentSearchResponse<TransactionResponse>>() {
        });
    } catch (ProcessingException ex) {
        throw new SearchTransactionsException(ex);
    }
    List<PaymentForSearchResult> chargeFromResponses = response.getPayments().stream().map(this::getPaymentForSearchResult).collect(toList());
    return new TransactionSearchResults(response.getTotal(), response.getCount(), response.getPage(), chargeFromResponses, transformLinks(response.getLinks()));
}
Also used : GenericType(javax.ws.rs.core.GenericType) TransactionResponse(uk.gov.pay.api.model.TransactionResponse) PaymentForSearchResult(uk.gov.pay.api.model.search.card.PaymentForSearchResult) TransactionSearchResults(uk.gov.pay.api.ledger.model.TransactionSearchResults) ProcessingException(javax.ws.rs.ProcessingException) SearchTransactionsException(uk.gov.pay.api.exception.SearchTransactionsException)

Example 2 with TransactionResponse

use of uk.gov.pay.api.model.TransactionResponse in project pay-publicapi by alphagov.

the class LedgerService method searchPayments.

public PaymentSearchResponse<TransactionResponse> searchPayments(Account account, Map<String, String> paramsAsMap) {
    paramsAsMap.put(PARAM_ACCOUNT_ID, account.getAccountId());
    paramsAsMap.put(PARAM_TRANSACTION_TYPE, PAYMENT_TRANSACTION_TYPE);
    paramsAsMap.put(PARAM_EXACT_REFERENCE_MATCH, "true");
    Response response = client.target(ledgerUriGenerator.transactionsURIWithParams(paramsAsMap)).request().accept(MediaType.APPLICATION_JSON_TYPE).get();
    if (response.getStatus() == SC_OK) {
        try {
            return response.readEntity(new GenericType<PaymentSearchResponse<TransactionResponse>>() {
            });
        } catch (ProcessingException ex) {
            throw new SearchPaymentsException(ex);
        }
    }
    throw new SearchPaymentsException(response);
}
Also used : PaymentSearchResponse(uk.gov.pay.api.model.search.card.PaymentSearchResponse) TransactionResponse(uk.gov.pay.api.model.TransactionResponse) Response(javax.ws.rs.core.Response) SearchPaymentsException(uk.gov.pay.api.exception.SearchPaymentsException) PaymentSearchResponse(uk.gov.pay.api.model.search.card.PaymentSearchResponse) ProcessingException(javax.ws.rs.ProcessingException)

Aggregations

ProcessingException (javax.ws.rs.ProcessingException)2 TransactionResponse (uk.gov.pay.api.model.TransactionResponse)2 GenericType (javax.ws.rs.core.GenericType)1 Response (javax.ws.rs.core.Response)1 SearchPaymentsException (uk.gov.pay.api.exception.SearchPaymentsException)1 SearchTransactionsException (uk.gov.pay.api.exception.SearchTransactionsException)1 TransactionSearchResults (uk.gov.pay.api.ledger.model.TransactionSearchResults)1 PaymentForSearchResult (uk.gov.pay.api.model.search.card.PaymentForSearchResult)1 PaymentSearchResponse (uk.gov.pay.api.model.search.card.PaymentSearchResponse)1