Class: AssemblyAI::Transcripts::WordSearchResponse
- Inherits:
-
Object
- Object
- AssemblyAI::Transcripts::WordSearchResponse
- Defined in:
- lib/assemblyai/transcripts/types/word_search_response.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#id ⇒ String
readonly
The ID of the transcript.
-
#matches ⇒ Array<AssemblyAI::Transcripts::WordSearchMatch>
readonly
The matches of the search.
-
#total_count ⇒ Integer
readonly
The total count of all matched instances.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ AssemblyAI::Transcripts::WordSearchResponse
Deserialize a JSON object to an instance of WordSearchResponse.
-
.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(id:, total_count:, matches:, additional_properties: nil) ⇒ AssemblyAI::Transcripts::WordSearchResponse constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of WordSearchResponse to a JSON object.
Constructor Details
#initialize(id:, total_count:, matches:, additional_properties: nil) ⇒ AssemblyAI::Transcripts::WordSearchResponse
31 32 33 34 35 36 37 |
# File 'lib/assemblyai/transcripts/types/word_search_response.rb', line 31 def initialize(id:, total_count:, matches:, additional_properties: nil) @id = id @total_count = total_count @matches = matches @additional_properties = additional_properties @_field_set = { "id": id, "total_count": total_count, "matches": matches } end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
18 19 20 |
# File 'lib/assemblyai/transcripts/types/word_search_response.rb', line 18 def additional_properties @additional_properties end |
#id ⇒ String (readonly)
Returns The ID of the transcript.
11 12 13 |
# File 'lib/assemblyai/transcripts/types/word_search_response.rb', line 11 def id @id end |
#matches ⇒ Array<AssemblyAI::Transcripts::WordSearchMatch> (readonly)
Returns The matches of the search.
16 17 18 |
# File 'lib/assemblyai/transcripts/types/word_search_response.rb', line 16 def matches @matches end |
#total_count ⇒ Integer (readonly)
Returns The total count of all matched instances. For e.g., word 1 matched 2 times, and word 2 matched 3 times, ‘total_count` will equal 5.
14 15 16 |
# File 'lib/assemblyai/transcripts/types/word_search_response.rb', line 14 def total_count @total_count end |
Class Method Details
.from_json(json_object:) ⇒ AssemblyAI::Transcripts::WordSearchResponse
Deserialize a JSON object to an instance of WordSearchResponse
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/assemblyai/transcripts/types/word_search_response.rb', line 43 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) id = struct["id"] total_count = struct["total_count"] matches = parsed_json["matches"]&.map do |v| v = v.to_json AssemblyAI::Transcripts::WordSearchMatch.from_json(json_object: v) end new( id: id, total_count: total_count, matches: matches, 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.
73 74 75 76 77 |
# File 'lib/assemblyai/transcripts/types/word_search_response.rb', line 73 def self.validate_raw(obj:) obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") obj.total_count.is_a?(Integer) != false || raise("Passed value for field obj.total_count is not the expected type, validation failed.") obj.matches.is_a?(Array) != false || raise("Passed value for field obj.matches is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of WordSearchResponse to a JSON object
63 64 65 |
# File 'lib/assemblyai/transcripts/types/word_search_response.rb', line 63 def to_json(*_args) @_field_set&.to_json end |