Freshdesk 基于 Freshdesk API v2,实现 ITicketService 统一接口。
包信息
| 项 | 值 |
|---|---|
| NuGet 包 | Bitzsoft.Integrations.Ticketing.Freshdesk |
| 实现接口 | ITicketService |
| Provider ID | freshdesk |
| 鉴权方式 | HTTP Basic Auth,凭据格式 api_key:x(api_key 作为用户名,密码为空即 x),Base64 编码后作为 Authorization: Basic 头 |
| 默认 BaseUrl | 由 Domain 自动拼接为 https://{domain}.freshdesk.com/api/v2 |
| 区域 | Global |
凭据(API Key)在 Freshdesk 个人设置(Profile Settings > API and Security)获取。
配置字段
| 字段 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
Domain | string | 是 | — | Freshdesk 子域名(如 mycompany) |
ApiKey | string | 是 | — | API Key |
BaseUrl | string | 否 | — | 留空时由 Domain 自动拼接 https://{domain}.freshdesk.com/api/v2 |
HttpClientName | string | 否 | TicketingFreshdesk | 业务 HttpClient 命名 |
配置 JSON 示例
{ "Ticketing": { "Freshdesk": { "Domain": "mycompany", "ApiKey": "xxxxxxxxxxxxxxxxxx" } }}DI 注册
// 从配置节注册(默认节名 Ticketing:Freshdesk)services.AddFreshdeskTicket(configuration);
// 或用回调单独配置services.AddFreshdeskTicket(options =>{ options.Domain = "mycompany"; options.ApiKey = "xxxxxxxxxxxxxxxxxx";});使用示例
public class SupportService{ private readonly ITicketService _ticket;
public SupportService(ITicketService ticket) => _ticket = ticket;
public Task<TicketInfo> CreateAsync(string subject, string description, string requesterEmail) => _ticket.CreateTicketAsync(new CreateTicketRequest { Subject = subject, Description = description, RequesterEmail = requesterEmail });
public Task<TicketingResult> ReplyAsync(string ticketId, string reply) => _ticket.AddCommentAsync(ticketId, reply, publicComment: true);}依赖
| 包 | 说明 |
|---|---|
Bitzsoft.Integrations.Ticketing | 工单系统服务抽象层 |
Bitzsoft.Integrations.Core | 公共基座 |
已知限制
- Basic Auth 凭据格式为
api_key:x(密码占位为x),仅需 API Key 一项凭据。