Customer
Auth /auth
POST /auth/login → đã test {
username,
password,
}
status: 200
{
info,
accessToken,
refreshToken,
}
404 Không tìm thấy username GET /auth/refresh → đã test 400 sai accessToken hoặc refreshtoken POST /auth/reset_password - yêu cầu thay đổi password POST /auth/new_password - thay đổi password request body { email, OTP, password } Customer /customer
Tất cả API bên dưới đều cần gửi
headers
x-access-token
POST /customer/password → đổi mật khẩu {
old_password,
new_password
}
Account
GET /customer/accounts → đã test 200 → trả về thông tin account 404 → không tìm thấy account GET /customer/accounts/:account_number → đã test 200 → trả về thông tin account POST /customer/accounts → đã test {
“account_name,
account_object
}
{
success:true,
user_id
account_number:,
account_name
account_object
}
400 → thiếu các trường → có kèm theo trong errors DELETE /customer/accounts/:account_number → đã test { success, deleted_account}
400 → account còn tiền hoặc là tài khoản chính → không xóa được PUT /customer/accounts/:account_number→ đã test { success, result}
400 → Tài khoản không phải là tài khoản tiết kiệm → không xóa được 500 → lỗi server bị cái vẹo gì đó chưa test kĩ Receiver
GET /customer/receivers → đã test Trả về danh sách receiver GET/customer/receivers/:_id → đã test (id là receiver id) POST /customer/receivers → test done → đã test {nhập tên gợi nhớ, không nhập tên gợi nhớ, thiếu account number hoặc bank }
{
name
account_number
bank
}
200 → success
400 → thiếu trường
500 → LỖI SERVER
PUT /customer/receivers/:_id → đã test { name}
response → trả về receiver sau khi thay đổi DELETE /customer/receivers/:_id → đã test DEBT LIST
GET /customer/debt_list → đã check 1 tài khoản {
debt : danh sách nhắc nợ mà người khác gửi cho mình, → mảng
own: danh sách nhắc nợ mình gửi người ta → mảng
}
GET /customer/debt_list/:_id → đã test POST /customer/debt_list → check, đã test {
src_account_number,
des_account_number,
description,
amount
}
200 → tạo thành công → trả về success và cái nhắc nợ PUT /customer/debt_list/:id → cancel nhắc nợ, request → body gửi description → nếu có DELETE /customer/debt_list/:id → điều kiện là phải cancel User
GET /customer/customers/:account_number → nhận thông tin user theo account_number → đã test 200 →
{
user_name
email
user_id,
full_name
}
Chỉ có thể tìm thông tin dựa trên tài khoản giao dịch
GET /customer/customers/:account_number?bank=”NKL Bank” → nhận thông tin user theo account_number và bank → đã test các ngân hàng đã có thể test Bank
GET /customer/banks → tra cuu danh sach ngan hang
Transaction
GET /transaction/request → yêu cầu lệnh chuyển tiền → đã check POST /transaction/transfer → chuyển tiền → đã check {
"user_name":"luffy",
"password":"onepiece",
"OTP":"496494",
"source_account":"1595967024",
"destination_account":"09437776833040",
"source_bank":"S2Q Bank",
"des_name":"Nguyễn Hoàng Sang",
"destination_bank": "Eight",
"isFeePayBySender": true,
"fee": 3000,
"amount":100000,
"description":"abc"
}
POST/transaction/pay_debt/ → thanh toán nợ → đã check {
OTP,
debtId
}
GET /transaction/histories/:account_number → lịch sử giao dịch của số tài khoản
POST /transaction/withdraw Notification
GET /customer/notification?ts=${ts}
lấy notification
let ts = 0;
function getNotification(){
const instance = axios.create({
baseURL: 'http://localhost:3000/customer/',
timeout:20000, // 20s
headers: {
'x-access-token': accessToken
}
});
const url = `notification?ts=${ts}`;
instance.get(url)
.then((res)=>{
if(res.status === 200){
console.log(res.data)
ts = res.data.return_ts;
}
})
.then(()=>{
getNotification();
});
}
TRả về
200:
{
user_id,
is_seen: false,
type: // loại thông báo [”
content: nội dung thông báo
create_at: thời gian tạo thông báo,
}
POST /customer/notification
gửi kèm accesstoekn trong header
→ các notification chuyển trạng thái thành đã xem, sẽ không get thêm nữa
DELETE /customer/notification
→ các notification sẽ ẩn đi, gọi api sẽ không thấy nữa
Admin
POST /admin/employees → tạo employee {
user_name: ,
password: dài từ 5 tới 20 kí tự,
full_name:
}
POST /admin/admins → tạo admin {
user_name,
password,
full_name
}
POST /admin/customers → tạo customer full_name
email:
phone
}
response → hệ thống sẽ generate ra tên đăng nhập và số tài khoản và mật khẩu cho người udngf. GET /admin/employees → lấy hết danh sách nhân viên GET /admin/customers → danh sách nngườidungf GET /admin/users → lấy danh sách tất cả user trong hệ thống, nếu customer sẽ có thể tài khoản . DELETE /admin/employees/:user_id → xóa người nhân viên DELETE /admin/customers/:user_id → xóa người dùng GET /admin/partners/MPBank ← tên ngân hàng GET /admin/all_partner → danh sách ngân hàng. Employee
POST /employee/customers → tạo customer → Đã test {
user_name,
password,
full_name,
email,
phone
}
201→ thành công
400 → gửi thiếu
GET /employee/customers?email=”email” →get nguoi dùng bằng email GET /employee/accounts/histories/:account_number → lịch sử giao dịch của một tài khoản GET /employee/accounts/histories/:account_number?type=RECEIVED Các type =[ “RECEIVED”, “SEND”, “PAY_DEBT”, “SAVING”, “WITHDRAW” ] POST /employee/accounts/:account_number →nạp tiền vào 1 tài khoản REQUEST
{
amount: số tiền
}