Class: AssemblyAI::Transcripts::WordSearchResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/assemblyai/transcripts/types/word_search_response.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, total_count:, matches:, additional_properties: nil) ⇒ AssemblyAI::Transcripts::WordSearchResponse

Parameters:

  • id (String)

    The ID of the transcript

  • total_count (Integer)

    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.

  • matches (Array<AssemblyAI::Transcripts::WordSearchMatch>)

    The matches of the search

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    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

#idString (readonly)

Returns The ID of the transcript.

Returns:

  • (String)

    The ID of the transcript



11
12
13
# File 'lib/assemblyai/transcripts/types/word_search_response.rb', line 11

def id
  @id
end

#matchesArray<AssemblyAI::Transcripts::WordSearchMatch> (readonly)

Returns The matches of the search.

Returns:



16
17
18
# File 'lib/assemblyai/transcripts/types/word_search_response.rb', line 16

def matches
  @matches
end

#total_countInteger (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.

Returns:

  • (Integer)

    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

Parameters:

  • json_object (String)

Returns:



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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


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

Returns:

  • (String)


63
64
65
# File 'lib/assemblyai/transcripts/types/word_search_response.rb', line 63

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