Class: Vapi::BackoffPlan

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, max_retries:, base_delay_seconds:, additional_properties: nil) ⇒ Vapi::BackoffPlan

Parameters:

  • type (Hash{String => Object})

    This is the type of backoff plan to use. Defaults to fixed. @default fixed

  • max_retries (Float)

    This is the maximum number of retries to attempt if the request fails. Defaults to 0 (no retries). @default 0

  • base_delay_seconds (Float)

    This is the base delay in seconds. For linear backoff, this is the delay between each retry. For exponential backoff, this is the initial delay.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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

def initialize(type:, max_retries:, base_delay_seconds:, additional_properties: nil)
  @type = type
  @max_retries = max_retries
  @base_delay_seconds = base_delay_seconds
  @additional_properties = additional_properties
  @_field_set = { "type": type, "maxRetries": max_retries, "baseDelaySeconds": base_delay_seconds }
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/backoff_plan.rb', line 19

def additional_properties
  @additional_properties
end

#base_delay_secondsFloat (readonly)

Returns This is the base delay in seconds. For linear backoff, this is the delay between each retry. For exponential backoff, this is the initial delay.

Returns:

  • (Float)

    This is the base delay in seconds. For linear backoff, this is the delay between each retry. For exponential backoff, this is the initial delay.



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

def base_delay_seconds
  @base_delay_seconds
end

#max_retriesFloat (readonly)

Returns This is the maximum number of retries to attempt if the request fails. Defaults to 0 (no retries). @default 0.

Returns:

  • (Float)

    This is the maximum number of retries to attempt if the request fails. Defaults to 0 (no retries). @default 0



14
15
16
# File 'lib/vapi_server_sdk/types/backoff_plan.rb', line 14

def max_retries
  @max_retries
end

#typeHash{String => Object} (readonly)

Returns This is the type of backoff plan to use. Defaults to fixed. @default fixed.

Returns:

  • (Hash{String => Object})

    This is the type of backoff plan to use. Defaults to fixed. @default fixed



10
11
12
# File 'lib/vapi_server_sdk/types/backoff_plan.rb', line 10

def type
  @type
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::BackoffPlan

Deserialize a JSON object to an instance of BackoffPlan

Parameters:

  • json_object (String)

Returns:



47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/vapi_server_sdk/types/backoff_plan.rb', line 47

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  type = parsed_json["type"]
  max_retries = parsed_json["maxRetries"]
  base_delay_seconds = parsed_json["baseDelaySeconds"]
  new(
    type: type,
    max_retries: max_retries,
    base_delay_seconds: base_delay_seconds,
    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)


74
75
76
77
78
# File 'lib/vapi_server_sdk/types/backoff_plan.rb', line 74

def self.validate_raw(obj:)
  obj.type.is_a?(Hash) != false || raise("Passed value for field obj.type is not the expected type, validation failed.")
  obj.max_retries.is_a?(Float) != false || raise("Passed value for field obj.max_retries is not the expected type, validation failed.")
  obj.base_delay_seconds.is_a?(Float) != false || raise("Passed value for field obj.base_delay_seconds is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of BackoffPlan to a JSON object

Returns:

  • (String)


64
65
66
# File 'lib/vapi_server_sdk/types/backoff_plan.rb', line 64

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