Package com.braintreegateway.util

Examples of com.braintreegateway.util.NodeWrapper


    public AddOnGateway(Http http) {
        this.http = http;
    }

    public List<AddOn> all() {
        NodeWrapper node = http.get("/add_ons");

        List<AddOn> addOns = new ArrayList<AddOn>();

        for (NodeWrapper addOnResponse : node.findAll("add-on")) {
            addOns.add(new AddOn(addOnResponse));
        }

        return addOns;
    }
View Full Code Here


    public MerchantAccount(NodeWrapper node) {
        this.id = node.findString("id");
        this.status = EnumUtils.findByName(Status.class, node.findString("status"));

        NodeWrapper masterNode = node.findFirst("master-merchant-account");
        if (masterNode != null)
            this.masterMerchantAccount = new MerchantAccount(masterNode);
        else
            this.masterMerchantAccount = null;

        NodeWrapper individualNode = node.findFirst("individual");
        if (individualNode != null)
            this.individualDetails = new IndividualDetails(individualNode);
        else
            this.individualDetails = null;

        NodeWrapper businessNode = node.findFirst("business");
        if (businessNode != null)
            this.businessDetails = new BusinessDetails(businessNode);
        else
            this.businessDetails = null;

        NodeWrapper fundingNode = node.findFirst("funding");
        if (fundingNode != null)
            this.fundingDetails = new FundingDetails(fundingNode);
        else
            this.fundingDetails = null;
    }
View Full Code Here

    public WebhookNotification(NodeWrapper node) {
        this.kind = EnumUtils.findByName(Kind.class, node.findString("kind"));
        this.timestamp = node.findDateTime("timestamp");

        NodeWrapper wrapperNode = node.findFirst("subject");

        if (wrapperNode.findFirst("api-error-response") != null) {
            wrapperNode = wrapperNode.findFirst("api-error-response");
        }

        if (wrapperNode.findFirst("subscription") != null) {
            this.subscription = new Subscription(wrapperNode.findFirst("subscription"));
        }

        if (wrapperNode.findFirst("disbursement") != null) {
            this.disbursement = new Disbursement(wrapperNode.findFirst("disbursement"));
        }

        if (wrapperNode.findFirst("merchant-account") != null) {
            this.merchantAccount = new MerchantAccount(wrapperNode.findFirst("merchant-account"));
        }

        if (wrapperNode.findFirst("dispute") != null) {
            this.dispute = new Dispute(wrapperNode.findFirst("dispute"));
        }

        if (wrapperNode.findFirst("transaction") != null) {
            this.transaction = new Transaction(wrapperNode.findFirst("transaction"));
        }

        if (wrapperNode.findFirst("partner-merchant") != null) {
            this.partnerMerchant = new PartnerMerchant(wrapperNode.findFirst("partner-merchant"));
        }

        if (!wrapperNode.isSuccess()) {
            this.errors = new ValidationErrors(wrapperNode);
        }
    }
View Full Code Here

        prepaid = node.findString("prepaid");
        countryOfIssuance = node.findString("country-of-issuance");
        issuingBank = node.findString("issuing-bank");
        uniqueNumberIdentifier = node.findString("unique-number-identifier");
        token = node.findString("token");
        NodeWrapper billingAddressResponse = node.findFirst("billing-address");
        if (billingAddressResponse != null) {
            billingAddress = new Address(billingAddressResponse);
        }
        subscriptions = new ArrayList<Subscription>();
        for (NodeWrapper subscriptionResponse : node.findAll("subscriptions/subscription")) {
View Full Code Here

     * Cancels the {@link Subscription} with the given id.
     * @param id of the {@link Subscription} to cancel.
     * @return a {@link Result}.
     */
    public Result<Subscription> cancel(String id) {
        NodeWrapper node = http.put("/subscriptions/" + id + "/cancel");
        return new Result<Subscription>(node, Subscription.class);
    }
View Full Code Here

     * Creates a {@link Subscription}.
     * @param request the request.
     * @return a {@link Result}.
     */
    public Result<Subscription> create(SubscriptionRequest request) {
        NodeWrapper node = http.post("/subscriptions", request);
        return new Result<Subscription>(node, Subscription.class);
    }
View Full Code Here

     * @param id the id of the {@link Subscription}.
     * @param request the request.
     * @return a {@link Result}.
     */
    public Result<Subscription> update(String id, SubscriptionRequest request) {
        NodeWrapper node = http.put("/subscriptions/" + id, request);
        return new Result<Subscription>(node, Subscription.class);
    }
View Full Code Here

     * Search for a {@link Subscription}.
     * @param searchRequest the {@link SubscriptionSearchRequest}.
     * @return a {@link Result}.
     */
    public ResourceCollection<Subscription> search(SubscriptionSearchRequest searchRequest) {
        NodeWrapper node = http.post("/subscriptions/advanced_search_ids", searchRequest);
        return new ResourceCollection<Subscription>(new SubscriptionPager(this, searchRequest), node);
    }
View Full Code Here

        return new ResourceCollection<Subscription>(new SubscriptionPager(this, searchRequest), node);
    }

    List<Subscription> fetchSubscriptions(SubscriptionSearchRequest search, List<String> ids) {
        search.ids().in(ids);
        NodeWrapper response = http.post("/subscriptions/advanced_search", search);

        List<Subscription> items = new ArrayList<Subscription>();
        for (NodeWrapper node : response.findAll("subscription")) {
            items.add(new Subscription(node));
        }
       
        return items;
    }
View Full Code Here

       
        return items;
    }
       
    private Result<Transaction> retryCharge(SubscriptionTransactionRequest txnRequest) {
        NodeWrapper response = http.post("/transactions", txnRequest);
        return new Result<Transaction>(response, Transaction.class);
    }
View Full Code Here

TOP

Related Classes of com.braintreegateway.util.NodeWrapper

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.