rev-api 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: eaa50b9d9b8d001373ae19d4ae4e399ab21cb2e5
4
+ data.tar.gz: 8cb9bda20cd2cfca393614398dcc668ba1b6ebe2
5
+ SHA512:
6
+ metadata.gz: 9bb0071290cbab2b0ba7000fe4465efc839d47af99ed4d9de0c18de23557563924d6a1d4b71e7f14266d39996fbac7edc50a32048472e9ed3a9694d23258843c
7
+ data.tar.gz: 24dd6b5479d6287d7886299e1ce5b770048f85f95eda4a885324a8168972515035641a7e4417ccfb45889a200963a46636a80f54e9865e747acbbebb09c18406
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rev-api (1.0.2)
5
- httparty (>= 0.11.0)
4
+ rev-api (1.0.4)
5
+ httparty (~> 0.11, >= 0.11.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
@@ -17,9 +17,10 @@ GEM
17
17
  thor
18
18
  crack (0.4.1)
19
19
  safe_yaml (~> 0.9.0)
20
- httparty (0.11.0)
21
- multi_json (~> 1.0)
20
+ httparty (0.13.1)
21
+ json (~> 1.8)
22
22
  multi_xml (>= 0.5.2)
23
+ json (1.8.1)
23
24
  mime-types (1.25)
24
25
  multi_json (1.8.0)
25
26
  multi_xml (0.5.5)
@@ -50,11 +51,11 @@ PLATFORMS
50
51
 
51
52
  DEPENDENCIES
52
53
  coveralls
53
- rake (>= 10.1.0)
54
+ rake (~> 10.1, >= 10.1.0)
54
55
  redcarpet
55
56
  rev-api!
56
- rubygems-tasks
57
- turn (~> 0.9.6)
58
- vcr (~> 2.6.0)
59
- webmock (~> 1.11.0)
60
- yard
57
+ rubygems-tasks (~> 0)
58
+ turn (~> 0.9.6, ~> 0.9)
59
+ vcr (~> 2.6.0, ~> 2.6)
60
+ webmock (~> 1.11.0, ~> 1.11)
61
+ yard (~> 0)
data/Rakefile CHANGED
@@ -3,7 +3,7 @@ require 'yard'
3
3
  require 'rubygems/tasks'
4
4
 
5
5
  Rake::TestTask.new do |t|
6
- t.test_files = FileList['spec/lib/rev/*_spec.rb']
6
+ t.test_files = FileList['spec/lib/rev/**/*_spec.rb']
7
7
  t.verbose = true
8
8
  end
9
9
 
data/examples/cli.rb CHANGED
@@ -11,7 +11,7 @@ require 'pp'
11
11
  # ruby examples/cli.rb --sandbox --client-key your_client_key --user-key your_user_key
12
12
 
13
13
  class RevCLI
14
- COMMANDS = %w{help get list transcripts dl_transcripts dl_sources place cancel}
14
+ COMMANDS = %w{help get list transcripts captions dl_transcripts dl_captions dl_sources place_tc place_cp cancel}
15
15
 
16
16
  def initialize
17
17
  options = { :environment => Rev::Api::PRODUCTION_HOST, :verbatim => false, :timestamps => false }
@@ -115,6 +115,27 @@ class RevCLI
115
115
  end
116
116
  end
117
117
 
118
+ def captions(args)
119
+ begin
120
+ order_num = args[0]
121
+ order = @rev_client.get_order order_num
122
+
123
+ if order.captions.empty?
124
+ puts "There are no captions for order #{order_num}"
125
+ return
126
+ end
127
+
128
+ order.captions.each do |t|
129
+ puts "Contents of #{t.name}"
130
+ puts "-----------------------------------"
131
+ puts @rev_client.get_attachment_content(t.id).body
132
+ puts
133
+ end
134
+ rescue Rev::BadRequestError => e
135
+ puts "Displaying captions failed with error code #{e.code}, message #{e.message}"
136
+ end
137
+ end
138
+
118
139
  def dl_transcripts(args)
119
140
  begin
120
141
  order_num = args[0]
@@ -135,6 +156,26 @@ class RevCLI
135
156
  end
136
157
  end
137
158
 
159
+ def dl_captions(args)
160
+ begin
161
+ order_num = args[0]
162
+ order = @rev_client.get_order order_num
163
+
164
+ if order.captions.empty?
165
+ puts "There are no captions for order #{order_num}"
166
+ return
167
+ end
168
+
169
+ filenames = order.captions.map { |t| t.name}.join(',')
170
+ puts "Downloading files: #{filenames}"
171
+ order.captions.each do |t|
172
+ @rev_client.save_attachment_content t.id, t.name
173
+ end
174
+ rescue Rev::BadRequestError => e
175
+ puts "Downloading captions failed with error code #{e.code}, message #{e.message}"
176
+ end
177
+ end
178
+
138
179
  def dl_sources(args)
139
180
  begin
140
181
  order_num = args[0]
@@ -165,24 +206,37 @@ class RevCLI
165
206
  end
166
207
  end
167
208
 
168
- def place(args)
209
+ def place_tc(args)
210
+ inputs = upload(args, 'audio/mpeg')
211
+ tc_options = Rev::TranscriptionOptions.new(inputs)
212
+ place_helper(inputs, { :transcription_options => tc_options })
213
+ end
214
+
215
+ def place_cp(args)
216
+ inputs = upload(args, 'video/mpeg')
217
+ cp_options = Rev::CaptionOptions.new(inputs, {:output_file_formats => [Rev::CaptionOptions::OUTPUT_FILE_FORMATS[:scc]] })
218
+ place_helper(inputs, { :caption_options => cp_options })
219
+ end
220
+
221
+ def help(*args)
222
+ puts "commands are: #{COMMANDS.join(' ')} help exit"
223
+ end
224
+
225
+ private
226
+
227
+ def upload(args, type)
169
228
  input_urls = args.map do |f|
170
229
  puts "Uploading #{f}"
171
- @rev_client.upload_input(f, 'audio/mpeg')
230
+ @rev_client.upload_input(f, type)
172
231
  end
173
-
232
+ input_urls.map { |url| Rev::Input.new(:uri => url, :audio_length => 3) }
233
+ end
234
+
235
+ def place_helper(inputs, options)
174
236
  payment = Rev::Payment.with_credit_card_on_file
175
- inputs = input_urls.map { |url| Rev::Input.new(:uri => url, :audio_length => 3) }
176
- tc_options = Rev::TranscriptionOptions.new(inputs)
237
+ options = options.merge({ :payment => payment, :client_ref => 'XB432423', :comment => 'Please work quickly' })
238
+ request = Rev::OrderRequest.new(payment, options)
177
239
 
178
- request = Rev::OrderRequest.new(
179
- payment,
180
- :transcription_options => tc_options,
181
- :client_ref => 'XB432423',
182
- :comment => 'Please work quickly'
183
- )
184
-
185
- # act!
186
240
  begin
187
241
  new_order = @rev_client.submit_order(request)
188
242
  puts "New order: #{new_order}"
@@ -190,10 +244,7 @@ class RevCLI
190
244
  puts "Order placement failed with error code #{e.code}, message #{e.message}"
191
245
  end
192
246
  end
193
-
194
- def help(*args)
195
- puts "commands are: #{COMMANDS.join(' ')} help exit"
196
- end
247
+
197
248
  end
198
249
 
199
250
  cli = RevCLI.new
@@ -53,8 +53,11 @@ module Rev
53
53
  # 10006 Input Location is not specified - neither of External Link and URI set for input media
54
54
  EXTERNAL_LINK_OR_URI_NOT_SPECIFIED = 10006
55
55
 
56
- # 20001 Invalid Audio Length - If one of the input medias has a specified length that is not a positive integer
57
- INVALID_AUDIO_LENGTH = 20001
56
+ # 20001 Invalid Media Length - If one of the input medias has a specified length that is not a positive integer
57
+ INVALID_MEDIA_LENGTH = 20001
58
+
59
+ # @deprecated Use {#OrderRequestErrorCodes.INVALID_MEDIA_LENGTH} instead
60
+ INVALID_AUDIO_LENGTH = INVALID_MEDIA_LENGTH
58
61
 
59
62
  # 20002 Invalid Word Count - word counts for translation are missing or inaccurate
60
63
  INVALID_WORD_COUNT = 20002
@@ -1,14 +1,14 @@
1
1
  require 'rev-api/api_serializable'
2
2
 
3
3
  module Rev
4
- # Represents Translation or Transcription order.
5
- # Should have TranslationInfo or TranscriptionInfo, list
4
+ # Represents Translation, Caption, or Transcription order.
5
+ # Should have TranslationInfo, CaptionInfo, or TranscriptionInfo, list
6
6
  # of comments and attachments. Attributes names reflect
7
7
  # API exposed names, but occasional hyphens are replaced
8
8
  # with underscores
9
9
  class Order < ApiSerializable
10
10
  attr_reader :order_number, :price, :status, :attachments, :comments,
11
- :translation, :transcription, :client_ref
11
+ :translation, :transcription, :caption, :client_ref
12
12
 
13
13
  # @param fields [Hash] hash of order fields parsed from JSON API response
14
14
  def initialize(fields)
@@ -17,6 +17,7 @@ module Rev
17
17
  @comments = fields['comments'].map { |comment_fields| Comment.new(comment_fields) }
18
18
  @translation = TranslationInfo.new(fields['translation']) if fields['translation']
19
19
  @transcription = TranscriptionInfo.new(fields['transcription']) if fields['transcription']
20
+ @caption = CaptionInfo.new(fields['caption']) if fields['caption']
20
21
  end
21
22
 
22
23
  # @return [Array of Attachment] with the kind of "transcript"
@@ -29,6 +30,11 @@ module Rev
29
30
  @attachments.select { |a| a.kind == Attachment::KINDS[:translation]}
30
31
  end
31
32
 
33
+ # @return [Array of Attachment] with the kind of "caption"
34
+ def captions
35
+ @attachments.select { |a| a.kind == Attachment::KINDS[:caption] }
36
+ end
37
+
32
38
  # @return [Array of Attachment] with the kind of "sources"
33
39
  def sources
34
40
  @attachments.select { |a| a.kind == Attachment::KINDS[:media]}
@@ -61,6 +67,11 @@ module Rev
61
67
  class TranscriptionInfo < ApiSerializable
62
68
  attr_reader :total_length, :verbatim, :timestamps
63
69
  end
70
+
71
+ # Additional information specific to caption orders
72
+ class CaptionInfo < ApiSerializable
73
+ attr_reader :total_length
74
+ end
64
75
 
65
76
  # Represents order attachment - logical document associated with order
66
77
  class Attachment < ApiSerializable
@@ -69,17 +80,25 @@ module Rev
69
80
  KINDS = {
70
81
  :transcript => 'transcript',
71
82
  :translation => 'translation',
83
+ :caption => 'caption',
72
84
  :media => 'media'
73
85
  }
74
86
 
75
87
  # List of supported mime-types used to request attachment's content
76
88
  # within 'Accept' header
77
89
  REPRESENTATIONS = {
90
+ # Supported by :transcript and :translation
78
91
  :docx => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
79
92
  :doc => 'application/msword',
80
93
  :pdf => 'application/pdf',
81
94
  :txt => 'text/plain',
82
- :youtube => 'text/plain; format=youtube-transcript'
95
+ :youtube => 'text/plain; format=youtube-transcript',
96
+
97
+ # Supported by :caption
98
+ :srt => 'application/x-subrip',
99
+ :scc => 'text/x-scc',
100
+ :ttml => 'application/ttml+xml',
101
+ :qt => 'application/x-quicktime-timedtext'
83
102
  }
84
103
 
85
104
  # @param fields [Hash] fields of attachment fields parsed from JSON API response
@@ -3,9 +3,9 @@ require 'rev-api/api_serializable'
3
3
  module Rev
4
4
  # OrderRequest is used for constructing order 'spec' in consumer code and passing it into.
5
5
  # It consists of three main elements: :payment, :transcription_options and :notification.
6
- # You can also supply reference number and customer comment
6
+ # You can also supply priority, reference number, and customer comment
7
7
  #
8
- # @note http://www.rev.com/api/ordersposttranscription, http://www.rev.com/api/ordersposttranslation
8
+ # @note http://www.rev.com/api/ordersposttranscription, http://www.rev.com/api/ordersposttranslation, http://www.rev.com/api/orderspostcaption
9
9
  class OrderRequest < ApiSerializable
10
10
  # see {Rev::Payment}
11
11
  attr_reader :payment
@@ -15,6 +15,9 @@ module Rev
15
15
 
16
16
  # see {Rev::TranslationOptions}
17
17
  attr_reader :translation_options
18
+
19
+ # see {Rev::CaptionOptions}
20
+ attr_reader :caption_options
18
21
 
19
22
  # see {Rev::Notification}
20
23
  attr_reader :notification
@@ -24,10 +27,20 @@ module Rev
24
27
 
25
28
  # a comment with any special messages about the order (optional)
26
29
  attr_reader :comment
30
+
31
+ # a requested priority for the order, defaults to normal (optional)
32
+ attr_reader :priority
33
+
34
+ # use to correctly set priority
35
+ PRIORITY = {
36
+ :normal => 'Normal',
37
+ :time_insensitivie => 'TimeInsensitivie'
38
+ }
27
39
 
28
40
  # @param payment [Payment] payment info
29
41
  # @param fields [Hash] of fields to initialize instance. See instance attributes for available fields.
30
42
  def initialize(payment, fields = {})
43
+ fields = { :priority => PRIORITY[:normal] }.merge(fields)
31
44
  super fields
32
45
  @payment = payment
33
46
  end
@@ -84,23 +97,30 @@ module Rev
84
97
  attr_reader :number, :expiration_month, :expiration_year, :cardholder, :billing_address, :saved_id
85
98
  end
86
99
 
87
- # Transcription options. This section contains the input media that must be transferred to our servers
88
- # using a POST to /inputs, and are referenced using the URIs returned by that call. We also support external links.
89
- # Following points explain usage of inputs:
90
- # - For each input, you must provide either uri or external_link, but not both. If both or neither is provided,
91
- # error is returned.
92
- # - You should only provide an external_link if it links to page where the media can be found, rather than directly to
93
- # the media file, and that we will not attempt to do anything with the link when the API call is made.
94
- # This is in contrast to when you post to /inputs with a link to a media file - in that case we do download the file.
95
- # So the external_link should only be used when you can't link to the media file directly.
96
- # - The external_link can contain anything you want, but if it's a YouTube link, we will attempt to determine the
97
- # duration of the video on that page.
98
- # We also allow users of the api to specify if translation should be done using our Verbatim option (:verbatim => true)
99
- # and to specify if Time stamps should be included (:timestamps => true).
100
- class TranscriptionOptions < ApiSerializable
101
- # Mandatory, contains list of media to transcribe. Must have at least one element.
100
+ # Superclass for the business-line options that handles capture and common validation of inputs.
101
+ class InputOptions < ApiSerializable
102
+ # Mandatory, contains list of inputs. Must have at least one element.
102
103
  attr_reader :inputs
103
104
 
105
+ # @param inputs [Array] list of inputs
106
+ # @param info [Hash] of fields to initialize instance.
107
+ def initialize(inputs, info = {})
108
+ super info
109
+ raise(ArgumentError, "inputs must have at least one element") unless validate_inputs(inputs)
110
+ @inputs = inputs
111
+ end
112
+
113
+ private
114
+
115
+ def validate_inputs(inputs)
116
+ !inputs.nil? && inputs.length > 0
117
+ end
118
+ end
119
+
120
+ # Transcription options. This section contains the input media that must be transferred to our servers
121
+ # using a POST to /inputs, and are referenced using the URIs returned by that call. We also support external links.
122
+ # @see http://www.rev.com/api/ordersposttranscription
123
+ class TranscriptionOptions < InputOptions
104
124
  # Optional, should we transcribe the provided files verbatim? If true,
105
125
  # all filler words (i.e. umm, huh) will be included.
106
126
  attr_reader :verbatim
@@ -113,8 +133,7 @@ module Rev
113
133
  # - :verbatim => true/false
114
134
  # - :timestams => true/false
115
135
  def initialize(inputs, info = {})
116
- super info
117
- @inputs = inputs
136
+ super inputs, info
118
137
  end
119
138
  end
120
139
 
@@ -122,10 +141,8 @@ module Rev
122
141
  # servers using a POST to /inputs, and are referenced using the URIs returned by that call.
123
142
  # For each media, word count must be specified. The language code for the source and desitination
124
143
  # languages must also be specified.
125
- class TranslationOptions < ApiSerializable
126
- # Mandatory, contains list of media to transcribe. Must have at least one element.
127
- attr_reader :inputs
128
-
144
+ # @see http://www.rev.com/api/ordersposttranslation
145
+ class TranslationOptions < InputOptions
129
146
  # Mandatory, source language code
130
147
  attr_reader :source_language_code
131
148
 
@@ -138,8 +155,34 @@ module Rev
138
155
  # - :destination_language_code
139
156
  # @note For language codes refer to http://www.loc.gov/standards/iso639-2/php/code_list.php
140
157
  def initialize(inputs, info = {})
141
- super(info)
142
- @inputs = inputs
158
+ super inputs, info
159
+ end
160
+ end
161
+
162
+ # Caption options. This section contains the input media that must be transferred to our servers
163
+ # using a POST to /inputs, and are referenced using the URIs returned by that call. We also support external links.
164
+ # @see http://www.rev.com/api/orderspostcaption
165
+ class CaptionOptions < InputOptions
166
+ # Array of file formats the captions should be delivered as. (Optional, default is SubRip)
167
+ attr_reader :output_file_formats
168
+
169
+ # All supported output file formats
170
+ OUTPUT_FILE_FORMATS = {
171
+ :subrip => 'SubRip',
172
+ :scc => 'Scc',
173
+ :ttml => 'Ttml',
174
+ :qttext => 'QTtext'
175
+ }
176
+
177
+ def initialize(inputs, info = {})
178
+ super(inputs, info)
179
+ raise(ArgumentError, "invalid format(s)") unless validate_output_formats(info[:output_file_formats])
180
+ end
181
+
182
+ private
183
+
184
+ def validate_output_formats(formats)
185
+ formats.nil? || formats.select{|f| !OUTPUT_FILE_FORMATS.has_value?(f) }.empty?
143
186
  end
144
187
  end
145
188
 
@@ -149,11 +192,11 @@ module Rev
149
192
  attr_reader :word_length
150
193
 
151
194
  # Length of audio, in minutes (mandatory in case of inability to determine it automatically).
152
- # Used within {Rev::OrderRequest::TranscriptionInfo}
195
+ # Used within {Rev::OrderRequest::TranscriptionInfo} and {Rev::OrderRequest::CaptionInfo}
153
196
  attr_reader :audio_length
154
197
 
155
198
  # Mandatory, URI of the media, as returned from the call to POST /inputs.
156
- # :external_link might substitute :uri for Transcription.
199
+ # :external_link might substitute :uri for Transcription or Caption.
157
200
  attr_reader :uri
158
201
 
159
202
  # External URL, if sources wasn't POSTed as input (YouTube, Vimeo, Dropbox, etc)
@@ -1,3 +1,3 @@
1
1
  module Rev
2
- VERSION = '1.0.3'
2
+ VERSION = '1.0.4'
3
3
  end
data/rev-api.gemspec CHANGED
@@ -19,15 +19,15 @@ Gem::Specification.new do |s|
19
19
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
20
  s.require_paths = [ "lib", "spec" ]
21
21
 
22
- s.add_runtime_dependency('httparty', '>= 0.11.0')
22
+ s.add_runtime_dependency('httparty', '~> 0.11', '>= 0.11.0')
23
23
 
24
- s.add_development_dependency('webmock', '~> 1.11.0')
25
- s.add_development_dependency('vcr', '~> 2.6.0')
26
- s.add_development_dependency('turn', '~> 0.9.6')
27
- s.add_development_dependency('rake', '>= 10.1.0')
28
- s.add_development_dependency('yard')
24
+ s.add_development_dependency('webmock', '~> 1.11', '~> 1.11.0')
25
+ s.add_development_dependency('vcr', '~> 2.6', '~> 2.6.0')
26
+ s.add_development_dependency('turn', '~> 0.9', '~> 0.9.6')
27
+ s.add_development_dependency('rake', '~> 10.1', '>= 10.1.0')
28
+ s.add_development_dependency('yard', '~> 0')
29
29
  s.add_development_dependency('redcarpet')
30
- s.add_development_dependency('rubygems-tasks')
30
+ s.add_development_dependency('rubygems-tasks', '~> 0')
31
31
 
32
32
  s.has_rdoc = 'yard'
33
33
  end
@@ -0,0 +1,45 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://www.revtrunk.com/api/v1/orders
6
+ body:
7
+ encoding: UTF-8
8
+ string: ! '{"payment":{"type":"AccountBalance","credit_card":null},"caption_options":{"inputs":[{"external_link":"http://www.youtube.com/watch?v=UF8uR6Z6KLc"},{"audio_length":15,"external_link":"https://vimeo.com/7976699"}],"output_file_formats":["SubRip"]},"client_ref":"XB432423","comment":"Please
9
+ work quickly"}'
10
+ headers:
11
+ Content-Type:
12
+ - application/json
13
+ Authorization:
14
+ - Rev welcome:AAAAAu/YjZ3phXU5FsF35yIcgiA=
15
+ User-Agent:
16
+ - RevOfficialRubySDK/1.0.0
17
+ response:
18
+ status:
19
+ code: 201
20
+ message: Created
21
+ headers:
22
+ Cache-Control:
23
+ - no-cache
24
+ Pragma:
25
+ - no-cache
26
+ Expires:
27
+ - '-1'
28
+ Location:
29
+ - https://www.revtrunk.com/api/v1/orders/CP12345
30
+ Server:
31
+ - Microsoft-IIS/7.5
32
+ X-Miniprofiler-Ids:
33
+ - ! '["43bcb320-a1c9-4e9f-96c1-320e01a31549","ad8a37cd-e5ea-4134-ac9e-0390f722d6f6"]'
34
+ X-Powered-By:
35
+ - ASP.NET
36
+ Date:
37
+ - Wed, 18 Sep 2013 00:21:27 GMT
38
+ Content-Length:
39
+ - '0'
40
+ body:
41
+ encoding: US-ASCII
42
+ string: ''
43
+ http_version:
44
+ recorded_at: Wed, 18 Sep 2013 00:21:27 GMT
45
+ recorded_with: VCR 2.5.0
@@ -0,0 +1,8 @@
1
+ require_relative '../../spec_helper'
2
+
3
+ describe 'Exceptions' do
4
+ it 'has INVALID_MEDIA_LENGTH' do
5
+ Rev::OrderRequestErrorCodes::INVALID_MEDIA_LENGTH.must_equal Rev::OrderRequestErrorCodes::INVALID_AUDIO_LENGTH
6
+ end
7
+ end
8
+
@@ -0,0 +1,93 @@
1
+ require_relative '../../../spec_helper'
2
+
3
+ describe 'OrderRequest' do
4
+
5
+ it 'has normal priority' do
6
+ Rev::OrderRequest::PRIORITY[:normal].must_equal 'Normal'
7
+ end
8
+
9
+ it 'has time insensitivie priority' do
10
+ Rev::OrderRequest::PRIORITY[:time_insensitivie].must_equal 'TimeInsensitivie'
11
+ end
12
+
13
+ it 'defaults to normal priority' do
14
+ order = Rev::OrderRequest.new(Rev::Payment.with_credit_card_on_file, {})
15
+ order.priority.must_equal Rev::OrderRequest::PRIORITY[:normal]
16
+ end
17
+
18
+ it 'accepts priority during init' do
19
+ priority = Rev::OrderRequest::PRIORITY[:time_insensitivie]
20
+ order = Rev::OrderRequest.new(Rev::Payment.with_credit_card_on_file, { 'priority' => priority })
21
+ order.priority.must_equal priority
22
+ end
23
+
24
+ it 'has caption options' do
25
+ order = Rev::OrderRequest.new(Rev::Payment.with_credit_card_on_file, {})
26
+ order.must_respond_to :caption_options
27
+ end
28
+
29
+ describe 'InputOptions' do
30
+ it 'is ApiSerializable' do
31
+ options = Rev::InputOptions.new([{}], {})
32
+ options.must_be_kind_of Rev::ApiSerializable
33
+ end
34
+
35
+ it 'requires non-empty inputs' do
36
+ proc { Rev::InputOptions.new([]) }.must_raise ArgumentError
37
+ end
38
+
39
+ it 'requires non-nil inputs' do
40
+ proc { Rev::InputOptions.new(nil) }.must_raise ArgumentError
41
+ end
42
+
43
+ it 'sets inputs from init' do
44
+ inputs = ['foo']
45
+ options = Rev::InputOptions.new(inputs)
46
+ options.inputs.must_equal inputs
47
+ end
48
+ end
49
+
50
+ describe 'TranscriptionOptions' do
51
+ it 'is InputOptions' do
52
+ options = Rev::TranscriptionOptions.new([{}], {})
53
+ options.must_be_kind_of Rev::InputOptions
54
+ end
55
+ end
56
+
57
+ describe 'TranslationOptions' do
58
+ it 'is InputOptions' do
59
+ options = Rev::TranslationOptions.new([{}], {})
60
+ options.must_be_kind_of Rev::InputOptions
61
+ end
62
+ end
63
+
64
+ describe 'CaptionOptions' do
65
+ it 'is InputOptions' do
66
+ options = Rev::CaptionOptions.new([{}], {})
67
+ options.must_be_kind_of Rev::InputOptions
68
+ end
69
+
70
+ it 'has output file formats attribute' do
71
+ options = Rev::CaptionOptions.new([{}], {})
72
+ options.must_respond_to :output_file_formats
73
+ end
74
+
75
+ it 'has output file formats hash' do
76
+ Rev::CaptionOptions::OUTPUT_FILE_FORMATS[:subrip].must_equal 'SubRip'
77
+ Rev::CaptionOptions::OUTPUT_FILE_FORMATS[:scc].must_equal 'Scc'
78
+ Rev::CaptionOptions::OUTPUT_FILE_FORMATS[:ttml].must_equal 'Ttml'
79
+ Rev::CaptionOptions::OUTPUT_FILE_FORMATS[:qttext].must_equal 'QTtext'
80
+ end
81
+
82
+ it 'rejects unknowns file formats' do
83
+ proc { Rev::CaptionOptions.new([{}], { :output_file_formats => ['invalid'] }) }.must_raise ArgumentError
84
+ end
85
+
86
+ it 'accepts valid file formats' do
87
+ order = Rev::CaptionOptions.new([{}], { :output_file_formats => [Rev::CaptionOptions::OUTPUT_FILE_FORMATS[:scc]] })
88
+ order.output_file_formats.length.must_equal 1
89
+ order.output_file_formats[0].must_equal Rev::CaptionOptions::OUTPUT_FILE_FORMATS[:scc];
90
+ end
91
+ end # CaptionOptions
92
+ end
93
+
@@ -0,0 +1,58 @@
1
+ require_relative '../../../spec_helper'
2
+
3
+ describe 'Order' do
4
+ let(:cp_order) {
5
+ Rev::Order.new (
6
+ { 'attachments' => { },
7
+ 'comments' => {},
8
+ 'caption' => { 'total_length' => 5 }
9
+ }
10
+ )
11
+ }
12
+
13
+ it 'has caption info' do
14
+ assert_respond_to cp_order, 'caption'
15
+ end
16
+
17
+ it 'parses caption info' do
18
+ assert_kind_of Rev::CaptionInfo, cp_order.caption
19
+ end
20
+
21
+ it 'has captions attachments' do
22
+ assert_respond_to cp_order, 'captions'
23
+ end
24
+
25
+ describe 'Attachments' do
26
+ describe 'REPRESENTATIONS' do
27
+ it 'has srt' do
28
+ Rev::Attachment::REPRESENTATIONS[:srt].must_equal 'application/x-subrip'
29
+ end
30
+
31
+ it 'has scc' do
32
+ Rev::Attachment::REPRESENTATIONS[:scc].must_equal 'text/x-scc'
33
+ end
34
+
35
+ it 'has ttml' do
36
+ Rev::Attachment::REPRESENTATIONS[:ttml].must_equal 'application/ttml+xml'
37
+ end
38
+
39
+ it 'has qt' do
40
+ Rev::Attachment::REPRESENTATIONS[:qt].must_equal 'application/x-quicktime-timedtext'
41
+ end
42
+ end
43
+
44
+ describe 'KINDS' do
45
+ it 'has caption' do
46
+ Rev::Attachment::KINDS[:caption].must_equal 'caption'
47
+ end
48
+ end
49
+ end # Attachments
50
+
51
+ describe 'CaptionInfo' do
52
+ it 'has total_length' do
53
+ info = Rev::CaptionInfo.new({})
54
+ assert_respond_to info, 'total_length'
55
+ end
56
+ end # CaptionInfo
57
+ end
58
+
@@ -32,10 +32,17 @@ describe 'POST /orders' do
32
32
  inputs = []
33
33
  inputs << Rev::Input.new(:word_length => 1000, :uri => 'urn:foxtranslate:inputmedia:SnVwbG9hZHMvMjAxMy0wOS0xNy9lMzk4MWIzNS0wNzM1LTRlMDAtODY1NC1jNWY4ZjE4MzdlMTIvc291cmNlZG9jdW1lbnQucG5n')
34
34
  }
35
+ let(:caption_inputs) {
36
+ inputs = []
37
+ inputs << Rev::Input.new(:external_link => 'http://www.youtube.com/watch?v=UF8uR6Z6KLc')
38
+ }
35
39
  let(:transcription_options) { Rev::TranscriptionOptions.new(transcription_inputs,
36
40
  :verbatim => true, :timestamps => true) }
37
41
  let(:translation_options) { Rev::TranslationOptions.new(translation_inputs,
38
42
  :source_language_code => 'es', :destination_language_code => 'en') }
43
+ let(:caption_options) {
44
+ Rev::CaptionOptions.new(caption_inputs, :output_file_formats => ['SubRip'])
45
+ }
39
46
 
40
47
  it 'must submit order using Credit Card including all attributes' do
41
48
  VCR.insert_cassette 'submit_tc_order_with_cc_and_all_attributes'
@@ -79,6 +86,7 @@ describe 'POST /orders' do
79
86
  },
80
87
  'client_ref' => 'XB432423',
81
88
  'comment' => 'Please work quickly',
89
+ 'priority' => Rev::OrderRequest::PRIORITY[:normal],
82
90
  'notification' => {
83
91
  'url' => 'http://www.example.com',
84
92
  'level' => 'Detailed'
@@ -109,6 +117,7 @@ describe 'POST /orders' do
109
117
  'saved_id' => 1
110
118
  }
111
119
  },
120
+ 'priority' => Rev::OrderRequest::PRIORITY[:normal],
112
121
  'transcription_options' => {
113
122
  'inputs' => [
114
123
  { 'external_link' => 'http://www.youtube.com/watch?v=UF8uR6Z6KLc' },
@@ -140,6 +149,7 @@ describe 'POST /orders' do
140
149
  'payment' => {
141
150
  'type' => 'AccountBalance'
142
151
  },
152
+ 'priority' => Rev::OrderRequest::PRIORITY[:normal],
143
153
  'transcription_options' => {
144
154
  'inputs' => [
145
155
  { 'external_link' => 'http://www.youtube.com/watch?v=UF8uR6Z6KLc' },
@@ -170,7 +180,7 @@ describe 'POST /orders' do
170
180
  exception.code.must_equal Rev::OrderRequestErrorCodes::TC_OR_TR_OPTIONS_NOT_SPECIFIED
171
181
  end
172
182
 
173
- it 'must submit translation order with translation options' do
183
+ it 'must submit translation order with options' do
174
184
  VCR.insert_cassette 'submit_tr_order'
175
185
 
176
186
  request = Rev::OrderRequest.new(
@@ -185,6 +195,7 @@ describe 'POST /orders' do
185
195
  'payment' => {
186
196
  'type' => 'AccountBalance'
187
197
  },
198
+ 'priority' => Rev::OrderRequest::PRIORITY[:normal],
188
199
  'translation_options' => {
189
200
  'inputs'=> [
190
201
  { 'word_length' => 1000, 'uri' => 'urn:foxtranslate:inputmedia:SnVwbG9hZHMvMjAxMy0wOS0xNy9lMzk4MWIzNS0wNzM1LTRlMDAtODY1NC1jNWY4ZjE4MzdlMTIvc291cmNlZG9jdW1lbnQucG5n' },
@@ -199,6 +210,33 @@ describe 'POST /orders' do
199
210
  actual_body.must_equal expected_body
200
211
  end
201
212
  end
213
+
214
+ it 'must submit caption order with options' do
215
+ VCR.insert_cassette 'submit_cp_order'
216
+
217
+ request = Rev::OrderRequest.new(balance_payment, :caption_options => caption_options)
218
+
219
+ new_order_num = client.submit_order(request)
220
+
221
+ new_order_num.must_equal 'CP12345'
222
+ expected_body = {
223
+ 'payment' => {
224
+ 'type' => 'AccountBalance'
225
+ },
226
+ 'priority' => Rev::OrderRequest::PRIORITY[:normal],
227
+ 'caption_options' => {
228
+ 'inputs'=> [
229
+ { 'external_link' => 'http://www.youtube.com/watch?v=UF8uR6Z6KLc' }
230
+ ],
231
+ 'output_file_formats' => [Rev::CaptionOptions::OUTPUT_FILE_FORMATS[:subrip]]
232
+ }
233
+ }
234
+ assert_requested(:post, /.*\/orders/, :times => 1) do |req|
235
+ req.headers['Content-Type'] == 'application/json'
236
+ actual_body = JSON.load req.body
237
+ actual_body.must_equal expected_body
238
+ end
239
+ end
202
240
 
203
241
  after do
204
242
  VCR.eject_cassette
metadata CHANGED
@@ -1,142 +1,155 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rev-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
5
- prerelease:
4
+ version: 1.0.4
6
5
  platform: ruby
7
6
  authors:
8
7
  - Rev.com, Inc
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-05-12 00:00:00.000000000 Z
11
+ date: 2014-05-30 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: httparty
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '0.11'
20
+ - - '>='
20
21
  - !ruby/object:Gem::Version
21
22
  version: 0.11.0
22
23
  type: :runtime
23
24
  prerelease: false
24
25
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
26
  requirements:
27
- - - ! '>='
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '0.11'
30
+ - - '>='
28
31
  - !ruby/object:Gem::Version
29
32
  version: 0.11.0
30
33
  - !ruby/object:Gem::Dependency
31
34
  name: webmock
32
35
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
36
  requirements:
37
+ - - ~>
38
+ - !ruby/object:Gem::Version
39
+ version: '1.11'
35
40
  - - ~>
36
41
  - !ruby/object:Gem::Version
37
42
  version: 1.11.0
38
43
  type: :development
39
44
  prerelease: false
40
45
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
46
  requirements:
47
+ - - ~>
48
+ - !ruby/object:Gem::Version
49
+ version: '1.11'
43
50
  - - ~>
44
51
  - !ruby/object:Gem::Version
45
52
  version: 1.11.0
46
53
  - !ruby/object:Gem::Dependency
47
54
  name: vcr
48
55
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
56
  requirements:
57
+ - - ~>
58
+ - !ruby/object:Gem::Version
59
+ version: '2.6'
51
60
  - - ~>
52
61
  - !ruby/object:Gem::Version
53
62
  version: 2.6.0
54
63
  type: :development
55
64
  prerelease: false
56
65
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
66
  requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: '2.6'
59
70
  - - ~>
60
71
  - !ruby/object:Gem::Version
61
72
  version: 2.6.0
62
73
  - !ruby/object:Gem::Dependency
63
74
  name: turn
64
75
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
76
  requirements:
77
+ - - ~>
78
+ - !ruby/object:Gem::Version
79
+ version: '0.9'
67
80
  - - ~>
68
81
  - !ruby/object:Gem::Version
69
82
  version: 0.9.6
70
83
  type: :development
71
84
  prerelease: false
72
85
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
86
  requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: '0.9'
75
90
  - - ~>
76
91
  - !ruby/object:Gem::Version
77
92
  version: 0.9.6
78
93
  - !ruby/object:Gem::Dependency
79
94
  name: rake
80
95
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
96
  requirements:
83
- - - ! '>='
97
+ - - ~>
98
+ - !ruby/object:Gem::Version
99
+ version: '10.1'
100
+ - - '>='
84
101
  - !ruby/object:Gem::Version
85
102
  version: 10.1.0
86
103
  type: :development
87
104
  prerelease: false
88
105
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
106
  requirements:
91
- - - ! '>='
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: '10.1'
110
+ - - '>='
92
111
  - !ruby/object:Gem::Version
93
112
  version: 10.1.0
94
113
  - !ruby/object:Gem::Dependency
95
114
  name: yard
96
115
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
116
  requirements:
99
- - - ! '>='
117
+ - - ~>
100
118
  - !ruby/object:Gem::Version
101
119
  version: '0'
102
120
  type: :development
103
121
  prerelease: false
104
122
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
123
  requirements:
107
- - - ! '>='
124
+ - - ~>
108
125
  - !ruby/object:Gem::Version
109
126
  version: '0'
110
127
  - !ruby/object:Gem::Dependency
111
128
  name: redcarpet
112
129
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
130
  requirements:
115
- - - ! '>='
131
+ - - '>='
116
132
  - !ruby/object:Gem::Version
117
133
  version: '0'
118
134
  type: :development
119
135
  prerelease: false
120
136
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
137
  requirements:
123
- - - ! '>='
138
+ - - '>='
124
139
  - !ruby/object:Gem::Version
125
140
  version: '0'
126
141
  - !ruby/object:Gem::Dependency
127
142
  name: rubygems-tasks
128
143
  requirement: !ruby/object:Gem::Requirement
129
- none: false
130
144
  requirements:
131
- - - ! '>='
145
+ - - ~>
132
146
  - !ruby/object:Gem::Version
133
147
  version: '0'
134
148
  type: :development
135
149
  prerelease: false
136
150
  version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
151
  requirements:
139
- - - ! '>='
152
+ - - ~>
140
153
  - !ruby/object:Gem::Version
141
154
  version: '0'
142
155
  description: Communicate with Rev.com API using plain Ruby objects without bothering
@@ -183,6 +196,7 @@ files:
183
196
  - spec/fixtures/api_cassettes/link_input.yml
184
197
  - spec/fixtures/api_cassettes/link_input_with_all_attributes.yml
185
198
  - spec/fixtures/api_cassettes/not_found_order.yml
199
+ - spec/fixtures/api_cassettes/submit_cp_order.yml
186
200
  - spec/fixtures/api_cassettes/submit_tc_order_with_account_balance.yml
187
201
  - spec/fixtures/api_cassettes/submit_tc_order_with_cc_and_all_attributes.yml
188
202
  - spec/fixtures/api_cassettes/submit_tc_order_with_invalid_request.yml
@@ -194,39 +208,41 @@ files:
194
208
  - spec/fixtures/sourcedocument.png
195
209
  - spec/lib/rev/api_spec.rb
196
210
  - spec/lib/rev/cancel_order_spec.rb
211
+ - spec/lib/rev/exceptions_spec.rb
197
212
  - spec/lib/rev/get_attachment_content_spec.rb
198
213
  - spec/lib/rev/get_attachment_metadata_spec.rb
199
214
  - spec/lib/rev/get_order_spec.rb
200
215
  - spec/lib/rev/get_orders_spec.rb
201
216
  - spec/lib/rev/http_client_spec.rb
217
+ - spec/lib/rev/models/order_request_spec.rb
218
+ - spec/lib/rev/models/order_spec.rb
202
219
  - spec/lib/rev/post_inputs_spec.rb
203
220
  - spec/lib/rev/post_order_spec.rb
204
221
  - spec/spec_helper.rb
205
222
  homepage: http://www.rev.com/api
206
223
  licenses:
207
224
  - Apache License 2.0
225
+ metadata: {}
208
226
  post_install_message:
209
227
  rdoc_options: []
210
228
  require_paths:
211
229
  - lib
212
230
  - spec
213
231
  required_ruby_version: !ruby/object:Gem::Requirement
214
- none: false
215
232
  requirements:
216
- - - ! '>='
233
+ - - '>='
217
234
  - !ruby/object:Gem::Version
218
235
  version: 1.9.3
219
236
  required_rubygems_version: !ruby/object:Gem::Requirement
220
- none: false
221
237
  requirements:
222
- - - ! '>='
238
+ - - '>='
223
239
  - !ruby/object:Gem::Version
224
240
  version: '0'
225
241
  requirements: []
226
242
  rubyforge_project:
227
- rubygems_version: 1.8.24
243
+ rubygems_version: 2.0.6
228
244
  signing_key:
229
- specification_version: 3
245
+ specification_version: 4
230
246
  summary: Ruby wrapper for Rev.com API
231
247
  test_files:
232
248
  - spec/fixtures/api_cassettes/cancel_order.yml
@@ -246,6 +262,7 @@ test_files:
246
262
  - spec/fixtures/api_cassettes/link_input.yml
247
263
  - spec/fixtures/api_cassettes/link_input_with_all_attributes.yml
248
264
  - spec/fixtures/api_cassettes/not_found_order.yml
265
+ - spec/fixtures/api_cassettes/submit_cp_order.yml
249
266
  - spec/fixtures/api_cassettes/submit_tc_order_with_account_balance.yml
250
267
  - spec/fixtures/api_cassettes/submit_tc_order_with_cc_and_all_attributes.yml
251
268
  - spec/fixtures/api_cassettes/submit_tc_order_with_invalid_request.yml
@@ -257,11 +274,15 @@ test_files:
257
274
  - spec/fixtures/sourcedocument.png
258
275
  - spec/lib/rev/api_spec.rb
259
276
  - spec/lib/rev/cancel_order_spec.rb
277
+ - spec/lib/rev/exceptions_spec.rb
260
278
  - spec/lib/rev/get_attachment_content_spec.rb
261
279
  - spec/lib/rev/get_attachment_metadata_spec.rb
262
280
  - spec/lib/rev/get_order_spec.rb
263
281
  - spec/lib/rev/get_orders_spec.rb
264
282
  - spec/lib/rev/http_client_spec.rb
283
+ - spec/lib/rev/models/order_request_spec.rb
284
+ - spec/lib/rev/models/order_spec.rb
265
285
  - spec/lib/rev/post_inputs_spec.rb
266
286
  - spec/lib/rev/post_order_spec.rb
267
287
  - spec/spec_helper.rb
288
+ has_rdoc: yard