Class: Vapi::StepDestination

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, step_name:, conditions: OMIT, additional_properties: nil) ⇒ Vapi::StepDestination

Parameters:

  • type (String)
  • conditions (Array<Vapi::StepDestinationConditionsItem>) (defaults to: OMIT)

    This is an optional array of conditions that must be met for this destination to be triggered. If empty, this is the default destination that the step transfers to.

  • step_name (String)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



32
33
34
35
36
37
38
39
40
# File 'lib/vapi_server_sdk/types/step_destination.rb', line 32

def initialize(type:, step_name:, conditions: OMIT, additional_properties: nil)
  @type = type
  @conditions = conditions if conditions != OMIT
  @step_name = step_name
  @additional_properties = additional_properties
  @_field_set = { "type": type, "conditions": conditions, "stepName": step_name }.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



18
19
20
# File 'lib/vapi_server_sdk/types/step_destination.rb', line 18

def additional_properties
  @additional_properties
end

#conditionsArray<Vapi::StepDestinationConditionsItem> (readonly)

Returns This is an optional array of conditions that must be met for this destination to be triggered. If empty, this is the default destination that the step transfers to.

Returns:

  • (Array<Vapi::StepDestinationConditionsItem>)

    This is an optional array of conditions that must be met for this destination to be triggered. If empty, this is the default destination that the step transfers to.



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

def conditions
  @conditions
end

#step_nameString (readonly)

Returns:

  • (String)


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

def step_name
  @step_name
end

#typeString (readonly)

Returns:

  • (String)


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

def type
  @type
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::StepDestination

Deserialize a JSON object to an instance of StepDestination

Parameters:

  • json_object (String)

Returns:



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

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  type = parsed_json["type"]
  conditions = parsed_json["conditions"]&.map do |item|
    item = item.to_json
    Vapi::StepDestinationConditionsItem.from_json(json_object: item)
  end
  step_name = parsed_json["stepName"]
  new(
    type: type,
    conditions: conditions,
    step_name: step_name,
    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/step_destination.rb', line 76

def self.validate_raw(obj:)
  obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.")
  obj.conditions&.is_a?(Array) != false || raise("Passed value for field obj.conditions is not the expected type, validation failed.")
  obj.step_name.is_a?(String) != false || raise("Passed value for field obj.step_name is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of StepDestination to a JSON object

Returns:

  • (String)


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

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