用 Go (Gin + GORM + SQLite) 重写整个后端: - 单二进制部署,不依赖 Python/pip/SDK - net/http 原生客户端,无 Cloudflare TLS 指纹问题 - 多阶段 Dockerfile:Node 构建前端 + Go 构建后端 + Alpine 运行 - 内存占用从 ~95MB 降至 ~3MB - 完整保留所有 API 路由、JWT 认证、API Key 权限、审计日志
44 lines
1.5 KiB
Go
44 lines
1.5 KiB
Go
package airwallex
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"net/url"
|
|
)
|
|
|
|
// ListCards retrieves a paginated list of issuing cards.
|
|
func (c *Client) ListCards(params url.Values) (*PaginatedResponse, error) {
|
|
data, statusCode, err := c.RequestRaw("GET", "api/v1/issuing/cards", params, nil)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if statusCode >= 400 {
|
|
return nil, parseAPIError(data, statusCode)
|
|
}
|
|
var result PaginatedResponse
|
|
if err := json.Unmarshal(data, &result); err != nil {
|
|
return nil, fmt.Errorf("airwallex: failed to parse cards response: %w", err)
|
|
}
|
|
return &result, nil
|
|
}
|
|
|
|
// CreateCard creates a new issuing card.
|
|
func (c *Client) CreateCard(data map[string]interface{}) (map[string]interface{}, error) {
|
|
return c.Request("POST", "api/v1/issuing/cards/create", nil, data)
|
|
}
|
|
|
|
// GetCard retrieves a single card by ID.
|
|
func (c *Client) GetCard(cardID string) (map[string]interface{}, error) {
|
|
return c.Request("GET", fmt.Sprintf("api/v1/issuing/cards/%s", cardID), nil, nil)
|
|
}
|
|
|
|
// GetCardDetails retrieves sensitive card details (PAN, CVV, etc.) by card ID.
|
|
func (c *Client) GetCardDetails(cardID string) (map[string]interface{}, error) {
|
|
return c.Request("GET", fmt.Sprintf("api/v1/issuing/cards/%s/details", cardID), nil, nil)
|
|
}
|
|
|
|
// UpdateCard updates an existing card by ID.
|
|
func (c *Client) UpdateCard(cardID string, data map[string]interface{}) (map[string]interface{}, error) {
|
|
return c.Request("POST", fmt.Sprintf("api/v1/issuing/cards/%s/update", cardID), nil, data)
|
|
}
|