AsposeDiagramCloud 18.10 → 20.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/AsposeDiagramCloud.gemspec +46 -0
- data/Gemfile +7 -0
- data/README.md +74 -0
- data/Rakefile +8 -0
- data/git_push.sh +55 -0
- data/lib/AsposeDiagramCloud.rb +85 -0
- data/lib/AsposeDiagramCloud/api/diagram_api.rb +768 -0
- data/lib/AsposeDiagramCloud/api/o_auth_api.rb +93 -0
- data/lib/AsposeDiagramCloud/api/storage_api.rb +905 -0
- data/lib/AsposeDiagramCloud/api_client.rb +391 -0
- data/lib/AsposeDiagramCloud/api_error.rb +38 -0
- data/lib/AsposeDiagramCloud/configuration.rb +209 -0
- data/lib/AsposeDiagramCloud/models/access_token_response.rb +251 -0
- data/lib/AsposeDiagramCloud/models/api_response_of_list_of_page_data.rb +190 -0
- data/lib/AsposeDiagramCloud/models/create_new_response.rb +188 -0
- data/lib/AsposeDiagramCloud/models/diagram_save_options.rb +244 -0
- data/lib/AsposeDiagramCloud/models/disc_usage.rb +209 -0
- data/lib/AsposeDiagramCloud/models/draw_shape_data.rb +262 -0
- data/lib/AsposeDiagramCloud/models/ellipse_data.rb +262 -0
- data/lib/AsposeDiagramCloud/models/error.rb +219 -0
- data/lib/AsposeDiagramCloud/models/error_details.rb +204 -0
- data/lib/AsposeDiagramCloud/models/file_version.rb +264 -0
- data/lib/AsposeDiagramCloud/models/file_versions.rb +191 -0
- data/lib/AsposeDiagramCloud/models/files_list.rb +191 -0
- data/lib/AsposeDiagramCloud/models/files_upload_result.rb +203 -0
- data/lib/AsposeDiagramCloud/models/html_save_options.rb +330 -0
- data/lib/AsposeDiagramCloud/models/image_save_options.rb +492 -0
- data/lib/AsposeDiagramCloud/models/line_data.rb +273 -0
- data/lib/AsposeDiagramCloud/models/modify_response.rb +202 -0
- data/lib/AsposeDiagramCloud/models/object_exist.rb +209 -0
- data/lib/AsposeDiagramCloud/models/page_data.rb +216 -0
- data/lib/AsposeDiagramCloud/models/page_setting.rb +219 -0
- data/lib/AsposeDiagramCloud/models/page_size.rb +221 -0
- data/lib/AsposeDiagramCloud/models/pdf_digital_signature_details.rb +248 -0
- data/lib/AsposeDiagramCloud/models/pdf_encryption_details.rb +260 -0
- data/lib/AsposeDiagramCloud/models/pdf_save_options.rb +408 -0
- data/lib/AsposeDiagramCloud/models/point_f.rb +221 -0
- data/lib/AsposeDiagramCloud/models/polyline_data.rb +273 -0
- data/lib/AsposeDiagramCloud/models/rectangle_f.rb +333 -0
- data/lib/AsposeDiagramCloud/models/rendering_save_options.rb +276 -0
- data/lib/AsposeDiagramCloud/models/saa_spose_response.rb +179 -0
- data/lib/AsposeDiagramCloud/models/save_as_response.rb +208 -0
- data/lib/AsposeDiagramCloud/models/save_options_model.rb +235 -0
- data/lib/AsposeDiagramCloud/models/save_options_request.rb +206 -0
- data/lib/AsposeDiagramCloud/models/shape_data.rb +221 -0
- data/lib/AsposeDiagramCloud/models/shape_style_data.rb +189 -0
- data/lib/AsposeDiagramCloud/models/storage_exist.rb +194 -0
- data/lib/AsposeDiagramCloud/models/storage_file.rb +239 -0
- data/lib/AsposeDiagramCloud/models/svg_save_options.rb +321 -0
- data/lib/AsposeDiagramCloud/models/swf_save_options.rb +271 -0
- data/lib/AsposeDiagramCloud/models/text_style_data.rb +253 -0
- data/lib/AsposeDiagramCloud/models/upload_response.rb +188 -0
- data/lib/AsposeDiagramCloud/models/xaml_save_options.rb +262 -0
- data/lib/AsposeDiagramCloud/models/xps_save_options.rb +271 -0
- data/lib/AsposeDiagramCloud/version.rb +15 -0
- data/spec/_spec.rb +308 -0
- data/spec/api/test_convert_spec.rb +308 -0
- data/spec/api/test_drawing_spec.rb +136 -0
- data/spec/api/test_page_spec.rb +92 -0
- data/spec/api_client_spec.rb +226 -0
- data/spec/configuration_spec.rb +42 -0
- data/spec/spec_helper.rb +120 -0
- data/testData/FileUpload.vdx +437 -0
- metadata +118 -49
@@ -0,0 +1,136 @@
|
|
1
|
+
=begin
|
2
|
+
#Aspose.Diagram Cloud API Reference
|
3
|
+
|
4
|
+
#No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
|
5
|
+
|
6
|
+
OpenAPI spec version: 3.0
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 2.3.0-SNAPSHOT
|
10
|
+
|
11
|
+
=end
|
12
|
+
#rspec spec/api/test_convert_spec.rb
|
13
|
+
|
14
|
+
require 'spec_helper'
|
15
|
+
require 'json'
|
16
|
+
|
17
|
+
$fileName="drawingTest.vsdx"
|
18
|
+
|
19
|
+
# Unit tests for AsposeDiagramCloud::DiagramApi
|
20
|
+
# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
|
21
|
+
# Please update as you see appropriate
|
22
|
+
describe 'DrawingApi' do
|
23
|
+
before do
|
24
|
+
# run before each test
|
25
|
+
#@instance = AsposeDiagramCloud::DiagramApi.new($grant_type,$client_id,$client_secret)
|
26
|
+
end
|
27
|
+
|
28
|
+
after do
|
29
|
+
# run after each test
|
30
|
+
end
|
31
|
+
|
32
|
+
describe 'test an instance of DiagramApi' do
|
33
|
+
it 'should create an instance of DiagramApi' do
|
34
|
+
expect($diagramApi).to be_instance_of(AsposeDiagramCloud::DiagramApi)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# unit tests for create_new
|
39
|
+
# Create Empty file into the specified format.
|
40
|
+
#
|
41
|
+
# @param name The document name.
|
42
|
+
# @param [Hash] opts the optional parameters
|
43
|
+
# @option opts [String] :folder The document folder.
|
44
|
+
# @option opts [BOOLEAN] :is_overwrite If true overwrite the same name file.The default value is false
|
45
|
+
# @return [CreateNewResponse]
|
46
|
+
describe 'create_new test' do
|
47
|
+
it "should work" do
|
48
|
+
name = $fileName
|
49
|
+
folder = $storageTestFOLDER
|
50
|
+
is_overwrite=true
|
51
|
+
result=$diagramApi.create_new(name, {:name=>name, :is_overwrite=>is_overwrite, :folder=>folder})
|
52
|
+
#print(result)
|
53
|
+
expect(result.created).not_to be_empty
|
54
|
+
#assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe 'put_draw_line test' do
|
59
|
+
it "should work" do
|
60
|
+
folder = $storageTestFOLDER
|
61
|
+
draw_data=AsposeDiagramCloud::LineData.new
|
62
|
+
draw_data.pin_x = 1
|
63
|
+
draw_data.pin_y = 2
|
64
|
+
draw_data.width = 1
|
65
|
+
draw_data.height = 1
|
66
|
+
draw_data.points =[AsposeDiagramCloud::PointF.new({"X"=>1,"Y"=>0}),AsposeDiagramCloud::PointF.new({"X"=>1,"Y"=>1})]
|
67
|
+
draw_data.text = "test draw line"
|
68
|
+
shapeStyleData = AsposeDiagramCloud::ShapeStyleData.new
|
69
|
+
shapeStyleData.back_ground_color = "#FF0000"
|
70
|
+
textStyleData = AsposeDiagramCloud::TextStyleData.new
|
71
|
+
textStyleData.font_size = 0.2
|
72
|
+
textStyleData.font_name = "Times New Roman"
|
73
|
+
draw_data.shape_style_data = shapeStyleData
|
74
|
+
draw_data.text_style_data = textStyleData
|
75
|
+
result=$diagramApi.put_draw_line($fileName,"Page-0", draw_data,{:folder=>folder})
|
76
|
+
#print(result)
|
77
|
+
expect(result.is_success).to be_truthy
|
78
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
describe 'put_draw_ellipse test' do
|
83
|
+
it "should work" do
|
84
|
+
folder = $storageTestFOLDER
|
85
|
+
draw_data=AsposeDiagramCloud::EllipseData.new
|
86
|
+
draw_data.pin_x = 5
|
87
|
+
draw_data.pin_y = 5
|
88
|
+
draw_data.width = 1
|
89
|
+
draw_data.height = 1
|
90
|
+
draw_data.text = "test draw ellipse"
|
91
|
+
shapeStyleData = AsposeDiagramCloud::ShapeStyleData.new
|
92
|
+
shapeStyleData.back_ground_color = "#FF0000"
|
93
|
+
textStyleData = AsposeDiagramCloud::TextStyleData.new
|
94
|
+
textStyleData.font_size = 0.2
|
95
|
+
textStyleData.font_name = "Times New Roman"
|
96
|
+
draw_data.shape_style_data = shapeStyleData
|
97
|
+
draw_data.text_style_data = textStyleData
|
98
|
+
result=$diagramApi.put_draw_ellipse($fileName,"Page-0", draw_data,{:folder=>folder})
|
99
|
+
#print(result)
|
100
|
+
expect(result.is_success).to be_truthy
|
101
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
describe 'put_draw_polyline test' do
|
106
|
+
it "should work" do
|
107
|
+
folder = $storageTestFOLDER
|
108
|
+
draw_data=AsposeDiagramCloud::PolylineData.new
|
109
|
+
draw_data.pin_x = 3
|
110
|
+
draw_data.pin_y = 3
|
111
|
+
draw_data.width = 1
|
112
|
+
draw_data.height = 1
|
113
|
+
draw_data.points =[AsposeDiagramCloud::PointF.new({"X"=>0,"Y"=>0}),
|
114
|
+
AsposeDiagramCloud::PointF.new({"X"=>0,"Y"=>1}),
|
115
|
+
AsposeDiagramCloud::PointF.new({"X"=>1,"Y"=>1}),
|
116
|
+
AsposeDiagramCloud::PointF.new({"X"=>1,"Y"=>0})
|
117
|
+
]
|
118
|
+
draw_data.text = "test draw polyline"
|
119
|
+
shapeStyleData = AsposeDiagramCloud::ShapeStyleData.new
|
120
|
+
shapeStyleData.back_ground_color = "#FF0000"
|
121
|
+
textStyleData = AsposeDiagramCloud::TextStyleData.new
|
122
|
+
textStyleData.font_size = 0.2
|
123
|
+
textStyleData.font_name = "Times New Roman"
|
124
|
+
draw_data.shape_style_data = shapeStyleData
|
125
|
+
draw_data.text_style_data = textStyleData
|
126
|
+
result=$diagramApi.put_draw_polyline($fileName,"Page-0", draw_data,{:folder=>folder})
|
127
|
+
#print(result)
|
128
|
+
expect(result.is_success).to be_truthy
|
129
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
=begin
|
2
|
+
#Aspose.Diagram Cloud API Reference
|
3
|
+
|
4
|
+
#No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
|
5
|
+
|
6
|
+
OpenAPI spec version: 3.0
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 2.3.0-SNAPSHOT
|
10
|
+
|
11
|
+
=end
|
12
|
+
#rspec spec/api/test_convert_spec.rb
|
13
|
+
|
14
|
+
require 'spec_helper'
|
15
|
+
require 'json'
|
16
|
+
|
17
|
+
$fileName="pageTest.vsdx"
|
18
|
+
|
19
|
+
# Unit tests for AsposeDiagramCloud::DiagramApi
|
20
|
+
# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
|
21
|
+
# Please update as you see appropriate
|
22
|
+
describe 'PageApi' do
|
23
|
+
before do
|
24
|
+
# run before each test
|
25
|
+
#@instance = AsposeDiagramCloud::DiagramApi.new($grant_type,$client_id,$client_secret)
|
26
|
+
end
|
27
|
+
|
28
|
+
after do
|
29
|
+
# run after each test
|
30
|
+
end
|
31
|
+
|
32
|
+
describe 'test an instance of DiagramApi' do
|
33
|
+
it 'should create an instance of DiagramApi' do
|
34
|
+
expect($diagramApi).to be_instance_of(AsposeDiagramCloud::DiagramApi)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# unit tests for create_new
|
39
|
+
# Create Empty file into the specified format.
|
40
|
+
#
|
41
|
+
# @param name The document name.
|
42
|
+
# @param [Hash] opts the optional parameters
|
43
|
+
# @option opts [String] :folder The document folder.
|
44
|
+
# @option opts [BOOLEAN] :is_overwrite If true overwrite the same name file.The default value is false
|
45
|
+
# @return [CreateNewResponse]
|
46
|
+
describe 'create_new test' do
|
47
|
+
it "should work" do
|
48
|
+
name = $fileName
|
49
|
+
folder = $storageTestFOLDER
|
50
|
+
is_overwrite=true
|
51
|
+
result=$diagramApi.create_new(name, {:name=>name, :is_overwrite=>is_overwrite, :folder=>folder})
|
52
|
+
#print(result)
|
53
|
+
expect(result.created).not_to be_empty
|
54
|
+
#assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe 'put_new_page test' do
|
59
|
+
it "should work" do
|
60
|
+
folder = $storageTestFOLDER
|
61
|
+
result=$diagramApi.put_new_page($fileName,"newPage", {:folder=>folder})
|
62
|
+
#print(result)
|
63
|
+
expect(result.is_success).to be_truthy
|
64
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe 'post_page_setup test' do
|
69
|
+
it "should work" do
|
70
|
+
folder = $storageTestFOLDER
|
71
|
+
setting=AsposeDiagramCloud::PageSetting.new
|
72
|
+
setting.page_width=2
|
73
|
+
setting.page_height=2
|
74
|
+
result=$diagramApi.post_page_setup($fileName,"Page-0",setting, {:folder=>folder})
|
75
|
+
#print(result)
|
76
|
+
expect(result.is_success).to be_truthy
|
77
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe 'get_pages test' do
|
82
|
+
it "should work" do
|
83
|
+
folder = $storageTestFOLDER
|
84
|
+
result=$diagramApi.get_pages($fileName, {:folder=>folder})
|
85
|
+
print(result.model.size)
|
86
|
+
expect(result.model.size).to be > 0
|
87
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
|
92
|
+
end
|
@@ -0,0 +1,226 @@
|
|
1
|
+
=begin
|
2
|
+
#Aspose.Diagram Cloud API Reference
|
3
|
+
|
4
|
+
#No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
|
5
|
+
|
6
|
+
OpenAPI spec version: 3.0
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 2.3.0-SNAPSHOT
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'spec_helper'
|
14
|
+
|
15
|
+
describe AsposeDiagramCloud::ApiClient do
|
16
|
+
context 'initialization' do
|
17
|
+
context 'URL stuff' do
|
18
|
+
context 'host' do
|
19
|
+
it 'removes http from host' do
|
20
|
+
AsposeDiagramCloud.configure { |c| c.host = 'http://example.com' }
|
21
|
+
expect(AsposeDiagramCloud::Configuration.default.host).to eq('example.com')
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'removes https from host' do
|
25
|
+
AsposeDiagramCloud.configure { |c| c.host = 'https://wookiee.com' }
|
26
|
+
expect(AsposeDiagramCloud::ApiClient.default.config.host).to eq('wookiee.com')
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'removes trailing path from host' do
|
30
|
+
AsposeDiagramCloud.configure { |c| c.host = 'hobo.com/v4' }
|
31
|
+
expect(AsposeDiagramCloud::Configuration.default.host).to eq('hobo.com')
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'base_path' do
|
36
|
+
it "prepends a slash to base_path" do
|
37
|
+
AsposeDiagramCloud.configure { |c| c.base_path = 'v4/dog' }
|
38
|
+
expect(AsposeDiagramCloud::Configuration.default.base_path).to eq('/v4/dog')
|
39
|
+
end
|
40
|
+
|
41
|
+
it "doesn't prepend a slash if one is already there" do
|
42
|
+
AsposeDiagramCloud.configure { |c| c.base_path = '/v4/dog' }
|
43
|
+
expect(AsposeDiagramCloud::Configuration.default.base_path).to eq('/v4/dog')
|
44
|
+
end
|
45
|
+
|
46
|
+
it "ends up as a blank string if nil" do
|
47
|
+
AsposeDiagramCloud.configure { |c| c.base_path = nil }
|
48
|
+
expect(AsposeDiagramCloud::Configuration.default.base_path).to eq('')
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "params_encoding in #build_request" do
|
55
|
+
let(:config) { AsposeDiagramCloud::Configuration.new }
|
56
|
+
let(:api_client) { AsposeDiagramCloud::ApiClient.new(config) }
|
57
|
+
|
58
|
+
it "defaults to nil" do
|
59
|
+
expect(AsposeDiagramCloud::Configuration.default.params_encoding).to eq(nil)
|
60
|
+
expect(config.params_encoding).to eq(nil)
|
61
|
+
|
62
|
+
request = api_client.build_request(:get, '/test')
|
63
|
+
expect(request.options[:params_encoding]).to eq(nil)
|
64
|
+
end
|
65
|
+
|
66
|
+
it "can be customized" do
|
67
|
+
config.params_encoding = :multi
|
68
|
+
request = api_client.build_request(:get, '/test')
|
69
|
+
expect(request.options[:params_encoding]).to eq(:multi)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe "timeout in #build_request" do
|
74
|
+
let(:config) { AsposeDiagramCloud::Configuration.new }
|
75
|
+
let(:api_client) { AsposeDiagramCloud::ApiClient.new(config) }
|
76
|
+
|
77
|
+
it "defaults to 0" do
|
78
|
+
expect(AsposeDiagramCloud::Configuration.default.timeout).to eq(0)
|
79
|
+
expect(config.timeout).to eq(0)
|
80
|
+
|
81
|
+
request = api_client.build_request(:get, '/test')
|
82
|
+
expect(request.options[:timeout]).to eq(0)
|
83
|
+
end
|
84
|
+
|
85
|
+
it "can be customized" do
|
86
|
+
config.timeout = 100
|
87
|
+
request = api_client.build_request(:get, '/test')
|
88
|
+
expect(request.options[:timeout]).to eq(100)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe "#deserialize" do
|
93
|
+
it "handles Array<Integer>" do
|
94
|
+
api_client = AsposeDiagramCloud::ApiClient.new
|
95
|
+
headers = {'Content-Type' => 'application/json'}
|
96
|
+
response = double('response', headers: headers, body: '[12, 34]')
|
97
|
+
data = api_client.deserialize(response, 'Array<Integer>')
|
98
|
+
expect(data).to be_instance_of(Array)
|
99
|
+
expect(data).to eq([12, 34])
|
100
|
+
end
|
101
|
+
|
102
|
+
it "handles Array<Array<Integer>>" do
|
103
|
+
api_client = AsposeDiagramCloud::ApiClient.new
|
104
|
+
headers = {'Content-Type' => 'application/json'}
|
105
|
+
response = double('response', headers: headers, body: '[[12, 34], [56]]')
|
106
|
+
data = api_client.deserialize(response, 'Array<Array<Integer>>')
|
107
|
+
expect(data).to be_instance_of(Array)
|
108
|
+
expect(data).to eq([[12, 34], [56]])
|
109
|
+
end
|
110
|
+
|
111
|
+
it "handles Hash<String, String>" do
|
112
|
+
api_client = AsposeDiagramCloud::ApiClient.new
|
113
|
+
headers = {'Content-Type' => 'application/json'}
|
114
|
+
response = double('response', headers: headers, body: '{"message": "Hello"}')
|
115
|
+
data = api_client.deserialize(response, 'Hash<String, String>')
|
116
|
+
expect(data).to be_instance_of(Hash)
|
117
|
+
expect(data).to eq({:message => 'Hello'})
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
describe "#object_to_hash" do
|
122
|
+
it "ignores nils and includes empty arrays" do
|
123
|
+
# uncomment below to test object_to_hash for model
|
124
|
+
#api_client = AsposeDiagramCloud::ApiClient.new
|
125
|
+
#_model = AsposeDiagramCloud::ModelName.new
|
126
|
+
# update the model attribute below
|
127
|
+
#_model.id = 1
|
128
|
+
# update the expected value (hash) below
|
129
|
+
#expected = {id: 1, name: '', tags: []}
|
130
|
+
#expect(api_client.object_to_hash(_model)).to eq(expected)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
describe "#build_collection_param" do
|
135
|
+
let(:param) { ['aa', 'bb', 'cc'] }
|
136
|
+
let(:api_client) { AsposeDiagramCloud::ApiClient.new }
|
137
|
+
|
138
|
+
it "works for csv" do
|
139
|
+
expect(api_client.build_collection_param(param, :csv)).to eq('aa,bb,cc')
|
140
|
+
end
|
141
|
+
|
142
|
+
it "works for ssv" do
|
143
|
+
expect(api_client.build_collection_param(param, :ssv)).to eq('aa bb cc')
|
144
|
+
end
|
145
|
+
|
146
|
+
it "works for tsv" do
|
147
|
+
expect(api_client.build_collection_param(param, :tsv)).to eq("aa\tbb\tcc")
|
148
|
+
end
|
149
|
+
|
150
|
+
it "works for pipes" do
|
151
|
+
expect(api_client.build_collection_param(param, :pipes)).to eq('aa|bb|cc')
|
152
|
+
end
|
153
|
+
|
154
|
+
it "works for multi" do
|
155
|
+
expect(api_client.build_collection_param(param, :multi)).to eq(['aa', 'bb', 'cc'])
|
156
|
+
end
|
157
|
+
|
158
|
+
it "fails for invalid collection format" do
|
159
|
+
expect(proc { api_client.build_collection_param(param, :INVALID) }).to raise_error(RuntimeError, 'unknown collection format: :INVALID')
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
describe "#json_mime?" do
|
164
|
+
let(:api_client) { AsposeDiagramCloud::ApiClient.new }
|
165
|
+
|
166
|
+
it "works" do
|
167
|
+
expect(api_client.json_mime?(nil)).to eq false
|
168
|
+
expect(api_client.json_mime?('')).to eq false
|
169
|
+
|
170
|
+
expect(api_client.json_mime?('application/json')).to eq true
|
171
|
+
expect(api_client.json_mime?('application/json; charset=UTF8')).to eq true
|
172
|
+
expect(api_client.json_mime?('APPLICATION/JSON')).to eq true
|
173
|
+
|
174
|
+
expect(api_client.json_mime?('application/xml')).to eq false
|
175
|
+
expect(api_client.json_mime?('text/plain')).to eq false
|
176
|
+
expect(api_client.json_mime?('application/jsonp')).to eq false
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
describe "#select_header_accept" do
|
181
|
+
let(:api_client) { AsposeDiagramCloud::ApiClient.new }
|
182
|
+
|
183
|
+
it "works" do
|
184
|
+
expect(api_client.select_header_accept(nil)).to be_nil
|
185
|
+
expect(api_client.select_header_accept([])).to be_nil
|
186
|
+
|
187
|
+
expect(api_client.select_header_accept(['application/json'])).to eq('application/json')
|
188
|
+
expect(api_client.select_header_accept(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
|
189
|
+
expect(api_client.select_header_accept(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
|
190
|
+
|
191
|
+
expect(api_client.select_header_accept(['application/xml'])).to eq('application/xml')
|
192
|
+
expect(api_client.select_header_accept(['text/html', 'application/xml'])).to eq('text/html,application/xml')
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
describe "#select_header_content_type" do
|
197
|
+
let(:api_client) { AsposeDiagramCloud::ApiClient.new }
|
198
|
+
|
199
|
+
it "works" do
|
200
|
+
expect(api_client.select_header_content_type(nil)).to eq('application/json')
|
201
|
+
expect(api_client.select_header_content_type([])).to eq('application/json')
|
202
|
+
|
203
|
+
expect(api_client.select_header_content_type(['application/json'])).to eq('application/json')
|
204
|
+
expect(api_client.select_header_content_type(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
|
205
|
+
expect(api_client.select_header_content_type(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
|
206
|
+
expect(api_client.select_header_content_type(['application/xml'])).to eq('application/xml')
|
207
|
+
expect(api_client.select_header_content_type(['text/plain', 'application/xml'])).to eq('text/plain')
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
describe "#sanitize_filename" do
|
212
|
+
let(:api_client) { AsposeDiagramCloud::ApiClient.new }
|
213
|
+
|
214
|
+
it "works" do
|
215
|
+
expect(api_client.sanitize_filename('sun')).to eq('sun')
|
216
|
+
expect(api_client.sanitize_filename('sun.gif')).to eq('sun.gif')
|
217
|
+
expect(api_client.sanitize_filename('../sun.gif')).to eq('sun.gif')
|
218
|
+
expect(api_client.sanitize_filename('/var/tmp/sun.gif')).to eq('sun.gif')
|
219
|
+
expect(api_client.sanitize_filename('./sun.gif')).to eq('sun.gif')
|
220
|
+
expect(api_client.sanitize_filename('..\sun.gif')).to eq('sun.gif')
|
221
|
+
expect(api_client.sanitize_filename('\var\tmp\sun.gif')).to eq('sun.gif')
|
222
|
+
expect(api_client.sanitize_filename('c:\var\tmp\sun.gif')).to eq('sun.gif')
|
223
|
+
expect(api_client.sanitize_filename('.\sun.gif')).to eq('sun.gif')
|
224
|
+
end
|
225
|
+
end
|
226
|
+
end
|