Class: Vapi::ResponseTextDeltaEvent

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content_index:, delta:, item_id:, output_index:, type:, additional_properties: nil) ⇒ Vapi::ResponseTextDeltaEvent

Parameters:

  • content_index (Float)

    Index of the content part

  • delta (String)

    Text delta being added

  • item_id (String)

    ID of the output item

  • output_index (Float)

    Index of the output item

  • type (String)

    Event type

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/vapi_server_sdk/types/response_text_delta_event.rb', line 33

def initialize(content_index:, delta:, item_id:, output_index:, type:, additional_properties: nil)
  @content_index = content_index
  @delta = delta
  @item_id = item_id
  @output_index = output_index
  @type = type
  @additional_properties = additional_properties
  @_field_set = {
    "content_index": content_index,
    "delta": delta,
    "item_id": item_id,
    "output_index": output_index,
    "type": type
  }
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/response_text_delta_event.rb', line 19

def additional_properties
  @additional_properties
end

#content_indexFloat (readonly)

Returns Index of the content part.

Returns:

  • (Float)

    Index of the content part



9
10
11
# File 'lib/vapi_server_sdk/types/response_text_delta_event.rb', line 9

def content_index
  @content_index
end

#deltaString (readonly)

Returns Text delta being added.

Returns:

  • (String)

    Text delta being added



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

def delta
  @delta
end

#item_idString (readonly)

Returns ID of the output item.

Returns:

  • (String)

    ID of the output item



13
14
15
# File 'lib/vapi_server_sdk/types/response_text_delta_event.rb', line 13

def item_id
  @item_id
end

#output_indexFloat (readonly)

Returns Index of the output item.

Returns:

  • (Float)

    Index of the output item



15
16
17
# File 'lib/vapi_server_sdk/types/response_text_delta_event.rb', line 15

def output_index
  @output_index
end

#typeString (readonly)

Returns Event type.

Returns:

  • (String)

    Event type



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

def type
  @type
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::ResponseTextDeltaEvent

Deserialize a JSON object to an instance of ResponseTextDeltaEvent

Parameters:

  • json_object (String)

Returns:



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/vapi_server_sdk/types/response_text_delta_event.rb', line 53

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  content_index = parsed_json["content_index"]
  delta = parsed_json["delta"]
  item_id = parsed_json["item_id"]
  output_index = parsed_json["output_index"]
  type = parsed_json["type"]
  new(
    content_index: content_index,
    delta: delta,
    item_id: item_id,
    output_index: output_index,
    type: type,
    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)


84
85
86
87
88
89
90
# File 'lib/vapi_server_sdk/types/response_text_delta_event.rb', line 84

def self.validate_raw(obj:)
  obj.content_index.is_a?(Float) != false || raise("Passed value for field obj.content_index is not the expected type, validation failed.")
  obj.delta.is_a?(String) != false || raise("Passed value for field obj.delta is not the expected type, validation failed.")
  obj.item_id.is_a?(String) != false || raise("Passed value for field obj.item_id is not the expected type, validation failed.")
  obj.output_index.is_a?(Float) != false || raise("Passed value for field obj.output_index is not the expected type, validation failed.")
  obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of ResponseTextDeltaEvent to a JSON object

Returns:

  • (String)


74
75
76
# File 'lib/vapi_server_sdk/types/response_text_delta_event.rb', line 74

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