Skip to content

Commit 0ea8ada

Browse files
authored
Merge pull request #71 from aspose-pdf-cloud/develop
update to 24.3
2 parents c931202 + 7f6e511 commit 0ea8ada

File tree

6 files changed

+52
-26
lines changed

6 files changed

+52
-26
lines changed

README.md

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ XLS, XLSX, PPTX, DOC, DOCX, MobiXML, JPEG, EMF, PNG, BMP, GIF, TIFF, Text
2929
## Read PDF Formats
3030
MHT, PCL, PS, XSLFO, MD
3131

32-
## Enhancements in Version 24.2
33-
- Memory leak when converting PDF to DOCX.
32+
## Enhancements in Version 24.3
3433
- A new version of Aspose.PDF Cloud was prepared using the latest version of Aspose.PDF for .NET.
3534

3635
## Installation
@@ -46,15 +45,15 @@ gem build aspose_pdf_cloud.gemspec
4645
Then either install the gem locally:
4746

4847
```shell
49-
gem install ./aspose_pdf_cloud-24.2.0.gem
48+
gem install ./aspose_pdf_cloud-24.3.0.gem
5049
```
51-
(for development, run `gem install --dev ./aspose_pdf_cloud-24.2.0.gem` to install the development dependencies)
50+
(for development, run `gem install --dev ./aspose_pdf_cloud-24.3.0.gem` to install the development dependencies)
5251

5352
or publish the gem to a gem hosting service, e.g. [RubyGems](https://rubygems.org/).
5453

5554
Finally add this to the Gemfile:
5655

57-
gem 'aspose_pdf_cloud', '~> 24.2.0'
56+
gem 'aspose_pdf_cloud', '~> 24.3.0'
5857

5958
### Install from Git
6059

@@ -67,19 +66,19 @@ Add the following in the Gemfile:
6766

6867
```ruby
6968
# Get your ClientId and ClientSecret from https://dashboard.aspose.cloud (free registration required).
69+
@pdf_api = PdfApi.new('MY_CLIENT_ID', 'MY_CLIENT_SECRET')
70+
file_name = 'PdfWithAnnotations.pdf'
71+
page_number = 2
72+
opts = {
73+
:folder => 'tempFolder'
74+
}
75+
response = @pdf_api.get_page_annotations(file_name, page_number, opts)
76+
```
7077

71-
AsposePdfCloud.configure do |config|
72-
config.client_data['ClientId'] = 'MY_CLIENT_ID'
73-
config.client_data['ClientSecret'] = 'MY_CLIENT_SECRET'
74-
config.host = host
75-
76-
file_name = 'PdfWithAnnotations.pdf'
77-
page_number = 2
78-
opts = {
79-
:folder => 'tempFolder'
80-
}
81-
82-
response = @pdf_api.get_page_annotations(file_name, page_number, opts)
78+
## SelfHost Aspose.PDF Cloud
79+
Create **PdfApi** object without **app_key** and **app_sid** parameters, but with **host** parameter set to *url of SelfHost Aspose.PDF Cloud* and **self_host** parameter set to *true*:
80+
```ruby
81+
@pdf_api = PdfApi.new('', '', 'MY_SELFHOST_URL', true)
8382
```
8483

8584
## Unit Tests

lib/aspose_pdf_cloud/api/pdf_api.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,18 @@ module AsposePdfCloud
2525
class PdfApi
2626
attr_accessor :api_client
2727

28-
def initialize(app_key, app_sid, api_client = ApiClient.default)
28+
def initialize(app_key, app_sid, host = "", self_host = false, api_client = ApiClient.default)
2929
@api_client = api_client
30+
@api_client.config.self_host = self_host
3031
@api_client.config.app_key = app_key
3132
@api_client.config.app_sid = app_sid
33+
if host != ""
34+
if @api_client.config.self_host
35+
@api_client.config.self_host_url = host
36+
else
37+
@api_client.config.host = host
38+
end
39+
end
3240
end
3341

3442

lib/aspose_pdf_cloud/api_client.rb

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,9 @@ def build_request(http_method, path, opts = {})
107107
form_params = opts[:form_params] || {}
108108
body = opts[:body] || {}
109109

110-
update_params_for_auth! header_params, query_params, opts[:auth_names]
110+
if !@config.self_host
111+
update_params_for_auth! header_params, query_params, opts[:auth_names]
112+
end
111113

112114
req_opts = {
113115
:method => http_method,
@@ -124,11 +126,12 @@ def build_request(http_method, path, opts = {})
124126
end
125127
end
126128

127-
# OAuth 2.0
128129
req_opts[:params] = opts[:query_params]
129130

130-
add_o_auth_token(req_opts)
131-
131+
if !@config.self_host
132+
# OAuth 2.0
133+
add_o_auth_token(req_opts)
134+
end
132135

133136
conn = Faraday.new url, {:params => query_params, :headers => header_params} do |f|
134137
f.request :multipart
@@ -411,6 +414,9 @@ def build_collection_param(param, collection_format)
411414

412415
# Request access and refresh tokens if needed
413416
def request_token_if_needed
417+
if @config.self_host
418+
return
419+
end
414420
# check token exists
415421
if @config.access_token
416422
return

lib/aspose_pdf_cloud/configuration.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@
2424
module AsposePdfCloud
2525
class Configuration
2626

27+
# SelfHost
28+
attr_accessor :self_host
29+
30+
# SelfHost URL
31+
attr_accessor :self_host_url
32+
2733
# App Key
2834
attr_accessor :app_key
2935

@@ -152,7 +158,11 @@ def host=(host)
152158
end
153159

154160
def base_url
155-
url = "#{scheme}://#{[host, '/v3.0'].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
161+
if @self_host
162+
url = self_host_url
163+
else
164+
url = "#{scheme}://#{[host, '/v3.0'].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
165+
end
156166
URI.encode(url)
157167
end
158168

lib/aspose_pdf_cloud/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@
2020
=end
2121

2222
module AsposePdfCloud
23-
VERSION = "24.2.0"
23+
VERSION = "24.3.0"
2424
end

test/pdf_tests.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,13 @@ class PdfTests < Minitest::Test
3232
def setup
3333
servercreds_json = File.read('../../../Settings/servercreds.json')
3434
creds = JSON.parse(servercreds_json)
35-
@pdf_api = PdfApi.new(creds["AppKey"], creds["AppSID"])
35+
self_host = creds.has_key?("SelfHost") ? creds["SelfHost"] : false
36+
app_key = creds.has_key?("AppKey") ? creds["AppKey"] : ""
37+
app_sid = creds.has_key?("AppSID") ? creds["AppSID"] : ""
38+
product_uri = creds.has_key?("ProductUri") ? creds["ProductUri"] : ""
39+
@pdf_api = PdfApi.new(app_key, app_sid, product_uri, self_host)
3640
@temp_folder = 'TempPdfCloud'
3741
@test_data_folder = '../test_data/'
38-
3942
config = @pdf_api.api_client.config
4043
config.scheme = 'https'
4144
end

0 commit comments

Comments
 (0)