5b4774e9c1
- 新增完整的Go客户端库实现,支持邮件服务器API的各种操作 - 实现账户管理、签名管理、邮件发送、审计、配额、通道等功能模块 - 提供ServiceAuth和AppAuth两种认证模式的客户端 - 添加详细的README文档,包含安装指南和使用示例 - 配置.gitignore文件以忽略构建产物和开发工具配置 - 支持分页查询、错误处理和客户端选项配置
55 lines
1.8 KiB
Go
55 lines
1.8 KiB
Go
package emailcli
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
)
|
|
|
|
func (c *Client) ListAuditPending(ctx context.Context, q AuditPendingQuery) (*PaginationResult[MailLog], error) {
|
|
params := mergeParams(paginationParams(q.PaginationQuery), map[string]interface{}{
|
|
"user_id": q.UserID,
|
|
"account_id": q.AccountID,
|
|
"keyword": q.Keyword,
|
|
})
|
|
return get[*PaginationResult[MailLog]](c, ctx, "/api/v1/audits/pending", buildQuery(params))
|
|
}
|
|
|
|
func (c *Client) GetAuditPendingDetail(ctx context.Context, id uint) (*MailLogDetail, error) {
|
|
return get[*MailLogDetail](c, ctx, fmt.Sprintf("/api/v1/audits/pending/%d", id), nil)
|
|
}
|
|
|
|
func (c *Client) ApproveAudit(ctx context.Context, id uint) error {
|
|
_, err := post[any](c, ctx, fmt.Sprintf("/api/v1/audits/%d/approve", id), nil)
|
|
return err
|
|
}
|
|
|
|
func (c *Client) RejectAudit(ctx context.Context, id uint, req AuditRejectReq) error {
|
|
_, err := post[any](c, ctx, fmt.Sprintf("/api/v1/audits/%d/reject", id), req)
|
|
return err
|
|
}
|
|
|
|
func (c *Client) BatchApproveAudit(ctx context.Context, req BatchAuditApproveReq) error {
|
|
_, err := post[any](c, ctx, "/api/v1/audits/batch/approve", req)
|
|
return err
|
|
}
|
|
|
|
func (c *Client) BatchRejectAudit(ctx context.Context, req BatchAuditRejectReq) error {
|
|
_, err := post[any](c, ctx, "/api/v1/audits/batch/reject", req)
|
|
return err
|
|
}
|
|
|
|
func (c *Client) ListAuditLogs(ctx context.Context, q AuditLogQuery) (*PaginationResult[MailAudit], error) {
|
|
params := mergeParams(paginationParams(q.PaginationQuery), map[string]interface{}{
|
|
"audit_type": q.AuditType,
|
|
"action": q.Action,
|
|
"user_id": q.UserID,
|
|
"start_date": q.StartDate,
|
|
"end_date": q.EndDate,
|
|
})
|
|
return get[*PaginationResult[MailAudit]](c, ctx, "/api/v1/audits/logs", buildQuery(params))
|
|
}
|
|
|
|
func (c *Client) GetAuditStats(ctx context.Context) (*AuditStats, error) {
|
|
return get[*AuditStats](c, ctx, "/api/v1/audits/stats", nil)
|
|
}
|