markety 1.4.3 → 2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/.gitignore +3 -0
- data/README.md +66 -15
- data/Rakefile +1 -1
- data/example_xml/get_lead_failure.xml +42 -0
- data/example_xml/get_lead_success.xml +63 -0
- data/example_xml/get_lead_success_two_leads.xml +88 -0
- data/example_xml/list_op_add_to_list_success.xml +42 -0
- data/example_xml/list_op_is_member_of_list_failure.xml +50 -0
- data/example_xml/list_op_is_member_of_list_success.xml +51 -0
- data/example_xml/list_op_remove_from_list_failure.xml +50 -0
- data/example_xml/list_op_remove_from_list_success.xml +42 -0
- data/example_xml/sync_lead_failure.xml +60 -0
- data/example_xml/sync_lead_success.xml +78 -0
- data/lib/markety.rb +26 -1
- data/lib/markety/authentication_header.rb +3 -3
- data/lib/markety/client.rb +35 -141
- data/lib/markety/command.rb +11 -0
- data/lib/markety/command/get_lead.rb +27 -0
- data/lib/markety/command/list_operation.rb +68 -0
- data/lib/markety/command/sync_lead.rb +55 -0
- data/lib/markety/enums.rb +18 -16
- data/lib/markety/lead.rb +69 -0
- data/lib/markety/lead_key.rb +5 -4
- data/lib/markety/response.rb +15 -0
- data/lib/markety/response/generic_response.rb +45 -0
- data/lib/markety/response/get_lead_response.rb +35 -0
- data/lib/markety/response/list_operation_response.rb +30 -0
- data/lib/markety/response/response_factory.rb +27 -0
- data/lib/markety/response/sync_lead_response.rb +32 -0
- data/lib/markety/version.rb +1 -3
- data/spec/markety/lead_key_spec.rb +10 -11
- data/spec/markety/{lead_record_spec.rb → lead_spec.rb} +13 -30
- data/spec/markety/response/get_lead_response_spec.rb +170 -0
- data/spec/markety/response/list_operation_response_spec.rb +76 -0
- data/spec/markety/response/sync_lead_response_spec.rb +107 -0
- data/spec/spec_helper.rb +4 -0
- data/spec/support/savon_helper.rb +14 -0
- metadata +61 -33
- data/lib/markety/lead_record.rb +0 -73
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'markety/lead'
|
2
|
+
require 'markety/response/generic_response'
|
3
|
+
|
4
|
+
module Markety
|
5
|
+
module Response
|
6
|
+
# Response class for SyncLead commands
|
7
|
+
class SyncLeadResponse < GenericResponse
|
8
|
+
|
9
|
+
# +:created+ or +:updated+ (or nil if unsuccessful)
|
10
|
+
attr_reader :update_type
|
11
|
+
# the updated or created Lead (or nil if unsuccessful)
|
12
|
+
attr_reader :updated_lead
|
13
|
+
# the ID of the created or updated Lead (or nil if unsuccessful)
|
14
|
+
attr_reader :lead_id
|
15
|
+
|
16
|
+
def initialize(response)
|
17
|
+
super(:sync_response,response)
|
18
|
+
h = self.to_hash
|
19
|
+
|
20
|
+
if self.success?
|
21
|
+
sync_status = h[:success_sync_lead][:result][:sync_status]
|
22
|
+
@lead_id = sync_status[:lead_id]
|
23
|
+
@update_type = sync_status[:status].downcase.to_sym
|
24
|
+
@updated_lead = ::Markety::Lead.from_hash(h[:success_sync_lead][:result][:lead_record])
|
25
|
+
else
|
26
|
+
# overwrite super's crap error message with useful one
|
27
|
+
@error_message = h[:fault][:detail][:service_exception][:message]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/markety/version.rb
CHANGED
@@ -4,29 +4,28 @@ module Markety
|
|
4
4
|
describe LeadKeyType do
|
5
5
|
it "should define the correct types" do
|
6
6
|
LeadKeyType::IDNUM.should == 'IDNUM'
|
7
|
-
LeadKeyType::COOKIE.should == 'COOKIE'
|
8
7
|
LeadKeyType::EMAIL.should == 'EMAIL'
|
9
|
-
LeadKeyType::
|
10
|
-
LeadKeyType::
|
11
|
-
LeadKeyType::
|
12
|
-
LeadKeyType::
|
13
|
-
LeadKeyType::
|
14
|
-
LeadKeyType::
|
8
|
+
#LeadKeyType::COOKIE.should == 'COOKIE'
|
9
|
+
#LeadKeyType::LEADOWNEREMAIL.should == 'LEADOWNEREMAIL'
|
10
|
+
#LeadKeyType::SFDCACCOUNTID.should == 'SFDCACCOUNTID'
|
11
|
+
#LeadKeyType::SFDCCONTACTID.should == 'SFDCCONTACTID'
|
12
|
+
#LeadKeyType::SFDCLEADID.should == 'SFDCLEADID'
|
13
|
+
#LeadKeyType::SFDCLEADOWNERID.should == 'SFDCLEADOWNERID'
|
14
|
+
#LeadKeyType::SFDCOPPTYID.should == 'SFDCOPPTYID'
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
18
|
describe LeadKey do
|
19
|
+
KEY_VALUE = 'a value'
|
20
|
+
KEY_TYPE = LeadKeyType::IDNUM
|
21
|
+
|
19
22
|
it "should store type and value on construction" do
|
20
|
-
KEY_VALUE = 'a value'
|
21
|
-
KEY_TYPE = LeadKeyType::IDNUM
|
22
23
|
lead_key = LeadKey.new(KEY_TYPE, KEY_VALUE)
|
23
24
|
lead_key.key_type.should == KEY_TYPE
|
24
25
|
lead_key.key_value.should == KEY_VALUE
|
25
26
|
end
|
26
27
|
|
27
28
|
it "should to_hash correctly" do
|
28
|
-
KEY_VALUE = 'a value'
|
29
|
-
KEY_TYPE = LeadKeyType::IDNUM
|
30
29
|
lead_key = LeadKey.new(KEY_TYPE, KEY_VALUE)
|
31
30
|
|
32
31
|
lead_key.to_hash.should == {
|
@@ -6,22 +6,22 @@ module Markety
|
|
6
6
|
|
7
7
|
|
8
8
|
|
9
|
-
describe
|
9
|
+
describe Lead do
|
10
10
|
it "should store the idnum" do
|
11
|
-
lead_record =
|
11
|
+
lead_record = Lead.new(email:EMAIL, idnum:IDNUM)
|
12
12
|
lead_record.idnum.should == IDNUM
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should store the email" do
|
16
|
-
|
16
|
+
Lead.new(email:EMAIL, idnum:IDNUM).email.should == EMAIL
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should implement == sensibly" do
|
20
|
-
lead_record1 =
|
20
|
+
lead_record1 = Lead.new(email:EMAIL, idnum:IDNUM)
|
21
21
|
lead_record1.set_attribute('favourite color', 'red')
|
22
22
|
lead_record1.set_attribute('age', '100')
|
23
23
|
|
24
|
-
lead_record2 =
|
24
|
+
lead_record2 = Lead.new(email:EMAIL, idnum:IDNUM)
|
25
25
|
lead_record2.set_attribute('favourite color', 'red')
|
26
26
|
lead_record2.set_attribute('age', '100')
|
27
27
|
|
@@ -29,35 +29,18 @@ module Markety
|
|
29
29
|
end
|
30
30
|
|
31
31
|
it "should store when attributes are set" do
|
32
|
-
lead_record =
|
32
|
+
lead_record = Lead.new(email:EMAIL, idnum:IDNUM)
|
33
33
|
lead_record.set_attribute('favourite color', 'red')
|
34
34
|
lead_record.get_attribute('favourite color').should == 'red'
|
35
35
|
end
|
36
36
|
|
37
37
|
it "should store when attributes are updated" do
|
38
|
-
lead_record =
|
38
|
+
lead_record = Lead.new(email:EMAIL, idnum:IDNUM)
|
39
39
|
lead_record.set_attribute('favourite color', 'red')
|
40
40
|
lead_record.set_attribute('favourite color', 'green')
|
41
41
|
lead_record.get_attribute('favourite color').should == 'green'
|
42
42
|
end
|
43
43
|
|
44
|
-
it "should yield all attributes through each_attribute_pair" do
|
45
|
-
lead_record = LeadRecord.new(EMAIL, IDNUM)
|
46
|
-
lead_record.set_attribute('favourite color', 'red')
|
47
|
-
lead_record.set_attribute('favourite color', 'green')
|
48
|
-
lead_record.set_attribute('age', '99')
|
49
|
-
|
50
|
-
pairs = []
|
51
|
-
lead_record.each_attribute_pair do |attribute_name, attribute_value|
|
52
|
-
pairs << [attribute_name, attribute_value]
|
53
|
-
end
|
54
|
-
|
55
|
-
pairs.size.should == 3
|
56
|
-
pairs.should include(['favourite color', 'green'])
|
57
|
-
pairs.should include(['age', '99'])
|
58
|
-
pairs.should include(['Email', EMAIL])
|
59
|
-
end
|
60
|
-
|
61
44
|
it 'should be instantiable from savon hash with no attributes' do
|
62
45
|
savon_hash = {
|
63
46
|
:id => IDNUM,
|
@@ -67,8 +50,8 @@ module Markety
|
|
67
50
|
:lead_attribute_list => nil
|
68
51
|
}
|
69
52
|
|
70
|
-
actual =
|
71
|
-
expected =
|
53
|
+
actual = Lead.from_hash(savon_hash)
|
54
|
+
expected = Lead.new(email:EMAIL, idnum:IDNUM)
|
72
55
|
|
73
56
|
actual.should == expected
|
74
57
|
end
|
@@ -84,9 +67,9 @@ module Markety
|
|
84
67
|
{:attribute => { :attr_name => 'FirstName', :attr_value => 'Yaya', :attr_type => 'string'}}
|
85
68
|
}
|
86
69
|
|
87
|
-
actual =
|
70
|
+
actual = Lead.from_hash(savon_hash)
|
88
71
|
|
89
|
-
expected =
|
72
|
+
expected = Lead.new(email:EMAIL, idnum:IDNUM)
|
90
73
|
expected.set_attribute('FirstName', 'Yaya')
|
91
74
|
|
92
75
|
actual.should == expected
|
@@ -107,9 +90,9 @@ module Markety
|
|
107
90
|
:id => IDNUM
|
108
91
|
}
|
109
92
|
|
110
|
-
actual =
|
93
|
+
actual = Lead.from_hash(savon_hash)
|
111
94
|
|
112
|
-
expected =
|
95
|
+
expected = Lead.new(email:EMAIL, idnum:IDNUM)
|
113
96
|
expected.set_attribute('Company', 'Yaya')
|
114
97
|
expected.set_attribute('FirstName', 'James')
|
115
98
|
expected.set_attribute('LastName', 'O\'Brien')
|
@@ -0,0 +1,170 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Markety
|
4
|
+
module Response
|
5
|
+
describe GetLeadResponse do
|
6
|
+
|
7
|
+
let(:success_xml) { <<END
|
8
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
9
|
+
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns1="http://www.marketo.com/mktows/">
|
10
|
+
<SOAP-ENV:Body>
|
11
|
+
<ns1:successGetLead>
|
12
|
+
<result>
|
13
|
+
<count>1</count>
|
14
|
+
<leadRecordList>
|
15
|
+
<leadRecord>
|
16
|
+
<Id>1001081</Id>
|
17
|
+
<Email>foo@example.com</Email>
|
18
|
+
<ForeignSysPersonId xsi:nil="true"/>
|
19
|
+
<ForeignSysType xsi:nil="true"/>
|
20
|
+
<leadAttributeList>
|
21
|
+
<attribute>
|
22
|
+
<attrName>FirstName</attrName>
|
23
|
+
<attrType>string</attrType>
|
24
|
+
<attrValue>Burt</attrValue>
|
25
|
+
</attribute>
|
26
|
+
<attribute>
|
27
|
+
<attrName>LastName</attrName>
|
28
|
+
<attrType>string</attrType>
|
29
|
+
<attrValue>Reynolds</attrValue>
|
30
|
+
</attribute>
|
31
|
+
</leadAttributeList>
|
32
|
+
</leadRecord>
|
33
|
+
</leadRecordList>
|
34
|
+
</result>
|
35
|
+
</ns1:successGetLead>
|
36
|
+
</SOAP-ENV:Body>
|
37
|
+
</SOAP-ENV:Envelope>
|
38
|
+
END
|
39
|
+
}
|
40
|
+
|
41
|
+
let(:success_xml_two_leads) { <<END
|
42
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
43
|
+
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns1="http://www.marketo.com/mktows/">
|
44
|
+
<SOAP-ENV:Body>
|
45
|
+
<ns1:successGetLead>
|
46
|
+
<result>
|
47
|
+
<count>2</count>
|
48
|
+
<leadRecordList>
|
49
|
+
<leadRecord>
|
50
|
+
<Id>1001084</Id>
|
51
|
+
<Email>foo@example.com</Email>
|
52
|
+
<ForeignSysPersonId xsi:nil="true"/>
|
53
|
+
<ForeignSysType xsi:nil="true"/>
|
54
|
+
<leadAttributeList>
|
55
|
+
<attribute>
|
56
|
+
<attrName>Company</attrName>
|
57
|
+
<attrType>string</attrType>
|
58
|
+
<attrValue>The Price is Right</attrValue>
|
59
|
+
</attribute>
|
60
|
+
<attribute>
|
61
|
+
<attrName>FirstName</attrName>
|
62
|
+
<attrType>string</attrType>
|
63
|
+
<attrValue>Bob</attrValue>
|
64
|
+
</attribute>
|
65
|
+
<attribute>
|
66
|
+
<attrName>LastName</attrName>
|
67
|
+
<attrType>string</attrType>
|
68
|
+
<attrValue>Barker</attrValue>
|
69
|
+
</attribute>
|
70
|
+
</leadAttributeList>
|
71
|
+
</leadRecord>
|
72
|
+
<leadRecord>
|
73
|
+
<Id>1001081</Id>
|
74
|
+
<Email>foo@example.com</Email>
|
75
|
+
<ForeignSysPersonId xsi:nil="true"/>
|
76
|
+
<ForeignSysType xsi:nil="true"/>
|
77
|
+
<leadAttributeList>
|
78
|
+
<attribute>
|
79
|
+
<attrName>Company</attrName>
|
80
|
+
<attrType>string</attrType>
|
81
|
+
<attrValue>foo</attrValue>
|
82
|
+
</attribute>
|
83
|
+
<attribute>
|
84
|
+
<attrName>FirstName</attrName>
|
85
|
+
<attrType>string</attrType>
|
86
|
+
<attrValue>foo</attrValue>
|
87
|
+
</attribute>
|
88
|
+
<attribute>
|
89
|
+
<attrName>LastName</attrName>
|
90
|
+
<attrType>string</attrType>
|
91
|
+
<attrValue>foo</attrValue>
|
92
|
+
</attribute>
|
93
|
+
<attribute>
|
94
|
+
<attrName>LeadStatus</attrName>
|
95
|
+
<attrType>string</attrType>
|
96
|
+
<attrValue>Inactive</attrValue>
|
97
|
+
</attribute>
|
98
|
+
</leadAttributeList>
|
99
|
+
</leadRecord>
|
100
|
+
</leadRecordList>
|
101
|
+
</result>
|
102
|
+
</ns1:successGetLead>
|
103
|
+
</SOAP-ENV:Body>
|
104
|
+
</SOAP-ENV:Envelope>
|
105
|
+
END
|
106
|
+
}
|
107
|
+
|
108
|
+
let(:failure_xml) { <<END
|
109
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
110
|
+
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
|
111
|
+
<SOAP-ENV:Body>
|
112
|
+
<SOAP-ENV:Fault>
|
113
|
+
<faultcode>SOAP-ENV:Client</faultcode>
|
114
|
+
<faultstring>20103 - Lead not found</faultstring>
|
115
|
+
<detail>
|
116
|
+
<ns1:serviceException xmlns:ns1="http://www.marketo.com/mktows/">
|
117
|
+
<name>mktServiceException</name>
|
118
|
+
<message>No lead found with EMAIL = pants@example.com (20103)</message>
|
119
|
+
<code>20103</code>
|
120
|
+
</ns1:serviceException>
|
121
|
+
</detail>
|
122
|
+
</SOAP-ENV:Fault>
|
123
|
+
</SOAP-ENV:Body>
|
124
|
+
</SOAP-ENV:Envelope>
|
125
|
+
END
|
126
|
+
}
|
127
|
+
|
128
|
+
|
129
|
+
it 'can construct from a success - one lead' do
|
130
|
+
savon_resp = SavonHelper.create_response(success_xml)
|
131
|
+
r = GetLeadResponse.new(savon_resp)
|
132
|
+
|
133
|
+
# GenericResponse fields
|
134
|
+
r.success?.should == true
|
135
|
+
r.error_message.should be_nil
|
136
|
+
|
137
|
+
# SyncLeadResponse fields
|
138
|
+
r.leads.length.should == 1
|
139
|
+
r.leads.first.get_attribute("FirstName").should == "Burt"
|
140
|
+
end
|
141
|
+
|
142
|
+
it 'can construct from a success - two leads' do
|
143
|
+
savon_resp = SavonHelper.create_response(success_xml_two_leads)
|
144
|
+
r = GetLeadResponse.new(savon_resp)
|
145
|
+
|
146
|
+
# GenericResponse fields
|
147
|
+
r.success?.should == true
|
148
|
+
r.error_message.should be_nil
|
149
|
+
|
150
|
+
# SyncLeadResponse fields
|
151
|
+
r.leads.length.should == 2
|
152
|
+
r.leads[0].get_attribute("Company").should == "The Price is Right"
|
153
|
+
r.leads[1].get_attribute("Company").should == "foo"
|
154
|
+
end
|
155
|
+
|
156
|
+
|
157
|
+
it 'can construct from a failure' do
|
158
|
+
savon_resp = SavonHelper.create_response(failure_xml)
|
159
|
+
r = GetLeadResponse.new(savon_resp)
|
160
|
+
|
161
|
+
# GenericResponse fields
|
162
|
+
r.success?.should == false
|
163
|
+
r.error_message.should == "No lead found with EMAIL = pants@example.com (20103)"
|
164
|
+
|
165
|
+
# SyncLeadResponse fields
|
166
|
+
r.leads.empty?.should be true
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Markety
|
4
|
+
module Response
|
5
|
+
describe ListOperationResponse do
|
6
|
+
|
7
|
+
let(:success_xml) {<<END
|
8
|
+
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.marketo.com/mktows/">
|
9
|
+
<SOAP-ENV:Body>
|
10
|
+
<ns1:successListOperation>
|
11
|
+
<result>
|
12
|
+
<success>true</success>
|
13
|
+
<statusList>
|
14
|
+
<leadStatus>
|
15
|
+
<leadKey>
|
16
|
+
<keyType>IDNUM</keyType>
|
17
|
+
<keyValue>1001088</keyValue>
|
18
|
+
</leadKey>
|
19
|
+
<status>true</status>
|
20
|
+
</leadStatus>
|
21
|
+
</statusList>
|
22
|
+
</result>
|
23
|
+
</ns1:successListOperation>
|
24
|
+
</SOAP-ENV:Body>
|
25
|
+
</SOAP-ENV:Envelope>
|
26
|
+
END
|
27
|
+
}
|
28
|
+
|
29
|
+
let(:failure_xml) {<<END
|
30
|
+
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.marketo.com/mktows/">
|
31
|
+
<SOAP-ENV:Body>
|
32
|
+
<ns1:successListOperation>
|
33
|
+
<result>
|
34
|
+
<success>false</success>
|
35
|
+
<statusList>
|
36
|
+
<leadStatus>
|
37
|
+
<leadKey>
|
38
|
+
<keyType>IDNUM</keyType>
|
39
|
+
<keyValue>1001086</keyValue>
|
40
|
+
</leadKey>
|
41
|
+
<status>false</status>
|
42
|
+
</leadStatus>
|
43
|
+
</statusList>
|
44
|
+
</result>
|
45
|
+
</ns1:successListOperation>
|
46
|
+
</SOAP-ENV:Body>
|
47
|
+
</SOAP-ENV:Envelope>
|
48
|
+
END
|
49
|
+
}
|
50
|
+
|
51
|
+
|
52
|
+
it 'can construct from a success' do
|
53
|
+
savon_resp = SavonHelper.create_response(success_xml)
|
54
|
+
r = ListOperationResponse.new(savon_resp)
|
55
|
+
|
56
|
+
# GenericResponse fields
|
57
|
+
r.success?.should == true
|
58
|
+
r.error_message.should be_nil
|
59
|
+
|
60
|
+
r.list_operation_success?.should == true
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'can construct from a failure' do
|
64
|
+
savon_resp = SavonHelper.create_response(failure_xml)
|
65
|
+
r = ListOperationResponse.new(savon_resp)
|
66
|
+
|
67
|
+
# GenericResponse fields
|
68
|
+
r.success?.should == true
|
69
|
+
r.error_message.should be_nil
|
70
|
+
|
71
|
+
r.list_operation_success?.should == false
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Markety
|
4
|
+
module Response
|
5
|
+
describe SyncLeadResponse do
|
6
|
+
|
7
|
+
let(:success_xml) { <<END
|
8
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
9
|
+
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns1="http://www.marketo.com/mktows/">
|
10
|
+
<SOAP-ENV:Body>
|
11
|
+
<ns1:successSyncLead>
|
12
|
+
<result>
|
13
|
+
<leadId>1001064</leadId>
|
14
|
+
<syncStatus>
|
15
|
+
<leadId>1001064</leadId>
|
16
|
+
<status>CREATED</status>
|
17
|
+
<error xsi:nil="true"/>
|
18
|
+
</syncStatus>
|
19
|
+
<leadRecord>
|
20
|
+
<Id>1001064</Id>
|
21
|
+
<Email>spiderman@example.com</Email>
|
22
|
+
<ForeignSysPersonId xsi:nil="true"/>
|
23
|
+
<ForeignSysType xsi:nil="true"/>
|
24
|
+
<leadAttributeList>
|
25
|
+
<attribute>
|
26
|
+
<attrName>FirstName</attrName>
|
27
|
+
<attrType>string</attrType>
|
28
|
+
<attrValue>Peter</attrValue>
|
29
|
+
</attribute>
|
30
|
+
<attribute>
|
31
|
+
<attrName>LastName</attrName>
|
32
|
+
<attrType>string</attrType>
|
33
|
+
<attrValue>Parker</attrValue>
|
34
|
+
</attribute>
|
35
|
+
<attribute>
|
36
|
+
<attrName>Website</attrName>
|
37
|
+
<attrType>url</attrType>
|
38
|
+
<attrValue>example.com</attrValue>
|
39
|
+
</attribute>
|
40
|
+
</leadAttributeList>
|
41
|
+
</leadRecord>
|
42
|
+
</result>
|
43
|
+
</ns1:successSyncLead>
|
44
|
+
</SOAP-ENV:Body>
|
45
|
+
</SOAP-ENV:Envelope>
|
46
|
+
END
|
47
|
+
}
|
48
|
+
|
49
|
+
let(:failure_xml) { <<END
|
50
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
51
|
+
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
|
52
|
+
<SOAP-ENV:Body>
|
53
|
+
<SOAP-ENV:Fault>
|
54
|
+
<faultcode>SOAP-ENV:Client</faultcode>
|
55
|
+
<faultstring>20105 - Unknown lead field</faultstring>
|
56
|
+
<detail>
|
57
|
+
<ns1:serviceException xmlns:ns1="http://www.marketo.com/mktows/">
|
58
|
+
<name>mktServiceException</name>
|
59
|
+
<message>syncLead operation failed: unknown fields for import: pants (20105)</message>
|
60
|
+
<code>20105</code>
|
61
|
+
</ns1:serviceException>
|
62
|
+
</detail>
|
63
|
+
</SOAP-ENV:Fault>
|
64
|
+
</SOAP-ENV:Body>
|
65
|
+
</SOAP-ENV:Envelope>
|
66
|
+
END
|
67
|
+
}
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
it 'can construct from a success' do
|
72
|
+
savon_resp = SavonHelper.create_response(success_xml)
|
73
|
+
|
74
|
+
r = SyncLeadResponse.new(savon_resp)
|
75
|
+
|
76
|
+
# GenericResponse fields
|
77
|
+
r.success?.should == true
|
78
|
+
r.error_message.should be_nil
|
79
|
+
# to_xml
|
80
|
+
# to_hash
|
81
|
+
|
82
|
+
# SyncLeadResponse fields
|
83
|
+
r.lead_id.should == "1001064"
|
84
|
+
r.update_type.should == :created
|
85
|
+
r.updated_lead.is_a?(::Markety::Lead).should == true
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'can construct from a failure' do
|
89
|
+
savon_resp = SavonHelper.create_response(failure_xml)
|
90
|
+
|
91
|
+
r = SyncLeadResponse.new(savon_resp)
|
92
|
+
|
93
|
+
# GenericResponse fields
|
94
|
+
r.success?.should == false
|
95
|
+
r.error_message.should == "syncLead operation failed: unknown fields for import: pants (20105)"
|
96
|
+
# to_xml
|
97
|
+
# to_hash
|
98
|
+
|
99
|
+
# SyncLeadResponse fields
|
100
|
+
r.lead_id.should be_nil
|
101
|
+
r.update_type.should be_nil
|
102
|
+
r.updated_lead.should be_nil
|
103
|
+
end
|
104
|
+
|
105
|
+
end #describe SyncLeadResponse
|
106
|
+
end #module Response
|
107
|
+
end #module Markety
|