Skip to content

Commit bc68c85

Browse files
committed
Merge branch 'feature-file-api' of https://github.com/dinosimone/hubspot-ruby into dinosimone-feature-file-api
2 parents ed69d5a + 9a62689 commit bc68c85

6 files changed

Lines changed: 437 additions & 0 deletions

File tree

lib/hubspot-ruby.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
require 'hubspot/engagement'
2626
require 'hubspot/subscription'
2727
require 'hubspot/oauth'
28+
require 'hubspot/file'
2829

2930
module Hubspot
3031
def self.configure(config={})

lib/hubspot/file.rb

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
require 'hubspot/utils'
2+
require 'base64'
3+
require 'pp'
4+
5+
module Hubspot
6+
#
7+
# HubSpot Files API
8+
#
9+
# {https://developers.hubspot.com/docs/methods/files/post_files}
10+
#
11+
class File
12+
GET_FILE_PATH = "/filemanager/api/v2/files/:file_id"
13+
DELETE_FILE_PATH = "/filemanager/api/v2/files/:file_id/full-delete"
14+
LIST_FILE_PATH = "/filemanager/api/v2/files"
15+
16+
attr_reader :id
17+
attr_reader :properties
18+
19+
def initialize(response_hash)
20+
@id = response_hash["id"]
21+
@properties = response_hash
22+
end
23+
24+
class << self
25+
def find_by_id(file_id)
26+
response = Hubspot::Connection.get_json(GET_FILE_PATH, { file_id: file_id })
27+
new(response)
28+
end
29+
end
30+
31+
# Permanently delete a file and all related data and thumbnails from file manager.
32+
# {https://developers.hubspot.com/docs/methods/files/hard_delete_file_and_associated_objects}
33+
def destroy!
34+
Hubspot::Connection.post_json(DELETE_FILE_PATH, params: {file_id: id})
35+
end
36+
37+
end
38+
end

spec/fixtures/vcr_cassettes/file_delete.yml

Lines changed: 173 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/fixtures/vcr_cassettes/file_find.yml

Lines changed: 48 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)