Class: Deepgram::Read::Response
- Inherits:
-
Object
- Object
- Deepgram::Read::Response
- Defined in:
- lib/deepgram/read.rb
Overview
The Response class encapsulates the response from the Deepgram Read API, providing methods to access various parts of the response data.
Instance Method Summary collapse
-
#initialize(status:, body:, headers:) ⇒ Response
constructor
Initializes a new Response object with the given status, body, and headers.
-
#intents ⇒ Array?
Extracts and returns the intents segments from the response data.
-
#metadata ⇒ Hash?
Extracts and returns the metadata from the response data.
-
#raw ⇒ Hash
Parses the response body as JSON and returns the raw data.
-
#sentiments ⇒ Array?
Extracts and returns the sentiments segments from the response data.
-
#summary ⇒ String?
Extracts and returns the summary text from the response data.
-
#topics ⇒ Array?
Extracts and returns the topics segments from the response data.
Constructor Details
#initialize(status:, body:, headers:) ⇒ Response
Initializes a new Response object with the given status, body, and headers.
44 45 46 47 48 |
# File 'lib/deepgram/read.rb', line 44 def initialize(status:, body:, headers:) @status = status @body = body @headers = headers end |
Instance Method Details
#intents ⇒ Array?
Extracts and returns the intents segments from the response data.
88 89 90 |
# File 'lib/deepgram/read.rb', line 88 def intents raw.dig('results', 'intents', 'segments') end |
#metadata ⇒ Hash?
Extracts and returns the metadata from the response data.
60 61 62 |
# File 'lib/deepgram/read.rb', line 60 def raw['metadata'] end |
#raw ⇒ Hash
Parses the response body as JSON and returns the raw data.
53 54 55 |
# File 'lib/deepgram/read.rb', line 53 def raw JSON.parse(@body) end |
#sentiments ⇒ Array?
Extracts and returns the sentiments segments from the response data.
81 82 83 |
# File 'lib/deepgram/read.rb', line 81 def sentiments raw.dig('results', 'sentiments', 'segments') end |
#summary ⇒ String?
Extracts and returns the summary text from the response data.
67 68 69 |
# File 'lib/deepgram/read.rb', line 67 def summary raw.dig('results', 'summary', 'text') end |
#topics ⇒ Array?
Extracts and returns the topics segments from the response data.
74 75 76 |
# File 'lib/deepgram/read.rb', line 74 def topics raw.dig('results', 'topics', 'segments') end |