Class: Deepgram::Speak::Response
- Inherits:
-
Object
- Object
- Deepgram::Speak::Response
- Defined in:
- lib/deepgram/speak.rb
Overview
The Response class encapsulates the response from the Deepgram Speak API, providing methods to access various parts of the response data.
Instance Method Summary collapse
-
#file ⇒ String
Returns the body of the response, which contains the speech file in asynchronous requests.
-
#initialize(status:, body:, headers:) ⇒ Response
constructor
Initializes a new Response object with the given status, body, and headers.
-
#raw ⇒ Hash
Parses the response body as JSON and returns the raw data.
-
#request_id ⇒ String?
Extracts and returns the request ID from the response data.
Constructor Details
#initialize(status:, body:, headers:) ⇒ Response
Initializes a new Response object with the given status, body, and headers.
62 63 64 65 66 |
# File 'lib/deepgram/speak.rb', line 62 def initialize(status:, body:, headers:) @status = status @body = body @headers = headers end |
Instance Method Details
#file ⇒ String
Returns the body of the response, which contains the speech file in asynchronous requests.
85 86 87 |
# File 'lib/deepgram/speak.rb', line 85 def file @body end |
#raw ⇒ Hash
Parses the response body as JSON and returns the raw data.
71 72 73 |
# File 'lib/deepgram/speak.rb', line 71 def raw JSON.parse(@body) end |
#request_id ⇒ String?
Extracts and returns the request ID from the response data.
78 79 80 |
# File 'lib/deepgram/speak.rb', line 78 def request_id raw['request_id'] end |