Class: ZendeskAPI::App::Upload

Inherits:
Data
  • Object
show all
Includes:
Create
Defined in:
lib/zendesk_api/resources.rb

Instance Attribute Summary

Attributes inherited from Data

#association, #attributes, #errors, #response

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Create

included

Methods included from Save

#clear_associations, #save, #save_associations

Methods included from ResponseHandler

#handle_response

Methods inherited from Data

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

Methods included from ZendeskAPI::Associations

included, #wrap_resource

Constructor Details

#initialize(client, attributes) ⇒ Upload

Returns a new instance of Upload.



854
855
856
857
858
# File 'lib/zendesk_api/resources.rb', line 854

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

Class Method Details

.resource_pathObject



847
848
849
# File 'lib/zendesk_api/resources.rb', line 847

def resource_path
  "uploads"
end

Instance Method Details

#attributes_for_saveObject

Don’t nest attributes



873
874
875
# File 'lib/zendesk_api/resources.rb', line 873

def attributes_for_save
  attributes
end

#changed?Boolean

Always save

Returns:

  • (Boolean)


868
869
870
# File 'lib/zendesk_api/resources.rb', line 868

def changed?
  true
end

#save!Object

Not nested under :upload, just returns :id



861
862
863
864
865
# File 'lib/zendesk_api/resources.rb', line 861

def save!(*)
  super.tap do
    attributes.id = @response.body["id"]
  end
end