landslider 0.5.6 → 0.5.7

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/VERSION.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 5
4
- :patch: 6
4
+ :patch: 7
5
5
  :build:
data/landslider.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{landslider}
8
- s.version = "0.5.6"
8
+ s.version = "0.5.7"
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"]
data/lib/landslider.rb CHANGED
@@ -5,6 +5,7 @@ class Landslider < Handsoap::Service
5
5
 
6
6
  class WsSearch
7
7
  attr_writer :first_result_position, :total_results_requested, :updated_on
8
+ attr_writer :search_criteria
8
9
 
9
10
  def initialize
10
11
  end
@@ -15,6 +16,10 @@ class Landslider < Handsoap::Service
15
16
  msg.add 'firstResultPosition', @first_result_position || DEFAULT_FIRST_RESULT_POSITION
16
17
  msg.add 'totalResultsRequested', @total_results_requested || DEFAULT_TOTAL_RESULTS_REQUESTED
17
18
  msg.add 'updatedOn', @updated_on unless @updated_on.nil?
19
+ unless @search_criteria.nil?
20
+ @search_criteria.soapify_for(msg)
21
+ end
22
+
18
23
  end
19
24
 
20
25
  end
@@ -42,8 +47,6 @@ class Landslider < Handsoap::Service
42
47
  class WsAccountNoteSearch < WsSearch
43
48
  attr_reader :account_id
44
49
 
45
- # alias :super_soapify_for :soapify_for
46
-
47
50
  def initialize(account_id)
48
51
  @account_id = account_id
49
52
  end
@@ -53,9 +56,7 @@ class Landslider < Handsoap::Service
53
56
  def soapify_for(msg)
54
57
  msg.add('accountNoteSearch') { |crit|
55
58
  crit.add 'accountId', @account_id
56
- crit.add 'firstResultPosition', @first_result_position || DEFAULT_FIRST_RESULT_POSITION
57
- crit.add 'totalResultsRequested', @total_results_requested || DEFAULT_TOTAL_RESULTS_REQUESTED
58
- crit.add 'updatedOn', @updated_on unless @updated_on.nil?
59
+ super(crit)
59
60
  }
60
61
  end
61
62
  end
@@ -72,9 +73,7 @@ class Landslider < Handsoap::Service
72
73
  def soapify_for(msg)
73
74
  msg.add('contactNote') { |crit|
74
75
  crit.add 'contactId', @contact_id
75
- crit.add 'firstResultPosition', @first_result_position || DEFAULT_FIRST_RESULT_POSITION
76
- crit.add 'totalResultsRequested', @total_results_requested || DEFAULT_TOTAL_RESULTS_REQUESTED
77
- crit.add 'updatedOn', @updated_on unless @updated_on.nil?
76
+ super(crit)
78
77
  }
79
78
  end
80
79
  end
@@ -91,9 +90,7 @@ class Landslider < Handsoap::Service
91
90
  def soapify_for(msg)
92
91
  msg.add('leadNote') { |crit|
93
92
  crit.add 'leadId', @lead_id
94
- crit.add 'firstResultPosition', @first_result_position || DEFAULT_FIRST_RESULT_POSITION
95
- crit.add 'totalResultsRequested', @total_results_requested || DEFAULT_TOTAL_RESULTS_REQUESTED
96
- crit.add 'updatedOn', @updated_on unless @updated_on.nil?
93
+ super(crit)
97
94
  }
98
95
  end
99
96
 
@@ -111,9 +108,7 @@ class Landslider < Handsoap::Service
111
108
  def soapify_for(msg)
112
109
  msg.add('opportunityNote') { |crit|
113
110
  crit.add 'opportunityId', @opportunity_id
114
- crit.add 'firstResultPosition', @first_result_position || DEFAULT_FIRST_RESULT_POSITION
115
- crit.add 'totalResultsRequested', @total_results_requested || DEFAULT_TOTAL_RESULTS_REQUESTED
116
- crit.add 'updatedOn', @updated_on unless @updated_on.nil?
111
+ super(crit)
117
112
  }
118
113
  end
119
114
  end
@@ -163,15 +158,11 @@ class Landslider < Handsoap::Service
163
158
  parse_login_result(node)
164
159
  end
165
160
 
166
- def get_accounts(session_id, first_result_position=1, total_results_requested=25, search_criteria=nil)
161
+ def get_accounts(session_id, search=WsSearch.new)
167
162
  self.session_id = session_id
168
163
  response = invoke('getAccounts', :soap_action => :none) do |message|
169
164
  message.add('accountsRequest') { |req|
170
- req.add 'firstResultPosition', first_result_position
171
- req.add 'totalResultsRequested', total_results_requested
172
- unless search_criteria.nil?
173
- search_criteria.soapify_for(req)
174
- end
165
+ search.soapify_for(req)
175
166
  }
176
167
  end
177
168
 
@@ -236,16 +227,12 @@ class Landslider < Handsoap::Service
236
227
  parse_api_version_result(node)
237
228
  end
238
229
 
239
- def get_contacts(session_id, first_result_position=1, total_results_requested=25, search_criteria=nil)
230
+ def get_contacts(session_id, search=WsSearch.new)
240
231
  self.session_id = session_id
241
232
 
242
233
  response = invoke('getContacts', :soap_action => :none) do |message|
243
234
  message.add('contactsRequest') { |req|
244
- req.add 'firstResultPosition', first_result_position
245
- req.add 'totalResultsRequested', total_results_requested
246
- unless search_criteria.nil?
247
- search_criteria.soapify_for(req)
248
- end
235
+ search.soapify_for(req)
249
236
  }
250
237
  end
251
238
  node = response.document.xpath('//ns:getContactsResponse', ns)
@@ -281,16 +268,12 @@ class Landslider < Handsoap::Service
281
268
  parse_get_instance_information_result(node)
282
269
  end
283
270
 
284
- def get_leads(session_id, account_id, first_result_position=1, total_results_requested=25, search_criteria=nil)
271
+ def get_leads(session_id, search=WsSearch.new)
285
272
  self.session_id = session_id
286
273
 
287
274
  response = invoke('getLeads', :soap_action => :none) do |message|
288
275
  message.add('leadRequest') { |req|
289
- req.add 'firstResultPosition', first_result_position
290
- req.add 'totalResultsRequested', total_results_requested
291
- unless search_criteria.nil?
292
- search_criteria.soapify_for(req)
293
- end
276
+ search.soapify_for(req)
294
277
  }
295
278
  end
296
279
 
@@ -314,16 +297,12 @@ class Landslider < Handsoap::Service
314
297
  parse_get_lead_notes_result(node)
315
298
  end
316
299
 
317
- def get_opportunities(session_id, first_result_position=1, total_results_requested=25, search_criteria=nil)
300
+ def get_opportunities(session_id, search=WsSearch.new)
318
301
  self.session_id = session_id
319
302
 
320
303
  response = invoke('getOpportunities', :soap_action => :none) do |message|
321
304
  message.add('opportunityRequest') { |req|
322
- req.add 'firstResultPosition', first_result_position
323
- req.add 'totalResultsRequested', total_results_requested
324
- unless search_criteria.nil?
325
- search_criteria.soapify_for(req)
326
- end
305
+ search.soapify_for(req)
327
306
  }
328
307
  end
329
308
  node = response.document.xpath('//ns:getOpportunitiesResponse', ns)
@@ -27,16 +27,6 @@ class LandsliderTest < Test::Unit::TestCase
27
27
  assert_operator result[:revision_version], :>=, 0
28
28
  end
29
29
 
30
- def test_landslider_get_accounts
31
- result = Landslider.get_accounts($sid)
32
-
33
- assert_equal false, result[:error]
34
- assert_not_nil result[:accounts]
35
- assert result[:accounts].all? { |a| !a[:account_name].nil? }, "account name required"
36
- assert_operator result[:results_returned], :>=, 0
37
- assert_operator result[:total_results_available], :>=, 0
38
- assert_not_nil result[:result_msg]
39
- end
40
30
 
41
31
  def test_landslider_get_account_by_id
42
32
  result = Landslider.get_account_by_id($sid, JAYTEST_ACCOUNT_ID)
@@ -133,7 +123,7 @@ class LandsliderTest < Test::Unit::TestCase
133
123
  end
134
124
 
135
125
  def test_landslider_get_leads
136
- result = Landslider.get_leads($sid, 51857822)
126
+ result = Landslider.get_leads($sid)
137
127
 
138
128
  validate_standard_api_result result
139
129
  assert_not_nil result[:leads]
@@ -146,11 +136,6 @@ class LandsliderTest < Test::Unit::TestCase
146
136
  assert_not_nil result[:custom_fields].first[:custom_field_id]
147
137
  end
148
138
 
149
- def test_landslider_get_opportunities
150
- result = Landslider.get_opportunities($sid)
151
- assert_not_nil result[:opportunities]
152
- end
153
-
154
139
  def test_landslider_get_user_information
155
140
  result = Landslider.get_user_information($sid, 'jayp@landslide.com')
156
141
 
@@ -4,6 +4,7 @@ require 'test_helper'
4
4
  class WsAccountNoteSearchTest < Test::Unit::TestCase
5
5
 
6
6
  def setup
7
+ # Landslider.logger = $stdout
7
8
  $sid3 ||= Landslider.login('LOGINTOKEN=' + LS_INSTANCE_NAME)[:session_id]
8
9
  end
9
10
 
@@ -4,42 +4,45 @@ require 'test_helper'
4
4
  class WsSearchTest < Test::Unit::TestCase
5
5
 
6
6
  def setup
7
+ # Landslider.logger = $stdout
7
8
  $sid2 ||= Landslider.login('LOGINTOKEN=' + LS_INSTANCE_NAME)[:session_id]
8
9
  end
9
10
 
10
11
  def test_ws_search_object
11
- search = Landslider::WsSearchCriterion.new('AccountName', 'Equals', 'Boston')
12
- assert_equal 'AccountName', search.field_id
13
- assert_equal 'Equals', search.operator
14
- assert_equal 'Boston', search.query_value
12
+ search_criteria = Landslider::WsSearchCriterion.new('AccountName', 'Equals', 'Boston')
13
+ assert_equal 'AccountName', search_criteria.field_id
14
+ assert_equal 'Equals', search_criteria.operator
15
+ assert_equal 'Boston', search_criteria.query_value
15
16
  end
16
17
 
17
18
  def test_get_accounts_without_search_criteria
18
- result = Landslider.get_accounts($sid2, 1, 25)
19
+ result = Landslider.get_accounts($sid2)
19
20
 
20
21
  assert_equal false, result[:error]
21
22
  assert_equal 6, result[:results_returned]
22
23
  end
23
24
 
24
25
  def test_get_accounts_with_search_criteria
25
- search = Landslider::WsSearchCriterion.new('AccountName', 'Equals', 'Boston')
26
- result = Landslider.get_accounts($sid2, 1, 25, search)
26
+ search = Landslider::WsSearch.new
27
+ search.search_criteria = Landslider::WsSearchCriterion.new('AccountName', 'Equals', 'Boston')
28
+ result = Landslider.get_accounts($sid2, search)
27
29
 
28
30
  assert_equal false, result[:error]
29
31
  assert_equal 1, result[:results_returned]
30
32
  end
31
33
 
32
34
  def test_get_opportunities_without_search_criteria
33
- result = Landslider.get_opportunities($sid2, 1, 25)
34
-
35
+ result = Landslider.get_opportunities($sid2)
36
+
35
37
  assert_equal false, result[:error]
36
38
  assert_equal 4, result[:results_returned]
37
39
  end
38
-
40
+
39
41
  def test_get_opportunities_with_search_criteria
40
42
  target_phase_name = 'Prospect'
41
- search = Landslider::WsSearchCriterion.new('CurrentPhaseName', 'Contains', target_phase_name)
42
- result = Landslider.get_opportunities($sid2, 1, 25, search)
43
+ search = Landslider::WsSearch.new
44
+ search.search_criteria = Landslider::WsSearchCriterion.new('CurrentPhaseName', 'Contains', target_phase_name)
45
+ result = Landslider.get_opportunities($sid2, search)
43
46
 
44
47
  assert_equal false, result[:error]
45
48
  assert_equal 3, result[:results_returned]
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: landslider
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.5.6
5
+ version: 0.5.7
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jay Prall