ร้านแลกเพชร
ใช้งานได้GET
/api/v1/diamond/shopดึงข้อมูลรายละเอียดทั้งหมดของร้านค้าเพชร
Headers
| ฟิลด์ | ชนิด | จำเป็น | คำอธิบาย |
|---|---|---|---|
| Authorization | string | ใช่ | ใช้ — แนบ Bearer <access_token> ของสมาชิก |
| X-Api-Key | string | ใช่ | API key ของ agent (ak_…) จากหน้า bo |
| X-Timestamp | string | ใช่ | เวลา sign เป็น unix milliseconds (คลาดเคลื่อนได้ ±300 วินาที) |
| X-Nonce | string | ใช่ | ค่าไม่ซ้ำต่อ request (UUIDv4) กัน replay |
| X-Signature | string | ใช่ | hex(HMAC-SHA256(secret, canonical)) — ดูหน้า Authentication |
| X-Player-IP | string | — | IP จริงของผู้เล่น (IPv4/IPv6) — แนะนำให้ส่ง (ใช้ใน login history) |
| X-Player-UA | string | — | User-Agent ของผู้เล่น (optional — ลง login history) |
| X-Request-Id | string | — | correlation id ของฝั่งคุณ — ระบบ echo กลับใน request_uuid (แนะนำให้ส่ง) |
| x-lang | string | — | th (default) หรือ en — ภาษาของ message |
Response
ฟิลด์ใน data
| ฟิลด์ | ชนิด | จำเป็น | คำอธิบาย |
|---|---|---|---|
| enabled | boolean | — | ระบบเพชรเปิดใช้อยู่หรือไม่ (สะสมเพชรได้) — ถ้า false ให้ซ่อนเมนูเพชร (ต้องเปิดที่ระดับ agent และบัญชีต้องเป็นกระเป๋าโหมด TRANSFER) |
| shop_enabled | boolean | — | ร้านเปิดให้แลกหรือไม่ — enabled = true แต่ shop_enabled = false หมายถึงยังสะสมเพชรได้แต่ปิดการแลกชั่วคราว (โชว์ catalog พร้อมปุ่มแลกแบบ disabled) |
| diamond_balance | number | — | ยอดเพชรคงเหลือของสมาชิก (จำนวนเต็ม) |
| items | object[] | — | รายการสินค้าที่แลกได้ เรียงตาม sort_order — คืนเสมอแม้ร้านปิด (shop_enabled = false) เพื่อโชว์ catalog |
| └ id | string | — | id ของสินค้า — ส่งเป็น item_id ตอนแลก (UUID) |
| └ cost_diamonds | number | — | ราคาเป็นจำนวนเพชร (จำนวนเต็ม) |
| └ credit_amount | string | — | เครดิตที่จะได้เข้ากระเป๋าเมื่อแลก (THB, string) |
| └ label | string | null | — | ชื่อ/ป้ายสินค้า (อาจเป็น null) |
ตัวอย่าง response
{
"success": true,
"code": 0,
"message": "Diamond shop fetched successfully",
"data": {
"enabled": true,
"shop_enabled": true,
"diamond_balance": 320,
"items": [
{ "id": "3f1c9a2e-7b41-4d6c-9a8e-2f5b1c0d7e10", "cost_diamonds": 100, "credit_amount": "50", "label": "แลกเครดิต 50 บาท" },
{ "id": "8b2d4f60-1c93-4a57-b0e2-6d3a9f1c8e42", "cost_diamonds": 200, "credit_amount": "120", "label": "แลกเครดิต 120 บาท" },
{ "id": "a1e7c5d3-9f24-4b18-8c60-3e2d7a4f9b51", "cost_diamonds": 500, "credit_amount": "350", "label": "แลกเครดิต 350 บาท" }
]
},
"request_uuid": "3b7e0d9c-4f61-4a28-b5e3-8d2c6f1a9e07"
}Error codes ที่พบได้
| code | ชื่อ | HTTP | ข้อความ |
|---|---|---|---|
| 6221 | DIAMOND_NOT_ENABLED | 400 | โปรแกรมเพชรยังไม่เปิดใช้งานหรือไม่มีสิทธิ์ปัจจุบันบัญชีที่ระบบเพชรปิดอยู่จะตอบสำเร็จพร้อม enabled = false และ items ว่างแทน — รองรับโค้ดนี้ไว้ด้วยเช่นเดียวกับตอน redeem |
| 1001 | UNAUTHORIZED | 401 | ไม่ได้รับอนุญาต |
| 1007 | TOKEN_INVALID | 401 | โทเค็นไม่ถูกต้อง |