Class: Memotoo

Inherits:
Object
  • Object
show all
Defined in:
lib/memotoo.rb,
lib/memotoo/main.rb

Constant Summary collapse

SEARCHDEFAULTS =
{ :limit_start => '0', :limit_nb => '100' }
NEEDS =

requirement for the objects - for validation

{ 	 :contact => [:lastname],
:contact_group => [:name],
:bookmark => [:url],
:bookmark_folder => [:name],
:note => [:description],
:calendar_category => [:name],
:event => [:title, :dateBegin, :dateEnd],
:holiday => [:description, :dateBegin, :dateEnd],
:task => [:title]}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(username, password, https = true, log = false, requestlog = true) ⇒ Memotoo

https

default:true for the SOAP service. Use false to use http-connection

log

default:false - set to true to see savons logging

requeslog

default:false - set to

example:(use https)

@connect=Memotoo::Connect.new("myusername","mypassword")

example:(use http)

@connect=Memotoo::Connect.new("myusername","mypassword", false)

example:(set loggin on and http-request-logging off)

@connect=Memotoo::Connect.new("myusername","mypassword", true, true, false)


34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/memotoo.rb', line 34

def initialize(username, password, https=true, log=false, requestlog=true)

	# need it for every request - will be merged in
	self.opts= { :param => { :login => username, :password => password}}
	
	# set savon logging and erros
	Savon.configure do |config|
		config.raise_errors = true # raise SOAP faults and HTTP errors
		config.log = log # enable/disable logging
		config.log_level = :debug # changing the log level
	end
	
	HTTPI.log=requestlog
	
	# build dynamically all methods - some magic :-)
	make_methods
	
	# creates client with memotoo settings 
	client(https)
end

Instance Attribute Details

#optsObject

will hold username and password in a hash style (used for all requests)



10
11
12
# File 'lib/memotoo.rb', line 10

def opts
  @opts
end

Instance Method Details

#client(https = true) ⇒ Object

Creates the Savon::Client.



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/memotoo.rb', line 56

def client(https=true)
		#--
		# in any case problems switch back to receiving the wsdl file from memotoo
		# https: wsdl.document = "https://www.memotoo.com/SOAP-server.php?wsdl"
		# http:  wsdl.document = "http://www.memotoo.com/SOAP-server.php?wsdl"
		#++
		@client ||= Savon::Client.new do
      wsdl.namespace="urn:memotooSoap"
if https
wsdl.endpoint="https://www.memotoo.com/SOAP-server.php"
http.auth.ssl.verify_mode = :none 
else
wsdl.endpoint="http://www.memotoo.com/SOAP-server.php"
end
http.auth.basic self.opts[:param][:login], self.opts[:param][:password]
		end
end