Skip to content

Commit 59c5d87

Browse files
committed
Updated sources
1 parent e8398fc commit 59c5d87

11 files changed

Lines changed: 323 additions & 201 deletions

Gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
groupdocs_viewer_cloud (19.3)
4+
groupdocs_viewer_cloud (19.5)
55
addressable (~> 2.5.0, >= 2.5.0)
66
faraday (~> 0.14.0)
77
mimemagic (~> 0.3.2)
@@ -15,7 +15,7 @@ GEM
1515
multipart-post (>= 1.2, < 3)
1616
mimemagic (0.3.3)
1717
minitest (5.11.3)
18-
multipart-post (2.0.0)
18+
multipart-post (2.1.1)
1919
public_suffix (3.0.3)
2020
rake (12.0.0)
2121

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ gem install groupdocs_viewer_cloud
1212
To add dependency to your app copy following into your Gemfile and run `bundle install`:
1313

1414
```
15-
gem "groupdocs_viewer_cloud", "~> 19.4"
15+
gem "groupdocs_viewer_cloud", "~> 19.5"
1616
```
1717

1818
## Getting Started
@@ -27,7 +27,7 @@ app_sid = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
2727
app_key = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
2828

2929
# Create instance of the API class
30-
api = GroupDocsViewerCloud::ViewerApi.from_keys(app_sid, app_key)
30+
api = GroupDocsViewerCloud::InfoApi.from_keys(app_sid, app_key)
3131

3232
# Retrieve supported file-formats
3333
response = api.get_supported_file_formats

lib/groupdocs_viewer_cloud.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,6 @@
6767
# APIs
6868
require_relative 'groupdocs_viewer_cloud/api/file_api'
6969
require_relative 'groupdocs_viewer_cloud/api/folder_api'
70+
require_relative 'groupdocs_viewer_cloud/api/info_api'
7071
require_relative 'groupdocs_viewer_cloud/api/storage_api'
71-
require_relative 'groupdocs_viewer_cloud/api/viewer_api'
72+
require_relative 'groupdocs_viewer_cloud/api/view_api'
Lines changed: 266 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,266 @@
1+
# -----------------------------------------------------------------------------------
2+
# <copyright company="Aspose Pty Ltd" file="info.rb">
3+
# Copyright (c) 2003-2019 Aspose Pty Ltd
4+
# </copyright>
5+
# <summary>
6+
# Permission is hereby granted, free of charge, to any person obtaining a copy
7+
# of this software and associated documentation files (the "Software"), to deal
8+
# in the Software without restriction, including without limitation the rights
9+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
# copies of the Software, and to permit persons to whom the Software is
11+
# furnished to do so, subject to the following conditions:
12+
#
13+
# The above copyright notice and this permission notice shall be included in all
14+
# copies or substantial portions of the Software.
15+
#
16+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
# SOFTWARE.
23+
# </summary>
24+
# -----------------------------------------------------------------------------------
25+
26+
require 'uri'
27+
require 'date'
28+
29+
module GroupDocsViewerCloud
30+
#
31+
# GroupDocs.Viewer Cloud API
32+
#
33+
class InfoApi
34+
attr_accessor :config
35+
36+
#make InfoApi.new private
37+
private_class_method :new
38+
39+
# Initializes new instance of InfoApi
40+
#
41+
# @param [config] Configuration
42+
# @return [InfoApi] New instance of InfoApi
43+
def initialize(config)
44+
@config = config
45+
@api_client = ApiClient.new(config)
46+
@access_token = nil
47+
end
48+
49+
# Initializes new instance of InfoApi
50+
#
51+
# @param [app_sid] Application identifier (App SID)
52+
# @param [app_key] Application private key (App Key)
53+
# @return [InfoApi] New instance of InfoApi
54+
def self.from_keys(app_sid, app_key)
55+
config = Configuration.new(app_sid, app_key)
56+
return new(config)
57+
end
58+
59+
# Initializes new instance of InfoApi
60+
#
61+
# @param [config] Configuration
62+
# @return [InfoApi] New instance of InfoApi
63+
def self.from_config(config)
64+
return new(config)
65+
end
66+
67+
# Retrieve information about document pages
68+
#
69+
# @param request get_info_request
70+
# @return [InfoResult]
71+
def get_info(request)
72+
data, _status_code, _headers = get_info_with_http_info(request)
73+
data
74+
end
75+
76+
# Retrieve information about document pages
77+
#
78+
# @param request get_info_request
79+
# @return [Array<(InfoResult, Fixnum, Hash)>]
80+
# InfoResult data, response status code and response headers
81+
def get_info_with_http_info(request)
82+
raise ArgumentError, 'Incorrect request type' unless request.is_a? GetInfoRequest
83+
84+
@api_client.config.logger.debug 'Calling API: InfoApi.get_info ...' if @api_client.config.debugging
85+
# verify the required parameter 'view_options' is set
86+
raise ArgumentError, 'Missing the required parameter view_options when calling InfoApi.get_info' if @api_client.config.client_side_validation && request.view_options.nil?
87+
# resource path
88+
local_var_path = '/viewer/info'
89+
90+
# query parameters
91+
query_params = {}
92+
93+
# header parameters
94+
header_params = {}
95+
# HTTP header 'Accept' (if needed)
96+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
97+
# HTTP header 'Content-Type'
98+
header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
99+
100+
# form parameters
101+
form_params = {}
102+
103+
# http body (model)
104+
post_body = @api_client.object_to_http_body(request.view_options)
105+
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
106+
header_params: header_params,
107+
query_params: query_params,
108+
form_params: form_params,
109+
body: post_body,
110+
access_token: get_access_token,
111+
return_type: 'InfoResult')
112+
if @api_client.config.debugging
113+
@api_client.config.logger.debug "API called:
114+
InfoApi#get_info\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
115+
end
116+
[data, status_code, headers]
117+
end
118+
119+
# List supported file formats
120+
#
121+
# @return [FormatsResult]
122+
def get_supported_file_formats()
123+
data, _status_code, _headers = get_supported_file_formats_with_http_info()
124+
data
125+
end
126+
127+
# List supported file formats
128+
#
129+
130+
# @return [Array<(FormatsResult, Fixnum, Hash)>]
131+
# FormatsResult data, response status code and response headers
132+
def get_supported_file_formats_with_http_info()
133+
134+
135+
@api_client.config.logger.debug 'Calling API: InfoApi.get_supported_file_formats ...' if @api_client.config.debugging
136+
# resource path
137+
local_var_path = '/viewer/formats'
138+
139+
# query parameters
140+
query_params = {}
141+
142+
# header parameters
143+
header_params = {}
144+
# HTTP header 'Accept' (if needed)
145+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
146+
# HTTP header 'Content-Type'
147+
header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
148+
149+
# form parameters
150+
form_params = {}
151+
152+
# http body (model)
153+
post_body = nil
154+
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
155+
header_params: header_params,
156+
query_params: query_params,
157+
form_params: form_params,
158+
body: post_body,
159+
access_token: get_access_token,
160+
return_type: 'FormatsResult')
161+
if @api_client.config.debugging
162+
@api_client.config.logger.debug "API called:
163+
InfoApi#get_supported_file_formats\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
164+
end
165+
[data, status_code, headers]
166+
end
167+
168+
#
169+
# Helper method to convert first letter to downcase
170+
#
171+
private def downcase_first_letter(str)
172+
value = str[0].downcase + str[1..-1]
173+
value
174+
end
175+
176+
#
177+
# Retrieves access token
178+
#
179+
private def get_access_token
180+
if @access_token.nil? then
181+
request_access_token
182+
end
183+
184+
@access_token
185+
end
186+
187+
#
188+
# Gets a access token from server
189+
#
190+
private def request_access_token
191+
auth_config = Configuration.new(@config.app_sid, @config.app_key)
192+
auth_config.api_base_url = @config.api_base_url
193+
auth_config.debugging = @config.debugging
194+
auth_config.logger = @config.logger
195+
auth_config.temp_folder_path = @config.temp_folder_path
196+
auth_config.client_side_validation = @config.client_side_validation
197+
auth_config.api_version = ''
198+
199+
auth_api_client = ApiClient.new(auth_config)
200+
201+
request_url = "/connect/token"
202+
post_data = "grant_type=client_credentials&client_id=#{@config.app_sid}&client_secret=#{@config.app_key}"
203+
204+
data, _status_code, _header = auth_api_client.call_api(:POST, request_url, :body => post_data, :return_type => 'Object')
205+
206+
@access_token = data[:access_token]
207+
208+
expires_in_seconds = data[:expires_in].to_i - 5 * 60
209+
expires_in_days = Rational(expires_in_seconds, 60 * 60 * 24)
210+
@access_token_expires_at = DateTime.now + expires_in_days
211+
end
212+
213+
# requires all files inside a directory from current dir
214+
# @param _dir can be relative path like '/lib' or "../lib"
215+
private def require_all(_dir)
216+
Dir[File.expand_path(File.join(File.dirname(File.absolute_path(__FILE__)), _dir)) + "/*.rb"].each do |file|
217+
require file
218+
end
219+
end
220+
end
221+
end
222+
#
223+
# --------------------------------------------------------------------------------------------------------------------
224+
# <copyright company="Aspose Pty Ltd" file="get_info_request.rb">
225+
# Copyright (c) 2003-2019 Aspose Pty Ltd
226+
# </copyright>
227+
# <summary>
228+
# Permission is hereby granted, free of charge, to any person obtaining a copy
229+
# of this software and associated documentation files (the "Software"), to deal
230+
# in the Software without restriction, including without limitation the rights
231+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
232+
# copies of the Software, and to permit persons to whom the Software is
233+
# furnished to do so, subject to the following conditions:
234+
#
235+
# The above copyright notice and this permission notice shall be included in all
236+
# copies or substantial portions of the Software.
237+
#
238+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
239+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
240+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
241+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
242+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
243+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
244+
# SOFTWARE.
245+
# </summary>
246+
# --------------------------------------------------------------------------------------------------------------------
247+
#
248+
249+
module GroupDocsViewerCloud
250+
251+
#
252+
# Request model for get_info operation.
253+
#
254+
class GetInfoRequest
255+
256+
# View options
257+
attr_accessor :view_options
258+
259+
#
260+
# Initializes a new instance.
261+
# @param view_options View options
262+
def initialize(view_options)
263+
self.view_options = view_options
264+
end
265+
end
266+
end

0 commit comments

Comments
 (0)