Module: ConnectStoopid

Defined in:
lib/connect-stoopid/company.rb,
lib/connect-stoopid.rb,
lib/connect-stoopid/time-entry.rb,
lib/connect-stoopid/reporting-client.rb

Overview

ConnectStoopid::ReportingClient Provides an interface to the ConnectWise Reporting API

Defined Under Namespace

Classes: Company, ReportingClient, TimeEntry

Constant Summary collapse

VERSION =
"0.1.4"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.soap_clientObject

Returns the value of attribute soap_client.



12
13
14
# File 'lib/connect-stoopid.rb', line 12

def soap_client
  @soap_client
end

.wsdlObject

Returns the value of attribute wsdl.



11
12
13
# File 'lib/connect-stoopid.rb', line 11

def wsdl
  @wsdl
end

Class Method Details

.base_soap_hashObject



54
55
56
57
58
59
60
61
62
63
# File 'lib/connect-stoopid.rb', line 54

def base_soap_hash
	request_options = {
		"credentials" => {
			"CompanyId"          => @company,
			"IntegratorLoginId"  => @username,
			"IntegratorPassword" => @password
		}
	}
	return request_options
end

.connect(company, username, password, options = {}) ⇒ Object

Parameters: psa_address – The hostname of your ConnectWise PSA, ie. con.companyconnect.net company – Company id used when logging into ConnectWise username – ConnectWise Integration username password – ConnectWise Integration password options – Override the default ReportingClient options



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/connect-stoopid.rb', line 24

def connect(company, username, password, options = {})
	@company  = company
	@username = username
	@password = password

	@client_options = {
		:client_logging       => true,
		:client_logging_level => :error,
		:soap_version         => 2,
		:soap_logging         => false,
		:soap_logging_level   => :fatal
	}
	@client_options.merge!(options)

	@soap_client = Savon.client({
		:wsdl         => @wsdl,
		:soap_version => @client_options[:soap_version],
		:log          => @client_options[:soap_logging],
		:log_level    => @client_options[:soap_logging_level]
	})
end

.log_client_message(message, level = :error) ⇒ Object



46
47
48
49
50
51
52
# File 'lib/connect-stoopid.rb', line 46

def log_client_message(message, level = :error)
	if logging
		if LOG_LEVELS[level] >= LOG_LEVELS[@client_options[:client_logging_level]]
			puts "#{self.class.to_s.split("::").last} Logger -- #{message}"
		end
	end
end