Class: Zernio::VoiceApi

Inherits:
Object
  • Object
show all
Defined in:
lib/zernio-sdk/api/voice_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ VoiceApi

Returns a new instance of VoiceApi.



19
20
21
# File 'lib/zernio-sdk/api/voice_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/zernio-sdk/api/voice_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#create_voice_call(create_voice_call_request, opts = {}) ⇒ CreateVoiceCall200Response

Place an outbound phone call Dials to FROM one of your voice-enabled numbers and, on answer, bridges the callee to the number's stored forward destination, or to the per-call forwardTo override. Destinations can be your own AI voice agent (Vapi/Retell), a phone, or a SIP endpoint. An optional greeting is spoken to the callee before the bridge. The 200 response means the call is dialing; the lifecycle continues asynchronously (track it via GET /v1/voice/calls/{id} or the call.* webhooks). Outbound calls are capped per rolling hour (429 when hit). Idempotency: send an Idempotency-Key header to make retries safe; same key + same body replays the original response instead of dialing (and billing) a second call.

Parameters:

  • create_voice_call_request (CreateVoiceCallRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :idempotency_key (String)

    Optional client-generated unique key (e.g. a UUID) that makes dial retries safe. Same key + same body replays the original response; same key + different body → 422; key still processing → 409.

Returns:



28
29
30
31
# File 'lib/zernio-sdk/api/voice_api.rb', line 28

def create_voice_call(create_voice_call_request, opts = {})
  data, _status_code, _headers = create_voice_call_with_http_info(create_voice_call_request, opts)
  data
end

#create_voice_call_with_http_info(create_voice_call_request, opts = {}) ⇒ Array<(CreateVoiceCall200Response, Integer, Hash)>

Place an outbound phone call Dials `to` FROM one of your voice-enabled numbers and, on answer, bridges the callee to the number's stored forward destination, or to the per-call `forwardTo` override. Destinations can be your own AI voice agent (Vapi/Retell), a phone, or a SIP endpoint. An optional `greeting` is spoken to the callee before the bridge. The 200 response means the call is dialing; the lifecycle continues asynchronously (track it via `GET /v1/voice/calls/id` or the `call.*` webhooks). Outbound calls are capped per rolling hour (429 when hit). Idempotency: send an `Idempotency-Key` header to make retries safe; same key + same body replays the original response instead of dialing (and billing) a second call.

Parameters:

  • create_voice_call_request (CreateVoiceCallRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :idempotency_key (String)

    Optional client-generated unique key (e.g. a UUID) that makes dial retries safe. Same key + same body replays the original response; same key + different body → 422; key still processing → 409.

Returns:

  • (Array<(CreateVoiceCall200Response, Integer, Hash)>)

    CreateVoiceCall200Response data, response status code and response headers



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/zernio-sdk/api/voice_api.rb', line 39

def create_voice_call_with_http_info(create_voice_call_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: VoiceApi.create_voice_call ...'
  end
  # verify the required parameter 'create_voice_call_request' is set
  if @api_client.config.client_side_validation && create_voice_call_request.nil?
    fail ArgumentError, "Missing the required parameter 'create_voice_call_request' when calling VoiceApi.create_voice_call"
  end
  if @api_client.config.client_side_validation && !opts[:'idempotency_key'].nil? && opts[:'idempotency_key'].to_s.length > 255
    fail ArgumentError, 'invalid value for "opts[:"idempotency_key"]" when calling VoiceApi.create_voice_call, the character length must be smaller than or equal to 255.'
  end

  # resource path
  local_var_path = '/v1/voice/calls'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end
  header_params[:'Idempotency-Key'] = opts[:'idempotency_key'] if !opts[:'idempotency_key'].nil?

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(create_voice_call_request)

  # return_type
  return_type = opts[:debug_return_type] || 'CreateVoiceCall200Response'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"VoiceApi.create_voice_call",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: VoiceApi#create_voice_call\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#create_voice_web_session(opts = {}) ⇒ CreateVoiceWebSession200Response

Mint a browser softphone session Step 1 of the two-step browser softphone handshake. Mints a WebRTC session (token + credential) the browser registers with the @telnyx/webrtc SDK. Once registered, call POST /v1/voice/calls/web/dial with the returned credentialId to place the call. The split avoids bridging to a browser that has not finished registering. The token lives ~1 hour (it must outlive the whole call, not just the handshake).

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



101
102
103
104
# File 'lib/zernio-sdk/api/voice_api.rb', line 101

def create_voice_web_session(opts = {})
  data, _status_code, _headers = create_voice_web_session_with_http_info(opts)
  data
end

#create_voice_web_session_with_http_info(opts = {}) ⇒ Array<(CreateVoiceWebSession200Response, Integer, Hash)>

Mint a browser softphone session Step 1 of the two-step browser softphone handshake. Mints a WebRTC session (token + credential) the browser registers with the `@telnyx/webrtc` SDK. Once registered, call `POST /v1/voice/calls/web/dial` with the returned `credentialId` to place the call. The split avoids bridging to a browser that has not finished registering. The token lives ~1 hour (it must outlive the whole call, not just the handshake).

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/zernio-sdk/api/voice_api.rb', line 110

def create_voice_web_session_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: VoiceApi.create_voice_web_session ...'
  end
  # resource path
  local_var_path = '/v1/voice/calls/web'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'CreateVoiceWebSession200Response'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"VoiceApi.create_voice_web_session",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: VoiceApi#create_voice_web_session\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#dial_voice_web_call(dial_voice_web_call_request, opts = {}) ⇒ DialVoiceWebCall200Response

Dial from the browser softphone Step 2 of the browser softphone handshake: places an outbound call whose answered leg is bridged to the browser registered with the credential from POST /v1/voice/calls/web. The call runs through the normal outbound lane, so it is logged as outbound (from = your number, to = target) and recorded per the number's settings.

Parameters:

Returns:



159
160
161
162
# File 'lib/zernio-sdk/api/voice_api.rb', line 159

def dial_voice_web_call(dial_voice_web_call_request, opts = {})
  data, _status_code, _headers = dial_voice_web_call_with_http_info(dial_voice_web_call_request, opts)
  data
end

#dial_voice_web_call_with_http_info(dial_voice_web_call_request, opts = {}) ⇒ Array<(DialVoiceWebCall200Response, Integer, Hash)>

Dial from the browser softphone Step 2 of the browser softphone handshake: places an outbound call whose answered leg is bridged to the browser registered with the credential from `POST /v1/voice/calls/web`. The call runs through the normal outbound lane, so it is logged as outbound (from = your number, to = target) and recorded per the number's settings.

Parameters:

Returns:

  • (Array<(DialVoiceWebCall200Response, Integer, Hash)>)

    DialVoiceWebCall200Response data, response status code and response headers



169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
# File 'lib/zernio-sdk/api/voice_api.rb', line 169

def dial_voice_web_call_with_http_info(dial_voice_web_call_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: VoiceApi.dial_voice_web_call ...'
  end
  # verify the required parameter 'dial_voice_web_call_request' is set
  if @api_client.config.client_side_validation && dial_voice_web_call_request.nil?
    fail ArgumentError, "Missing the required parameter 'dial_voice_web_call_request' when calling VoiceApi.dial_voice_web_call"
  end
  # resource path
  local_var_path = '/v1/voice/calls/web/dial'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(dial_voice_web_call_request)

  # return_type
  return_type = opts[:debug_return_type] || 'DialVoiceWebCall200Response'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"VoiceApi.dial_voice_web_call",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: VoiceApi#dial_voice_web_call\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#disable_voice_on_number(id, opts = {}) ⇒ DisableVoiceOnNumber200Response

Disable phone calling on a number Turns off PSTN calling for the number. The stored forward destination and settings are preserved, so re-enabling restores the prior config.

Parameters:

  • id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



227
228
229
230
# File 'lib/zernio-sdk/api/voice_api.rb', line 227

def disable_voice_on_number(id, opts = {})
  data, _status_code, _headers = disable_voice_on_number_with_http_info(id, opts)
  data
end

#disable_voice_on_number_with_http_info(id, opts = {}) ⇒ Array<(DisableVoiceOnNumber200Response, Integer, Hash)>

Disable phone calling on a number Turns off PSTN calling for the number. The stored forward destination and settings are preserved, so re-enabling restores the prior config.

Parameters:

  • id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
# File 'lib/zernio-sdk/api/voice_api.rb', line 237

def disable_voice_on_number_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: VoiceApi.disable_voice_on_number ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling VoiceApi.disable_voice_on_number"
  end
  # resource path
  local_var_path = '/v1/phone-numbers/{id}/voice'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'DisableVoiceOnNumber200Response'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"VoiceApi.disable_voice_on_number",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: VoiceApi#disable_voice_on_number\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#enable_voice_on_number(id, opts = {}) ⇒ EnableVoiceOnNumber200Response

Enable phone calling on a number Turns on regular phone (PSTN) calling for one of your numbers and configures how inbound calls are handled. Inbound calls route to forwardTo: your own AI voice agent (Vapi/Retell), a phone, or a SIP endpoint. Optional extras: voicemail, business-hours windows, an IVR menu, a caller blocklist, recording, and transcription. A number can also be voice-enabled with no forward (outbound-only). Idempotent, and doubles as the settings update: only fields present in the body are written. Omitting forwardTo preserves the current destination; sending an empty string clears it.

Parameters:

  • id (String)

    Phone number record ID (from GET /v1/phone-numbers).

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

Returns:



291
292
293
294
# File 'lib/zernio-sdk/api/voice_api.rb', line 291

def enable_voice_on_number(id, opts = {})
  data, _status_code, _headers = enable_voice_on_number_with_http_info(id, opts)
  data
end

#enable_voice_on_number_with_http_info(id, opts = {}) ⇒ Array<(EnableVoiceOnNumber200Response, Integer, Hash)>

Enable phone calling on a number Turns on regular phone (PSTN) calling for one of your numbers and configures how inbound calls are handled. Inbound calls route to `forwardTo`: your own AI voice agent (Vapi/Retell), a phone, or a SIP endpoint. Optional extras: voicemail, business-hours windows, an IVR menu, a caller blocklist, recording, and transcription. A number can also be voice-enabled with no forward (outbound-only). Idempotent, and doubles as the settings update: only fields present in the body are written. Omitting `forwardTo` preserves the current destination; sending an empty string clears it.

Parameters:

  • id (String)

    Phone number record ID (from GET /v1/phone-numbers).

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

Returns:



302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
# File 'lib/zernio-sdk/api/voice_api.rb', line 302

def enable_voice_on_number_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: VoiceApi.enable_voice_on_number ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling VoiceApi.enable_voice_on_number"
  end
  # resource path
  local_var_path = '/v1/phone-numbers/{id}/voice'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'enable_voice_on_number_request'])

  # return_type
  return_type = opts[:debug_return_type] || 'EnableVoiceOnNumber200Response'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"VoiceApi.enable_voice_on_number",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: VoiceApi#enable_voice_on_number\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#end_voice_call(id, opts = {}) ⇒ EndVoiceCall200Response

Hang up a live call Hangs up a live call on demand. Idempotent: ending a call that already ended (or never connected) returns success with the call's current status. Final duration/cost are written asynchronously when the hangup event lands, so the call doc may briefly still show its prior status.

Parameters:

  • id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



360
361
362
363
# File 'lib/zernio-sdk/api/voice_api.rb', line 360

def end_voice_call(id, opts = {})
  data, _status_code, _headers = end_voice_call_with_http_info(id, opts)
  data
end

#end_voice_call_with_http_info(id, opts = {}) ⇒ Array<(EndVoiceCall200Response, Integer, Hash)>

Hang up a live call Hangs up a live call on demand. Idempotent: ending a call that already ended (or never connected) returns success with the call's current status. Final duration/cost are written asynchronously when the hangup event lands, so the call doc may briefly still show its prior status.

Parameters:

  • id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(EndVoiceCall200Response, Integer, Hash)>)

    EndVoiceCall200Response data, response status code and response headers



370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
# File 'lib/zernio-sdk/api/voice_api.rb', line 370

def end_voice_call_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: VoiceApi.end_voice_call ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling VoiceApi.end_voice_call"
  end
  # resource path
  local_var_path = '/v1/voice/calls/{id}/end'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'EndVoiceCall200Response'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"VoiceApi.end_voice_call",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: VoiceApi#end_voice_call\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_voice_call(id, opts = {}) ⇒ GetVoiceCall200Response

Get a phone call Full call detail, including the transcript segments when transcription was on.

Parameters:

  • id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



423
424
425
426
# File 'lib/zernio-sdk/api/voice_api.rb', line 423

def get_voice_call(id, opts = {})
  data, _status_code, _headers = get_voice_call_with_http_info(id, opts)
  data
end

#get_voice_call_estimate(to, opts = {}) ⇒ GetVoiceCallEstimate200Response

Estimate call cost Pre-call cost estimate for a PSTN call: the carrier leg plus optional recording and transcription add-ons. Same billing formula as the post-call invoice, so the quote and the final charge can't disagree. The per-minute figure is deliberately conservative (the real cost comes from the settled carrier record after the call), so estimates trend slightly over the actual invoice. Parity endpoint of GET /v1/whatsapp/calls/estimate, minus the Meta line (PSTN calls have no separate Meta bill, so totalCostUSD equals billableCostUSD).

Parameters:

  • to (String)

    Destination number, E.164 (leading + optional).

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :minutes (Integer) — default: default to 1
  • :recording (Boolean)
  • :transcription (Boolean)

Returns:



489
490
491
492
# File 'lib/zernio-sdk/api/voice_api.rb', line 489

def get_voice_call_estimate(to, opts = {})
  data, _status_code, _headers = get_voice_call_estimate_with_http_info(to, opts)
  data
end

#get_voice_call_estimate_with_http_info(to, opts = {}) ⇒ Array<(GetVoiceCallEstimate200Response, Integer, Hash)>

Estimate call cost Pre-call cost estimate for a PSTN call: the carrier leg plus optional recording and transcription add-ons. Same billing formula as the post-call invoice, so the quote and the final charge can't disagree. The per-minute figure is deliberately conservative (the real cost comes from the settled carrier record after the call), so estimates trend slightly over the actual invoice. Parity endpoint of `GET /v1/whatsapp/calls/estimate`, minus the Meta line (PSTN calls have no separate Meta bill, so `totalCostUSD` equals `billableCostUSD`).

Parameters:

  • to (String)

    Destination number, E.164 (leading + optional).

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :minutes (Integer) — default: default to 1
  • :recording (Boolean)
  • :transcription (Boolean)

Returns:



502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
# File 'lib/zernio-sdk/api/voice_api.rb', line 502

def get_voice_call_estimate_with_http_info(to, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: VoiceApi.get_voice_call_estimate ...'
  end
  # verify the required parameter 'to' is set
  if @api_client.config.client_side_validation && to.nil?
    fail ArgumentError, "Missing the required parameter 'to' when calling VoiceApi.get_voice_call_estimate"
  end
  if @api_client.config.client_side_validation && !opts[:'minutes'].nil? && opts[:'minutes'] > 120
    fail ArgumentError, 'invalid value for "opts[:"minutes"]" when calling VoiceApi.get_voice_call_estimate, must be smaller than or equal to 120.'
  end

  if @api_client.config.client_side_validation && !opts[:'minutes'].nil? && opts[:'minutes'] < 1
    fail ArgumentError, 'invalid value for "opts[:"minutes"]" when calling VoiceApi.get_voice_call_estimate, must be greater than or equal to 1.'
  end

  # resource path
  local_var_path = '/v1/voice/calls/estimate'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'to'] = to
  query_params[:'minutes'] = opts[:'minutes'] if !opts[:'minutes'].nil?
  query_params[:'recording'] = opts[:'recording'] if !opts[:'recording'].nil?
  query_params[:'transcription'] = opts[:'transcription'] if !opts[:'transcription'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'GetVoiceCallEstimate200Response'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"VoiceApi.get_voice_call_estimate",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: VoiceApi#get_voice_call_estimate\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_voice_call_recording(id, opts = {}) ⇒ GetWhatsAppCallRecording200Response

Get a call recording Resolves a fresh, playable MP3 URL for the call's recording (provider-signed URLs expire ~10 minutes after signing, so this endpoint re-signs on demand). Default responds 302 Found redirecting to the fresh URL; pass as=json to receive { url } instead.

Parameters:

  • id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :as (String)

    `json` returns `{ url }` instead of a 302 redirect.

Returns:



568
569
570
571
# File 'lib/zernio-sdk/api/voice_api.rb', line 568

def get_voice_call_recording(id, opts = {})
  data, _status_code, _headers = get_voice_call_recording_with_http_info(id, opts)
  data
end

#get_voice_call_recording_with_http_info(id, opts = {}) ⇒ Array<(GetWhatsAppCallRecording200Response, Integer, Hash)>

Get a call recording Resolves a fresh, playable MP3 URL for the call's recording (provider-signed URLs expire ~10 minutes after signing, so this endpoint re-signs on demand). Default responds `302 Found` redirecting to the fresh URL; pass `as=json` to receive `{ url }` instead.

Parameters:

  • id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :as (String)

    `json` returns `{ url }` instead of a 302 redirect.

Returns:



579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
# File 'lib/zernio-sdk/api/voice_api.rb', line 579

def get_voice_call_recording_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: VoiceApi.get_voice_call_recording ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling VoiceApi.get_voice_call_recording"
  end
  allowable_values = ["json"]
  if @api_client.config.client_side_validation && opts[:'as'] && !allowable_values.include?(opts[:'as'])
    fail ArgumentError, "invalid value for \"as\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/v1/voice/calls/{id}/recording'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'as'] = opts[:'as'] if !opts[:'as'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'GetWhatsAppCallRecording200Response'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"VoiceApi.get_voice_call_recording",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: VoiceApi#get_voice_call_recording\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_voice_call_with_http_info(id, opts = {}) ⇒ Array<(GetVoiceCall200Response, Integer, Hash)>

Get a phone call Full call detail, including the transcript segments when transcription was on.

Parameters:

  • id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(GetVoiceCall200Response, Integer, Hash)>)

    GetVoiceCall200Response data, response status code and response headers



433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
# File 'lib/zernio-sdk/api/voice_api.rb', line 433

def get_voice_call_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: VoiceApi.get_voice_call ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling VoiceApi.get_voice_call"
  end
  # resource path
  local_var_path = '/v1/voice/calls/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'GetVoiceCall200Response'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"VoiceApi.get_voice_call",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: VoiceApi#get_voice_call\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_voice_calls(opts = {}) ⇒ ListVoiceCalls200Response

List phone calls Your PSTN voice calls (inbound + outbound), newest first. Cursor pagination: pass the returned nextCursor as before for the next page. For a history that also includes WhatsApp calls, use GET /v1/calls.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :status (String)
  • :direction (String)
  • :number (String)

    Exact filter: calls involving this number (typically one of your DIDs). E.164, leading + optional.

  • :before (Time)
  • :limit (Integer) — default: default to 50

Returns:



641
642
643
644
# File 'lib/zernio-sdk/api/voice_api.rb', line 641

def list_voice_calls(opts = {})
  data, _status_code, _headers = list_voice_calls_with_http_info(opts)
  data
end

#list_voice_calls_with_http_info(opts = {}) ⇒ Array<(ListVoiceCalls200Response, Integer, Hash)>

List phone calls Your PSTN voice calls (inbound + outbound), newest first. Cursor pagination: pass the returned `nextCursor` as `before` for the next page. For a history that also includes WhatsApp calls, use `GET /v1/calls`.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :status (String)
  • :direction (String)
  • :number (String)

    Exact filter: calls involving this number (typically one of your DIDs). E.164, leading + optional.

  • :before (Time)
  • :limit (Integer) — default: default to 50

Returns:

  • (Array<(ListVoiceCalls200Response, Integer, Hash)>)

    ListVoiceCalls200Response data, response status code and response headers



655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
# File 'lib/zernio-sdk/api/voice_api.rb', line 655

def list_voice_calls_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: VoiceApi.list_voice_calls ...'
  end
  allowable_values = ["ringing", "answered", "ended", "failed"]
  if @api_client.config.client_side_validation && opts[:'status'] && !allowable_values.include?(opts[:'status'])
    fail ArgumentError, "invalid value for \"status\", must be one of #{allowable_values}"
  end
  allowable_values = ["inbound", "outbound"]
  if @api_client.config.client_side_validation && opts[:'direction'] && !allowable_values.include?(opts[:'direction'])
    fail ArgumentError, "invalid value for \"direction\", must be one of #{allowable_values}"
  end
  if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 200
    fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling VoiceApi.list_voice_calls, must be smaller than or equal to 200.'
  end

  if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1
    fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling VoiceApi.list_voice_calls, must be greater than or equal to 1.'
  end

  # resource path
  local_var_path = '/v1/voice/calls'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'status'] = opts[:'status'] if !opts[:'status'].nil?
  query_params[:'direction'] = opts[:'direction'] if !opts[:'direction'].nil?
  query_params[:'number'] = opts[:'number'] if !opts[:'number'].nil?
  query_params[:'before'] = opts[:'before'] if !opts[:'before'].nil?
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'ListVoiceCalls200Response'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"VoiceApi.list_voice_calls",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: VoiceApi#list_voice_calls\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#transfer_voice_call(id, transfer_voice_call_request, opts = {}) ⇒ TransferVoiceCall200Response

Blind-transfer a live call Moves the call's current leg to a new destination (a phone number or a SIP endpoint). This is a BLIND transfer: control of the leg is handed off and the call ends normally when the transferred leg hangs up. The caller ID presented on the transfer leg is always your own number.

Parameters:

  • id (String)
  • transfer_voice_call_request (TransferVoiceCallRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



726
727
728
729
# File 'lib/zernio-sdk/api/voice_api.rb', line 726

def transfer_voice_call(id, transfer_voice_call_request, opts = {})
  data, _status_code, _headers = transfer_voice_call_with_http_info(id, transfer_voice_call_request, opts)
  data
end

#transfer_voice_call_with_http_info(id, transfer_voice_call_request, opts = {}) ⇒ Array<(TransferVoiceCall200Response, Integer, Hash)>

Blind-transfer a live call Moves the call's current leg to a new destination (a phone number or a SIP endpoint). This is a BLIND transfer: control of the leg is handed off and the call ends normally when the transferred leg hangs up. The caller ID presented on the transfer leg is always your own number.

Parameters:

  • id (String)
  • transfer_voice_call_request (TransferVoiceCallRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
# File 'lib/zernio-sdk/api/voice_api.rb', line 737

def transfer_voice_call_with_http_info(id, transfer_voice_call_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: VoiceApi.transfer_voice_call ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling VoiceApi.transfer_voice_call"
  end
  # verify the required parameter 'transfer_voice_call_request' is set
  if @api_client.config.client_side_validation && transfer_voice_call_request.nil?
    fail ArgumentError, "Missing the required parameter 'transfer_voice_call_request' when calling VoiceApi.transfer_voice_call"
  end
  # resource path
  local_var_path = '/v1/voice/calls/{id}/transfer'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(transfer_voice_call_request)

  # return_type
  return_type = opts[:debug_return_type] || 'TransferVoiceCall200Response'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"VoiceApi.transfer_voice_call",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: VoiceApi#transfer_voice_call\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end