aspose_cells_cloud 26.7 → 26.9

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.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +656 -76
  3. data/lib/aspose_cells_cloud/api/cells_api.rb +8 -0
  4. data/lib/aspose_cells_cloud/requests/categorize_spreadsheet_request.rb +151 -0
  5. data/lib/aspose_cells_cloud/requests/smart_marker_template_request.rb +30 -0
  6. data/lib/aspose_cells_cloud/requests/translate_spreadsheet_request.rb +24 -0
  7. data/lib/aspose_cells_cloud/requests/translate_text_file_request.rb +24 -0
  8. data/lib/aspose_cells_cloud/version.rb +1 -1
  9. data/lib/aspose_cells_cloud.rb +1 -0
  10. data/spec/client_spec.rb +114 -0
  11. data/spec/configuration_spec.rb +61 -0
  12. data/spec/form_file_spec.rb +47 -0
  13. data/spec/model_spec.rb +73 -0
  14. data/spec/request_spec.rb +87 -0
  15. data/spec/rich_response_spec.rb +46 -0
  16. data/spec/sdk_error_spec.rb +27 -0
  17. data/spec/spec_helper.rb +21 -134
  18. metadata +10 -78
  19. data/spec/TestData/AggregateCellsByColor.xlsx +0 -0
  20. data/spec/TestData/Book1.xlsx +0 -0
  21. data/spec/TestData/BookCsvDuplicateData.csv +0 -21
  22. data/spec/TestData/BookDuplicateData.xlsx +0 -0
  23. data/spec/TestData/BookFormula.xlsx +0 -0
  24. data/spec/TestData/BookTableL2W.xlsx +0 -0
  25. data/spec/TestData/BookText.xlsx +0 -0
  26. data/spec/TestData/CompanySales.xlsx +0 -0
  27. data/spec/TestData/EmployeeSalesSummary-BlankWorksheet.xlsx +0 -0
  28. data/spec/TestData/EmployeeSalesSummary.xlsx +0 -0
  29. data/spec/TestData/EmployeeSalesSummary_Locked.xlsx +0 -0
  30. data/spec/TestData/Formula tutorial.xlsx +0 -0
  31. data/spec/TestData/Group.xlsx +0 -0
  32. data/spec/TestData/Home inventory.xlsx +0 -0
  33. data/spec/TestData/LockedEmployeeSalesSummary.xlsx +0 -0
  34. data/spec/TestData/OLEDoc.docx +0 -0
  35. data/spec/TestData/ReportData.xml +0 -1
  36. data/spec/TestData/Simple invoice.xlsx +0 -0
  37. data/spec/TestData/Template.xlsx +0 -0
  38. data/spec/TestData/TestCase.xlsx +0 -0
  39. data/spec/TestData/TestTables.xlsx +0 -0
  40. data/spec/TestData/WaterMark.png +0 -0
  41. data/spec/TestData/assemblytest.xlsx +0 -0
  42. data/spec/TestData/data.xml +0 -1
  43. data/spec/TestData/datasource.xlsx +0 -0
  44. data/spec/TestData/myDocument.xlsx +0 -0
  45. data/spec/TestData/needUnlock.xlsx +0 -0
  46. data/spec/TestData/needlock.xlsx +0 -0
  47. data/spec/TestData/roywang.pfx +0 -0
  48. data/spec/TestData/word.jpg +0 -0
  49. data/spec/calculate/calculate_spec.rb +0 -29
  50. data/spec/cells_cloud30/auto_filter_controller_spec.rb +0 -211
  51. data/spec/cells_cloud30/batch_controller_spec.rb +0 -113
  52. data/spec/cells_cloud30/cells_controller_spec.rb +0 -627
  53. data/spec/cells_cloud30/cells_status_controller_spec.rb +0 -43
  54. data/spec/cells_cloud30/chart_area_controller_spec.rb +0 -58
  55. data/spec/cells_cloud30/charts_controller_spec.rb +0 -227
  56. data/spec/cells_cloud30/conditional_formattings_controller_spec.rb +0 -149
  57. data/spec/cells_cloud30/conversion30_spec.rb +0 -1112
  58. data/spec/cells_cloud30/data_processing_controller_spec.rb +0 -97
  59. data/spec/cells_cloud30/hypelinks_controller_spec.rb +0 -104
  60. data/spec/cells_cloud30/light_cells_spec.rb +0 -1059
  61. data/spec/cells_cloud30/list_objects_controller_spec.rb +0 -225
  62. data/spec/cells_cloud30/ole_objects_controller_spec.rb +0 -108
  63. data/spec/cells_cloud30/page_breaks_controller_spec.rb +0 -163
  64. data/spec/cells_cloud30/page_setup_controller_spec.rb +0 -149
  65. data/spec/cells_cloud30/pictures_controller_spec.rb +0 -106
  66. data/spec/cells_cloud30/pivot_tables_controller_spec.rb +0 -312
  67. data/spec/cells_cloud30/properties_controller_spec.rb +0 -89
  68. data/spec/cells_cloud30/ranges_controller_spec.rb +0 -227
  69. data/spec/cells_cloud30/shapes_controller_spec.rb +0 -139
  70. data/spec/cells_cloud30/sparkline_groups_controller_spec.rb +0 -104
  71. data/spec/cells_cloud30/text_processing_controller_spec.rb +0 -67
  72. data/spec/cells_cloud30/workbook_controller_spec.rb +0 -519
  73. data/spec/cells_cloud30/worksheet_controller_spec.rb +0 -609
  74. data/spec/cells_cloud30/worksheet_validations_controller_spec.rb +0 -104
  75. data/spec/cells_cloud30/xml_controller_spec.rb +0 -48
  76. data/spec/data_processing/conversion_spec.rb +0 -428
  77. data/spec/data_processing/import_data_spec.rb +0 -24
  78. data/spec/data_processing/merger_spec.rb +0 -28
  79. data/spec/data_processing/protection_spec.rb +0 -29
  80. data/spec/data_processing/splitter_spec.rb +0 -47
  81. data/spec/data_processing/transform_spec.rb +0 -43
  82. data/spec/dynabic/file_controller_spec.rb +0 -60
  83. data/spec/dynabic/folder_controller_spec.rb +0 -88
  84. data/spec/dynabic/storage_controller_spec.rb +0 -73
  85. data/spec/management/management_spec.rb +0 -111
  86. data/spec/search2_replace/replacer_spec.rb +0 -46
  87. data/spec/search2_replace/searcher_spec.rb +0 -131
  88. data/spec/text_processing/add_text_spec.rb +0 -45
  89. data/spec/text_processing/convert_text_spec.rb +0 -37
  90. data/spec/text_processing/extract_text_spec.rb +0 -37
  91. data/spec/text_processing/remove_characters_spec.rb +0 -53
  92. data/spec/text_processing/split_text_spec.rb +0 -21
  93. data/spec/text_processing/trim_spreadsheet_spec.rb +0 -29
  94. data/spec/text_processing/update_word_case_spec.rb +0 -37
@@ -80,6 +80,14 @@ module AsposeCellsCloud
80
80
  return data
81
81
  end
82
82
 
83
+ # AI-powered data categorization: Automatically classifies spreadsheet column data into logical groups.
84
+
85
+ def categorize_spreadsheet( categorize_spreadsheet_request, opts = {})
86
+
87
+ data, _status_code, _headers = categorize_spreadsheet_request.create_http_request(@api_client,opts )
88
+ return data
89
+ end
90
+
83
91
  # The Aggregate by Color API provides a convenient way to perform calculations on cells that share the same fill or font color. This API supports a range of aggregate operations, including count, sum, maximum value, minimum value, and average value, enabling you to analyze and summarize data based on color distinctions.
84
92
 
85
93
  def aggregate_cells_by_color( aggregate_cells_by_color_request, opts = {})
@@ -0,0 +1,151 @@
1
+ =begin
2
+ --------------------------------------------------------------------------------------------------------------------
3
+ <copyright company="Aspose" file="CategorizeSpreadsheet_request.rb.cs">
4
+ Copyright (c) 2026 Aspose.Cells Cloud
5
+ </copyright>
6
+ <summary>
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in all
15
+ copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ SOFTWARE.
24
+ </summary>
25
+ --------------------------------------------------------------------------------------------------------------------
26
+ =end
27
+
28
+
29
+ require "uri"
30
+
31
+ module AsposeCellsCloud
32
+ class CategorizeSpreadsheetRequest
33
+
34
+ attr_accessor :spreadsheet
35
+ attr_accessor :target_column
36
+ attr_accessor :sheet_name
37
+ attr_accessor :new_column_name
38
+ attr_accessor :region
39
+ attr_accessor :password
40
+
41
+ def initialize(attributes = {})
42
+ return unless attributes.is_a?(Hash)
43
+
44
+ # convert string to symbol for hash key
45
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
46
+
47
+ if attributes.has_key?(:'Spreadsheet')
48
+ self.spreadsheet = attributes[:'Spreadsheet']
49
+ end
50
+
51
+ if attributes.has_key?(:'targetColumn')
52
+ self.target_column = attributes[:'targetColumn']
53
+ end
54
+
55
+ if attributes.has_key?(:'sheetName')
56
+ self.sheet_name = attributes[:'sheetName']
57
+ end
58
+
59
+ if attributes.has_key?(:'newColumnName')
60
+ self.new_column_name = attributes[:'newColumnName']
61
+ end
62
+
63
+ if attributes.has_key?(:'region')
64
+ self.region = attributes[:'region']
65
+ end
66
+
67
+ if attributes.has_key?(:'password')
68
+ self.password = attributes[:'password']
69
+ end
70
+
71
+ end
72
+ # Attribute mapping from ruby-style variable name to JSON key.
73
+ def self.attribute_map
74
+ {
75
+ :'spreadsheet' => :'Spreadsheet',
76
+ :'target_column' => :'targetColumn',
77
+ :'sheet_name' => :'sheetName',
78
+ :'new_column_name' => :'newColumnName',
79
+ :'region' => :'region',
80
+ :'password' => :'password'
81
+ }
82
+ end
83
+
84
+ # Attribute type mapping.
85
+ def self.swagger_types
86
+ {
87
+ :'spreadsheet' => :'String',
88
+ :'target_column' => :'String',
89
+ :'sheet_name' => :'String',
90
+ :'new_column_name' => :'String',
91
+ :'region' => :'String',
92
+ :'password' => :'String'
93
+ }
94
+ end
95
+
96
+ def create_http_request(api_client,opts = {})
97
+ if api_client.config.debugging
98
+ api_client.config.logger.debug "Calling API: CellsApi.categorize_spreadsheet ..."
99
+ end
100
+ api_client.request_token_if_needed
101
+ # verify the required parameter 'spreadsheet' is set
102
+ if api_client.config.client_side_validation && spreadsheet.nil?
103
+ fail ArgumentError, "Missing the required parameter 'spreadsheet' when calling CellsApi.categorize_spreadsheet "
104
+ end
105
+ # verify the required parameter 'target_column' is set
106
+ if api_client.config.client_side_validation && target_column.nil?
107
+ fail ArgumentError, "Missing the required parameter 'target_column' when calling CellsApi.categorize_spreadsheet "
108
+ end
109
+
110
+ # resource path
111
+ local_var_path = "v4.0/cells/ai/categorize/spreadsheet"
112
+ # query parameters
113
+ query_params = {}
114
+ query_params[:'targetColumn'] = self.target_column if !self.target_column.nil?
115
+ query_params[:'sheetName'] = self.sheet_name if !self.sheet_name.nil?
116
+ query_params[:'newColumnName'] = self.new_column_name if !self.new_column_name.nil?
117
+ query_params[:'region'] = self.region if !self.region.nil?
118
+ query_params[:'password'] = self.password if !self.password.nil?
119
+
120
+ # header parameters
121
+ header_params = {}
122
+ # HTTP header 'Accept' (if needed)
123
+ header_params['Accept'] = api_client.select_header_accept(['application/json'])
124
+ # HTTP header 'Content-Type'
125
+ header_params['Content-Type'] = api_client.select_header_content_type(['application/json'])
126
+
127
+ # form parameters
128
+ form_params = {}
129
+ post_body = nil
130
+
131
+ header_params['Content-Type'] = api_client.select_header_content_type(['multipart/form-data'])
132
+ if !spreadsheet.empty? && File.exist?(spreadsheet )
133
+ form_params[File.basename(spreadsheet)] = ::File.open(spreadsheet,"r")
134
+ end
135
+
136
+ #auth_names = []
137
+ auth_names = ['JWT']
138
+ data, status_code, headers = api_client.call_api(:PUT, local_var_path,
139
+ :header_params => header_params,
140
+ :query_params => query_params,
141
+ :form_params => form_params,
142
+ :body => post_body,
143
+ :auth_names => auth_names,
144
+ :return_type => 'File')
145
+ if api_client.config.debugging
146
+ api_client.config.logger.debug "API called: Specification.Name>Api.categorize_spreadsheet\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
147
+ end
148
+ return data, status_code, headers
149
+ end
150
+ end
151
+ end
@@ -31,6 +31,8 @@ require "uri"
31
31
  module AsposeCellsCloud
32
32
  class SmartMarkerTemplateRequest
33
33
 
34
+ attr_accessor :datafile
35
+ attr_accessor :templatefile
34
36
  attr_accessor :region
35
37
  attr_accessor :password
36
38
 
@@ -40,6 +42,14 @@ module AsposeCellsCloud
40
42
  # convert string to symbol for hash key
41
43
  attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
42
44
 
45
+ if attributes.has_key?(:'datafile')
46
+ self.datafile = attributes[:'datafile']
47
+ end
48
+
49
+ if attributes.has_key?(:'templatefile')
50
+ self.templatefile = attributes[:'templatefile']
51
+ end
52
+
43
53
  if attributes.has_key?(:'region')
44
54
  self.region = attributes[:'region']
45
55
  end
@@ -52,6 +62,8 @@ module AsposeCellsCloud
52
62
  # Attribute mapping from ruby-style variable name to JSON key.
53
63
  def self.attribute_map
54
64
  {
65
+ :'datafile' => :'datafile',
66
+ :'templatefile' => :'templatefile',
55
67
  :'region' => :'region',
56
68
  :'password' => :'password'
57
69
  }
@@ -60,6 +72,8 @@ module AsposeCellsCloud
60
72
  # Attribute type mapping.
61
73
  def self.swagger_types
62
74
  {
75
+ :'datafile' => :'String',
76
+ :'templatefile' => :'String',
63
77
  :'region' => :'String',
64
78
  :'password' => :'String'
65
79
  }
@@ -70,6 +84,14 @@ module AsposeCellsCloud
70
84
  api_client.config.logger.debug "Calling API: CellsApi.smart_marker_template ..."
71
85
  end
72
86
  api_client.request_token_if_needed
87
+ # verify the required parameter 'datafile' is set
88
+ if api_client.config.client_side_validation && datafile.nil?
89
+ fail ArgumentError, "Missing the required parameter 'datafile' when calling CellsApi.smart_marker_template "
90
+ end
91
+ # verify the required parameter 'templatefile' is set
92
+ if api_client.config.client_side_validation && templatefile.nil?
93
+ fail ArgumentError, "Missing the required parameter 'templatefile' when calling CellsApi.smart_marker_template "
94
+ end
73
95
 
74
96
  # resource path
75
97
  local_var_path = "v4.0/cells/report/smart/template"
@@ -89,6 +111,14 @@ module AsposeCellsCloud
89
111
  form_params = {}
90
112
  post_body = nil
91
113
 
114
+ header_params['Content-Type'] = api_client.select_header_content_type(['multipart/form-data'])
115
+ if !datafile.empty? && File.exist?(datafile )
116
+ form_params[File.basename(datafile)] = ::File.open(datafile,"r")
117
+ end
118
+ if !templatefile.empty? && File.exist?(templatefile )
119
+ form_params[File.basename(templatefile)] = ::File.open(templatefile,"r")
120
+ end
121
+
92
122
  #auth_names = []
93
123
  auth_names = ['JWT']
94
124
  data, status_code, headers = api_client.call_api(:PUT, local_var_path,
@@ -33,6 +33,9 @@ module AsposeCellsCloud
33
33
 
34
34
  attr_accessor :spreadsheet
35
35
  attr_accessor :target_language
36
+ attr_accessor :custom_endpoint
37
+ attr_accessor :custom_api_key
38
+ attr_accessor :custom_model
36
39
  attr_accessor :region
37
40
  attr_accessor :password
38
41
 
@@ -50,6 +53,18 @@ module AsposeCellsCloud
50
53
  self.target_language = attributes[:'targetLanguage']
51
54
  end
52
55
 
56
+ if attributes.has_key?(:'customEndpoint')
57
+ self.custom_endpoint = attributes[:'customEndpoint']
58
+ end
59
+
60
+ if attributes.has_key?(:'customApiKey')
61
+ self.custom_api_key = attributes[:'customApiKey']
62
+ end
63
+
64
+ if attributes.has_key?(:'customModel')
65
+ self.custom_model = attributes[:'customModel']
66
+ end
67
+
53
68
  if attributes.has_key?(:'region')
54
69
  self.region = attributes[:'region']
55
70
  end
@@ -64,6 +79,9 @@ module AsposeCellsCloud
64
79
  {
65
80
  :'spreadsheet' => :'Spreadsheet',
66
81
  :'target_language' => :'targetLanguage',
82
+ :'custom_endpoint' => :'customEndpoint',
83
+ :'custom_api_key' => :'customApiKey',
84
+ :'custom_model' => :'customModel',
67
85
  :'region' => :'region',
68
86
  :'password' => :'password'
69
87
  }
@@ -74,6 +92,9 @@ module AsposeCellsCloud
74
92
  {
75
93
  :'spreadsheet' => :'String',
76
94
  :'target_language' => :'String',
95
+ :'custom_endpoint' => :'String',
96
+ :'custom_api_key' => :'String',
97
+ :'custom_model' => :'String',
77
98
  :'region' => :'String',
78
99
  :'password' => :'String'
79
100
  }
@@ -98,6 +119,9 @@ module AsposeCellsCloud
98
119
  # query parameters
99
120
  query_params = {}
100
121
  query_params[:'targetLanguage'] = self.target_language if !self.target_language.nil?
122
+ query_params[:'customEndpoint'] = self.custom_endpoint if !self.custom_endpoint.nil?
123
+ query_params[:'customApiKey'] = self.custom_api_key if !self.custom_api_key.nil?
124
+ query_params[:'customModel'] = self.custom_model if !self.custom_model.nil?
101
125
  query_params[:'region'] = self.region if !self.region.nil?
102
126
  query_params[:'password'] = self.password if !self.password.nil?
103
127
 
@@ -33,6 +33,9 @@ module AsposeCellsCloud
33
33
 
34
34
  attr_accessor :spreadsheet
35
35
  attr_accessor :target_language
36
+ attr_accessor :custom_endpoint
37
+ attr_accessor :custom_api_key
38
+ attr_accessor :custom_model
36
39
  attr_accessor :region
37
40
  attr_accessor :password
38
41
 
@@ -50,6 +53,18 @@ module AsposeCellsCloud
50
53
  self.target_language = attributes[:'targetLanguage']
51
54
  end
52
55
 
56
+ if attributes.has_key?(:'customEndpoint')
57
+ self.custom_endpoint = attributes[:'customEndpoint']
58
+ end
59
+
60
+ if attributes.has_key?(:'customApiKey')
61
+ self.custom_api_key = attributes[:'customApiKey']
62
+ end
63
+
64
+ if attributes.has_key?(:'customModel')
65
+ self.custom_model = attributes[:'customModel']
66
+ end
67
+
53
68
  if attributes.has_key?(:'region')
54
69
  self.region = attributes[:'region']
55
70
  end
@@ -64,6 +79,9 @@ module AsposeCellsCloud
64
79
  {
65
80
  :'spreadsheet' => :'Spreadsheet',
66
81
  :'target_language' => :'targetLanguage',
82
+ :'custom_endpoint' => :'customEndpoint',
83
+ :'custom_api_key' => :'customApiKey',
84
+ :'custom_model' => :'customModel',
67
85
  :'region' => :'region',
68
86
  :'password' => :'password'
69
87
  }
@@ -74,6 +92,9 @@ module AsposeCellsCloud
74
92
  {
75
93
  :'spreadsheet' => :'String',
76
94
  :'target_language' => :'String',
95
+ :'custom_endpoint' => :'String',
96
+ :'custom_api_key' => :'String',
97
+ :'custom_model' => :'String',
77
98
  :'region' => :'String',
78
99
  :'password' => :'String'
79
100
  }
@@ -98,6 +119,9 @@ module AsposeCellsCloud
98
119
  # query parameters
99
120
  query_params = {}
100
121
  query_params[:'targetLanguage'] = self.target_language if !self.target_language.nil?
122
+ query_params[:'customEndpoint'] = self.custom_endpoint if !self.custom_endpoint.nil?
123
+ query_params[:'customApiKey'] = self.custom_api_key if !self.custom_api_key.nil?
124
+ query_params[:'customModel'] = self.custom_model if !self.custom_model.nil?
101
125
  query_params[:'region'] = self.region if !self.region.nil?
102
126
  query_params[:'password'] = self.password if !self.password.nil?
103
127
 
@@ -27,5 +27,5 @@
27
27
 
28
28
 
29
29
  module AsposeCellsCloud
30
- VERSION = "26.7"
30
+ VERSION = "26.9"
31
31
  end
@@ -491,6 +491,7 @@ require 'aspose_cells_cloud/requests/translate_spreadsheet_request'
491
491
  require 'aspose_cells_cloud/requests/translate_text_file_request'
492
492
  require 'aspose_cells_cloud/requests/report_ai_analysis_request'
493
493
  require 'aspose_cells_cloud/requests/summarize_spreadsheet_request'
494
+ require 'aspose_cells_cloud/requests/categorize_spreadsheet_request'
494
495
  require 'aspose_cells_cloud/requests/aggregate_cells_by_color_request'
495
496
  require 'aspose_cells_cloud/requests/math_calculate_request'
496
497
  require 'aspose_cells_cloud/requests/calculation_formula_request'
@@ -0,0 +1,114 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'tempfile'
4
+
5
+ RSpec.describe Aspose::Cells::Cloud::AsposeCellsCloudClient do
6
+ subject(:client) { described_class.new('client-id', 'client-secret') }
7
+
8
+ describe 'construction' do
9
+ it 'builds a Configuration with the supplied credentials and default base_url' do
10
+ expect(client.configuration.client_id).to eq('client-id')
11
+ expect(client.configuration.client_secret).to eq('client-secret')
12
+ expect(client.configuration.base_url).to eq('https://api.aspose.cloud')
13
+ end
14
+
15
+ it 'accepts a custom base_url and options' do
16
+ custom = described_class.new('id', 'secret', 'https://example.com', timeout: 10, retries: 2)
17
+ expect(custom.configuration.base_url).to eq('https://example.com')
18
+ expect(custom.configuration.timeout).to eq(10)
19
+ expect(custom.configuration.retries).to eq(2)
20
+ end
21
+
22
+ it 'exposes configuration via #get_configuration' do
23
+ expect(client.get_configuration).to be(client.configuration)
24
+ end
25
+ end
26
+
27
+ describe '#build_multipart (private)' do
28
+ it 'embeds a file as a multipart part with its basename' do
29
+ Tempfile.create('book') do |file|
30
+ file.write('spreadsheet-bytes')
31
+ file.flush
32
+ content_type, body = client.send(:build_multipart, 'File' => file.path)
33
+ expect(content_type).to match(%r{^multipart/form-data; boundary=})
34
+ expect(body).to include('name="File"')
35
+ expect(body).to include("filename=\"#{File.basename(file.path)}\"")
36
+ expect(body).to include('spreadsheet-bytes')
37
+ end
38
+ end
39
+
40
+ it 'sends a plain value as a text field' do
41
+ _content_type, body = client.send(:build_multipart, 'note' => 'hello')
42
+ expect(body).to include('name="note"')
43
+ expect(body).to include('hello')
44
+ end
45
+
46
+ it 'accepts an open IO object (File/Tempfile) as a file part' do
47
+ Tempfile.create('book') do |file|
48
+ file.write('from-io')
49
+ file.flush
50
+ _content_type, body = client.send(:build_multipart, 'File' => file)
51
+ expect(body).to include("filename=\"#{File.basename(file.path)}\"")
52
+ expect(body).to include('from-io')
53
+ end
54
+ end
55
+
56
+ it 'accepts a FormFile.from_bytes binary array as a file part' do
57
+ form_file = Aspose::Cells::Cloud::FormFile.from_bytes([0x00, 0x48, 0x49], filename: 'raw.bin')
58
+ _content_type, body = client.send(:build_multipart, 'File' => form_file)
59
+ expect(body).to include('filename="raw.bin"')
60
+ expect(body).to include("\x00HI".b)
61
+ end
62
+
63
+ it 'uses a FormFile content_type when provided' do
64
+ form_file = Aspose::Cells::Cloud::FormFile.from_bytes([0x50, 0x4B], filename: 'a.xlsx',
65
+ content_type: 'application/vnd.ms-excel')
66
+ content_type, body = client.send(:build_multipart, 'File' => form_file)
67
+ expect(content_type).to match(%r{^multipart/form-data; boundary=})
68
+ expect(body).to include('Content-Type: application/vnd.ms-excel')
69
+ end
70
+
71
+ it 'sends a bare integer array as a binary text field' do
72
+ _content_type, body = client.send(:build_multipart, 'blob' => [0x01, 0x02, 0x03])
73
+ expect(body).to include("name=\"blob\"")
74
+ expect(body).to include("\x01\x02\x03".b)
75
+ expect(body).not_to include('filename=')
76
+ end
77
+ end
78
+
79
+ describe '#build_request (private)' do
80
+ let(:uri) { URI.parse('https://api.aspose.cloud/v4.0/cells/convert') }
81
+
82
+ it 'builds a GET request with no body' do
83
+ req = client.send(:build_request, 'GET', uri, {}, nil, nil)
84
+ expect(req).to be_a(Net::HTTP::Get)
85
+ expect(req.body).to be_nil
86
+ end
87
+
88
+ it 'serializes a JSON body' do
89
+ req = client.send(:build_request, 'POST', uri, { 'Content-Type' => 'application/json' },
90
+ { 'Name' => 'x' }, nil)
91
+ expect(req.body).to eq('{"Name":"x"}')
92
+ expect(req['Content-Type']).to eq('application/json')
93
+ end
94
+
95
+ it 'rejects an unsupported HTTP method' do
96
+ expect { client.send(:build_request, 'PATCH', uri, {}, nil, nil) }
97
+ .to raise_error(Aspose::Cells::Cloud::SDKError, /Unsupported HTTP method/)
98
+ end
99
+ end
100
+
101
+ describe '#upload_file / #download_file' do
102
+ it 'upload_file builds and executes an UploadFileRequest' do
103
+ response = double('response', success?: true)
104
+ allow(client).to receive(:execute).and_return(response)
105
+ expect(client.upload_file('TestData/In/a.xlsx', 'testdata/a.xlsx')).to be(response)
106
+ end
107
+
108
+ it 'download_file returns the response bytes' do
109
+ response = double('response', to_bytes: 'CONTENT')
110
+ allow(client).to receive(:execute).and_return(response)
111
+ expect(client.download_file('TestData/In/a.xlsx')).to eq('CONTENT')
112
+ end
113
+ end
114
+ end
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.describe Aspose::Cells::Cloud::Configuration do
4
+ describe 'defaults' do
5
+ subject(:config) { described_class.new }
6
+
7
+ it 'defaults base_url to the production endpoint' do
8
+ expect(config.base_url).to eq('https://api.aspose.cloud')
9
+ end
10
+
11
+ it 'defaults timeout to 30 seconds' do
12
+ expect(config.timeout).to eq(30)
13
+ end
14
+
15
+ it 'defaults retries to 0' do
16
+ expect(config.retries).to eq(0)
17
+ end
18
+
19
+ it 'defaults api_version to v4.0' do
20
+ expect(config.api_version).to eq('v4.0')
21
+ end
22
+
23
+ it 'leaves credentials nil (no fake defaults)' do
24
+ expect(config.client_id).to be_nil
25
+ expect(config.client_secret).to be_nil
26
+ end
27
+
28
+ it 'starts with an empty header map' do
29
+ expect(config.header_parameters).to eq({})
30
+ end
31
+ end
32
+
33
+ describe '#token_url' do
34
+ it 'derives the OAuth2 endpoint from api_version (v4.0) by default' do
35
+ expect(described_class.new.token_url).to eq('https://api.aspose.cloud/v4.0/cells/connect/token')
36
+ end
37
+
38
+ it 'uses /v3.0/cells/connect/token when api_version is v3.0' do
39
+ config = described_class.new(api_version: 'v3.0')
40
+ expect(config.token_url).to eq('https://api.aspose.cloud/v3.0/cells/connect/token')
41
+ end
42
+
43
+ it 'honours an explicit auth_url override' do
44
+ config = described_class.new(auth_url: 'https://example.com/oauth2/token')
45
+ expect(config.token_url).to eq('https://example.com/oauth2/token')
46
+ end
47
+
48
+ it 'strips a trailing slash from base_url' do
49
+ config = described_class.new(base_url: 'https://api.aspose.cloud/')
50
+ expect(config.token_url).to eq('https://api.aspose.cloud/v4.0/cells/connect/token')
51
+ end
52
+ end
53
+
54
+ describe '#add_default_header' do
55
+ it 'adds a header to the map' do
56
+ config = described_class.new
57
+ config.add_default_header('X-Custom', 'value')
58
+ expect(config.header_parameters['X-Custom']).to eq('value')
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'stringio'
4
+ require 'tempfile'
5
+
6
+ RSpec.describe Aspose::Cells::Cloud::FormFile do
7
+ describe '.from_path' do
8
+ it 'reads the file bytes and uses its basename as the filename' do
9
+ Tempfile.create('book') do |file|
10
+ file.write('sheet-bytes')
11
+ file.flush
12
+ form_file = described_class.from_path(file.path)
13
+ expect(form_file.filename).to eq(File.basename(file.path))
14
+ expect(form_file.read).to eq('sheet-bytes')
15
+ expect(form_file.read.encoding).to eq(Encoding::BINARY)
16
+ end
17
+ end
18
+ end
19
+
20
+ describe '.from_io' do
21
+ it 'reads the stream and honors an explicit filename' do
22
+ form_file = described_class.from_io(StringIO.new('io-content'), filename: 'report.csv')
23
+ expect(form_file.filename).to eq('report.csv')
24
+ expect(form_file.read).to eq('io-content')
25
+ end
26
+ end
27
+
28
+ describe '.from_bytes' do
29
+ it 'packs an integer byte array into a binary string' do
30
+ form_file = described_class.from_bytes([0x50, 0x4B, 0x03, 0x04], filename: 'Book1.xlsx')
31
+ expect(form_file.read).to eq("\x50\x4B\x03\x04".b)
32
+ end
33
+
34
+ it 'accepts a binary string as-is' do
35
+ form_file = described_class.from_bytes("\x50\x4B".b, filename: 'a.xlsx')
36
+ expect(form_file.read).to eq("\x50\x4B".b)
37
+ end
38
+ end
39
+
40
+ describe 'validation' do
41
+ it 'requires exactly one of path/io/bytes' do
42
+ expect { described_class.new }.to raise_error(ArgumentError, /exactly one/)
43
+ expect { described_class.new(path: 'a', io: StringIO.new) }.to raise_error(ArgumentError, /exactly one/)
44
+ expect { described_class.from_bytes([1], filename: nil) }.not_to raise_error
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,73 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.describe 'generated models' do
4
+ describe Aspose::Cells::Cloud::Model::Font do
5
+ it 'serializes set attributes to PascalCase wire names' do
6
+ font = described_class.new(is_bold: true, size: 16, name: 'Arial')
7
+ expect(font.to_h).to eq('IsBold' => true, 'Name' => 'Arial', 'Size' => 16)
8
+ end
9
+
10
+ it 'omits nil attributes (omitempty semantics)' do
11
+ expect(described_class.new.to_h).to eq({})
12
+ end
13
+
14
+ it 'produces JSON via #to_json' do
15
+ font = described_class.new(size: 12)
16
+ expect(font.to_json).to eq('{"Size":12}')
17
+ end
18
+ end
19
+
20
+ describe Aspose::Cells::Cloud::Model::FontSetting do
21
+ it 'nests a model reference with #to_h' do
22
+ setting = described_class.new(
23
+ font: Aspose::Cells::Cloud::Model::Font.new(size: 10),
24
+ length: 5,
25
+ start_index: 0
26
+ )
27
+ expect(setting.to_h).to eq('Font' => { 'Size' => 10 }, 'Length' => 5, 'StartIndex' => 0)
28
+ end
29
+ end
30
+
31
+ describe 'keyword-conflict attributes' do
32
+ it 'maps a Type property to a type_ accessor with wire name Type' do
33
+ color = Aspose::Cells::Cloud::Model::CellsColor.new(type_: 'Automatic')
34
+ expect(color.type_).to eq('Automatic')
35
+ expect(color.to_h).to eq('Type' => 'Automatic')
36
+ end
37
+ end
38
+
39
+ describe 'container (array-of-model) properties' do
40
+ it 'maps each element with #to_h' do
41
+ links = Aspose::Cells::Cloud::Model::ListObjects.new(
42
+ list_object_list: [
43
+ Aspose::Cells::Cloud::Model::ListObject.new,
44
+ Aspose::Cells::Cloud::Model::ListObject.new
45
+ ]
46
+ )
47
+ expect(links.to_h['ListObjectList']).to be_an(Array)
48
+ expect(links.to_h['ListObjectList'].length).to eq(2)
49
+ end
50
+ end
51
+
52
+ describe 'enum models' do
53
+ it 'serializes to an empty hash' do
54
+ enum = Aspose::Cells::Cloud::Model::AggregateOperation.new('Sum')
55
+ expect(enum.to_h).to eq({})
56
+ end
57
+ end
58
+
59
+ describe 'full generation' do
60
+ it 'generates 483 model classes' do
61
+ model_files = Dir[File.join(__dir__, '..', 'lib', 'aspose', 'cells', 'cloud', 'model', '*.rb')]
62
+ expect(model_files.length).to eq(483)
63
+ end
64
+
65
+ it 'every model responds to to_h and to_json' do
66
+ Aspose::Cells::Cloud::Model.constants.each do |const|
67
+ klass = Aspose::Cells::Cloud::Model.const_get(const)
68
+ next unless klass.is_a?(Class)
69
+ expect(klass.new).to respond_to(:to_h, :to_json)
70
+ end
71
+ end
72
+ end
73
+ end