Credit pools
รายการ credit pool — sub-tab Ngân sách (pool) ไม่ใช่ Hạn mức (set_budget บน AI projects)
UI dealer: Credit pools, + Nạp, LEDGER มักแสดงเมื่อ Share credit เปิด
Auth: Bearer + access_token, registration domain, device fields
Playground
Playground — Home feed → งบโปรเจกต เมื่อรัน npm run docs:stack (ชื่อ worker ตรง UI)
Playground (Home feed)
กลุ่ม งบโปรเจกต บน POST /gateway/credit-pools:
| Worker | action |
|---|---|
| รายการ pool | list |
| ธุรกรรม pool | ledger |
| สร้างและเติม pool | create |
| เติม pool | deposit |
| ลบ pool | delete |
| เครดิตร่วม | set_share_credit |
List สำหรับ project
POST https://api.gommo.net/api/v2/credit-pools
| Field | หมายเหตุ |
|---|---|
action | list |
scope_type | project |
scope_id | id_base โปรเจกต์ |
$domain = $env:GOMMO_API_DOMAIN
if (-not $domain) { throw 'Set GOMMO_API_DOMAIN' }
$h = @{ Authorization = "Bearer $env:TOKEN"; 'Content-Type' = 'application/x-www-form-urlencoded' }
$scopeId = '<project_id_base>'
$body = "access_token=$env:TOKEN&domain=$domain&action=list&scope_type=project&scope_id=$scopeId&language=vi"
Invoke-RestMethod -Method Post -Uri 'https://api.gommo.net/api/v2/credit-pools' -Headers $h -Body $bodyGateway Mode B
POST {gateway}/gateway/credit-pools — JSON { "action": "list", "scope_type": "project", "scope_id": "…" }
OpenAPI: openapi.yaml
Ledger (verify แล้ว)
action=ledger, scope_type=project, scope_id=id_base, limit (เช่น 20). Response: data.items[]
Create pool & nạp (verify แล้ว)
action=create, name, amount, currency_name (เช่น credit_ai), status (shared), scope_type + scope_id
Delete pool (verify แล้ว — Xóa)
UI dealer Xóa เรียก POST https://api.gommo.net/api/v2/credit-pools ด้วย action=delete
| Field | จำเป็น | หมายเหตุ |
|---|---|---|
scope_type | ใช่ | project |
scope_id | ใช่ | id_base โปรเจกต์ |
pool_id | ใช่ | UUID จาก action=list → data.pools[].id |
Response: { "success": true, "data": { "ok": true } }
คืนกระเป๋า
data.ok === true หมายถึง upstream ยอมรับการลบ pool — ไม่ รับประกันยอดคงเหลือกลับ กระเป๋าส่วนตัว — ตรวจ balance และ ledger หลังลบ
Gateway Mode B:
{
"action": "delete",
"scope_type": "project",
"scope_id": "<project id_base>",
"pool_id": "<จาก list data.pools[].id>",
"language": "vi"
}Alias gateway: poolId → pool_id. Playground: ลบ pool
Deposit / Bơm (verify แล้ว)
action=deposit, scope_type=project, scope_id=id_base, pool_id, amount, optional note. UI min ~200k. Wallet reserve 100k — ต้องมี ≥ amount + 100k มิฉะนั้น error: 1. Playground: เติม pool.
ยังไม่มี pool → create. Share credit: set_share_credit, id_base, enabled
