Sha256: 3461b26d5d40c253bfdd3f80bc77e28b4322eed0399c3ec7ac2050267f59d9c7

Contents?: true

Size: 998 Bytes

Versions: 10

Compression:

Stored size: 998 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

10 entries across 10 versions & 1 rubygems

Version Path
hubspot-api-ruby-0.18.0 lib/hubspot/file.rb
hubspot-api-ruby-0.17.1 lib/hubspot/file.rb
hubspot-api-ruby-0.17.0 lib/hubspot/file.rb
hubspot-api-ruby-0.16.0 lib/hubspot/file.rb
hubspot-api-ruby-0.15.0 lib/hubspot/file.rb
hubspot-api-ruby-0.14.0 lib/hubspot/file.rb
hubspot-api-ruby-0.13.0 lib/hubspot/file.rb
hubspot-api-ruby-0.12.0 lib/hubspot/file.rb
hubspot-api-ruby-0.11.0 lib/hubspot/file.rb
hubspot-api-ruby-0.10.0 lib/hubspot/file.rb