verbalizeit 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +23 -0
- data/.rspec +2 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +150 -0
- data/Rakefile +2 -0
- data/lib/verbalizeit.rb +10 -0
- data/lib/verbalizeit/client.rb +151 -0
- data/lib/verbalizeit/error.rb +21 -0
- data/lib/verbalizeit/language.rb +16 -0
- data/lib/verbalizeit/task.rb +110 -0
- data/lib/verbalizeit/translator.rb +17 -0
- data/lib/verbalizeit/version.rb +3 -0
- data/spec/fixtures/cassettes/client/completed_file.yml +224 -0
- data/spec/fixtures/cassettes/client/completed_file_not_found.yml +186 -0
- data/spec/fixtures/cassettes/client/create_postback_task.yml +188 -0
- data/spec/fixtures/cassettes/client/create_task.yml +188 -0
- data/spec/fixtures/cassettes/client/create_task_start_task.yml +188 -0
- data/spec/fixtures/cassettes/client/get_task.yml +188 -0
- data/spec/fixtures/cassettes/client/get_task_not_found.yml +186 -0
- data/spec/fixtures/cassettes/client/language_list.yml +132 -0
- data/spec/fixtures/cassettes/client/list_tasks.yml +188 -0
- data/spec/fixtures/cassettes/client/list_tasks_start_limit.yml +188 -0
- data/spec/fixtures/cassettes/client/list_tasks_status.yml +188 -0
- data/spec/fixtures/cassettes/client/no_file_or_url.yml +186 -0
- data/spec/fixtures/cassettes/client/no_operation.yml +186 -0
- data/spec/fixtures/cassettes/client/no_source_language.yml +186 -0
- data/spec/fixtures/cassettes/client/no_target_language.yml +186 -0
- data/spec/fixtures/cassettes/client/start_task.yml +244 -0
- data/spec/fixtures/cassettes/client/start_task_forbidden.yml +57 -0
- data/spec/fixtures/cassettes/client/start_task_not_found.yml +186 -0
- data/spec/fixtures/cassettes/client/unauthorized.yml +54 -0
- data/spec/fixtures/cassettes/language/find_by_language_region_code.yml +132 -0
- data/spec/fixtures/cassettes/task/languages.yml +132 -0
- data/spec/spec_helper.rb +12 -0
- data/spec/support/created_task.json +32 -0
- data/spec/support/sample.srt +39 -0
- data/spec/support/sample.xliff +21 -0
- data/spec/verbalizeit/client_spec.rb +326 -0
- data/spec/verbalizeit/language_spec.rb +50 -0
- data/spec/verbalizeit/task_spec.rb +124 -0
- data/spec/verbalizeit/translator_spec.rb +21 -0
- data/verbalizeit.gemspec +29 -0
- metadata +228 -0
@@ -0,0 +1,54 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://stagingapi.verbalizeit.com/v2/languages
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Typhoeus - https://github.com/typhoeus/typhoeus
|
12
|
+
X-Api-Key:
|
13
|
+
- '12345'
|
14
|
+
response:
|
15
|
+
status:
|
16
|
+
code: 401
|
17
|
+
message: Unauthorized
|
18
|
+
headers:
|
19
|
+
Access-Control-Allow-Credentials:
|
20
|
+
- 'true'
|
21
|
+
Access-Control-Allow-Headers:
|
22
|
+
- "*,x-requested-with,Content-Type,If-Modified-Since,If-None-Match,Auth-User-Token"
|
23
|
+
Access-Control-Allow-Methods:
|
24
|
+
- POST, PUT, GET, OPTIONS, DELETE
|
25
|
+
Access-Control-Allow-Origin:
|
26
|
+
- ''
|
27
|
+
Cache-Control:
|
28
|
+
- no-cache
|
29
|
+
Content-Type:
|
30
|
+
- application/json; charset=utf-8
|
31
|
+
Date:
|
32
|
+
- Wed, 24 Dec 2014 00:17:15 GMT
|
33
|
+
Server:
|
34
|
+
- nginx/1.4.6 (Ubuntu)
|
35
|
+
Status:
|
36
|
+
- 401 Unauthorized
|
37
|
+
X-Rack-Cache:
|
38
|
+
- miss
|
39
|
+
X-Request-Id:
|
40
|
+
- b2b223340b6c0c78787bfcf28d64bf34
|
41
|
+
X-Runtime:
|
42
|
+
- '0.016598'
|
43
|
+
X-Ua-Compatible:
|
44
|
+
- IE=Edge,chrome=1
|
45
|
+
Content-Length:
|
46
|
+
- '2'
|
47
|
+
Connection:
|
48
|
+
- keep-alive
|
49
|
+
body:
|
50
|
+
encoding: UTF-8
|
51
|
+
string: "{}"
|
52
|
+
http_version:
|
53
|
+
recorded_at: Wed, 24 Dec 2014 00:17:15 GMT
|
54
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,132 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://stagingapi.verbalizeit.com/v2/languages
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Typhoeus - https://github.com/typhoeus/typhoeus
|
12
|
+
X-Api-Key:
|
13
|
+
- "<API KEY>"
|
14
|
+
response:
|
15
|
+
status:
|
16
|
+
code: 200
|
17
|
+
message: OK
|
18
|
+
headers:
|
19
|
+
Access-Control-Allow-Credentials:
|
20
|
+
- 'true'
|
21
|
+
Access-Control-Allow-Headers:
|
22
|
+
- "*,x-requested-with,Content-Type,If-Modified-Since,If-None-Match,Auth-User-Token"
|
23
|
+
Access-Control-Allow-Methods:
|
24
|
+
- POST, PUT, GET, OPTIONS, DELETE
|
25
|
+
Access-Control-Allow-Origin:
|
26
|
+
- ''
|
27
|
+
Cache-Control:
|
28
|
+
- max-age=0, private, must-revalidate
|
29
|
+
Content-Type:
|
30
|
+
- application/json; charset=utf-8
|
31
|
+
Date:
|
32
|
+
- Wed, 24 Dec 2014 19:13:29 GMT
|
33
|
+
Etag:
|
34
|
+
- '"6ed3f7edbf0ed0cbba041a3932fd237c"'
|
35
|
+
Server:
|
36
|
+
- nginx/1.4.6 (Ubuntu)
|
37
|
+
Set-Cookie:
|
38
|
+
- _verbalizeit_session=BAh7B0kiD3Nlc3Npb25faWQGOgZFRkkiJTRkMzA5Mzg3ZjcxZWFjODc4YWI0NjliYzY2NmJjYzkzBjsAVEkiHXdhcmRlbi51c2VyLmN1c3RvbWVyLmtleQY7AFRbCEkiDUN1c3RvbWVyBjsARlsGaQLVAkkiIiQyYSQxMCRDNTlDS0tsaTVQOVBVLmF0TERVeHJPBjsAVA%3D%3D--7929c3a9b10eb6e62b8c23c51e14749fb7266c34;
|
39
|
+
domain=.verbalizeit.com; path=/
|
40
|
+
Status:
|
41
|
+
- 200 OK
|
42
|
+
X-Rack-Cache:
|
43
|
+
- miss
|
44
|
+
X-Request-Id:
|
45
|
+
- 43ae9abb5aa47bb0f5a662e109f8d9d5
|
46
|
+
X-Runtime:
|
47
|
+
- '0.304583'
|
48
|
+
X-Ua-Compatible:
|
49
|
+
- IE=Edge,chrome=1
|
50
|
+
Transfer-Encoding:
|
51
|
+
- chunked
|
52
|
+
Connection:
|
53
|
+
- keep-alive
|
54
|
+
body:
|
55
|
+
encoding: ASCII-8BIT
|
56
|
+
string: !binary |-
|
57
|
+
W3sibmFtZSI6IkVuZ2xpc2giLCJsYW5ndWFnZV9yZWdpb25fY29kZSI6ImVu
|
58
|
+
Zy1VUyJ9LHsibmFtZSI6IkFmcmlrYWFucyIsImxhbmd1YWdlX3JlZ2lvbl9j
|
59
|
+
b2RlIjoiYWZyLVpBIn0seyJuYW1lIjoiQXJhYmljIiwibGFuZ3VhZ2VfcmVn
|
60
|
+
aW9uX2NvZGUiOiJhcmEtQUUifSx7Im5hbWUiOiJCb2ttw6VsIiwibGFuZ3Vh
|
61
|
+
Z2VfcmVnaW9uX2NvZGUiOiJub2ItTk8ifSx7Im5hbWUiOiJCb3NuaWFuIiwi
|
62
|
+
bGFuZ3VhZ2VfcmVnaW9uX2NvZGUiOiJib3MtQkEifSx7Im5hbWUiOiJCdWxn
|
63
|
+
YXJpYW4iLCJsYW5ndWFnZV9yZWdpb25fY29kZSI6ImJ1bC1CRyJ9LHsibmFt
|
64
|
+
ZSI6IkNhdGFsYW4iLCJsYW5ndWFnZV9yZWdpb25fY29kZSI6ImNhdC1FU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Fu
|
125
|
+
KSIsImxhbmd1YWdlX3JlZ2lvbl9jb2RlIjoiemhvLVRXIn0seyJuYW1lIjoi
|
126
|
+
VHVya2lzaCIsImxhbmd1YWdlX3JlZ2lvbl9jb2RlIjoidHVyLVRSIn0seyJu
|
127
|
+
YW1lIjoiVWtyYWluaWFuIiwibGFuZ3VhZ2VfcmVnaW9uX2NvZGUiOiJ1a3It
|
128
|
+
VUEifSx7Im5hbWUiOiJWaWV0bmFtZXNlIiwibGFuZ3VhZ2VfcmVnaW9uX2Nv
|
129
|
+
ZGUiOiJ2aWUtVk4ifV0=
|
130
|
+
http_version:
|
131
|
+
recorded_at: Wed, 24 Dec 2014 19:13:30 GMT
|
132
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,132 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://stagingapi.verbalizeit.com/v2/languages
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Typhoeus - https://github.com/typhoeus/typhoeus
|
12
|
+
X-Api-Key:
|
13
|
+
- "<API KEY>"
|
14
|
+
response:
|
15
|
+
status:
|
16
|
+
code: 200
|
17
|
+
message: OK
|
18
|
+
headers:
|
19
|
+
Access-Control-Allow-Credentials:
|
20
|
+
- 'true'
|
21
|
+
Access-Control-Allow-Headers:
|
22
|
+
- "*,x-requested-with,Content-Type,If-Modified-Since,If-None-Match,Auth-User-Token"
|
23
|
+
Access-Control-Allow-Methods:
|
24
|
+
- POST, PUT, GET, OPTIONS, DELETE
|
25
|
+
Access-Control-Allow-Origin:
|
26
|
+
- ''
|
27
|
+
Cache-Control:
|
28
|
+
- max-age=0, private, must-revalidate
|
29
|
+
Content-Type:
|
30
|
+
- application/json; charset=utf-8
|
31
|
+
Date:
|
32
|
+
- Wed, 24 Dec 2014 19:08:54 GMT
|
33
|
+
Etag:
|
34
|
+
- '"6ed3f7edbf0ed0cbba041a3932fd237c"'
|
35
|
+
Server:
|
36
|
+
- nginx/1.4.6 (Ubuntu)
|
37
|
+
Set-Cookie:
|
38
|
+
- _verbalizeit_session=BAh7B0kiD3Nlc3Npb25faWQGOgZFRkkiJWU3OGNmZjEwNjU2MzA1ZmRjZGUzNWQ3YjU3YjJkZDE1BjsAVEkiHXdhcmRlbi51c2VyLmN1c3RvbWVyLmtleQY7AFRbCEkiDUN1c3RvbWVyBjsARlsGaQLVAkkiIiQyYSQxMCRDNTlDS0tsaTVQOVBVLmF0TERVeHJPBjsAVA%3D%3D--e7381f517410a586dcd0af88b265464dab7743fd;
|
39
|
+
domain=.verbalizeit.com; path=/
|
40
|
+
Status:
|
41
|
+
- 200 OK
|
42
|
+
X-Rack-Cache:
|
43
|
+
- miss
|
44
|
+
X-Request-Id:
|
45
|
+
- 9fb729bbe84ea0276779719f91681544
|
46
|
+
X-Runtime:
|
47
|
+
- '0.325158'
|
48
|
+
X-Ua-Compatible:
|
49
|
+
- IE=Edge,chrome=1
|
50
|
+
Transfer-Encoding:
|
51
|
+
- chunked
|
52
|
+
Connection:
|
53
|
+
- keep-alive
|
54
|
+
body:
|
55
|
+
encoding: ASCII-8BIT
|
56
|
+
string: !binary |-
|
57
|
+
W3sibmFtZSI6IkVuZ2xpc2giLCJsYW5ndWFnZV9yZWdpb25fY29kZSI6ImVu
|
58
|
+
Zy1VUyJ9LHsibmFtZSI6IkFmcmlrYWFucyIsImxhbmd1YWdlX3JlZ2lvbl9j
|
59
|
+
b2RlIjoiYWZyLVpBIn0seyJuYW1lIjoiQXJhYmljIiwibGFuZ3VhZ2VfcmVn
|
60
|
+
aW9uX2NvZGUiOiJhcmEtQUUifSx7Im5hbWUiOiJCb2ttw6VsIiwibGFuZ3Vh
|
61
|
+
Z2VfcmVnaW9uX2NvZGUiOiJub2ItTk8ifSx7Im5hbWUiOiJCb3NuaWFuIiwi
|
62
|
+
bGFuZ3VhZ2VfcmVnaW9uX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LUNOIn0seyJuYW1lIjoiVHJhZGl0aW9uYWwg
|
123
|
+
Q2hpbmVzZSAoSG9uZyBLb25nKSIsImxhbmd1YWdlX3JlZ2lvbl9jb2RlIjoi
|
124
|
+
emhvLUhLIn0seyJuYW1lIjoiVHJhZGl0aW9uYWwgQ2hpbmVzZSAoVGFpd2Fu
|
125
|
+
KSIsImxhbmd1YWdlX3JlZ2lvbl9jb2RlIjoiemhvLVRXIn0seyJuYW1lIjoi
|
126
|
+
VHVya2lzaCIsImxhbmd1YWdlX3JlZ2lvbl9jb2RlIjoidHVyLVRSIn0seyJu
|
127
|
+
YW1lIjoiVWtyYWluaWFuIiwibGFuZ3VhZ2VfcmVnaW9uX2NvZGUiOiJ1a3It
|
128
|
+
VUEifSx7Im5hbWUiOiJWaWV0bmFtZXNlIiwibGFuZ3VhZ2VfcmVnaW9uX2Nv
|
129
|
+
ZGUiOiJ2aWUtVk4ifV0=
|
130
|
+
http_version:
|
131
|
+
recorded_at: Wed, 24 Dec 2014 19:08:55 GMT
|
132
|
+
recorded_with: VCR 2.9.3
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'vcr'
|
2
|
+
require 'webmock/rspec'
|
3
|
+
require 'pry'
|
4
|
+
require 'verbalizeit'
|
5
|
+
require 'dotenv'
|
6
|
+
Dotenv.load
|
7
|
+
|
8
|
+
VCR.configure do |c|
|
9
|
+
c.cassette_library_dir = 'spec/fixtures/cassettes'
|
10
|
+
c.hook_into :webmock
|
11
|
+
c.filter_sensitive_data('<API KEY>') { ENV['STAGING_API_KEY'] }
|
12
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
{
|
2
|
+
"id": "TX1234",
|
3
|
+
"url": "http://www.verbalizeit.com/v2/tasks/TCAAA",
|
4
|
+
"status": "complete",
|
5
|
+
"rush_order": false,
|
6
|
+
"project_name": "Marketing Materials",
|
7
|
+
"source_language": "eng-US",
|
8
|
+
"target_language": "spa-ES",
|
9
|
+
"price_currency": "usd",
|
10
|
+
"price_amount": 11.22,
|
11
|
+
"due_at": "2014-10-13T11:56:02-04:00",
|
12
|
+
"completed_at": "2014-10-09T12:11:06-04:00",
|
13
|
+
"created_at": "2014-10-09T11:56:02-04:00",
|
14
|
+
"operation": "text_translation",
|
15
|
+
"download_url": "https://api.verbalizeit.com/v2/tasks/TX1234/completed_file",
|
16
|
+
"source_download_url": "https://api.verbalizeit.com/v2/tasks/TX1234/source_file",
|
17
|
+
"source_filename": "marketing_materials.docx",
|
18
|
+
"unit_count": 66,
|
19
|
+
"unit_type": "word",
|
20
|
+
"translation_units": 16,
|
21
|
+
"translation_units_complete": 16,
|
22
|
+
"translator":{
|
23
|
+
"name": "Jenny S.",
|
24
|
+
"avatar": "http://assets.verbalizeit.com/translator.jpg"
|
25
|
+
},
|
26
|
+
"reviewer":{
|
27
|
+
"name": "Stephen D.",
|
28
|
+
"avatar": "http://assets.verbalizeit.com/revewier.jpg"
|
29
|
+
},
|
30
|
+
"postback_url": "https://api.mycompany.com/finished_task",
|
31
|
+
"status_url": "https://api.mycompany.com/task_changed_status"
|
32
|
+
}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
1
|
2
|
+
00:00:21,671 --> 00:01:28,930
|
3
|
+
In a time yet to be... After the global
|
4
|
+
economic collapse, only seven walled
|
5
|
+
|
6
|
+
2
|
7
|
+
00:01:28,930 --> 00:01:34,901
|
8
|
+
cities remain on Earth. Outside of these
|
9
|
+
walls, 99% of the population struggles to
|
10
|
+
|
11
|
+
3
|
12
|
+
00:01:34,901 --> 00:01:41,018
|
13
|
+
survive with no infrastructure. Meanwhile,
|
14
|
+
a new kind of human is emerging. Psychic
|
15
|
+
|
16
|
+
4
|
17
|
+
00:01:41,018 --> 00:01:45,925
|
18
|
+
boy and girl counterparts who hold the key
|
19
|
+
to mankind's evolution. A forgotten
|
20
|
+
|
21
|
+
5
|
22
|
+
00:01:45,925 --> 00:01:50,116
|
23
|
+
prophecy foretells of new kind soul mates
|
24
|
+
that will ignite a genetic change reaction
|
25
|
+
|
26
|
+
6
|
27
|
+
00:01:50,116 --> 00:01:55,041
|
28
|
+
re-tuning the human species into
|
29
|
+
telepathic beings. But a population of
|
30
|
+
|
31
|
+
7
|
32
|
+
00:01:55,041 --> 00:01:59,563
|
33
|
+
psychic humans would spell doom for the
|
34
|
+
hidden masters of this planet. For
|
35
|
+
|
36
|
+
8
|
37
|
+
00:01:59,563 --> 00:02:04,684
|
38
|
+
deception lies in manipulation of the
|
39
|
+
tools the have used to rule for centuries.
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<xliff>
|
3
|
+
<file>
|
4
|
+
<body>
|
5
|
+
<trans-unit>
|
6
|
+
<source>VerbalizeIt</source>
|
7
|
+
<target></target>
|
8
|
+
</trans-unit>
|
9
|
+
<trans-unit>
|
10
|
+
<source>Check out this content.</source>
|
11
|
+
<target></target>
|
12
|
+
</trans-unit>
|
13
|
+
<trans-unit>
|
14
|
+
<source>
|
15
|
+
Here is some more source content
|
16
|
+
</source>
|
17
|
+
<target></target>
|
18
|
+
</trans-unit>
|
19
|
+
</body>
|
20
|
+
</file>
|
21
|
+
</xliff>
|
@@ -0,0 +1,326 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Verbalizeit::Client do
|
4
|
+
|
5
|
+
let(:staging_api_key) { ENV['STAGING_API_KEY'] }
|
6
|
+
let(:source_language) { 'eng-US' }
|
7
|
+
let(:target_language) { 'fra-FR' }
|
8
|
+
let(:operation) { 'text_translation' }
|
9
|
+
let(:video) { 'video_transcription' }
|
10
|
+
let(:file_xliff) { File.open(File.expand_path('./spec/support/sample.xliff'), 'r') }
|
11
|
+
let(:file_srt) { File.open(File.expand_path('./spec/support/sample.srt'), 'r') }
|
12
|
+
let(:media_resource_url) { 'http://vimeo.com/100265082' }
|
13
|
+
let(:postback_url) { 'https://verbalizeit.com/postback' }
|
14
|
+
let(:status_url) { 'https://verbalizeit.com/status' }
|
15
|
+
|
16
|
+
describe 'initialize' do
|
17
|
+
|
18
|
+
it 'raises Verbalizeit::Error::Unauthorized if api key is invalid' do
|
19
|
+
VCR.use_cassette('client/unauthorized') do
|
20
|
+
expect { Verbalizeit::Client.new(12345, :staging) }.to raise_error(Verbalizeit::Error::Unauthorized)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'raises Verbalizeit::Error:UnknownEnvironment if the environment is unknown' do
|
25
|
+
expect { Verbalizeit::Client.new(staging_api_key, :foo) }.to raise_error(Verbalizeit::Error::UnknownEnvironment)
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'authenticates the user and fetches the language list' do
|
29
|
+
VCR.use_cassette('client/language_list') do
|
30
|
+
client = Verbalizeit::Client.new(staging_api_key, :staging)
|
31
|
+
|
32
|
+
expect(client.languages.count > 1).to eq(true)
|
33
|
+
expect(client.languages.first.name).to eq('English')
|
34
|
+
expect(client.languages.first.language_region_code).to eq('eng-US')
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
describe 'create task' do
|
41
|
+
|
42
|
+
it 'raises Verbalizeit::Error::BadRequest if no source_language is present' do
|
43
|
+
VCR.use_cassette('client/no_source_language') do
|
44
|
+
client = Verbalizeit::Client.new(staging_api_key, :staging)
|
45
|
+
|
46
|
+
options = {file: file_xliff}
|
47
|
+
|
48
|
+
expect {
|
49
|
+
client.create_task(nil, target_language, operation, options)
|
50
|
+
}.to raise_error(Verbalizeit::Error::BadRequest)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'raises Verbalizeit::Error::BadRequest if no target_language is present' do
|
55
|
+
VCR.use_cassette('client/no_target_language') do
|
56
|
+
client = Verbalizeit::Client.new(staging_api_key, :staging)
|
57
|
+
|
58
|
+
options = {file: file_xliff}
|
59
|
+
|
60
|
+
expect {
|
61
|
+
client.create_task(source_language, nil, operation, options)
|
62
|
+
}.to raise_error(Verbalizeit::Error::BadRequest)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'raises Verbalizeit::Error::BadRequest if no operation is present' do
|
67
|
+
VCR.use_cassette('client/no_operation') do
|
68
|
+
client = Verbalizeit::Client.new(staging_api_key, :staging)
|
69
|
+
|
70
|
+
options = {file: file_xliff}
|
71
|
+
|
72
|
+
expect {
|
73
|
+
client.create_task(source_language, target_language, nil, options)
|
74
|
+
}.to raise_error(Verbalizeit::Error::BadRequest)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'raises Verbalizeit::Error::BadRequest if no url or file is present' do
|
79
|
+
VCR.use_cassette('client/no_file_or_url') do
|
80
|
+
client = Verbalizeit::Client.new(staging_api_key, :staging)
|
81
|
+
|
82
|
+
expect {
|
83
|
+
client.create_task(source_language, target_language, operation)
|
84
|
+
}.to raise_error(Verbalizeit::Error::BadRequest)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'creates a task' do
|
89
|
+
VCR.use_cassette('client/create_task') do
|
90
|
+
client = Verbalizeit::Client.new(staging_api_key, :staging)
|
91
|
+
|
92
|
+
options = {file: file_xliff}
|
93
|
+
|
94
|
+
task = client.create_task(source_language, target_language, operation, options)
|
95
|
+
expect(task.id).to_not eq(nil)
|
96
|
+
expect(task.status).to_not eq(nil)
|
97
|
+
expect(task.rush_order).to eq(false)
|
98
|
+
expect(task.price_amount > 0).to eq(true)
|
99
|
+
expect(task.translation_units).to eq(3)
|
100
|
+
expect(task.status).to eq('preview')
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'creates a task with postback/status urls as a rush order' do
|
105
|
+
VCR.use_cassette('client/create_postback_task') do
|
106
|
+
client = Verbalizeit::Client.new(staging_api_key, :staging)
|
107
|
+
|
108
|
+
options = {
|
109
|
+
file: file_xliff, postback_url: postback_url,
|
110
|
+
status_url: status_url
|
111
|
+
}
|
112
|
+
|
113
|
+
task = client.create_task(source_language, target_language, operation, options)
|
114
|
+
expect(task.id).to_not eq(nil)
|
115
|
+
expect(task.status).to_not eq(nil)
|
116
|
+
expect(task.rush_order).to eq(false)
|
117
|
+
expect(task.price_amount > 0).to eq(true)
|
118
|
+
expect(task.status).to eq('preview')
|
119
|
+
expect(task.postback_url).to eq(postback_url)
|
120
|
+
expect(task.status_url).to eq(status_url)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
it 'creates a task and starts it' do
|
125
|
+
VCR.use_cassette('client/create_task_start_task') do
|
126
|
+
client = Verbalizeit::Client.new(staging_api_key, :staging)
|
127
|
+
|
128
|
+
options = {
|
129
|
+
file: file_srt, media_resource_url: media_resource_url,
|
130
|
+
start: true, rush_order: true
|
131
|
+
}
|
132
|
+
|
133
|
+
task = client.create_task(source_language, target_language, video, options)
|
134
|
+
expect(task.id).to_not eq(nil)
|
135
|
+
expect(task.status).to_not eq(nil)
|
136
|
+
expect(task.rush_order).to eq(true)
|
137
|
+
expect(task.price_amount > 0).to eq(true)
|
138
|
+
expect(task.status).to eq('processing')
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
end
|
143
|
+
|
144
|
+
describe 'list tasks' do
|
145
|
+
|
146
|
+
it 'gets a list of all the tasks' do
|
147
|
+
VCR.use_cassette('client/list_tasks') do
|
148
|
+
client = Verbalizeit::Client.new(staging_api_key, :staging)
|
149
|
+
|
150
|
+
tasks = client.list_tasks
|
151
|
+
|
152
|
+
expect(tasks[:total]).to eq(7)
|
153
|
+
expect(tasks[:start]).to eq(0)
|
154
|
+
expect(tasks[:limit]).to eq(10)
|
155
|
+
expect(tasks[:tasks].first.id).to_not eq(nil)
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
it 'can specify a start and limit' do
|
160
|
+
VCR.use_cassette('client/list_tasks_start_limit') do
|
161
|
+
client = Verbalizeit::Client.new(staging_api_key, :staging)
|
162
|
+
|
163
|
+
tasks = client.list_tasks({start: 2, limit: 5})
|
164
|
+
|
165
|
+
expect(tasks[:total]).to eq(7)
|
166
|
+
expect(tasks[:start]).to eq(2)
|
167
|
+
expect(tasks[:limit]).to eq(5)
|
168
|
+
expect(tasks[:tasks].first.id).to_not eq(nil)
|
169
|
+
expect(tasks[:tasks].size).to eq(5)
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
it 'can specify a status' do
|
174
|
+
VCR.use_cassette('client/list_tasks_status') do
|
175
|
+
client = Verbalizeit::Client.new(staging_api_key, :staging)
|
176
|
+
|
177
|
+
tasks = client.list_tasks({status: 'preview'})
|
178
|
+
|
179
|
+
expect(tasks[:total]).to eq(6)
|
180
|
+
expect(tasks[:start]).to eq(0)
|
181
|
+
expect(tasks[:limit]).to eq(10)
|
182
|
+
expect(tasks[:tasks].first.id).to_not eq(nil)
|
183
|
+
expect(tasks[:tasks].size).to eq(6)
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
it 'raises VerbalizeIt::Error::NotImplemented if an error response is received' do
|
188
|
+
VCR.use_cassette('client/list_tasks_not_implemented') do
|
189
|
+
struct = Struct.new(:code, :body)
|
190
|
+
response = struct.new(400, {}.to_json)
|
191
|
+
|
192
|
+
allow(Typhoeus).to receive(:get).and_return(response)
|
193
|
+
|
194
|
+
client = Verbalizeit::Client.new(staging_api_key, :staging)
|
195
|
+
|
196
|
+
expect { client.list_tasks }.to raise_error(Verbalizeit::Error::NotImplemented)
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
end
|
201
|
+
|
202
|
+
describe 'get task' do
|
203
|
+
|
204
|
+
it 'raises VerbalizeIt::Error::NotFound if the task does not exist' do
|
205
|
+
VCR.use_cassette('client/get_task_not_found') do
|
206
|
+
client = Verbalizeit::Client.new(staging_api_key, :staging)
|
207
|
+
|
208
|
+
expect {
|
209
|
+
client.get_task('garbage')
|
210
|
+
}.to raise_error(Verbalizeit::Error::NotFound)
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
it 'raises VerbalizeIt::Error::Forbidden if the task does not belong to the account' do
|
215
|
+
VCR.use_cassette('client/get_task_forbidden') do
|
216
|
+
struct = Struct.new(:code, :body)
|
217
|
+
response = struct.new(403, {}.to_json)
|
218
|
+
|
219
|
+
allow(Typhoeus).to receive(:get).and_return(response)
|
220
|
+
|
221
|
+
client = Verbalizeit::Client.new(staging_api_key, :staging)
|
222
|
+
|
223
|
+
expect {
|
224
|
+
client.get_task('sd9f8w3j434')
|
225
|
+
}.to raise_error(Verbalizeit::Error::Forbidden)
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
it 'can get an individual task' do
|
230
|
+
VCR.use_cassette('client/get_task') do
|
231
|
+
client = Verbalizeit::Client.new(staging_api_key, :staging)
|
232
|
+
|
233
|
+
id = 'T2EB60C'
|
234
|
+
response = client.get_task(id)
|
235
|
+
|
236
|
+
expect(response.id).to eq(id)
|
237
|
+
expect(response.status).to_not eq(nil)
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
end
|
242
|
+
|
243
|
+
describe 'start task' do
|
244
|
+
|
245
|
+
it 'raises VerbalizeIt::Error::NotFound if the task does not exist' do
|
246
|
+
VCR.use_cassette('client/start_task_not_found') do
|
247
|
+
client = Verbalizeit::Client.new(staging_api_key, :staging)
|
248
|
+
|
249
|
+
expect {
|
250
|
+
client.start_task('garbage')
|
251
|
+
}.to raise_error(Verbalizeit::Error::NotFound)
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
it 'raises VerbalizeIt::Error::Forbidden if the task does not belong to the account' do
|
256
|
+
VCR.use_cassette('client/start_task_forbidden') do
|
257
|
+
struct = Struct.new(:code, :body)
|
258
|
+
response = struct.new(403, {}.to_json)
|
259
|
+
|
260
|
+
allow(Typhoeus).to receive(:get).and_return(response)
|
261
|
+
|
262
|
+
client = Verbalizeit::Client.new(staging_api_key, :staging)
|
263
|
+
|
264
|
+
expect {
|
265
|
+
client.start_task('sd9f8w3j434')
|
266
|
+
}.to raise_error(Verbalizeit::Error::Forbidden)
|
267
|
+
end
|
268
|
+
end
|
269
|
+
|
270
|
+
it 'starts a task' do
|
271
|
+
VCR.use_cassette('client/start_task') do
|
272
|
+
client = Verbalizeit::Client.new(staging_api_key, :staging)
|
273
|
+
options = {file: file_xliff}
|
274
|
+
task = client.create_task(source_language, target_language, operation, options)
|
275
|
+
|
276
|
+
expect(task.status).to_not eq('processing')
|
277
|
+
|
278
|
+
response = client.start_task(task.id)
|
279
|
+
|
280
|
+
expect(response).to eq(true)
|
281
|
+
end
|
282
|
+
end
|
283
|
+
|
284
|
+
end
|
285
|
+
|
286
|
+
describe 'task completed file' do
|
287
|
+
|
288
|
+
it 'raises VerbalizeIt::Error::NotFound if the task does not exist' do
|
289
|
+
VCR.use_cassette('client/completed_file_not_found') do
|
290
|
+
client = Verbalizeit::Client.new(staging_api_key, :staging)
|
291
|
+
|
292
|
+
expect {
|
293
|
+
client.task_completed_file('garbage')
|
294
|
+
}.to raise_error(Verbalizeit::Error::NotFound)
|
295
|
+
end
|
296
|
+
end
|
297
|
+
|
298
|
+
it 'raises VerbalizeIt::Error::Forbidden if the task does not belong to the account' do
|
299
|
+
VCR.use_cassette('client/completed_file_forbidden') do
|
300
|
+
struct = Struct.new(:code, :body)
|
301
|
+
response = struct.new(403, {}.to_json)
|
302
|
+
|
303
|
+
allow(Typhoeus).to receive(:get).and_return(response)
|
304
|
+
|
305
|
+
client = Verbalizeit::Client.new(staging_api_key, :staging)
|
306
|
+
|
307
|
+
expect {
|
308
|
+
client.task_completed_file('sd9f8w3j434')
|
309
|
+
}.to raise_error(Verbalizeit::Error::Forbidden)
|
310
|
+
end
|
311
|
+
end
|
312
|
+
|
313
|
+
it 'returns the completed file' do
|
314
|
+
VCR.use_cassette('client/completed_file') do
|
315
|
+
client = Verbalizeit::Client.new(staging_api_key, :staging)
|
316
|
+
|
317
|
+
file = client.task_completed_file('T399ECD')
|
318
|
+
|
319
|
+
expect(file.filename).to eq("\"sample.srt\"")
|
320
|
+
expect(file.content).to include('I am sample translated text.')
|
321
|
+
end
|
322
|
+
end
|
323
|
+
|
324
|
+
end
|
325
|
+
|
326
|
+
end
|