package emailcli import ( "context" "fmt" ) // CreateChannel 创建发件通道。Code 为唯一标识,发件请求的 channel 字段填写此 Code。 // Strategy 可取 StrategyRoundRobin / StrategyWeight / StrategyLeastUsed。 // // POST /api/v1/channels ServiceAuth func (c *Client) CreateChannel(ctx context.Context, req CreateChannelReq) (*Channel, error) { return post[*Channel](c, ctx, "/api/v1/channels", req) } // ListChannels 分页查询通道,支持按状态与关键字过滤。 // // GET /api/v1/channels?page=&page_size=&status=&keyword= ServiceAuth func (c *Client) ListChannels(ctx context.Context, q ChannelListQuery) (*PaginationResult[Channel], error) { params := mergeParams(paginationParams(q.PaginationQuery), map[string]interface{}{ "status": q.Status, "keyword": q.Keyword, }) return get[*PaginationResult[Channel]](c, ctx, "/api/v1/channels", buildQuery(params)) } // UpdateChannel 局部更新通道。Code 不可修改;修改 Status 可启用/禁用通道。 // // PUT /api/v1/channels/{id} ServiceAuth func (c *Client) UpdateChannel(ctx context.Context, id uint, req UpdateChannelReq) (*Channel, error) { return put[*Channel](c, ctx, fmt.Sprintf("/api/v1/channels/%d", id), req) } // DeleteChannel 删除通道(软删除)。通道下如有启用中的发信账号,建议先清空。 // // DELETE /api/v1/channels/{id} ServiceAuth func (c *Client) DeleteChannel(ctx context.Context, id uint) error { _, err := del[any](c, ctx, fmt.Sprintf("/api/v1/channels/%d", id)) return err }