Module: VoiceBase::V2::Response

Defined in:
lib/voicebase/v2/response.rb

Constant Summary collapse

TRANSCRIPT_READY_STATUS =
"finished".freeze

Instance Method Summary collapse

Instance Method Details

#keyword_groupsObject



34
35
36
# File 'lib/voicebase/v2/response.rb', line 34

def keyword_groups
  voicebase_response['media']['keywords']['latest']['groups']
end

#keywordsObject



30
31
32
# File 'lib/voicebase/v2/response.rb', line 30

def keywords
  voicebase_response['media']['keywords']['latest']['words']
end

#media_idObject



16
17
18
# File 'lib/voicebase/v2/response.rb', line 16

def media_id
  voicebase_response['mediaId']
end

#success?Boolean

Returns:

  • (Boolean)


7
8
9
10
11
12
13
14
# File 'lib/voicebase/v2/response.rb', line 7

def success?

  # for the V1 API this indicates both a successful HTTP status code and a values of "SUCCESS" in the
  # returned JSON. with V2, there is no "SUCCESS" value. The combined use was split, adding
  # #transcript_ready? to both interfaces.

  ok?
end

#topicsObject



38
39
40
# File 'lib/voicebase/v2/response.rb', line 38

def topics
  voicebase_response['media']['topics']['latest']['topics']
end

#transcriptObject



24
25
26
27
28
# File 'lib/voicebase/v2/response.rb', line 24

def transcript
  # this retrieves the JSON transcript only
  # the plain text transcript is a plain text non-JSON response
  voicebase_response['media']['transcripts']['latest']['words']
end

#transcript_ready?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/voicebase/v2/response.rb', line 20

def transcript_ready?
  voicebase_response['media']['status'].casecmp(TRANSCRIPT_READY_STATUS) == 0
end