cloudmersive-image-recognition-api-client 1.2.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +7 -0
  3. data/README.md +132 -0
  4. data/Rakefile +8 -0
  5. data/cloudmersive-image-recognition-api-client.gemspec +45 -0
  6. data/docs/AgeDetectionResult.md +10 -0
  7. data/docs/ArtisticApi.md +66 -0
  8. data/docs/DetectedLicensePlate.md +14 -0
  9. data/docs/DetectedObject.md +13 -0
  10. data/docs/DrawRectangleInstance.md +14 -0
  11. data/docs/DrawRectangleRequest.md +10 -0
  12. data/docs/DrawTextInstance.md +15 -0
  13. data/docs/DrawTextRequest.md +10 -0
  14. data/docs/EditApi.md +179 -0
  15. data/docs/Face.md +11 -0
  16. data/docs/FaceApi.md +228 -0
  17. data/docs/FaceLocateResponse.md +11 -0
  18. data/docs/ImageDescriptionResponse.md +11 -0
  19. data/docs/NsfwApi.md +63 -0
  20. data/docs/NsfwResult.md +10 -0
  21. data/docs/ObjectDetectionResult.md +10 -0
  22. data/docs/PersonWithAge.md +10 -0
  23. data/docs/RecognitionOutcome.md +9 -0
  24. data/docs/RecognizeApi.md +287 -0
  25. data/docs/ResizeApi.md +69 -0
  26. data/docs/VehicleLicensePlateDetectionResult.md +10 -0
  27. data/git_push.sh +55 -0
  28. data/lib/cloudmersive-image-recognition-api-client.rb +60 -0
  29. data/lib/cloudmersive-image-recognition-api-client/api/artistic_api.rb +85 -0
  30. data/lib/cloudmersive-image-recognition-api-client/api/edit_api.rb +202 -0
  31. data/lib/cloudmersive-image-recognition-api-client/api/face_api.rb +247 -0
  32. data/lib/cloudmersive-image-recognition-api-client/api/nsfw_api.rb +79 -0
  33. data/lib/cloudmersive-image-recognition-api-client/api/recognize_api.rb +306 -0
  34. data/lib/cloudmersive-image-recognition-api-client/api/resize_api.rb +91 -0
  35. data/lib/cloudmersive-image-recognition-api-client/api_client.rb +389 -0
  36. data/lib/cloudmersive-image-recognition-api-client/api_error.rb +38 -0
  37. data/lib/cloudmersive-image-recognition-api-client/configuration.rb +209 -0
  38. data/lib/cloudmersive-image-recognition-api-client/models/age_detection_result.rb +211 -0
  39. data/lib/cloudmersive-image-recognition-api-client/models/detected_license_plate.rb +245 -0
  40. data/lib/cloudmersive-image-recognition-api-client/models/detected_object.rb +239 -0
  41. data/lib/cloudmersive-image-recognition-api-client/models/draw_rectangle_instance.rb +249 -0
  42. data/lib/cloudmersive-image-recognition-api-client/models/draw_rectangle_request.rb +227 -0
  43. data/lib/cloudmersive-image-recognition-api-client/models/draw_text_instance.rb +259 -0
  44. data/lib/cloudmersive-image-recognition-api-client/models/draw_text_request.rb +227 -0
  45. data/lib/cloudmersive-image-recognition-api-client/models/face.rb +219 -0
  46. data/lib/cloudmersive-image-recognition-api-client/models/face_locate_response.rb +220 -0
  47. data/lib/cloudmersive-image-recognition-api-client/models/image_description_response.rb +219 -0
  48. data/lib/cloudmersive-image-recognition-api-client/models/nsfw_result.rb +209 -0
  49. data/lib/cloudmersive-image-recognition-api-client/models/object_detection_result.rb +211 -0
  50. data/lib/cloudmersive-image-recognition-api-client/models/person_with_age.rb +209 -0
  51. data/lib/cloudmersive-image-recognition-api-client/models/recognition_outcome.rb +199 -0
  52. data/lib/cloudmersive-image-recognition-api-client/models/vehicle_license_plate_detection_result.rb +211 -0
  53. data/lib/cloudmersive-image-recognition-api-client/version.rb +15 -0
  54. data/spec/api/artistic_api_spec.rb +48 -0
  55. data/spec/api/edit_api_spec.rb +73 -0
  56. data/spec/api/face_api_spec.rb +83 -0
  57. data/spec/api/nsfw_api_spec.rb +47 -0
  58. data/spec/api/recognize_api_spec.rb +96 -0
  59. data/spec/api/resize_api_spec.rb +49 -0
  60. data/spec/api_client_spec.rb +226 -0
  61. data/spec/configuration_spec.rb +42 -0
  62. data/spec/models/age_detection_result_spec.rb +54 -0
  63. data/spec/models/detected_license_plate_spec.rb +78 -0
  64. data/spec/models/detected_object_spec.rb +72 -0
  65. data/spec/models/draw_rectangle_instance_spec.rb +78 -0
  66. data/spec/models/draw_rectangle_request_spec.rb +54 -0
  67. data/spec/models/draw_text_instance_spec.rb +84 -0
  68. data/spec/models/draw_text_request_spec.rb +54 -0
  69. data/spec/models/face_locate_response_spec.rb +60 -0
  70. data/spec/models/face_spec.rb +60 -0
  71. data/spec/models/image_description_response_spec.rb +60 -0
  72. data/spec/models/nsfw_result_spec.rb +54 -0
  73. data/spec/models/object_detection_result_spec.rb +54 -0
  74. data/spec/models/person_with_age_spec.rb +54 -0
  75. data/spec/models/recognition_outcome_spec.rb +48 -0
  76. data/spec/models/vehicle_license_plate_detection_result_spec.rb +54 -0
  77. data/spec/spec_helper.rb +111 -0
  78. metadata +302 -0
@@ -0,0 +1,73 @@
1
+ =begin
2
+ #imageapi
3
+
4
+ #Image Recognition and Processing APIs let you use Machine Learning to recognize and process images, and also perform useful image modification operations.
5
+
6
+ OpenAPI spec version: v1
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: unset
10
+
11
+ =end
12
+
13
+ require 'spec_helper'
14
+ require 'json'
15
+
16
+ # Unit tests for CloudmersiveImageRecognitionApiClient::EditApi
17
+ # Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
18
+ # Please update as you see appropriate
19
+ describe 'EditApi' do
20
+ before do
21
+ # run before each test
22
+ @instance = CloudmersiveImageRecognitionApiClient::EditApi.new
23
+ end
24
+
25
+ after do
26
+ # run after each test
27
+ end
28
+
29
+ describe 'test an instance of EditApi' do
30
+ it 'should create an instance of EditApi' do
31
+ expect(@instance).to be_instance_of(CloudmersiveImageRecognitionApiClient::EditApi)
32
+ end
33
+ end
34
+
35
+ # unit tests for edit_composite_basic
36
+ # Composite two images together
37
+ # Composites two input images together; a layered image onto a base image. The first image you input is the base image. The second image (the layered image) will be composited on top of this base image. Supports PNG transparency. To control padding you can include transparent pixels at the border(s) of your layered images as appropriate.
38
+ # @param location Location to composite the layered images; possible values are: \"center\", \"top-left\", \"top-center\", \"top-right\", \"center-left\", \"center-right\", \"bottom-left\", \"bottom-center\", \"bottom-right\"
39
+ # @param base_image Image file to perform the operation on. Common file formats such as PNG, JPEG are supported.
40
+ # @param layered_image Image to layer on top of the base image.
41
+ # @param [Hash] opts the optional parameters
42
+ # @return [Object]
43
+ describe 'edit_composite_basic test' do
44
+ it "should work" do
45
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
46
+ end
47
+ end
48
+
49
+ # unit tests for edit_draw_rectangle
50
+ # Draw rectangle onto an image
51
+ # Draw one or more rectangles, with customized visuals, onto an image
52
+ # @param request
53
+ # @param [Hash] opts the optional parameters
54
+ # @return [Object]
55
+ describe 'edit_draw_rectangle test' do
56
+ it "should work" do
57
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
58
+ end
59
+ end
60
+
61
+ # unit tests for edit_draw_text
62
+ # Draw text onto an image
63
+ # Draw one or more pieces of text, with customized visuals, onto an image
64
+ # @param request
65
+ # @param [Hash] opts the optional parameters
66
+ # @return [Object]
67
+ describe 'edit_draw_text test' do
68
+ it "should work" do
69
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
70
+ end
71
+ end
72
+
73
+ end
@@ -0,0 +1,83 @@
1
+ =begin
2
+ #imageapi
3
+
4
+ #Image Recognition and Processing APIs let you use Machine Learning to recognize and process images, and also perform useful image modification operations.
5
+
6
+ OpenAPI spec version: v1
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: unset
10
+
11
+ =end
12
+
13
+ require 'spec_helper'
14
+ require 'json'
15
+
16
+ # Unit tests for CloudmersiveImageRecognitionApiClient::FaceApi
17
+ # Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
18
+ # Please update as you see appropriate
19
+ describe 'FaceApi' do
20
+ before do
21
+ # run before each test
22
+ @instance = CloudmersiveImageRecognitionApiClient::FaceApi.new
23
+ end
24
+
25
+ after do
26
+ # run after each test
27
+ end
28
+
29
+ describe 'test an instance of FaceApi' do
30
+ it 'should create an instance of FaceApi' do
31
+ expect(@instance).to be_instance_of(CloudmersiveImageRecognitionApiClient::FaceApi)
32
+ end
33
+ end
34
+
35
+ # unit tests for face_crop_first
36
+ # Crop image to face (square)
37
+ # Crop an image to the face (rectangular crop). If there is more than one face present, choose the first one.
38
+ # @param image_file Image file to perform the operation on. Common file formats such as PNG, JPEG are supported.
39
+ # @param [Hash] opts the optional parameters
40
+ # @return [String]
41
+ describe 'face_crop_first test' do
42
+ it "should work" do
43
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
44
+ end
45
+ end
46
+
47
+ # unit tests for face_crop_first_round
48
+ # Crop image to face (round)
49
+ # Crop an image to the face (circular/round crop). If there is more than one face present, choose the first one.
50
+ # @param image_file Image file to perform the operation on. Common file formats such as PNG, JPEG are supported.
51
+ # @param [Hash] opts the optional parameters
52
+ # @return [String]
53
+ describe 'face_crop_first_round test' do
54
+ it "should work" do
55
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
56
+ end
57
+ end
58
+
59
+ # unit tests for face_detect_age
60
+ # Detect the age of people in an image
61
+ # Identify the age, position, and size of human faces in an image, along with a recognition confidence level. People in the image do NOT need to be facing the camera; they can be facing away, edge-on, etc.
62
+ # @param image_file Image file to perform the operation on. Common file formats such as PNG, JPEG are supported.
63
+ # @param [Hash] opts the optional parameters
64
+ # @return [AgeDetectionResult]
65
+ describe 'face_detect_age test' do
66
+ it "should work" do
67
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
68
+ end
69
+ end
70
+
71
+ # unit tests for face_locate
72
+ # Find faces in an image
73
+ # Locate the positions of all faces in an image
74
+ # @param image_file Image file to perform the operation on. Common file formats such as PNG, JPEG are supported.
75
+ # @param [Hash] opts the optional parameters
76
+ # @return [FaceLocateResponse]
77
+ describe 'face_locate test' do
78
+ it "should work" do
79
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
80
+ end
81
+ end
82
+
83
+ end
@@ -0,0 +1,47 @@
1
+ =begin
2
+ #imageapi
3
+
4
+ #Image Recognition and Processing APIs let you use Machine Learning to recognize and process images, and also perform useful image modification operations.
5
+
6
+ OpenAPI spec version: v1
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: unset
10
+
11
+ =end
12
+
13
+ require 'spec_helper'
14
+ require 'json'
15
+
16
+ # Unit tests for CloudmersiveImageRecognitionApiClient::NsfwApi
17
+ # Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
18
+ # Please update as you see appropriate
19
+ describe 'NsfwApi' do
20
+ before do
21
+ # run before each test
22
+ @instance = CloudmersiveImageRecognitionApiClient::NsfwApi.new
23
+ end
24
+
25
+ after do
26
+ # run after each test
27
+ end
28
+
29
+ describe 'test an instance of NsfwApi' do
30
+ it 'should create an instance of NsfwApi' do
31
+ expect(@instance).to be_instance_of(CloudmersiveImageRecognitionApiClient::NsfwApi)
32
+ end
33
+ end
34
+
35
+ # unit tests for nsfw_classify
36
+ # Not safe for work (NSFW) racy content classification
37
+ # Classify an image into Not Safe For Work (NSFW)/Porn/Racy content and Safe Content.
38
+ # @param image_file Image file to perform the operation on. Common file formats such as PNG, JPEG are supported.
39
+ # @param [Hash] opts the optional parameters
40
+ # @return [NsfwResult]
41
+ describe 'nsfw_classify test' do
42
+ it "should work" do
43
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
44
+ end
45
+ end
46
+
47
+ end
@@ -0,0 +1,96 @@
1
+ =begin
2
+ #imageapi
3
+
4
+ #Image Recognition and Processing APIs let you use Machine Learning to recognize and process images, and also perform useful image modification operations.
5
+
6
+ OpenAPI spec version: v1
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: unset
10
+
11
+ =end
12
+
13
+ require 'spec_helper'
14
+ require 'json'
15
+
16
+ # Unit tests for CloudmersiveImageRecognitionApiClient::RecognizeApi
17
+ # Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
18
+ # Please update as you see appropriate
19
+ describe 'RecognizeApi' do
20
+ before do
21
+ # run before each test
22
+ @instance = CloudmersiveImageRecognitionApiClient::RecognizeApi.new
23
+ end
24
+
25
+ after do
26
+ # run after each test
27
+ end
28
+
29
+ describe 'test an instance of RecognizeApi' do
30
+ it 'should create an instance of RecognizeApi' do
31
+ expect(@instance).to be_instance_of(CloudmersiveImageRecognitionApiClient::RecognizeApi)
32
+ end
33
+ end
34
+
35
+ # unit tests for recognize_describe
36
+ # Describe an image in natural language
37
+ # Generate an English language text description of the image as a sentence.
38
+ # @param image_file Image file to perform the operation on. Common file formats such as PNG, JPEG are supported.
39
+ # @param [Hash] opts the optional parameters
40
+ # @return [ImageDescriptionResponse]
41
+ describe 'recognize_describe test' do
42
+ it "should work" do
43
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
44
+ end
45
+ end
46
+
47
+ # unit tests for recognize_detect_and_unskew_document
48
+ # Detect and unskew a photo of a document
49
+ # Detect and unskew a photo of a document (e.g. taken on a cell phone) into a perfectly square image. Great for document scanning applications; once unskewed, this image is perfect for converting to PDF using the Convert API or optical character recognition using the OCR API.
50
+ # @param image_file Image file to perform the operation on. Common file formats such as PNG, JPEG are supported.
51
+ # @param [Hash] opts the optional parameters
52
+ # @option opts [String] :post_processing_effect Optional, post-processing effects to apply to the email, default is None. Possible values are None and BlackAndWhite (force the image into a black and white view to aid in OCR operations).
53
+ # @return [String]
54
+ describe 'recognize_detect_and_unskew_document test' do
55
+ it "should work" do
56
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
57
+ end
58
+ end
59
+
60
+ # unit tests for recognize_detect_objects
61
+ # Detect objects, including types and locations, in an image
62
+ # Identify the position, size and description of objects in an image, along with a recognition confidence level. Detects both human people and objects in an image.
63
+ # @param image_file Image file to perform the operation on. Common file formats such as PNG, JPEG are supported.
64
+ # @param [Hash] opts the optional parameters
65
+ # @return [ObjectDetectionResult]
66
+ describe 'recognize_detect_objects test' do
67
+ it "should work" do
68
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
69
+ end
70
+ end
71
+
72
+ # unit tests for recognize_detect_people
73
+ # Detect people, including locations, in an image
74
+ # Identify the position, and size of human people in an image, along with a recognition confidence level. People in the image do NOT need to be facing the camera; they can be facing away, edge-on, etc.
75
+ # @param image_file Image file to perform the operation on. Common file formats such as PNG, JPEG are supported.
76
+ # @param [Hash] opts the optional parameters
77
+ # @return [ObjectDetectionResult]
78
+ describe 'recognize_detect_people test' do
79
+ it "should work" do
80
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
81
+ end
82
+ end
83
+
84
+ # unit tests for recognize_detect_vehicle_license_plates
85
+ # Detect vehicle license plates in an image
86
+ # Identify the position, and size, and content of vehicle license plates in an image. License plates should be within 15-20 degrees on-axis to the camera.
87
+ # @param image_file Image file to perform the operation on. Common file formats such as PNG, JPEG are supported.
88
+ # @param [Hash] opts the optional parameters
89
+ # @return [VehicleLicensePlateDetectionResult]
90
+ describe 'recognize_detect_vehicle_license_plates test' do
91
+ it "should work" do
92
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
93
+ end
94
+ end
95
+
96
+ end
@@ -0,0 +1,49 @@
1
+ =begin
2
+ #imageapi
3
+
4
+ #Image Recognition and Processing APIs let you use Machine Learning to recognize and process images, and also perform useful image modification operations.
5
+
6
+ OpenAPI spec version: v1
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: unset
10
+
11
+ =end
12
+
13
+ require 'spec_helper'
14
+ require 'json'
15
+
16
+ # Unit tests for CloudmersiveImageRecognitionApiClient::ResizeApi
17
+ # Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
18
+ # Please update as you see appropriate
19
+ describe 'ResizeApi' do
20
+ before do
21
+ # run before each test
22
+ @instance = CloudmersiveImageRecognitionApiClient::ResizeApi.new
23
+ end
24
+
25
+ after do
26
+ # run after each test
27
+ end
28
+
29
+ describe 'test an instance of ResizeApi' do
30
+ it 'should create an instance of ResizeApi' do
31
+ expect(@instance).to be_instance_of(CloudmersiveImageRecognitionApiClient::ResizeApi)
32
+ end
33
+ end
34
+
35
+ # unit tests for resize_post
36
+ # Resize an image with parameters
37
+ # Resize an image to a maximum width and maximum height, while preserving the image's original aspect ratio
38
+ # @param max_width Maximum width of the output image - final image will be as large as possible while less than or equial to this width
39
+ # @param max_height Maximum height of the output image - final image will be as large as possible while less than or equial to this height
40
+ # @param image_file Image file to perform the operation on. Common file formats such as PNG, JPEG are supported.
41
+ # @param [Hash] opts the optional parameters
42
+ # @return [String]
43
+ describe 'resize_post test' do
44
+ it "should work" do
45
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
46
+ end
47
+ end
48
+
49
+ end
@@ -0,0 +1,226 @@
1
+ =begin
2
+ #imageapi
3
+
4
+ #Image Recognition and Processing APIs let you use Machine Learning to recognize and process images, and also perform useful image modification operations.
5
+
6
+ OpenAPI spec version: v1
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: unset
10
+
11
+ =end
12
+
13
+ require 'spec_helper'
14
+
15
+ describe CloudmersiveImageRecognitionApiClient::ApiClient do
16
+ context 'initialization' do
17
+ context 'URL stuff' do
18
+ context 'host' do
19
+ it 'removes http from host' do
20
+ CloudmersiveImageRecognitionApiClient.configure { |c| c.host = 'http://example.com' }
21
+ expect(CloudmersiveImageRecognitionApiClient::Configuration.default.host).to eq('example.com')
22
+ end
23
+
24
+ it 'removes https from host' do
25
+ CloudmersiveImageRecognitionApiClient.configure { |c| c.host = 'https://wookiee.com' }
26
+ expect(CloudmersiveImageRecognitionApiClient::ApiClient.default.config.host).to eq('wookiee.com')
27
+ end
28
+
29
+ it 'removes trailing path from host' do
30
+ CloudmersiveImageRecognitionApiClient.configure { |c| c.host = 'hobo.com/v4' }
31
+ expect(CloudmersiveImageRecognitionApiClient::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
+ CloudmersiveImageRecognitionApiClient.configure { |c| c.base_path = 'v4/dog' }
38
+ expect(CloudmersiveImageRecognitionApiClient::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
+ CloudmersiveImageRecognitionApiClient.configure { |c| c.base_path = '/v4/dog' }
43
+ expect(CloudmersiveImageRecognitionApiClient::Configuration.default.base_path).to eq('/v4/dog')
44
+ end
45
+
46
+ it "ends up as a blank string if nil" do
47
+ CloudmersiveImageRecognitionApiClient.configure { |c| c.base_path = nil }
48
+ expect(CloudmersiveImageRecognitionApiClient::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) { CloudmersiveImageRecognitionApiClient::Configuration.new }
56
+ let(:api_client) { CloudmersiveImageRecognitionApiClient::ApiClient.new(config) }
57
+
58
+ it "defaults to nil" do
59
+ expect(CloudmersiveImageRecognitionApiClient::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) { CloudmersiveImageRecognitionApiClient::Configuration.new }
75
+ let(:api_client) { CloudmersiveImageRecognitionApiClient::ApiClient.new(config) }
76
+
77
+ it "defaults to 0" do
78
+ expect(CloudmersiveImageRecognitionApiClient::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 = CloudmersiveImageRecognitionApiClient::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 = CloudmersiveImageRecognitionApiClient::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 = CloudmersiveImageRecognitionApiClient::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 = CloudmersiveImageRecognitionApiClient::ApiClient.new
125
+ #_model = CloudmersiveImageRecognitionApiClient::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) { CloudmersiveImageRecognitionApiClient::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) { CloudmersiveImageRecognitionApiClient::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) { CloudmersiveImageRecognitionApiClient::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) { CloudmersiveImageRecognitionApiClient::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) { CloudmersiveImageRecognitionApiClient::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