exact-target 0.0.4
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/CHANGELOG +4 -0
- data/LICENSE +481 -0
- data/Manifest +22 -0
- data/README.rdoc +170 -0
- data/Rakefile +40 -0
- data/exact-target.gemspec +32 -0
- data/lib/exact_target.rb +109 -0
- data/lib/exact_target/builder_ext.rb +11 -0
- data/lib/exact_target/configuration.rb +42 -0
- data/lib/exact_target/error.rb +16 -0
- data/lib/exact_target/net_https_hack.rb +8 -0
- data/lib/exact_target/request_builder.rb +284 -0
- data/lib/exact_target/response_class.erb +30 -0
- data/lib/exact_target/response_classes.rb +61 -0
- data/lib/exact_target/response_handler.rb +167 -0
- data/lib/exact_target/string_ext.rb +22 -0
- data/spec/exact_target/net_https_hack_spec.rb +8 -0
- data/spec/exact_target/response_handler_spec.rb +15 -0
- data/spec/exact_target/string_ext_spec.rb +13 -0
- data/spec/exact_target_data.yml +133 -0
- data/spec/exact_target_spec.rb +382 -0
- data/spec/spec.opts +4 -0
- data/spec/subscriber_list_spec.rb +290 -0
- metadata +95 -0
data/spec/spec.opts
ADDED
@@ -0,0 +1,290 @@
|
|
1
|
+
=begin
|
2
|
+
require 'exact_target'
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
describe ExactTarget::SubscriberList do
|
6
|
+
|
7
|
+
@example_subscriber = Proc.new do
|
8
|
+
ExactTarget::Subscriber.new.tap do |sub|
|
9
|
+
sub.email_address = 'someone@somehwere.com'
|
10
|
+
sub.status = 'active'
|
11
|
+
sub.email_type = 'HTML'
|
12
|
+
sub.first_name = 'Some'
|
13
|
+
sub.last_name = 'One'
|
14
|
+
sub.title = 'Director of HR'
|
15
|
+
sub.region = 'Midwest'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
ExactTarget::SubscriberList.find_ids('epub test').should == [42, 47]
|
20
|
+
|
21
|
+
ExactTarget::SubscriberList.find(:all, 'epub test').should == [@example_subscriber_list_42, @example_subscriber_list_47]
|
22
|
+
ExactTarget::SubscriberList.find(:first, 'epub test').should == @example_subscriber_list_42
|
23
|
+
ExactTarget::SubscriberList.find(:last, 'epub test').should == @example_subscriber_list_47
|
24
|
+
|
25
|
+
ExactTarget::SubscriberList.find(42).should == @example_subscriber_list_42
|
26
|
+
|
27
|
+
ExactTarget::SubscriberList.new('Epub Test').tap { |li| li.save.should_not raise_error }.id.should == 53
|
28
|
+
|
29
|
+
@example_subscriber_list_42.tap { |li| li.name = 'Epub Test - RENAME' }.save.should be_true
|
30
|
+
|
31
|
+
ExactTarget::SubscriberList.import_all([72, 33, 99], 'sometestfile.txt', %w(some_field other_field), :email_address => 'confirm_result@nowhere.com').should == 841
|
32
|
+
|
33
|
+
@example_subscriber_list_42.import('sometestfile.txt', %w(some_field other_field), :email_address => 'confirm_result@nowhere.com').should == 841
|
34
|
+
|
35
|
+
ExactTarget::SubscriberList.import_status(119792).should == 'Complete'
|
36
|
+
|
37
|
+
@example_subscriber_list_42.subscribers(:status => 'Active').should == [@example_subscriber_94, @example_subscriber_99]
|
38
|
+
|
39
|
+
@example_subscriber_list_42.delete.should_not raise_error
|
40
|
+
|
41
|
+
@example_subscriber_
|
42
|
+
|
43
|
+
test_et :list_retrievegroups do
|
44
|
+
@res.size.should == 2
|
45
|
+
|
46
|
+
@res = @res.last
|
47
|
+
@res.should be_a(ExactTarget::ListGroupInformation)
|
48
|
+
@res.group_id.should == 875
|
49
|
+
@res.parentlist_id.should == 77
|
50
|
+
@res.description.should == "test desc"
|
51
|
+
@res.group_name.should == "test group"
|
52
|
+
@res.to_s.should == "test group"
|
53
|
+
end
|
54
|
+
|
55
|
+
test_et :list_refresh_group, 3514 do
|
56
|
+
@res.should == 6127
|
57
|
+
end
|
58
|
+
|
59
|
+
test_et :batch_inquire, 8912 do
|
60
|
+
@res.should == 'Completed'
|
61
|
+
end
|
62
|
+
|
63
|
+
#################################################################
|
64
|
+
|
65
|
+
test_et :subscriber_add, 1234, @example_subscriber, :status => 'active', :ChannelMemberID => 5678 do
|
66
|
+
@res.should == 12334566
|
67
|
+
end
|
68
|
+
|
69
|
+
test_et :subscriber_edit, 63718, 'user@email.com', @example_subscriber,
|
70
|
+
:status => 'unsub',
|
71
|
+
:reason => 'insert your unsubscribe reason here',
|
72
|
+
:ChannelMemberID => 5678 do
|
73
|
+
@res.should == 12334566
|
74
|
+
end
|
75
|
+
|
76
|
+
test_et :subscriber_retrieve, 123456, 'someone@example.com' do
|
77
|
+
@res.size.should == 1
|
78
|
+
|
79
|
+
@res = @res.last
|
80
|
+
@res.should be_a(ExactTarget::SubscriberInformation)
|
81
|
+
@res.subid.should == 125704849
|
82
|
+
@res.listid.should == 63718
|
83
|
+
@res.list_name.should == 'Newsletter List'
|
84
|
+
|
85
|
+
@res = @res.subscriber
|
86
|
+
@res.email_address.should == "jdoe@example.com"
|
87
|
+
@res.first_name.should == "John"
|
88
|
+
@res.region.should == ""
|
89
|
+
@res.email_type.should == "HTML"
|
90
|
+
@res.title.should == ""
|
91
|
+
@res.status.should == "Active"
|
92
|
+
@res.last_name.should == "Doe"
|
93
|
+
end
|
94
|
+
|
95
|
+
test_et :subscriber_retrieve, 123456789 do
|
96
|
+
@res.size.should == 2
|
97
|
+
|
98
|
+
@res = @res.last
|
99
|
+
@res.should be_a(ExactTarget::SubscriberInformation)
|
100
|
+
@res.subid.should == 125504849
|
101
|
+
@res.listid.should == 63719
|
102
|
+
@res.list_name.should == 'TechnologyUpdate'
|
103
|
+
|
104
|
+
@res = @res.subscriber
|
105
|
+
@res.email_address.should == "jdoe@example.com"
|
106
|
+
@res.first_name.should == "John"
|
107
|
+
@res.region.should == ""
|
108
|
+
@res.email_type.should == "HTML"
|
109
|
+
@res.title.should == ""
|
110
|
+
@res.status.should == "Active"
|
111
|
+
@res.last_name.should == "Doe"
|
112
|
+
end
|
113
|
+
|
114
|
+
test_et :subscriber_delete, 112233445566, 'bob@hotmail.com' do
|
115
|
+
@res.should be_true
|
116
|
+
end
|
117
|
+
|
118
|
+
test_et :subscriber_delete, 112233445566 do
|
119
|
+
@res.should be_true
|
120
|
+
end
|
121
|
+
|
122
|
+
test_et :subscriber_masterunsub,
|
123
|
+
%w(Email1@example.com Email2@example.com Email3@example.com) do
|
124
|
+
@res.size.should == 3
|
125
|
+
(1..3).each do |i|
|
126
|
+
@res["Email#{i}@example.com"].should == "masterunsub"
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
#################################################################
|
131
|
+
|
132
|
+
test_et :email_retrieve do
|
133
|
+
verify_email_retrieve
|
134
|
+
end
|
135
|
+
|
136
|
+
test_et :email_retrieve, 'Welcome to Fortune One!' do
|
137
|
+
verify_email_retrieve
|
138
|
+
end
|
139
|
+
|
140
|
+
test_et :email_retrieve, :start_date => Date.parse('2008-09-15'),
|
141
|
+
:end_date => Date.parse('2008-10-15') do
|
142
|
+
verify_email_retrieve
|
143
|
+
end
|
144
|
+
|
145
|
+
test_et :email_retrieve, 'Welcome to Fortune One!',
|
146
|
+
:start_date => Date.parse('2008-09-15'),
|
147
|
+
:end_date => Date.parse('2008-10-15') do
|
148
|
+
verify_email_retrieve
|
149
|
+
end
|
150
|
+
|
151
|
+
def verify_email_retrieve
|
152
|
+
@res.size.should == 3
|
153
|
+
|
154
|
+
@res = @res.last
|
155
|
+
@res.emailid.should == 205449
|
156
|
+
@res.emailname.should == 'ET 04 Demo Email'
|
157
|
+
@res.emailsubject.should == 'ET 04 Demo Email'
|
158
|
+
@res.emailcreateddate.should == Date.parse('2004-03-19')
|
159
|
+
@res.categoryid.should == 75163
|
160
|
+
@res.to_s.should == 'ET 04 Demo Email'
|
161
|
+
end
|
162
|
+
|
163
|
+
test_et :email_add, 'Your body email name',
|
164
|
+
'Your email subject line',
|
165
|
+
:body => 'Your HTML email body' do
|
166
|
+
@res.should == 44180
|
167
|
+
end
|
168
|
+
|
169
|
+
test_et :email_add, 'Your file email name',
|
170
|
+
'Your email subject line',
|
171
|
+
:file => 'Filename' do
|
172
|
+
@res.should == 44180
|
173
|
+
end
|
174
|
+
|
175
|
+
test_et :email_add_text, 155324, :body => 'Your text email body' do
|
176
|
+
@res.should be_true
|
177
|
+
end
|
178
|
+
|
179
|
+
test_et :email_add_text, 155325, :file => 'Filename' do
|
180
|
+
@res.should be_true
|
181
|
+
end
|
182
|
+
|
183
|
+
test_et :email_retrieve_body, 12344556 do
|
184
|
+
@res.should == '<h1>...BODY...</h1>'
|
185
|
+
end
|
186
|
+
|
187
|
+
#################################################################
|
188
|
+
|
189
|
+
test_et :job_send, 112233, [12345, 12346],
|
190
|
+
:suppress_ids => 35612,
|
191
|
+
:from_name => 'FrName',
|
192
|
+
:from_email => 'fr.email@nowhere.com',
|
193
|
+
:additional => 'addit',
|
194
|
+
:multipart_mime => true,
|
195
|
+
:track_links => false,
|
196
|
+
:send_date => '5/3/2011',
|
197
|
+
:send_time => '17:35',
|
198
|
+
:test_send => true do
|
199
|
+
@res.should == 2030602
|
200
|
+
end
|
201
|
+
|
202
|
+
specify "job_send with error" do
|
203
|
+
expect do
|
204
|
+
et_request :job_send, [:BOGUS, nil, nil], "job send with error"
|
205
|
+
end.should raise_error(
|
206
|
+
ExactTarget::Error,
|
207
|
+
'ExactTarget error #68: File does not exist.'
|
208
|
+
)
|
209
|
+
end
|
210
|
+
|
211
|
+
#################################################################
|
212
|
+
|
213
|
+
context :send_to_exact_target do
|
214
|
+
before(:each) do
|
215
|
+
@path = '/foo?qf=xml&xml=%3Csomexml/%3E'
|
216
|
+
@http = mock('Net::HTTP')
|
217
|
+
@http.should_receive(:use_ssl=).with(true)
|
218
|
+
@http.should_receive(:open_timeout=).with(2)
|
219
|
+
@http.should_receive(:read_timeout=).with(5)
|
220
|
+
Net::HTTP.should_receive(:new).with('base.url.com', 443).and_return(@http)
|
221
|
+
end
|
222
|
+
|
223
|
+
specify :success do
|
224
|
+
resp = stub('Net::HTTPSuccess', :is_a? => true, :body => 'xyz')
|
225
|
+
@http.should_receive(:get).with(@path).and_return(resp)
|
226
|
+
ExactTarget.send_to_exact_target('<somexml/>').should == 'xyz'
|
227
|
+
end
|
228
|
+
|
229
|
+
specify :error do
|
230
|
+
resp = stub('Net::HTTPFailure', :error! => 'err')
|
231
|
+
@http.should_receive(:get).with(@path).and_return(resp)
|
232
|
+
ExactTarget.send_to_exact_target('<somexml/>').should == 'err'
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
specify "method_missing should throw normal error when bogus method" do
|
237
|
+
expect { ExactTarget.bogus }.should raise_error
|
238
|
+
end
|
239
|
+
|
240
|
+
#################################################################
|
241
|
+
|
242
|
+
private
|
243
|
+
|
244
|
+
def et_request(method, args, desc)
|
245
|
+
request, response = et_xml(method, args, desc)
|
246
|
+
request = <<-END.gsub(/>\s+</m, '><').strip
|
247
|
+
<?xml version="1.0"?>
|
248
|
+
<exacttarget>
|
249
|
+
<authorization>
|
250
|
+
<username>a_user</username>
|
251
|
+
<password>a_pass</password>
|
252
|
+
</authorization>
|
253
|
+
<system>
|
254
|
+
#{request}
|
255
|
+
</system>
|
256
|
+
</exacttarget>
|
257
|
+
END
|
258
|
+
response = <<-END.gsub(/>\s+</m, '><').strip
|
259
|
+
<?xml version='1.0'?>
|
260
|
+
<exacttarget>
|
261
|
+
<system>
|
262
|
+
#{response}
|
263
|
+
</system>
|
264
|
+
</exacttarget>
|
265
|
+
END
|
266
|
+
@logger.should_receive(:debug).twice
|
267
|
+
ExactTarget.should_receive(:send_to_exact_target).with(request).and_return(response)
|
268
|
+
unless method == :accountinfo_retrieve_attrbs
|
269
|
+
ExactTarget.stub :accountinfo_retrieve_attrbs => @atts
|
270
|
+
end
|
271
|
+
ExactTarget.send(method, *args)
|
272
|
+
end
|
273
|
+
|
274
|
+
def et_xml(method, args, desc)
|
275
|
+
xml = @xml[method.to_s] || {}
|
276
|
+
args = args.map { |a| a.is_a?(Hash) ? 'HASH' : a }
|
277
|
+
if args.size == 1 and xml.has_key?(k = args.first)
|
278
|
+
xml = xml[k]
|
279
|
+
elsif xml.has_key?(k = args.join(', '))
|
280
|
+
xml = xml[k]
|
281
|
+
elsif xml.has_key?(k = args.hash)
|
282
|
+
xml = xml[k]
|
283
|
+
end
|
284
|
+
%w(request response).map do |k|
|
285
|
+
xml[k] or raise "Can not determine #{k} xml for #{desc}"
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
289
|
+
end
|
290
|
+
=end
|
metadata
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: exact-target
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 4
|
9
|
+
version: 0.0.4
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- David McCullars
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-04-11 00:00:00 -04:00
|
18
|
+
default_executable:
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: |
|
22
|
+
This is a pure-ruby implementation of the ExactTarget api.
|
23
|
+
For more information consule http://www.exacttarget.com/.
|
24
|
+
|
25
|
+
email: dmccullars@ePublishing.com
|
26
|
+
executables: []
|
27
|
+
|
28
|
+
extensions: []
|
29
|
+
|
30
|
+
extra_rdoc_files:
|
31
|
+
- CHANGELOG
|
32
|
+
- LICENSE
|
33
|
+
- README.rdoc
|
34
|
+
files:
|
35
|
+
- CHANGELOG
|
36
|
+
- LICENSE
|
37
|
+
- README.rdoc
|
38
|
+
- Rakefile
|
39
|
+
- lib/exact_target.rb
|
40
|
+
- lib/exact_target/builder_ext.rb
|
41
|
+
- lib/exact_target/configuration.rb
|
42
|
+
- lib/exact_target/error.rb
|
43
|
+
- lib/exact_target/net_https_hack.rb
|
44
|
+
- lib/exact_target/request_builder.rb
|
45
|
+
- lib/exact_target/response_class.erb
|
46
|
+
- lib/exact_target/response_classes.rb
|
47
|
+
- lib/exact_target/response_handler.rb
|
48
|
+
- lib/exact_target/string_ext.rb
|
49
|
+
- spec/exact_target/net_https_hack_spec.rb
|
50
|
+
- spec/exact_target/response_handler_spec.rb
|
51
|
+
- spec/exact_target/string_ext_spec.rb
|
52
|
+
- spec/exact_target_data.yml
|
53
|
+
- spec/exact_target_spec.rb
|
54
|
+
- spec/spec.opts
|
55
|
+
- spec/subscriber_list_spec.rb
|
56
|
+
- Manifest
|
57
|
+
- exact-target.gemspec
|
58
|
+
has_rdoc: true
|
59
|
+
homepage: http://github.com/ePublishing/exact_target
|
60
|
+
licenses: []
|
61
|
+
|
62
|
+
post_install_message:
|
63
|
+
rdoc_options:
|
64
|
+
- --line-numbers
|
65
|
+
- --inline-source
|
66
|
+
- --title
|
67
|
+
- Exact-target
|
68
|
+
- --main
|
69
|
+
- README.rdoc
|
70
|
+
require_paths:
|
71
|
+
- lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
segments:
|
77
|
+
- 0
|
78
|
+
version: "0"
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
segments:
|
84
|
+
- 1
|
85
|
+
- 2
|
86
|
+
version: "1.2"
|
87
|
+
requirements: []
|
88
|
+
|
89
|
+
rubyforge_project: exact-target
|
90
|
+
rubygems_version: 1.3.6
|
91
|
+
signing_key:
|
92
|
+
specification_version: 3
|
93
|
+
summary: This is a pure-ruby implementation of the ExactTarget api. For more information consule http://www.exacttarget.com/.
|
94
|
+
test_files: []
|
95
|
+
|