landslider 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 2
4
- :patch: 1
4
+ :patch: 2
5
5
  :build:
data/lib/landslider.rb CHANGED
@@ -43,7 +43,7 @@ class Landslider < Handsoap::Service
43
43
  def get_api_version(session_id)
44
44
  self.session_id = session_id
45
45
 
46
- response = invoke("urn:getApiVersion", :soap_action => :none)
46
+ response = invoke("getApiVersion", :soap_action => :none)
47
47
 
48
48
  node = response.document.xpath('//ns:getApiVersionResponse', ns)
49
49
  parse_api_version_result(node)
@@ -113,8 +113,8 @@ class Landslider < Handsoap::Service
113
113
  ans.add 'totalResultsRequested', 10
114
114
  }
115
115
  end
116
- puts response.document.inspect
117
-
116
+ node = response.document.xpath('//ns:getContactNotesResponse', ns)
117
+ parse_get_contact_notes_result(node)
118
118
  end
119
119
 
120
120
  def get_opportunity_notes(session_id, opportunity_id)
@@ -128,8 +128,8 @@ class Landslider < Handsoap::Service
128
128
  ans.add 'totalResultsRequested', 10
129
129
  }
130
130
  end
131
- puts response.document.inspect
132
-
131
+ node = response.document.xpath('//ns:getOpportunityNotesResponse', ns)
132
+ parse_get_opportunity_notes_result(node)
133
133
  end
134
134
 
135
135
  def get_lead_notes(session_id, lead_id)
@@ -143,8 +143,8 @@ class Landslider < Handsoap::Service
143
143
  ans.add 'totalResultsRequested', 10
144
144
  }
145
145
  end
146
- puts response.document.inspect
147
-
146
+ node = response.document.xpath('//ns:getLeadNotesResponse', ns)
147
+ parse_get_lead_notes_result(node)
148
148
  end
149
149
 
150
150
  private
@@ -177,6 +177,7 @@ class Landslider < Handsoap::Service
177
177
  def parse_get_accounts_result(node)
178
178
  {
179
179
  :accounts => node.xpath('//Accounts/accountList', ns).map { |child| parse_account(child) },
180
+
180
181
  :error => xml_to_bool(node, '//Accounts/error/text()'),
181
182
  :error_code => xml_to_int(node, '//Accounts/errorCode/text()'),
182
183
  :result_msg => xml_to_str(node, '//Accounts/resultMsg/text()'),
@@ -187,17 +188,21 @@ class Landslider < Handsoap::Service
187
188
 
188
189
  def parse_get_account_notes_result(node)
189
190
  {
191
+ :notes => parse_notes(node),
192
+
190
193
  :error => xml_to_bool(node, './*/error/text()'),
191
194
  :error_code => xml_to_int(node, './*/errorCode/text()'),
192
195
  :result_msg => xml_to_str(node, './*/resultMsg/text()'),
193
196
  :status_code => xml_to_int(node, './*/statusCode/text()'),
194
- :results_returned => xml_to_int(node, './*/resultsReturned/text()')
197
+ :results_returned => xml_to_int(node, './*/resultsReturned/text()'),
198
+ :total_results_available => xml_to_int(node, './*/totalResultsAvailable/text()')
195
199
  }
196
200
  end
197
201
 
198
202
  def parse_get_account_opportunities_result(node)
199
203
  {
200
204
  :opportunities => node.xpath('./*/opportunityList', ns).map { |child| parse_opportunity(child) },
205
+
201
206
  :error => xml_to_bool(node, './*/error/text()'),
202
207
  :results_returned => xml_to_int(node, './*/resultsReturned/text()'),
203
208
  :total_results_available => xml_to_int(node, './*/totalResultsAvailable/text()')
@@ -207,7 +212,48 @@ class Landslider < Handsoap::Service
207
212
  def parse_get_account_contacts_result(node)
208
213
  {
209
214
  :contacts => node.xpath('./*/contactList', ns).map { |child| parse_contact(child) },
215
+
216
+ :error => xml_to_bool(node, './*/error/text()'),
217
+ :results_returned => xml_to_int(node, './*/resultsReturned/text()'),
218
+ :total_results_available => xml_to_int(node, './*/totalResultsAvailable/text()')
219
+ }
220
+ end
221
+
222
+ def parse_get_contact_notes_result(node)
223
+ {
224
+ :notes => parse_notes(node),
225
+
226
+ :error => xml_to_bool(node, './*/error/text()'),
227
+ :error_code => xml_to_int(node, './*/errorCode/text()'),
228
+ :result_msg => xml_to_str(node, './*/resultMsg/text()'),
229
+ :status_code => xml_to_int(node, './*/statusCode/text()'),
230
+ :results_returned => xml_to_int(node, './*/resultsReturned/text()'),
231
+ :total_results_available => xml_to_int(node, './*/totalResultsAvailable/text()')
232
+
233
+ }
234
+ end
235
+
236
+ def parse_get_lead_notes_result(node)
237
+ {
238
+ :notes => parse_notes(node),
239
+
240
+ :error => xml_to_bool(node, './*/error/text()'),
241
+ :error_code => xml_to_int(node, './*/errorCode/text()'),
242
+ :result_msg => xml_to_str(node, './*/resultMsg/text()'),
243
+ :status_code => xml_to_int(node, './*/statusCode/text()'),
244
+ :results_returned => xml_to_int(node, './*/resultsReturned/text()'),
245
+ :total_results_available => xml_to_int(node, './*/totalResultsAvailable/text()')
246
+ }
247
+ end
248
+
249
+ def parse_get_opportunity_notes_result(node)
250
+ {
251
+ :notes => parse_notes(node),
252
+
210
253
  :error => xml_to_bool(node, './*/error/text()'),
254
+ :error_code => xml_to_int(node, './*/errorCode/text()'),
255
+ :result_msg => xml_to_str(node, './*/resultMsg/text()'),
256
+ :status_code => xml_to_int(node, './*/statusCode/text()'),
211
257
  :results_returned => xml_to_int(node, './*/resultsReturned/text()'),
212
258
  :total_results_available => xml_to_int(node, './*/totalResultsAvailable/text()')
213
259
  }
@@ -275,6 +321,27 @@ class Landslider < Handsoap::Service
275
321
  }
276
322
  end
277
323
 
324
+ def parse_notes(node)
325
+ {
326
+ :notes => node.xpath('./*/notes', ns).map { |child| parse_note(child) }
327
+ }
328
+ end
329
+
330
+ # WsNote
331
+ def parse_note(node)
332
+ {
333
+ #:entity_id => xml_to_str(node, './entityId/text()'),
334
+ #:entity_type => xml_to_str(node, './entityType/text()'),
335
+ :archived_by => xml_to_int(node, './archivedBy/text()'),
336
+ :created_by => xml_to_int(node, './createdBy/text()'),
337
+ :created_on => xml_to_str(node, './createdOn/text()'),
338
+ :latest => xml_to_bool(node, './latest/text()'),
339
+ :note_id => xml_to_str(node, './noteId/text()'),
340
+ :note_html => xml_to_str(node, './note/text()')
341
+
342
+ }
343
+ end
344
+
278
345
  # WsOpportunity
279
346
  def parse_opportunity(node)
280
347
  {
@@ -3,7 +3,17 @@ require 'test_helper'
3
3
 
4
4
  class LandsliderTest < Test::Unit::TestCase
5
5
 
6
+ def setup
7
+ # TODO: fetch a session_id once
8
+ # if $sid.nil?
9
+ result = Landslider.login('LOGINTOKEN=' + LS_INSTANCE_NAME)
10
+ $sid = result[:session_id]
11
+ # end
12
+ #puts "using #{$sid} to login"
13
+ end
14
+
6
15
  def test_landslider_login
16
+ # other tests should use $sid for authenticatoin
7
17
  result = Landslider.login('LOGINTOKEN=' + LS_INSTANCE_NAME)
8
18
 
9
19
  assert_not_nil result
@@ -12,8 +22,7 @@ class LandsliderTest < Test::Unit::TestCase
12
22
  end
13
23
 
14
24
  def test_landslider_get_api_version
15
- result = Landslider.login('LOGINTOKEN=' + LS_INSTANCE_NAME)
16
- result = Landslider.get_api_version(result[:session_id])
25
+ result = Landslider.get_api_version($sid)
17
26
 
18
27
  assert_not_nil result
19
28
  assert_operator result[:major_version], :>=, 2
@@ -22,8 +31,8 @@ class LandsliderTest < Test::Unit::TestCase
22
31
  end
23
32
 
24
33
  def test_landslider_get_accounts
25
- result = Landslider.login('LOGINTOKEN=' + LS_INSTANCE_NAME)
26
- result = Landslider.get_accounts(result[:session_id])
34
+ result = Landslider.get_accounts($sid)
35
+
27
36
  assert_equal false, result[:error]
28
37
  assert_not_nil result[:accounts]
29
38
  assert result[:accounts].all? { |a| !a[:account_name].nil? }, "account name required"
@@ -32,34 +41,25 @@ class LandsliderTest < Test::Unit::TestCase
32
41
  assert_not_nil result[:result_msg]
33
42
  end
34
43
 
35
- def test_landslider_get_account_contacts
36
- result = Landslider.login('LOGINTOKEN=' + LS_INSTANCE_NAME)
37
-
44
+ def test_landslider_get_account_contacts
38
45
  # exists on jaytest
39
- result = Landslider.get_account_contacts(result[:session_id], 51857822)
46
+ result = Landslider.get_account_contacts($sid, 51857822)
40
47
 
41
- assert_equal false, result[:error]
42
- assert_operator result[:results_returned], :>=, 1
48
+ validate_standard_api_result result
43
49
  assert result[:contacts].all? { |con| !con[:last_name].nil? }, "last name required"
44
50
  end
45
51
 
46
52
  def test_landslider_get_account_notes
47
- result = Landslider.login('LOGINTOKEN=' + LS_INSTANCE_NAME)
48
-
49
53
  # exists on jaytest
50
- result = Landslider.get_account_notes(result[:session_id], 55647822)
54
+ result = Landslider.get_account_notes($sid, 55647822)
51
55
 
52
56
  validate_standard_api_result result
53
- assert_operator result[:results_returned], :>=, 1
54
-
57
+ validate_at_least_one_note_returned result
55
58
  end
56
-
57
-
58
- def test_landslider_get_account_opportunities
59
- result = Landslider.login('LOGINTOKEN=' + LS_INSTANCE_NAME)
60
59
 
60
+ def test_landslider_get_account_opportunities
61
61
  # exists on jaytest
62
- result = Landslider.get_account_opportunities(result[:session_id], 51858821)
62
+ result = Landslider.get_account_opportunities($sid, 51858821)
63
63
 
64
64
  assert_equal false, result[:error]
65
65
  assert result[:opportunities].all? { |opp|
@@ -68,22 +68,55 @@ class LandsliderTest < Test::Unit::TestCase
68
68
  !opp[:deal_value].nil? &&
69
69
  !opp[:selling_process].nil?
70
70
  }, "opportunities require a name, account, deal value and selling process"
71
-
72
- end
71
+ end
72
+
73
+ def test_landslider_get_contact_notes
74
+ # exists on jaytest
75
+ result = Landslider.get_contact_notes($sid, 62813411)
76
+
77
+ validate_standard_api_result result
78
+ validate_at_least_one_note_returned result
79
+ end
80
+
81
+ def test_landslider_get_lead_notes
82
+ # exists on jaytest
83
+ result = Landslider.get_lead_notes($sid, 33592028)
84
+
85
+ validate_standard_api_result result
86
+ validate_at_least_one_note_returned result
87
+ end
88
+
73
89
 
90
+ def test_landslider_get_opportunity_notes
91
+ # exists on jaytest
92
+ result = Landslider.get_opportunity_notes($sid, 55952453)
93
+
94
+ validate_standard_api_result result
95
+ validate_at_least_one_note_returned result
96
+ end
74
97
 
75
98
  private
76
99
 
77
100
  def validate_standard_api_result(result)
78
101
  assert_equal Hash, result.class, "api method should return a hash"
102
+ assert_not_nil result[:results_returned], ":results_returned missing"
79
103
  assert_operator result[:results_returned], :>=, 0
104
+ assert_not_nil result[:total_results_available], ":total_results_available missing"
105
+ assert_operator result[:total_results_available], :>=, 0
106
+ assert_not_nil result[:error]
80
107
  assert_equal false, result[:error], "error should be false"
81
108
  end
82
-
83
- def login(session_id)
84
- Landslider.login(session_id)
85
- end
86
109
 
110
+ def validate_at_least_one_note_returned(result)
111
+ assert_operator result[:results_returned], :>=, 1
112
+ assert_not_nil result[:notes], "at least one note should be returned"
113
+ assert_equal Hash, result[:notes].class
114
+ end
115
+
116
+ # def login(session_id)
117
+ # Landslider.login(session_id)
118
+ # end
119
+ #
87
120
 
88
121
  end
89
122
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: landslider
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.1
5
+ version: 0.2.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-04-25 00:00:00 -04:00
13
+ date: 2011-04-27 00:00:00 -04:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency