office_autopilot_api 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +6 -0
- data/.rspec +1 -0
- data/Gemfile +4 -0
- data/MIT-LICENSE +20 -0
- data/README.md +71 -0
- data/Rakefile +8 -0
- data/lib/office_autopilot_api.rb +1 -0
- data/lib/office_autopilot_api/client.rb +51 -0
- data/lib/office_autopilot_api/client/contacts.rb +160 -0
- data/lib/office_autopilot_api/error.rb +7 -0
- data/lib/office_autopilot_api/request.rb +11 -0
- data/lib/office_autopilot_api/version.rb +3 -0
- data/office_autopilot_api.gemspec +30 -0
- data/spec/data/contacts_add_response.xml +69 -0
- data/spec/data/contacts_fetch_sequences.xml +4 -0
- data/spec/data/contacts_key_type.xml +99 -0
- data/spec/data/contacts_pull_tags.xml +5 -0
- data/spec/data/contacts_search_multiple_response.xml +198 -0
- data/spec/data/contacts_search_single_response.xml +68 -0
- data/spec/data/invalid_contact_ids_error.xml +3 -0
- data/spec/data/invalid_xml_error_response.xml +3 -0
- data/spec/office_autopilot_api/client/contacts_spec.rb +243 -0
- data/spec/office_autopilot_api/client_spec.rb +54 -0
- data/spec/office_autopilot_api/request_spec.rb +15 -0
- data/spec/spec_helper.rb +25 -0
- metadata +166 -0
@@ -0,0 +1,99 @@
|
|
1
|
+
<result>
|
2
|
+
<contact id="" bulk_mail="">
|
3
|
+
<Group_Tag name="Contact Information">
|
4
|
+
<field name="First Name" type="text"/>
|
5
|
+
<field name="Last Name" type="text"/>
|
6
|
+
<field name="E-Mail" type="text"/>
|
7
|
+
<field name="Home Phone" type="phone"/>
|
8
|
+
<field name="Title" type="text"/>
|
9
|
+
<field name="Office Phone" type="text"/>
|
10
|
+
<field name="Cell Phone" type="phone"/>
|
11
|
+
<field name="Fax" type="text"/>
|
12
|
+
<field name="Address" type="text"/>
|
13
|
+
<field name="Company" type="text"/>
|
14
|
+
<field name="Address 2" type="text"/>
|
15
|
+
<field name="City" type="text"/>
|
16
|
+
<field name="State" type="state"/>
|
17
|
+
<field name="Zip Code" type="text"/>
|
18
|
+
<field name="Website " type="text"/>
|
19
|
+
<field name="Country" type="country"/>
|
20
|
+
<field name="Birthday" type="fulldate"/>
|
21
|
+
</Group_Tag>
|
22
|
+
<Group_Tag name="Lead Information">
|
23
|
+
<field name="Contact Owner" type=""/>
|
24
|
+
<field name="First Referrer" type=""/>
|
25
|
+
<field name="Last Referrer" type=""/>
|
26
|
+
<field name="Lead Source" type="tdrop">
|
27
|
+
<option>Adwords</option>
|
28
|
+
<option>Tradeshow</option>
|
29
|
+
<option>Business Card</option>
|
30
|
+
<option>Referral</option>
|
31
|
+
<option>Newspaper Ad</option>
|
32
|
+
</field>
|
33
|
+
<field name="Campaign" type="tdrop">
|
34
|
+
<option>Free Trial</option>
|
35
|
+
<option>20% Off</option>
|
36
|
+
<option>Mother's Day</option>
|
37
|
+
</field>
|
38
|
+
<field name="Ad" type="tdrop">
|
39
|
+
<option>Ad Version 1</option>
|
40
|
+
<option>Ad Version 2</option>
|
41
|
+
</field>
|
42
|
+
<field name="Media" type="tdrop">
|
43
|
+
<option>PPC</option>
|
44
|
+
<option>Direct Mail</option>
|
45
|
+
<option>Banner</option>
|
46
|
+
<option>Newspaper</option>
|
47
|
+
</field>
|
48
|
+
</Group_Tag>
|
49
|
+
<Group_Tag name="Sequences and Tags">
|
50
|
+
<field name="Sequences" type="sequence"/>
|
51
|
+
<field name="Contact Tags" type="list">
|
52
|
+
<list id="3">newleads</list>
|
53
|
+
<list id="4">old_leads</list>
|
54
|
+
<list id="5">legacy Leads</list>
|
55
|
+
</field>
|
56
|
+
</Group_Tag>
|
57
|
+
<Group_Tag name="PrecisoPro" editable="1">
|
58
|
+
<field name="Lead Status" type="tdrop" editable="1">
|
59
|
+
<option>INB-APP</option>
|
60
|
+
<option>OUTB-APP</option>
|
61
|
+
<option>REJECT-APP</option>
|
62
|
+
<option>ASSIGNED</option>
|
63
|
+
<option>NEW</option>
|
64
|
+
<option>CUSTOMER</option>
|
65
|
+
<option>NO SHOW</option>
|
66
|
+
</field>
|
67
|
+
<field name="Appointment For" type="text" editable="1"/>
|
68
|
+
<field name="Appointment Date" type="text" editable="1"/>
|
69
|
+
<field name="Appointment Time" type="text" editable="1"/>
|
70
|
+
<field name="Treatment" type="text" editable="1"/>
|
71
|
+
<field name="Contact Preference" type="tdrop" editable="1">
|
72
|
+
<option>Phone</option>
|
73
|
+
<option>Email</option>
|
74
|
+
</field>
|
75
|
+
<field name="Dentist Id" type="text" editable="1"/>
|
76
|
+
<field name="Dentist Name" type="text" editable="1"/>
|
77
|
+
<field name="Dentist Address" type="text" editable="1"/>
|
78
|
+
<field name="Dentist Email" type="text" editable="1"/>
|
79
|
+
<field name="Dentist Telephone" type="text" editable="1"/>
|
80
|
+
<field name="Expected CLV" type="text" editable="1"/>
|
81
|
+
<field name="Already Spent" type="text" editable="1"/>
|
82
|
+
<field name="Notes" type="longtext" editable="1"/>
|
83
|
+
</Group_Tag>
|
84
|
+
<Group_Tag name="Affiliate Data" editable="1">
|
85
|
+
<field name="Affiliate Program" type="aff_program"/>
|
86
|
+
<field name="Number of Sales" type="numeric"/>
|
87
|
+
<field name="$ Sales" type="price"/>
|
88
|
+
<field name="Affiliate Paypal" type="text"/>
|
89
|
+
</Group_Tag>
|
90
|
+
<Group_Tag name="Credit Card" editable="1">
|
91
|
+
<field name="Card Type" type="ndrop"/>
|
92
|
+
<field name="Card Expiration Month" type="tdrop"/>
|
93
|
+
<field name="Charge Result" type="tdrop"/>
|
94
|
+
<field name="Card Expiration Year" type="numeric"/>
|
95
|
+
<field name="Card Number (Last 4)" type="numeric"/>
|
96
|
+
<field name="Payment Center Link" type="Payment Center Link"/>
|
97
|
+
</Group_Tag>
|
98
|
+
</contact>
|
99
|
+
</result>
|
@@ -0,0 +1,198 @@
|
|
1
|
+
<result>
|
2
|
+
<contact id='8' date='1299674533' dlm='1299674554' score='0.00' purl='bobby' bulk_mail='1'>
|
3
|
+
<Group_Tag name='Contact Information'>
|
4
|
+
<field name="First Name">bobby</field>
|
5
|
+
<field name="Last Name">brown</field>
|
6
|
+
<field name="E-Mail">bobby@example.com</field>
|
7
|
+
<field name="Home Phone"/>
|
8
|
+
<field name="Title"/>
|
9
|
+
<field name="Office Phone"/>
|
10
|
+
<field name="Cell Phone"/>
|
11
|
+
<field name="Fax"/>
|
12
|
+
<field name="Address"/>
|
13
|
+
<field name="Company"/>
|
14
|
+
<field name="Address 2"/>
|
15
|
+
<field name="City"/>
|
16
|
+
<field name="State"/>
|
17
|
+
<field name="Zip Code"/>
|
18
|
+
<field name="Website "/>
|
19
|
+
<field name="Country"/>
|
20
|
+
<field name="Birthday"/>
|
21
|
+
</Group_Tag>
|
22
|
+
<Group_Tag name='Lead Information'>
|
23
|
+
<field name="Contact Owner">Jimbo Watunusi</field>
|
24
|
+
<field name="First Referrer"/>
|
25
|
+
<field name="Last Referrer"/>
|
26
|
+
<field name="Lead Source"/>
|
27
|
+
<field name="Campaign"/>
|
28
|
+
<field name="Ad"/>
|
29
|
+
<field name="Media"/>
|
30
|
+
</Group_Tag>
|
31
|
+
<Group_Tag name='Sequences and Tags'>
|
32
|
+
<field name="Sequences">*/*</field>
|
33
|
+
<field name="Contact Tags"/>
|
34
|
+
</Group_Tag>
|
35
|
+
<Group_Tag name='Purchase History'></Group_Tag>
|
36
|
+
<Group_Tag name='Most Recent Charge'>
|
37
|
+
<field name="Charge Amount">$0.00</field>
|
38
|
+
<field name="Charge Invoice #"/>
|
39
|
+
</Group_Tag>
|
40
|
+
<Group_Tag name='Affiliate Data'>
|
41
|
+
<field name="Affiliate Program"/>
|
42
|
+
<field name="Number of Sales"/>
|
43
|
+
<field name="$ Sales">$0.00</field>
|
44
|
+
<field name="Paypal E-mail"/>
|
45
|
+
<field name="Affiliate Paypal"/>
|
46
|
+
</Group_Tag>
|
47
|
+
<Group_Tag name='Most Recent Invoice'>
|
48
|
+
<field name="Invoice #"/>
|
49
|
+
<field name="Total Invoice Amount">$0.00</field>
|
50
|
+
</Group_Tag>
|
51
|
+
<Group_Tag name='Lead Status'>
|
52
|
+
<field name="Lead Status"/>
|
53
|
+
<field name="Preferencia Contacto"/>
|
54
|
+
</Group_Tag>
|
55
|
+
<Group_Tag name='Credit Card'>
|
56
|
+
<field name="Card Type"/>
|
57
|
+
<field name="Card Expiration Month"/>
|
58
|
+
<field name="Charge Result"/>
|
59
|
+
<field name="Card Expiration Year"/>
|
60
|
+
<field name="Card Number (Last 4)"/>
|
61
|
+
<field name="Payment Center Link"/>
|
62
|
+
</Group_Tag>
|
63
|
+
<Group_Tag name='Invoices'></Group_Tag>
|
64
|
+
<Group_Tag name='Subscriptions and Payment Plans'></Group_Tag>
|
65
|
+
<Group_Tag name='Website Subscribers'></Group_Tag>
|
66
|
+
</contact>
|
67
|
+
<contact id='5' date='1296056609' dlm='1296056694' score='0.00' purl='Paciente2' bulk_mail='1'>
|
68
|
+
<Group_Tag name='Contact Information'>
|
69
|
+
<field name="First Name">Ali</field>
|
70
|
+
<field name="Last Name">Maju</field>
|
71
|
+
<field name="E-Mail">ali@example.com</field>
|
72
|
+
<field name="Home Phone">1234</field>
|
73
|
+
<field name="Title"/>
|
74
|
+
<field name="Office Phone">1234123</field>
|
75
|
+
<field name="Cell Phone">123444</field>
|
76
|
+
<field name="Fax"/>
|
77
|
+
<field name="Address"/>
|
78
|
+
<field name="Company"/>
|
79
|
+
<field name="Address 2"/>
|
80
|
+
<field name="City"/>
|
81
|
+
<field name="State"/>
|
82
|
+
<field name="Zip Code"/>
|
83
|
+
<field name="Website "/>
|
84
|
+
<field name="Country"/>
|
85
|
+
<field name="Birthday"/>
|
86
|
+
</Group_Tag>
|
87
|
+
<Group_Tag name='Lead Information'>
|
88
|
+
<field name="Contact Owner">Jimbo Watunusi</field>
|
89
|
+
<field name="First Referrer"/>
|
90
|
+
<field name="Last Referrer"/>
|
91
|
+
<field name="Lead Source"/>
|
92
|
+
<field name="Campaign"/>
|
93
|
+
<field name="Ad"/>
|
94
|
+
<field name="Media"/>
|
95
|
+
</Group_Tag>
|
96
|
+
<Group_Tag name='Sequences and Tags'>
|
97
|
+
<field name="Sequences">*/*</field>
|
98
|
+
<field name="Contact Tags"/>
|
99
|
+
</Group_Tag>
|
100
|
+
<Group_Tag name='Purchase History'></Group_Tag>
|
101
|
+
<Group_Tag name='Most Recent Charge'>
|
102
|
+
<field name="Charge Amount">$0.00</field>
|
103
|
+
<field name="Charge Invoice #"/>
|
104
|
+
</Group_Tag>
|
105
|
+
<Group_Tag name='Affiliate Data'>
|
106
|
+
<field name="Affiliate Program"/>
|
107
|
+
<field name="Number of Sales"/>
|
108
|
+
<field name="$ Sales">$0.00</field>
|
109
|
+
<field name="Paypal E-mail"/>
|
110
|
+
<field name="Affiliate Paypal"/>
|
111
|
+
</Group_Tag>
|
112
|
+
<Group_Tag
|
113
|
+
name='Most Recent Invoice'>
|
114
|
+
<field name="Invoice #"/>
|
115
|
+
<field name="Total Invoice Amount">$0.00</field>
|
116
|
+
</Group_Tag>
|
117
|
+
<Group_Tag name='Lead Status'>
|
118
|
+
<field name="Lead Status">ASSIGNED</field>
|
119
|
+
<field name="Preferencia Contacto">Entre las 13 y 16</field>
|
120
|
+
</Group_Tag>
|
121
|
+
<Group_Tag name='Credit Card'>
|
122
|
+
<field name="Card Type"/>
|
123
|
+
<field name="Card Expiration Month"/>
|
124
|
+
<field name="Charge Result"/>
|
125
|
+
<field name="Card Expiration Year"/>
|
126
|
+
<field name="Card Number (Last 4)"/>
|
127
|
+
<field name="Payment Center Link"/>
|
128
|
+
</Group_Tag>
|
129
|
+
<Group_Tag name='Invoices'></Group_Tag>
|
130
|
+
<Group_Tag name='Subscriptions and Payment Plans'></Group_Tag>
|
131
|
+
<Group_Tag name='Website Subscribers'></Group_Tag>
|
132
|
+
</contact>
|
133
|
+
<contact id='7' date='1299671887' dlm='1299674450' score='0.00' purl='prashant' bulk_mail='1'>
|
134
|
+
<Group_Tag name='Contact Information'>
|
135
|
+
<field name="First Name">prashant</field>
|
136
|
+
<field name="Last Name">nadarajan</field>
|
137
|
+
<field name="E-Mail">prashant@example.com</field>
|
138
|
+
<field name="Home Phone"/>
|
139
|
+
<field name="Title"/>
|
140
|
+
<field name="Office Phone"/>
|
141
|
+
<field name="Cell Phone"/>
|
142
|
+
<field name="Fax"/>
|
143
|
+
<field name="Address"/>
|
144
|
+
<field name="Company"/>
|
145
|
+
<field name="Address 2"/>
|
146
|
+
<field name="City"/>
|
147
|
+
<field name="State"/>
|
148
|
+
<field name="Zip Code"/>
|
149
|
+
<field name="Website "/>
|
150
|
+
<field name="Country"/>
|
151
|
+
<field name="Birthday"/>
|
152
|
+
</Group_Tag>
|
153
|
+
<Group_Tag name='Lead Information'>
|
154
|
+
<field name="Contact Owner">Don Corleone</field>
|
155
|
+
<field name="First Referrer"/>
|
156
|
+
<field name="Last Referrer"/>
|
157
|
+
<field name="Lead Source"/>
|
158
|
+
<field name="Campaign"/>
|
159
|
+
<field name="Ad"/>
|
160
|
+
<field name="Media"/>
|
161
|
+
</Group_Tag>
|
162
|
+
<Group_Tag name='Sequences and Tags'>
|
163
|
+
<field name="Sequences">*/*</field>
|
164
|
+
<field name="Contact Tags"/>
|
165
|
+
</Group_Tag>
|
166
|
+
<Group_Tag name='Purchase History'></Group_Tag>
|
167
|
+
<Group_Tag name='Most Recent Charge'>
|
168
|
+
<field name="Charge Amount">$0.00</field>
|
169
|
+
<field name="Charge Invoice #"/>
|
170
|
+
</Group_Tag>
|
171
|
+
<Group_Tag name='Affiliate Data'>
|
172
|
+
<field name="Affiliate Program"/>
|
173
|
+
<field name="Number of Sales"/>
|
174
|
+
<field name="$ Sales">$0.00</field>
|
175
|
+
<field name="Paypal E-mail"/>
|
176
|
+
<field name="Affiliate Paypal"/>
|
177
|
+
</Group_Tag>
|
178
|
+
<Group_Tag name='Most Recent Invoice'>
|
179
|
+
<field name="Invoice #"/>
|
180
|
+
<field name="Total Invoice Amount">$0.00</field>
|
181
|
+
</Group_Tag>
|
182
|
+
<Group_Tag name='Lead Status'>
|
183
|
+
<field name="Lead Status"/>
|
184
|
+
<field name="Preferencia Contacto"/>
|
185
|
+
</Group_Tag>
|
186
|
+
<Group_Tag name='Credit Card'>
|
187
|
+
<field name="Card Type"/>
|
188
|
+
<field name="Card Expiration Month"/>
|
189
|
+
<field name="Charge Result"/>
|
190
|
+
<field name="Card Expiration Year"/>
|
191
|
+
<field name="Card Number (Last 4)"/>
|
192
|
+
<field name="Payment Center Link"/>
|
193
|
+
</Group_Tag>
|
194
|
+
<Group_Tag name='Invoices'></Group_Tag>
|
195
|
+
<Group_Tag name='Subscriptions and Payment Plans'></Group_Tag>
|
196
|
+
<Group_Tag name='Website Subscribers'></Group_Tag>
|
197
|
+
</contact>
|
198
|
+
</result>
|
@@ -0,0 +1,68 @@
|
|
1
|
+
<result>
|
2
|
+
<contact id='7' date='1299671887' dlm='1299674450' score='0.00' purl='prashant' bulk_mail='1'>
|
3
|
+
<Group_Tag name='Contact Information'>
|
4
|
+
<field name="First Name">prashant</field>
|
5
|
+
<field name="Last Name">nadarajan</field>
|
6
|
+
<field name="E-Mail">prashant@example.com</field>
|
7
|
+
<field name="Home Phone"/>
|
8
|
+
<field name="Title"/>
|
9
|
+
<field name="Office Phone"/>
|
10
|
+
<field name="Cell Phone"/>
|
11
|
+
<field name="Fax"/>
|
12
|
+
<field name="Address"/>
|
13
|
+
<field name="Company"/>
|
14
|
+
<field name="Address 2"/>
|
15
|
+
<field name="City"/>
|
16
|
+
<field name="State"/>
|
17
|
+
<field name="Zip Code"/>
|
18
|
+
<field name="Website "/>
|
19
|
+
<field name="Country"/>
|
20
|
+
<field name="Birthday"/>
|
21
|
+
</Group_Tag>
|
22
|
+
<Group_Tag name='Lead Information'>
|
23
|
+
<field name="Contact Owner">Don Corleone</field>
|
24
|
+
<field name="First Referrer"/>
|
25
|
+
<field name="Last Referrer"/>
|
26
|
+
<field name="Lead Source"/>
|
27
|
+
<field name="Campaign"/>
|
28
|
+
<field name="Ad"/>
|
29
|
+
<field name="Media"/>
|
30
|
+
</Group_Tag>
|
31
|
+
<Group_Tag name='Sequences and Tags'>
|
32
|
+
<field name="Sequences">*/*</field>
|
33
|
+
<field name="Contact Tags"/>
|
34
|
+
</Group_Tag>
|
35
|
+
<Group_Tag name='Purchase History'></Group_Tag>
|
36
|
+
<Group_Tag name='Most Recent Charge'>
|
37
|
+
<field name="Charge Amount">$0.00</field>
|
38
|
+
<field name="Charge Invoice #"/>
|
39
|
+
</Group_Tag>
|
40
|
+
<Group_Tag name='Affiliate Data'>
|
41
|
+
<field name="Affiliate Program"/>
|
42
|
+
<field name="Number of Sales"/>
|
43
|
+
<field name="$ Sales">$0.00</field>
|
44
|
+
<field name="Paypal E-mail"/>
|
45
|
+
<field name="Affiliate Paypal"/>
|
46
|
+
</Group_Tag>
|
47
|
+
<Group_Tag
|
48
|
+
name='Most Recent Invoice'>
|
49
|
+
<field name="Invoice #"/>
|
50
|
+
<field name="Total Invoice Amount">$0.00</field>
|
51
|
+
</Group_Tag>
|
52
|
+
<Group_Tag name='Lead Status'>
|
53
|
+
<field name="Lead Status"/>
|
54
|
+
<field name="Preferencia Contacto"/>
|
55
|
+
</Group_Tag>
|
56
|
+
<Group_Tag name='Credit Card'>
|
57
|
+
<field name="Card Type"/>
|
58
|
+
<field name="Card Expiration Month"/>
|
59
|
+
<field name="Charge Result"/>
|
60
|
+
<field name="Card Expiration Year"/>
|
61
|
+
<field name="Card Number (Last 4)"/>
|
62
|
+
<field name="Payment Center Link"/>
|
63
|
+
</Group_Tag>
|
64
|
+
<Group_Tag name='Invoices'></Group_Tag>
|
65
|
+
<Group_Tag name='Subscriptions and Payment Plans'></Group_Tag>
|
66
|
+
<Group_Tag name='Website Subscribers'></Group_Tag>
|
67
|
+
</contact>
|
68
|
+
</result>
|
@@ -0,0 +1,243 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OfficeAutopilotApi::Client::Contacts do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@contact_endpoint = "#{api_endpoint}/cdata.php"
|
7
|
+
@client = OfficeAutopilotApi::Client.new(:api_id => 'xxx', :api_key => 'xxx')
|
8
|
+
@auth_str = "Appid=#{@client.api_id}&Key=#{@client.api_key}"
|
9
|
+
end
|
10
|
+
|
11
|
+
def request_body(req_type, options = {})
|
12
|
+
options = { 'reqType' => req_type }.merge(options)
|
13
|
+
|
14
|
+
query = ''
|
15
|
+
options.each do |key, value|
|
16
|
+
if key == "data"
|
17
|
+
value = escape_xml(value)
|
18
|
+
end
|
19
|
+
query << "#{key}=#{value}&"
|
20
|
+
end
|
21
|
+
query << @auth_str
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "#xml_for_search" do
|
25
|
+
# <search>
|
26
|
+
# <equation>
|
27
|
+
# <field>E-Mail</field>
|
28
|
+
# <op>e</op>
|
29
|
+
# <value>john@example.com</value>
|
30
|
+
# </equation>
|
31
|
+
# </search>
|
32
|
+
|
33
|
+
context "searching with one field" do
|
34
|
+
it "returns a valid simple search data xml" do
|
35
|
+
field = "E-Mail"
|
36
|
+
op = "e"
|
37
|
+
value = "john@example.com"
|
38
|
+
|
39
|
+
xml = Nokogiri::XML(@client.send(:xml_for_search, { :field => field, :op => op, :value => value }) )
|
40
|
+
xml.at_css('field').content.should == field
|
41
|
+
xml.at_css('op').content.should == op
|
42
|
+
xml.at_css('value').content.should == value
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context "searching with more than one field" do
|
47
|
+
it "returns a valid multi search data xml" do
|
48
|
+
search_options = [
|
49
|
+
{:field => 'E-Mail', :op => 'e', :value => 'foo@example.com'},
|
50
|
+
{:field => 'Contact Tags', :op => 'n', :value => 'bar'},
|
51
|
+
]
|
52
|
+
|
53
|
+
xml = @client.send(:xml_for_search, search_options)
|
54
|
+
xml = Nokogiri::XML(xml)
|
55
|
+
xml.css('field')[0].content.should == 'E-Mail'
|
56
|
+
xml.css('op')[0].content.should == 'e'
|
57
|
+
xml.css('value')[0].content.should == 'foo@example.com'
|
58
|
+
|
59
|
+
xml.css('field')[1].content.should == 'Contact Tags'
|
60
|
+
xml.css('op')[1].content.should == 'n'
|
61
|
+
xml.css('value')[1].content.should == 'bar'
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe "#contacts_search" do
|
67
|
+
it "returns the matched contacts" do
|
68
|
+
search_options = {:field => 'E-Mail', :op => 'e', :value => 'prashant@example.com'}
|
69
|
+
search_xml = @client.send(:xml_for_search, search_options)
|
70
|
+
contacts_xml = test_data('contacts_search_single_response.xml')
|
71
|
+
|
72
|
+
request_body = request_body('search', 'data' => search_xml)
|
73
|
+
stub_request(:post, @contact_endpoint).with(:body => request_body).to_return(:body => contacts_xml)
|
74
|
+
|
75
|
+
contacts = @client.contacts_search(search_options)
|
76
|
+
WebMock.should have_requested(:post, @contact_endpoint).with(:body => request_body)
|
77
|
+
contacts.should == @client.send(:parse_contacts_xml, contacts_xml)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe "#xml_for_contact" do
|
82
|
+
before do
|
83
|
+
@contact_options = {
|
84
|
+
'Contact Information' => {'First Name' => 'Bob', 'Last Name' => 'Foo', 'E-Mail' => 'b@example.com'},
|
85
|
+
'Lead Information' => {'Contact Owner' => 'Mr Bar'}
|
86
|
+
}
|
87
|
+
end
|
88
|
+
|
89
|
+
it "returns a valid contacts xml" do
|
90
|
+
xml = @client.send(:xml_for_contact, @contact_options)
|
91
|
+
xml = Nokogiri::XML(xml)
|
92
|
+
|
93
|
+
xml.at_css('contact')['id'].should be_nil
|
94
|
+
|
95
|
+
contact_info = xml.css("contact Group_Tag[name='Contact Information']")
|
96
|
+
contact_info.at_css("field[name='First Name']").content.should == 'Bob'
|
97
|
+
contact_info.at_css("field[name='Last Name']").content.should == 'Foo'
|
98
|
+
|
99
|
+
lead_info = xml.css("contact Group_Tag[name='Lead Information']")
|
100
|
+
lead_info.at_css("field[name='Contact Owner']").content.should == 'Mr Bar'
|
101
|
+
end
|
102
|
+
|
103
|
+
context "when 'id' is specified" do
|
104
|
+
it "returns a valid contact xml containing the contact id" do
|
105
|
+
@contact_options.merge!('id' => '1234')
|
106
|
+
xml = Nokogiri::XML( @client.send(:xml_for_contact, @contact_options) )
|
107
|
+
|
108
|
+
xml.at_css('contact')['id'].should == '1234'
|
109
|
+
contact_info = xml.css("contact Group_Tag[name='Contact Information']")
|
110
|
+
contact_info.at_css("field[name='First Name']").content.should == 'Bob'
|
111
|
+
contact_info.at_css("field[name='Last Name']").content.should == 'Foo'
|
112
|
+
|
113
|
+
lead_info = xml.css("contact Group_Tag[name='Lead Information']")
|
114
|
+
lead_info.at_css("field[name='Contact Owner']").content.should == 'Mr Bar'
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
describe "#parse_contacts_xml" do
|
120
|
+
context "when the results contain one contact" do
|
121
|
+
it "returns an array containing the contact" do
|
122
|
+
contacts = @client.send(:parse_contacts_xml, test_data('contacts_search_single_response.xml'))
|
123
|
+
|
124
|
+
contacts.size.should == 1
|
125
|
+
|
126
|
+
contacts.each do |contact|
|
127
|
+
contact['id'].should == '7'
|
128
|
+
contact['Contact Information']['First Name'].should == 'prashant'
|
129
|
+
contact['Contact Information']['Last Name'].should == 'nadarajan'
|
130
|
+
contact['Contact Information']['E-Mail'].should == 'prashant@example.com'
|
131
|
+
contact['Lead Information']['Contact Owner'].should == 'Don Corleone'
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
context "when the results contain more than one contact" do
|
137
|
+
it "returns an array containing the contacts" do
|
138
|
+
contacts = @client.send(:parse_contacts_xml, test_data('contacts_search_multiple_response.xml'))
|
139
|
+
|
140
|
+
contacts.size.should == 3
|
141
|
+
|
142
|
+
contacts[0]['id'].should == '8'
|
143
|
+
contacts[0]['Contact Information']['E-Mail'].should == 'bobby@example.com'
|
144
|
+
contacts[0]['Lead Information']['Contact Owner'].should == 'Jimbo Watunusi'
|
145
|
+
|
146
|
+
contacts[1]['id'].should == '5'
|
147
|
+
contacts[1]['Contact Information']['E-Mail'].should == 'ali@example.com'
|
148
|
+
contacts[1]['Lead Information']['Contact Owner'].should == 'Jimbo Watunusi'
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
describe "#contacts_add" do
|
154
|
+
it "returns the newly created contact" do
|
155
|
+
contact_options = {
|
156
|
+
'Contact Information' => {'First Name' => 'prashant', 'Last Name' => 'nadarajan', 'E-Mail' => 'prashant@example.com'},
|
157
|
+
'Lead Information' => {'Contact Owner' => 'Don Corleone'}
|
158
|
+
}
|
159
|
+
|
160
|
+
request_contact_xml = @client.send(:xml_for_contact, contact_options)
|
161
|
+
response_contact_xml = test_data('contacts_add_response.xml')
|
162
|
+
|
163
|
+
request_body = request_body('add', 'return_id' => '1', 'data' => request_contact_xml)
|
164
|
+
stub_request(:post, @contact_endpoint).with(:body => request_body).to_return(:body => response_contact_xml)
|
165
|
+
|
166
|
+
contact = @client.contacts_add(contact_options)
|
167
|
+
WebMock.should have_requested(:post, @contact_endpoint).with(:body => request_body)
|
168
|
+
|
169
|
+
contact['id'].should == '7'
|
170
|
+
contact['Contact Information']['First Name'].should == 'prashant'
|
171
|
+
contact['Contact Information']['Last Name'].should == 'nadarajan'
|
172
|
+
contact['Contact Information']['E-Mail'].should == 'prashant@example.com'
|
173
|
+
contact['Lead Information']['Contact Owner'].should == 'Don Corleone'
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
describe "#contacts_pull_tag" do
|
178
|
+
it "returns all the contact tag names and ids" do
|
179
|
+
pull_tags_xml = test_data('contacts_pull_tags.xml')
|
180
|
+
stub_request(:post, @contact_endpoint).with(:body => request_body('pull_tag')).to_return(:body => pull_tags_xml)
|
181
|
+
|
182
|
+
tags = @client.contacts_pull_tag
|
183
|
+
tags['3'].should == 'newleads'
|
184
|
+
tags['4'].should == 'old_leads'
|
185
|
+
tags['5'].should == 'legacy Leads'
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
describe "#contacts_fetch_sequences" do
|
190
|
+
it "returns all the available contact sequences" do
|
191
|
+
xml = test_data('contacts_fetch_sequences.xml')
|
192
|
+
stub_request(:post, @contact_endpoint).with(:body => request_body('fetch_sequences')).to_return(:body => xml)
|
193
|
+
sequences = @client.contacts_fetch_sequences
|
194
|
+
sequences['3'].should == 'APPOINTMENT REMINDER'
|
195
|
+
sequences['4'].should == 'foo sequence'
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
describe "#contacts_key" do
|
200
|
+
it "returns information on the contact data structure" do
|
201
|
+
xml = test_data('contacts_key_type.xml')
|
202
|
+
stub_request(:post, @contact_endpoint).with(:body => request_body('key')).to_return(:body => xml)
|
203
|
+
|
204
|
+
result = @client.contacts_key
|
205
|
+
result["Contact Information"]["editable"].should be_false
|
206
|
+
result["Contact Information"]["fields"]["Cell Phone"]["editable"].should be_false
|
207
|
+
result["Contact Information"]["fields"]["Cell Phone"]["type"].should == "phone"
|
208
|
+
result["Contact Information"]["fields"]["Birthday"]["type"].should == "fulldate"
|
209
|
+
|
210
|
+
result["Lead Information"]["fields"]["Lead Source"]["type"].should == "tdrop"
|
211
|
+
result["Lead Information"]["fields"]["Lead Source"]["options"][0].should == "Adwords"
|
212
|
+
result["Lead Information"]["fields"]["Lead Source"]["options"][4].should == "Newspaper Ad"
|
213
|
+
|
214
|
+
result["Sequences and Tags"]["fields"]["Contact Tags"]["type"].should == "list"
|
215
|
+
result["Sequences and Tags"]["fields"]["Contact Tags"]["list"]["5"].should == "legacy Leads"
|
216
|
+
|
217
|
+
result["PrecisoPro"]["editable"].should be_true
|
218
|
+
result["PrecisoPro"]["fields"]["Lead Status"]["editable"].should be_true
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
describe "#contacts_fetch" do
|
223
|
+
context "when all the ids exists" do
|
224
|
+
it "returns the contacts" do
|
225
|
+
xml_response = test_data('contacts_search_multiple_response.xml')
|
226
|
+
xml_request = "<contact_id>8</contact_id><contact_id>5</contact_id><contact_id>7</contact_id>"
|
227
|
+
stub_request(:post, @contact_endpoint).with(:body => request_body('fetch', 'data' => xml_request )).to_return(:body => xml_response)
|
228
|
+
|
229
|
+
results = @client.contacts_fetch([8, 5, 7])
|
230
|
+
results.size.should == 3
|
231
|
+
results[0]["Contact Information"].should_not be_nil
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
context "when some of the ids don't exist" do
|
236
|
+
pending
|
237
|
+
end
|
238
|
+
|
239
|
+
context "when all the ids don't exist" do
|
240
|
+
pending
|
241
|
+
end
|
242
|
+
end
|
243
|
+
end
|