lib/postini/user.rb in postini-0.0.2 vs lib/postini/user.rb in postini-0.0.3
- old
+ new
@@ -18,11 +18,11 @@
class << self
# Return a new instance of the user
# TODO: Make this take various options just like ActiveRecord
def find( user )
- remote = Postini::API::AutomatedBatch::AutomatedBatchPort.new( Postini.endpoint_uri( user ) )
+ remote = automated_batch_port( user )
request = Postini::API::AutomatedBatch::Displayuser.new( Postini.auth, user )
response = remote.displayuser( request )
user_record = response.userRecord
attributes = {}
@@ -36,15 +36,22 @@
new( attributes )
end
# Permanently remove the user from Postini
def destroy( address )
- remote = Postini::API::AutomatedBatch::AutomatedBatchPort.new( Postini.endpoint_uri( address ) )
+ remote = automated_batch_port( address )
request = Postini::API::AutomatedBatch::Deleteuser.new( Postini.auth, address )
remote.deleteuser( request )
end
+ # Return a remote port for the address, with debug enabled if required
+ def automated_batch_port( address = nil ) #:nodoc:
+ remote = Postini::API::AutomatedBatch::AutomatedBatchPort.new( Postini.endpoint_uri( address ) )
+ remote.wiredump_dev = Postini.soap4r_wiredump_dev if Postini.soap4r_wiredump?
+ remote
+ end
+
end
# Setup a new instance with the combination of attributes set
def initialize( attributes = {} )
attributes.each_pair do |k,v|
@@ -62,11 +69,11 @@
return false unless new?
# TODO: Add missing validations here
return false if @address.nil? || @org.nil?
- remote = Postini::API::AutomatedBatch::AutomatedBatchPort.new( Postini.endpoint_uri )
+ remote = automated_batch_port
args = Postini::API::AutomatedBatch::Adduserargs.new( @org, welcome )
request = Postini::API::AutomatedBatch::Adduser.new( Postini.auth, @address, args )
remote.adduser( request )
end
@@ -78,11 +85,11 @@
end
# Return the list of aliases for the mailbox
def aliases
if @aliases.nil?
- remote = Postini::API::AutomatedBatch::AutomatedBatchPort.new( Postini.endpoint_uri( @address ) )
+ remote = self.class.automated_batch_port( @address )
query = Postini::API::AutomatedBatch::ListusersqueryParams.new
query.aliases = 1
query.childorgs = 1
query.primaryqs = @address
query.targetOrg = @orgid
@@ -102,18 +109,18 @@
end
# Add an alias to this user
def add_alias( address )
@aliases = nil # clear our cache
- remote = Postini::API::AutomatedBatch::AutomatedBatchPort.new( Postini.endpoint_uri( @address ) )
+ remote = self.class.automated_batch_port( @address )
request = Postini::API::AutomatedBatch::Addalias.new( Postini.auth, @address, address )
remote.addalias( request )
end
# Removes the specified alias
def remove_alias( address )
@aliases = nil # clear our cache
- remote = Postini::API::AutomatedBatch::AutomatedBatchPort.new( Postini.endpoint_uri( @address ) )
+ remote = self.class.automated_batch_port( @address )
request = Postini::API::AutomatedBatch::Deletealias.new( Postini.auth, address )
remote.deletealias( request )
end
# Removes all aliases from the user