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, 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.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



35
36
37
38
39
40
41
42
43
# File 'lib/vapi_server_sdk/types/server.rb', line 35

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

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



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

def additional_properties
  @additional_properties
end

#secretString (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_secondsFloat (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

#urlString (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:



49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/vapi_server_sdk/types/server.rb', line 49

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"]
  new(
    timeout_seconds: timeout_seconds,
    url: url,
    secret: secret,
    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)


76
77
78
79
80
# File 'lib/vapi_server_sdk/types/server.rb', line 76

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.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of Server to a JSON object

Returns:

  • (String)


66
67
68
# File 'lib/vapi_server_sdk/types/server.rb', line 66

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