Class: ZendeskAPI::Attachment

Inherits:
ReadResource show all
Defined in:
lib/zendesk_api/resources.rb

Instance Attribute Summary

Attributes inherited from DataResource

#error, #error_message

Attributes inherited from Data

#association, #attributes, #errors, #response

Instance Method Summary collapse

Methods included from Read

included, #reload!

Methods included from Sideloading

included, #set_includes

Methods included from ResponseHandler

#handle_response

Methods included from Verbs

#any, #delete, #post, #put

Methods inherited from Data

#==, #id, inherited, #loaded_associations, #method_missing, namespace, new_from_response, #new_record?, #path, resource_name, resource_path, #respond_to_missing?, singular_resource_name, subclasses, #to_json, #to_s

Methods included from Associations

included, #wrap_resource

Constructor Details

#initialize(client, attributes = {}) ⇒ Attachment

Returns a new instance of Attachment.



87
88
89
90
91
# File 'lib/zendesk_api/resources.rb', line 87

def initialize(client, attributes = {})
  attributes[:file] ||= attributes.delete(:id)

  super
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ZendeskAPI::Data

Instance Method Details

#saveObject



93
94
95
96
# File 'lib/zendesk_api/resources.rb', line 93

def save
  upload = Upload.create!(@client, attributes)
  self.token = upload.token
end

#to_paramObject



98
99
100
# File 'lib/zendesk_api/resources.rb', line 98

def to_param
  token
end