aspose_cells_cloud 20.11 → 20.11.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (281) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +21 -0
  3. data/README.md +116 -0
  4. data/lib/aspose_cells_cloud.rb +296 -0
  5. data/lib/aspose_cells_cloud/api/cells_api.rb +19867 -0
  6. data/lib/aspose_cells_cloud/api_client.rb +493 -0
  7. data/lib/aspose_cells_cloud/api_error.rb +48 -0
  8. data/lib/aspose_cells_cloud/configuration.rb +178 -0
  9. data/lib/aspose_cells_cloud/models/above_average.rb +234 -0
  10. data/lib/aspose_cells_cloud/models/access_token_response.rb +261 -0
  11. data/lib/aspose_cells_cloud/models/area.rb +243 -0
  12. data/lib/aspose_cells_cloud/models/auto_filter.rb +227 -0
  13. data/lib/aspose_cells_cloud/models/auto_filter_response.rb +221 -0
  14. data/lib/aspose_cells_cloud/models/auto_fitter_options.rb +231 -0
  15. data/lib/aspose_cells_cloud/models/auto_shape.rb +504 -0
  16. data/lib/aspose_cells_cloud/models/auto_shape_response.rb +221 -0
  17. data/lib/aspose_cells_cloud/models/auto_shapes.rb +209 -0
  18. data/lib/aspose_cells_cloud/models/auto_shapes_response.rb +221 -0
  19. data/lib/aspose_cells_cloud/models/border.rb +216 -0
  20. data/lib/aspose_cells_cloud/models/calculation_options.rb +225 -0
  21. data/lib/aspose_cells_cloud/models/cell.rb +401 -0
  22. data/lib/aspose_cells_cloud/models/cell_area.rb +245 -0
  23. data/lib/aspose_cells_cloud/models/cell_response.rb +221 -0
  24. data/lib/aspose_cells_cloud/models/cell_value.rb +234 -0
  25. data/lib/aspose_cells_cloud/models/cells.rb +270 -0
  26. data/lib/aspose_cells_cloud/models/cells_cloud_file_info.rb +230 -0
  27. data/lib/aspose_cells_cloud/models/cells_cloud_response.rb +212 -0
  28. data/lib/aspose_cells_cloud/models/cells_color.rb +234 -0
  29. data/lib/aspose_cells_cloud/models/cells_document_properties.rb +209 -0
  30. data/lib/aspose_cells_cloud/models/cells_document_properties_response.rb +221 -0
  31. data/lib/aspose_cells_cloud/models/cells_document_property.rb +225 -0
  32. data/lib/aspose_cells_cloud/models/cells_document_property_response.rb +221 -0
  33. data/lib/aspose_cells_cloud/models/cells_error.rb +229 -0
  34. data/lib/aspose_cells_cloud/models/cells_object_operate_task_parameter.rb +216 -0
  35. data/lib/aspose_cells_cloud/models/cells_response.rb +221 -0
  36. data/lib/aspose_cells_cloud/models/chart.rb +626 -0
  37. data/lib/aspose_cells_cloud/models/chart_area.rb +317 -0
  38. data/lib/aspose_cells_cloud/models/chart_area_response.rb +221 -0
  39. data/lib/aspose_cells_cloud/models/chart_frame.rb +317 -0
  40. data/lib/aspose_cells_cloud/models/chart_operate_parameter.rb +279 -0
  41. data/lib/aspose_cells_cloud/models/charts.rb +209 -0
  42. data/lib/aspose_cells_cloud/models/charts_response.rb +221 -0
  43. data/lib/aspose_cells_cloud/models/color.rb +245 -0
  44. data/lib/aspose_cells_cloud/models/color_filter.rb +234 -0
  45. data/lib/aspose_cells_cloud/models/color_filter_request.rb +216 -0
  46. data/lib/aspose_cells_cloud/models/color_scale.rb +249 -0
  47. data/lib/aspose_cells_cloud/models/column.rb +243 -0
  48. data/lib/aspose_cells_cloud/models/column_response.rb +221 -0
  49. data/lib/aspose_cells_cloud/models/columns.rb +237 -0
  50. data/lib/aspose_cells_cloud/models/columns_response.rb +221 -0
  51. data/lib/aspose_cells_cloud/models/comment.rb +297 -0
  52. data/lib/aspose_cells_cloud/models/comment_response.rb +221 -0
  53. data/lib/aspose_cells_cloud/models/comments.rb +209 -0
  54. data/lib/aspose_cells_cloud/models/comments_response.rb +221 -0
  55. data/lib/aspose_cells_cloud/models/conditional_formatting.rb +218 -0
  56. data/lib/aspose_cells_cloud/models/conditional_formatting_icon.rb +235 -0
  57. data/lib/aspose_cells_cloud/models/conditional_formatting_response.rb +221 -0
  58. data/lib/aspose_cells_cloud/models/conditional_formatting_value.rb +219 -0
  59. data/lib/aspose_cells_cloud/models/conditional_formattings.rb +223 -0
  60. data/lib/aspose_cells_cloud/models/conditional_formattings_response.rb +221 -0
  61. data/lib/aspose_cells_cloud/models/convert_task_parameter.rb +216 -0
  62. data/lib/aspose_cells_cloud/models/copy_options.rb +248 -0
  63. data/lib/aspose_cells_cloud/models/create_pivot_table_request.rb +263 -0
  64. data/lib/aspose_cells_cloud/models/custom_filter.rb +207 -0
  65. data/lib/aspose_cells_cloud/models/custom_parser_config.rb +216 -0
  66. data/lib/aspose_cells_cloud/models/data_bar.rb +309 -0
  67. data/lib/aspose_cells_cloud/models/data_bar_border.rb +209 -0
  68. data/lib/aspose_cells_cloud/models/data_sorter.rb +227 -0
  69. data/lib/aspose_cells_cloud/models/dif_save_options.rb +265 -0
  70. data/lib/aspose_cells_cloud/models/disc_usage.rb +219 -0
  71. data/lib/aspose_cells_cloud/models/dynamic_filter.rb +216 -0
  72. data/lib/aspose_cells_cloud/models/error_details.rb +214 -0
  73. data/lib/aspose_cells_cloud/models/file_source.rb +207 -0
  74. data/lib/aspose_cells_cloud/models/file_version.rb +274 -0
  75. data/lib/aspose_cells_cloud/models/file_versions.rb +201 -0
  76. data/lib/aspose_cells_cloud/models/files_list.rb +201 -0
  77. data/lib/aspose_cells_cloud/models/files_upload_result.rb +213 -0
  78. data/lib/aspose_cells_cloud/models/fill_format.rb +259 -0
  79. data/lib/aspose_cells_cloud/models/fill_format_response.rb +221 -0
  80. data/lib/aspose_cells_cloud/models/filter_column.rb +277 -0
  81. data/lib/aspose_cells_cloud/models/font.rb +279 -0
  82. data/lib/aspose_cells_cloud/models/font_setting.rb +244 -0
  83. data/lib/aspose_cells_cloud/models/format_condition.rb +327 -0
  84. data/lib/aspose_cells_cloud/models/gradient_fill.rb +227 -0
  85. data/lib/aspose_cells_cloud/models/gradient_fill_stop.rb +226 -0
  86. data/lib/aspose_cells_cloud/models/horizontal_page_break.rb +231 -0
  87. data/lib/aspose_cells_cloud/models/horizontal_page_break_response.rb +221 -0
  88. data/lib/aspose_cells_cloud/models/horizontal_page_breaks.rb +209 -0
  89. data/lib/aspose_cells_cloud/models/horizontal_page_breaks_response.rb +221 -0
  90. data/lib/aspose_cells_cloud/models/html_save_options.rb +373 -0
  91. data/lib/aspose_cells_cloud/models/hyperlink.rb +234 -0
  92. data/lib/aspose_cells_cloud/models/hyperlink_response.rb +221 -0
  93. data/lib/aspose_cells_cloud/models/hyperlinks.rb +223 -0
  94. data/lib/aspose_cells_cloud/models/hyperlinks_response.rb +221 -0
  95. data/lib/aspose_cells_cloud/models/icon_filter.rb +212 -0
  96. data/lib/aspose_cells_cloud/models/icon_set.rb +253 -0
  97. data/lib/aspose_cells_cloud/models/image_save_options.rb +373 -0
  98. data/lib/aspose_cells_cloud/models/import_batch_data_option.rb +236 -0
  99. data/lib/aspose_cells_cloud/models/import_csv_data_option.rb +281 -0
  100. data/lib/aspose_cells_cloud/models/import_data_task_parameter.rb +216 -0
  101. data/lib/aspose_cells_cloud/models/import_double_array_option.rb +263 -0
  102. data/lib/aspose_cells_cloud/models/import_int_array_option.rb +263 -0
  103. data/lib/aspose_cells_cloud/models/import_option.rb +225 -0
  104. data/lib/aspose_cells_cloud/models/import_string_array_option.rb +263 -0
  105. data/lib/aspose_cells_cloud/models/legend.rb +335 -0
  106. data/lib/aspose_cells_cloud/models/legend_response.rb +221 -0
  107. data/lib/aspose_cells_cloud/models/line.rb +360 -0
  108. data/lib/aspose_cells_cloud/models/line_format.rb +358 -0
  109. data/lib/aspose_cells_cloud/models/line_response.rb +221 -0
  110. data/lib/aspose_cells_cloud/models/link.rb +225 -0
  111. data/lib/aspose_cells_cloud/models/link_element.rb +198 -0
  112. data/lib/aspose_cells_cloud/models/list_column.rb +209 -0
  113. data/lib/aspose_cells_cloud/models/list_object.rb +350 -0
  114. data/lib/aspose_cells_cloud/models/list_object_operate_parameter.rb +207 -0
  115. data/lib/aspose_cells_cloud/models/list_object_response.rb +221 -0
  116. data/lib/aspose_cells_cloud/models/list_objects.rb +209 -0
  117. data/lib/aspose_cells_cloud/models/list_objects_response.rb +221 -0
  118. data/lib/aspose_cells_cloud/models/m_html_save_options.rb +373 -0
  119. data/lib/aspose_cells_cloud/models/markdown_save_options.rb +292 -0
  120. data/lib/aspose_cells_cloud/models/merged_cell.rb +254 -0
  121. data/lib/aspose_cells_cloud/models/merged_cell_response.rb +221 -0
  122. data/lib/aspose_cells_cloud/models/merged_cells.rb +223 -0
  123. data/lib/aspose_cells_cloud/models/merged_cells_response.rb +221 -0
  124. data/lib/aspose_cells_cloud/models/multiple_filter.rb +189 -0
  125. data/lib/aspose_cells_cloud/models/multiple_filters.rb +209 -0
  126. data/lib/aspose_cells_cloud/models/name.rb +276 -0
  127. data/lib/aspose_cells_cloud/models/name_response.rb +221 -0
  128. data/lib/aspose_cells_cloud/models/names.rb +223 -0
  129. data/lib/aspose_cells_cloud/models/names_response.rb +221 -0
  130. data/lib/aspose_cells_cloud/models/negative_bar_format.rb +229 -0
  131. data/lib/aspose_cells_cloud/models/object_exist.rb +219 -0
  132. data/lib/aspose_cells_cloud/models/ods_save_options.rb +265 -0
  133. data/lib/aspose_cells_cloud/models/ole_object.rb +567 -0
  134. data/lib/aspose_cells_cloud/models/ole_object_response.rb +221 -0
  135. data/lib/aspose_cells_cloud/models/ole_objects.rb +209 -0
  136. data/lib/aspose_cells_cloud/models/ole_objects_response.rb +221 -0
  137. data/lib/aspose_cells_cloud/models/ooxml_save_options.rb +274 -0
  138. data/lib/aspose_cells_cloud/models/operate_object.rb +207 -0
  139. data/lib/aspose_cells_cloud/models/operate_object_position.rb +243 -0
  140. data/lib/aspose_cells_cloud/models/operate_parameter.rb +198 -0
  141. data/lib/aspose_cells_cloud/models/page_break_operate_parameter.rb +252 -0
  142. data/lib/aspose_cells_cloud/models/page_section.rb +259 -0
  143. data/lib/aspose_cells_cloud/models/page_sections_response.rb +223 -0
  144. data/lib/aspose_cells_cloud/models/page_setup.rb +542 -0
  145. data/lib/aspose_cells_cloud/models/page_setup_operate_parameter.rb +207 -0
  146. data/lib/aspose_cells_cloud/models/page_setup_response.rb +221 -0
  147. data/lib/aspose_cells_cloud/models/password_request.rb +198 -0
  148. data/lib/aspose_cells_cloud/models/paste_options.rb +225 -0
  149. data/lib/aspose_cells_cloud/models/pattern_fill.rb +252 -0
  150. data/lib/aspose_cells_cloud/models/pdf_save_options.rb +355 -0
  151. data/lib/aspose_cells_cloud/models/pdf_security_options.rb +283 -0
  152. data/lib/aspose_cells_cloud/models/pic_format_option.rb +243 -0
  153. data/lib/aspose_cells_cloud/models/picture.rb +558 -0
  154. data/lib/aspose_cells_cloud/models/picture_response.rb +221 -0
  155. data/lib/aspose_cells_cloud/models/pictures.rb +209 -0
  156. data/lib/aspose_cells_cloud/models/pictures_response.rb +221 -0
  157. data/lib/aspose_cells_cloud/models/pivot_field.rb +546 -0
  158. data/lib/aspose_cells_cloud/models/pivot_field_response.rb +221 -0
  159. data/lib/aspose_cells_cloud/models/pivot_filter.rb +279 -0
  160. data/lib/aspose_cells_cloud/models/pivot_filter_response.rb +221 -0
  161. data/lib/aspose_cells_cloud/models/pivot_filters_response.rb +223 -0
  162. data/lib/aspose_cells_cloud/models/pivot_item.rb +228 -0
  163. data/lib/aspose_cells_cloud/models/pivot_table.rb +824 -0
  164. data/lib/aspose_cells_cloud/models/pivot_table_field_request.rb +200 -0
  165. data/lib/aspose_cells_cloud/models/pivot_table_operate_parameter.rb +276 -0
  166. data/lib/aspose_cells_cloud/models/pivot_table_response.rb +221 -0
  167. data/lib/aspose_cells_cloud/models/pivot_tables.rb +209 -0
  168. data/lib/aspose_cells_cloud/models/pivot_tables_response.rb +221 -0
  169. data/lib/aspose_cells_cloud/models/protect_sheet_parameter.rb +335 -0
  170. data/lib/aspose_cells_cloud/models/range.rb +309 -0
  171. data/lib/aspose_cells_cloud/models/range_copy_request.rb +225 -0
  172. data/lib/aspose_cells_cloud/models/range_set_outline_border_request.rb +225 -0
  173. data/lib/aspose_cells_cloud/models/range_set_style_request.rb +207 -0
  174. data/lib/aspose_cells_cloud/models/range_value_response.rb +223 -0
  175. data/lib/aspose_cells_cloud/models/ranges.rb +200 -0
  176. data/lib/aspose_cells_cloud/models/ranges_response.rb +221 -0
  177. data/lib/aspose_cells_cloud/models/result_destination.rb +216 -0
  178. data/lib/aspose_cells_cloud/models/row.rb +261 -0
  179. data/lib/aspose_cells_cloud/models/row_response.rb +221 -0
  180. data/lib/aspose_cells_cloud/models/rows.rb +237 -0
  181. data/lib/aspose_cells_cloud/models/rows_response.rb +221 -0
  182. data/lib/aspose_cells_cloud/models/save_options.rb +265 -0
  183. data/lib/aspose_cells_cloud/models/save_response.rb +221 -0
  184. data/lib/aspose_cells_cloud/models/save_result.rb +200 -0
  185. data/lib/aspose_cells_cloud/models/save_result_task_parameter.rb +207 -0
  186. data/lib/aspose_cells_cloud/models/shadow_effect.rb +252 -0
  187. data/lib/aspose_cells_cloud/models/shape.rb +504 -0
  188. data/lib/aspose_cells_cloud/models/shape_operate_parameter.rb +207 -0
  189. data/lib/aspose_cells_cloud/models/shape_response.rb +221 -0
  190. data/lib/aspose_cells_cloud/models/shapes.rb +209 -0
  191. data/lib/aspose_cells_cloud/models/shapes_response.rb +221 -0
  192. data/lib/aspose_cells_cloud/models/single_value.rb +207 -0
  193. data/lib/aspose_cells_cloud/models/single_value_response.rb +221 -0
  194. data/lib/aspose_cells_cloud/models/smart_marker_task_parameter.rb +216 -0
  195. data/lib/aspose_cells_cloud/models/solid_fill.rb +216 -0
  196. data/lib/aspose_cells_cloud/models/sort_key.rb +221 -0
  197. data/lib/aspose_cells_cloud/models/sparkline.rb +226 -0
  198. data/lib/aspose_cells_cloud/models/sparkline_group.rb +434 -0
  199. data/lib/aspose_cells_cloud/models/sparkline_group_response.rb +221 -0
  200. data/lib/aspose_cells_cloud/models/sparkline_groups.rb +200 -0
  201. data/lib/aspose_cells_cloud/models/sparkline_groups_response.rb +221 -0
  202. data/lib/aspose_cells_cloud/models/split_result.rb +200 -0
  203. data/lib/aspose_cells_cloud/models/split_result_document.rb +212 -0
  204. data/lib/aspose_cells_cloud/models/split_result_response.rb +222 -0
  205. data/lib/aspose_cells_cloud/models/split_workbook_task_parameter.rb +243 -0
  206. data/lib/aspose_cells_cloud/models/spreadsheet_ml2003_save_options.rb +292 -0
  207. data/lib/aspose_cells_cloud/models/storage_exist.rb +204 -0
  208. data/lib/aspose_cells_cloud/models/storage_file.rb +249 -0
  209. data/lib/aspose_cells_cloud/models/style.rb +407 -0
  210. data/lib/aspose_cells_cloud/models/style_response.rb +221 -0
  211. data/lib/aspose_cells_cloud/models/svg_save_options.rb +274 -0
  212. data/lib/aspose_cells_cloud/models/task_data.rb +200 -0
  213. data/lib/aspose_cells_cloud/models/task_description.rb +207 -0
  214. data/lib/aspose_cells_cloud/models/task_parameter.rb +189 -0
  215. data/lib/aspose_cells_cloud/models/text_item.rb +207 -0
  216. data/lib/aspose_cells_cloud/models/text_items.rb +209 -0
  217. data/lib/aspose_cells_cloud/models/text_items_response.rb +221 -0
  218. data/lib/aspose_cells_cloud/models/text_options.rb +333 -0
  219. data/lib/aspose_cells_cloud/models/text_water_marker_request.rb +239 -0
  220. data/lib/aspose_cells_cloud/models/texture_fill.rb +243 -0
  221. data/lib/aspose_cells_cloud/models/theme_color.rb +207 -0
  222. data/lib/aspose_cells_cloud/models/tile_pic_option.rb +263 -0
  223. data/lib/aspose_cells_cloud/models/title.rb +380 -0
  224. data/lib/aspose_cells_cloud/models/title_response.rb +221 -0
  225. data/lib/aspose_cells_cloud/models/top10.rb +219 -0
  226. data/lib/aspose_cells_cloud/models/top10_filter.rb +240 -0
  227. data/lib/aspose_cells_cloud/models/txt_save_options.rb +301 -0
  228. data/lib/aspose_cells_cloud/models/validation.rb +360 -0
  229. data/lib/aspose_cells_cloud/models/validation_response.rb +221 -0
  230. data/lib/aspose_cells_cloud/models/validations.rb +223 -0
  231. data/lib/aspose_cells_cloud/models/validations_response.rb +221 -0
  232. data/lib/aspose_cells_cloud/models/value_type.rb +189 -0
  233. data/lib/aspose_cells_cloud/models/vertical_page_break.rb +231 -0
  234. data/lib/aspose_cells_cloud/models/vertical_page_break_response.rb +221 -0
  235. data/lib/aspose_cells_cloud/models/vertical_page_breaks.rb +209 -0
  236. data/lib/aspose_cells_cloud/models/vertical_page_breaks_response.rb +221 -0
  237. data/lib/aspose_cells_cloud/models/workbook.rb +290 -0
  238. data/lib/aspose_cells_cloud/models/workbook_encryption_request.rb +224 -0
  239. data/lib/aspose_cells_cloud/models/workbook_operate_parameter.rb +198 -0
  240. data/lib/aspose_cells_cloud/models/workbook_protection_request.rb +209 -0
  241. data/lib/aspose_cells_cloud/models/workbook_replace_response.rb +235 -0
  242. data/lib/aspose_cells_cloud/models/workbook_response.rb +221 -0
  243. data/lib/aspose_cells_cloud/models/workbook_settings.rb +626 -0
  244. data/lib/aspose_cells_cloud/models/workbook_settings_operate_parameter.rb +207 -0
  245. data/lib/aspose_cells_cloud/models/workbook_settings_response.rb +221 -0
  246. data/lib/aspose_cells_cloud/models/worksheet.rb +510 -0
  247. data/lib/aspose_cells_cloud/models/worksheet_moving_request.rb +209 -0
  248. data/lib/aspose_cells_cloud/models/worksheet_replace_response.rb +235 -0
  249. data/lib/aspose_cells_cloud/models/worksheet_response.rb +221 -0
  250. data/lib/aspose_cells_cloud/models/worksheets.rb +209 -0
  251. data/lib/aspose_cells_cloud/models/worksheets_response.rb +221 -0
  252. data/lib/aspose_cells_cloud/models/xls_save_options.rb +265 -0
  253. data/lib/aspose_cells_cloud/models/xlsb_save_options.rb +265 -0
  254. data/lib/aspose_cells_cloud/models/xps_save_options.rb +265 -0
  255. data/lib/aspose_cells_cloud/version.rb +25 -0
  256. data/spec/api/cells_api_spec.rb +1145 -0
  257. data/spec/api/cells_auto_filter_api_spec.rb +430 -0
  258. data/spec/api/cells_chart_area_api_spec.rb +92 -0
  259. data/spec/api/cells_charts_api_spec.rb +390 -0
  260. data/spec/api/cells_conditional_formattings_api_spec.rb +259 -0
  261. data/spec/api/cells_hypelinks_api_spec.rb +170 -0
  262. data/spec/api/cells_list_objects_api_spec.rb +245 -0
  263. data/spec/api/cells_ole_objects_api_spec.rb +177 -0
  264. data/spec/api/cells_page_breaks_api_spec.rb +269 -0
  265. data/spec/api/cells_page_setup_api_spec.rb +198 -0
  266. data/spec/api/cells_pictures_api_spec.rb +174 -0
  267. data/spec/api/cells_pivot_tables_api_spec.rb +525 -0
  268. data/spec/api/cells_properties_api_spec.rb +129 -0
  269. data/spec/api/cells_ranges_api_spec.rb +284 -0
  270. data/spec/api/cells_save_as_api_spec.rb +74 -0
  271. data/spec/api/cells_shapes_api_spec.rb +174 -0
  272. data/spec/api/cells_simple_spec.rb +44 -0
  273. data/spec/api/cells_sparkline_group_spec.rb +43 -0
  274. data/spec/api/cells_storage_api_spec.rb +69 -0
  275. data/spec/api/cells_storage_spec.rb +45 -0
  276. data/spec/api/cells_task_api_spec.rb +61 -0
  277. data/spec/api/cells_workbook_api_spec.rb +641 -0
  278. data/spec/api/cells_worksheet_validations_api_spec.rb +139 -0
  279. data/spec/api/cells_worksheets_api_spec.rb +843 -0
  280. data/spec/spec_helper.rb +132 -0
  281. metadata +282 -3
@@ -0,0 +1,493 @@
1
+ =begin
2
+ --------------------------------------------------------------------------------------------------------------------
3
+ Copyright (c) 2020 Aspose.Cells Cloud
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18
+ SOFTWARE.
19
+ --------------------------------------------------------------------------------------------------------------------
20
+
21
+ =end
22
+
23
+ require 'date'
24
+ require 'json'
25
+ require 'logger'
26
+ require 'tempfile'
27
+ require 'uri'
28
+ require 'faraday'
29
+ require_relative 'version'
30
+ require_relative 'api_error'
31
+
32
+ module AsposeCellsCloud
33
+ class ApiClient
34
+ # The Configuration object holding settings to be used in the API client.
35
+ attr_accessor :config
36
+
37
+ # Defines the headers to be used in HTTP requests of all API calls by default.
38
+ #
39
+ # @return [Hash]
40
+ attr_accessor :default_headers
41
+
42
+ attr_accessor :get_access_token_time
43
+ # Initializes the ApiClient
44
+ # @option config [Configuration] Configuration for initializing the object, default to Configuration.default
45
+ def initialize(config = Configuration.default)
46
+ @config = config
47
+
48
+ @default_headers = {
49
+ 'Content-Type' => "application/json",
50
+ 'x-aspose-client' => "ruby sdk",
51
+ 'x-aspose-version' => "#{ AsposeCellsCloud::VERSION }"
52
+ }
53
+ end
54
+
55
+ def self.default
56
+ @@default ||= ApiClient.new
57
+ end
58
+
59
+ # Call an API with given options.
60
+ #
61
+ # @return [Array<(Object, Fixnum, Hash)>] an array of 3 elements:
62
+ # the data deserialized from response body (could be nil), response status code and response headers.
63
+ def call_api(http_method, path, opts = {})
64
+ response = build_request(http_method, path, opts)
65
+ download_file response if opts[:return_type] == 'File'
66
+
67
+ if @config.debugging
68
+ @config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
69
+ end
70
+
71
+ unless response.success?
72
+
73
+ if response.status == 0
74
+ # Errors from libcurl will be made visible here
75
+ fail ApiError.new(:code => 0,
76
+ :message => response.reason_phrase)
77
+ else
78
+ fail ApiError.new(:code => response.status,
79
+ :response_headers => response.headers,
80
+ :response_body => response.body),
81
+ response.reason_phrase
82
+ end
83
+ end
84
+
85
+ if opts[:return_type]
86
+ data = deserialize(response, opts[:return_type])
87
+ else
88
+ data = nil
89
+ end
90
+ [data, response.status, response.headers]
91
+ end
92
+
93
+ # Builds the HTTP request
94
+ #
95
+ # @param [String] http_method HTTP method/verb (e.g. POST)
96
+ # @param [String] path URL path (e.g. /account/new)
97
+ # @option opts [Hash] :header_params Header parameters
98
+ # @option opts [Hash] :query_params Query parameters
99
+ # @option opts [Hash] :form_params Query parameters
100
+ # @option opts [Object] :body HTTP body (JSON/XML)
101
+ # @return [Faraday::Response] A Faraday Response
102
+ def build_request(http_method, path, opts = {})
103
+ url = build_request_url(path)
104
+ http_method = http_method.to_sym.downcase
105
+
106
+ header_params = @default_headers.merge(opts[:header_params] || {})
107
+ query_params = opts[:query_params] || {}
108
+ form_params = opts[:form_params] || {}
109
+ body = opts[:body] || {}
110
+
111
+ update_params_for_auth! header_params, query_params, opts[:auth_names]
112
+
113
+ req_opts = {
114
+ :method => http_method,
115
+ :headers => header_params,
116
+ :params => query_params,
117
+ :body => body
118
+ }
119
+
120
+ if [:post, :patch, :put, :delete].include?(http_method)
121
+ req_body = build_request_body(header_params, form_params, opts[:body])
122
+ req_opts.update :body => req_body
123
+ if @config.debugging
124
+ @config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n"
125
+ end
126
+ end
127
+
128
+ # OAuth 2.0
129
+ req_opts[:params] = opts[:query_params]
130
+
131
+ if @config.access_token
132
+ add_o_auth_token(req_opts)
133
+ end
134
+
135
+ conn = Faraday.new url, {:params => query_params, :headers => header_params} do |f|
136
+ f.request :multipart
137
+ f.request :url_encoded
138
+ f.adapter Faraday.default_adapter
139
+ end
140
+
141
+ if req_opts[:body] == {}
142
+ req_opts[:body] = nil
143
+ end
144
+
145
+ case http_method
146
+ when :post
147
+ return conn.post url, req_opts[:body]
148
+ when :put
149
+ return conn.put url, req_opts[:body]
150
+ when :get
151
+ return conn.get url, req_opts[:body]
152
+ else
153
+ return conn.delete url do |c|
154
+ c.body = req_opts[:body]
155
+ end
156
+ end
157
+ end
158
+
159
+ # Check if the given MIME is a JSON MIME.
160
+ # JSON MIME examples:
161
+ # application/json
162
+ # application/json; charset=UTF8
163
+ # APPLICATION/JSON
164
+ # */*
165
+ # @param [String] mime MIME
166
+ # @return [Boolean] True if the MIME is application/json
167
+ def json_mime?(mime)
168
+ (mime == "*/*") || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
169
+ end
170
+
171
+ # Deserialize the response to the given return type.
172
+ #
173
+ # @param [Response] response HTTP response
174
+ # @param [String] return_type some examples: "User", "Array[User]", "Hash[String,Integer]"
175
+ def deserialize(response, return_type)
176
+ body = response.body
177
+
178
+ # handle file downloading - return the File instance processed in request callbacks
179
+ # note that response body is empty when the file is written in chunks in request on_body callback
180
+ return @tempfile if return_type == 'File'
181
+
182
+ return nil if body.nil? || body.empty?
183
+
184
+ # return response body directly for String return type
185
+ return body if return_type == 'String'
186
+
187
+ # ensuring a default content type
188
+ content_type = response.headers['Content-Type'] || 'application/json'
189
+
190
+ raise "Content-Type is not supported: #{content_type}" unless json_mime?(content_type)
191
+
192
+ begin
193
+ data = JSON.parse("[#{body}]", :symbolize_names => true)[0]
194
+ rescue JSON::ParserError => e
195
+ if %w(String Date DateTime).include?(return_type)
196
+ data = body
197
+ else
198
+ raise e
199
+ end
200
+ end
201
+
202
+ convert_to_type data, return_type
203
+ end
204
+
205
+ # Convert data to the given return type.
206
+ # @param [Object] data Data to be converted
207
+ # @param [String] return_type Return type
208
+ # @return [Mixed] Data in a particular type
209
+ def convert_to_type(data, return_type)
210
+ return nil if data.nil?
211
+ case return_type
212
+ when 'String'
213
+ data.to_s
214
+ when 'Integer'
215
+ data.to_i
216
+ when 'Float'
217
+ data.to_f
218
+ when 'BOOLEAN'
219
+ data == true
220
+ when 'DateTime'
221
+ # parse date time (expecting ISO 8601 format)
222
+ DateTime.parse data
223
+ when 'Date'
224
+ # parse date time (expecting ISO 8601 format)
225
+ Date.parse data
226
+ when 'Object'
227
+ # generic object (usually a Hash), return directly
228
+ data
229
+ when /\AArray<(.+)>\z/
230
+ # e.g. Array<Pet>
231
+ sub_type = $1
232
+ data.map {|item| convert_to_type(item, sub_type) }
233
+ when /\AHash\<String, (.+)\>\z/
234
+ # e.g. Hash<String, Integer>
235
+ sub_type = $1
236
+ {}.tap do |hash|
237
+ data.each {|k, v| hash[k] = convert_to_type(v, sub_type) }
238
+ end
239
+ else
240
+ # models, e.g. Pet
241
+ AsposeCellsCloud.const_get(return_type).new.tap do |model|
242
+ model.build_from_hash data
243
+ end
244
+ end
245
+ end
246
+
247
+ # Save response body into a file in (the defined) temporary folder, using the filename
248
+ # from the "Content-Disposition" header if provided, otherwise a random filename.
249
+ # The response body is written to the file in chunks in order to handle files which
250
+ # size is larger than maximum Ruby String or even larger than the maximum memory a Ruby
251
+ # process can use.
252
+ #
253
+ # @see Configuration#temp_folder_path
254
+ def download_file(response)
255
+ tempfile = nil
256
+ encoding = nil
257
+
258
+ content_disposition = response.headers['Content-Disposition']
259
+ if content_disposition and content_disposition =~ /filename=/i
260
+ filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
261
+ prefix = sanitize_filename(filename)
262
+ else
263
+ prefix = 'download-'
264
+ end
265
+ prefix = prefix + '-' unless prefix.end_with?('-')
266
+ encoding = response.body.encoding
267
+ tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
268
+ @tempfile = tempfile
269
+
270
+ tempfile.write(response.body)
271
+
272
+ response.on_complete do |resp|
273
+ tempfile.close
274
+ @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
275
+ "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
276
+ "will be deleted automatically with GC. It's also recommended to delete the temp file "\
277
+ "explicitly with `tempfile.delete`"
278
+ end
279
+ end
280
+
281
+ # Sanitize filename by removing path.
282
+ # e.g. ../../sun.gif becomes sun.gif
283
+ #
284
+ # @param [String] filename the filename to be sanitized
285
+ # @return [String] the sanitized filename
286
+ def sanitize_filename(filename)
287
+ filename.gsub(/.*[\/\\]/, '')
288
+ end
289
+
290
+ def build_request_url(path)
291
+ # Add leading and trailing slashes to path
292
+ path = "/#{path}".gsub(/\/+/, '/')
293
+ URI.encode(@config.base_url + path)
294
+ end
295
+
296
+ # Builds the HTTP request body
297
+ #
298
+ # @param [Hash] header_params Header parameters
299
+ # @param [Hash] form_params Query parameters
300
+ # @param [Object] body HTTP body (JSON/XML)
301
+ # @return [String] HTTP body data in the form of string
302
+ def build_request_body(header_params, form_params, body)
303
+ # http form
304
+ if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
305
+ header_params['Content-Type'] == 'multipart/form-data'
306
+ data = {}
307
+ form_params.each do |key, value|
308
+ case value
309
+ when ::File
310
+ data[key] = Faraday::UploadIO.new(value.path, MimeMagic.by_magic(value).to_s, key)
311
+ when ::Array, nil
312
+ # let typhoeus handle File, Array and nil parameters
313
+ data[key] = value
314
+ else
315
+ data[key] = value.to_s
316
+ end
317
+ end
318
+ elsif body
319
+ data = body.is_a?(String) ? body : body.to_json
320
+ else
321
+ data = nil
322
+ end
323
+ data
324
+ end
325
+
326
+ # Update hearder and query params based on authentication settings.
327
+ #
328
+ # @param [Hash] header_params Header parameters
329
+ # @param [Hash] query_params Query parameters
330
+ # @param [String] auth_names Authentication scheme name
331
+ def update_params_for_auth!(header_params, query_params, auth_names)
332
+ Array(auth_names).each do |auth_name|
333
+ auth_setting = @config.auth_settings[auth_name]
334
+ next unless auth_setting
335
+ case auth_setting[:in]
336
+ when 'header' then header_params[auth_setting[:key]] = auth_setting[:value]
337
+ when 'query' then query_params[auth_setting[:key]] = auth_setting[:value]
338
+ else raise ArgumentError, 'Authentication token must be in `query` of `header`'
339
+ end
340
+ end
341
+ end
342
+
343
+ # Sets user agent in HTTP header
344
+ #
345
+ # @param [String] user_agent User agent (e.g. swagger-codegen/ruby/1.0.0)
346
+ def user_agent=(user_agent)
347
+ @user_agent = user_agent
348
+ @default_headers['User-Agent'] = @user_agent
349
+ end
350
+
351
+ # Return Accept header based on an array of accepts provided.
352
+ # @param [Array] accepts array for Accept
353
+ # @return [String] the Accept header (e.g. application/json)
354
+ def select_header_accept(accepts)
355
+ return nil if accepts.nil? || accepts.empty?
356
+ # use JSON when present, otherwise use all of the provided
357
+ json_accept = accepts.find { |s| json_mime?(s) }
358
+ return json_accept || accepts.join(',')
359
+ end
360
+
361
+ # Return Content-Type header based on an array of content types provided.
362
+ # @param [Array] content_types array for Content-Type
363
+ # @return [String] the Content-Type header (e.g. application/json)
364
+ def select_header_content_type(content_types)
365
+ # use application/json by default
366
+ return 'application/json' if content_types.nil? || content_types.empty?
367
+ # use JSON when present, otherwise use the first one
368
+ json_content_type = content_types.find { |s| json_mime?(s) }
369
+ return json_content_type || content_types.first
370
+ end
371
+
372
+ # Convert object (array, hash, object, etc) to JSON string.
373
+ # @param [Object] model object to be converted into JSON string
374
+ # @return [String] JSON string representation of the object
375
+ def object_to_http_body(model)
376
+ return '"' + model + '"' if model.is_a?(String)
377
+ return model if model.nil?
378
+ local_body = nil
379
+ if model.is_a?(Array)
380
+ local_body = model.map{|m| object_to_hash(m) }
381
+ else
382
+ local_body = object_to_hash(model)
383
+ end
384
+ local_body.to_json
385
+ end
386
+
387
+ # Convert object(non-array) to hash.
388
+ # @param [Object] obj object to be converted into JSON string
389
+ # @return [String] JSON string representation of the object
390
+ def object_to_hash(obj)
391
+ if obj.respond_to?(:to_hash)
392
+ obj.to_hash
393
+ else
394
+ obj
395
+ end
396
+ end
397
+
398
+ # Build parameter value according to the given collection format.
399
+ # @param [String] collection_format one of :csv, :ssv, :tsv, :pipes and :multi
400
+ def build_collection_param(param, collection_format)
401
+ case collection_format
402
+ when :csv
403
+ param.join(',')
404
+ when :ssv
405
+ param.join(' ')
406
+ when :tsv
407
+ param.join("\t")
408
+ when :pipes
409
+ param.join('|')
410
+ when :multi
411
+ # return the array directly as faraday will handle it as expected
412
+ param
413
+ else
414
+ fail "unknown collection format: #{collection_format.inspect}"
415
+ end
416
+ end
417
+
418
+ # Request access and refresh tokens if needed
419
+ def request_token_if_needed
420
+ # check token exists
421
+ if @config.client_id.nil? && @config.client_secret.nil?
422
+ return
423
+ end
424
+ if @config.access_token
425
+ now = Time.now
426
+ time_difference = now - $get_access_token_time
427
+ if time_difference < 86300
428
+ return
429
+ end
430
+ end
431
+
432
+ # resource path
433
+ local_var_path = "/connect/token"
434
+ if @config.api_version === "v1.1"
435
+ local_var_path ="/oauth2/token"
436
+ end
437
+ url = build_request_url(local_var_path).gsub('/'+config.api_version, '')
438
+ #url = build_request_url(local_var_path).gsub('/v3.0', '')
439
+
440
+ # header parameters
441
+ header_params = {}
442
+ # HTTP header 'Content-Type'
443
+ header_params['Content-Type'] = select_header_content_type(['application/x-www-form-urlencoded'])
444
+
445
+ query_params = {}
446
+ # form parameters
447
+ form_params = {}
448
+ form_params["grant_type"] = 'client_credentials'
449
+ form_params["client_id"] = @config.client_id
450
+ form_params["client_secret"] = @config.client_secret
451
+
452
+ body = {}
453
+
454
+
455
+ req_opts = {
456
+ :headers => header_params,
457
+ :params => query_params,
458
+ :body => body
459
+ }
460
+
461
+
462
+ req_body = build_request_body(header_params, form_params, body)
463
+ req_opts.update :body => req_body
464
+
465
+ req_opts[:params] = query_params
466
+
467
+
468
+ conn = Faraday.new url, {:params => query_params, :headers => header_params} do |f|
469
+ f.request :multipart
470
+ f.request :url_encoded
471
+ f.adapter Faraday.default_adapter
472
+ end
473
+
474
+ if req_opts[:body] == {}
475
+ req_opts[:body] = nil
476
+ end
477
+
478
+
479
+ response = conn.post url, form_params, req_opts[:body]
480
+ data = JSON.parse("[#{response.body}]", :symbolize_names => true)[0]
481
+
482
+ @config.access_token = data[:access_token]
483
+
484
+ $get_access_token_time = Time.now
485
+ end
486
+
487
+ # Adds OAuth2.0 token
488
+ def add_o_auth_token(req_opts)
489
+ req_opts[:headers][:Authorization] = "Bearer " + @config.access_token
490
+ end
491
+
492
+ end
493
+ end