rev-api 2.0.3 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d6d9816d10431466d097102deefc91846e2dc1b1
4
- data.tar.gz: be67240ab97c0b3f4cab2eb3ce8e6f1d39787fa0
3
+ metadata.gz: c4126d05598d0db6d32e56f7e827b1fc96940e20
4
+ data.tar.gz: 4d47a8ce94a5bf50e3e90902f5bafac18651c271
5
5
  SHA512:
6
- metadata.gz: d8aed8b6c55afc38a64d121e9eadbb6059e2ac1155ad0fc37c8b89aa020cd9e60b0ddfbdab321764c27bde0113250b07993d301818f2ae4c6de7398d26a4eea8
7
- data.tar.gz: 68ae92704b2639777040c792765c4b73a13c05bcffc90a504562a256275c0c75829c3ab2c447221e25bf302656111560992058db5d4e184b3e97a970049c0434
6
+ metadata.gz: d565c4d92f78ef8f736f262c8e59edac3339ab4431f837d8134245b533216e4d84ee3b6de8ed65ec43292508f40a3b93f7edfffc897c37f2a94cb2a7331b46ea
7
+ data.tar.gz: 167b9597f691911f6a4534ebcff6b0292b4d1a06ba6941defd6623a9e3bc84ca6e23de45f8fccce49e75e083b58e0ddca85bcc47c9249e0d1fdfd29c2693014c
data/lib/rev-api/api.rb CHANGED
@@ -220,7 +220,7 @@ module Rev
220
220
  def upload_input(path, content_type)
221
221
  filename = Pathname.new(path).basename
222
222
  headers = {
223
- 'Content-Disposition' => "attachment; filename=#{filename}",
223
+ 'Content-Disposition' => "attachment; filename=\"#{filename}\"",
224
224
  'Content-Type' => content_type
225
225
  }
226
226
 
@@ -152,6 +152,9 @@ module Rev
152
152
  # Array of file formats the captions should be delivered as. (Optional, default is SubRip)
153
153
  attr_reader :output_file_formats
154
154
 
155
+ # Optional, Array of language codes to request foreign language subtitles
156
+ attr_reader :subtitle_languages
157
+
155
158
  # All supported output file formats
156
159
  OUTPUT_FILE_FORMATS = {
157
160
  :subrip => 'SubRip',
@@ -165,6 +168,10 @@ module Rev
165
168
  :cheetahcap => 'CheetahCap'
166
169
  }
167
170
 
171
+ # @param inputs [Array] list of inputs
172
+ # @param info [Hash] of fields to initialize instance. May contain:
173
+ # - :subtitle_languages
174
+ # @see TranslationOptions for a list of language codes.
168
175
  def initialize(inputs, info = {})
169
176
  super(inputs, info)
170
177
  raise(ArgumentError, "invalid format(s)") unless validate_output_formats(info[:output_file_formats])
@@ -1,3 +1,3 @@
1
1
  module Rev
2
- VERSION = '2.0.3'
2
+ VERSION = '2.1.0'
3
3
  end
@@ -25,7 +25,7 @@ http_interactions:
25
25
  Expires:
26
26
  - '-1'
27
27
  Location:
28
- - urn:foxtranslate:inputmedia:UHVwbG9hZHMvMjAxMy0wOS0xNy82NGRhOWY4Ny0zYTNlLTQ3NDgtYmI4Yi05MmE3ZmVhMTJjYzcvcmV2X2xvZ29fY29sb3JlZF90b3AucG5n
28
+ - urn:rev:inputmedia:UHVwbG9hZHMvMjAxMy0wOS0xNy82NGRhOWY4Ny0zYTNlLTQ3NDgtYmI4Yi05MmE3ZmVhMTJjYzcvcmV2X2xvZ29fY29sb3JlZF90b3AucG5n
29
29
  Server:
30
30
  - Microsoft-IIS/7.5
31
31
  X-Miniprofiler-Ids:
@@ -25,7 +25,7 @@ http_interactions:
25
25
  Expires:
26
26
  - '-1'
27
27
  Location:
28
- - urn:foxtranslate:inputmedia:SnVwbG9hZHMvMjAxMy0wOS0xNy83MTZjOTAzNC1iMDkxLTRlYjgtOTAzMi1kNjU0NzMzNDJlZTcvc291cmNlZG9jdW1lbnQucG5n
28
+ - urn:rev:inputmedia:SnVwbG9hZHMvMjAxMy0wOS0xNy83MTZjOTAzNC1iMDkxLTRlYjgtOTAzMi1kNjU0NzMzNDJlZTcvc291cmNlZG9jdW1lbnQucG5n
29
29
  Server:
30
30
  - Microsoft-IIS/7.5
31
31
  X-Miniprofiler-Ids:
@@ -0,0 +1,45 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://www.revtrunk.com/api/v1/inputs
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"url":"https://s3-us-west-2.amazonaws.com/public-rev/translation/Rev
9
+ Certified Template (2014-06-11).docx","filename":"Rev Certified Template (2014-06-11).docx","content_type":"application/vnd.openxmlformats-officedocument.wordprocessingml.document"}'
10
+ headers:
11
+ Authorization:
12
+ - Rev welcome:AAAAAu/YjZ3phXU5FsF35yIcgiA=
13
+ User-Agent:
14
+ - RevOfficialRubySDK/2.1.0
15
+ Content-Type:
16
+ - application/json
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
+ - urn:rev:inputmedia:YHVwbG9hZHMvMjAxNS0xMC0yMC80ZTlkNmFhZS02YmNhLTQzY2MtOTViNy1lM2E0MmNhNmQwMmQvUmV2IENlcnRpZmllZCBUZW1wbGF0ZSAoMjAxNC0wNi0xMSkuZG9jeA==
30
+ Server:
31
+ - Microsoft-IIS/8.5
32
+ X-Miniprofiler-Ids:
33
+ - '["a40c8bab-d6ad-4e2f-b277-d5691885e974"]'
34
+ X-Powered-By:
35
+ - ASP.NET
36
+ Date:
37
+ - Tue, 20 Oct 2015 21:48:24 GMT
38
+ Content-Length:
39
+ - '0'
40
+ body:
41
+ encoding: UTF-8
42
+ string: ''
43
+ http_version:
44
+ recorded_at: Tue, 20 Oct 2015 21:48:23 GMT
45
+ recorded_with: VCR 2.6.0
@@ -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"},"caption_options":{"inputs":[{"external_link":"http://www.youtube.com/watch?v=UF8uR6Z6KLc"},{"video_length_seconds":900,"external_link":"https://vimeo.com/7976699"}],"subtitle_languages":["es","it"],"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/CP56789
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
@@ -5,7 +5,7 @@ http_interactions:
5
5
  uri: https://www.revtrunk.com/api/v1/orders
6
6
  body:
7
7
  encoding: UTF-8
8
- string: ! '{"payment":{"type":"AccountBalance"},"translation_options":{"source_language_code":"es","destination_language_code":"en","inputs":[{"word_length":1000,"uri":"urn:foxtranslate:inputmedia:SnVwbG9hZHMvMjAxMy0wOS0xNy9lMzk4MWIzNS0wNzM1LTRlMDAtODY1NC1jNWY4ZjE4MzdlMTIvc291cmNlZG9jdW1lbnQucG5n"}]}}'
8
+ string: ! '{"payment":{"type":"AccountBalance"},"translation_options":{"source_language_code":"es","destination_language_code":"en","inputs":[{"word_length":1000,"uri":"urn:rev:inputmedia:SnVwbG9hZHMvMjAxMy0wOS0xNy9lMzk4MWIzNS0wNzM1LTRlMDAtODY1NC1jNWY4ZjE4MzdlMTIvc291cmNlZG9jdW1lbnQucG5n"}]}}'
9
9
  headers:
10
10
  Content-Type:
11
11
  - application/json
@@ -52,7 +52,7 @@ http_interactions:
52
52
  User-Agent:
53
53
  - RevOfficialRubySDK/1.0.0
54
54
  Content-Disposition:
55
- - attachment; filename=sourcedocument.png
55
+ - attachment; filename="sourcedocument.png"
56
56
  Content-Type:
57
57
  - image/png
58
58
  Accept:
@@ -71,7 +71,7 @@ http_interactions:
71
71
  Expires:
72
72
  - '-1'
73
73
  Location:
74
- - urn:foxtranslate:inputmedia:SnVwbG9hZHMvMjAxMy0wOS0yNi9jYzljNGE0MC03NTY3LTQ2YjYtYmVmMi0xMjU5ODgwODNhMWQvc291cmNlZG9jdW1lbnQucG5n
74
+ - urn:rev:inputmedia:SnVwbG9hZHMvMjAxMy0wOS0yNi9jYzljNGE0MC03NTY3LTQ2YjYtYmVmMi0xMjU5ODgwODNhMWQvc291cmNlZG9jdW1lbnQucG5n
75
75
  Server:
76
76
  - Microsoft-IIS/7.5
77
77
  X-Miniprofiler-Ids:
@@ -52,7 +52,7 @@ http_interactions:
52
52
  User-Agent:
53
53
  - RevOfficialRubySDK/1.0.0
54
54
  Content-Disposition:
55
- - attachment; filename=sourcedocument.png
55
+ - attachment; filename="sourcedocument.png"
56
56
  Content-Type:
57
57
  - trololo
58
58
  Accept:
@@ -11,14 +11,34 @@ describe 'POST /inputs' do
11
11
  content_type = 'image/png'
12
12
  new_input_location = client.create_input_from_link(link, filename, content_type)
13
13
 
14
- new_input_location.must_match 'urn:foxtranslate:inputmedia:'
14
+ new_input_location.must_match 'urn:rev:inputmedia:'
15
+ expected_body = {
16
+ 'url' => link,
17
+ 'filename' => filename,
18
+ 'content_type' => content_type
19
+ }
20
+ assert_requested(:post, /.*\/inputs/, :times => 1) do |req|
21
+ req.headers['Content-Type'].must_equal 'application/json'
22
+ actual_body = JSON.load req.body
23
+ actual_body.must_equal expected_body
24
+ end
25
+ end
26
+
27
+ it 'must quote the filename' do
28
+ VCR.insert_cassette 'link_input_with_spaces_in_filename'
29
+
30
+ link = 'https://s3-us-west-2.amazonaws.com/public-rev/translation/Rev Certified Template (2014-06-11).docx'
31
+ filename = 'Rev Certified Template (2014-06-11).docx'
32
+ content_type = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
33
+ new_input_location = client.create_input_from_link(link, filename, content_type)
34
+
35
+ new_input_location.must_match 'urn:rev:inputmedia:'
15
36
  expected_body = {
16
37
  'url' => link,
17
38
  'filename' => filename,
18
39
  'content_type' => content_type
19
40
  }
20
41
  assert_requested(:post, /.*\/inputs/, :times => 1) do |req|
21
- req.headers['Content-Type'] == 'application/json'
22
42
  actual_body = JSON.load req.body
23
43
  actual_body.must_equal expected_body
24
44
  end
@@ -30,10 +50,10 @@ describe 'POST /inputs' do
30
50
  link = 'https://www.rev.com/content/img/rev/rev_logo_colored_top.png'
31
51
  new_input_location = client.create_input_from_link(link)
32
52
 
33
- new_input_location.must_match 'urn:foxtranslate:inputmedia:'
53
+ new_input_location.must_match 'urn:rev:inputmedia:'
34
54
  expected_body = { 'url' => link }
35
55
  assert_requested(:post, /.*\/inputs/, :times => 1) do |req|
36
- req.headers['Content-Type'] == 'application/json'
56
+ req.headers['Content-Type'].must_equal 'application/json'
37
57
  actual_body = JSON.load req.body
38
58
  actual_body.must_equal expected_body
39
59
  end
@@ -47,11 +67,11 @@ describe 'POST /inputs' do
47
67
 
48
68
  new_input_location = client.upload_input(filename, content_type)
49
69
 
50
- new_input_location.must_match 'urn:foxtranslate:inputmedia:'
70
+ new_input_location.must_match 'urn:rev:inputmedia:'
51
71
  expected_body = File.read(filename)
52
72
  assert_requested(:post, /.*\/inputs/, :times => 1) do |req|
53
- req.headers['Content-Type'] == content_type
54
- req.headers['Content-Disposition'] == 'attachment; filename="sourcedocument.png'
73
+ req.headers['Content-Type'].must_equal content_type
74
+ req.headers['Content-Disposition'].must_equal 'attachment; filename="sourcedocument.png"'
55
75
  req.body.must_equal expected_body
56
76
  end
57
77
  end
@@ -21,7 +21,7 @@ describe 'POST /orders' do
21
21
  }
22
22
  let(:translation_inputs) {
23
23
  inputs = []
24
- inputs << Rev::Input.new(:word_length => 1000, :uri => 'urn:foxtranslate:inputmedia:SnVwbG9hZHMvMjAxMy0wOS0xNy9lMzk4MWIzNS0wNzM1LTRlMDAtODY1NC1jNWY4ZjE4MzdlMTIvc291cmNlZG9jdW1lbnQucG5n')
24
+ inputs << Rev::Input.new(:word_length => 1000, :uri => 'urn:rev:inputmedia:SnVwbG9hZHMvMjAxMy0wOS0xNy9lMzk4MWIzNS0wNzM1LTRlMDAtODY1NC1jNWY4ZjE4MzdlMTIvc291cmNlZG9jdW1lbnQucG5n')
25
25
  }
26
26
  let(:caption_inputs) {
27
27
  inputs = []
@@ -34,6 +34,10 @@ describe 'POST /orders' do
34
34
  let(:caption_options) {
35
35
  Rev::CaptionOptions.new(caption_inputs, :output_file_formats => ['SubRip'])
36
36
  }
37
+ let(:subtitle_options) {
38
+ Rev::CaptionOptions.new(caption_inputs, :subtitle_languages => ['es','it'],
39
+ :output_file_formats => ['SubRip'])
40
+ }
37
41
 
38
42
  it 'must place order using account balance' do
39
43
  VCR.insert_cassette 'submit_tc_order_with_account_balance'
@@ -59,11 +63,7 @@ describe 'POST /orders' do
59
63
  'timestamps' => true
60
64
  }
61
65
  }
62
- assert_requested(:post, /.*\/orders/, :times => 1) do |req|
63
- req.headers['Content-Type'] == 'application/json'
64
- actual_body = JSON.load req.body
65
- actual_body.must_equal expected_body
66
- end
66
+ assert_order_placement_success(expected_body)
67
67
  end
68
68
 
69
69
  it 'must default to account balance if payment property not set' do
@@ -90,19 +90,14 @@ describe 'POST /orders' do
90
90
  'timestamps' => true
91
91
  }
92
92
  }
93
- assert_requested(:post, /.*\/orders/, :times => 1) do |req|
94
- req.headers['Content-Type'] == 'application/json'
95
- actual_body = JSON.load req.body
96
- actual_body.must_equal expected_body
97
- end
93
+ assert_order_placement_success(expected_body)
98
94
  end
99
95
 
100
96
  it 'must raise BadRequest error in case of request validation failure' do
101
97
  VCR.insert_cassette 'submit_tc_order_with_invalid_request'
102
98
 
103
99
  # example - missing transcription options
104
- request = Rev::OrderRequest.new(
105
- )
100
+ request = Rev::OrderRequest.new
106
101
 
107
102
  action = lambda { client.submit_order(request) }
108
103
  exception = action.must_raise Rev::BadRequestError
@@ -127,26 +122,22 @@ describe 'POST /orders' do
127
122
  'priority' => Rev::OrderRequest::PRIORITY[:normal],
128
123
  'translation_options' => {
129
124
  'inputs'=> [
130
- { 'word_length' => 1000, 'uri' => 'urn:foxtranslate:inputmedia:SnVwbG9hZHMvMjAxMy0wOS0xNy9lMzk4MWIzNS0wNzM1LTRlMDAtODY1NC1jNWY4ZjE4MzdlMTIvc291cmNlZG9jdW1lbnQucG5n' },
125
+ { 'word_length' => 1000, 'uri' => 'urn:rev:inputmedia:SnVwbG9hZHMvMjAxMy0wOS0xNy9lMzk4MWIzNS0wNzM1LTRlMDAtODY1NC1jNWY4ZjE4MzdlMTIvc291cmNlZG9jdW1lbnQucG5n' },
131
126
  ],
132
127
  'source_language_code' => 'es',
133
128
  'destination_language_code' => 'en'
134
129
  }
135
130
  }
136
- assert_requested(:post, /.*\/orders/, :times => 1) do |req|
137
- req.headers['Content-Type'] == 'application/json'
138
- actual_body = JSON.load req.body
139
- actual_body.must_equal expected_body
140
- end
131
+ assert_order_placement_success(expected_body)
141
132
  end
142
-
133
+
143
134
  it 'must submit caption order with options' do
144
135
  VCR.insert_cassette 'submit_cp_order'
145
-
136
+
146
137
  request = Rev::OrderRequest.new(:caption_options => caption_options)
147
-
138
+
148
139
  new_order_num = client.submit_order(request)
149
-
140
+
150
141
  new_order_num.must_equal 'CP12345'
151
142
  expected_body = {
152
143
  'payment' => {
@@ -160,15 +151,45 @@ describe 'POST /orders' do
160
151
  'output_file_formats' => [Rev::CaptionOptions::OUTPUT_FILE_FORMATS[:subrip]]
161
152
  }
162
153
  }
163
- assert_requested(:post, /.*\/orders/, :times => 1) do |req|
164
- req.headers['Content-Type'] == 'application/json'
165
- actual_body = JSON.load req.body
166
- actual_body.must_equal expected_body
167
- end
154
+ assert_order_placement_success(expected_body)
155
+ end
156
+
157
+ it 'must submit subtitle order with options' do
158
+ VCR.insert_cassette 'submit_su_order'
159
+
160
+ request = Rev::OrderRequest.new(:caption_options => subtitle_options)
161
+
162
+ new_order_num = client.submit_order(request)
163
+
164
+ new_order_num.must_equal 'CP56789'
165
+ expected_body = {
166
+ 'payment' => {
167
+ 'type' => 'AccountBalance'
168
+ },
169
+ 'priority' => Rev::OrderRequest::PRIORITY[:normal],
170
+ 'caption_options' => {
171
+ 'inputs'=> [
172
+ { 'video_length_seconds' => 900, 'external_link' => 'http://www.youtube.com/watch?v=UF8uR6Z6KLc' }
173
+ ],
174
+ 'subtitle_languages' => ['es','it'],
175
+ 'output_file_formats' => [Rev::CaptionOptions::OUTPUT_FILE_FORMATS[:subrip]]
176
+ }
177
+ }
178
+ assert_order_placement_success(expected_body)
168
179
  end
169
180
 
170
181
  after do
171
182
  VCR.eject_cassette
172
183
  end
173
184
 
174
- end
185
+ private
186
+
187
+ def assert_order_placement_success(expected_body)
188
+ assert_requested(:post, /.*\/orders/, :times => 1) do |req|
189
+ req.headers['Content-Type'].must_equal 'application/json'
190
+ actual_body = JSON.load req.body
191
+ actual_body.must_equal expected_body
192
+ end
193
+ end
194
+
195
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rev-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.3
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rev.com, Inc
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-02 00:00:00.000000000 Z
11
+ date: 2015-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -209,8 +209,10 @@ files:
209
209
  - spec/fixtures/api_cassettes/get_tr_order.yml
210
210
  - spec/fixtures/api_cassettes/link_input.yml
211
211
  - spec/fixtures/api_cassettes/link_input_with_all_attributes.yml
212
+ - spec/fixtures/api_cassettes/link_input_with_spaces_in_filename.yml
212
213
  - spec/fixtures/api_cassettes/not_found_order.yml
213
214
  - spec/fixtures/api_cassettes/submit_cp_order.yml
215
+ - spec/fixtures/api_cassettes/submit_su_order.yml
214
216
  - spec/fixtures/api_cassettes/submit_tc_order_with_account_balance.yml
215
217
  - spec/fixtures/api_cassettes/submit_tc_order_with_invalid_request.yml
216
218
  - spec/fixtures/api_cassettes/submit_tc_order_without_specifying_payment.yml
@@ -276,8 +278,10 @@ test_files:
276
278
  - spec/fixtures/api_cassettes/get_tr_order.yml
277
279
  - spec/fixtures/api_cassettes/link_input.yml
278
280
  - spec/fixtures/api_cassettes/link_input_with_all_attributes.yml
281
+ - spec/fixtures/api_cassettes/link_input_with_spaces_in_filename.yml
279
282
  - spec/fixtures/api_cassettes/not_found_order.yml
280
283
  - spec/fixtures/api_cassettes/submit_cp_order.yml
284
+ - spec/fixtures/api_cassettes/submit_su_order.yml
281
285
  - spec/fixtures/api_cassettes/submit_tc_order_with_account_balance.yml
282
286
  - spec/fixtures/api_cassettes/submit_tc_order_with_invalid_request.yml
283
287
  - spec/fixtures/api_cassettes/submit_tc_order_without_specifying_payment.yml