Class: Vapi::ProviderResources::Client

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ void

Parameters:



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

def initialize(client:)
  @client = client
end

Instance Method Details

#provider_resource_controller_create_provider_resource(request_options: {}, **params) ⇒ Vapi::Types::ProviderResource

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):

Returns:



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/vapi/provider_resources/client.rb', line 88

def provider_resource_controller_create_provider_resource(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: "provider/#{URI.encode_uri_component(params[:provider].to_s)}/#{URI.encode_uri_component(params[:resource_name].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::Types::ProviderResource.load(response.body)
  else
    error_class = Vapi::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#provider_resource_controller_delete_provider_resource(request_options: {}, **params) ⇒ Vapi::Types::ProviderResource

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):

Returns:



156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'lib/vapi/provider_resources/client.rb', line 156

def provider_resource_controller_delete_provider_resource(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: "provider/#{URI.encode_uri_component(params[:provider].to_s)}/#{URI.encode_uri_component(params[:resource_name].to_s)}/#{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::Types::ProviderResource.load(response.body)
  else
    error_class = Vapi::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#provider_resource_controller_get_provider_resource(request_options: {}, **params) ⇒ Vapi::Types::ProviderResource

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):

Returns:



122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/vapi/provider_resources/client.rb', line 122

def provider_resource_controller_get_provider_resource(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: "provider/#{URI.encode_uri_component(params[:provider].to_s)}/#{URI.encode_uri_component(params[:resource_name].to_s)}/#{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::Types::ProviderResource.load(response.body)
  else
    error_class = Vapi::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#provider_resource_controller_get_provider_resources_paginated(request_options: {}, **params) ⇒ Vapi::Types::ProviderResourcePaginatedResponse

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):

Returns:



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

def provider_resource_controller_get_provider_resources_paginated(request_options: {}, **params)
  params = Vapi::Internal::Types::Utils.normalize_keys(params)
  query_param_names = %i[id resource_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["resourceId"] = params[:resource_id] if params.key?(:resource_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 = params.except(*query_param_names)

  request = Vapi::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "provider/#{URI.encode_uri_component(params[:provider].to_s)}/#{URI.encode_uri_component(params[:resource_name].to_s)}",
    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::ProviderResourcePaginatedResponse.load(response.body)
  else
    error_class = Vapi::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#provider_resource_controller_update_provider_resource(request_options: {}, **params) ⇒ Vapi::Types::ProviderResource

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):

Returns:



190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
# File 'lib/vapi/provider_resources/client.rb', line 190

def provider_resource_controller_update_provider_resource(request_options: {}, **params)
  params = Vapi::Internal::Types::Utils.normalize_keys(params)
  request = Vapi::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "PATCH",
    path: "provider/#{URI.encode_uri_component(params[:provider].to_s)}/#{URI.encode_uri_component(params[:resource_name].to_s)}/#{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::Types::ProviderResource.load(response.body)
  else
    error_class = Vapi::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end