SuperAPI AI 工具集

telnyx-account-notifications-java

编程与开发

查看项目

更新于 10-16 04:39

技能介绍

用途

Telnyx Account Notifications - Java 是一个面向 Java 开发者的技能,用于配置 Telnyx 账户告警与事件的通知渠道和通知设置。它通过 Telnyx Java SDK 提供可直接参考的示例代码,帮助开发者在 Java 应用中管理通知相关的资源。

主要能力

该技能覆盖以下资源的管理操作:

  • 通知渠道(notification channels):列表、创建、获取、更新、删除。渠道类型枚举包括 sms、voice、email、webhook。
  • 通知事件条件(notification event conditions):列表。返回字段包括 allow_multiple_channels、associated_record_type(account、phone_number)、asynchronous、description、enabled、name、notification_event_id、parameters、supported_channels 等。
  • 通知事件(notification events):列表。返回字段包括 enabled、name、notification_category 等。
  • 通知配置文件(notification profiles):列表、创建、获取、更新、删除。
  • 通知设置(notification settings):列表、添加、获取、删除。状态枚举包括 enabled、enable-received、enable-pending、enable-submitted、delete-received、delete-pending、delete-submitted、deleted。

使用方式

安装依赖:

Maven:

<dependency>
    <groupId>com.telnyx.sdk</groupId>
    <artifactId>telnyx</artifactId>
    <version>6.89.0</version>
</dependency>

Gradle:

implementation("com.telnyx.sdk:telnyx:6.89.0")

初始化客户端:

import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;

TelnyxClient client = TelnyxOkHttpClient.fromEnv();

所有示例均假设 client 已按上述方式初始化。

错误处理:所有 API 调用都可能因网络错误、速率限制(429)、校验错误(422)或认证错误(401)而失败。生产代码中应始终处理错误:

import com.telnyx.sdk.errors.TelnyxServiceException;

try {
    var result = client.messages().send(params);
} catch (TelnyxServiceException e) {
    System.err.println("API error " + e.statusCode() + ": " + e.getMessage());
    if (e.statusCode() == 422) {
        System.err.println("Validation error — check required fields and formats");
    } else if (e.statusCode() == 429) {
        // Rate limited — wait and retry with exponential backoff
        Thread.sleep(1000);
    }
}

常见错误码:401 无效 API key,403 权限不足,404 资源未找到,422 校验错误(检查字段格式),429 速率限制(使用指数退避重试)。

分页:列表方法返回一页数据。使用 .autoPager() 自动迭代:for (var item : page.autoPager()) { ... }。如需手动控制,使用 .hasNextPage() 和 .nextPage()。

适用场景

适用于需要在 Java 应用中集成 Telnyx 账户通知能力的开发者,例如通过代码管理通知渠道、配置通知配置文件、查询通知事件与事件条件,以及维护通知设置。

限制

资料未提供该技能的具体收费、价格、平台支持范围或实际使用效果等信息。