Sha256: 9db863da5a3efde523b153b5e5dfc1a8e1b3515b22531555544badb088bf6ad7

Contents?: true

Size: 992 Bytes

Versions: 3

Compression:

Stored size: 992 Bytes

Contents

require 'hubspot/utils'
require 'base64'
require 'pp'

module Hubspot
  #
  # HubSpot Files API
  #
  # {https://developers.hubspot.com/docs/methods/files/post_files}
  #
  class File
    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"

    attr_reader :id
    attr_reader :properties

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

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

    # 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}
    def destroy!
      Hubspot::Connection.post_json(DELETE_FILE_PATH, params: {file_id: id})
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hubspot-api-ruby-0.9.0 lib/hubspot/file.rb
hubspot-api-ruby-0.8.1 lib/hubspot/file.rb
hubspot-api-ruby-0.8.0 lib/hubspot/file.rb