landslider 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +23 -11
- data/VERSION.yml +1 -1
- data/landslider.gemspec +6 -4
- data/lib/landslider.rb +19 -16
- data/test/landslider_test.rb +6 -6
- data/test/ws_search_test.rb +36 -0
- metadata +4 -2
data/README.rdoc
CHANGED
@@ -4,20 +4,17 @@ Ruby interface to Landslide's SOAP based API
|
|
4
4
|
|
5
5
|
== Pre-requisites
|
6
6
|
|
7
|
-
|
7
|
+
== Dependencies
|
8
8
|
|
9
|
-
|
9
|
+
=== Landslide account
|
10
10
|
|
11
|
-
|
11
|
+
An account with Landslide that has the API enabled. (www.landslide.com) Contact support@landslide.com to have the API enabled.
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
jeweler
|
16
|
-
handsoap >= 1.1.8
|
17
|
-
|
18
|
-
You also need to have either curb or httpclient on the load path.
|
13
|
+
=== Ruby gem dependencies
|
14
|
+
|
15
|
+
gem install jeweler curb handsoap
|
19
16
|
|
20
|
-
==
|
17
|
+
== Installation
|
21
18
|
|
22
19
|
gem install landslider
|
23
20
|
|
@@ -41,7 +38,22 @@ This gem requires the following gems:
|
|
41
38
|
puts "id: #{account[:account_id]} name: #{account[:account_name]}"
|
42
39
|
end
|
43
40
|
|
44
|
-
|
41
|
+
== Testing
|
42
|
+
|
43
|
+
The default rake task is set to run the tests.
|
44
|
+
|
45
|
+
$ rake
|
46
|
+
|
47
|
+
Tests are needed here because the API uses a specific XML structure for requests and responses.
|
48
|
+
|
49
|
+
== Contributing
|
50
|
+
|
51
|
+
Read the github doc on forking:
|
52
|
+
http://help.github.com/forking/
|
53
|
+
|
54
|
+
== API methods
|
55
|
+
|
56
|
+
These are the api methods that can be called. There are plenty of others to map out.
|
45
57
|
|
46
58
|
* login
|
47
59
|
* getApiVersion
|
data/VERSION.yml
CHANGED
data/landslider.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{landslider}
|
8
|
-
s.version = "0.5.
|
8
|
+
s.version = "0.5.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Jay Prall"]
|
12
|
-
s.date = %q{2011-05-
|
12
|
+
s.date = %q{2011-05-06}
|
13
13
|
s.default_executable = %q{generate_api_key.rb}
|
14
14
|
s.description = %q{Landslider is a ruby interface to the Landslide SOAP-based API}
|
15
15
|
s.email = %q{jay@j4y.net}
|
@@ -30,7 +30,8 @@ Gem::Specification.new do |s|
|
|
30
30
|
"landslider.gemspec",
|
31
31
|
"lib/landslider.rb",
|
32
32
|
"test/landslider_test.rb",
|
33
|
-
"test/test_helper.rb"
|
33
|
+
"test/test_helper.rb",
|
34
|
+
"test/ws_search_test.rb"
|
34
35
|
]
|
35
36
|
s.homepage = %q{https://github.com/j4y/landslider}
|
36
37
|
s.licenses = ["MIT"]
|
@@ -39,7 +40,8 @@ Gem::Specification.new do |s|
|
|
39
40
|
s.summary = %q{Landslide Ruby}
|
40
41
|
s.test_files = [
|
41
42
|
"test/landslider_test.rb",
|
42
|
-
"test/test_helper.rb"
|
43
|
+
"test/test_helper.rb",
|
44
|
+
"test/ws_search_test.rb"
|
43
45
|
]
|
44
46
|
|
45
47
|
if s.respond_to? :specification_version then
|
data/lib/landslider.rb
CHANGED
@@ -54,18 +54,19 @@ class Landslider < Handsoap::Service
|
|
54
54
|
parse_api_version_result(node)
|
55
55
|
end
|
56
56
|
|
57
|
-
def get_accounts(session_id, first_result_position=1, total_results_requested=25)
|
57
|
+
def get_accounts(session_id, first_result_position=1, total_results_requested=25, search_criteria=nil)
|
58
58
|
self.session_id = session_id
|
59
59
|
response = invoke('getAccounts', :soap_action => :none) do |message|
|
60
60
|
message.add('accountsRequest') { |ar|
|
61
61
|
ar.add 'firstResultPosition', first_result_position
|
62
62
|
ar.add 'totalResultsRequested', total_results_requested
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
63
|
+
unless search_criteria.nil?
|
64
|
+
ar.add('searchCriteria') { |sc|
|
65
|
+
sc.add 'fieldId', search_criteria.field_id
|
66
|
+
sc.add 'operator', search_criteria.operator
|
67
|
+
sc.add 'queryValue', search_criteria.query_value
|
68
|
+
}
|
69
|
+
end
|
69
70
|
}
|
70
71
|
end
|
71
72
|
|
@@ -110,13 +111,6 @@ class Landslider < Handsoap::Service
|
|
110
111
|
ans.add 'accountId', account_id
|
111
112
|
ans.add 'firstResultPosition', first_result_position
|
112
113
|
ans.add 'totalResultsRequested', total_results_requested
|
113
|
-
|
114
|
-
# ans.add('searchCriteria') { |sc|
|
115
|
-
# # just find accounts with an empty main city
|
116
|
-
#
|
117
|
-
# sc.add 'fieldId', 'MainAddressCity'
|
118
|
-
# sc.add 'operator', 'Empty'
|
119
|
-
# }
|
120
114
|
}
|
121
115
|
end
|
122
116
|
node = response.document.xpath('//ns:getAccountNotesResponse', ns)
|
@@ -213,7 +207,7 @@ class Landslider < Handsoap::Service
|
|
213
207
|
parse_get_lead_notes_result(node)
|
214
208
|
end
|
215
209
|
|
216
|
-
def get_opportunities(session_id, first_result_position=1, total_results_requested=25)
|
210
|
+
def get_opportunities(session_id, first_result_position=1, total_results_requested=25, search_criteria=nil)
|
217
211
|
self.session_id = session_id
|
218
212
|
|
219
213
|
response = invoke('getOpportunities', :soap_action => :none) do |message|
|
@@ -412,7 +406,6 @@ class Landslider < Handsoap::Service
|
|
412
406
|
|
413
407
|
def parse_get_lead_notes_result(node)
|
414
408
|
|
415
|
-
puts node.inspect
|
416
409
|
notes = parse_notes(node)
|
417
410
|
{
|
418
411
|
:error => xml_to_bool(node, './Notes/error/text()'),
|
@@ -612,5 +605,15 @@ class Landslider < Handsoap::Service
|
|
612
605
|
:start_date => xml_to_date(node, './startDate/text()')
|
613
606
|
}
|
614
607
|
end
|
608
|
+
|
609
|
+
class WsSearch
|
610
|
+
attr_reader :field_id, :operator, :query_value
|
611
|
+
|
612
|
+
def initialize(field_id, operator, query_value)
|
613
|
+
@field_id = field_id
|
614
|
+
@operator = operator
|
615
|
+
@query_value = query_value
|
616
|
+
end
|
617
|
+
end
|
615
618
|
|
616
619
|
end
|
data/test/landslider_test.rb
CHANGED
@@ -60,7 +60,7 @@ class LandsliderTest < Test::Unit::TestCase
|
|
60
60
|
assert_not_nil result[:account]
|
61
61
|
|
62
62
|
assert_not_nil result[:account][:custom_fields]
|
63
|
-
|
63
|
+
assert_kind_of Array, result[:account][:custom_fields]
|
64
64
|
assert_operator result[:account][:custom_fields].length, :>=, 2
|
65
65
|
|
66
66
|
end
|
@@ -70,7 +70,7 @@ class LandsliderTest < Test::Unit::TestCase
|
|
70
70
|
|
71
71
|
assert_equal 3, result[:results_returned]
|
72
72
|
validate_standard_api_result result
|
73
|
-
|
73
|
+
assert_kind_of Array, result[:contacts]
|
74
74
|
assert_not_nil result[:contacts].first[:contact_id]
|
75
75
|
assert result[:contacts].all? { |con| !con[:last_name].nil? }, "last name required"
|
76
76
|
end
|
@@ -103,7 +103,7 @@ class LandsliderTest < Test::Unit::TestCase
|
|
103
103
|
result = Landslider.get_account_opportunities($sid, 51858821)
|
104
104
|
|
105
105
|
assert_equal false, result[:error]
|
106
|
-
|
106
|
+
assert_kind_of Array, result[:opportunities]
|
107
107
|
|
108
108
|
assert result[:opportunities].all? { |opp|
|
109
109
|
!opp[:account_name].nil? &&
|
@@ -155,7 +155,7 @@ class LandsliderTest < Test::Unit::TestCase
|
|
155
155
|
|
156
156
|
validate_standard_api_result result
|
157
157
|
assert_not_nil result[:leads]
|
158
|
-
|
158
|
+
assert_kind_of Array, result[:leads]
|
159
159
|
end
|
160
160
|
|
161
161
|
def test_landslider_get_lead_custom_fields
|
@@ -207,7 +207,7 @@ class LandsliderTest < Test::Unit::TestCase
|
|
207
207
|
private
|
208
208
|
|
209
209
|
def validate_standard_api_result(result)
|
210
|
-
|
210
|
+
assert_kind_of Hash, result
|
211
211
|
assert_not_nil result[:results_returned], ":results_returned missing"
|
212
212
|
assert_operator result[:results_returned], :>=, 0
|
213
213
|
assert_not_nil result[:total_results_available], ":total_results_available missing"
|
@@ -219,7 +219,7 @@ class LandsliderTest < Test::Unit::TestCase
|
|
219
219
|
def validate_at_least_one_note_returned(result)
|
220
220
|
assert_operator result[:results_returned], :>=, 1
|
221
221
|
assert_not_nil result[:notes], "at least one note should be returned"
|
222
|
-
|
222
|
+
assert_kind_of Array, result[:notes]
|
223
223
|
end
|
224
224
|
|
225
225
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
|
2
|
+
require 'test_helper'
|
3
|
+
|
4
|
+
class WsSearchTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
if $sid2.nil?
|
8
|
+
# only get a session once
|
9
|
+
result = Landslider.login('LOGINTOKEN=' + LS_INSTANCE_NAME)
|
10
|
+
$sid2 = result[:session_id]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_ws_search_object
|
15
|
+
search = Landslider::WsSearch.new('AccountName', 'Equals', 'Boston')
|
16
|
+
assert_equal 'AccountName', search.field_id
|
17
|
+
assert_equal 'Equals', search.operator
|
18
|
+
assert_equal 'Boston', search.query_value
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_get_accounts_without_search_criteria
|
22
|
+
result = Landslider.get_accounts($sid2, 1, 25)
|
23
|
+
|
24
|
+
assert_equal false, result[:error]
|
25
|
+
assert_equal 6, result[:results_returned]
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_get_accounts_with_search_criteria
|
29
|
+
search = Landslider::WsSearch.new('AccountName', 'Equals', 'Boston')
|
30
|
+
result = Landslider.get_accounts($sid2, 1, 25, search)
|
31
|
+
|
32
|
+
assert_equal false, result[:error]
|
33
|
+
assert_equal 1, result[:results_returned]
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: landslider
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.5.
|
5
|
+
version: 0.5.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Jay Prall
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-05-
|
13
|
+
date: 2011-05-06 00:00:00 -04:00
|
14
14
|
default_executable: generate_api_key.rb
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -79,6 +79,7 @@ files:
|
|
79
79
|
- lib/landslider.rb
|
80
80
|
- test/landslider_test.rb
|
81
81
|
- test/test_helper.rb
|
82
|
+
- test/ws_search_test.rb
|
82
83
|
has_rdoc: true
|
83
84
|
homepage: https://github.com/j4y/landslider
|
84
85
|
licenses:
|
@@ -110,3 +111,4 @@ summary: Landslide Ruby
|
|
110
111
|
test_files:
|
111
112
|
- test/landslider_test.rb
|
112
113
|
- test/test_helper.rb
|
114
|
+
- test/ws_search_test.rb
|