diff --git a/README.md b/README.md index 7544c4f..7d9bd1f 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Aspose.Cells Cloud SDK for Ruby - API version: 3.0 -- SDK version: 19.10 +- SDK version: 20.2 This repository contains Aspose.Cells Cloud SDK for Ruby source code. This SDK allows you to work with Aspose.Cells Cloud REST APIs in your Ruby applications quickly and easily, with zero initial cost. @@ -54,7 +54,7 @@ The complete source code is available in this repository folder. You can either -To use Aspose.Cells Cloud SDK you need to register an account with [Aspose Cloud](https://www.aspose.cloud/) and lookup/create App Key and SID at [Cloud Dashboard](https://dashboard.aspose.cloud/#/apps). There is free quota available. For more details, see [Aspose Cloud Pricing](https://purchase.aspose.cloud/pricing). +To use Aspose.Cells Cloud SDK for Ruby you need to register an account with [Aspose Cloud](https://www.aspose.cloud/) and lookup/create App Key and SID at [Cloud Dashboard](https://dashboard.aspose.cloud/#/apps). There is free quota available. For more details, see [Aspose Cloud Pricing](https://purchase.aspose.cloud/pricing). diff --git a/lib/aspose_cells_cloud/api/cells_api.rb b/lib/aspose_cells_cloud/api/cells_api.rb index 316a26a..5d1410d 100644 --- a/lib/aspose_cells_cloud/api/cells_api.rb +++ b/lib/aspose_cells_cloud/api/cells_api.rb @@ -14949,7 +14949,7 @@ def cells_workbook_put_convert_workbook_with_http_info(workbook, opts = {}) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) - + header_params['Content-Type'] = @api_client.select_header_content_type(['application/octet-stream']) # form parameters form_params = {} @@ -15015,7 +15015,8 @@ def cells_workbook_put_document_protect_from_changes_with_http_info(name, opts = header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) - + header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data']) + header_params['Content-Type'] = @api_client.select_header_content_type(['application/octet-stream']) # form parameters form_params = {} diff --git a/lib/aspose_cells_cloud/api_client.rb b/lib/aspose_cells_cloud/api_client.rb index b9052ba..8f95f49 100644 --- a/lib/aspose_cells_cloud/api_client.rb +++ b/lib/aspose_cells_cloud/api_client.rb @@ -39,6 +39,7 @@ class ApiClient # @return [Hash] attr_accessor :default_headers + attr_accessor :get_access_token_time # Initializes the ApiClient # @option config [Configuration] Configuration for initializing the object, default to Configuration.default def initialize(config = Configuration.default) @@ -415,9 +416,14 @@ def build_collection_param(param, collection_format) # Request access and refresh tokens if needed def request_token_if_needed + # check token exists if @config.access_token - return + now = Time.now + time_difference = now - $get_access_token_time + if time_difference < 86300 + return + end end # resource path @@ -471,6 +477,8 @@ def request_token_if_needed data = JSON.parse("[#{response.body}]", :symbolize_names => true)[0] @config.access_token = data[:access_token] + + $get_access_token_time = Time.now end # Adds OAuth2.0 token diff --git a/lib/aspose_cells_cloud/version.rb b/lib/aspose_cells_cloud/version.rb index bf02ec6..3f42cfb 100644 --- a/lib/aspose_cells_cloud/version.rb +++ b/lib/aspose_cells_cloud/version.rb @@ -21,5 +21,5 @@ =end module AsposeCellsCloud - VERSION = "20.1" + VERSION = "20.2" end diff --git a/spec/api/cells_storage_api_spec.rb b/spec/api/cells_storage_api_spec.rb index f50ef89..c5d9e48 100644 --- a/spec/api/cells_storage_api_spec.rb +++ b/spec/api/cells_storage_api_spec.rb @@ -37,20 +37,20 @@ it "should work" do name ="ReportData.xml" folder = $TEMPFOLDER -# stream = File.read("/home/roywang/asposecellscloudsdk/data/" << name) +# stream = File.read("data/" << name) # @instance.object_exists(name) # @instance.storage_exists("Default App"); # filename = folder +"/" + name -# aFile = File.new("/home/roywang/asposecellscloudsdk/data/" +name , 'rb') +# aFile = File.new("data/" +name , 'rb') # stream = aFile.sysread(aFile.size) # aFile.close -# binary_file = File.open("/home/roywang/asposecellscloudsdk/data/" +name, "rb") +# binary_file = File.open("data/" +name, "rb") # data = [ # [ "import[sync]","false" ], # [ "import[name]", stream, { filename: "Book1.xlsx"} ] # ] -# stream = File.open("/home/roywang/asposecellscloudsdk/data/" +name,"r") {|io| io.read(io.size) } - @instance.upload_file( "Temp/ReportData.xml", ::File.open("/home/roywang/asposecellscloudsdk/data/" +name,"r") {|io| io.read(io.size) }) +# stream = File.open("data/" +name,"r") {|io| io.read(io.size) } + @instance.upload_file( "Temp/ReportData.xml", ::File.open("data/" +name,"r") {|io| io.read(io.size) }) # @instance.copy_file(name , folder +"/1"+ name) # @instance.copy_folder(folder, folder + "2"); # @instance.move_folder(folder+ "2", folder + "3"); diff --git a/spec/api/cells_storage_spec.rb b/spec/api/cells_storage_spec.rb index bef5acd..3e1a4b4 100644 --- a/spec/api/cells_storage_spec.rb +++ b/spec/api/cells_storage_spec.rb @@ -31,18 +31,17 @@ folder = $TEMPFOLDER @instance.create_folder("ruby") @instance.copy_folder("ruby","ruby1") - @instance.delete_folder("ruby") @instance.move_folder("ruby1","ruby") - @instance.upload_file( "ruby/"+name, ::File.open("/home/roywang/asposecellscloudsdk/data/" +name,"r") {|io| io.read(io.size) }) + @instance.upload_file( "ruby/"+name, ::File.open("data/" +name,"r") {|io| io.read(io.size) }) @instance.copy_file("ruby/"+name,"ruby/1"+name) @instance.delete_file("ruby/"+name) @instance.move_file("ruby/1"+name,"ruby/"+name) @instance.download_file("ruby/"+name) -# @instance.delete_file("ruby/"+name) -# @instance.delete_folder("ruby") + @instance.delete_file("ruby/"+name) + @instance.delete_folder("ruby") - #@instance.cells_workbook_put_convert_workbook(::File.open("/home/roywang/asposecellscloudsdk/data/Book1.xlsx","r") {|io| io.read(io.size) },{:format=>format,out_path=>out_path}) + #@instance.cells_workbook_put_convert_workbook(::File.open("data/Book1.xlsx","r") {|io| io.read(io.size) },{:format=>format,out_path=>out_path}) # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers end end diff --git a/spec/api/cells_workbook_api_spec.rb b/spec/api/cells_workbook_api_spec.rb index 8c3fb48..b808b40 100644 --- a/spec/api/cells_workbook_api_spec.rb +++ b/spec/api/cells_workbook_api_spec.rb @@ -435,7 +435,7 @@ format = 'pdf' password = nil out_path = "Tdd.pdf" - result = @instance.cells_workbook_put_convert_workbook(::File.open("/home/roywang/asposecellscloudsdk/data/Book1.xlsx","r") {|io| io.read(io.size) },{:format=>format,out_path=>out_path}) + result = @instance.cells_workbook_put_convert_workbook(::File.open("data/Book1.xlsx","r") {|io| io.read(io.size) },{:format=>format,out_path=>out_path}) # expect(result.code).to eql(200) # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers end diff --git a/spec/api/cells_worksheets_api_spec.rb b/spec/api/cells_worksheets_api_spec.rb index 42a7b0a..60b1669 100644 --- a/spec/api/cells_worksheets_api_spec.rb +++ b/spec/api/cells_worksheets_api_spec.rb @@ -40,7 +40,7 @@ it "should work" do name = $BOOK1 sheet_name = $SHEET1 - aFile = File.new('/home/roywang/asposecellscloudsdk/data/WaterMark.png', 'r') + aFile = File.new('data/WaterMark.png', 'r') png = aFile.sysread(aFile.size) aFile.close folder = $TEMPFOLDER @@ -617,7 +617,7 @@ cell_name = 'C1' comment = AsposeCellsCloud::Comment.new({:Author=>'Roy'}) folder = $TEMPFOLDER - @instance.upload_file( folder+"/"+name, ::File.open("/home/roywang/asposecellscloudsdk/data/" +name,"r") {|io| io.read(io.size) }) + @instance.upload_file( folder+"/"+name, ::File.open("data/" +name,"r") {|io| io.read(io.size) }) @instance.cells_worksheets_put_worksheet_comment(name, sheet_name, cell_name, {:comment=>comment, :folder=>folder}) # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 11fa5df..295122a 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -13,8 +13,8 @@ # load the gem require 'aspose_cells_cloud' $grant_type = 'client_credentials' # replace NULL with a proper value - $client_id = '66164C51-693E-4904-A121-545961673EC1' # '66164C51-693E-4904-A121-545961673EC1' # replace NULL with a proper value - $client_secret = '536e76768419db9585afdd37bb5f7533' # '536e76768419db9585afdd37bb5f7533' # replace NULL with a proper value + $client_id = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' # replace NULL with a proper value + $client_secret = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' # replace NULL with a proper value $access_token $BOOK1 = "Book1.xlsx" $MYDOC = "myDocument.xlsx"