connect-stoopid 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -14
- data/lib/connect-stoopid.rb +73 -2
- data/lib/connect-stoopid/company.rb +76 -0
- data/lib/connect-stoopid/time-entry.rb +50 -0
- metadata +12 -10
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
MDU1NzcwYjM4NTU3ZTExMjU5NDI4OWIxZTk1YmU4ODUxYTRmMmNkYzc0NDEx
|
10
|
-
OTBmMjBiMDhkNDZhZjkwMzY5MWZmYWY0ZWU4ZDQwNDg4ZjQ2Nzg3MjBhM2Vj
|
11
|
-
YjY0YzgwOGRjZDQ3ZWI2NGZkY2RmODA2OWRiODI0YWE5NjdiYzA=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
MzdmMWY3YzYyNTNkOGYwZGNjYTMxNjJkMjNkY2YwNWFjNWRiZWRmNGY3ZDdh
|
14
|
-
YzFmZTYxMmQ5MzA3YjhhYWU4NWMyMDhlMDBlN2ZiMThmOTMyYjMwYTliZTgy
|
15
|
-
ZDhkYTJiZThjN2NiNzhhMTEzMWVlYTBlYmYyZjZmZjRhMDM5NzQ=
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e3ad83e5c20885435d1a49cccf9f79ad6458fdd1
|
4
|
+
data.tar.gz: 5480f53f59e1859b1ef065d517223e1d4092bb3c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 336ff88d78aaf947c83388144311cc9dcde6c8aa203bb5840319ae158756b76c28605403d2e455ab56e94649169800986fef0c954549b2bfda7bc83324eff54c
|
7
|
+
data.tar.gz: 8b1d2cc42d80c42a60616707e44b4473ade6061da8995ff5eaef4aeafaebbab369eb16f8828d365ad8661a271870bcd8974002a2ebbf42b1449b056fce9d6bf3
|
data/lib/connect-stoopid.rb
CHANGED
@@ -1,7 +1,78 @@
|
|
1
1
|
module ConnectStoopid
|
2
|
-
VERSION = "0.1.
|
2
|
+
VERSION = "0.1.4"
|
3
3
|
|
4
4
|
require 'savon'
|
5
5
|
require 'rexml/document'
|
6
6
|
require 'connect-stoopid/reporting-client'
|
7
|
-
|
7
|
+
require 'connect-stoopid/time-entry'
|
8
|
+
require 'connect-stoopid/company'
|
9
|
+
|
10
|
+
# The WSDL and the SOAP client currently need to be accessible by the API classes.
|
11
|
+
class << self; attr_accessor :wsdl end
|
12
|
+
class << self; attr_accessor :soap_client end
|
13
|
+
|
14
|
+
# The methods defined need to be accessible and instance methods of the ConnectStoopid module.
|
15
|
+
class << self
|
16
|
+
##
|
17
|
+
# Parameters:
|
18
|
+
# psa_address -- The hostname of your ConnectWise PSA, ie. con.companyconnect.net
|
19
|
+
# company -- Company id used when logging into ConnectWise
|
20
|
+
# username -- ConnectWise Integration username
|
21
|
+
# password -- ConnectWise Integration password
|
22
|
+
# options -- Override the default ReportingClient options
|
23
|
+
##
|
24
|
+
def connect(company, username, password, options = {})
|
25
|
+
@company = company
|
26
|
+
@username = username
|
27
|
+
@password = password
|
28
|
+
|
29
|
+
@client_options = {
|
30
|
+
:client_logging => true,
|
31
|
+
:client_logging_level => :error,
|
32
|
+
:soap_version => 2,
|
33
|
+
:soap_logging => false,
|
34
|
+
:soap_logging_level => :fatal
|
35
|
+
}
|
36
|
+
@client_options.merge!(options)
|
37
|
+
|
38
|
+
@soap_client = Savon.client({
|
39
|
+
:wsdl => @wsdl,
|
40
|
+
:soap_version => @client_options[:soap_version],
|
41
|
+
:log => @client_options[:soap_logging],
|
42
|
+
:log_level => @client_options[:soap_logging_level]
|
43
|
+
})
|
44
|
+
end
|
45
|
+
|
46
|
+
def log_client_message(message, level = :error)
|
47
|
+
if logging
|
48
|
+
if LOG_LEVELS[level] >= LOG_LEVELS[@client_options[:client_logging_level]]
|
49
|
+
puts "#{self.class.to_s.split("::").last} Logger -- #{message}"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def base_soap_hash
|
55
|
+
request_options = {
|
56
|
+
"credentials" => {
|
57
|
+
"CompanyId" => @company,
|
58
|
+
"IntegratorLoginId" => @username,
|
59
|
+
"IntegratorPassword" => @password
|
60
|
+
}
|
61
|
+
}
|
62
|
+
return request_options
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
66
|
+
|
67
|
+
LOG_LEVELS = {
|
68
|
+
:debug => 1,
|
69
|
+
:standard => 2,
|
70
|
+
:error => 3
|
71
|
+
}
|
72
|
+
|
73
|
+
def logging
|
74
|
+
return @client_options[:client_logging]
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
=begin
|
2
|
+
ConnectStoopid::Company
|
3
|
+
Provides an interface to the ConnectWise Time Entry API
|
4
|
+
=end
|
5
|
+
|
6
|
+
module ConnectStoopid
|
7
|
+
class Company
|
8
|
+
|
9
|
+
def initialize(psa_address, company, username, password, options = {})
|
10
|
+
ConnectStoopid.wsdl = "https://#{psa_address}/v4_6_release/apis/1.5/CompanyApi.asmx?wsdl"
|
11
|
+
ConnectStoopid.connect(company, username, password, options)
|
12
|
+
end
|
13
|
+
|
14
|
+
##
|
15
|
+
# Parameters:
|
16
|
+
# options: Key value pairs to add to the Savon SOAP request
|
17
|
+
# Returns:
|
18
|
+
# False on failure, an array of companies on success.
|
19
|
+
##
|
20
|
+
def find_companies(options = {})
|
21
|
+
ConnectStoopid.log_client_message("FindCompanies", :debug)
|
22
|
+
|
23
|
+
request_options = ConnectStoopid.base_soap_hash
|
24
|
+
request_options.merge!(options)
|
25
|
+
|
26
|
+
begin
|
27
|
+
response = ConnectStoopid.soap_client.call(:find_companies, :message => request_options)
|
28
|
+
rescue Savon::SOAPFault => error
|
29
|
+
ConnectStoopid.log_client_message("SOAP Fault\nError Message:\n#{error}", :error)
|
30
|
+
else
|
31
|
+
if response.success?
|
32
|
+
companies = []
|
33
|
+
xml_doc = REXML::Document.new(response.to_xml)
|
34
|
+
#REXML::XPath.each(xml_doc, "//Company") do |company|
|
35
|
+
# companies << company
|
36
|
+
#end
|
37
|
+
result = xml_doc
|
38
|
+
else
|
39
|
+
result = false
|
40
|
+
end
|
41
|
+
end
|
42
|
+
return result
|
43
|
+
end
|
44
|
+
|
45
|
+
##
|
46
|
+
# Parameters:
|
47
|
+
# options: Key value pairs to add to the Savon SOAP request
|
48
|
+
# Returns:
|
49
|
+
# False on failure, an array of companies on success.
|
50
|
+
##
|
51
|
+
def get_company(id)
|
52
|
+
ConnectStoopid.log_client_message("GetCompany", :debug)
|
53
|
+
|
54
|
+
request_options = ConnectStoopid.base_soap_hash
|
55
|
+
request_options.merge!(
|
56
|
+
{ "id" => id }
|
57
|
+
)
|
58
|
+
|
59
|
+
begin
|
60
|
+
response = ConnectStoopid.soap_client.call(:get_company, :message => request_options)
|
61
|
+
rescue Savon::SOAPFault => error
|
62
|
+
ConnectStoopid.log_client_message("SOAP Fault\nError Message:\n#{error}", :error)
|
63
|
+
else
|
64
|
+
if response.success?
|
65
|
+
xml_doc = REXML::Document.new(response.to_xml)
|
66
|
+
result = xml_doc
|
67
|
+
else
|
68
|
+
result = false
|
69
|
+
end
|
70
|
+
end
|
71
|
+
return result
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
=begin
|
2
|
+
ConnectStoopid::TimeEntry
|
3
|
+
Provides an interface to the ConnectWise Time Entry API
|
4
|
+
=end
|
5
|
+
|
6
|
+
module ConnectStoopid
|
7
|
+
class TimeEntry
|
8
|
+
|
9
|
+
def initialize(psa_address, company, username, password, options = {})
|
10
|
+
ConnectStoopid.wsdl = "https://#{psa_address}/v4_6_release/apis/1.5/TimeEntryApi.asmx?wsdl"
|
11
|
+
ConnectStoopid.connect(company, username, password, options)
|
12
|
+
end
|
13
|
+
|
14
|
+
##
|
15
|
+
# Parameters:
|
16
|
+
# options: Key value pairs to add to the Savon SOAP request
|
17
|
+
# Returns:
|
18
|
+
# Error on failure, returns true on addition of time entry.
|
19
|
+
##
|
20
|
+
def add_time_entry(
|
21
|
+
options = {
|
22
|
+
"MemberID" => "testuser",
|
23
|
+
"ChargeCode" => "Automated (testuser)",
|
24
|
+
"WorkType" => "Regular",
|
25
|
+
"DateStart" => "",
|
26
|
+
"TimeStart" => "",
|
27
|
+
"TimeEnd" => "",
|
28
|
+
"Notes" => "",
|
29
|
+
}
|
30
|
+
)
|
31
|
+
ConnectStoopid.log_client_message("Adding a Time Entry | Member: #{options['MemberID']} Start: #{options['TimeStart']} End: #{options['TimeEnd']}", :debug)
|
32
|
+
|
33
|
+
request_options = ConnectStoopid.base_soap_hash
|
34
|
+
request_options.merge!({ "timeEntry" => options })
|
35
|
+
|
36
|
+
begin
|
37
|
+
response = ConnectStoopid.soap_client.call(:add_time_entry, :message => request_options)
|
38
|
+
rescue Savon::SOAPFault => error
|
39
|
+
ConnectStoopid.log_client_message("SOAP Fault\nError Message:\n#{error}", :error)
|
40
|
+
else
|
41
|
+
if response.success?
|
42
|
+
result = true
|
43
|
+
else
|
44
|
+
result = false
|
45
|
+
end
|
46
|
+
end
|
47
|
+
return result
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: connect-stoopid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Stump
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: savon
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 2.2.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 2.2.0
|
27
27
|
description: Simple Ruby client handling access to the ConnectWise SOAP APIs
|
@@ -30,8 +30,10 @@ executables: []
|
|
30
30
|
extensions: []
|
31
31
|
extra_rdoc_files: []
|
32
32
|
files:
|
33
|
-
- ./lib/connect-stoopid.rb
|
34
|
-
- ./lib/connect-stoopid/reporting-client.rb
|
33
|
+
- "./lib/connect-stoopid.rb"
|
34
|
+
- "./lib/connect-stoopid/reporting-client.rb"
|
35
|
+
- "./lib/connect-stoopid/time-entry.rb"
|
36
|
+
- "./lib/connect-stoopid/company.rb"
|
35
37
|
homepage: https://github.com/bytesofknowledge/connect-stoopid
|
36
38
|
licenses:
|
37
39
|
- GPL-2
|
@@ -42,18 +44,18 @@ require_paths:
|
|
42
44
|
- lib
|
43
45
|
required_ruby_version: !ruby/object:Gem::Requirement
|
44
46
|
requirements:
|
45
|
-
- -
|
47
|
+
- - ">="
|
46
48
|
- !ruby/object:Gem::Version
|
47
49
|
version: '0'
|
48
50
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
51
|
requirements:
|
50
|
-
- -
|
52
|
+
- - ">="
|
51
53
|
- !ruby/object:Gem::Version
|
52
54
|
version: '0'
|
53
55
|
requirements: []
|
54
56
|
rubyforge_project:
|
55
|
-
rubygems_version: 2.
|
57
|
+
rubygems_version: 2.1.11
|
56
58
|
signing_key:
|
57
59
|
specification_version: 4
|
58
|
-
summary: Run queries against the ConnectWise
|
60
|
+
summary: Run queries against the ConnectWise SOAP API
|
59
61
|
test_files: []
|