Пример #1
0
 public int pay(String number, Double fee) {
   Balance b = get(number);
   if (b == null) return -1;
   Map<String, Object> map = new LinkedHashMap<>();
   map.put("carnumber", number);
   map.put("balance", b.getBalance() - fee);
   JSONArray json = JSONArray.fromObject(map);
   String jstr = json.get(0).toString();
   String url = Values.DOMAIN + "Balance/" + b.getId();
   String resultXML = HttpHelper.SendHttpRequest("put", url, jstr);
   System.out.println(resultXML);
   return 0;
 }
Пример #2
0
 public Balance get(String carNumber) {
   String url = Values.DOMAIN + "Balance/?Balance.carnumber=" + carNumber;
   String resultXML = HttpHelper.SendHttpRequest("get", url, null);
   List<Balance> us = Balance.parseJSON(resultXML);
   if (us.size() == 0) return null;
   return us.get(0);
 }
Пример #3
0
 public List<Balance> getAll() {
   String url = Values.DOMAIN + "Balance/";
   String resultXML = HttpHelper.SendHttpRequest("get", url, null);
   List<Balance> ret = Balance.parseJSON(resultXML);
   return ret;
 }