Class: Hubspot::File

Inherits:
Object
  • Object
show all
Defined in:
lib/hubspot/file.rb

Overview

Constant Summary collapse

GET_FILE_PATH =
"/filemanager/api/v2/files/:file_id"
DELETE_FILE_PATH =
"/filemanager/api/v2/files/:file_id/full-delete"
LIST_FILE_PATH =
"/filemanager/api/v2/files"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response_hash) ⇒ File

Returns a new instance of File.



19
20
21
22
# File 'lib/hubspot/file.rb', line 19

def initialize(response_hash)
  @id = response_hash["id"]
  @properties = response_hash
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



16
17
18
# File 'lib/hubspot/file.rb', line 16

def id
  @id
end

#propertiesObject (readonly)

Returns the value of attribute properties.



17
18
19
# File 'lib/hubspot/file.rb', line 17

def properties
  @properties
end

Class Method Details

.find_by_id(file_id) ⇒ Object



25
26
27
28
# File 'lib/hubspot/file.rb', line 25

def find_by_id(file_id)
  response = Hubspot::Connection.get_json(GET_FILE_PATH, { file_id: file_id })
  new(response)
end

Instance Method Details

#destroy!Object

Permanently delete a file and all related data and thumbnails from file manager. https://developers.hubspot.com/docs/methods/files/hard_delete_file_and_associated_objects



33
34
35
# File 'lib/hubspot/file.rb', line 33

def destroy!
  Hubspot::Connection.post_json(DELETE_FILE_PATH, params: {file_id: id})
end