module DeskApi::Resource::Download

{DeskApi::Resource::Download} is responsible for download helper methods like `#download`

@author Thomas Stachl <tstachl@salesforce.com> @copyright Copyright © 2013-2016 Salesforce.com @license BSD 3-Clause License

@example download an attachment {DeskApi::Resource}

DeskApi.cases.find(123).attachments.entries.first.download

Public Instance Methods

download() click to toggle source

Download the attachment {DeskApi::Resource}

@raise [NoMethodError] if self is not an attachment resource

# File lib/desk_api/resource/download.rb, line 45
def download
  unless resource_type == 'attachment'
    raise NoMethodError, "#download is only available on attachment resources"
  end

  Tempfile.new(file_name).tap do |f|
    f.write(@_client.get(url).body)
    f.rewind
  end
end