landslider 0.4.5 → 0.4.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/README.rdoc +7 -1
- data/VERSION.yml +1 -1
- data/landslider.gemspec +1 -1
- data/lib/landslider.rb +125 -30
- data/test/landslider_test.rb +41 -9
- data/test/test_helper.rb +1 -1
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -32,7 +32,7 @@ This gem requires the following gems:
|
|
32
32
|
LS_API_KEY = Digest::MD5.hexdigest(LS_API_PASSWORD + LS_INSTANCE_NAME)
|
33
33
|
LS_API_ENDPOINT = {
|
34
34
|
:uri => "https://#{LS_INSTANCE_NAME}.api.landslide.com/webservices/SoapService",
|
35
|
-
:version =>
|
35
|
+
:version => 1
|
36
36
|
}
|
37
37
|
|
38
38
|
response = Landslider.login('LOGINTOKEN=' + LS_INSTANCE_NAME)
|
@@ -49,13 +49,19 @@ This gem requires the following gems:
|
|
49
49
|
* getApiVersion
|
50
50
|
* getAccounts
|
51
51
|
* getAccountById
|
52
|
+
* getAccountCustomFields
|
52
53
|
* getAccountContacts
|
53
54
|
* getAccountNotes
|
54
55
|
* getAccountOpportunities
|
56
|
+
* getContacts
|
57
|
+
* getContactCustomFields
|
55
58
|
* getContactNotes
|
56
59
|
* getInstanceInformation
|
57
60
|
* getLeads
|
61
|
+
* getLeadCustomFields
|
58
62
|
* getLeadNotes
|
63
|
+
* getOpportunities
|
64
|
+
* getOpportunityCustomFields
|
59
65
|
* getOpportunityNotes
|
60
66
|
* getUserInformation
|
61
67
|
* getUserInformationById
|
data/VERSION.yml
CHANGED
data/landslider.gemspec
CHANGED
data/lib/landslider.rb
CHANGED
@@ -20,6 +20,13 @@ class Landslider < Handsoap::Service
|
|
20
20
|
sh.add('urn:sessionId', self.session_id)
|
21
21
|
}
|
22
22
|
end
|
23
|
+
|
24
|
+
def on_after_create_http_request(http_request)
|
25
|
+
http_request.headers.merge!({'user-agent' => ["landslider-ruby-gem-version-0.4.6"]})
|
26
|
+
|
27
|
+
# TODO: use cookies to maintain session state
|
28
|
+
# http_request.headers.merge!({'cookie' => ["JSESSIONID=#{self.session_id}"]})
|
29
|
+
end
|
23
30
|
|
24
31
|
def on_http_error(response)
|
25
32
|
puts response.inspect
|
@@ -83,9 +90,15 @@ class Landslider < Handsoap::Service
|
|
83
90
|
response = invoke("getAccountContacts", :soap_action => :none) do |message|
|
84
91
|
message.add 'accountId', account_id
|
85
92
|
end
|
86
|
-
|
93
|
+
|
87
94
|
node = response.document.xpath('//ns:getAccountContactsResponse', ns)
|
88
|
-
parse_get_account_contacts_result(node)
|
95
|
+
parse_get_account_contacts_result(node)
|
96
|
+
end
|
97
|
+
|
98
|
+
def get_account_custom_fields(session_id)
|
99
|
+
response = invoke("getAccountCustomFields")
|
100
|
+
node = response.document.xpath('//ns:getAccountCustomFieldsResponse', ns)
|
101
|
+
parse_get_entity_custom_fields_result(node)
|
89
102
|
end
|
90
103
|
|
91
104
|
def get_account_notes(session_id, account_id, first_result_position=1, total_results_requested=25)
|
@@ -117,7 +130,28 @@ class Landslider < Handsoap::Service
|
|
117
130
|
end
|
118
131
|
|
119
132
|
node = response.document.xpath('//ns:getAccountOpportunitiesResponse', ns)
|
120
|
-
parse_get_account_opportunities_result(node)
|
133
|
+
parse_get_account_opportunities_result(node)
|
134
|
+
end
|
135
|
+
|
136
|
+
def get_contacts(session_id, first_result_position=1, total_results_requested=25)
|
137
|
+
self.session_id = session_id
|
138
|
+
|
139
|
+
response = invoke("getContacts", :soap_action => :none) do |message|
|
140
|
+
message.add('contactsRequest') { |c|
|
141
|
+
c.add 'firstResultPosition', first_result_position
|
142
|
+
c.add 'totalResultsRequested', total_results_requested
|
143
|
+
}
|
144
|
+
end
|
145
|
+
node = response.document.xpath('//ns:getContactsResponse', ns)
|
146
|
+
parse_get_contacts_result(node)
|
147
|
+
end
|
148
|
+
|
149
|
+
def get_contact_custom_fields(session_id)
|
150
|
+
self.session_id = session_id
|
151
|
+
|
152
|
+
response = invoke("getContactCustomFields")
|
153
|
+
node = response.document.xpath('//ns:getContactCustomFieldsResponse', ns)
|
154
|
+
parse_get_entity_custom_fields_result(node)
|
121
155
|
end
|
122
156
|
|
123
157
|
def get_contact_notes(session_id, contact_id, first_result_position=1, total_results_requested=25)
|
@@ -154,11 +188,18 @@ class Landslider < Handsoap::Service
|
|
154
188
|
lr.add 'firstResultPosition', first_result_position
|
155
189
|
lr.add 'totalResultsRequested', total_results_requested
|
156
190
|
}
|
157
|
-
end
|
191
|
+
end
|
192
|
+
|
158
193
|
node = response.document.xpath('//ns:getLeadsResponse', ns)
|
159
194
|
parse_get_leads_result(node)
|
160
195
|
end
|
161
196
|
|
197
|
+
def get_lead_custom_fields(session_id)
|
198
|
+
response = invoke("getLeadCustomFields")
|
199
|
+
node = response.document.xpath('//ns:getLeadCustomFieldsResponse', ns)
|
200
|
+
parse_get_entity_custom_fields_result(node)
|
201
|
+
end
|
202
|
+
|
162
203
|
def get_lead_notes(session_id, lead_id, first_result_position=1, total_results_requested=25)
|
163
204
|
self.session_id = session_id
|
164
205
|
|
@@ -173,7 +214,27 @@ class Landslider < Handsoap::Service
|
|
173
214
|
node = response.document.xpath('//ns:getLeadNotesResponse', ns)
|
174
215
|
parse_get_lead_notes_result(node)
|
175
216
|
end
|
217
|
+
|
218
|
+
def get_opportunities(session_id, first_result_position=1, total_results_requested=25)
|
219
|
+
self.session_id = session_id
|
220
|
+
|
221
|
+
response = invoke("getOpportunities", :soap_action => :none) do |message|
|
222
|
+
message.add('opportunityRequest') { |req|
|
223
|
+
req.add 'firstResultPosition', first_result_position
|
224
|
+
req.add 'totalResultsRequested', total_results_requested
|
225
|
+
}
|
226
|
+
end
|
227
|
+
node = response.document.xpath('//ns:getOpportunitiesResponse', ns)
|
228
|
+
parse_get_opportunities_result(node)
|
229
|
+
end
|
176
230
|
|
231
|
+
def get_opportunity_custom_fields(session_id)
|
232
|
+
self.session_id = session_id
|
233
|
+
|
234
|
+
response = invoke("getOpportunityCustomFields")
|
235
|
+
node = response.document.xpath('//ns:getOpportunityCustomFieldsResponse', ns)
|
236
|
+
parse_get_entity_custom_fields_result(node)
|
237
|
+
end
|
177
238
|
|
178
239
|
def get_opportunity_notes(session_id, opportunity_id, first_result_position=1, total_results_requested=25)
|
179
240
|
self.session_id = session_id
|
@@ -291,6 +352,16 @@ class Landslider < Handsoap::Service
|
|
291
352
|
}
|
292
353
|
end
|
293
354
|
|
355
|
+
def parse_get_contacts_result(node)
|
356
|
+
{
|
357
|
+
:contacts => node.xpath('./*/contactList', ns).map { |child| parse_contact(child) },
|
358
|
+
|
359
|
+
:error => xml_to_bool(node, './*/error/text()'),
|
360
|
+
:results_returned => xml_to_int(node, './*/resultsReturned/text()'),
|
361
|
+
:total_results_available => xml_to_int(node, './*/totalResultsAvailable/text()')
|
362
|
+
}
|
363
|
+
end
|
364
|
+
|
294
365
|
def parse_get_contact_notes_result(node)
|
295
366
|
notes = parse_notes(node)
|
296
367
|
{
|
@@ -304,6 +375,17 @@ class Landslider < Handsoap::Service
|
|
304
375
|
}.merge(notes)
|
305
376
|
end
|
306
377
|
|
378
|
+
def parse_get_entity_custom_fields_result(node)
|
379
|
+
{
|
380
|
+
:custom_fields => node.xpath('./*/customFields', ns).map { |child| parse_custom_field(child) },
|
381
|
+
|
382
|
+
:error => xml_to_bool(node, './*/error/text()'),
|
383
|
+
:error_code => xml_to_int(node, './*/errorCode/text()'),
|
384
|
+
:result_msg => xml_to_str(node, './*/resultMsg/text()'),
|
385
|
+
:status_code => xml_to_int(node, './*/statusCode/text()')
|
386
|
+
}
|
387
|
+
end
|
388
|
+
|
307
389
|
def parse_get_instance_information_result(node)
|
308
390
|
{
|
309
391
|
:address => parse_address(node.xpath('./*/address')),
|
@@ -317,7 +399,6 @@ class Landslider < Handsoap::Service
|
|
317
399
|
}
|
318
400
|
end
|
319
401
|
|
320
|
-
|
321
402
|
def parse_get_leads_result(node)
|
322
403
|
leads = parse_leads(node)
|
323
404
|
{
|
@@ -343,6 +424,19 @@ class Landslider < Handsoap::Service
|
|
343
424
|
}.merge(notes)
|
344
425
|
end
|
345
426
|
|
427
|
+
def parse_get_opportunities_result(node)
|
428
|
+
{
|
429
|
+
:opportunities => node.xpath('./*/opportunityList', ns).map { |child| parse_opportunity(child) },
|
430
|
+
|
431
|
+
:error => xml_to_bool(node, './*/error/text()'),
|
432
|
+
:error_code => xml_to_int(node, './*/errorCode/text()'),
|
433
|
+
:result_msg => xml_to_str(node, './*/resultMsg/text()'),
|
434
|
+
:status_code => xml_to_int(node, './*/statusCode/text()'),
|
435
|
+
:results_returned => xml_to_int(node, './*/resultsReturned/text()'),
|
436
|
+
:total_results_available => xml_to_int(node, './*/totalResultsAvailable/text()')
|
437
|
+
}
|
438
|
+
end
|
439
|
+
|
346
440
|
def parse_get_opportunity_notes_result(node)
|
347
441
|
notes = parse_notes(node)
|
348
442
|
{
|
@@ -396,9 +490,6 @@ class Landslider < Handsoap::Service
|
|
396
490
|
# WsAccountType
|
397
491
|
def parse_account_type(node)
|
398
492
|
{
|
399
|
-
#:entity_id => xml_to_str(node, './entityId/text()'),
|
400
|
-
#:entity_type => xml_to_str(node, './entityType/text()')
|
401
|
-
#:account_type_id => xml_to_str(node, './accountTypeId/text()'),
|
402
493
|
:account_type => xml_to_str(node, './accountType/text()')
|
403
494
|
}
|
404
495
|
end
|
@@ -406,9 +497,6 @@ class Landslider < Handsoap::Service
|
|
406
497
|
# WsAddress
|
407
498
|
def parse_address(node)
|
408
499
|
{
|
409
|
-
#:entity_id => xml_to_str(node, './entityId/text()'),
|
410
|
-
#:entity_type => xml_to_str(node, './entityType/text()'),
|
411
|
-
#:address_id => xml_to_str(node, './addressId/text()'),
|
412
500
|
:address => xml_to_str(node, './address1/text()'),
|
413
501
|
:city => xml_to_str(node, './city/text()'),
|
414
502
|
:state => xml_to_str(node, './state/text()'),
|
@@ -427,7 +515,11 @@ class Landslider < Handsoap::Service
|
|
427
515
|
:work_phone => xml_to_str(node, './workPhone/text()'),
|
428
516
|
:home_phone => xml_to_str(node, './homePhone/text()'),
|
429
517
|
:email => xml_to_str(node, './email/text()'),
|
430
|
-
:
|
518
|
+
:title => xml_to_str(node, './homePhone/text()'),
|
519
|
+
:reports_to => xml_to_str(node, './reportsTo/text()'),
|
520
|
+
:owner_id => xml_to_int(node, './ownerId/text()'),
|
521
|
+
:contact_id => xml_to_int(node, './contactId/text()'),
|
522
|
+
:custom_fields => node.xpath('./customFields', ns).map { |child| parse_custom_field(child) }
|
431
523
|
}
|
432
524
|
end
|
433
525
|
|
@@ -461,18 +553,16 @@ class Landslider < Handsoap::Service
|
|
461
553
|
:notes => node.xpath('./*/notes', ns).map { |child| parse_note(child) }
|
462
554
|
}
|
463
555
|
end
|
464
|
-
|
556
|
+
|
465
557
|
# WsNote
|
466
558
|
def parse_note(node)
|
467
559
|
{
|
468
|
-
#:entity_id => xml_to_str(node, './entityId/text()'),
|
469
|
-
#:entity_type => xml_to_str(node, './entityType/text()'),
|
470
|
-
:archived_by => xml_to_int(node, './archivedBy/text()'),
|
471
560
|
:created_by => xml_to_int(node, './createdBy/text()'),
|
472
561
|
:created_on => xml_to_date(node, './createdOn/text()'),
|
473
562
|
:latest => xml_to_bool(node, './latest/text()'),
|
563
|
+
:note_html => xml_to_str(node, './note/text()'),
|
474
564
|
:note_id => xml_to_int(node, './noteId/text()'),
|
475
|
-
:
|
565
|
+
:updated_on => xml_to_date(node, './updatedOn/text()'),
|
476
566
|
}
|
477
567
|
end
|
478
568
|
|
@@ -485,16 +575,20 @@ class Landslider < Handsoap::Service
|
|
485
575
|
# WsLead
|
486
576
|
def parse_lead(node)
|
487
577
|
{
|
488
|
-
:
|
489
|
-
:
|
578
|
+
:account_id => xml_to_int(node, './accountId/text()'),
|
579
|
+
:converted => xml_to_bool(node, './converted/text()'),
|
580
|
+
:created_by => xml_to_int(node, './createdBy/text()'),
|
581
|
+
:created_on => xml_to_date(node, './createdOn/text()'),
|
582
|
+
:hot => xml_to_bool(node, './hot/text()'),
|
583
|
+
:lead_id => xml_to_int(node, './leadId/text()'),
|
490
584
|
:lead_rating => xml_to_str(node, './leadRating/rating/text()'),
|
585
|
+
:lead_source => xml_to_str(node, './leadSource/source/text()'),
|
491
586
|
:lead_status => xml_to_str(node, './leadStatus/status/text()'),
|
492
|
-
:
|
493
|
-
:primary_owner_id => xml_to_int(node, './primaryOwnerId/text()'),
|
587
|
+
:name => xml_to_str(node, './name/text()'),
|
494
588
|
:ok_to_call => xml_to_bool(node, './okToCall/text()'),
|
495
589
|
:ok_to_email => xml_to_bool(node, './okToEmail/text()'),
|
496
|
-
:
|
497
|
-
:
|
590
|
+
:primary_owner_id => xml_to_int(node, './primaryOwnerId/text()'),
|
591
|
+
:custom_fields => node.xpath('./customFields', ns).map { |child| parse_custom_field(child) }
|
498
592
|
|
499
593
|
}
|
500
594
|
end
|
@@ -502,19 +596,20 @@ class Landslider < Handsoap::Service
|
|
502
596
|
# WsOpportunity
|
503
597
|
def parse_opportunity(node)
|
504
598
|
{
|
505
|
-
#:entity_id => xml_to_str(node, './entityId/text()'),
|
506
|
-
#:entity_type => xml_to_str(node, './entityType/text()'),
|
507
599
|
:account_id => xml_to_int(node, './accountId/text()'),
|
508
600
|
:account_name => xml_to_str(node, './accountName/text()'),
|
509
|
-
:opportunity_id => xml_to_int(node, './opportunityId/text()'),
|
510
|
-
:name => xml_to_str(node, './name/text()'),
|
511
|
-
:deal_value => xml_to_str(node, './dealValue/text()'),
|
512
601
|
:confidence => xml_to_str(node, './confidence/text()'),
|
602
|
+
:current_phase_name => xml_to_str(node, './currentPhaseName/text()'),
|
603
|
+
:deal_value => xml_to_str(node, './dealValue/text()'),
|
604
|
+
:description => xml_to_str(node, './description/text()'),
|
605
|
+
:hot => xml_to_bool(node, './hot/text()'),
|
606
|
+
:name => xml_to_str(node, './name/text()'),
|
607
|
+
:opportunity_id => xml_to_int(node, './opportunityId/text()'),
|
513
608
|
:opportunity_status => xml_to_str(node, './opportunityStatus/status/text()'),
|
609
|
+
:primary_owner_id => xml_to_int(node, './primaryOwnerId/text()'),
|
514
610
|
:selling_process => xml_to_str(node, './sellingProcess/sellingProcess/text()'),
|
515
611
|
:selling_process_id => xml_to_int(node, './sellingProcess/sellingProcessId/text()'),
|
516
|
-
:
|
517
|
-
:current_phase_name => xml_to_str(node, './currentPhaseName/text()')
|
612
|
+
:start_date => xml_to_date(node, './startDate/text()')
|
518
613
|
}
|
519
614
|
end
|
520
615
|
|
data/test/landslider_test.rb
CHANGED
@@ -6,16 +6,15 @@ class LandsliderTest < Test::Unit::TestCase
|
|
6
6
|
JAYTEST_ACCOUNT_ID = 55647822
|
7
7
|
|
8
8
|
def setup
|
9
|
-
|
10
|
-
|
9
|
+
if $sid.nil?
|
10
|
+
# only get a session once
|
11
11
|
result = Landslider.login('LOGINTOKEN=' + LS_INSTANCE_NAME)
|
12
12
|
$sid = result[:session_id]
|
13
|
-
|
14
|
-
#puts "using #{$sid} to login"
|
13
|
+
end
|
15
14
|
end
|
16
15
|
|
17
16
|
def test_landslider_login
|
18
|
-
# other tests should use $sid for
|
17
|
+
# other tests should use $sid for authentication
|
19
18
|
result = Landslider.login('LOGINTOKEN=' + LS_INSTANCE_NAME)
|
20
19
|
|
21
20
|
assert_not_nil result
|
@@ -72,11 +71,17 @@ class LandsliderTest < Test::Unit::TestCase
|
|
72
71
|
|
73
72
|
validate_standard_api_result result
|
74
73
|
assert_equal Array, result[:contacts].class
|
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
|
77
77
|
|
78
|
+
def test_landslider_get_account_custom_fields
|
79
|
+
result = Landslider.get_account_custom_fields($sid)
|
80
|
+
assert_not_nil result[:custom_fields]
|
81
|
+
assert_not_nil result[:custom_fields].first[:custom_field_id]
|
82
|
+
end
|
83
|
+
|
78
84
|
def test_landslider_get_account_notes
|
79
|
-
# exists on jaytest
|
80
85
|
result = Landslider.get_account_notes($sid, JAYTEST_ACCOUNT_ID)
|
81
86
|
|
82
87
|
validate_standard_api_result result
|
@@ -86,7 +91,7 @@ class LandsliderTest < Test::Unit::TestCase
|
|
86
91
|
def test_landslider_get_account_opportunities
|
87
92
|
# exists on jaytest
|
88
93
|
result = Landslider.get_account_opportunities($sid, 51858821)
|
89
|
-
|
94
|
+
|
90
95
|
assert_equal false, result[:error]
|
91
96
|
assert_equal Array, result[:opportunities].class
|
92
97
|
|
@@ -98,8 +103,20 @@ class LandsliderTest < Test::Unit::TestCase
|
|
98
103
|
}, "opportunities require a name, account, deal value and selling process"
|
99
104
|
end
|
100
105
|
|
106
|
+
def test_landslider_get_contacts
|
107
|
+
result = Landslider.get_contacts($sid)
|
108
|
+
assert_not_nil result
|
109
|
+
assert_not_nil result[:contacts]
|
110
|
+
assert_not_nil result[:contacts].first[:custom_fields]
|
111
|
+
end
|
112
|
+
|
113
|
+
def test_landslider_get_contact_custom_fields
|
114
|
+
result = Landslider.get_contact_custom_fields($sid)
|
115
|
+
assert_not_nil result[:custom_fields]
|
116
|
+
assert_not_nil result[:custom_fields].first[:custom_field_id]
|
117
|
+
end
|
118
|
+
|
101
119
|
def test_landslider_get_contact_notes
|
102
|
-
# exists on jaytest
|
103
120
|
result = Landslider.get_contact_notes($sid, 62813411)
|
104
121
|
|
105
122
|
validate_standard_api_result result
|
@@ -117,14 +134,25 @@ class LandsliderTest < Test::Unit::TestCase
|
|
117
134
|
assert_not_nil result[:instance_url]
|
118
135
|
end
|
119
136
|
|
137
|
+
def test_landslider_get_opportunity_custom_fields
|
138
|
+
result = Landslider.get_opportunity_custom_fields($sid)
|
139
|
+
assert_not_nil result[:custom_fields]
|
140
|
+
assert_not_nil result[:custom_fields].first[:custom_field_id]
|
141
|
+
end
|
142
|
+
|
120
143
|
def test_landslider_get_leads
|
121
144
|
result = Landslider.get_leads($sid, 51857822)
|
122
|
-
|
145
|
+
|
123
146
|
validate_standard_api_result result
|
124
147
|
assert_not_nil result[:leads]
|
125
148
|
assert_equal Array, result[:leads].class
|
126
149
|
end
|
127
150
|
|
151
|
+
def test_landslider_get_lead_custom_fields
|
152
|
+
result = Landslider.get_lead_custom_fields($sid)
|
153
|
+
assert_not_nil result[:custom_fields]
|
154
|
+
assert_not_nil result[:custom_fields].first[:custom_field_id]
|
155
|
+
end
|
128
156
|
|
129
157
|
def test_landslider_get_lead_notes
|
130
158
|
# exists on jaytest
|
@@ -134,6 +162,10 @@ class LandsliderTest < Test::Unit::TestCase
|
|
134
162
|
validate_at_least_one_note_returned result
|
135
163
|
end
|
136
164
|
|
165
|
+
def test_landslider_get_opportunities
|
166
|
+
result = Landslider.get_opportunities($sid)
|
167
|
+
assert_not_nil result[:opportunities]
|
168
|
+
end
|
137
169
|
|
138
170
|
def test_landslider_get_opportunity_notes
|
139
171
|
# exists on jaytest
|
data/test/test_helper.rb
CHANGED
@@ -7,7 +7,7 @@ LS_API_PASSWORD = 'Applogin1'
|
|
7
7
|
LS_API_KEY = Digest::MD5.hexdigest(LS_API_PASSWORD + LS_INSTANCE_NAME)
|
8
8
|
LS_API_ENDPOINT = {
|
9
9
|
:uri => "https://#{LS_INSTANCE_NAME}.api.landslide.com/webservices/SoapService",
|
10
|
-
:version =>
|
10
|
+
:version => 1
|
11
11
|
}
|
12
12
|
|
13
13
|
require 'test/unit'
|