Class: Zendesk::Attachment

Inherits:
Resource show all
Defined in:
lib/zendesk/attachment.rb

Constant Summary

Constants included from Constants

Constants::PRIORITY, Constants::RESTRICTION, Constants::ROLE, Constants::STATUS, Constants::TICKET_TYPE, Constants::VIA

Instance Method Summary collapse

Methods inherited from Resource

create, #load_data

Methods included from Properties

included

Constructor Details

#initialize(path, filename = nil) ⇒ Attachment

Returns a new instance of Attachment.



2
3
4
5
6
# File 'lib/zendesk/attachment.rb', line 2

def initialize(path, filename = nil)
  @path = path
  @filename = filename || File.basename(path)

end

Instance Method Details

#saveObject

return token of attached file



8
9
10
11
# File 'lib/zendesk/attachment.rb', line 8

def save
  response = Zendesk.resource["uploads.xml?filename=#{@filename}"].post(File.read(@path))
  REXML::Document.new(response).elements['uploads'].attributes['token']
end