Class: Vapi::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/vapi_server_sdk/types/server.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url:, timeout_seconds: OMIT, secret: OMIT, headers: OMIT, additional_properties: nil) ⇒ Vapi::Server

Parameters:

  • timeout_seconds (Float) (defaults to: OMIT) —

    This is the timeout in seconds for the request to your server. Defaults to 20 seconds. @default 20

  • url (String) —

    API endpoint to send requests to.

  • secret (String) (defaults to: OMIT) —

    This is the secret you can set that Vapi will send with every request to your server. Will be sent as a header called x-vapi-secret. Same precedence logic as server.

  • headers (Hash{String => Object}) (defaults to: OMIT) —

    These are the custom headers to include in the request sent to your server. Each key-value pair represents a header name and its value.

  • additional_properties (OpenStruct) (defaults to: nil) —

    Additional properties unmapped to the current class definition



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/vapi_server_sdk/types/server.rb', line 40

def initialize(url:, timeout_seconds: OMIT, secret: OMIT, headers: OMIT, additional_properties: nil)
  @timeout_seconds = timeout_seconds if timeout_seconds != OMIT
  @url = url
  @secret = secret if secret != OMIT
  @headers = headers if headers != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "timeoutSeconds": timeout_seconds,
    "url": url,
    "secret": secret,
    "headers": headers
  }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#additional_properties ⇒ OpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct) —

    Additional properties unmapped to the current class definition



22
23
24
# File 'lib/vapi_server_sdk/types/server.rb', line 22

def additional_properties
  @additional_properties
end

#headers ⇒ Hash{String => Object} (readonly)

Returns These are the custom headers to include in the request sent to your server. Each key-value pair represents a header name and its value.

Returns:

  • (Hash{String => Object}) —

    These are the custom headers to include in the request sent to your server. Each key-value pair represents a header name and its value.



20
21
22
# File 'lib/vapi_server_sdk/types/server.rb', line 20

def headers
  @headers
end

#secret ⇒ String (readonly)

Returns This is the secret you can set that Vapi will send with every request to your server. Will be sent as a header called x-vapi-secret. Same precedence logic as server.

Returns:

  • (String) —

    This is the secret you can set that Vapi will send with every request to your server. Will be sent as a header called x-vapi-secret. Same precedence logic as server.



17
18
19
# File 'lib/vapi_server_sdk/types/server.rb', line 17

def secret
  @secret
end

#timeout_seconds ⇒ Float (readonly)

Returns This is the timeout in seconds for the request to your server. Defaults to 20 seconds. @default 20.

Returns:

  • (Float) —

    This is the timeout in seconds for the request to your server. Defaults to 20 seconds. @default 20



11
12
13
# File 'lib/vapi_server_sdk/types/server.rb', line 11

def timeout_seconds
  @timeout_seconds
end

#url ⇒ String (readonly)

Returns API endpoint to send requests to.

Returns:

  • (String) —

    API endpoint to send requests to.



13
14
15
# File 'lib/vapi_server_sdk/types/server.rb', line 13

def url
  @url
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::Server

Deserialize a JSON object to an instance of Server

Parameters:

  • json_object (String)

Returns:



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/vapi_server_sdk/types/server.rb', line 60

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  timeout_seconds = parsed_json["timeoutSeconds"]
  url = parsed_json["url"]
  secret = parsed_json["secret"]
  headers = parsed_json["headers"]
  new(
    timeout_seconds: timeout_seconds,
    url: url,
    secret: secret,
    headers: headers,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions.

Parameters:

  • obj (Object)

Returns:

  • (Void)


89
90
91
92
93
94
# File 'lib/vapi_server_sdk/types/server.rb', line 89

def self.validate_raw(obj:)
  obj.timeout_seconds&.is_a?(Float) != false || raise("Passed value for field obj.timeout_seconds is not the expected type, validation failed.")
  obj.url.is_a?(String) != false || raise("Passed value for field obj.url is not the expected type, validation failed.")
  obj.secret&.is_a?(String) != false || raise("Passed value for field obj.secret is not the expected type, validation failed.")
  obj.headers&.is_a?(Hash) != false || raise("Passed value for field obj.headers is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of Server to a JSON object

Returns:

  • (String)


79
80
81
# File 'lib/vapi_server_sdk/types/server.rb', line 79

def to_json(*_args)
  @_field_set&.to_json
end