Class: Landslider

Inherits:
Handsoap::Service
  • Object
show all
Defined in:
lib/landslider.rb,
lib/landslider/entities/ws_note.rb,
lib/landslider/entities/ws_user.rb,
lib/landslider/entities/ws_task.rb,
lib/landslider/entities/ws_lead.rb,
lib/landslider/entities/ws_result.rb,
lib/landslider/entities/ws_search.rb,
lib/landslider/entities/ws_entity.rb,
lib/landslider/entities/ws_contact.rb,
lib/landslider/entities/ws_account.rb,
lib/landslider/entities/ws_my_list.rb,
lib/landslider/entities/ws_product.rb,
lib/landslider/entities/ws_address.rb,
lib/landslider/entities/ws_employee.rb,
lib/landslider/entities/ws_lead_note.rb,
lib/landslider/entities/ws_lead_search.rb,
lib/landslider/entities/ws_user_search.rb,
lib/landslider/entities/ws_task_search.rb,
lib/landslider/entities/ws_opportunity.rb,
lib/landslider/entities/ws_lead_contact.rb,
lib/landslider/entities/ws_payment_term.rb,
lib/landslider/entities/ws_contact_note.rb,
lib/landslider/entities/ws_account_note.rb,
lib/landslider/entities/ws_product_result.rb,
lib/landslider/entities/ws_account_search.rb,
lib/landslider/entities/ws_contact_search.rb,
lib/landslider/entities/ws_primary_entity.rb,
lib/landslider/entities/ws_pick_list_item.rb,
lib/landslider/entities/ws_product_family.rb,
lib/landslider/entities/ws_search_operator.rb,
lib/landslider/entities/ws_selling_process.rb,
lib/landslider/entities/ws_lead_note_search.rb,
lib/landslider/entities/ws_search_criterion.rb,
lib/landslider/entities/ws_opportunity_note.rb,
lib/landslider/entities/ws_opportunity_search.rb,
lib/landslider/entities/ws_opportunity_status.rb,
lib/landslider/entities/ws_account_note_search.rb,
lib/landslider/entities/ws_contact_note_search.rb,
lib/landslider/entities/ws_record_upsert_result.rb,
lib/landslider/entities/ws_account_contact_search.rb,
lib/landslider/entities/ws_opportunity_note_search.rb

Overview

landslider gem main class

Defined Under Namespace

Classes: WsAccount, WsAccountContactSearch, WsAccountNote, WsAccountNoteSearch, WsAccountSearch, WsAddress, WsContact, WsContactNote, WsContactNoteSearch, WsContactSearch, WsEmployee, WsEntity, WsLead, WsLeadContact, WsLeadNote, WsLeadNoteSearch, WsLeadSearch, WsMyList, WsNote, WsOpportunity, WsOpportunityNote, WsOpportunityNoteSearch, WsOpportunitySearch, WsOpportunityStatus, WsPaymentTerm, WsPickListItem, WsPrimaryEntity, WsProduct, WsProductFamily, WsProductResult, WsRecordUpsertResult, WsResult, WsSearch, WsSearchCriterion, WsSearchOperator, WsSellingProcess, WsTask, WsTaskSearch, WsUser, WsUserSearch

Constant Summary

LS_API_NAMESPACE =
'http://www.landslide.com/webservices/SoapService'
DEFAULT_FIRST_RESULT_POSITION =
1
DEFAULT_TOTAL_RESULTS_REQUESTED =
25

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#session_idObject

Returns the value of attribute session_id



19
20
21
# File 'lib/landslider.rb', line 19

def session_id
  @session_id
end

Instance Method Details

#add_task(session_id, task) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
# File 'lib/landslider.rb', line 55

def add_task(session_id, task)
	self.session_id = session_id
	response = invoke('urn:addTask', :soap_action => :none) do |message|
		message.add('task') { |req|
			task.soapify_for(req)
		}
	end
	node = response.document.xpath('//ns:addTaskResponse/Status', ns)
	parse_add_task_result(node)

end

#get_account_by_id(session_id, account_id) ⇒ Hash

Parameters:

  • session_id (String)
  • account_id (Integer)

Returns:

  • (Hash)


85
86
87
88
89
90
91
92
93
94
# File 'lib/landslider.rb', line 85

def (session_id, )
	self.session_id = session_id

	response = invoke('urn:getAccountById', :soap_action => :none) do |message|
		message.add 'accountId', 
	end

	node = response.document.xpath('//ns:getAccountByIdResponse', ns)
	(node)
end

#get_account_contacts(session_id, account_id, is_primary = false) ⇒ Hash

Parameters:

  • session_id (String)
  • account_id (Integer)
  • is_primary (Boolean) (defaults to: false)

Returns:

  • (Hash)


100
101
102
103
104
105
106
107
108
109
# File 'lib/landslider.rb', line 100

def (session_id, , is_primary=false)
	self.session_id = session_id
	response = invoke('urn:getAccountContacts', :soap_action => :none) do |message|
		message.add 'accountId', 
		message.add 'isPrimary', is_primary
	end

	node = response.document.xpath('//ns:getAccountContactsResponse', ns)
	(node)
end

#get_account_custom_fields(session_id) ⇒ Hash

Parameters:

  • session_id (String)

Returns:

  • (Hash)


113
114
115
116
117
# File 'lib/landslider.rb', line 113

def (session_id)
	response = invoke('urn:getAccountCustomFields')
	node = response.document.xpath('//ns:getAccountCustomFieldsResponse', ns)
	parse_get_entity_custom_fields_result(node)
end

#get_account_notes(session_id, search) ⇒ Hash

Parameters:

Returns:

  • (Hash)


122
123
124
125
126
127
128
129
130
# File 'lib/landslider.rb', line 122

def (session_id, search)
	self.session_id = session_id

	response = invoke('urn:getAccountNotes', :soap_action => :none) do |message|
		search.soapify_for(message)
	end
	node = response.document.xpath('//ns:getAccountNotesResponse', ns)
	(node)
end

#get_account_opportunities(session_id, account_id) ⇒ Hash

Parameters:

  • session_id (String)

Returns:

  • (Hash)


134
135
136
137
138
139
140
141
142
# File 'lib/landslider.rb', line 134

def (session_id, )
	self.session_id = session_id
	response = invoke('urn:getAccountOpportunities', :soap_action => :none) do |message|
		message.add 'accountId', 
	end

	node = response.document.xpath('//ns:getAccountOpportunitiesResponse', ns)
	(node)
end

#get_account_types(session_id) ⇒ Hash

Parameters:

  • session_id (String)

Returns:

  • (Hash)


146
147
148
149
150
151
152
# File 'lib/landslider.rb', line 146

def (session_id)
	self.session_id = session_id
	response = invoke('urn:getAccountTypes')
	
	node = response.document.xpath('//ns:getAccountTypesResponse', ns)
	(node)
end

#get_accounts(session_id, search = WsSearch.new) ⇒ Hash

Parameters:

Returns:

  • (Hash)


70
71
72
73
74
75
76
77
78
79
80
# File 'lib/landslider.rb', line 70

def get_accounts(session_id, search=WsSearch.new)
	self.session_id = session_id
	response = invoke('urn:getAccounts', :soap_action => :none) do |message|
		message.add('accountsRequest') { |req|
			search.soapify_for(req)
		}
	end

	node = response.document.xpath('//ns:getAccountsResponse', ns)
	parse_get_accounts_result(node)
end

#get_api_version(session_id) ⇒ Hash

Parameters:

  • session_id (String)

Returns:

  • (Hash)


156
157
158
159
160
161
162
163
# File 'lib/landslider.rb', line 156

def get_api_version(session_id)
	self.session_id = session_id

	response = invoke('urn:getApiVersion', :soap_action => :none)

	node = response.document.xpath('//ns:getApiVersionResponse', ns)
	parse_api_version_result(node)
end

#get_contact_by_id(session_id, contact_id) ⇒ Hash

Parameters:

  • session_id (String)
  • contact_id (Integer)

Returns:

  • (Hash)


168
169
170
171
172
173
174
175
176
177
# File 'lib/landslider.rb', line 168

def get_contact_by_id(session_id, contact_id)
	self.session_id = session_id

	response = invoke('urn:getContactById', :soap_action => :none) do |message|
		message.add 'contactId', contact_id
	end

	node = response.document.xpath('//ns:getContactByIdResponse', ns)
	parse_get_contact_by_id_result(node)
end

#get_contact_custom_fields(session_id) ⇒ Hash

Parameters:

  • session_id (String)

Returns:

  • (Hash)


197
198
199
200
201
202
203
# File 'lib/landslider.rb', line 197

def get_contact_custom_fields(session_id)
	self.session_id = session_id

	response = invoke('urn:getContactCustomFields')
	node = response.document.xpath('//ns:getContactCustomFieldsResponse', ns)
	parse_get_entity_custom_fields_result(node)
end

#get_contact_notes(session_id, search) ⇒ Hash

Parameters:

Returns:

  • (Hash)


208
209
210
211
212
213
214
215
216
217
# File 'lib/landslider.rb', line 208

def get_contact_notes(session_id, search)
	self.session_id = session_id

	response = invoke('urn:getContactNotes', :soap_action => :none) do |message|
		search.soapify_for(message)
	end
	node = response.document.xpath('//ns:getContactNotesResponse', ns)
	parse_get_contact_notes_result(node)

end

#get_contacts(session_id, search = WsSearch.new) ⇒ Hash

Parameters:

Returns:

  • (Hash)


182
183
184
185
186
187
188
189
190
191
192
193
# File 'lib/landslider.rb', line 182

def get_contacts(session_id, search=WsSearch.new)
	self.session_id = session_id

	# public WsContactResultSet getContacts(WsContactSearch request)
	response = invoke('urn:getContacts', :soap_action => :none) do |message|
		message.add('contactsRequest') { |req|
			search.soapify_for(req)
		}
	end
	node = response.document.xpath('//ns:getContactsResponse', ns)
	parse_get_contacts_result(node)
end

#get_instance_information(session_id, user_id) ⇒ Hash

Parameters:

  • user_id (String)
  • session_id (String)

Returns:

  • (Hash)


222
223
224
225
226
227
228
229
230
# File 'lib/landslider.rb', line 222

def get_instance_information(session_id, user_id)
	self.session_id = session_id

	response = invoke('urn:getInstanceInformation', :soap_action => :none) do |message|
		message.add 'userId', user_id
	end
	node = response.document.xpath('//ns:getInstanceInformationResponse', ns)
	parse_get_instance_information_result(node)
end

#get_lead_custom_fields(session_id) ⇒ Hash

Parameters:

  • session_id (String)

Returns:

  • (Hash)


250
251
252
253
254
# File 'lib/landslider.rb', line 250

def get_lead_custom_fields(session_id)
	response = invoke('urn:getLeadCustomFields')
	node = response.document.xpath('//ns:getLeadCustomFieldsResponse', ns)
	parse_get_entity_custom_fields_result(node)
end

#get_lead_notes(session_id, search) ⇒ Hash

Parameters:

Returns:

  • (Hash)


259
260
261
262
263
264
265
266
267
# File 'lib/landslider.rb', line 259

def get_lead_notes(session_id, search)
	self.session_id = session_id

	response = invoke('urn:getLeadNotes', :soap_action => :none) do |message|
		search.soapify_for(message)
	end
	node = response.document.xpath('//ns:getLeadNotesResponse', ns)
	parse_get_lead_notes_result(node)
end

#get_leads(session_id, search = WsLeadSearch.new) ⇒ Hash

Parameters:

  • session_id (String)
  • search (WsLeadSearch) (defaults to: WsLeadSearch.new)

Returns:

  • (Hash)


235
236
237
238
239
240
241
242
243
244
245
246
# File 'lib/landslider.rb', line 235

def get_leads(session_id, search=WsLeadSearch.new)
	self.session_id = session_id

	response = invoke('urn:getLeads', :soap_action => :none) do |message|
		message.add('leadRequest') { |req|
			search.soapify_for(req)
		}
	end

	node = response.document.xpath('//ns:getLeadsResponse', ns)
	parse_get_leads_result(node)
end

#get_opportunities(session_id, search = WsSearch.new) ⇒ Hash

Parameters:

Returns:

  • (Hash)


272
273
274
275
276
277
278
279
280
281
282
# File 'lib/landslider.rb', line 272

def get_opportunities(session_id, search=WsSearch.new)
	self.session_id = session_id

	response = invoke('urn:getOpportunities', :soap_action => :none) do |message|
		message.add('opportunityRequest') { |req|
			search.soapify_for(req)
		}
	end
	node = response.document.xpath('//ns:getOpportunitiesResponse', ns)
	parse_get_opportunities_result(node)
end

#get_opportunity_custom_fields(session_id) ⇒ Hash

Parameters:

  • session_id (String)

Returns:

  • (Hash)


286
287
288
289
290
291
292
# File 'lib/landslider.rb', line 286

def get_opportunity_custom_fields(session_id)
	self.session_id = session_id

	response = invoke('urn:getOpportunityCustomFields')
	node = response.document.xpath('//ns:getOpportunityCustomFieldsResponse', ns)
	parse_get_entity_custom_fields_result(node)
end

#get_opportunity_notes(session_id, search) ⇒ Hash

Parameters:

Returns:

  • (Hash)


297
298
299
300
301
302
303
304
305
# File 'lib/landslider.rb', line 297

def get_opportunity_notes(session_id, search)
	self.session_id = session_id

	response = invoke('urn:getOpportunityNotes', :soap_action => :none) do |message|
		search.soapify_for(message)
	end
	node = response.document.xpath('//ns:getOpportunityNotesResponse', ns)
	parse_get_opportunity_notes_result(node)
end

#get_task_types(session_id) ⇒ Hash

Parameters:

  • session_id (String)

Returns:

  • (Hash)


309
310
311
312
313
314
# File 'lib/landslider.rb', line 309

def get_task_types(session_id)
	self.session_id = session_id
	response = invoke('urn:getTaskTypes', :soap_action => :none)
	node = response.document.xpath('//ns:getTaskTypesResponse', ns)
	parse_get_task_types_result(node)
end

#get_tasks(session_id, search) ⇒ Hash

Parameters:

Returns:

  • (Hash)


319
320
321
322
323
324
325
326
327
328
329
# File 'lib/landslider.rb', line 319

def get_tasks(session_id, search)
	self.session_id = session_id

	response = invoke('urn:getTasks', :soap_action => :none) do |message|
		message.add('taskSearch') { |req|
			search.soapify_for(req)
		}
	end
	node = response.document.xpath('//ns:getTasksResponse', ns)
	parse_get_tasks_result(node)
end

#get_user_information(session_id, user_id) ⇒ Hash

Parameters:

  • session_id (String)
  • user_id (String)

    usually in the form of user@example.com

Returns:

  • (Hash)


334
335
336
337
338
339
340
341
342
# File 'lib/landslider.rb', line 334

def get_user_information(session_id, user_id)

	self.session_id = session_id
	response = invoke('urn:getUserInformation', :soap_action => :none) do |message|
		message.add 'userId', user_id
	end
	node = response.document.xpath('//ns:getUserInformationResponse', ns)
	parse_get_user_information_by_id_result(node)
end

#get_user_information_by_id(session_id, user_id) ⇒ Hash

Parameters:

  • session_id (String)
  • user_id (Integer)

Returns:

  • (Hash)


347
348
349
350
351
352
353
354
355
# File 'lib/landslider.rb', line 347

def get_user_information_by_id(session_id, user_id)
	self.session_id = session_id

	response = invoke('urn:getUserInformationById', :soap_action => :none) do |message|
		message.add 'userId', user_id
	end
	node = response.document.xpath('//ns:getUserInformationByIdResponse', ns)
	parse_get_user_information_by_id_result(node)
end

#login(session_id) ⇒ Hash

Parameters:

  • session_id (String)

Returns:

  • (Hash)


42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/landslider.rb', line 42

def (session_id)
	self.session_id = session_id
	response = invoke('urn:login', :soap_action => :none) do |message|
		message.add('wsUser') { |u|
			u.add 'username', ::LS_API_USERNAME
			u.add 'password', ::LS_API_KEY
		}
	end

	node = response.document.xpath('//ns:loginResponse/loginResponse', ns)
	(node)
end

#on_after_create_http_request(http_request) ⇒ Object

Parameters:

  • http_request (Handsoap::Http::Request)


31
32
33
# File 'lib/landslider.rb', line 31

def on_after_create_http_request(http_request)
	http_request.headers.merge!({'user-agent' => ['landslider-ruby-gem-version-0.4.6']})
end

#on_create_document(doc) ⇒ Object

Parameters:

  • doc (Handsoap::XmlMason::Document)


22
23
24
25
26
27
28
# File 'lib/landslider.rb', line 22

def on_create_document(doc)
	doc.alias 'urn', LS_API_NAMESPACE
	header = doc.find('Header')
	header.add('urn:SessionHeader') { |sh|
		sh.add('urn:sessionId', self.session_id)
	}
end

#on_http_error(response) ⇒ Object

Parameters:

  • response (Object)


36
37
38
# File 'lib/landslider.rb', line 36

def on_http_error(response)
	puts response.inspect
end

#run_mylist_by_id(session_id, mylist_id) ⇒ Hash

Parameters:

  • session_id (String)
  • mylist_id (Integer)

Returns:

  • (Hash)


360
361
362
363
364
365
366
367
368
# File 'lib/landslider.rb', line 360

def run_mylist_by_id(session_id, mylist_id)
	self.session_id = session_id

	response = invoke('urn:runMyListbyId', :soap_action => :none) do |message|
		message.add 'myListId', mylist_id
	end
	node = response.document.xpath('//ns:runMyListbyIdResponse', ns)
	parse_run_mylist_by_id_result(node)
end