Snippets

EasyPaymentGateway Rest(ish) endpoint

Created by Wesley Acheson last modified Wesley Acheson
package com.easypaymentgateway.risk;

import java.math.BigDecimal;

import com.fasterxml.jackson.annotation.JsonCreator;

public class CurrencyLimit {
	
	String iso; 
	BigDecimal min;
	BigDecimal max;
	
	@JsonCreator
	public CurrencyLimit() {
		
	}
	
	public CurrencyLimit(String string, long i, long j) {
		this.iso = string;
		this.min = BigDecimal.valueOf(i);
		this.max = BigDecimal.valueOf(j);
		}
	public String getIso() {
		return iso;
	}
	public void setIso(String iso) {
		this.iso = iso;
	}
	public BigDecimal getMin() {
		return min;
	}
	public void setMin(BigDecimal min) {
		this.min = min;
	}
	public BigDecimal getMax() {
		return max;
	}
	public void setMax(BigDecimal max) {
		this.max = max;
	}

}
    @RequestMapping(value = "/currencySomething", method = RequestMethod.POST)
    public List<CurrencyLimit> getCurrencyLimits(@RequestBody List<String> l) {
    	
    	for (String c :l) {
    		System.out.println(c);
    	}
    	return new ArrayList<CurrencyLimit>() {{
    		add(new CurrencyLimit("GBP", 10, 10000));
    	}};
    }
    
    @RequestMapping(value = "/currencySomething", method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
    public List<CurrencyLimit> getCurrencyLimitsForm(@RequestParam("currencies") List<String> l) {
    	return getCurrencyLimits(l);
    }
    
    @RequestMapping(value = "/getCurrency", method = RequestMethod.GET)
    public List<CurrencyLimit> getCurrencyLimits2() {
    	return new ArrayList<CurrencyLimit>() {{
    		add(new CurrencyLimit("GBP", 10, 10000));
    		add(new CurrencyLimit("EUR", 20, 100000));
    	}};
    }
1
2
3
4
5
6
7
[
  {
    "iso": "GBP",
    "min": 10,
    "max": 10000
  }
]

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.