Dazl 内部 API 客户端
用于Dazl内部API的Type安全SDK由OpenAPI规格生成.
安装
npm install @dazl/api-client
使用量
创建客户端实例 createClient 并传递给每个API呼叫:
import { createClient } from '@dazl/api-client/internal/fetch-client';
import { Billing } from '@dazl/api-client/internal';
const client = createClient({
baseUrl: 'http://api-server-url/private',
headers: {
'x-api-key': 'my-secret-api-key',
},
});
const customerInfoRes = await Billing.getCustomerInfoByDazlId({
path: { dazlId: 'USER_DAZL_ID' },
client,
});
if (customerInfoRes.error) {
throw new Error(customerInfoRes.error.message);
}
const customerInfo = customerInfoRes.data;
代表用户行事
建议的模式是,与 x-user-id 页眉烤入并存储在请求上下文中 :
// middleware — runs once per request
const userClient = createClient({
baseUrl: 'http://api-server-url/private',
headers: {
'x-api-key': 'my-secret-api-key',
'x-user-id': context.userId, // userId from the authenticated request
},
});
context.apiClient = userClient;
// handler — no need to pass headers each time
const customerInfoRes = await Billing.getCustomerInfoByDazlId({
path: { dazlId: 'USER_DAZL_ID' },
client: context.apiClient,
});
相关文件
其他客户端获取文档可在此找到 : https://heyapi.dev/openapi-ts/客户端/牵引
主要信件兼容性
生成的 WorkspaceMailbox, (中文(简体) ), ChatInbox,以及 MajorConversation 客户包括添加剂
回复相关性,仅限发送者重试资格/创建,以及 appendMajorIncoming生成
与 npm run update:sdk:local 从寄存器根。 生成源 sdk/src/ 为:
与其他API合同一样,建立产出.
部署添加剂迁移和API,先发布重生成的SDK,再更新dazl
SDK在部署其呼叫器前依赖. getWorkspaceMessagingCapabilities 区分
旧服务器的支持; 失败的检查未知 。 接收答复仍只保留现状.
appendMajorIncoming 只接受来信箱身份,获取其内容和所有者
,并保留目的地对话的标题和保留时间戳.