예제 #1
0
 def test_exchangeCurrency(self):
     logging.info("ApiTest.test_exchangeCurrency")
     print(apis.exchangeCurrency(fMoney=1000.0))
     print(apis.exchangeCurrency(fMoney=1000.0, strFrom="USD", strTo="USD"))
     print(apis.exchangeCurrency(fMoney=1000.0, strFrom="USD", strTo="TWD"))
     print(apis.exchangeCurrency(fMoney=1000.0, strFrom="TWD", strTo="USD"))
     print(apis.exchangeCurrency(fMoney=1000.0, strFrom="JPY", strTo="TWD"))
예제 #2
0
def exchangeCurrency():
    strDate = request.args.get("date", None, type=str) #歷史匯率(暫不處理)
    fMoney = request.args.get("money", 0.0, type=float) #金額
    strFromCurrency = request.args.get("from", "TWD", type=str).upper() #原始幣別
    strToCurrency = request.args.get("to", "TWD", type=str).upper() #目標幣別
    fResultMoney = apis.exchangeCurrency(fMoney=fMoney, strFrom=strFromCurrency, strTo=strToCurrency)
    return jsonify(fResultMoney=fResultMoney,
               form=strFromCurrency,
               to=strToCurrency)