Class: Hubspot::Files::Files::FilesApi

Inherits:
Object
  • Object
show all
Defined in:
lib/hubspot/codegen/files/files/api/files_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ FilesApi

Returns a new instance of FilesApi.



21
22
23
# File 'lib/hubspot/codegen/files/files/api/files_api.rb', line 21

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



19
20
21
# File 'lib/hubspot/codegen/files/files/api/files_api.rb', line 19

def api_client
  @api_client
end

Instance Method Details

#archive(file_id, opts = {}) ⇒ nil

Delete file Delete file by ID

Parameters:

  • file_id (String)

    File ID to delete

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (nil)


29
30
31
32
# File 'lib/hubspot/codegen/files/files/api/files_api.rb', line 29

def archive(file_id, opts = {})
  archive_with_http_info(file_id, opts)
  nil
end

#archive_gdpr(file_id, opts = {}) ⇒ nil

GDPR delete GDRP delete file

Parameters:

  • file_id (String)

    ID of file to GDPR delete

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (nil)


96
97
98
99
# File 'lib/hubspot/codegen/files/files/api/files_api.rb', line 96

def archive_gdpr(file_id, opts = {})
  archive_gdpr_with_http_info(file_id, opts)
  nil
end

#archive_gdpr_with_http_info(file_id, opts = {}) ⇒ Array<(nil, Integer, Hash)>

GDPR delete GDRP delete file

Parameters:

  • file_id (String)

    ID of file to GDPR delete

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

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

    nil, response status code and response headers



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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/hubspot/codegen/files/files/api/files_api.rb', line 106

def archive_gdpr_with_http_info(file_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: FilesApi.archive_gdpr ...'
  end
  # verify the required parameter 'file_id' is set
  if @api_client.config.client_side_validation && file_id.nil?
    fail ArgumentError, "Missing the required parameter 'file_id' when calling FilesApi.archive_gdpr"
  end
  pattern = Regexp.new(/\d+/)
  if @api_client.config.client_side_validation && file_id !~ pattern
    fail ArgumentError, "invalid value for 'file_id' when calling FilesApi.archive_gdpr, must conform to the pattern #{pattern}."
  end

  # resource path
  local_var_path = '/files/v3/files/{fileId}/gdpr-delete'.sub('{' + 'fileId' + '}', CGI.escape(file_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['*/*'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:body] 

  # return_type
  return_type = opts[:return_type] 

  # auth_names
  auth_names = opts[:auth_names] || ['hapikey', 'oauth2']

  new_options = opts.merge(
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: FilesApi#archive_gdpr\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#archive_with_http_info(file_id, opts = {}) ⇒ Array<(nil, Integer, Hash)>

Delete file Delete file by ID

Parameters:

  • file_id (String)

    File ID to delete

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

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

    nil, response status code and response headers



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/hubspot/codegen/files/files/api/files_api.rb', line 39

def archive_with_http_info(file_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: FilesApi.archive ...'
  end
  # verify the required parameter 'file_id' is set
  if @api_client.config.client_side_validation && file_id.nil?
    fail ArgumentError, "Missing the required parameter 'file_id' when calling FilesApi.archive"
  end
  pattern = Regexp.new(/\d+/)
  if @api_client.config.client_side_validation && file_id !~ pattern
    fail ArgumentError, "invalid value for 'file_id' when calling FilesApi.archive, must conform to the pattern #{pattern}."
  end

  # resource path
  local_var_path = '/files/v3/files/{fileId}'.sub('{' + 'fileId' + '}', CGI.escape(file_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['*/*'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:body] 

  # return_type
  return_type = opts[:return_type] 

  # auth_names
  auth_names = opts[:auth_names] || ['hapikey', 'oauth2']

  new_options = opts.merge(
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: FilesApi#archive\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#check_import(task_id, opts = {}) ⇒ FileActionResponse

Check import status. Check the status of requested import.

Parameters:

  • task_id (String)

    Import by URL task ID

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



163
164
165
166
# File 'lib/hubspot/codegen/files/files/api/files_api.rb', line 163

def check_import(task_id, opts = {})
  data, _status_code, _headers = check_import_with_http_info(task_id, opts)
  data
end

#check_import_with_http_info(task_id, opts = {}) ⇒ Array<(FileActionResponse, Integer, Hash)>

Check import status. Check the status of requested import.

Parameters:

  • task_id (String)

    Import by URL task ID

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(FileActionResponse, Integer, Hash)>)

    FileActionResponse data, response status code and response headers



173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
# File 'lib/hubspot/codegen/files/files/api/files_api.rb', line 173

def check_import_with_http_info(task_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: FilesApi.check_import ...'
  end
  # verify the required parameter 'task_id' is set
  if @api_client.config.client_side_validation && task_id.nil?
    fail ArgumentError, "Missing the required parameter 'task_id' when calling FilesApi.check_import"
  end
  # resource path
  local_var_path = '/files/v3/files/import-from-url/async/tasks/{taskId}/status'.sub('{' + 'taskId' + '}', CGI.escape(task_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:body] 

  # return_type
  return_type = opts[:return_type] || 'FileActionResponse' 

  # auth_names
  auth_names = opts[:auth_names] || ['hapikey', 'oauth2']

  new_options = opts.merge(
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: FilesApi#check_import\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#do_search(opts = {}) ⇒ CollectionResponseFile

Search files Search through files in the file manager. Does not display hidden or archived files.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :properties (Array<String>)

    Desired file properties in the return object.

  • :after (String)

    The maximum offset of items for a given search is 10000. Narrow your search down if you are reaching this limit.

  • :before (String)
  • :limit (Integer)

    Number of items to return. Maximum limit is 100.

  • :sort (Array<String>)

    Sort files by a given field.

  • :id (String)

    Search files by given ID.

  • :created_at (DateTime)

    Search files by time of creation.

  • :created_at_lte (DateTime)
  • :created_at_gte (DateTime)
  • :updated_at (DateTime)

    Search files by time of latest updated.

  • :updated_at_lte (DateTime)
  • :updated_at_gte (DateTime)
  • :name (String)

    Search for files containing the given name.

  • :path (String)

    Search files by path.

  • :parent_folder_id (Integer)

    Search files within given folder ID.

  • :size (Integer)

    Query by file size.

  • :height (Integer)

    Search files by height of image or video.

  • :width (Integer)

    Search files by width of image or video.

  • :encoding (String)

    Search files with specified encoding.

  • :type (String)

    Filter by provided file type.

  • :extension (String)

    Search files by given extension.

  • :url (String)

    Search for given URL

  • :is_usable_in_content (Boolean)

    If true shows files that have been marked to be used in new content. It false shows files that should not be used in new content.

  • :allows_anonymous_access (Boolean)

    If &#39;true&#39; will show private files; if &#39;false&#39; will show public files

Returns:



248
249
250
251
# File 'lib/hubspot/codegen/files/files/api/files_api.rb', line 248

def do_search(opts = {})
  data, _status_code, _headers = do_search_with_http_info(opts)
  data
end

#do_search_with_http_info(opts = {}) ⇒ Array<(CollectionResponseFile, Integer, Hash)>

Search files Search through files in the file manager. Does not display hidden or archived files.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :properties (Array<String>)

    Desired file properties in the return object.

  • :after (String)

    The maximum offset of items for a given search is 10000. Narrow your search down if you are reaching this limit.

  • :before (String)
  • :limit (Integer)

    Number of items to return. Maximum limit is 100.

  • :sort (Array<String>)

    Sort files by a given field.

  • :id (String)

    Search files by given ID.

  • :created_at (DateTime)

    Search files by time of creation.

  • :created_at_lte (DateTime)
  • :created_at_gte (DateTime)
  • :updated_at (DateTime)

    Search files by time of latest updated.

  • :updated_at_lte (DateTime)
  • :updated_at_gte (DateTime)
  • :name (String)

    Search for files containing the given name.

  • :path (String)

    Search files by path.

  • :parent_folder_id (Integer)

    Search files within given folder ID.

  • :size (Integer)

    Query by file size.

  • :height (Integer)

    Search files by height of image or video.

  • :width (Integer)

    Search files by width of image or video.

  • :encoding (String)

    Search files with specified encoding.

  • :type (String)

    Filter by provided file type.

  • :extension (String)

    Search files by given extension.

  • :url (String)

    Search for given URL

  • :is_usable_in_content (Boolean)

    If true shows files that have been marked to be used in new content. It false shows files that should not be used in new content.

  • :allows_anonymous_access (Boolean)

    If &#39;true&#39; will show private files; if &#39;false&#39; will show public files

Returns:

  • (Array<(CollectionResponseFile, Integer, Hash)>)

    CollectionResponseFile data, response status code and response headers



281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
# File 'lib/hubspot/codegen/files/files/api/files_api.rb', line 281

def do_search_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: FilesApi.do_search ...'
  end
  # resource path
  local_var_path = '/files/v3/files/search'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'properties'] = @api_client.build_collection_param(opts[:'properties'], :csv) if !opts[:'properties'].nil?
  query_params[:'after'] = opts[:'after'] if !opts[:'after'].nil?
  query_params[:'before'] = opts[:'before'] if !opts[:'before'].nil?
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'sort'] = @api_client.build_collection_param(opts[:'sort'], :multi) if !opts[:'sort'].nil?
  query_params[:'id'] = opts[:'id'] if !opts[:'id'].nil?
  query_params[:'createdAt'] = opts[:'created_at'] if !opts[:'created_at'].nil?
  query_params[:'createdAtLte'] = opts[:'created_at_lte'] if !opts[:'created_at_lte'].nil?
  query_params[:'createdAtGte'] = opts[:'created_at_gte'] if !opts[:'created_at_gte'].nil?
  query_params[:'updatedAt'] = opts[:'updated_at'] if !opts[:'updated_at'].nil?
  query_params[:'updatedAtLte'] = opts[:'updated_at_lte'] if !opts[:'updated_at_lte'].nil?
  query_params[:'updatedAtGte'] = opts[:'updated_at_gte'] if !opts[:'updated_at_gte'].nil?
  query_params[:'name'] = opts[:'name'] if !opts[:'name'].nil?
  query_params[:'path'] = opts[:'path'] if !opts[:'path'].nil?
  query_params[:'parentFolderId'] = opts[:'parent_folder_id'] if !opts[:'parent_folder_id'].nil?
  query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?
  query_params[:'height'] = opts[:'height'] if !opts[:'height'].nil?
  query_params[:'width'] = opts[:'width'] if !opts[:'width'].nil?
  query_params[:'encoding'] = opts[:'encoding'] if !opts[:'encoding'].nil?
  query_params[:'type'] = opts[:'type'] if !opts[:'type'].nil?
  query_params[:'extension'] = opts[:'extension'] if !opts[:'extension'].nil?
  query_params[:'url'] = opts[:'url'] if !opts[:'url'].nil?
  query_params[:'isUsableInContent'] = opts[:'is_usable_in_content'] if !opts[:'is_usable_in_content'].nil?
  query_params[:'allowsAnonymousAccess'] = opts[:'allows_anonymous_access'] if !opts[:'allows_anonymous_access'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:body] 

  # return_type
  return_type = opts[:return_type] || 'CollectionResponseFile' 

  # auth_names
  auth_names = opts[:auth_names] || ['hapikey', 'oauth2']

  new_options = opts.merge(
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: FilesApi#do_search\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_by_id(file_id, opts = {}) ⇒ File

Get file. Get file by ID.

Parameters:

  • file_id (String)

    Id of the desired file.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :properties (Array<String>)

Returns:

  • (File)


354
355
356
357
# File 'lib/hubspot/codegen/files/files/api/files_api.rb', line 354

def get_by_id(file_id, opts = {})
  data, _status_code, _headers = get_by_id_with_http_info(file_id, opts)
  data
end

#get_by_id_with_http_info(file_id, opts = {}) ⇒ Array<(File, Integer, Hash)>

Get file. Get file by ID.

Parameters:

  • file_id (String)

    Id of the desired file.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :properties (Array<String>)

Returns:

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

    File data, response status code and response headers



365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
# File 'lib/hubspot/codegen/files/files/api/files_api.rb', line 365

def get_by_id_with_http_info(file_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: FilesApi.get_by_id ...'
  end
  # verify the required parameter 'file_id' is set
  if @api_client.config.client_side_validation && file_id.nil?
    fail ArgumentError, "Missing the required parameter 'file_id' when calling FilesApi.get_by_id"
  end
  pattern = Regexp.new(/\d+/)
  if @api_client.config.client_side_validation && file_id !~ pattern
    fail ArgumentError, "invalid value for 'file_id' when calling FilesApi.get_by_id, must conform to the pattern #{pattern}."
  end

  # resource path
  local_var_path = '/files/v3/files/{fileId}'.sub('{' + 'fileId' + '}', CGI.escape(file_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'properties'] = @api_client.build_collection_param(opts[:'properties'], :csv) if !opts[:'properties'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:body] 

  # return_type
  return_type = opts[:return_type] || 'HubspotFile' 

  # auth_names
  auth_names = opts[:auth_names] || ['hapikey', 'oauth2']

  new_options = opts.merge(
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: FilesApi#get_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_signed_url(file_id, opts = {}) ⇒ SignedUrl

Get signed URL to access private file. Generates signed URL that allows temporary access to a private file.

Parameters:

  • file_id (String)

    ID of file.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :size (String)

    For image files. This will resize the image to the desired size before sharing. Does not affect the original file, just the file served by this signed URL.

  • :expiration_seconds (Integer)

    How long in seconds the link will provide access to the file.

  • :upscale (Boolean)

    If size is provided, this will upscale the image to fit the size dimensions.

Returns:



426
427
428
429
# File 'lib/hubspot/codegen/files/files/api/files_api.rb', line 426

def get_signed_url(file_id, opts = {})
  data, _status_code, _headers = get_signed_url_with_http_info(file_id, opts)
  data
end

#get_signed_url_with_http_info(file_id, opts = {}) ⇒ Array<(SignedUrl, Integer, Hash)>

Get signed URL to access private file. Generates signed URL that allows temporary access to a private file.

Parameters:

  • file_id (String)

    ID of file.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :size (String)

    For image files. This will resize the image to the desired size before sharing. Does not affect the original file, just the file served by this signed URL.

  • :expiration_seconds (Integer)

    How long in seconds the link will provide access to the file.

  • :upscale (Boolean)

    If size is provided, this will upscale the image to fit the size dimensions.

Returns:

  • (Array<(SignedUrl, Integer, Hash)>)

    SignedUrl data, response status code and response headers



439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
# File 'lib/hubspot/codegen/files/files/api/files_api.rb', line 439

def get_signed_url_with_http_info(file_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: FilesApi.get_signed_url ...'
  end
  # verify the required parameter 'file_id' is set
  if @api_client.config.client_side_validation && file_id.nil?
    fail ArgumentError, "Missing the required parameter 'file_id' when calling FilesApi.get_signed_url"
  end
  pattern = Regexp.new(/\d+/)
  if @api_client.config.client_side_validation && file_id !~ pattern
    fail ArgumentError, "invalid value for 'file_id' when calling FilesApi.get_signed_url, must conform to the pattern #{pattern}."
  end

  allowable_values = ["thumb", "icon", "medium", "preview"]
  if @api_client.config.client_side_validation && opts[:'size'] && !allowable_values.include?(opts[:'size'])
    fail ArgumentError, "invalid value for \"size\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/files/v3/files/{fileId}/signed-url'.sub('{' + 'fileId' + '}', CGI.escape(file_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?
  query_params[:'expirationSeconds'] = opts[:'expiration_seconds'] if !opts[:'expiration_seconds'].nil?
  query_params[:'upscale'] = opts[:'upscale'] if !opts[:'upscale'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:body] 

  # return_type
  return_type = opts[:return_type] || 'SignedUrl' 

  # auth_names
  auth_names = opts[:auth_names] || ['hapikey', 'oauth2']

  new_options = opts.merge(
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: FilesApi#get_signed_url\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#import_from_url(import_from_url_input, opts = {}) ⇒ ImportFromUrlTaskLocator

Import a file from a URL into the file manager. Asynchronously imports the file at the given URL into the file manager.

Parameters:

  • import_from_url_input (ImportFromUrlInput)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



503
504
505
506
# File 'lib/hubspot/codegen/files/files/api/files_api.rb', line 503

def import_from_url(import_from_url_input, opts = {})
  data, _status_code, _headers = import_from_url_with_http_info(import_from_url_input, opts)
  data
end

#import_from_url_with_http_info(import_from_url_input, opts = {}) ⇒ Array<(ImportFromUrlTaskLocator, Integer, Hash)>

Import a file from a URL into the file manager. Asynchronously imports the file at the given URL into the file manager.

Parameters:

  • import_from_url_input (ImportFromUrlInput)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(ImportFromUrlTaskLocator, Integer, Hash)>)

    ImportFromUrlTaskLocator data, response status code and response headers



513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
# File 'lib/hubspot/codegen/files/files/api/files_api.rb', line 513

def import_from_url_with_http_info(import_from_url_input, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: FilesApi.import_from_url ...'
  end
  # verify the required parameter 'import_from_url_input' is set
  if @api_client.config.client_side_validation && import_from_url_input.nil?
    fail ArgumentError, "Missing the required parameter 'import_from_url_input' when calling FilesApi.import_from_url"
  end
  # resource path
  local_var_path = '/files/v3/files/import-from-url/async'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[: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 = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:body] || @api_client.object_to_http_body(import_from_url_input) 

  # return_type
  return_type = opts[:return_type] || 'ImportFromUrlTaskLocator' 

  # auth_names
  auth_names = opts[:auth_names] || ['hapikey', 'oauth2']

  new_options = opts.merge(
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: FilesApi#import_from_url\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#replace(file_id, opts = {}) ⇒ File

Replace file. Replace existing file data with new file data. Can be used to change image content without having to upload a new file and update all references.

Parameters:

  • file_id (String)

    Id of the desired file.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :file (File)

    File data that will replace existing file in the file manager.

  • :charset_hunch (String)

    Character set of given file data.

  • :options (String)

    JSON String representing FileReplaceOptions

Returns:

  • (File)


570
571
572
573
# File 'lib/hubspot/codegen/files/files/api/files_api.rb', line 570

def replace(file_id, opts = {})
  data, _status_code, _headers = replace_with_http_info(file_id, opts)
  data
end

#replace_with_http_info(file_id, opts = {}) ⇒ Array<(File, Integer, Hash)>

Replace file. Replace existing file data with new file data. Can be used to change image content without having to upload a new file and update all references.

Parameters:

  • file_id (String)

    Id of the desired file.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :file (File)

    File data that will replace existing file in the file manager.

  • :charset_hunch (String)

    Character set of given file data.

  • :options (String)

    JSON String representing FileReplaceOptions

Returns:

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

    File data, response status code and response headers



583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
# File 'lib/hubspot/codegen/files/files/api/files_api.rb', line 583

def replace_with_http_info(file_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: FilesApi.replace ...'
  end
  # verify the required parameter 'file_id' is set
  if @api_client.config.client_side_validation && file_id.nil?
    fail ArgumentError, "Missing the required parameter 'file_id' when calling FilesApi.replace"
  end
  pattern = Regexp.new(/\d+/)
  if @api_client.config.client_side_validation && file_id !~ pattern
    fail ArgumentError, "invalid value for 'file_id' when calling FilesApi.replace, must conform to the pattern #{pattern}."
  end

  # resource path
  local_var_path = '/files/v3/files/{fileId}'.sub('{' + 'fileId' + '}', CGI.escape(file_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[: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 = opts[:form_params] || {}
  form_params['file'] = opts[:'file'] if !opts[:'file'].nil?
  form_params['charsetHunch'] = opts[:'charset_hunch'] if !opts[:'charset_hunch'].nil?
  form_params['options'] = opts[:'options'] if !opts[:'options'].nil?

  # http body (model)
  post_body = opts[:body] 

  # return_type
  return_type = opts[:return_type] || 'HubspotFile' 

  # auth_names
  auth_names = opts[:auth_names] || ['hapikey', 'oauth2']

  new_options = opts.merge(
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: FilesApi#replace\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#update_properties(file_id, file_update_input, opts = {}) ⇒ File

update file properties Update properties of file by ID.

Parameters:

  • file_id (String)

    ID of file to update

  • file_update_input (FileUpdateInput)

    Options to update.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (File)


646
647
648
649
# File 'lib/hubspot/codegen/files/files/api/files_api.rb', line 646

def update_properties(file_id, file_update_input, opts = {})
  data, _status_code, _headers = update_properties_with_http_info(file_id, file_update_input, opts)
  data
end

#update_properties_with_http_info(file_id, file_update_input, opts = {}) ⇒ Array<(File, Integer, Hash)>

update file properties Update properties of file by ID.

Parameters:

  • file_id (String)

    ID of file to update

  • file_update_input (FileUpdateInput)

    Options to update.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

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

    File data, response status code and response headers



657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
# File 'lib/hubspot/codegen/files/files/api/files_api.rb', line 657

def update_properties_with_http_info(file_id, file_update_input, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: FilesApi.update_properties ...'
  end
  # verify the required parameter 'file_id' is set
  if @api_client.config.client_side_validation && file_id.nil?
    fail ArgumentError, "Missing the required parameter 'file_id' when calling FilesApi.update_properties"
  end
  pattern = Regexp.new(/\d+/)
  if @api_client.config.client_side_validation && file_id !~ pattern
    fail ArgumentError, "invalid value for 'file_id' when calling FilesApi.update_properties, must conform to the pattern #{pattern}."
  end

  # verify the required parameter 'file_update_input' is set
  if @api_client.config.client_side_validation && file_update_input.nil?
    fail ArgumentError, "Missing the required parameter 'file_update_input' when calling FilesApi.update_properties"
  end
  # resource path
  local_var_path = '/files/v3/files/{fileId}'.sub('{' + 'fileId' + '}', CGI.escape(file_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[: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 = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:body] || @api_client.object_to_http_body(file_update_input) 

  # return_type
  return_type = opts[:return_type] || 'HubspotFile' 

  # auth_names
  auth_names = opts[:auth_names] || ['hapikey', 'oauth2']

  new_options = opts.merge(
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: FilesApi#update_properties\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#upload(opts = {}) ⇒ File

Upload file Upload a single file with content specified in request body.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :file (File)

    File to be uploaded.

  • :folder_id (String)

    Either &#39;folderId&#39; or &#39;folderPath&#39; is required. folderId is the ID of the folder the file will be uploaded to.

  • :folder_path (String)

    Either &#39;folderPath&#39; or &#39;folderId&#39; is required. This field represents the destination folder path for the uploaded file. If a path doesn&#39;t exist, the system will try to create one.

  • :file_name (String)

    Desired name for the uploaded file.

  • :charset_hunch (String)

    Character set of the uploaded file.

  • :options (String)

    JSON string representing FileUploadOptions.

Returns:

  • (File)


725
726
727
728
# File 'lib/hubspot/codegen/files/files/api/files_api.rb', line 725

def upload(opts = {})
  data, _status_code, _headers = upload_with_http_info(opts)
  data
end

#upload_with_http_info(opts = {}) ⇒ Array<(File, Integer, Hash)>

Upload file Upload a single file with content specified in request body.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :file (File)

    File to be uploaded.

  • :folder_id (String)

    Either &#39;folderId&#39; or &#39;folderPath&#39; is required. folderId is the ID of the folder the file will be uploaded to.

  • :folder_path (String)

    Either &#39;folderPath&#39; or &#39;folderId&#39; is required. This field represents the destination folder path for the uploaded file. If a path doesn&#39;t exist, the system will try to create one.

  • :file_name (String)

    Desired name for the uploaded file.

  • :charset_hunch (String)

    Character set of the uploaded file.

  • :options (String)

    JSON string representing FileUploadOptions.

Returns:

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

    File data, response status code and response headers



740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
# File 'lib/hubspot/codegen/files/files/api/files_api.rb', line 740

def upload_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: FilesApi.upload ...'
  end
  # resource path
  local_var_path = '/files/v3/files'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[: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 = opts[:form_params] || {}
  form_params['file'] = opts[:'file'] if !opts[:'file'].nil?
  form_params['folderId'] = opts[:'folder_id'] if !opts[:'folder_id'].nil?
  form_params['folderPath'] = opts[:'folder_path'] if !opts[:'folder_path'].nil?
  form_params['fileName'] = opts[:'file_name'] if !opts[:'file_name'].nil?
  form_params['charsetHunch'] = opts[:'charset_hunch'] if !opts[:'charset_hunch'].nil?
  form_params['options'] = opts[:'options'] if !opts[:'options'].nil?

  # http body (model)
  post_body = opts[:body] 

  # return_type
  return_type = opts[:return_type] || 'HubspotFile' 

  # auth_names
  auth_names = opts[:auth_names] || ['hapikey', 'oauth2']

  new_options = opts.merge(
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: FilesApi#upload\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end