Class: ZendeskAPI::App

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

Defined Under Namespace

Classes: Plan, Upload

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of App



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

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



890
891
892
893
894
895
896
# File 'lib/zendesk_api/resources.rb', line 890

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



938
939
940
# File 'lib/zendesk_api/resources.rb', line 938

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

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



934
935
936
# File 'lib/zendesk_api/resources.rb', line 934

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

Instance Method Details

#attributes_for_saveObject

Don't nest attributes



946
947
948
# File 'lib/zendesk_api/resources.rb', line 946

def attributes_for_save
  attributes.changes
end

#handle_response(response) ⇒ Object



950
951
952
# File 'lib/zendesk_api/resources.rb', line 950

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

#plans(options = {}) ⇒ ZendeskAPI::App::Plan

Returns The associated object

Parameters:

  • options (Hash) (defaults to: {})

    Options to pass to the collection object

Returns:



943
# File 'lib/zendesk_api/resources.rb', line 943

has_many Plan

#plans=(value) ⇒ ZendeskAPI::App::Plan

Returns The associated object

Parameters:

Returns:



943
# File 'lib/zendesk_api/resources.rb', line 943

has_many Plan

#uploadZendeskAPI::Upload

Returns The associated object

Returns:



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

has Upload, :path => "uploads"

#upload=(value) ⇒ ZendeskAPI::Upload

Returns The associated object

Parameters:

Returns:



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

has Upload, :path => "uploads"