Class: Vapi::Insight::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/vapi/insight/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ void

Parameters:



9
10
11
# File 'lib/vapi/insight/client.rb', line 9

def initialize(client:)
  @client = client
end

Instance Method Details

#insight_controller_create(request_options: {}, **params) ⇒ Vapi::Insight::Types::InsightControllerCreateResponse

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/vapi/insight/client.rb', line 82

def insight_controller_create(request_options: {}, **params)
  params = Vapi::Internal::Types::Utils.normalize_keys(params)
  request = Vapi::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "reporting/insight",
    body: Vapi::Insight::Types::InsightControllerCreateRequest.new(params).to_h,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Vapi::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Vapi::Insight::Types::InsightControllerCreateResponse.load(response.body)
  else
    error_class = Vapi::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#insight_controller_find_all(request_options: {}, **params) ⇒ Vapi::Types::InsightPaginatedResponse

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :id (String, nil)
  • :page (Integer, nil)
  • :sort_order (Vapi::Insight::Types::InsightControllerFindAllRequestSortOrder, nil)
  • :limit (Integer, nil)
  • :created_at_gt (String, nil)
  • :created_at_lt (String, nil)
  • :created_at_ge (String, nil)
  • :created_at_le (String, nil)
  • :updated_at_gt (String, nil)
  • :updated_at_lt (String, nil)
  • :updated_at_ge (String, nil)
  • :updated_at_le (String, nil)

Returns:



34
35
36
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
# File 'lib/vapi/insight/client.rb', line 34

def insight_controller_find_all(request_options: {}, **params)
  params = Vapi::Internal::Types::Utils.normalize_keys(params)
  query_param_names = %i[id page sort_order limit created_at_gt created_at_lt created_at_ge created_at_le updated_at_gt updated_at_lt updated_at_ge updated_at_le]
  query_params = {}
  query_params["id"] = params[:id] if params.key?(:id)
  query_params["page"] = params[:page] if params.key?(:page)
  query_params["sortOrder"] = params[:sort_order] if params.key?(:sort_order)
  query_params["limit"] = params[:limit] if params.key?(:limit)
  query_params["createdAtGt"] = params[:created_at_gt] if params.key?(:created_at_gt)
  query_params["createdAtLt"] = params[:created_at_lt] if params.key?(:created_at_lt)
  query_params["createdAtGe"] = params[:created_at_ge] if params.key?(:created_at_ge)
  query_params["createdAtLe"] = params[:created_at_le] if params.key?(:created_at_le)
  query_params["updatedAtGt"] = params[:updated_at_gt] if params.key?(:updated_at_gt)
  query_params["updatedAtLt"] = params[:updated_at_lt] if params.key?(:updated_at_lt)
  query_params["updatedAtGe"] = params[:updated_at_ge] if params.key?(:updated_at_ge)
  query_params["updatedAtLe"] = params[:updated_at_le] if params.key?(:updated_at_le)
  params.except(*query_param_names)

  request = Vapi::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "reporting/insight",
    query: query_params,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Vapi::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Vapi::Types::InsightPaginatedResponse.load(response.body)
  else
    error_class = Vapi::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#insight_controller_find_one(request_options: {}, **params) ⇒ Vapi::Insight::Types::InsightControllerFindOneResponse

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :id (String)

Returns:



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/vapi/insight/client.rb', line 115

def insight_controller_find_one(request_options: {}, **params)
  params = Vapi::Internal::Types::Utils.normalize_keys(params)
  request = Vapi::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "reporting/insight/#{URI.encode_uri_component(params[:id].to_s)}",
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Vapi::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Vapi::Insight::Types::InsightControllerFindOneResponse.load(response.body)
  else
    error_class = Vapi::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#insight_controller_preview(request_options: {}, **params) ⇒ Vapi::Types::InsightRunResponse

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:



251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
# File 'lib/vapi/insight/client.rb', line 251

def insight_controller_preview(request_options: {}, **params)
  params = Vapi::Internal::Types::Utils.normalize_keys(params)
  request = Vapi::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "reporting/insight/preview",
    body: Vapi::Insight::Types::InsightControllerPreviewRequest.new(params).to_h,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Vapi::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Vapi::Types::InsightRunResponse.load(response.body)
  else
    error_class = Vapi::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#insight_controller_remove(request_options: {}, **params) ⇒ Vapi::Insight::Types::InsightControllerRemoveResponse

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :id (String)

Returns:



147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# File 'lib/vapi/insight/client.rb', line 147

def insight_controller_remove(request_options: {}, **params)
  params = Vapi::Internal::Types::Utils.normalize_keys(params)
  request = Vapi::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "DELETE",
    path: "reporting/insight/#{URI.encode_uri_component(params[:id].to_s)}",
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Vapi::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Vapi::Insight::Types::InsightControllerRemoveResponse.load(response.body)
  else
    error_class = Vapi::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#insight_controller_run(request_options: {}, **params) ⇒ Vapi::Types::InsightRunResponse

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :id (String)

Returns:



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
# File 'lib/vapi/insight/client.rb', line 215

def insight_controller_run(request_options: {}, **params)
  params = Vapi::Internal::Types::Utils.normalize_keys(params)
  request_data = Vapi::Insight::Types::InsightRunDto.new(params).to_h
  non_body_param_names = ["id"]
  body = request_data.except(*non_body_param_names)

  request = Vapi::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "reporting/insight/#{URI.encode_uri_component(params[:id].to_s)}/run",
    body: body,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Vapi::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Vapi::Types::InsightRunResponse.load(response.body)
  else
    error_class = Vapi::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#insight_controller_update(request_options: {}, **params) ⇒ Vapi::Insight::Types::InsightControllerUpdateResponse

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :id (String)

Returns:



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
# File 'lib/vapi/insight/client.rb', line 179

def insight_controller_update(request_options: {}, **params)
  params = Vapi::Internal::Types::Utils.normalize_keys(params)
  path_param_names = %i[id]
  body_params = params.except(*path_param_names)

  request = Vapi::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "PATCH",
    path: "reporting/insight/#{URI.encode_uri_component(params[:id].to_s)}",
    body: Vapi::Insight::Types::InsightControllerUpdateRequestBody.new(body_params).to_h,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Vapi::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Vapi::Insight::Types::InsightControllerUpdateResponse.load(response.body)
  else
    error_class = Vapi::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end