---
# System prepended metadata

title: api for app

---

URL
>     $language='zh' | 'en' | 'id' | 'vi'
    web: https://staging.clconline.store/$language?agent=clcapp
    api: https://staging-app-api.clconline.store

1.透過webview取得 token 與 refresh_token

    formData.append('cellphone', cellphone)
    formData.append('token', token)
    formData.append('refresh_token', refresh_token)
    formData.append('country_code', "+886")

2.刷新token

    POST /auth/refresh_token
    --header 'Authorization: Bearer eyJhbGciOi'
    --header 'x-refresh-token: j_bklwk1l3'

```jsonld
{
    "access_token": "eyJhbGciOiJIUzI1NiIsImtpZCI6Im1TNkV2eEVFNmtjdk9WVngiLCJ0eXAiOiJKV1QifQ.eyJhdWQiOiJhdXRoZW50aWNhdGVkIiwiZXhwIjoxNzA4OTM4MjQ5LCJpYXQiOjE3MDg5MzQ2NDksImlzcyI6Imh0dHBzOi8vbHBpcWVhbmluY3Rkc2xvcmlsaW0uc3VwYWJhc2UuY28vYXV0aC92MSIsInN1YiI6ImQ3ZDNmNTliLWJkNDctNGRmNi1hYTRmLTk5NDQzOTZhNDEyOCIsImVtYWlsIjoiIiwicGhvbmUiOiI4ODY5MTIzNDU2NzQiLCJhcHBfbWV0YWRhdGEiOnsicHJvdmlkZXIiOiJwaG9uZSIsInByb3ZpZGVycyI6WyJwaG9uZSJdfSwidXNlcl9tZXRhZGF0YSI6eyJuYW1lIjoiTWFydGluIHRlc3QifSwicm9sZSI6ImF1dGhlbnRpY2F0ZWQiLCJhYWwiOiJhYWwxIiwiYW1yIjpbeyJtZXRob2QiOiJwYXNzd29yZCIsInRpbWVzdGFtcCI6MTcwODkzNDYyN31dLCJzZXNzaW9uX2lkIjoiNWI4YTdiZDgtNTg3My00NWU0LTk5YzEtNTk0OTQzMzNjM2RlIn0.V7xIKq0owB87vXk854Yrhc_2V8hsRzNQaNSMeiCJUio",
    "refresh_token": "PhJwAysIQBUuCANT84i7hw"
}
```
3.登出

    POST /auth/sign_out 
    --header 'Authorization: Bearer eyJhbGciOi'
    --header 'x-refresh-token: j_bklwk1l3'

4.取得會員資訊
    
    GET /user/profile --header 'Authorization: Bearer eyJhbGciOi'

Response
```jsonld=
{
    "id": 1,
    "email": "example@example.com",
    "cellphone": "",
    "name": "test",
    "clc_point": 10,
    "cashback": 20
}
```
    
5.取得訂單列表 (X

    

6.更新會員資訊 (api延後開發) (前台畫面 需帶入token 可編輯會員畫面)

    PUT /user/profile --header 'Authorization: Bearer eyJhbGciOi'

```jsonld=
{
    "name": "test2"
}
```

7.取得所有交易紀錄 (固定ip)

    GET /clc_point/logs?method=1&date=2023-01-01
    method => 1：開卡(會員註冊) 2：儲值 3：使用(扣款) 4：儲值作廢 5：使用作廢
    若無帶入method 則撈出所有資料
    
```jsonld=
[{
    'order_id': "",
    'org_order_id': "",
    'amount': 0,
    'created_at': ""
}]
```

8.取得個人交易紀錄 (先不用

    GET /user/clc_point/logs?method=1&date=2023-01-01 --header 'Authorization: Bearer eyJhbGciOi'
    method => 1：開卡(會員註冊) 2：儲值 3：使用(扣款) 4：儲值作廢 5：使用作廢
    若無帶入method 則撈出所有資料
```jsonld
[{
    'order_id': "",
    'org_order_id': "",
    'amount': 1,
    'created_at': ""
}]
```

9.轉帳

    POST /clc_point/transaction --header 'Authorization: Bearer eyJhbGciOi'
```json=
{
    "phone": "886912345678", //格式為 886開頭 沒有'+'號
    "amount": 1
} 
```

1, 2, ,3 ,4, 9 優先做