Class: Zernio::CallsApi

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ CallsApi

Returns a new instance of CallsApi.



19
20
21
# File 'lib/zernio-sdk/api/calls_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/calls_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#get_call(id, opts = {}) ⇒ GetCall200Response

Get a call (any channel) Channel-agnostic call detail: works for both WhatsApp and regular phone (PSTN) calls, so any row from GET /v1/calls can be opened without branching on channel. Returns the full call including transcript segments, with contactId/contactName set when the counterparty matches a CRM contact.

Parameters:

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

    the optional parameters

Returns:



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

def get_call(id, opts = {})
  data, _status_code, _headers = get_call_with_http_info(id, opts)
  data
end

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

Get a call recording Channel-agnostic recording fetch: resolves a fresh, playable MP3 URL for any call regardless of channel (provider-signed URLs expire ~10 minutes after signing, so this 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:



91
92
93
94
# File 'lib/zernio-sdk/api/calls_api.rb', line 91

def get_call_recording(id, opts = {})
  data, _status_code, _headers = get_call_recording_with_http_info(id, opts)
  data
end

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

Get a call recording Channel-agnostic recording fetch: resolves a fresh, playable MP3 URL for any call regardless of channel (provider-signed URLs expire ~10 minutes after signing, so this 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:



102
103
104
105
106
107
108
109
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
153
# File 'lib/zernio-sdk/api/calls_api.rb', line 102

def get_call_recording_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CallsApi.get_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 CallsApi.get_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/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 => :"CallsApi.get_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: CallsApi#get_call_recording\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_call_with_http_info(id, opts = {}) ⇒ Array<(GetCall200Response, Integer, Hash)>

Get a call (any channel) Channel-agnostic call detail: works for both WhatsApp and regular phone (PSTN) calls, so any row from `GET /v1/calls` can be opened without branching on `channel`. Returns the full call including transcript segments, with `contactId`/`contactName` set when the counterparty matches a CRM contact.

Parameters:

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

    the optional parameters

Returns:

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

    GetCall200Response data, response status code and response headers



37
38
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
# File 'lib/zernio-sdk/api/calls_api.rb', line 37

def get_call_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CallsApi.get_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 CallsApi.get_call"
  end
  # resource path
  local_var_path = '/v1/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] || 'GetCall200Response'

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

  new_options = opts.merge(
    :operation => :"CallsApi.get_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: CallsApi#get_call\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_calls(opts = {}) ⇒ ListCalls200Response

List all calls (unified history) Unified call history across ALL of your numbers: both channels (WhatsApp Business Calling + regular phone/PSTN), inbound and outbound, newest first. Unlike GET /v1/voice/calls (PSTN-only) and GET /v1/whatsapp/calls (one account at a time), this endpoint needs no accountId and never requires fanning out one request per number. Any row can be opened channel-agnostically via GET /v1/calls/{id} and GET /v1/calls/{id}/recording; no branching on channel needed. When the counterparty number matches a CRM contact, contactId and contactName are set. Cursor pagination: pass the returned nextCursor as before to fetch the next page. nextCursor is null on the last page.

Parameters:

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

    the optional parameters

Options Hash (opts):

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

    Exact filter: calls involving this number (typically one of YOUR numbers, to scope history to a single line). E.164, leading + optional.

  • :search (String)

    Free-text match on the from/to numbers. Non-digits are stripped, so partial queries like `302` or `+1 302` work.

  • :before (Time)

    Return calls with startedAt strictly before this instant (use the previous page's nextCursor).

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

Returns:



166
167
168
169
# File 'lib/zernio-sdk/api/calls_api.rb', line 166

def list_calls(opts = {})
  data, _status_code, _headers = list_calls_with_http_info(opts)
  data
end

#list_calls_with_http_info(opts = {}) ⇒ Array<(ListCalls200Response, Integer, Hash)>

List all calls (unified history) Unified call history across ALL of your numbers: both channels (WhatsApp Business Calling + regular phone/PSTN), inbound and outbound, newest first. Unlike `GET /v1/voice/calls` (PSTN-only) and `GET /v1/whatsapp/calls` (one account at a time), this endpoint needs no `accountId` and never requires fanning out one request per number. Any row can be opened channel-agnostically via `GET /v1/calls/id` and `GET /v1/calls/id/recording`; no branching on `channel` needed. When the counterparty number matches a CRM contact, `contactId` and `contactName` are set. Cursor pagination: pass the returned `nextCursor` as `before` to fetch the next page. `nextCursor` is null on the last page.

Parameters:

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

    the optional parameters

Options Hash (opts):

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

    Exact filter: calls involving this number (typically one of YOUR numbers, to scope history to a single line). E.164, leading + optional.

  • :search (String)

    Free-text match on the from/to numbers. Non-digits are stripped, so partial queries like `302` or `+1 302` work.

  • :before (Time)

    Return calls with startedAt strictly before this instant (use the previous page's nextCursor).

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

Returns:

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

    ListCalls200Response data, response status code and response headers



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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
# File 'lib/zernio-sdk/api/calls_api.rb', line 182

def list_calls_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CallsApi.list_calls ...'
  end
  allowable_values = ["whatsapp", "pstn"]
  if @api_client.config.client_side_validation && opts[:'channel'] && !allowable_values.include?(opts[:'channel'])
    fail ArgumentError, "invalid value for \"channel\", must be one of #{allowable_values}"
  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 CallsApi.list_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 CallsApi.list_calls, must be greater than or equal to 1.'
  end

  # resource path
  local_var_path = '/v1/calls'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'channel'] = opts[:'channel'] if !opts[:'channel'].nil?
  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[:'search'] = opts[:'search'] if !opts[:'search'].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] || 'ListCalls200Response'

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

  new_options = opts.merge(
    :operation => :"CallsApi.list_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: CallsApi#list_calls\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end