Class: Vapi::BackoffPlan
- Inherits:
-
Object
- Object
- Vapi::BackoffPlan
- Defined in:
- lib/vapi_server_sdk/types/backoff_plan.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#base_delay_seconds ⇒ Float
readonly
This is the base delay in seconds.
-
#max_retries ⇒ Float
readonly
This is the maximum number of retries to attempt if the request fails.
-
#type ⇒ Hash{String => Object}
readonly
This is the type of backoff plan to use.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Vapi::BackoffPlan
Deserialize a JSON object to an instance of BackoffPlan.
-
.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.
Instance Method Summary collapse
- #initialize(type:, max_retries:, base_delay_seconds:, additional_properties: nil) ⇒ Vapi::BackoffPlan constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of BackoffPlan to a JSON object.
Constructor Details
#initialize(type:, max_retries:, base_delay_seconds:, additional_properties: nil) ⇒ Vapi::BackoffPlan
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_properties ⇒ OpenStruct (readonly)
Returns 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_seconds ⇒ Float (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.
17 18 19 |
# File 'lib/vapi_server_sdk/types/backoff_plan.rb', line 17 def base_delay_seconds @base_delay_seconds end |
#max_retries ⇒ Float (readonly)
Returns 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 |
#type ⇒ Hash{String => Object} (readonly)
Returns 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
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.
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
64 65 66 |
# File 'lib/vapi_server_sdk/types/backoff_plan.rb', line 64 def to_json(*_args) @_field_set&.to_json end |