Class: Rev::Input

Inherits:
ApiSerializable show all
Defined in:
lib/rev-api/models/order_request.rb

Overview

Input for order (aka source file)

Constant Summary collapse

SUPPORTED_ACCENTS =
{
  :american_neutral => 'AmericanNeutral',
  :american_southern => 'AmericanSouthern',
  :asian => 'Asian',
  :australian => 'Australian',
  :british => 'British',
  :indian => 'Indian',
  :other => 'Other',
  :unknown => 'Unknown'
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ApiSerializable

#initialize, #to_hash, #to_json

Constructor Details

This class inherits a constructor from Rev::ApiSerializable

Instance Attribute Details

#accentsObject (readonly)

Optional, list of accents.



221
222
223
# File 'lib/rev-api/models/order_request.rb', line 221

def accents
  @accents
end

#audio_length_secondsObject (readonly)

Length of audio in seconds (mandatory in case of inability to determine it automatically). Used within OrderRequest::TranscriptionInfo



201
202
203
# File 'lib/rev-api/models/order_request.rb', line 201

def audio_length_seconds
  @audio_length_seconds
end

External URL, if sources wasn’t POSTed as input (YouTube, Vimeo, Dropbox, etc)



212
213
214
# File 'lib/rev-api/models/order_request.rb', line 212

def external_link
  @external_link
end

#glossaryObject (readonly)

Optional, list of glossary entries.



215
216
217
# File 'lib/rev-api/models/order_request.rb', line 215

def glossary
  @glossary
end

#speakersObject (readonly)

Optional, list of speaker names.



218
219
220
# File 'lib/rev-api/models/order_request.rb', line 218

def speakers
  @speakers
end

#uriObject (readonly)

Mandatory, URI of the media, as returned from the call to POST /inputs. :external_link might substitute :uri for Transcription or Caption.



209
210
211
# File 'lib/rev-api/models/order_request.rb', line 209

def uri
  @uri
end

#video_length_secondsObject (readonly)

Length of video in seconds (mandatory in case of inability to determine it automatically). Used within OrderRequest::CaptionInfo



205
206
207
# File 'lib/rev-api/models/order_request.rb', line 205

def video_length_seconds
  @video_length_seconds
end

Instance Method Details

#validate_accentsObject



260
261
262
263
264
265
266
267
268
269
# File 'lib/rev-api/models/order_request.rb', line 260

def validate_accents
  if accents
    if accents.length > SUPPORTED_ACCENTS.length
      raise(ArgumentError, "Length of accents list cannot exceed number of supported accents.")
    end
    if accents.any?{ |accent| !Rev::Input::SUPPORTED_ACCENTS.has_value?(accent) }
      raise(ArgumentError, 'Unsupported accent provided')
    end
  end
end

#validate_glossaryObject



234
235
236
237
238
239
240
241
242
243
244
245
# File 'lib/rev-api/models/order_request.rb', line 234

def validate_glossary
  if glossary
    if glossary.length > GLOSSARY_ENTRIES_LIMIT
      raise(ArgumentError, "Glossary must not exceed #{GLOSSARY_ENTRIES_LIMIT} entries")
    end
    glossary.each { |term|
      if term.length > GLOSSARY_ENTRY_LENGTH_LIMIT
        raise(ArgumentError, "Glossary entries cannot exceed #{GLOSSARY_ENTRY_LENGTH_LIMIT} characters")
      end
    }
  end
end

#validate_speakersObject



247
248
249
250
251
252
253
254
255
256
257
258
# File 'lib/rev-api/models/order_request.rb', line 247

def validate_speakers
  if speakers
    if speakers.length > SPEAKER_ENTRIES_LIMIT
      raise(ArgumentError, "Speaker list must not exceed #{SPEAKER_ENTRIES_LIMIT} entries")
    end
    speakers.each { |speaker|
      if speaker.length > SPEAKER_ENTRY_LENGTH_LIMIT
        raise(ArgumentError, "Speaker name cannot exceed #{SPEAKER_ENTRY_LENGTH_LIMIT} characters")
      end
    }
  end
end