Class: ConnectStoopid::TimeEntry

Inherits:
Object
  • Object
show all
Defined in:
lib/connect-stoopid/time-entry.rb

Instance Method Summary collapse

Constructor Details

#initialize(psa_address, company, username, password, options = {}) ⇒ TimeEntry

Returns a new instance of TimeEntry.



9
10
11
12
# File 'lib/connect-stoopid/time-entry.rb', line 9

def initialize(psa_address, company, username, password, options = {})
  ConnectStoopid.wsdl = "https://#{psa_address}/v4_6_release/apis/1.5/TimeEntryApi.asmx?wsdl"
  ConnectStoopid.connect(company, username, password, options)
end

Instance Method Details

#add_time_entry(options = { "MemberID" => "testuser", "ChargeCode" => "Automated (testuser)", "WorkType" => "Regular", "DateStart" => "", "TimeStart" => "", "TimeEnd" => "", "Notes" => "", }) ⇒ Object

Error on failure, returns true on addition of time entry.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/connect-stoopid/time-entry.rb', line 20

def add_time_entry(
   options = {
     "MemberID"   => "testuser",
     "ChargeCode" => "Automated (testuser)",
     "WorkType"   => "Regular",
     "DateStart"  => "",
     "TimeStart"  => "",
     "TimeEnd"    => "",
     "Notes"      => "",
   }
 )
	ConnectStoopid.log_client_message("Adding a Time Entry | Member: #{options['MemberID']} Start: #{options['TimeStart']} End: #{options['TimeEnd']}", :debug)

	request_options = ConnectStoopid.base_soap_hash
	request_options.merge!({ "timeEntry" => options })
		
	begin
		response = ConnectStoopid.soap_client.call(:add_time_entry, :message => request_options)
	rescue Savon::SOAPFault => error
		ConnectStoopid.log_client_message("SOAP Fault\nError Message:\n#{error}", :error)
	else
		if response.success?
       result = true
     else
       result = false
		end
	end
   return result
end