本專案以 laravel 開發
- PHP ^7.3 / ^8.0
安裝相依套件
composer install
執行
php artisan serve
URIs Relative to {hostname}/api
HTTP Request | 描述 |
---|---|
GET /currency |
支援的貨幣列表及匯率 |
POST /currency/exchange |
換匯估算 |
日幣
轉換為 台幣
之匯率以 data.JPY.TWD
表示
HTTTP Request
GET {hostname}/api/currency
Parameters
No parameters need.
{
"data": {
"TWD": {
"TWD": 1,
"JPY": 3.669,
"USD": 0.03281
},
"JPY": {
"TWD": 0.26956,
"JPY": 1,
"USD": 0.00885
},
"USD": {
"TWD": 30.444,
"JPY": 111.801,
"USD": 1
}
}
}
HTTTP Request
POST {hostname}/api/currency/exchange
Parameters
No parameters need.
Request Body
Property Name | Value | Description |
---|---|---|
currency | string | 目標幣別,/api/currency 所列之一的貨幣 |
payment | string | 原始幣別,/api/currency 所列之一的貨幣 |
amount | float | 原始幣別金額 |
Request sample
{
"currency": "JPY",
"payment": "TWD",
"amount": 100
}
Response
200
Response schema: application/json
{
"data": {
"amount": "366.90"
}
}
400
Response schema: application/json
{
"errors": {
"payment": [
"The selected payment is invalid."
]
}
}