Class: ZendeskAPI::App

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

Defined Under Namespace

Classes: Plan, Upload

Instance Attribute Summary

Attributes inherited from DataResource

#error, #error_message

Attributes inherited from Data

#association, #attributes, #errors, #response

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Destroy

#destroy, #destroy!, #destroyed?, included

Methods included from Update

included

Methods included from Save

#clear_associations, #save, #save!, #save_associations

Methods included from Create

included

Methods included from Read

included, #reload!

Methods included from Sideloading

included, #set_includes

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 = {}) ⇒ App

Returns a new instance of App.



878
879
880
881
882
# File 'lib/zendesk_api/resources.rb', line 878

def initialize(client, attributes = {})
  attributes[:upload_id] ||= nil

  super
end

Dynamic Method Handling

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

Class Method Details

.create!(client, attributes = {}, &block) ⇒ Object



884
885
886
887
888
889
890
# File 'lib/zendesk_api/resources.rb', line 884

def self.create!(client, attributes = {}, &block)
  if file_path = attributes.delete(:upload)
    attributes[:upload_id] = client.apps.uploads.create!(:file => file_path).id
  end

  super
end

.installations(client, *args, &block) ⇒ Object



932
933
934
# File 'lib/zendesk_api/resources.rb', line 932

def self.installations(client, *args, &block)
  ZendeskAPI::Collection.new(client, AppInstallation, *args, &block)
end

.uploads(client, *args, &block) ⇒ Object



928
929
930
# File 'lib/zendesk_api/resources.rb', line 928

def self.uploads(client, *args, &block)
  ZendeskAPI::Collection.new(client, Upload, *args, &block)
end

Instance Method Details

#attributes_for_saveObject

Don’t nest attributes



940
941
942
# File 'lib/zendesk_api/resources.rb', line 940

def attributes_for_save
  attributes.changes
end

#handle_response(response) ⇒ Object



944
945
946
# File 'lib/zendesk_api/resources.rb', line 944

def handle_response(response)
  @attributes.replace(response.body) if response.body
end