Class: GroupDocsViewerCloud::ViewApi

Inherits:
Object
  • Object
show all
Defined in:
lib/groupdocs_viewer_cloud/api/view_api.rb

Overview

GroupDocs.Viewer Cloud API

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ ViewApi

Initializes new instance of ViewApi

Parameters:



43
44
45
46
47
# File 'lib/groupdocs_viewer_cloud/api/view_api.rb', line 43

def initialize(config)
  @config = config
  @api_client = ApiClient.new(config)
  @access_token = nil
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



34
35
36
# File 'lib/groupdocs_viewer_cloud/api/view_api.rb', line 34

def config
  @config
end

Class Method Details

.from_config(config) ⇒ ViewApi

Initializes new instance of ViewApi

Parameters:

Returns:

  • (ViewApi)

    New instance of ViewApi



63
64
65
# File 'lib/groupdocs_viewer_cloud/api/view_api.rb', line 63

def self.from_config(config)
  return new(config)
end

.from_keys(app_sid, app_key) ⇒ ViewApi

Initializes new instance of ViewApi

Parameters:

  • Application (app_sid)

    identifier (App SID)

  • Application (app_key)

    private key (App Key)

Returns:

  • (ViewApi)

    New instance of ViewApi



54
55
56
57
# File 'lib/groupdocs_viewer_cloud/api/view_api.rb', line 54

def self.from_keys(app_sid, app_key)
  config = Configuration.new(app_sid, app_key)
  return new(config)
end

Instance Method Details

#convert_and_download(request) ⇒ File

Converts input document file to format specified

Parameters:

  • request

    convert_and_download_request

Returns:

  • (File)


71
72
73
74
# File 'lib/groupdocs_viewer_cloud/api/view_api.rb', line 71

def convert_and_download(request)
  data, _status_code, _headers = convert_and_download_with_http_info(request)
  data
end

#convert_and_download_with_http_info(request) ⇒ Array<(File, Fixnum, Hash)>

Converts input document file to format specified

File data, response status code and response headers

Parameters:

  • request

    convert_and_download_request

Returns:

  • (Array<(File, Fixnum, Hash)>)

Raises:

  • (ArgumentError)


81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/groupdocs_viewer_cloud/api/view_api.rb', line 81

def convert_and_download_with_http_info(request)
  raise ArgumentError, 'Incorrect request type' unless request.is_a? ConvertAndDownloadRequest

  @api_client.config.logger.debug 'Calling API: ViewApi.convert_and_download ...' if @api_client.config.debugging
  # verify the required parameter 'format' is set
  raise ArgumentError, 'Missing the required parameter format when calling ViewApi.convert_and_download' if @api_client.config.client_side_validation && request.format.nil?
  # verify the required parameter 'file' is set
  raise ArgumentError, 'Missing the required parameter file when calling ViewApi.convert_and_download' if @api_client.config.client_side_validation && request.file.nil?
  # resource path
  local_var_path = '/viewer/convertAndDownload'

  # query parameters
  query_params = {}
  query_params[downcase_first_letter('format')] = request.format

  if local_var_path.include? ('{' + downcase_first_letter('pages') + '}')
    local_var_path = local_var_path.sub('{' + downcase_first_letter('pages') + '}', request.pages.to_s)
  else
    query_params[downcase_first_letter('pages')] = request.pages unless request.pages.nil?
  end
  if local_var_path.include? ('{' + downcase_first_letter('password') + '}')
    local_var_path = local_var_path.sub('{' + downcase_first_letter('password') + '}', request.password.to_s)
  else
    query_params[downcase_first_letter('password')] = request.password unless request.password.nil?
  end

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])

  # form parameters
  form_params = {}
  form_params[downcase_first_letter('File')] = request.file

  # http body (model)
  post_body = nil
  data, status_code, headers = @api_client.call_api(:PUT, local_var_path,
                                                    header_params: header_params,
                                                    query_params: query_params,
                                                    form_params: form_params,
                                                    body: post_body,
                                                    access_token: get_access_token,
                                                    return_type: 'File')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called:
    ViewApi#convert_and_download\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  [data, status_code, headers]
end

#create_view(request) ⇒ ViewResult

Render document pages

Parameters:

  • request

    create_view_request

Returns:



138
139
140
141
# File 'lib/groupdocs_viewer_cloud/api/view_api.rb', line 138

def create_view(request)
  data, _status_code, _headers = create_view_with_http_info(request)
  data
end

#create_view_with_http_info(request) ⇒ Array<(ViewResult, Fixnum, Hash)>

Render document pages

ViewResult data, response status code and response headers

Parameters:

  • request

    create_view_request

Returns:

Raises:

  • (ArgumentError)


148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# File 'lib/groupdocs_viewer_cloud/api/view_api.rb', line 148

def create_view_with_http_info(request)
  raise ArgumentError, 'Incorrect request type' unless request.is_a? CreateViewRequest

  @api_client.config.logger.debug 'Calling API: ViewApi.create_view ...' if @api_client.config.debugging
  # verify the required parameter 'view_options' is set
  raise ArgumentError, 'Missing the required parameter view_options when calling ViewApi.create_view' if @api_client.config.client_side_validation && request.view_options.nil?
  # resource path
  local_var_path = '/viewer/view'

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  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'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = @api_client.object_to_http_body(request.view_options)
  data, status_code, headers = @api_client.call_api(:POST, local_var_path,
                                                    header_params: header_params,
                                                    query_params: query_params,
                                                    form_params: form_params,
                                                    body: post_body,
                                                    access_token: get_access_token,
                                                    return_type: 'ViewResult')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called:
    ViewApi#create_view\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  [data, status_code, headers]
end

#delete_view(request) ⇒ nil

Delete rendered pages

Parameters:

  • request

    delete_view_request

Returns:

  • (nil)


190
191
192
193
# File 'lib/groupdocs_viewer_cloud/api/view_api.rb', line 190

def delete_view(request)
  delete_view_with_http_info(request)
  nil
end

#delete_view_with_http_info(request) ⇒ Array<(nil, Fixnum, Hash)>

Delete rendered pages

nil, response status code and response headers

Parameters:

  • request

    delete_view_request

Returns:

  • (Array<(nil, Fixnum, Hash)>)

Raises:

  • (ArgumentError)


200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
# File 'lib/groupdocs_viewer_cloud/api/view_api.rb', line 200

def delete_view_with_http_info(request)
  raise ArgumentError, 'Incorrect request type' unless request.is_a? DeleteViewRequest

  @api_client.config.logger.debug 'Calling API: ViewApi.delete_view ...' if @api_client.config.debugging
  # verify the required parameter 'delete_view_options' is set
  raise ArgumentError, 'Missing the required parameter delete_view_options when calling ViewApi.delete_view' if @api_client.config.client_side_validation && request.delete_view_options.nil?
  # resource path
  local_var_path = '/viewer/view'

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  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'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = @api_client.object_to_http_body(request.delete_view_options)
  data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,
                                                    header_params: header_params,
                                                    query_params: query_params,
                                                    form_params: form_params,
                                                    body: post_body,
                                                    access_token: get_access_token)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called:
    ViewApi#delete_view\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  [data, status_code, headers]
end