landslider 0.2.0 → 0.2.1

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: 0
4
+ :patch: 1
5
5
  :build:
data/lib/landslider.rb CHANGED
@@ -67,31 +67,17 @@ class Landslider < Handsoap::Service
67
67
  node = response.document.xpath('//ns:getAccountsResponse', ns)
68
68
  parse_get_accounts_result(node)
69
69
  end
70
-
71
- def get_account_opportunities(session_id, account_id)
72
- self.session_id = session_id
73
- response = invoke("getAccountOpportunities", :soap_action => :none) do |message|
74
- message.add 'accountId', account_id
75
- end
76
- puts response.document.inspect
77
-
78
- node = response.document.xpath('//ns:getAccountOpportunitiesResponse', ns)
79
- parse_get_account_opportunities_result(node)
80
- end
81
-
82
70
 
83
-
84
71
  def get_account_contacts(session_id, account_id)
85
72
  self.session_id = session_id
86
73
  response = invoke("getAccountContacts", :soap_action => :none) do |message|
87
74
  message.add 'accountId', account_id
88
75
  end
89
- puts response.document.inspect
90
76
 
91
77
  node = response.document.xpath('//ns:getAccountContactsResponse', ns)
92
78
  parse_get_account_contacts_result(node)
93
79
  end
94
-
80
+
95
81
  def get_account_notes(session_id, account_id)
96
82
  self.session_id = session_id
97
83
 
@@ -101,20 +87,22 @@ class Landslider < Handsoap::Service
101
87
  ans.add 'accountId', account_id
102
88
  ans.add 'firstResultPosition', 1
103
89
  ans.add 'totalResultsRequested', 10
104
-
105
- # search criteria doesn't seem to work
106
- # ans.add('searchCriteria') { |sc|
107
- # sc.add 'fieldId', 'note'
108
- # sc.add 'operator', 'Contains'
109
- # sc.add 'queryValue', 'BLAH'
110
- # }
111
90
  }
112
91
  end
113
- puts response.document.inspect
114
-
92
+ node = response.document.xpath('//ns:getAccountNotesResponse', ns)
93
+ parse_get_account_notes_result(node)
115
94
  end
116
95
 
117
-
96
+ def get_account_opportunities(session_id, account_id)
97
+ self.session_id = session_id
98
+ response = invoke("getAccountOpportunities", :soap_action => :none) do |message|
99
+ message.add 'accountId', account_id
100
+ end
101
+
102
+ node = response.document.xpath('//ns:getAccountOpportunitiesResponse', ns)
103
+ parse_get_account_opportunities_result(node)
104
+ end
105
+
118
106
  def get_contact_notes(session_id, contact_id)
119
107
  self.session_id = session_id
120
108
 
@@ -129,7 +117,6 @@ class Landslider < Handsoap::Service
129
117
 
130
118
  end
131
119
 
132
-
133
120
  def get_opportunity_notes(session_id, opportunity_id)
134
121
  self.session_id = session_id
135
122
 
@@ -160,7 +147,6 @@ class Landslider < Handsoap::Service
160
147
 
161
148
  end
162
149
 
163
-
164
150
  private
165
151
 
166
152
  def ns
@@ -199,6 +185,16 @@ class Landslider < Handsoap::Service
199
185
  }
200
186
  end
201
187
 
188
+ def parse_get_account_notes_result(node)
189
+ {
190
+ :error => xml_to_bool(node, './*/error/text()'),
191
+ :error_code => xml_to_int(node, './*/errorCode/text()'),
192
+ :result_msg => xml_to_str(node, './*/resultMsg/text()'),
193
+ :status_code => xml_to_int(node, './*/statusCode/text()'),
194
+ :results_returned => xml_to_int(node, './*/resultsReturned/text()')
195
+ }
196
+ end
197
+
202
198
  def parse_get_account_opportunities_result(node)
203
199
  {
204
200
  :opportunities => node.xpath('./*/opportunityList', ns).map { |child| parse_opportunity(child) },
@@ -21,7 +21,7 @@ class LandsliderTest < Test::Unit::TestCase
21
21
  assert_operator result[:revision_version], :>=, 0
22
22
  end
23
23
 
24
- def test_get_accounts
24
+ def test_landslider_get_accounts
25
25
  result = Landslider.login('LOGINTOKEN=' + LS_INSTANCE_NAME)
26
26
  result = Landslider.get_accounts(result[:session_id])
27
27
  assert_equal false, result[:error]
@@ -32,9 +32,54 @@ class LandsliderTest < Test::Unit::TestCase
32
32
  assert_not_nil result[:result_msg]
33
33
  end
34
34
 
35
+ def test_landslider_get_account_contacts
36
+ result = Landslider.login('LOGINTOKEN=' + LS_INSTANCE_NAME)
37
+
38
+ # exists on jaytest
39
+ result = Landslider.get_account_contacts(result[:session_id], 51857822)
40
+
41
+ assert_equal false, result[:error]
42
+ assert_operator result[:results_returned], :>=, 1
43
+ assert result[:contacts].all? { |con| !con[:last_name].nil? }, "last name required"
44
+ end
45
+
46
+ def test_landslider_get_account_notes
47
+ result = Landslider.login('LOGINTOKEN=' + LS_INSTANCE_NAME)
48
+
49
+ # exists on jaytest
50
+ result = Landslider.get_account_notes(result[:session_id], 55647822)
51
+
52
+ validate_standard_api_result result
53
+ assert_operator result[:results_returned], :>=, 1
54
+
55
+ end
56
+
57
+
58
+ def test_landslider_get_account_opportunities
59
+ result = Landslider.login('LOGINTOKEN=' + LS_INSTANCE_NAME)
60
+
61
+ # exists on jaytest
62
+ result = Landslider.get_account_opportunities(result[:session_id], 51858821)
63
+
64
+ assert_equal false, result[:error]
65
+ assert result[:opportunities].all? { |opp|
66
+ !opp[:account_name].nil? &&
67
+ !opp[:name].nil? &&
68
+ !opp[:deal_value].nil? &&
69
+ !opp[:selling_process].nil?
70
+ }, "opportunities require a name, account, deal value and selling process"
71
+
72
+ end
73
+
35
74
 
36
75
  private
37
76
 
77
+ def validate_standard_api_result(result)
78
+ assert_equal Hash, result.class, "api method should return a hash"
79
+ assert_operator result[:results_returned], :>=, 0
80
+ assert_equal false, result[:error], "error should be false"
81
+ end
82
+
38
83
  def login(session_id)
39
84
  Landslider.login(session_id)
40
85
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: landslider
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.0
5
+ version: 0.2.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jay Prall