From 40a3e3a83b242d5fef1f59132f2530468bf260a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=B0=D0=B2=D0=B5=D0=BB=20=D0=9B=D0=B0=D0=B2=D1=80?= =?UTF-8?q?=D0=B8=D0=BD=D0=BE=D0=B2=D0=B8=D1=87?= Date: Mon, 30 Nov 2020 16:38:21 +0300 Subject: [PATCH 1/2] v3 filemanager api support --- lib/hubspot/file.rb | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/lib/hubspot/file.rb b/lib/hubspot/file.rb index 323e8c43..027bb891 100644 --- a/lib/hubspot/file.rb +++ b/lib/hubspot/file.rb @@ -1,22 +1,28 @@ module Hubspot class File - UPLOAD_FILE_PATH = '/filemanager/api/v2/files' - + UPLOAD_FILE_PATH = '/filemanager/api/v3/files/upload' + class << self - def upload(file, params) - query = { - overwrite: params['overwrite'] || false, - hidden: params['hidden'] || false + def upload(file, params = {}) + body = { + file: file, + options: JSON.generate(file_options(params)), + folderPath: '/docs' } - options = { - multipart: - [ - { name: 'files', contents: file }, - { name: 'file_names', contents: params['file_names'] }, - { name: 'folder_paths', contents: params['folder_paths'] } - ] + + ::Hubspot::FilesConnection.post(UPLOAD_FILE_PATH, body: body, params: params) + end + + protected + + def file_options(params) + { + 'access' => params['access'] || 'PUBLIC_INDEXABLE', + 'ttl' => params['ttl'] || 'P3M', + 'overwrite' => params['overwrite'] || false, + 'duplicateValidationStrategy' => params['duplicate_validation_strategy'] || 'NONE', + 'duplicateValidationScope' => params['duplicate_validation_scope'] || 'ENTIRE_PORTAL' } - Hubspot::FilesConnection.post(UPLOAD_FILE_PATH, params: query, body: options) end end end From 50664efbb9631284221efbad9d21dc003a85c606 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=B0=D0=B2=D0=B5=D0=BB=20=D0=9B=D0=B0=D0=B2=D1=80?= =?UTF-8?q?=D0=B8=D0=BD=D0=BE=D0=B2=D0=B8=D1=87?= Date: Mon, 30 Nov 2020 16:39:01 +0300 Subject: [PATCH 2/2] v0.9.1 --- hubspot-ruby.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hubspot-ruby.gemspec b/hubspot-ruby.gemspec index 4df837ab..b23e9f3a 100644 --- a/hubspot-ruby.gemspec +++ b/hubspot-ruby.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |s| s.name = "hubspot-ruby" - s.version = "0.9.0" + s.version = "0.9.1" s.require_paths = ["lib"] s.authors = ["Andrew DiMichele", "Chris Bisnett", "Vladislav Ermolkin"] s.description = "hubspot-ruby is a wrapper for the HubSpot REST API"