Class: OpenAI::Responses::UnknownServerEvent

Inherits:
Object
  • Object
show all
Includes:
WebSocket::Protocol
Defined in:
lib/openai/helpers/responses_websocket/unknown_server_event.rb

Overview

A valid JSON event whose discriminator is newer than this SDK version.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data:) ⇒ UnknownServerEvent

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of UnknownServerEvent.



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/openai/helpers/responses_websocket/unknown_server_event.rb', line 19

def initialize(data:)
  value = data.fetch(:type)
  unless value.is_a?(String) || value.is_a?(Symbol)
    raise ArgumentError, "Responses server event type must be a string or symbol"
  end

  @type = value.to_sym
  @stream_id = data[:stream_id]
  @data = freeze_json(data)
  freeze
end

Instance Attribute Details

#data ⇒ Hash{Symbol=>Object} (readonly)

Returns:

  • (Hash{Symbol=>Object})


13
14
15
# File 'lib/openai/helpers/responses_websocket/unknown_server_event.rb', line 13

def data
  @data
end

#stream_id ⇒ Object (readonly)

Returns:

  • (Object)


16
17
18
# File 'lib/openai/helpers/responses_websocket/unknown_server_event.rb', line 16

def stream_id
  @stream_id
end

#type ⇒ Symbol (readonly)

Returns:

  • (Symbol)


10
11
12
# File 'lib/openai/helpers/responses_websocket/unknown_server_event.rb', line 10

def type
  @type
end

Instance Method Details

#inspect ⇒ Object Also known as: to_s

Keep routine diagnostics payload-free. Callers that explicitly need the unknown JSON can use #data or #to_h.



36
# File 'lib/openai/helpers/responses_websocket/unknown_server_event.rb', line 36

def inspect = "#<#{self.class} type=#{@type.inspect}>"

#to_h ⇒ Hash{Symbol=>Object}

Returns:

  • (Hash{Symbol=>Object})


32
# File 'lib/openai/helpers/responses_websocket/unknown_server_event.rb', line 32

def to_h = @data