Class: AssemblyAI::Transcripts::ContentSafetyLabelResult

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text:, labels:, sentences_idx_start:, sentences_idx_end:, timestamp:, additional_properties: nil) ⇒ AssemblyAI::Transcripts::ContentSafetyLabelResult



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/assemblyai/transcripts/types/content_safety_label_result.rb', line 38

def initialize(text:, labels:, sentences_idx_start:, sentences_idx_end:, timestamp:, additional_properties: nil)
  @text = text
  @labels = labels
  @sentences_idx_start = sentences_idx_start
  @sentences_idx_end = sentences_idx_end
  @timestamp = timestamp
  @additional_properties = additional_properties
  @_field_set = {
    "text": text,
    "labels": labels,
    "sentences_idx_start": sentences_idx_start,
    "sentences_idx_end": sentences_idx_end,
    "timestamp": timestamp
  }
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)



23
24
25
# File 'lib/assemblyai/transcripts/types/content_safety_label_result.rb', line 23

def additional_properties
  @additional_properties
end

#labelsArray<AssemblyAI::Transcripts::ContentSafetyLabel> (readonly)



15
16
17
# File 'lib/assemblyai/transcripts/types/content_safety_label_result.rb', line 15

def labels
  @labels
end

#sentences_idx_endInteger (readonly)



19
20
21
# File 'lib/assemblyai/transcripts/types/content_safety_label_result.rb', line 19

def sentences_idx_end
  @sentences_idx_end
end

#sentences_idx_startInteger (readonly)



17
18
19
# File 'lib/assemblyai/transcripts/types/content_safety_label_result.rb', line 17

def sentences_idx_start
  @sentences_idx_start
end

#textString (readonly)



12
13
14
# File 'lib/assemblyai/transcripts/types/content_safety_label_result.rb', line 12

def text
  @text
end

#timestampAssemblyAI::Transcripts::Timestamp (readonly)



21
22
23
# File 'lib/assemblyai/transcripts/types/content_safety_label_result.rb', line 21

def timestamp
  @timestamp
end

Class Method Details

.from_json(json_object:) ⇒ AssemblyAI::Transcripts::ContentSafetyLabelResult

Deserialize a JSON object to an instance of ContentSafetyLabelResult



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/assemblyai/transcripts/types/content_safety_label_result.rb', line 58

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  text = struct["text"]
  labels = parsed_json["labels"]&.map do |v|
    v = v.to_json
    AssemblyAI::Transcripts::ContentSafetyLabel.from_json(json_object: v)
  end
  sentences_idx_start = struct["sentences_idx_start"]
  sentences_idx_end = struct["sentences_idx_end"]
  if parsed_json["timestamp"].nil?
    timestamp = nil
  else
    timestamp = parsed_json["timestamp"].to_json
    timestamp = AssemblyAI::Transcripts::Timestamp.from_json(json_object: timestamp)
  end
  new(
    text: text,
    labels: labels,
    sentences_idx_start: sentences_idx_start,
    sentences_idx_end: sentences_idx_end,
    timestamp: timestamp,
    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.


97
98
99
100
101
102
103
# File 'lib/assemblyai/transcripts/types/content_safety_label_result.rb', line 97

def self.validate_raw(obj:)
  obj.text.is_a?(String) != false || raise("Passed value for field obj.text is not the expected type, validation failed.")
  obj.labels.is_a?(Array) != false || raise("Passed value for field obj.labels is not the expected type, validation failed.")
  obj.sentences_idx_start.is_a?(Integer) != false || raise("Passed value for field obj.sentences_idx_start is not the expected type, validation failed.")
  obj.sentences_idx_end.is_a?(Integer) != false || raise("Passed value for field obj.sentences_idx_end is not the expected type, validation failed.")
  AssemblyAI::Transcripts::Timestamp.validate_raw(obj: obj.timestamp)
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of ContentSafetyLabelResult to a JSON object



87
88
89
# File 'lib/assemblyai/transcripts/types/content_safety_label_result.rb', line 87

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