-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from AssemblyAI/fern-bot/03-18-2024-0809PM
🌿 Fern Regeneration -- March 18, 2024
- Loading branch information
Showing
9 changed files
with
194 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# frozen_string_literal: true | ||
|
||
require "json" | ||
require_relative "session_begins" | ||
require_relative "partial_transcript" | ||
require_relative "final_transcript" | ||
require_relative "session_terminated" | ||
require_relative "realtime_error" | ||
|
||
module AssemblyAI | ||
class Realtime | ||
# Receive messages from the WebSocket | ||
class ReceiveMessage | ||
# Deserialize a JSON object to an instance of ReceiveMessage | ||
# | ||
# @param json_object [JSON] | ||
# @return [Realtime::ReceiveMessage] | ||
def self.from_json(json_object:) | ||
struct = JSON.parse(json_object, object_class: OpenStruct) | ||
begin | ||
Realtime::SessionBegins.validate_raw(obj: struct) | ||
return Realtime::SessionBegins.from_json(json_object: json_object) | ||
rescue StandardError | ||
# noop | ||
end | ||
begin | ||
Realtime::PartialTranscript.validate_raw(obj: struct) | ||
return Realtime::PartialTranscript.from_json(json_object: json_object) | ||
rescue StandardError | ||
# noop | ||
end | ||
begin | ||
Realtime::FinalTranscript.validate_raw(obj: struct) | ||
return Realtime::FinalTranscript.from_json(json_object: json_object) | ||
rescue StandardError | ||
# noop | ||
end | ||
begin | ||
Realtime::SessionTerminated.validate_raw(obj: struct) | ||
return Realtime::SessionTerminated.from_json(json_object: json_object) | ||
rescue StandardError | ||
# noop | ||
end | ||
begin | ||
Realtime::RealtimeError.validate_raw(obj: struct) | ||
return Realtime::RealtimeError.from_json(json_object: json_object) | ||
rescue StandardError | ||
# noop | ||
end | ||
struct | ||
end | ||
|
||
# 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. | ||
# | ||
# @param obj [Object] | ||
# @return [Void] | ||
def self.validate_raw(obj:) | ||
begin | ||
return Realtime::SessionBegins.validate_raw(obj: obj) | ||
rescue StandardError | ||
# noop | ||
end | ||
begin | ||
return Realtime::PartialTranscript.validate_raw(obj: obj) | ||
rescue StandardError | ||
# noop | ||
end | ||
begin | ||
return Realtime::FinalTranscript.validate_raw(obj: obj) | ||
rescue StandardError | ||
# noop | ||
end | ||
begin | ||
return Realtime::SessionTerminated.validate_raw(obj: obj) | ||
rescue StandardError | ||
# noop | ||
end | ||
begin | ||
return Realtime::RealtimeError.validate_raw(obj: obj) | ||
rescue StandardError | ||
# noop | ||
end | ||
raise("Passed value matched no type within the union, validation failed.") | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# frozen_string_literal: true | ||
|
||
require "json" | ||
require_relative "terminate_session" | ||
require_relative "force_end_utterance" | ||
require_relative "configure_end_utterance_silence_threshold" | ||
|
||
module AssemblyAI | ||
class Realtime | ||
# Send messages to the WebSocket | ||
class SendMessage | ||
# Deserialize a JSON object to an instance of SendMessage | ||
# | ||
# @param json_object [JSON] | ||
# @return [Realtime::SendMessage] | ||
def self.from_json(json_object:) | ||
struct = JSON.parse(json_object, object_class: OpenStruct) | ||
begin | ||
struct.is_a?(String) != false || raise("Passed value for field struct is not the expected type, validation failed.") | ||
return json_object | ||
rescue StandardError | ||
# noop | ||
end | ||
begin | ||
Realtime::TerminateSession.validate_raw(obj: struct) | ||
return Realtime::TerminateSession.from_json(json_object: json_object) | ||
rescue StandardError | ||
# noop | ||
end | ||
begin | ||
Realtime::ForceEndUtterance.validate_raw(obj: struct) | ||
return Realtime::ForceEndUtterance.from_json(json_object: json_object) | ||
rescue StandardError | ||
# noop | ||
end | ||
begin | ||
Realtime::ConfigureEndUtteranceSilenceThreshold.validate_raw(obj: struct) | ||
return Realtime::ConfigureEndUtteranceSilenceThreshold.from_json(json_object: json_object) | ||
rescue StandardError | ||
# noop | ||
end | ||
struct | ||
end | ||
|
||
# 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. | ||
# | ||
# @param obj [Object] | ||
# @return [Void] | ||
def self.validate_raw(obj:) | ||
begin | ||
return obj.is_a?(String) != false || raise("Passed value for field obj is not the expected type, validation failed.") | ||
rescue StandardError | ||
# noop | ||
end | ||
begin | ||
return Realtime::TerminateSession.validate_raw(obj: obj) | ||
rescue StandardError | ||
# noop | ||
end | ||
begin | ||
return Realtime::ForceEndUtterance.validate_raw(obj: obj) | ||
rescue StandardError | ||
# noop | ||
end | ||
begin | ||
return Realtime::ConfigureEndUtteranceSilenceThreshold.validate_raw(obj: obj) | ||
rescue StandardError | ||
# noop | ||
end | ||
raise("Passed value matched no type within the union, validation failed.") | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters