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

com.braintreegateway.ExchangeRateQuotePayload Maven / Gradle / Ivy

package com.braintreegateway;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class ExchangeRateQuotePayload {
    private List quotes;

    public ExchangeRateQuotePayload quotes(List quotes) {
        this.quotes = quotes;
        return this;
    }

    public ExchangeRateQuotePayload() {
    }

    public ExchangeRateQuotePayload (Map data) {
        this.quotes = new ArrayList<>();
        List> quoteObjs = (List>)data.get("quotes");

        for (Map quoteObj : quoteObjs) {
            Map baseAmountObj = (Map) quoteObj.get("baseAmount");
            Map quoteAmountObj = (Map) quoteObj.get("quoteAmount");
            MonetaryAmount baseAmount = new MonetaryAmount();
            baseAmount.setValue(new BigDecimal((String) baseAmountObj.get("value")));
            baseAmount.setCurrencyCode((String) baseAmountObj.get("currencyCode"));
            MonetaryAmount quoteAmount = new MonetaryAmount();
            quoteAmount.setValue(new BigDecimal((String) quoteAmountObj.get("value")));
            quoteAmount.setCurrencyCode((String) quoteAmountObj.get("currencyCode"));

            ExchangeRateQuote quote = new ExchangeRateQuote()
                .exchangeRate((String) quoteObj.get("exchangeRate"))
                .id((String) quoteObj.get("id"))
                .tradeRate((String) quoteObj.get("tradeRate"))
                .expiresAt((String) quoteObj.get("expiresAt"))
                .refreshesAt((String) quoteObj.get("refreshesAt"))
                .baseAmount(baseAmount)
                .quoteAmount(quoteAmount);

            this.quotes.add(quote);
        }
    }

    public List getQuotes() {
        return quotes;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy