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(timeout_seconds: OMIT, url: OMIT, headers: OMIT, backoff_plan: OMIT, additional_properties: nil) ⇒ Vapi::Server

Parameters:

  • timeout_seconds (Float) (defaults to: OMIT)

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

  • url (String) (defaults to: OMIT)

    This is where the request will be sent.

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

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

  • backoff_plan (Vapi::BackoffPlan) (defaults to: OMIT)

    This is the backoff plan if the request fails. Defaults to undefined (the request will not be retried). @default undefined (the request will not be retried)

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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

def initialize(timeout_seconds: OMIT, url: OMIT, headers: OMIT, backoff_plan: OMIT, additional_properties: nil)
  @timeout_seconds = timeout_seconds if timeout_seconds != OMIT
  @url = url if url != OMIT
  @headers = headers if headers != OMIT
  @backoff_plan = backoff_plan if backoff_plan != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "timeoutSeconds": timeout_seconds,
    "url": url,
    "headers": headers,
    "backoffPlan": backoff_plan
  }.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



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

def additional_properties
  @additional_properties
end

#backoff_planVapi::BackoffPlan (readonly)

Returns This is the backoff plan if the request fails. Defaults to undefined (the request will not be retried). @default undefined (the request will not be retried).

Returns:

  • (Vapi::BackoffPlan)

    This is the backoff plan if the request fails. Defaults to undefined (the request will not be retried). @default undefined (the request will not be retried)



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

def backoff_plan
  @backoff_plan
end

#headersHash{String => Object} (readonly)

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

Returns:

  • (Hash{String => Object})

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



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

def headers
  @headers
end

#timeout_secondsFloat (readonly)

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

Returns:

  • (Float)

    This is the timeout in seconds for the request. 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 This is where the request will be sent.

Returns:

  • (String)

    This is where the request will be sent.



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:



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

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"]
  headers = parsed_json["headers"]
  if parsed_json["backoffPlan"].nil?
    backoff_plan = nil
  else
    backoff_plan = parsed_json["backoffPlan"].to_json
    backoff_plan = Vapi::BackoffPlan.from_json(json_object: backoff_plan)
  end
  new(
    timeout_seconds: timeout_seconds,
    url: url,
    headers: headers,
    backoff_plan: backoff_plan,
    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)


93
94
95
96
97
98
# File 'lib/vapi_server_sdk/types/server.rb', line 93

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.headers&.is_a?(Hash) != false || raise("Passed value for field obj.headers is not the expected type, validation failed.")
  obj.backoff_plan.nil? || Vapi::BackoffPlan.validate_raw(obj: obj.backoff_plan)
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of Server to a JSON object

Returns:

  • (String)


83
84
85
# File 'lib/vapi_server_sdk/types/server.rb', line 83

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