All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.braintreegateway.CreditCardVerificationGateway Maven / Gradle / Ivy

There is a newer version: 3.32.0_1
Show newest version
package com.braintreegateway;

import com.braintreegateway.exceptions.NotFoundException;
import com.braintreegateway.util.Http;
import com.braintreegateway.util.NodeWrapper;
import java.util.ArrayList;
import java.util.List;

public class CreditCardVerificationGateway {
    private Configuration configuration;
    private Http http;

    public CreditCardVerificationGateway(Http http, Configuration configuration) {
        this.configuration = configuration;
        this.http = http;
    }

    List fetchCreditCardVerifications(CreditCardVerificationSearchRequest query, List ids) {
        query.ids().in(ids);
        NodeWrapper response = http.post(configuration.getMerchantPath() + "/verifications/advanced_search", query);

        List items = new ArrayList();
        for (NodeWrapper node : response.findAll("verification")) {
            items.add(new CreditCardVerification(node));
        }

        return items;
    }

    public CreditCardVerification find(String id) {
        if (id == null || id.trim().equals("")) {
            throw new NotFoundException();
        }

        return new CreditCardVerification(http.get(configuration.getMerchantPath() + "/verifications/" + id));
    }

    public ResourceCollection search(CreditCardVerificationSearchRequest query) {
        NodeWrapper node = http.post(configuration.getMerchantPath() + "/verifications/advanced_search_ids", query);
        return new ResourceCollection(new CreditCardVerificationPager(this, query), node);
    }

    public Result create(CreditCardVerificationRequest request) {
        NodeWrapper response = http.post(configuration.getMerchantPath() + "/verifications", request);
        return new Result(response, CreditCardVerification.class);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy