Class: Vapi::Condition

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value:, operator:, param:, additional_properties: nil) ⇒ Vapi::Condition

Parameters:

  • value (String)

    This is the value you want to compare against the parameter.

  • operator (Vapi::ConditionOperator)

    This is the operator you want to use to compare the parameter and value.

  • param (String)

    This is the name of the parameter that you want to check.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



28
29
30
31
32
33
34
# File 'lib/vapi_server_sdk/types/condition.rb', line 28

def initialize(value:, operator:, param:, additional_properties: nil)
  @value = value
  @operator = operator
  @param = param
  @additional_properties = additional_properties
  @_field_set = { "value": value, "operator": operator, "param": param }
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



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

def additional_properties
  @additional_properties
end

#operatorVapi::ConditionOperator (readonly)

Returns This is the operator you want to use to compare the parameter and value.

Returns:



12
13
14
# File 'lib/vapi_server_sdk/types/condition.rb', line 12

def operator
  @operator
end

#paramString (readonly)

Returns This is the name of the parameter that you want to check.

Returns:

  • (String)

    This is the name of the parameter that you want to check.



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

def param
  @param
end

#valueString (readonly)

Returns This is the value you want to compare against the parameter.

Returns:

  • (String)

    This is the value you want to compare against the parameter.



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

def value
  @value
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::Condition

Deserialize a JSON object to an instance of Condition

Parameters:

  • json_object (String)

Returns:



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

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  value = parsed_json["value"]
  operator = parsed_json["operator"]
  param = parsed_json["param"]
  new(
    value: value,
    operator: operator,
    param: param,
    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)


67
68
69
70
71
# File 'lib/vapi_server_sdk/types/condition.rb', line 67

def self.validate_raw(obj:)
  obj.value.is_a?(String) != false || raise("Passed value for field obj.value is not the expected type, validation failed.")
  obj.operator.is_a?(Vapi::ConditionOperator) != false || raise("Passed value for field obj.operator is not the expected type, validation failed.")
  obj.param.is_a?(String) != false || raise("Passed value for field obj.param is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of Condition to a JSON object

Returns:

  • (String)


57
58
59
# File 'lib/vapi_server_sdk/types/condition.rb', line 57

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