Class: AssemblyAI::Realtime::SessionBegins
- Inherits:
-
Object
- Object
- AssemblyAI::Realtime::SessionBegins
- Defined in:
- lib/assemblyai/realtime/types/session_begins.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#expires_at ⇒ DateTime
readonly
Timestamp when this session will expire.
-
#message_type ⇒ String
readonly
Describes the type of the message.
-
#session_id ⇒ String
readonly
Unique identifier for the established session.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ AssemblyAI::Realtime::SessionBegins
Deserialize a JSON object to an instance of SessionBegins.
-
.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.
Instance Method Summary collapse
- #initialize(message_type:, session_id:, expires_at:, additional_properties: nil) ⇒ AssemblyAI::Realtime::SessionBegins constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of SessionBegins to a JSON object.
Constructor Details
#initialize(message_type:, session_id:, expires_at:, additional_properties: nil) ⇒ AssemblyAI::Realtime::SessionBegins
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 = @session_id = session_id @expires_at = expires_at @additional_properties = additional_properties @_field_set = { "message_type": , "session_id": session_id, "expires_at": expires_at } end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns 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_at ⇒ DateTime (readonly)
Returns 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_type ⇒ String (readonly)
Returns Describes the type of the message.
11 12 13 |
# File 'lib/assemblyai/realtime/types/session_begins.rb', line 11 def @message_type end |
#session_id ⇒ String (readonly)
Returns 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
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) = 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: , 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.
68 69 70 71 72 |
# File 'lib/assemblyai/realtime/types/session_begins.rb', line 68 def self.validate_raw(obj:) obj..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
58 59 60 |
# File 'lib/assemblyai/realtime/types/session_begins.rb', line 58 def to_json(*_args) @_field_set&.to_json end |