Class: AssemblyAI::Realtime::SessionBegins

Inherits:
Object
  • Object
show all
Defined in:
lib/assemblyai/realtime/types/session_begins.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message_type:, session_id:, expires_at:, additional_properties: nil) ⇒ AssemblyAI::Realtime::SessionBegins

Parameters:

  • message_type (String)

    Describes the type of the message

  • session_id (String)

    Unique identifier for the established session

  • expires_at (DateTime)

    Timestamp when this session will expire

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



29
30
31
32
33
34
35
# File 'lib/assemblyai/realtime/types/session_begins.rb', line 29

def initialize(message_type:, session_id:, expires_at:, additional_properties: nil)
  @message_type = message_type
  @session_id = session_id
  @expires_at = expires_at
  @additional_properties = additional_properties
  @_field_set = { "message_type": message_type, "session_id": session_id, "expires_at": expires_at }
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



17
18
19
# File 'lib/assemblyai/realtime/types/session_begins.rb', line 17

def additional_properties
  @additional_properties
end

#expires_atDateTime (readonly)

Returns Timestamp when this session will expire.

Returns:

  • (DateTime)

    Timestamp when this session will expire



15
16
17
# File 'lib/assemblyai/realtime/types/session_begins.rb', line 15

def expires_at
  @expires_at
end

#message_typeString (readonly)

Returns Describes the type of the message.

Returns:

  • (String)

    Describes the type of the message



11
12
13
# File 'lib/assemblyai/realtime/types/session_begins.rb', line 11

def message_type
  @message_type
end

#session_idString (readonly)

Returns Unique identifier for the established session.

Returns:

  • (String)

    Unique identifier for the established session



13
14
15
# File 'lib/assemblyai/realtime/types/session_begins.rb', line 13

def session_id
  @session_id
end

Class Method Details

.from_json(json_object:) ⇒ AssemblyAI::Realtime::SessionBegins

Deserialize a JSON object to an instance of SessionBegins

Parameters:

  • json_object (String)

Returns:



41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/assemblyai/realtime/types/session_begins.rb', line 41

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  message_type = struct["message_type"]
  session_id = struct["session_id"]
  expires_at = (DateTime.parse(parsed_json["expires_at"]) unless parsed_json["expires_at"].nil?)
  new(
    message_type: message_type,
    session_id: session_id,
    expires_at: expires_at,
    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)


68
69
70
71
72
# File 'lib/assemblyai/realtime/types/session_begins.rb', line 68

def self.validate_raw(obj:)
  obj.message_type.is_a?(String) != false || raise("Passed value for field obj.message_type is not the expected type, validation failed.")
  obj.session_id.is_a?(String) != false || raise("Passed value for field obj.session_id is not the expected type, validation failed.")
  obj.expires_at.is_a?(DateTime) != false || raise("Passed value for field obj.expires_at is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of SessionBegins to a JSON object

Returns:

  • (String)


58
59
60
# File 'lib/assemblyai/realtime/types/session_begins.rb', line 58

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