จัดการสาขา
จัดการสาขาสำหรับบริการ EasySlip ของคุณ สาขาช่วยให้คุณแบ่งการใช้งาน API ตามแผนก สถานที่ หรือแอปพลิเคชันต่างๆ
ดูรายการสาขาทั้งหมด
http
GET /b2b/branchesFull URL: https://api.easyslip.com/b2b/branches
Permission: branch:read
Request
ไม่ต้องส่ง request body
ตัวอย่าง
bash
curl -X GET https://api.easyslip.com/b2b/branches \
-H "X-API-Key: ${API_KEY}" \
-H "X-Timestamp: ${TIMESTAMP}" \
-H "X-Nonce: ${NONCE}" \
-H "X-Signature: ${SIGNATURE}"javascript
const headers = signRequest({
method: 'GET',
path: '/b2b/branches',
body: null,
apiKey: 'your_api_key',
secretKey: 'your_secret_key',
})
const response = await fetch('https://api.easyslip.com/b2b/branches', { headers })
const result = await response.json()Success Response (200)
json
{
"success": true,
"data": [
{
"id": "cm1a2b3c4d5e6f7g8h9i0",
"name": "สำนักงานใหญ่",
"isActive": true,
"ipAddress": null,
"limitQuota": 10000,
"usedQuota": 1500,
"totalUsedQuota": 45000,
"bankAccounts": [
{
"id": "cm9z8y7x6w5v4u3t2s1r0",
"bankCode": "004",
"bankNumber": "123-4-56789-0",
"nameTh": "บริษัท อีซี่สลิป จำกัด",
"nameEn": "EasySlip Co., Ltd."
}
],
"createdAt": "2024-06-15T10:30:00+07:00",
"updatedAt": "2024-12-01T14:00:00+07:00"
},
{
"id": "cm2b3c4d5e6f7g8h9i0j1",
"name": "สาขาเชียงใหม่",
"isActive": true,
"ipAddress": "203.150.100.50",
"limitQuota": 5000,
"usedQuota": 800,
"totalUsedQuota": 12000,
"bankAccounts": [],
"createdAt": "2024-08-20T09:00:00+07:00",
"updatedAt": "2024-11-15T16:30:00+07:00"
}
]
}ฟิลด์ใน Response
| ฟิลด์ | ชนิด | คำอธิบาย |
|---|---|---|
id | string | ID สาขา |
name | string | ชื่อสาขา |
isActive | boolean | สถานะการใช้งานสาขา |
ipAddress | string | null | IP address ที่อนุญาต (null = อนุญาตทุก IP) |
limitQuota | number | null | โควตาสูงสุดของสาขา (null = ใช้โควตาระดับบริการ) |
usedQuota | number | โควตาที่ใช้ไปในรอบนี้ |
totalUsedQuota | number | โควตาที่ใช้ไปทั้งหมดตลอดการใช้งาน |
bankAccounts | array | บัญชีธนาคารที่เชื่อมต่อ |
createdAt | string | เวลาที่สร้าง (ISO 8601) |
updatedAt | string | เวลาที่อัปเดตล่าสุด (ISO 8601) |
ดูข้อมูลสาขา
http
GET /b2b/branches/:branchIdFull URL: https://api.easyslip.com/b2b/branches/:branchId
Permission: branch:read
ตัวอย่าง
bash
curl -X GET https://api.easyslip.com/b2b/branches/cm1a2b3c4d5e6f7g8h9i0 \
-H "X-API-Key: ${API_KEY}" \
-H "X-Timestamp: ${TIMESTAMP}" \
-H "X-Nonce: ${NONCE}" \
-H "X-Signature: ${SIGNATURE}"javascript
const headers = signRequest({
method: 'GET',
path: '/b2b/branches/cm1a2b3c4d5e6f7g8h9i0',
body: null,
apiKey: 'your_api_key',
secretKey: 'your_secret_key',
})
const response = await fetch(
'https://api.easyslip.com/b2b/branches/cm1a2b3c4d5e6f7g8h9i0',
{ headers }
)
const result = await response.json()Success Response (200)
json
{
"success": true,
"data": {
"id": "cm1a2b3c4d5e6f7g8h9i0",
"name": "สำนักงานใหญ่",
"isActive": true,
"ipAddress": null,
"limitQuota": 10000,
"usedQuota": 1500,
"totalUsedQuota": 45000,
"bankAccounts": [
{
"id": "cm9z8y7x6w5v4u3t2s1r0",
"bankCode": "004",
"bankNumber": "123-4-56789-0",
"nameTh": "บริษัท อีซี่สลิป จำกัด",
"nameEn": "EasySlip Co., Ltd."
}
],
"createdAt": "2024-06-15T10:30:00+07:00",
"updatedAt": "2024-12-01T14:00:00+07:00"
}
}Error Response (404)
json
{
"success": false,
"error": {
"code": "BRANCH_NOT_FOUND",
"message": "Branch not found"
}
}สร้างสาขาใหม่
http
POST /b2b/branchesFull URL: https://api.easyslip.com/b2b/branches
Permission: branch:write
Request Body
| ฟิลด์ | ชนิด | จำเป็น | คำอธิบาย |
|---|---|---|---|
name | string | ใช่ | ชื่อสาขา |
limitQuota | number | null | ไม่ | โควตาสูงสุด (null หรือไม่ส่งเพื่อใช้โควตาระดับบริการ) |
bankAccountIds | string[] | ไม่ | ID บัญชีธนาคารที่ต้องการเชื่อมต่อ |
ตัวอย่าง
bash
curl -X POST https://api.easyslip.com/b2b/branches \
-H "Content-Type: application/json" \
-H "X-API-Key: ${API_KEY}" \
-H "X-Timestamp: ${TIMESTAMP}" \
-H "X-Nonce: ${NONCE}" \
-H "X-Signature: ${SIGNATURE}" \
-d '{
"name": "สาขาขอนแก่น",
"limitQuota": 3000,
"bankAccountIds": ["cm9z8y7x6w5v4u3t2s1r0"]
}'javascript
const body = {
name: 'สาขาขอนแก่น',
limitQuota: 3000,
bankAccountIds: ['cm9z8y7x6w5v4u3t2s1r0'],
}
const headers = signRequest({
method: 'POST',
path: '/b2b/branches',
body,
apiKey: 'your_api_key',
secretKey: 'your_secret_key',
})
const response = await fetch('https://api.easyslip.com/b2b/branches', {
method: 'POST',
headers,
body: JSON.stringify(body),
})
const result = await response.json()Success Response (201)
json
{
"success": true,
"data": {
"id": "cm3c4d5e6f7g8h9i0j1k2",
"name": "สาขาขอนแก่น",
"isActive": true,
"ipAddress": null,
"limitQuota": 3000,
"usedQuota": 0,
"totalUsedQuota": 0,
"bankAccounts": [
{
"id": "cm9z8y7x6w5v4u3t2s1r0",
"bankCode": "004",
"bankNumber": "123-4-56789-0",
"nameTh": "บริษัท อีซี่สลิป จำกัด",
"nameEn": "EasySlip Co., Ltd."
}
],
"createdAt": "2025-01-10T11:00:00+07:00",
"updatedAt": "2025-01-10T11:00:00+07:00"
}
}แก้ไขสาขา
http
PATCH /b2b/branches/:branchIdFull URL: https://api.easyslip.com/b2b/branches/:branchId
Permission: branch:write
Request Body
ทุกฟิลด์เป็น optional ส่งเฉพาะฟิลด์ที่ต้องการแก้ไข
| ฟิลด์ | ชนิด | คำอธิบาย |
|---|---|---|
name | string | ชื่อสาขา |
isActive | boolean | สถานะการใช้งาน |
ipAddress | string | null | IP address ที่อนุญาต (null เพื่ออนุญาตทุก IP) |
bankAccountIds | string[] | แทนที่บัญชีธนาคารที่เชื่อมต่อด้วยรายการนี้ |
ตัวอย่าง
bash
curl -X PATCH https://api.easyslip.com/b2b/branches/cm1a2b3c4d5e6f7g8h9i0 \
-H "Content-Type: application/json" \
-H "X-API-Key: ${API_KEY}" \
-H "X-Timestamp: ${TIMESTAMP}" \
-H "X-Nonce: ${NONCE}" \
-H "X-Signature: ${SIGNATURE}" \
-d '{
"name": "สำนักงานใหญ่ กรุงเทพฯ",
"ipAddress": "203.150.100.10"
}'javascript
const body = {
name: 'สำนักงานใหญ่ กรุงเทพฯ',
ipAddress: '203.150.100.10',
}
const headers = signRequest({
method: 'PATCH',
path: '/b2b/branches/cm1a2b3c4d5e6f7g8h9i0',
body,
apiKey: 'your_api_key',
secretKey: 'your_secret_key',
})
const response = await fetch(
'https://api.easyslip.com/b2b/branches/cm1a2b3c4d5e6f7g8h9i0',
{
method: 'PATCH',
headers,
body: JSON.stringify(body),
}
)
const result = await response.json()Success Response (200)
json
{
"success": true,
"data": {
"id": "cm1a2b3c4d5e6f7g8h9i0",
"name": "สำนักงานใหญ่ กรุงเทพฯ",
"isActive": true,
"ipAddress": "203.150.100.10",
"limitQuota": 10000,
"usedQuota": 1500,
"totalUsedQuota": 45000,
"bankAccounts": [
{
"id": "cm9z8y7x6w5v4u3t2s1r0",
"bankCode": "004",
"bankNumber": "123-4-56789-0",
"nameTh": "บริษัท อีซี่สลิป จำกัด",
"nameEn": "EasySlip Co., Ltd."
}
],
"createdAt": "2024-06-15T10:30:00+07:00",
"updatedAt": "2025-01-10T15:00:00+07:00"
}
}ลบสาขา
http
DELETE /b2b/branches/:branchIdFull URL: https://api.easyslip.com/b2b/branches/:branchId
Permission: branch:write
WARNING
การลบเป็นแบบ soft delete สาขาจะถูกปิดใช้งานและทำเครื่องหมายว่าถูกลบ แต่ข้อมูลยังคงถูกเก็บไว้
ตัวอย่าง
bash
curl -X DELETE https://api.easyslip.com/b2b/branches/cm2b3c4d5e6f7g8h9i0j1 \
-H "X-API-Key: ${API_KEY}" \
-H "X-Timestamp: ${TIMESTAMP}" \
-H "X-Nonce: ${NONCE}" \
-H "X-Signature: ${SIGNATURE}"javascript
const headers = signRequest({
method: 'DELETE',
path: '/b2b/branches/cm2b3c4d5e6f7g8h9i0j1',
body: null,
apiKey: 'your_api_key',
secretKey: 'your_secret_key',
})
const response = await fetch(
'https://api.easyslip.com/b2b/branches/cm2b3c4d5e6f7g8h9i0j1',
{ method: 'DELETE', headers }
)
const result = await response.json()Success Response (200)
json
{
"success": true,
"data": {
"id": "cm2b3c4d5e6f7g8h9i0j1",
"name": "สาขาเชียงใหม่",
"isActive": false,
"deletedAt": "2025-01-10T16:00:00+07:00"
}
}Error Responses
ไม่พบสาขา (404)
json
{
"success": false,
"error": {
"code": "BRANCH_NOT_FOUND",
"message": "Branch not found"
}
}ข้อมูลไม่ถูกต้อง (400)
json
{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "Branch name is required"
}
}