assemblyai 1.0.0.pre.beta.7 → 1.0.0.pre.beta.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/lib/assemblyai/files/client.rb +4 -2
  3. data/lib/assemblyai/files/types/uploaded_file.rb +20 -11
  4. data/lib/assemblyai/lemur/client.rb +256 -150
  5. data/lib/assemblyai/lemur/types/lemur_action_items_response.rb +28 -14
  6. data/lib/assemblyai/lemur/types/lemur_base_params.rb +83 -54
  7. data/lib/assemblyai/lemur/types/lemur_base_params_context.rb +11 -5
  8. data/lib/assemblyai/lemur/types/lemur_base_response.rb +20 -11
  9. data/lib/assemblyai/lemur/types/lemur_question.rb +57 -31
  10. data/lib/assemblyai/lemur/types/lemur_question_answer.rb +28 -14
  11. data/lib/assemblyai/lemur/types/lemur_question_answer_response.rb +29 -14
  12. data/lib/assemblyai/lemur/types/lemur_question_context.rb +13 -6
  13. data/lib/assemblyai/lemur/types/lemur_summary_response.rb +28 -14
  14. data/lib/assemblyai/lemur/types/lemur_task_response.rb +28 -14
  15. data/lib/assemblyai/lemur/types/purge_lemur_request_data_response.rb +32 -17
  16. data/lib/assemblyai/realtime/client.rb +30 -14
  17. data/lib/assemblyai/realtime/types/configure_end_utterance_silence_threshold.rb +24 -13
  18. data/lib/assemblyai/realtime/types/final_transcript.rb +72 -41
  19. data/lib/assemblyai/realtime/types/force_end_utterance.rb +20 -11
  20. data/lib/assemblyai/realtime/types/message_type.rb +1 -0
  21. data/lib/assemblyai/realtime/types/partial_transcript.rb +62 -34
  22. data/lib/assemblyai/realtime/types/realtime_base_message.rb +22 -13
  23. data/lib/assemblyai/realtime/types/realtime_base_transcript.rb +57 -31
  24. data/lib/assemblyai/realtime/types/realtime_error.rb +20 -11
  25. data/lib/assemblyai/realtime/types/realtime_message.rb +44 -18
  26. data/lib/assemblyai/realtime/types/realtime_temporary_token_response.rb +20 -11
  27. data/lib/assemblyai/realtime/types/realtime_transcript.rb +15 -9
  28. data/lib/assemblyai/realtime/types/session_begins.rb +31 -14
  29. data/lib/assemblyai/realtime/types/session_information.rb +69 -0
  30. data/lib/assemblyai/realtime/types/session_terminated.rb +20 -11
  31. data/lib/assemblyai/realtime/types/terminate_session.rb +20 -11
  32. data/lib/assemblyai/realtime/types/word.rb +36 -18
  33. data/lib/assemblyai/streaming/types/receive_message.rb +113 -0
  34. data/lib/assemblyai/{realtime → streaming}/types/send_message.rb +26 -14
  35. data/lib/assemblyai/streaming/types/streaming.rb +11 -0
  36. data/lib/assemblyai/transcripts/client.rb +50 -18
  37. data/lib/assemblyai/transcripts/list_by_url_client.rb +6 -4
  38. data/lib/assemblyai/transcripts/polling_client.rb +12 -2
  39. data/lib/assemblyai/transcripts/types/auto_highlight_result.rb +40 -19
  40. data/lib/assemblyai/transcripts/types/auto_highlights_result.rb +38 -14
  41. data/lib/assemblyai/transcripts/types/chapter.rb +40 -20
  42. data/lib/assemblyai/transcripts/types/content_safety_label.rb +32 -16
  43. data/lib/assemblyai/transcripts/types/content_safety_label_result.rb +51 -29
  44. data/lib/assemblyai/transcripts/types/content_safety_labels_result.rb +51 -29
  45. data/lib/assemblyai/transcripts/types/entity.rb +41 -21
  46. data/lib/assemblyai/transcripts/types/page_details.rb +59 -33
  47. data/lib/assemblyai/transcripts/types/paragraphs_response.rb +37 -19
  48. data/lib/assemblyai/transcripts/types/redact_pii_audio_quality.rb +4 -1
  49. data/lib/assemblyai/transcripts/types/redacted_audio_response.rb +29 -15
  50. data/lib/assemblyai/transcripts/types/sentences_response.rb +37 -19
  51. data/lib/assemblyai/transcripts/types/sentiment_analysis_result.rb +62 -35
  52. data/lib/assemblyai/transcripts/types/severity_score_summary.rb +32 -16
  53. data/lib/assemblyai/transcripts/types/speech_model.rb +1 -0
  54. data/lib/assemblyai/transcripts/types/substitution_policy.rb +3 -1
  55. data/lib/assemblyai/transcripts/types/timestamp.rb +28 -14
  56. data/lib/assemblyai/transcripts/types/topic_detection_model_result.rb +39 -19
  57. data/lib/assemblyai/transcripts/types/topic_detection_result.rb +40 -21
  58. data/lib/assemblyai/transcripts/types/topic_detection_result_labels_item.rb +31 -15
  59. data/lib/assemblyai/transcripts/types/transcript.rb +512 -293
  60. data/lib/assemblyai/transcripts/types/transcript_custom_spelling.rb +30 -15
  61. data/lib/assemblyai/transcripts/types/transcript_language_code.rb +3 -2
  62. data/lib/assemblyai/transcripts/types/transcript_list.rb +33 -17
  63. data/lib/assemblyai/transcripts/types/transcript_list_item.rb +60 -34
  64. data/lib/assemblyai/transcripts/types/transcript_optional_params.rb +334 -191
  65. data/lib/assemblyai/transcripts/types/transcript_paragraph.rb +61 -33
  66. data/lib/assemblyai/transcripts/types/transcript_ready_notification.rb +30 -16
  67. data/lib/assemblyai/transcripts/types/transcript_sentence.rb +61 -33
  68. data/lib/assemblyai/transcripts/types/transcript_status.rb +2 -1
  69. data/lib/assemblyai/transcripts/types/transcript_utterance.rb +55 -31
  70. data/lib/assemblyai/transcripts/types/transcript_word.rb +55 -24
  71. data/lib/assemblyai/transcripts/types/word_search_match.rb +40 -20
  72. data/lib/assemblyai/transcripts/types/word_search_response.rb +36 -17
  73. data/lib/assemblyai/types/error.rb +32 -16
  74. data/lib/requests.rb +80 -34
  75. data/lib/types_export.rb +4 -3
  76. metadata +6 -5
  77. data/lib/assemblyai/realtime/types/audio_data.rb +0 -7
  78. data/lib/assemblyai/realtime/types/receive_message.rb +0 -87
@@ -1,49 +1,65 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "ostruct"
3
4
  require "json"
4
5
 
5
6
  module AssemblyAI
6
7
  class Transcripts
7
8
  class ContentSafetyLabel
8
- attr_reader :label, :confidence, :severity, :additional_properties
9
+ # @return [String] The label of the sensitive topic
10
+ attr_reader :label
11
+ # @return [Float] The confidence score for the topic being discussed, from 0 to 1
12
+ attr_reader :confidence
13
+ # @return [Float] How severely the topic is discussed in the section, from 0 to 1
14
+ attr_reader :severity
15
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
16
+ attr_reader :additional_properties
17
+ # @return [Object]
18
+ attr_reader :_field_set
19
+ protected :_field_set
20
+
21
+ OMIT = Object.new
9
22
 
10
23
  # @param label [String] The label of the sensitive topic
11
24
  # @param confidence [Float] The confidence score for the topic being discussed, from 0 to 1
12
25
  # @param severity [Float] How severely the topic is discussed in the section, from 0 to 1
13
26
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
14
- # @return [Transcripts::ContentSafetyLabel]
27
+ # @return [AssemblyAI::Transcripts::ContentSafetyLabel]
15
28
  def initialize(label:, confidence:, severity:, additional_properties: nil)
16
- # @type [String] The label of the sensitive topic
17
29
  @label = label
18
- # @type [Float] The confidence score for the topic being discussed, from 0 to 1
19
30
  @confidence = confidence
20
- # @type [Float] How severely the topic is discussed in the section, from 0 to 1
21
31
  @severity = severity
22
- # @type [OpenStruct] Additional properties unmapped to the current class definition
23
32
  @additional_properties = additional_properties
33
+ @_field_set = { "label": label, "confidence": confidence, "severity": severity }
24
34
  end
25
35
 
26
36
  # Deserialize a JSON object to an instance of ContentSafetyLabel
27
37
  #
28
- # @param json_object [JSON]
29
- # @return [Transcripts::ContentSafetyLabel]
38
+ # @param json_object [String]
39
+ # @return [AssemblyAI::Transcripts::ContentSafetyLabel]
30
40
  def self.from_json(json_object:)
31
41
  struct = JSON.parse(json_object, object_class: OpenStruct)
32
- JSON.parse(json_object)
33
- label = struct.label
34
- confidence = struct.confidence
35
- severity = struct.severity
36
- new(label: label, confidence: confidence, severity: severity, additional_properties: struct)
42
+ label = struct["label"]
43
+ confidence = struct["confidence"]
44
+ severity = struct["severity"]
45
+ new(
46
+ label: label,
47
+ confidence: confidence,
48
+ severity: severity,
49
+ additional_properties: struct
50
+ )
37
51
  end
38
52
 
39
53
  # Serialize an instance of ContentSafetyLabel to a JSON object
40
54
  #
41
- # @return [JSON]
55
+ # @return [String]
42
56
  def to_json(*_args)
43
- { "label": @label, "confidence": @confidence, "severity": @severity }.to_json
57
+ @_field_set&.to_json
44
58
  end
45
59
 
46
- # 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.
60
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
61
+ # hash and check each fields type against the current object's property
62
+ # definitions.
47
63
  #
48
64
  # @param obj [Object]
49
65
  # @return [Void]
@@ -2,73 +2,95 @@
2
2
 
3
3
  require_relative "content_safety_label"
4
4
  require_relative "timestamp"
5
+ require "ostruct"
5
6
  require "json"
6
7
 
7
8
  module AssemblyAI
8
9
  class Transcripts
9
10
  class ContentSafetyLabelResult
10
- attr_reader :text, :labels, :sentences_idx_start, :sentences_idx_end, :timestamp, :additional_properties
11
+ # @return [String] The transcript of the section flagged by the Content Moderation model
12
+ attr_reader :text
13
+ # @return [Array<AssemblyAI::Transcripts::ContentSafetyLabel>] An array of safety labels, one per sensitive topic that was detected in the
14
+ # section
15
+ attr_reader :labels
16
+ # @return [Integer] The sentence index at which the section begins
17
+ attr_reader :sentences_idx_start
18
+ # @return [Integer] The sentence index at which the section ends
19
+ attr_reader :sentences_idx_end
20
+ # @return [AssemblyAI::Transcripts::Timestamp] Timestamp information for the section
21
+ attr_reader :timestamp
22
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
23
+ attr_reader :additional_properties
24
+ # @return [Object]
25
+ attr_reader :_field_set
26
+ protected :_field_set
27
+
28
+ OMIT = Object.new
11
29
 
12
30
  # @param text [String] The transcript of the section flagged by the Content Moderation model
13
- # @param labels [Array<Transcripts::ContentSafetyLabel>] An array of safety labels, one per sensitive topic that was detected in the section
31
+ # @param labels [Array<AssemblyAI::Transcripts::ContentSafetyLabel>] An array of safety labels, one per sensitive topic that was detected in the
32
+ # section
14
33
  # @param sentences_idx_start [Integer] The sentence index at which the section begins
15
34
  # @param sentences_idx_end [Integer] The sentence index at which the section ends
16
- # @param timestamp [Transcripts::Timestamp] Timestamp information for the section
35
+ # @param timestamp [AssemblyAI::Transcripts::Timestamp] Timestamp information for the section
17
36
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
18
- # @return [Transcripts::ContentSafetyLabelResult]
37
+ # @return [AssemblyAI::Transcripts::ContentSafetyLabelResult]
19
38
  def initialize(text:, labels:, sentences_idx_start:, sentences_idx_end:, timestamp:, additional_properties: nil)
20
- # @type [String] The transcript of the section flagged by the Content Moderation model
21
39
  @text = text
22
- # @type [Array<Transcripts::ContentSafetyLabel>] An array of safety labels, one per sensitive topic that was detected in the section
23
40
  @labels = labels
24
- # @type [Integer] The sentence index at which the section begins
25
41
  @sentences_idx_start = sentences_idx_start
26
- # @type [Integer] The sentence index at which the section ends
27
42
  @sentences_idx_end = sentences_idx_end
28
- # @type [Transcripts::Timestamp] Timestamp information for the section
29
43
  @timestamp = timestamp
30
- # @type [OpenStruct] Additional properties unmapped to the current class definition
31
44
  @additional_properties = additional_properties
45
+ @_field_set = {
46
+ "text": text,
47
+ "labels": labels,
48
+ "sentences_idx_start": sentences_idx_start,
49
+ "sentences_idx_end": sentences_idx_end,
50
+ "timestamp": timestamp
51
+ }
32
52
  end
33
53
 
34
54
  # Deserialize a JSON object to an instance of ContentSafetyLabelResult
35
55
  #
36
- # @param json_object [JSON]
37
- # @return [Transcripts::ContentSafetyLabelResult]
56
+ # @param json_object [String]
57
+ # @return [AssemblyAI::Transcripts::ContentSafetyLabelResult]
38
58
  def self.from_json(json_object:)
39
59
  struct = JSON.parse(json_object, object_class: OpenStruct)
40
60
  parsed_json = JSON.parse(json_object)
41
- text = struct.text
61
+ text = struct["text"]
42
62
  labels = parsed_json["labels"]&.map do |v|
43
63
  v = v.to_json
44
- Transcripts::ContentSafetyLabel.from_json(json_object: v)
64
+ AssemblyAI::Transcripts::ContentSafetyLabel.from_json(json_object: v)
45
65
  end
46
- sentences_idx_start = struct.sentences_idx_start
47
- sentences_idx_end = struct.sentences_idx_end
66
+ sentences_idx_start = struct["sentences_idx_start"]
67
+ sentences_idx_end = struct["sentences_idx_end"]
48
68
  if parsed_json["timestamp"].nil?
49
69
  timestamp = nil
50
70
  else
51
71
  timestamp = parsed_json["timestamp"].to_json
52
- timestamp = Transcripts::Timestamp.from_json(json_object: timestamp)
72
+ timestamp = AssemblyAI::Transcripts::Timestamp.from_json(json_object: timestamp)
53
73
  end
54
- new(text: text, labels: labels, sentences_idx_start: sentences_idx_start, sentences_idx_end: sentences_idx_end,
55
- timestamp: timestamp, additional_properties: struct)
74
+ new(
75
+ text: text,
76
+ labels: labels,
77
+ sentences_idx_start: sentences_idx_start,
78
+ sentences_idx_end: sentences_idx_end,
79
+ timestamp: timestamp,
80
+ additional_properties: struct
81
+ )
56
82
  end
57
83
 
58
84
  # Serialize an instance of ContentSafetyLabelResult to a JSON object
59
85
  #
60
- # @return [JSON]
86
+ # @return [String]
61
87
  def to_json(*_args)
62
- {
63
- "text": @text,
64
- "labels": @labels,
65
- "sentences_idx_start": @sentences_idx_start,
66
- "sentences_idx_end": @sentences_idx_end,
67
- "timestamp": @timestamp
68
- }.to_json
88
+ @_field_set&.to_json
69
89
  end
70
90
 
71
- # 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.
91
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
92
+ # hash and check each fields type against the current object's property
93
+ # definitions.
72
94
  #
73
95
  # @param obj [Object]
74
96
  # @return [Void]
@@ -77,7 +99,7 @@ module AssemblyAI
77
99
  obj.labels.is_a?(Array) != false || raise("Passed value for field obj.labels is not the expected type, validation failed.")
78
100
  obj.sentences_idx_start.is_a?(Integer) != false || raise("Passed value for field obj.sentences_idx_start is not the expected type, validation failed.")
79
101
  obj.sentences_idx_end.is_a?(Integer) != false || raise("Passed value for field obj.sentences_idx_end is not the expected type, validation failed.")
80
- Transcripts::Timestamp.validate_raw(obj: obj.timestamp)
102
+ AssemblyAI::Transcripts::Timestamp.validate_raw(obj: obj.timestamp)
81
103
  end
82
104
  end
83
105
  end
@@ -2,73 +2,95 @@
2
2
 
3
3
  require_relative "audio_intelligence_model_status"
4
4
  require_relative "content_safety_label_result"
5
+ require "ostruct"
5
6
  require "json"
6
7
 
7
8
  module AssemblyAI
8
9
  class Transcripts
9
10
  # An array of results for the Content Moderation model, if it is enabled.
10
- # See [Content moderation](https://www.assemblyai.com/docs/models/content-moderation) for more information.
11
+ # See [Content
12
+ # moderation](https://www.assemblyai.com/docs/models/content-moderation) for more
13
+ # information.
11
14
  class ContentSafetyLabelsResult
12
- attr_reader :status, :results, :summary, :severity_score_summary, :additional_properties
15
+ # @return [AssemblyAI::Transcripts::AudioIntelligenceModelStatus] The status of the Content Moderation model. Either success, or unavailable in
16
+ # the rare case that the model failed.
17
+ attr_reader :status
18
+ # @return [Array<AssemblyAI::Transcripts::ContentSafetyLabelResult>]
19
+ attr_reader :results
20
+ # @return [Hash{String => Float}] A summary of the Content Moderation confidence results for the entire audio file
21
+ attr_reader :summary
22
+ # @return [Hash{String => AssemblyAI::Transcripts::SeverityScoreSummary}] A summary of the Content Moderation severity results for the entire audio file
23
+ attr_reader :severity_score_summary
24
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
25
+ attr_reader :additional_properties
26
+ # @return [Object]
27
+ attr_reader :_field_set
28
+ protected :_field_set
13
29
 
14
- # @param status [Transcripts::AudioIntelligenceModelStatus] The status of the Content Moderation model. Either success, or unavailable in the rare case that the model failed.
15
- # @param results [Array<Transcripts::ContentSafetyLabelResult>]
30
+ OMIT = Object.new
31
+
32
+ # @param status [AssemblyAI::Transcripts::AudioIntelligenceModelStatus] The status of the Content Moderation model. Either success, or unavailable in
33
+ # the rare case that the model failed.
34
+ # @param results [Array<AssemblyAI::Transcripts::ContentSafetyLabelResult>]
16
35
  # @param summary [Hash{String => Float}] A summary of the Content Moderation confidence results for the entire audio file
17
- # @param severity_score_summary [Hash{String => Transcripts::SeverityScoreSummary}] A summary of the Content Moderation severity results for the entire audio file
36
+ # @param severity_score_summary [Hash{String => AssemblyAI::Transcripts::SeverityScoreSummary}] A summary of the Content Moderation severity results for the entire audio file
18
37
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
19
- # @return [Transcripts::ContentSafetyLabelsResult]
38
+ # @return [AssemblyAI::Transcripts::ContentSafetyLabelsResult]
20
39
  def initialize(status:, results:, summary:, severity_score_summary:, additional_properties: nil)
21
- # @type [Transcripts::AudioIntelligenceModelStatus] The status of the Content Moderation model. Either success, or unavailable in the rare case that the model failed.
22
40
  @status = status
23
- # @type [Array<Transcripts::ContentSafetyLabelResult>]
24
41
  @results = results
25
- # @type [Hash{String => Float}] A summary of the Content Moderation confidence results for the entire audio file
26
42
  @summary = summary
27
- # @type [Hash{String => Transcripts::SeverityScoreSummary}] A summary of the Content Moderation severity results for the entire audio file
28
43
  @severity_score_summary = severity_score_summary
29
- # @type [OpenStruct] Additional properties unmapped to the current class definition
30
44
  @additional_properties = additional_properties
45
+ @_field_set = {
46
+ "status": status,
47
+ "results": results,
48
+ "summary": summary,
49
+ "severity_score_summary": severity_score_summary
50
+ }
31
51
  end
32
52
 
33
53
  # Deserialize a JSON object to an instance of ContentSafetyLabelsResult
34
54
  #
35
- # @param json_object [JSON]
36
- # @return [Transcripts::ContentSafetyLabelsResult]
55
+ # @param json_object [String]
56
+ # @return [AssemblyAI::Transcripts::ContentSafetyLabelsResult]
37
57
  def self.from_json(json_object:)
38
58
  struct = JSON.parse(json_object, object_class: OpenStruct)
39
59
  parsed_json = JSON.parse(json_object)
40
- status = struct.status
60
+ status = struct["status"]
41
61
  results = parsed_json["results"]&.map do |v|
42
62
  v = v.to_json
43
- Transcripts::ContentSafetyLabelResult.from_json(json_object: v)
63
+ AssemblyAI::Transcripts::ContentSafetyLabelResult.from_json(json_object: v)
44
64
  end
45
- summary = struct.summary
46
- severity_score_summary = parsed_json["severity_score_summary"]&.transform_values do |_k, v|
65
+ summary = struct["summary"]
66
+ severity_score_summary = parsed_json["severity_score_summary"]&.transform_values do |v|
47
67
  v = v.to_json
48
- Transcripts::SeverityScoreSummary.from_json(json_object: v)
68
+ AssemblyAI::Transcripts::SeverityScoreSummary.from_json(json_object: v)
49
69
  end
50
- new(status: status, results: results, summary: summary, severity_score_summary: severity_score_summary,
51
- additional_properties: struct)
70
+ new(
71
+ status: status,
72
+ results: results,
73
+ summary: summary,
74
+ severity_score_summary: severity_score_summary,
75
+ additional_properties: struct
76
+ )
52
77
  end
53
78
 
54
79
  # Serialize an instance of ContentSafetyLabelsResult to a JSON object
55
80
  #
56
- # @return [JSON]
81
+ # @return [String]
57
82
  def to_json(*_args)
58
- {
59
- "status": @status,
60
- "results": @results,
61
- "summary": @summary,
62
- "severity_score_summary": @severity_score_summary
63
- }.to_json
83
+ @_field_set&.to_json
64
84
  end
65
85
 
66
- # 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.
86
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
87
+ # hash and check each fields type against the current object's property
88
+ # definitions.
67
89
  #
68
90
  # @param obj [Object]
69
91
  # @return [Void]
70
92
  def self.validate_raw(obj:)
71
- obj.status.is_a?(Transcripts::AudioIntelligenceModelStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
93
+ obj.status.is_a?(AssemblyAI::Transcripts::AudioIntelligenceModelStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
72
94
  obj.results.is_a?(Array) != false || raise("Passed value for field obj.results is not the expected type, validation failed.")
73
95
  obj.summary.is_a?(Hash) != false || raise("Passed value for field obj.summary is not the expected type, validation failed.")
74
96
  obj.severity_score_summary.is_a?(Hash) != false || raise("Passed value for field obj.severity_score_summary is not the expected type, validation failed.")
@@ -1,60 +1,80 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "entity_type"
4
+ require "ostruct"
4
5
  require "json"
5
6
 
6
7
  module AssemblyAI
7
8
  class Transcripts
8
9
  # A detected entity
9
10
  class Entity
10
- attr_reader :entity_type, :text, :start, :end_, :additional_properties
11
+ # @return [AssemblyAI::Transcripts::EntityType] The type of entity for the detected entity
12
+ attr_reader :entity_type
13
+ # @return [String] The text for the detected entity
14
+ attr_reader :text
15
+ # @return [Integer] The starting time, in milliseconds, at which the detected entity appears in the
16
+ # audio file
17
+ attr_reader :start
18
+ # @return [Integer] The ending time, in milliseconds, for the detected entity in the audio file
19
+ attr_reader :end_
20
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
21
+ attr_reader :additional_properties
22
+ # @return [Object]
23
+ attr_reader :_field_set
24
+ protected :_field_set
11
25
 
12
- # @param entity_type [Transcripts::EntityType] The type of entity for the detected entity
26
+ OMIT = Object.new
27
+
28
+ # @param entity_type [AssemblyAI::Transcripts::EntityType] The type of entity for the detected entity
13
29
  # @param text [String] The text for the detected entity
14
- # @param start [Integer] The starting time, in milliseconds, at which the detected entity appears in the audio file
30
+ # @param start [Integer] The starting time, in milliseconds, at which the detected entity appears in the
31
+ # audio file
15
32
  # @param end_ [Integer] The ending time, in milliseconds, for the detected entity in the audio file
16
33
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
17
- # @return [Transcripts::Entity]
34
+ # @return [AssemblyAI::Transcripts::Entity]
18
35
  def initialize(entity_type:, text:, start:, end_:, additional_properties: nil)
19
- # @type [Transcripts::EntityType] The type of entity for the detected entity
20
36
  @entity_type = entity_type
21
- # @type [String] The text for the detected entity
22
37
  @text = text
23
- # @type [Integer] The starting time, in milliseconds, at which the detected entity appears in the audio file
24
38
  @start = start
25
- # @type [Integer] The ending time, in milliseconds, for the detected entity in the audio file
26
39
  @end_ = end_
27
- # @type [OpenStruct] Additional properties unmapped to the current class definition
28
40
  @additional_properties = additional_properties
41
+ @_field_set = { "entity_type": entity_type, "text": text, "start": start, "end": end_ }
29
42
  end
30
43
 
31
44
  # Deserialize a JSON object to an instance of Entity
32
45
  #
33
- # @param json_object [JSON]
34
- # @return [Transcripts::Entity]
46
+ # @param json_object [String]
47
+ # @return [AssemblyAI::Transcripts::Entity]
35
48
  def self.from_json(json_object:)
36
49
  struct = JSON.parse(json_object, object_class: OpenStruct)
37
- JSON.parse(json_object)
38
- entity_type = struct.entity_type
39
- text = struct.text
40
- start = struct.start
41
- end_ = struct.end
42
- new(entity_type: entity_type, text: text, start: start, end_: end_, additional_properties: struct)
50
+ entity_type = struct["entity_type"]
51
+ text = struct["text"]
52
+ start = struct["start"]
53
+ end_ = struct["end"]
54
+ new(
55
+ entity_type: entity_type,
56
+ text: text,
57
+ start: start,
58
+ end_: end_,
59
+ additional_properties: struct
60
+ )
43
61
  end
44
62
 
45
63
  # Serialize an instance of Entity to a JSON object
46
64
  #
47
- # @return [JSON]
65
+ # @return [String]
48
66
  def to_json(*_args)
49
- { "entity_type": @entity_type, "text": @text, "start": @start, "end": @end_ }.to_json
67
+ @_field_set&.to_json
50
68
  end
51
69
 
52
- # 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.
70
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
71
+ # hash and check each fields type against the current object's property
72
+ # definitions.
53
73
  #
54
74
  # @param obj [Object]
55
75
  # @return [Void]
56
76
  def self.validate_raw(obj:)
57
- obj.entity_type.is_a?(Transcripts::EntityType) != false || raise("Passed value for field obj.entity_type is not the expected type, validation failed.")
77
+ obj.entity_type.is_a?(AssemblyAI::Transcripts::EntityType) != false || raise("Passed value for field obj.entity_type is not the expected type, validation failed.")
58
78
  obj.text.is_a?(String) != false || raise("Passed value for field obj.text is not the expected type, validation failed.")
59
79
  obj.start.is_a?(Integer) != false || raise("Passed value for field obj.start is not the expected type, validation failed.")
60
80
  obj.end_.is_a?(Integer) != false || raise("Passed value for field obj.end_ is not the expected type, validation failed.")
@@ -1,65 +1,91 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "ostruct"
3
4
  require "json"
4
5
 
5
6
  module AssemblyAI
6
7
  class Transcripts
7
- # Details of the transcript page. Transcripts are sorted from newest to oldest. The previous URL always points to a page with older transcripts.
8
+ # Details of the transcript page. Transcripts are sorted from newest to oldest.
9
+ # The previous URL always points to a page with older transcripts.
8
10
  class PageDetails
9
- attr_reader :limit, :result_count, :current_url, :prev_url, :next_url, :additional_properties
11
+ # @return [Integer]
12
+ attr_reader :limit
13
+ # @return [Integer]
14
+ attr_reader :result_count
15
+ # @return [String]
16
+ attr_reader :current_url
17
+ # @return [String] The URL to the next page of transcripts. The previous URL always points to a
18
+ # page with older transcripts.
19
+ attr_reader :prev_url
20
+ # @return [String] The URL to the next page of transcripts. The next URL always points to a page
21
+ # with newer transcripts.
22
+ attr_reader :next_url
23
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
24
+ attr_reader :additional_properties
25
+ # @return [Object]
26
+ attr_reader :_field_set
27
+ protected :_field_set
28
+
29
+ OMIT = Object.new
10
30
 
11
31
  # @param limit [Integer]
12
32
  # @param result_count [Integer]
13
33
  # @param current_url [String]
14
- # @param prev_url [String] The URL to the next page of transcripts. The previous URL always points to a page with older transcripts.
15
- # @param next_url [String] The URL to the next page of transcripts. The next URL always points to a page with newer transcripts.
34
+ # @param prev_url [String] The URL to the next page of transcripts. The previous URL always points to a
35
+ # page with older transcripts.
36
+ # @param next_url [String] The URL to the next page of transcripts. The next URL always points to a page
37
+ # with newer transcripts.
16
38
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
17
- # @return [Transcripts::PageDetails]
18
- def initialize(limit:, result_count:, current_url:, prev_url: nil, next_url: nil, additional_properties: nil)
19
- # @type [Integer]
39
+ # @return [AssemblyAI::Transcripts::PageDetails]
40
+ def initialize(limit:, result_count:, current_url:, prev_url: OMIT, next_url: OMIT, additional_properties: nil)
20
41
  @limit = limit
21
- # @type [Integer]
22
42
  @result_count = result_count
23
- # @type [String]
24
43
  @current_url = current_url
25
- # @type [String] The URL to the next page of transcripts. The previous URL always points to a page with older transcripts.
26
- @prev_url = prev_url
27
- # @type [String] The URL to the next page of transcripts. The next URL always points to a page with newer transcripts.
28
- @next_url = next_url
29
- # @type [OpenStruct] Additional properties unmapped to the current class definition
44
+ @prev_url = prev_url if prev_url != OMIT
45
+ @next_url = next_url if next_url != OMIT
30
46
  @additional_properties = additional_properties
47
+ @_field_set = {
48
+ "limit": limit,
49
+ "result_count": result_count,
50
+ "current_url": current_url,
51
+ "prev_url": prev_url,
52
+ "next_url": next_url
53
+ }.reject do |_k, v|
54
+ v == OMIT
55
+ end
31
56
  end
32
57
 
33
58
  # Deserialize a JSON object to an instance of PageDetails
34
59
  #
35
- # @param json_object [JSON]
36
- # @return [Transcripts::PageDetails]
60
+ # @param json_object [String]
61
+ # @return [AssemblyAI::Transcripts::PageDetails]
37
62
  def self.from_json(json_object:)
38
63
  struct = JSON.parse(json_object, object_class: OpenStruct)
39
- JSON.parse(json_object)
40
- limit = struct.limit
41
- result_count = struct.result_count
42
- current_url = struct.current_url
43
- prev_url = struct.prev_url
44
- next_url = struct.next_url
45
- new(limit: limit, result_count: result_count, current_url: current_url, prev_url: prev_url, next_url: next_url,
46
- additional_properties: struct)
64
+ limit = struct["limit"]
65
+ result_count = struct["result_count"]
66
+ current_url = struct["current_url"]
67
+ prev_url = struct["prev_url"]
68
+ next_url = struct["next_url"]
69
+ new(
70
+ limit: limit,
71
+ result_count: result_count,
72
+ current_url: current_url,
73
+ prev_url: prev_url,
74
+ next_url: next_url,
75
+ additional_properties: struct
76
+ )
47
77
  end
48
78
 
49
79
  # Serialize an instance of PageDetails to a JSON object
50
80
  #
51
- # @return [JSON]
81
+ # @return [String]
52
82
  def to_json(*_args)
53
- {
54
- "limit": @limit,
55
- "result_count": @result_count,
56
- "current_url": @current_url,
57
- "prev_url": @prev_url,
58
- "next_url": @next_url
59
- }.to_json
83
+ @_field_set&.to_json
60
84
  end
61
85
 
62
- # 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.
86
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
87
+ # hash and check each fields type against the current object's property
88
+ # definitions.
63
89
  #
64
90
  # @param obj [Object]
65
91
  # @return [Void]