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



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)



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

def additional_properties
  @additional_properties
end

#backoff_planVapi::BackoffPlan (readonly)



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

def backoff_plan
  @backoff_plan
end

#headersHash{String => Object} (readonly)



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

def headers
  @headers
end

#timeout_secondsFloat (readonly)



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

def timeout_seconds
  @timeout_seconds
end

#urlString (readonly)



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



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.


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



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

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