fileturn 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -14
- data/.gitignore +1 -0
- data/README.md +49 -44
- data/fileturn.gemspec +1 -0
- data/lib/fileturn/errors.rb +14 -0
- data/lib/fileturn/http_client.rb +10 -8
- data/lib/fileturn/resources/account.rb +11 -35
- data/lib/fileturn/resources/conversion.rb +80 -0
- data/lib/fileturn/resources/resource.rb +0 -5
- data/lib/fileturn/version.rb +1 -1
- data/lib/fileturn.rb +6 -7
- data/spec/fileturn_spec.rb +5 -5
- data/spec/fixtures/vcr_cassettes/account_info.yml +24 -63
- data/spec/fixtures/vcr_cassettes/conversion_all_not_authorized.yml +48 -0
- data/spec/fixtures/vcr_cassettes/conversion_not_authorized.yml +48 -0
- data/spec/fixtures/vcr_cassettes/conversion_not_found.yml +48 -0
- data/spec/fixtures/vcr_cassettes/conversion_process_created.yml +52 -0
- data/spec/fixtures/vcr_cassettes/conversion_process_no_params.yml +97 -0
- data/spec/fixtures/vcr_cassettes/conversion_process_success.yml +50 -0
- data/spec/fixtures/vcr_cassettes/conversion_success.yml +50 -0
- data/spec/fixtures/vcr_cassettes/conversions_all.yml +50 -0
- data/spec/fixtures/vcr_cassettes/conversions_all_second.yml +97 -0
- data/spec/fixtures/vcr_cassettes/reload_.yml +52 -0
- data/spec/fixtures/vcr_cassettes/reload_done.yml +50 -0
- data/spec/resources/account_spec.rb +8 -23
- data/spec/resources/conversion_spec.rb +213 -0
- data/spec/resources/upload_spec.rb +35 -35
- data/spec/spec_helper.rb +1 -1
- data/spec/stub_http_client.rb +1 -1
- metadata +58 -61
- data/lib/fileturn/exceptions.rb +0 -30
- data/lib/fileturn/resources/file.rb +0 -112
- data/lib/fileturn/resources/notification.rb +0 -16
- data/spec/fixtures/vcr_cassettes/file_all.yml +0 -103
- data/spec/fixtures/vcr_cassettes/file_all_notifications.yml +0 -103
- data/spec/fixtures/vcr_cassettes/file_convert_no_params.yml +0 -87
- data/spec/fixtures/vcr_cassettes/file_convert_success.yml +0 -89
- data/spec/fixtures/vcr_cassettes/file_doesnt_upload_since_too_big.yml +0 -46
- data/spec/fixtures/vcr_cassettes/file_failed_.yml +0 -176
- data/spec/fixtures/vcr_cassettes/file_notifications.yml +0 -89
- data/spec/fixtures/vcr_cassettes/file_queued_.yml +0 -176
- data/spec/fixtures/vcr_cassettes/file_reload.yml +0 -132
- data/spec/fixtures/vcr_cassettes/file_success.yml +0 -89
- data/spec/fixtures/vcr_cassettes/file_success_.yml +0 -176
- data/spec/fixtures/vcr_cassettes/file_time_taken.yml +0 -176
- data/spec/fixtures/vcr_cassettes/file_unauthorized.yml +0 -87
- data/spec/fixtures/vcr_cassettes/file_upload_doc_queued.yml +0 -782
- data/spec/fixtures/vcr_cassettes/file_upload_not_enough_credits.yml +0 -130
- data/spec/fixtures/vcr_cassettes/file_upload_queued.yml +0 -203
- data/spec/fixtures/vcr_cassettes/upload_all.yml +0 -89
- data/spec/fixtures/vcr_cassettes/upload_one.yml +0 -89
- data/spec/fixtures/vcr_cassettes/upload_refetch.yml +0 -132
- data/spec/resources/file_spec.rb +0 -184
@@ -0,0 +1,213 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe FileTurn::Conversion do
|
4
|
+
|
5
|
+
let(:successful_conversion_id) { 'b120b954-82b2-41c6-bef2-c83b3462463b' }
|
6
|
+
|
7
|
+
describe '.find' do
|
8
|
+
it 'raises exception when not authorized' do
|
9
|
+
VCR.use_cassette('conversion_not_authorized') do
|
10
|
+
FileTurn.configure(api_token: '123')
|
11
|
+
expect { FileTurn::Conversion.find(successful_conversion_id) }.to raise_error(FileTurn::NotFoundError)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'raises exception when not found' do
|
16
|
+
VCR.use_cassette('conversion_not_found') do
|
17
|
+
expect { FileTurn::Conversion.find(123) }.to raise_error(FileTurn::NotFoundError)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'returns the conversion' do
|
22
|
+
VCR.use_cassette('conversion_success') do
|
23
|
+
conversion = FileTurn::Conversion.find(successful_conversion_id)
|
24
|
+
expect(conversion.id).to eq(successful_conversion_id)
|
25
|
+
expect(conversion.type).to eq('WordToPdf')
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'returns notification responses for conversion' do
|
30
|
+
VCR.use_cassette('conversion_success') do
|
31
|
+
conversion = FileTurn::Conversion.find(successful_conversion_id)
|
32
|
+
expect(conversion.notification_responses.count).to be(1)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '.all' do
|
38
|
+
it 'raises exception when not authorized' do
|
39
|
+
VCR.use_cassette('conversion_all_not_authorized') do
|
40
|
+
FileTurn.configure(api_token: '123')
|
41
|
+
expect { FileTurn::Conversion.all }.to raise_error(FileTurn::UnauthorizedError)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'fetches all the conversions' do
|
46
|
+
VCR.use_cassette('conversions_all') do
|
47
|
+
obj = FileTurn::Conversion.all
|
48
|
+
|
49
|
+
expect(obj.current_page).to be(1)
|
50
|
+
expect(obj.per_page).to be(20)
|
51
|
+
expect(obj.total_pages).to_not be_nil
|
52
|
+
expect(obj.total_conversions).to_not be_nil
|
53
|
+
|
54
|
+
expect(obj.conversions).to_not be(0)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'fetches 5 conversions from second page' do
|
59
|
+
VCR.use_cassette('conversions_all_second') do
|
60
|
+
obj = FileTurn::Conversion.all(page: 2, per: 5)
|
61
|
+
|
62
|
+
expect(obj.current_page).to be(2)
|
63
|
+
expect(obj.per_page).to be(5)
|
64
|
+
expect(obj.total_pages).to_not be_nil
|
65
|
+
expect(obj.total_conversions).to_not be_nil
|
66
|
+
|
67
|
+
expect(obj.conversions).to_not be(0)
|
68
|
+
|
69
|
+
expect(obj.conversions.first.class).to be(FileTurn::Conversion)
|
70
|
+
expect(obj.conversions.first.reload!.temporary_download_urls.count).to be(1)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe '.process!' do
|
76
|
+
it 'with no parameters' do
|
77
|
+
VCR.use_cassette('conversion_process_no_params') do
|
78
|
+
expect { FileTurn::Conversion.process!({}) }.to raise_error(FileTurn::BadRequestError)
|
79
|
+
|
80
|
+
begin
|
81
|
+
FileTurn::Conversion.process!({})
|
82
|
+
rescue FileTurn::BadRequestError => ex
|
83
|
+
expect(ex.errors).to include("Type can't be blank")
|
84
|
+
expect(ex.errors).to include("Source files can't be blank")
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'is created and successful' do
|
90
|
+
VCR.use_cassette('conversion_process_created') do
|
91
|
+
conv = FileTurn::Conversion.process!(url: "http://iiswc.org/iiswc2013/sample.doc", type: "WordToPdf")
|
92
|
+
expect(conv.created?).to be(true)
|
93
|
+
|
94
|
+
VCR.use_cassette('conversion_process_success') do
|
95
|
+
conv = FileTurn::Conversion.find(conv.id)
|
96
|
+
expect(conv.created?).to be(false)
|
97
|
+
expect(conv.completed?).to be(true)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
describe 'reload!' do
|
104
|
+
it 'fetches from server' do
|
105
|
+
VCR.use_cassette('reload!') do
|
106
|
+
conv = FileTurn::Conversion.process!(url: "http://iiswc.org/iiswc2013/sample.doc", type: "WordToPdf")
|
107
|
+
expect(conv.created?).to be(true)
|
108
|
+
|
109
|
+
VCR.use_cassette('reload_done') do
|
110
|
+
conv.reload!
|
111
|
+
expect(conv.created?).to be(false)
|
112
|
+
expect(conv.completed?).to be(true)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
# describe 'upload' do
|
119
|
+
# it 'converts an uploaded file' do
|
120
|
+
# VCR.use_cassette('file_upload_queued') do
|
121
|
+
# file = FileTurn::File.convert(:file => File.open('README.md'), :convert_to => :pdf)
|
122
|
+
# file.queued?.should == true
|
123
|
+
# end
|
124
|
+
# end
|
125
|
+
|
126
|
+
# it 'converts and uploads a doc file' do
|
127
|
+
# VCR.use_cassette('file_upload_doc_queued') do
|
128
|
+
# file = FileTurn::File.convert(:file => File.open('./spec/data/testfile.docx'), :convert_to => :pdf)
|
129
|
+
# file.queued?.should == true
|
130
|
+
# end
|
131
|
+
# end
|
132
|
+
|
133
|
+
# it 'doesnt upload a file if there are not enough credits' do
|
134
|
+
# VCR.use_cassette('file_upload_not_enough_credits') do
|
135
|
+
# user_without_credits
|
136
|
+
# file = FileTurn::File.convert(:file => File.open('./spec/data/testfile.docx'), :convert_to => :pdf)
|
137
|
+
# file.queued?.should == nil
|
138
|
+
# file.errors.should == {'credits'=>['need more credits to convert files']}
|
139
|
+
|
140
|
+
# FileTurn::Upload.all.uploads.count.should == 0
|
141
|
+
# end
|
142
|
+
# end
|
143
|
+
|
144
|
+
# it 'doesnt upload since file is too big' do
|
145
|
+
# user_without_credits
|
146
|
+
# FileTurn::Account.should_receive(:max_file_size_in_bytes).and_return(0)
|
147
|
+
# file = FileTurn::File.convert(:file => File.open('./spec/data/testfile.docx'), :convert_to => :pdf)
|
148
|
+
# file.queued?.should == nil
|
149
|
+
# file.errors.should == {'file_size'=>['is too big']}
|
150
|
+
|
151
|
+
# VCR.use_cassette('file_doesnt_upload_since_too_big') do
|
152
|
+
# FileTurn::Upload.all.uploads.count.should == 0
|
153
|
+
# end
|
154
|
+
# end
|
155
|
+
# end
|
156
|
+
|
157
|
+
# it '#success?' do
|
158
|
+
# VCR.use_cassette('file_success?') do
|
159
|
+
# expected_results = {
|
160
|
+
# retrieve_successful_file => true,
|
161
|
+
# retrieve_failed_file => false,
|
162
|
+
# retrieve_queued_file => false
|
163
|
+
# }
|
164
|
+
|
165
|
+
# expected_results.each { |f, r| f.success?.should == r }
|
166
|
+
# end
|
167
|
+
# end
|
168
|
+
|
169
|
+
# it '#failed?' do
|
170
|
+
# VCR.use_cassette('file_failed?') do
|
171
|
+
# expected_results = {
|
172
|
+
# retrieve_successful_file => false,
|
173
|
+
# retrieve_failed_file => true,
|
174
|
+
# retrieve_queued_file => false
|
175
|
+
# }
|
176
|
+
|
177
|
+
# expected_results.each { |f, r| f.failed?.should == r }
|
178
|
+
# end
|
179
|
+
# end
|
180
|
+
|
181
|
+
# it '#queued?' do
|
182
|
+
# VCR.use_cassette('file_queued?') do
|
183
|
+
# expected_results = {
|
184
|
+
# retrieve_successful_file => false,
|
185
|
+
# retrieve_failed_file => false,
|
186
|
+
# retrieve_queued_file => true
|
187
|
+
# }
|
188
|
+
|
189
|
+
# expected_results.each { |f, r| f.queued?.should == r }
|
190
|
+
# end
|
191
|
+
# end
|
192
|
+
|
193
|
+
# it '#reload returns expected results' do
|
194
|
+
# VCR.use_cassette('file_reload') do
|
195
|
+
# retrieve_successful_file.should_receive(:parse_json_params)
|
196
|
+
# old_result = retrieve_successful_file.params
|
197
|
+
# retrieve_successful_file.reload.params.should == old_result
|
198
|
+
# end
|
199
|
+
# end
|
200
|
+
|
201
|
+
# it '#time_taken returns expected results' do
|
202
|
+
# VCR.use_cassette('file_time_taken') do
|
203
|
+
# expected_results = {
|
204
|
+
# retrieve_successful_file => 105.926075,
|
205
|
+
# retrieve_failed_file => nil,
|
206
|
+
# retrieve_queued_file => nil
|
207
|
+
# }
|
208
|
+
|
209
|
+
# expected_results.each { |f, r| f.time_taken.should == r }
|
210
|
+
# end
|
211
|
+
# end
|
212
|
+
|
213
|
+
end
|
@@ -1,41 +1,41 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
1
|
+
# require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
2
|
|
3
|
-
describe FileTurn::Upload do
|
3
|
+
# describe FileTurn::Upload do
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
5
|
+
# describe '.all' do
|
6
|
+
# it 'retrives all the uploaded files' do
|
7
|
+
# VCR.use_cassette('upload all') do
|
8
|
+
# obj = FileTurn::Upload.all
|
9
|
+
# obj.uploads.count.should == 20
|
10
|
+
# obj.current_page.should == 1
|
11
|
+
# obj.per_page.should == 20
|
12
|
+
# obj.total_pages.should >= 4
|
13
|
+
# end
|
14
|
+
# end
|
15
|
+
# end
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
17
|
+
# describe '.find' do
|
18
|
+
# it 'fetches a single uploaded file' do
|
19
|
+
# VCR.use_cassette('upload one') do
|
20
|
+
# upload = FileTurn::Upload.find(19)
|
21
|
+
# upload.id.should == 19
|
22
|
+
# upload.policy.should_not be_empty
|
23
|
+
# upload.signature.should_not be_empty
|
24
|
+
# upload.aws_access_key_id.should_not be_empty
|
25
|
+
# upload.key.should_not be_empty
|
26
|
+
# upload.url.should_not be_empty
|
27
|
+
# end
|
28
|
+
# end
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
30
|
+
# it 'reload fetches the info again' do
|
31
|
+
# VCR.use_cassette('upload refetch') do
|
32
|
+
# upload = FileTurn::Upload.find(19)
|
33
|
+
# old_params = upload.params
|
34
|
+
# upload.should_receive(:parse_json_params)
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
36
|
+
# upload.reload.params.should == old_params
|
37
|
+
# end
|
38
|
+
# end
|
39
|
+
# end
|
40
40
|
|
41
|
-
end
|
41
|
+
# end
|
data/spec/spec_helper.rb
CHANGED
data/spec/stub_http_client.rb
CHANGED
metadata
CHANGED
@@ -1,97 +1,111 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fileturn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nisarg Shah
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: recursive-open-struct
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
25
39
|
- !ruby/object:Gem::Version
|
26
40
|
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
|
-
- - ~>
|
45
|
+
- - "~>"
|
32
46
|
- !ruby/object:Gem::Version
|
33
47
|
version: '1.3'
|
34
48
|
type: :development
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
|
-
- - ~>
|
52
|
+
- - "~>"
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: '1.3'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rake
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
|
-
- -
|
59
|
+
- - ">="
|
46
60
|
- !ruby/object:Gem::Version
|
47
61
|
version: '0'
|
48
62
|
type: :development
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
|
-
- -
|
66
|
+
- - ">="
|
53
67
|
- !ruby/object:Gem::Version
|
54
68
|
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: rspec
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
|
-
- -
|
73
|
+
- - ">="
|
60
74
|
- !ruby/object:Gem::Version
|
61
75
|
version: '0'
|
62
76
|
type: :development
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
|
-
- -
|
80
|
+
- - ">="
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: vcr
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
|
-
- -
|
87
|
+
- - ">="
|
74
88
|
- !ruby/object:Gem::Version
|
75
89
|
version: '0'
|
76
90
|
type: :development
|
77
91
|
prerelease: false
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
79
93
|
requirements:
|
80
|
-
- -
|
94
|
+
- - ">="
|
81
95
|
- !ruby/object:Gem::Version
|
82
96
|
version: '0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: webmock
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
86
100
|
requirements:
|
87
|
-
- -
|
101
|
+
- - ">="
|
88
102
|
- !ruby/object:Gem::Version
|
89
103
|
version: '0'
|
90
104
|
type: :development
|
91
105
|
prerelease: false
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
|
-
- -
|
108
|
+
- - ">="
|
95
109
|
- !ruby/object:Gem::Version
|
96
110
|
version: '0'
|
97
111
|
description: FileTurn Client
|
@@ -101,18 +115,17 @@ executables: []
|
|
101
115
|
extensions: []
|
102
116
|
extra_rdoc_files: []
|
103
117
|
files:
|
104
|
-
- .gitignore
|
118
|
+
- ".gitignore"
|
105
119
|
- Gemfile
|
106
120
|
- LICENSE.txt
|
107
121
|
- README.md
|
108
122
|
- Rakefile
|
109
123
|
- fileturn.gemspec
|
110
124
|
- lib/fileturn.rb
|
111
|
-
- lib/fileturn/
|
125
|
+
- lib/fileturn/errors.rb
|
112
126
|
- lib/fileturn/http_client.rb
|
113
127
|
- lib/fileturn/resources/account.rb
|
114
|
-
- lib/fileturn/resources/
|
115
|
-
- lib/fileturn/resources/notification.rb
|
128
|
+
- lib/fileturn/resources/conversion.rb
|
116
129
|
- lib/fileturn/resources/resource.rb
|
117
130
|
- lib/fileturn/resources/upload.rb
|
118
131
|
- lib/fileturn/version.rb
|
@@ -121,27 +134,19 @@ files:
|
|
121
134
|
- spec/data/testfile.docx
|
122
135
|
- spec/fileturn_spec.rb
|
123
136
|
- spec/fixtures/vcr_cassettes/account_info.yml
|
124
|
-
- spec/fixtures/vcr_cassettes/
|
125
|
-
- spec/fixtures/vcr_cassettes/
|
126
|
-
- spec/fixtures/vcr_cassettes/
|
127
|
-
- spec/fixtures/vcr_cassettes/
|
128
|
-
- spec/fixtures/vcr_cassettes/
|
129
|
-
- spec/fixtures/vcr_cassettes/
|
130
|
-
- spec/fixtures/vcr_cassettes/
|
131
|
-
- spec/fixtures/vcr_cassettes/
|
132
|
-
- spec/fixtures/vcr_cassettes/
|
133
|
-
- spec/fixtures/vcr_cassettes/
|
134
|
-
- spec/fixtures/vcr_cassettes/
|
135
|
-
- spec/fixtures/vcr_cassettes/file_time_taken.yml
|
136
|
-
- spec/fixtures/vcr_cassettes/file_unauthorized.yml
|
137
|
-
- spec/fixtures/vcr_cassettes/file_upload_doc_queued.yml
|
138
|
-
- spec/fixtures/vcr_cassettes/file_upload_not_enough_credits.yml
|
139
|
-
- spec/fixtures/vcr_cassettes/file_upload_queued.yml
|
140
|
-
- spec/fixtures/vcr_cassettes/upload_all.yml
|
141
|
-
- spec/fixtures/vcr_cassettes/upload_one.yml
|
142
|
-
- spec/fixtures/vcr_cassettes/upload_refetch.yml
|
137
|
+
- spec/fixtures/vcr_cassettes/conversion_all_not_authorized.yml
|
138
|
+
- spec/fixtures/vcr_cassettes/conversion_not_authorized.yml
|
139
|
+
- spec/fixtures/vcr_cassettes/conversion_not_found.yml
|
140
|
+
- spec/fixtures/vcr_cassettes/conversion_process_created.yml
|
141
|
+
- spec/fixtures/vcr_cassettes/conversion_process_no_params.yml
|
142
|
+
- spec/fixtures/vcr_cassettes/conversion_process_success.yml
|
143
|
+
- spec/fixtures/vcr_cassettes/conversion_success.yml
|
144
|
+
- spec/fixtures/vcr_cassettes/conversions_all.yml
|
145
|
+
- spec/fixtures/vcr_cassettes/conversions_all_second.yml
|
146
|
+
- spec/fixtures/vcr_cassettes/reload_.yml
|
147
|
+
- spec/fixtures/vcr_cassettes/reload_done.yml
|
143
148
|
- spec/resources/account_spec.rb
|
144
|
-
- spec/resources/
|
149
|
+
- spec/resources/conversion_spec.rb
|
145
150
|
- spec/resources/upload_spec.rb
|
146
151
|
- spec/spec_helper.rb
|
147
152
|
- spec/stub_http_client.rb
|
@@ -154,17 +159,17 @@ require_paths:
|
|
154
159
|
- lib
|
155
160
|
required_ruby_version: !ruby/object:Gem::Requirement
|
156
161
|
requirements:
|
157
|
-
- -
|
162
|
+
- - ">="
|
158
163
|
- !ruby/object:Gem::Version
|
159
164
|
version: '0'
|
160
165
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
161
166
|
requirements:
|
162
|
-
- -
|
167
|
+
- - ">="
|
163
168
|
- !ruby/object:Gem::Version
|
164
169
|
version: '0'
|
165
170
|
requirements: []
|
166
171
|
rubyforge_project:
|
167
|
-
rubygems_version: 2.
|
172
|
+
rubygems_version: 2.6.14
|
168
173
|
signing_key:
|
169
174
|
specification_version: 4
|
170
175
|
summary: FileTurn Client
|
@@ -174,27 +179,19 @@ test_files:
|
|
174
179
|
- spec/data/testfile.docx
|
175
180
|
- spec/fileturn_spec.rb
|
176
181
|
- spec/fixtures/vcr_cassettes/account_info.yml
|
177
|
-
- spec/fixtures/vcr_cassettes/
|
178
|
-
- spec/fixtures/vcr_cassettes/
|
179
|
-
- spec/fixtures/vcr_cassettes/
|
180
|
-
- spec/fixtures/vcr_cassettes/
|
181
|
-
- spec/fixtures/vcr_cassettes/
|
182
|
-
- spec/fixtures/vcr_cassettes/
|
183
|
-
- spec/fixtures/vcr_cassettes/
|
184
|
-
- spec/fixtures/vcr_cassettes/
|
185
|
-
- spec/fixtures/vcr_cassettes/
|
186
|
-
- spec/fixtures/vcr_cassettes/
|
187
|
-
- spec/fixtures/vcr_cassettes/
|
188
|
-
- spec/fixtures/vcr_cassettes/file_time_taken.yml
|
189
|
-
- spec/fixtures/vcr_cassettes/file_unauthorized.yml
|
190
|
-
- spec/fixtures/vcr_cassettes/file_upload_doc_queued.yml
|
191
|
-
- spec/fixtures/vcr_cassettes/file_upload_not_enough_credits.yml
|
192
|
-
- spec/fixtures/vcr_cassettes/file_upload_queued.yml
|
193
|
-
- spec/fixtures/vcr_cassettes/upload_all.yml
|
194
|
-
- spec/fixtures/vcr_cassettes/upload_one.yml
|
195
|
-
- spec/fixtures/vcr_cassettes/upload_refetch.yml
|
182
|
+
- spec/fixtures/vcr_cassettes/conversion_all_not_authorized.yml
|
183
|
+
- spec/fixtures/vcr_cassettes/conversion_not_authorized.yml
|
184
|
+
- spec/fixtures/vcr_cassettes/conversion_not_found.yml
|
185
|
+
- spec/fixtures/vcr_cassettes/conversion_process_created.yml
|
186
|
+
- spec/fixtures/vcr_cassettes/conversion_process_no_params.yml
|
187
|
+
- spec/fixtures/vcr_cassettes/conversion_process_success.yml
|
188
|
+
- spec/fixtures/vcr_cassettes/conversion_success.yml
|
189
|
+
- spec/fixtures/vcr_cassettes/conversions_all.yml
|
190
|
+
- spec/fixtures/vcr_cassettes/conversions_all_second.yml
|
191
|
+
- spec/fixtures/vcr_cassettes/reload_.yml
|
192
|
+
- spec/fixtures/vcr_cassettes/reload_done.yml
|
196
193
|
- spec/resources/account_spec.rb
|
197
|
-
- spec/resources/
|
194
|
+
- spec/resources/conversion_spec.rb
|
198
195
|
- spec/resources/upload_spec.rb
|
199
196
|
- spec/spec_helper.rb
|
200
197
|
- spec/stub_http_client.rb
|
data/lib/fileturn/exceptions.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
module FileTurn
|
2
|
-
|
3
|
-
class FileTurnException < Exception
|
4
|
-
attr_reader :resp
|
5
|
-
def initialize(resp)
|
6
|
-
@resp = resp
|
7
|
-
end
|
8
|
-
|
9
|
-
def to_s
|
10
|
-
resp
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
class UnauthorizedException < FileTurnException; end;
|
15
|
-
class InternalServerException < FileTurnException; end;
|
16
|
-
|
17
|
-
class UnprocessableEntityException < FileTurnException
|
18
|
-
attr_reader :parsed_response
|
19
|
-
|
20
|
-
def initialize(resp)
|
21
|
-
super(resp)
|
22
|
-
@parsed_response = OpenStruct.new(JSON.parse(resp.body))
|
23
|
-
end
|
24
|
-
|
25
|
-
def to_s
|
26
|
-
@parsed_response.to_s
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|