Class: Deepgram::Read::Response

Inherits:
Object
  • Object
show all
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

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

#intentsArray?

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

#metadataHash?

Extracts and returns the metadata from the response data.



60
61
62
# File 'lib/deepgram/read.rb', line 60

def 
  raw['metadata']
end

#rawHash

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

#sentimentsArray?

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

#summaryString?

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

#topicsArray?

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