telnyx-seti-ruby

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
<!-- Auto-generated from Telnyx OpenAPI specs. Do not edit. -->
<!-- 基于Telnyx OpenAPI规范自动生成,请勿编辑。 -->

Telnyx Seti - Ruby

Telnyx Seti - Ruby

Installation

安装

bash
gem install telnyx
bash
gem install telnyx

Setup

配置

ruby
require "telnyx"

client = Telnyx::Client.new(
  api_key: ENV["TELNYX_API_KEY"], # This is the default and can be omitted
)
All examples below assume
client
is already initialized as shown above.
ruby
require "telnyx"

client = Telnyx::Client.new(
  api_key: ENV["TELNYX_API_KEY"], # 这是默认配置,可以省略
)
以下所有示例都假设
client
已按照上述方式完成初始化。

Error Handling

错误处理

All API calls can fail with network errors, rate limits (429), validation errors (422), or authentication errors (401). Always handle errors in production code:
ruby
begin
  result = client.messages.send_(to: "+13125550001", from: "+13125550002", text: "Hello")
rescue Telnyx::Errors::APIConnectionError
  puts "Network error — check connectivity and retry"
rescue Telnyx::Errors::RateLimitError
  # 429: rate limited — wait and retry with exponential backoff
  sleep(1) # Check Retry-After header for actual delay
rescue Telnyx::Errors::APIStatusError => e
  puts "API error #{e.status}: #{e.message}"
  if e.status == 422
    puts "Validation error — check required fields and formats"
  end
end
Common error codes:
401
invalid API key,
403
insufficient permissions,
404
resource not found,
422
validation error (check field formats),
429
rate limited (retry with exponential backoff).
所有API调用都可能因网络错误、速率限制(429)、验证错误(422)或认证错误(401)而失败。在生产环境代码中请务必做好错误处理:
ruby
begin
  result = client.messages.send_(to: "+13125550001", from: "+13125550002", text: "Hello")
rescue Telnyx::Errors::APIConnectionError
  puts "网络错误 — 检查网络连接后重试"
rescue Telnyx::Errors::RateLimitError
  # 429: 触发速率限制 — 等待后使用指数退避策略重试
  sleep(1) # 可查看Retry-After响应头获取准确的等待时长
rescue Telnyx::Errors::APIStatusError => e
  puts "API错误 #{e.status}: #{e.message}"
  if e.status == 422
    puts "验证错误 — 检查必填字段和格式是否正确"
  end
end
常见错误码:
401
API密钥无效,
403
权限不足,
404
资源不存在,
422
验证错误(请检查字段格式),
429
触发速率限制(请使用指数退避策略重试)。

Get Enum

获取枚举值

GET /10dlc/enum/{endpoint}
ruby
response = client.messaging_10dlc.get_enum(:mno)

puts(response)
GET /10dlc/enum/{endpoint}
ruby
response = client.messaging_10dlc.get_enum(:mno)

puts(response)

Retrieve Black Box Test Results

获取黑盒测试结果

Returns the results of the various black box tests
GET /seti/black_box_test_results
ruby
response = client.seti.retrieve_black_box_test_results

puts(response)
Returns:
black_box_tests
(array[object]),
product
(string),
record_type
(string)
返回各类黑盒测试的结果
GET /seti/black_box_test_results
ruby
response = client.seti.retrieve_black_box_test_results

puts(response)
返回值:
black_box_tests
(对象数组)、
product
(字符串)、
record_type
(字符串)