Class: Piwik::SitesManager

Inherits:
ApiModule show all
Defined in:
lib/piwik/sites_manager.rb

Instance Attribute Summary

Attributes inherited from Base

#attributes

Class Method Summary collapse

Methods inherited from ApiModule

api_call_to_const, available_methods, defaults, method_missing, scoped_methods

Methods included from DataMethods

included

Methods inherited from Base

call, #call, collection, #collection, #config, #created_at, #delete, #id, #id_attr, #initialize, load, load_config_from_file, #method_missing, #new?, parse_xml, #parse_xml, #save

Methods included from ApiScope

included

Methods included from Typecast

included

Constructor Details

This class inherits a constructor from Piwik::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Piwik::Base

Class Method Details

.add(params) ⇒ Object

monkeypatching, as the Piwik API is inconsistent. not all add methods return the same response type. Boo.


55
56
57
58
59
60
# File 'lib/piwik/sites_manager.rb', line 55

def self.add params
  obj = Piwik::Site.new(params)
  resp = self.api_call('addSite',params)
  obj.attributes.idSite = resp
  obj
end

.delete(params) ⇒ Object


66
67
68
# File 'lib/piwik/sites_manager.rb', line 66

def self.delete params
  self.api_call('deleteSite',params)
end

.get(params) ⇒ Object

Raises:


46
47
48
49
50
51
# File 'lib/piwik/sites_manager.rb', line 46

def self.get params
  resp = self.get_site_from_id(params)  # Hack. The Piwik API get really weird sometimes

  raise Piwik::UnknownSite if resp.value == '0'
  Piwik::Site.new resp
end

.save(params) ⇒ Object


62
63
64
# File 'lib/piwik/sites_manager.rb', line 62

def self.save params
  self.api_call('updateSite',params)
end