landslider 0.2.3 → 0.2.4

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: 2
4
- :patch: 3
4
+ :patch: 4
5
5
  :build:
data/lib/landslider.rb CHANGED
@@ -98,6 +98,13 @@ class Landslider < Handsoap::Service
98
98
  ans.add 'accountId', account_id
99
99
  ans.add 'firstResultPosition', 1
100
100
  ans.add 'totalResultsRequested', 10
101
+
102
+ ans.add('searchCriteria') { |sc|
103
+ # just find accounts with an empty main city
104
+
105
+ sc.add 'fieldId', 'MainAddressCity'
106
+ sc.add 'operator', 'Empty'
107
+ }
101
108
  }
102
109
  end
103
110
  node = response.document.xpath('//ns:getAccountNotesResponse', ns)
@@ -143,43 +150,18 @@ class Landslider < Handsoap::Service
143
150
  parse_get_opportunity_notes_result(node)
144
151
  end
145
152
 
146
- def get_leads(session_id)
147
- # <soap:getLeads>
148
- # <!--Optional:-->
149
- # <leadRequest>
150
- # <entityId>?</entityId>
151
- # <!--Optional:-->
152
- # <entityName>?</entityName>
153
- # <!--Optional:-->
154
- # <entityType>?</entityType>
155
- # <allowDuplicateCriterion>?</allowDuplicateCriterion>
156
- # <firstResultPosition>?</firstResultPosition>
157
- # <returnDeletedRecords>?</returnDeletedRecords>
158
- # <!--Zero or more repetitions:-->
159
- # <searchCriteria>
160
- # <!--Optional:-->
161
- # <fieldId>?</fieldId>
162
- # <!--Optional:-->
163
- # <operator>?</operator>
164
- # <!--Optional:-->
165
- # <queryValue>?</queryValue>
166
- # </searchCriteria>
167
- # <!--Optional:-->
168
- # <sourceSystemId>?</sourceSystemId>
169
- # <totalResultsRequested>?</totalResultsRequested>
170
- # <!--Optional:-->
171
- # <updatedOn>?</updatedOn>
172
- # <accountId>?</accountId>
173
- # <hot>?</hot>
174
- # <hotSpecified>?</hotSpecified>
175
- # <!--Optional:-->
176
- # <name>?</name>
177
- # <primaryOwnerId>?</primaryOwnerId>
178
- # <statusId>?</statusId>
179
- # <targetId>?</targetId>
180
- # </leadRequest>
181
- # </soap:getLeads>
153
+ def get_leads(session_id, account_id)
154
+ self.session_id = session_id
155
+
156
+ response = invoke("getLeads", :soap_action => :none) do |message|
157
+ message.add('leadRequest') { |lr|
182
158
 
159
+ lr.add 'firstResultPosition', 1
160
+ lr.add 'totalResultsRequested', 10
161
+ }
162
+ end
163
+ node = response.document.xpath('//ns:getLeadsResponse', ns)
164
+ parse_get_leads_result(node)
183
165
  end
184
166
 
185
167
  def get_lead_notes(session_id, lead_id)
@@ -291,6 +273,18 @@ class Landslider < Handsoap::Service
291
273
 
292
274
  }
293
275
  end
276
+ def parse_get_leads_result(node)
277
+ {
278
+ :leads => parse_leads(node),
279
+
280
+ :error => xml_to_bool(node, './*/error/text()'),
281
+ :error_code => xml_to_int(node, './*/errorCode/text()'),
282
+ :result_msg => xml_to_str(node, './*/resultMsg/text()'),
283
+ :status_code => xml_to_int(node, './*/statusCode/text()'),
284
+ :results_returned => xml_to_int(node, './*/resultsReturned/text()'),
285
+ :total_results_available => xml_to_int(node, './*/totalResultsAvailable/text()')
286
+ }
287
+ end
294
288
 
295
289
  def parse_get_lead_notes_result(node)
296
290
  {
@@ -400,7 +394,24 @@ class Landslider < Handsoap::Service
400
394
 
401
395
  }
402
396
  end
403
-
397
+
398
+ def parse_leads(node)
399
+ {
400
+ :leads => node.xpath('./*/leadList', ns).map { |child| parse_lead(child) }
401
+ }
402
+ end
403
+
404
+ # WsLead
405
+ def parse_lead(node)
406
+ {
407
+ :name => xml_to_str(node, './name/text()'),
408
+ :ok_to_call => xml_to_bool(node, './okToCall/text()'),
409
+ :ok_to_email => xml_to_bool(node, './okToEmail/text()'),
410
+ :hot => xml_to_bool(node, './hot/text()')
411
+ }
412
+
413
+ end
414
+
404
415
  # WsOpportunity
405
416
  def parse_opportunity(node)
406
417
  {
@@ -64,7 +64,7 @@ class LandsliderTest < Test::Unit::TestCase
64
64
  validate_standard_api_result result
65
65
  validate_at_least_one_note_returned result
66
66
  end
67
-
67
+
68
68
  def test_landslider_get_account_opportunities
69
69
  # exists on jaytest
70
70
  result = Landslider.get_account_opportunities($sid, 51858821)
@@ -77,7 +77,7 @@ class LandsliderTest < Test::Unit::TestCase
77
77
  !opp[:selling_process].nil?
78
78
  }, "opportunities require a name, account, deal value and selling process"
79
79
  end
80
-
80
+
81
81
  def test_landslider_get_contact_notes
82
82
  # exists on jaytest
83
83
  result = Landslider.get_contact_notes($sid, 62813411)
@@ -87,9 +87,10 @@ class LandsliderTest < Test::Unit::TestCase
87
87
  end
88
88
 
89
89
  def test_landslider_get_leads
90
- result = Landslider.get_leads($sid)
91
- puts result.inspect
92
-
90
+ result = Landslider.get_leads($sid, 51857822)
91
+
92
+ validate_standard_api_result result
93
+ assert_not_nil result[:leads]
93
94
  end
94
95
 
95
96
 
@@ -109,9 +110,9 @@ class LandsliderTest < Test::Unit::TestCase
109
110
  validate_standard_api_result result
110
111
  validate_at_least_one_note_returned result
111
112
  end
112
-
113
+
113
114
  private
114
-
115
+
115
116
  def validate_standard_api_result(result)
116
117
  assert_equal Hash, result.class, "api method should return a hash"
117
118
  assert_not_nil result[:results_returned], ":results_returned missing"
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: landslider
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.3
5
+ version: 0.2.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jay Prall