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

#==, #account_data, #id, inherited, #inspect, #loaded_associations, #method_missing, namespace, new_from_response, #new_record?, #path, #refresh_custom_fields_metadata, 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.



1099
1100
1101
1102
1103
# File 'lib/zendesk_api/resources.rb', line 1099

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



1092
1093
1094
# File 'lib/zendesk_api/resources.rb', line 1092

def resource_path
  "uploads"
end

Instance Method Details

#attributes_for_saveObject

Don't nest attributes



1118
1119
1120
# File 'lib/zendesk_api/resources.rb', line 1118

def attributes_for_save
  attributes
end

#changed?Boolean

Always save

Returns:

  • (Boolean)


1113
1114
1115
# File 'lib/zendesk_api/resources.rb', line 1113

def changed?
  true
end

#save!Object

Not nested under :upload, just returns :id



1106
1107
1108
1109
1110
# File 'lib/zendesk_api/resources.rb', line 1106

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